diff --git a/4dev/database/table/edit_access_data.sql b/4dev/database/table/edit_access_data.sql index ecadbedd..09ff02a8 100644 --- a/4dev/database/table/edit_access_data.sql +++ b/4dev/database/table/edit_access_data.sql @@ -11,6 +11,6 @@ CREATE TABLE edit_access_data ( edit_access_id INT NOT NULL, name VARCHAR, value VARCHAR, - enabled SMALLINT NOT NULL DEFAULT 0, - FOREIGN KEY (edit_access_id) REFERENCES edit_access (edit_access_id) MATCH FULL ON DELETE CASCADE ON UPDATE CASCADE + enabled SMALLINT NOT NULL DEFAULT 0, + FOREIGN KEY (edit_access_id) REFERENCES edit_access (edit_access_id) MATCH FULL ON DELETE CASCADE ON UPDATE CASCADE ) INHERITS (edit_generic) WITHOUT OIDS; diff --git a/4dev/sync/sync_template.sh b/4dev/sync/sync_template.sh index 0650adea..c48dbde3 100755 --- a/4dev/sync/sync_template.sh +++ b/4dev/sync/sync_template.sh @@ -1,12 +1,12 @@ #!/bin/bash # create path -path=`pwd`"/"$0; +path=$(pwd)"/"$0; LOCAL_BASE_DIR=""; LOCAL_DIR=$LOCAL_BASE_DIR""; REMOTE_WEB=""; -TARGET_HOST_WEB="@ +TARGET_HOST_WEB="@"; TMP_DIR=$LOCAL_BASE_DIR"/4dev/"; tmpf_web=$TMP_DIR"tmp.web"; diff --git a/www/libs/TRAIT_db_pgsql.inc b/4dev/update/20180322_db_interface/TRAIT_db_pgsql.inc similarity index 100% rename from www/libs/TRAIT_db_pgsql.inc rename to 4dev/update/20180322_db_interface/TRAIT_db_pgsql.inc diff --git a/www/libs/db_pgsql_pdo.inc b/4dev/update/20180322_db_interface/db_pgsql_pdo.inc similarity index 100% rename from www/libs/db_pgsql_pdo.inc rename to 4dev/update/20180322_db_interface/db_pgsql_pdo.inc diff --git a/4dev/update/20180323_namespace/comp_func.sh b/4dev/update/20180323_namespace/comp_func.sh new file mode 100755 index 00000000..bd3f96f4 --- /dev/null +++ b/4dev/update/20180323_namespace/comp_func.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +OIFS=${IFS}; +base_dir="/home/clemens/html/developers/clemens/core_data/php_libraries/trunk/"; +class_file="CoreLibs/Output/Form/Generate.inc"; +tmp_file=${base_dir}"4dev/tmp/tmp.comp."$(echo "${class_file}" | tr \/. _); +rpl_file=${base_dir}"4dev/tmp/tmp.rpl."$(echo "${class_file}" | tr \/. _); +rm -f "${tmp_file}"; +rm -f "${rpl_file}"; +if [ ! -f ${class_file} ]; +then + echo "Cannot find ${class_file} in current folder: $(pwd)"; + exit; +fi; +cat "${class_file}" | grep "WAS :" -B 1 | while read line; +do + # if method grep for function call + found=$(echo "${line}" | sed -e 's/^[ \t]*//' | grep "METHOD:"); + if [ -n "${found}" ]; + then + method=$(echo "${line}" | cut -d " " -f 3); + echo "1 MET: ${method}"; + # is method + if [ -n "${method}" ]; + then + # the full new call + new_function_call_full=$(grep "function ${method}(" "${class_file}" | grep "function" | sed -e 's/^[ \t]*//'); + # just the method name + new_function_call=$(echo "${new_function_call_full}" | sed -e 's/public //' | sed -e 's/private //' | sed -e 's/static //' | sed -e 's/function //' | cut -d "(" -f 1); + # check if func call is more than just alphanumeric (we don't need to redeclare those, functions are case insenstivie) + # + # only params (remove all = ... stuff) + new_function_call_params=$(echo "${new_function_call_full}" | cut -d "(" -f 2- | sed -e 's/)//'); + old_function_call_params=''; + IFS=','; + for el in ${new_function_call_params}; + do + if [ -n "${old_function_call_params}" ]; + then + old_function_call_params=${old_function_call_params}", "; + fi; + old_function_call_params=${old_function_call_params}$(echo "${el}" | cut -d "=" -f 1 | tr -d ' '); + done; + # cut -d "," "${new_function_call_params}" | while + fi; + fi; + # if this is a WAS + was=$(echo "${line}" | sed -e 's/^[ \t]*//' | grep "WAS :" | tr -s " "); + if [ -n "${was}" ]; + then + old_function_call=$(echo "${was}" | cut -d " " -f 4) + echo "2 OLD: ${old_function_call} => ${new_function_call} [${new_function_call_full}]"; + # for return write: + # rpl new -> old { new } + rpl=$(echo "${new_function_call_full}" | sed -e "s/${new_function_call}/${old_function_call}/"); + new_call="${rpl}\n"; + new_call=${new_call}"{\n"; + new_call=${new_call}"\terror_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']);\n"; + new_call=${new_call}"\treturn \$this->${new_function_call}(${old_function_call_params});\n"; + new_call=${new_call}"}\n"; + echo -e "${new_call}" >> "${tmp_file}"; + echo "3A RPL CALL: ${rpl}"; + echo "3B RPL CALL: return \$this->${new_function_call}(${old_function_call_params});"; + echo "4 SWT RPL : rpl '\$this->${old_function_call}' '\$this->${new_function_call}'"; + # write the replace calls for old $this->old_call to $this->new_call + echo "rpl '\$this->${old_function_call}' '\$this->${new_function_call}' ##TARGET_FILE##" >> "${rpl_file}"; + echo "----"; + fi; +done; +IFS=${OIFS}; + +# __END__ diff --git a/4dev/update/20180323_namespace/rpl_old_method_in_file.sh b/4dev/update/20180323_namespace/rpl_old_method_in_file.sh new file mode 100755 index 00000000..dba24008 --- /dev/null +++ b/4dev/update/20180323_namespace/rpl_old_method_in_file.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +cat tmp.comp | while read i; +do + found=$(echo "${i}" | grep "function "); + if [ -n "${found}" ]; then + fk=$(echo "${i}" | cut -d " " -f 3 | cut -d "(" -f 1); + fi; + found=$(echo "${i}" | grep "\$this->"); + if [ -n "${found}" ]; then + # no to debug + found=$(echo "${i}" | grep "debug("); + if [ -z "${found}" ]; then + fk_n=$(echo "${i}" | cut -d "(" -f 1); + echo "rpl '\$this->${fk}' '${fk_n}' CoreLibs/DB/IO.inc"; + fi; + fi; +done; diff --git a/www/Smarty b/www/Smarty deleted file mode 120000 index da807799..00000000 --- a/www/Smarty +++ /dev/null @@ -1 +0,0 @@ -smarty-3.1.30 \ No newline at end of file diff --git a/www/admin/Smarty b/www/admin/Smarty deleted file mode 120000 index 100a744c..00000000 --- a/www/admin/Smarty +++ /dev/null @@ -1 +0,0 @@ -../Smarty \ No newline at end of file diff --git a/www/admin/cache b/www/admin/cache deleted file mode 120000 index a32eef45..00000000 --- a/www/admin/cache +++ /dev/null @@ -1 +0,0 @@ -../cache/ \ No newline at end of file diff --git a/www/admin/class_test.php b/www/admin/class_test.php index b42094d3..db0d64c2 100644 --- a/www/admin/class_test.php +++ b/www/admin/class_test.php @@ -1,4 +1,4 @@ -db_info(1); +// set language for l10n +$lang = 'en_utf8'; +// init login & backend class +$login = new CoreLibs\ACL\Login($DB_CONFIG[LOGIN_DB], $lang); +$basic = new CoreLibs\Admin\Backend($DB_CONFIG[MAIN_DB], $lang); +$basic->dbInfo(1); +ob_end_flush(); // set + check edit access id $edit_access_id = 3; -print "ACL UNIT: ".print_r(array_keys($login->acl['unit']), 1)."
"; -print "ACCESS CHECK: ".$login->login_check_edit_access($edit_access_id)."
"; -if ($login->login_check_edit_access($edit_access_id)) { - $basic->edit_access_id = $edit_access_id; +if (array_key_exists('unit', $login->acl)) { + print "ACL UNIT: ".print_r(array_keys($login->acl['unit']), 1)."
"; + print "ACCESS CHECK: ".$login->loginCheckEditAccess($edit_access_id)."
"; + if ($login->loginCheckEditAccess($edit_access_id)) { + $basic->edit_access_id = $edit_access_id; + } else { + $basic->edit_access_id = $login->acl['unit_id']; + } } else { - $basic->edit_access_id = $login->acl['unit_id']; + print "Something went wrong with the login
"; } // $basic->debug('SESSION', $basic->print_ar($_SESSION)); @@ -59,12 +60,12 @@ print "DEBUG OUT ALL: ".$basic->debug_output_all."
"; print "ECHO OUT ALL: ".$basic->echo_output_all."
"; print "PRINT OUT ALL: ".$basic->print_output_all."
"; -print "CALLER BACKTRACE: ".$basic->get_caller_method()."
"; +print "CALLER BACKTRACE: ".$basic->getCallerMethod()."
"; $basic->debug('SOME MARK', 'Some error output'); print "EDIT ACCESS ID: ".$basic->edit_access_id."
"; // print "ACL:
".$basic->print_ar($login->acl)."
"; -$basic->debug('ACL', "ACL: ".$basic->print_ar($login->acl)); +$basic->debug('ACL', "ACL: ".$basic->printAr($login->acl)); // print "DEFAULT ACL:
".$basic->print_ar($login->default_acl_list)."
"; // print "DEFAULT ACL:
".$basic->print_ar($login->default_acl_list)."
"; // $result = array_flip(array_filter(array_flip($login->default_acl_list), function ($key) { if (is_numeric($key)) return $key; })); @@ -72,51 +73,54 @@ $basic->debug('ACL', "ACL: ".$basic->print_ar($login->acl)); // DEPRICATED CALL // $basic->adbSetACL($login->acl); -while ($res = $basic->db_return("SELECT * FROM max_test")) { +// DB client encoding +print "DB Client encoding: ".$basic->dbGetEncoding()."
"; + +while ($res = $basic->dbReturn("SELECT * FROM max_test")) { print "TIME: ".$res['time']."
"; } -$status = $basic->db_exec("INSERT INTO foo (test) VALUES ('FOO TEST ".time()."') RETURNING test"); +$status = $basic->dbExec("INSERT INTO foo (test) VALUES ('FOO TEST ".time()."') RETURNING test"); print "DIRECT INSERT STATUS: $status | PRIMARY KEY: ".$basic->insert_id." | PRIMARY KEY EXT: ".print_r($basic->insert_id_ext, 1)."
"; -print "DIRECT INSERT PREVIOUS INSERTED: ".print_r($basic->db_return_row("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), 1)."
"; -$basic->db_prepare("ins_foo", "INSERT INTO foo (test) VALUES ($1)"); -$status = $basic->db_execute("ins_foo", array('BAR TEST '.time())); +print "DIRECT INSERT PREVIOUS INSERTED: ".print_r($basic->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), 1)."
"; +$basic->dbPrepare("ins_foo", "INSERT INTO foo (test) VALUES ($1)"); +$status = $basic->dbExecute("ins_foo", array('BAR TEST '.time())); print "PREPARE INSERT STATUS: $status | PRIMARY KEY: ".$basic->insert_id." | PRIMARY KEY EXT: ".print_r($basic->insert_id_ext, 1)."
"; -print "PREPARE INSERT PREVIOUS INSERTED: ".print_r($basic->db_return_row("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), 1)."
"; +print "PREPARE INSERT PREVIOUS INSERTED: ".print_r($basic->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), 1)."
"; // returning test with multiple entries // $status = $basic->db_exec("INSERT INTO foo (test) values ('BAR 1 ".time()."'), ('BAR 2 ".time()."'), ('BAR 3 ".time()."') RETURNING foo_id"); -$status = $basic->db_exec("INSERT INTO foo (test) values ('BAR 1 ".time()."'), ('BAR 2 ".time()."'), ('BAR 3 ".time()."') RETURNING foo_id, test"); +$status = $basic->dbExec("INSERT INTO foo (test) values ('BAR 1 ".time()."'), ('BAR 2 ".time()."'), ('BAR 3 ".time()."') RETURNING foo_id, test"); print "DIRECT MULTIPLE INSERT STATUS: $status | PRIMARY KEYS: ".print_r($basic->insert_id, 1)." | PRIMARY KEY EXT: ".print_r($basic->insert_id_ext, 1)."
"; // no returning, but not needed ; -$status = $basic->db_exec("INSERT INTO foo (test) VALUES ('FOO; TEST ".time()."');"); +$status = $basic->dbExec("INSERT INTO foo (test) VALUES ('FOO; TEST ".time()."');"); print "DIRECT INSERT STATUS: $status | PRIMARY KEY: ".$basic->insert_id." | PRIMARY KEY EXT: ".print_r($basic->insert_id_ext, 1)."
"; # db write class test $table = 'foo'; -print "TABLE META DATA: ".$basic->print_ar($basic->db_show_table_meta_data($table))."
"; +print "TABLE META DATA: ".$basic->printAr($basic->dbShowTableMetaData($table))."
"; $primary_key = ''; # unset $db_write_table = array ('test', 'string_a', 'number_a', 'some_bool'); // $db_write_table = array ('test'); $object_fields_not_touch = array (); $object_fields_not_update = array (); $data = array ('test' => 'BOOL TEST SOMETHING '.time(), 'string_a' => 'SOME TEXT', 'number_a' => 5); -$primary_key = $basic->db_write_data_ext($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data); +$primary_key = $basic->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data); print "Wrote to DB tabel $table and got primary key $primary_key
"; $data = array ('test' => 'BOOL TEST ON '.time(), 'string_a' => '', 'number_a' => 0, 'some_bool' => 1); -$primary_key = $basic->db_write_data_ext($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data); +$primary_key = $basic->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data); print "Wrote to DB tabel $table and got primary key $primary_key
"; $data = array ('test' => 'BOOL TEST OFF '.time(), 'string_a' => null, 'number_a' => null, 'some_bool' => 0); -$primary_key = $basic->db_write_data_ext($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data); +$primary_key = $basic->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data); print "Wrote to DB tabel $table and got primary key $primary_key
"; $data = array ('test' => 'BOOL TEST UNSET '.time()); -$primary_key = $basic->db_write_data_ext($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data); +$primary_key = $basic->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data); print "Wrote to DB tabel $table and got primary key $primary_key
"; # async test queries -/* $basic->db_exec_async("SELECT test FROM foo, (SELECT pg_sleep(10)) as sub WHERE foo_id IN (27, 50, 67, 44, 10)"); +/* $basic->dbExecAsync("SELECT test FROM foo, (SELECT pg_sleep(10)) as sub WHERE foo_id IN (27, 50, 67, 44, 10)"); echo "WAITING FOR ASYNC: "; $chars = array('|', '/', '-', '\\'); -while (($ret = $basic->db_check_async()) === true) +while (($ret = $basic->dbCheckAsync()) === true) { if ((list($_, $char) = each($chars)) === FALSE) { @@ -128,37 +132,37 @@ while (($ret = $basic->db_check_async()) === true) flush(); } print "
END STATUS: ".$ret."
"; -// while ($res = $basic->db_fetch_array($ret)) -while ($res = $basic->db_fetch_array()) +// while ($res = $basic->dbFetchArray($ret)) +while ($res = $basic->dbFetchArray()) { echo "RES: ".$res['test']."
"; } # test async insert -$basic->db_exec_async("INSERT INTO foo (Test) VALUES ('ASYNC TEST ".time()."')"); +$basic->dbExecAsync("INSERT INTO foo (Test) VALUES ('ASYNC TEST ".time()."')"); echo "WAITING FOR ASYNC INSERT: "; -while (($ret = $basic->db_check_async()) === true) +while (($ret = $basic->dbCheckAsync()) === true) { print "."; sleep(1); flush(); } print "
END STATUS: ".$ret." | PK: ".$basic->insert_id."
"; -print "ASYNC PREVIOUS INSERTED: ".print_r($basic->db_return_row("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), 1)."
"; */ +print "ASYNC PREVIOUS INSERTED: ".print_r($basic->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), 1)."
"; */ $to_db_version = '9.1.9'; -print "VERSION DB: ".$basic->db_version()."
"; -print "DB Version smaller $to_db_version: ".$basic->db_compare_version('<'.$to_db_version)."
"; -print "DB Version smaller than $to_db_version: ".$basic->db_compare_version('<='.$to_db_version)."
"; -print "DB Version equal $to_db_version: ".$basic->db_compare_version('='.$to_db_version)."
"; -print "DB Version bigger than $to_db_version: ".$basic->db_compare_version('>='.$to_db_version)."
"; -print "DB Version bigger $to_db_version: ".$basic->db_compare_version('>'.$to_db_version)."
"; +print "VERSION DB: ".$basic->dbVersion()."
"; +print "DB Version smaller $to_db_version: ".$basic->dbCompareVersion('<'.$to_db_version)."
"; +print "DB Version smaller than $to_db_version: ".$basic->dbCompareVersion('<='.$to_db_version)."
"; +print "DB Version equal $to_db_version: ".$basic->dbCompareVersion('='.$to_db_version)."
"; +print "DB Version bigger than $to_db_version: ".$basic->dbCompareVersion('>='.$to_db_version)."
"; +print "DB Version bigger $to_db_version: ".$basic->dbCompareVersion('>'.$to_db_version)."
"; /* $q = "SELECT FOO FRO BAR"; // $q = "Select * from foo"; -$foo = $basic->db_exec_async($q); +$foo = $basic->dbExecAsync($q); print "[ERR] Query: ".$q."
"; print "[ERR] RESOURCE: $foo
"; -while (($ret = $basic->db_check_async()) === true) +while (($ret = $basic->dbCheckAsync()) === true) { print "[ERR]: $ret
"; // sleep(5); @@ -166,30 +170,33 @@ while (($ret = $basic->db_check_async()) === true) // search path check $q = "SHOW search_path"; -$cursor = $basic->db_exec($q); -$data = $basic->db_fetch_array($cursor)['search_path']; +$cursor = $basic->dbExec($q); +$data = $basic->dbFetchArray($cursor)['search_path']; print "RETURN DATA FOR search_path: ".$data."
"; -// print "RETURN DATA FOR search_path: ".$basic->print_ar($data)."
"; +// print "RETURN DATA FOR search_path: ".$basic->printAr($data)."
"; // insert something into test.schema_test and see if we get the PK back -$status = $basic->db_exec("INSERT INTO test.schema_test (contents, id) VALUES ('TIME: ".time()."', ".rand(1, 10).")"); +$status = $basic->dbExec("INSERT INTO test.schema_test (contents, id) VALUES ('TIME: ".time()."', ".rand(1, 10).")"); print "OTHER SCHEMA INSERT STATUS: ".$status." | PK NAME: ".$basic->pk_name.", PRIMARY KEY: ".$basic->insert_id."
"; // time string thest $timestamp = 5887998.33445; -$time_string = $basic->TimeStringFormat($timestamp); +$time_string = $basic->timeStringFormat($timestamp); print "TIME STRING TEST: ".$time_string."
"; -print "REVERSE TIME STRING: ".$basic->StringToTime($time_string); +print "REVERSE TIME STRING: ".$basic->stringToTime($time_string); // magic links test -print $basic->magic_links('user@bubu.at').'
'; -print $basic->magic_links('http://test.com/foo/bar.php?foo=1').'
'; +print $basic->magicLinks('user@bubu.at').'
'; +print $basic->magicLinks('http://test.com/foo/bar.php?foo=1').'
'; // compare date $date_1 = '2017/1/5'; $date_2 = '2017-01-05'; -print "COMPARE DATE: ".$basic->CompareDate($date_1, $date_2)."
"; +print "COMPARE DATE: ".$basic->compareDate($date_1, $date_2)."
"; // print error messages -print $basic->print_error_msg(); +print $login->printErrorMsg(); +print $basic->printErrorMsg(); print ""; + +# __END__ diff --git a/www/admin/edit_base.inc b/www/admin/edit_base.inc index 62ee3d32..14bf0850 100644 --- a/www/admin/edit_base.inc +++ b/www/admin/edit_base.inc @@ -1,4 +1,4 @@ -db_exec("SET search_path TO ".LOGIN_DB_SCHEMA); +$form = new CoreLibs\Output\Form\Generate($DB_CONFIG[MAIN_DB], $lang); +$form->dbExec("SET search_path TO ".LOGIN_DB_SCHEMA); if ($form->mobile_phone) { echo "I am sorry, but this page cannot be viewed by a mobile phone"; exit; } // smarty template engine (extended Translation version) -$smarty = new SmartyML($lang); +$smarty = new CoreLibs\Template\SmartyExtend($lang); if (TARGET == 'live' || TARGET == 'remote') { // login @@ -98,7 +91,7 @@ function EditLog($event = '', $data = '') { $q = "INSERT INTO edit_log "; $q .= "(euid, event_date, ip, event, data, page) "; - $q .= "VALUES (".$_SESSION['EUID'].", NOW(), '".$_SERVER["REMOTE_ADDR"]."', '".$GLOBALS['form']->db_escape_string($event)."', '".$GLOBALS['form']->db_escape_string($data)."', '".$GLOBALS['form']->get_page_name()."')"; + $q .= "VALUES (".$_SESSION['EUID'].", NOW(), '".$_SERVER["REMOTE_ADDR"]."', '".$GLOBALS['form']->dbEscapeString($event)."', '".$GLOBALS['form']->dbEscapeString($data)."', '".$GLOBALS['form']->getPageName()."')"; } // log backend data @@ -112,11 +105,11 @@ $data = array ( // log action EditLog('Edit Submit', serialize($data)); -$form->form_procedure_load(${$form->archive_pk_name}); -$form->form_procedure_new(); -$form->form_procedure_save(); -$form->form_procedure_delete(); -$form->form_procedure_delete_from_element_list($element_list, $remove_name); +$form->formProcedureLoad(${$form->archive_pk_name}); +$form->formProcedureNew(); +$form->formProcedureSave(); +$form->formProcedureDelete(); +$form->formProcedureDeleteFromElementList($element_list, $remove_name); // define all needed smarty stuff for the general HTML/page building $HEADER['CSS'] = CSS; @@ -128,7 +121,7 @@ $HEADER['JAVASCRIPT'] = $EDIT_JAVASCRIPT; $DATA['table_width'] = $table_width; // write out error / status messages -$messages[] = $form->form_error_msg(); +$messages[] = $form->formPrintMsg(); $DATA['form_error_msg'] = $messages; // MENU START @@ -172,7 +165,7 @@ for ($i = 1; $i <= count($menuarray); $i ++) { if ($i == 1 || !(($i - 1) % $SPLIT_FACTOR)) { $menu_data[$j]['splitfactor_in'] = 1; } - if ($menuarray[($i - 1)]["filename"] == $form->get_page_name()) { + if ($menuarray[($i - 1)]["filename"] == $form->getPageName()) { $position = $i - 1; $menu_data[$j]['position'] = 1; } else { @@ -197,103 +190,103 @@ $L_TITLE = $DATA['page_name']; $HEADER['HTML_TITLE'] = ((!$L_TITLE) ? $form->l->__($G_TITLE) : $form->l->__($L_TITLE)); // END MENU // LOAD AND NEW -$DATA['load'] = $form->form_create_load(); -$DATA['new'] = $form->form_create_new(); +$DATA['load'] = $form->formCreateLoad(); +$DATA['new'] = $form->formCreateNew(); // SHOW DATA PART if ($form->yes) { $DATA['form_yes'] = $form->yes; $DATA['form_my_page_name'] = $form->my_page_name; - // depending on the "get_page_name()" I show different stuff + // depending on the "getPageName()" I show different stuff switch ($form->my_page_name) { case "edit_users": - $elements[] = $form->form_create_element("login_error_count"); - $elements[] = $form->form_create_element("login_error_date_last"); - $elements[] = $form->form_create_element("login_error_date_first"); - $elements[] = $form->form_create_element("enabled"); - $elements[] = $form->form_create_element("username"); - $elements[] = $form->form_create_element("password"); - $elements[] = $form->form_create_element("password_change_interval"); - $elements[] = $form->form_create_element("email"); - $elements[] = $form->form_create_element("last_name"); - $elements[] = $form->form_create_element("first_name"); - $elements[] = $form->form_create_element("edit_group_id"); - $elements[] = $form->form_create_element("edit_access_right_id"); - $elements[] = $form->form_create_element("strict"); - $elements[] = $form->form_create_element("locked"); - $elements[] = $form->form_create_element("admin"); - $elements[] = $form->form_create_element("debug"); - $elements[] = $form->form_create_element("db_debug"); - $elements[] = $form->form_create_element("edit_language_id"); - $elements[] = $form->form_create_element("edit_scheme_id"); - $elements[] = $form->form_show_list_table("edit_access_user"); + $elements[] = $form->formCreateElement("login_error_count"); + $elements[] = $form->formCreateElement("login_error_date_last"); + $elements[] = $form->formCreateElement("login_error_date_first"); + $elements[] = $form->formCreateElement("enabled"); + $elements[] = $form->formCreateElement("username"); + $elements[] = $form->formCreateElement("password"); + $elements[] = $form->formCreateElement("password_change_interval"); + $elements[] = $form->formCreateElement("email"); + $elements[] = $form->formCreateElement("last_name"); + $elements[] = $form->formCreateElement("first_name"); + $elements[] = $form->formCreateElement("edit_group_id"); + $elements[] = $form->formCreateElement("edit_access_right_id"); + $elements[] = $form->formCreateElement("strict"); + $elements[] = $form->formCreateElement("locked"); + $elements[] = $form->formCreateElement("admin"); + $elements[] = $form->formCreateElement("debug"); + $elements[] = $form->formCreateElement("db_debug"); + $elements[] = $form->formCreateElement("edit_language_id"); + $elements[] = $form->formCreateElement("edit_scheme_id"); + $elements[] = $form->formCreateElementListTable("edit_access_user"); break; case "edit_schemes": - $elements[] = $form->form_create_element("enabled"); - $elements[] = $form->form_create_element("name"); - $elements[] = $form->form_create_element("header_color"); - $elements[] = $form->form_create_element("template"); + $elements[] = $form->formCreateElement("enabled"); + $elements[] = $form->formCreateElement("name"); + $elements[] = $form->formCreateElement("header_color"); + $elements[] = $form->formCreateElement("template"); break; case "edit_pages": if (!$form->table_array["edit_page_id"]["value"]) { $q = "DELETE FROM temp_files"; - $form->db_exec($q); + $form->dbExec($q); // gets all files in the current dir ending with .php $crap = exec("ls *.php", $output, $status); // now get all that are NOT in de DB $q = "INSERT INTO temp_files VALUES "; for ($i = 0; $i < count($output); $i ++) { - $t_q = "('".$form->db_escape_string($output[$i])."')"; - $form->db_exec($q.$t_q, 'NULL'); + $t_q = "('".$form->dbEscapeString($output[$i])."')"; + $form->dbExec($q.$t_q, 'NULL'); } - $elements[] = $form->form_create_element("filename"); + $elements[] = $form->formCreateElement("filename"); } else { // show file menu // just show name of file ... $DATA['filename_exist'] = 1; $DATA['filename'] = $form->table_array["filename"]["value"]; } // File Name View IF - $elements[] = $form->form_create_element("name"); - // $elements[] = $form->form_create_element("tag"); - // $elements[] = $form->form_create_element("min_acl"); - $elements[] = $form->form_create_element("order_number"); - $elements[] = $form->form_create_element("online"); - $elements[] = $form->form_create_element("menu"); - $elements[] = $form->form_show_list_table("edit_query_string"); - $elements[] = $form->form_create_element("popup"); - $elements[] = $form->form_create_element("popup_x"); - $elements[] = $form->form_create_element("popup_y"); - $elements[] = $form->form_show_reference_table("edit_visible_group"); - $elements[] = $form->form_show_reference_table("edit_menu_group"); + $elements[] = $form->formCreateElement("name"); + // $elements[] = $form->formCreateElement("tag"); + // $elements[] = $form->formCreateElement("min_acl"); + $elements[] = $form->formCreateElement("order_number"); + $elements[] = $form->formCreateElement("online"); + $elements[] = $form->formCreateElement("menu"); + $elements[] = $form->formCreateElementListTable("edit_query_string"); + $elements[] = $form->formCreateElement("popup"); + $elements[] = $form->formCreateElement("popup_x"); + $elements[] = $form->formCreateElement("popup_y"); + $elements[] = $form->formCreateElementReferenceTable("edit_visible_group"); + $elements[] = $form->formCreateElementReferenceTable("edit_menu_group"); break; case "edit_languages": - $elements[] = $form->form_create_element("enabled"); - $elements[] = $form->form_create_element("short_name"); - $elements[] = $form->form_create_element("long_name"); - $elements[] = $form->form_create_element("iso_name"); + $elements[] = $form->formCreateElement("enabled"); + $elements[] = $form->formCreateElement("short_name"); + $elements[] = $form->formCreateElement("long_name"); + $elements[] = $form->formCreateElement("iso_name"); break; case "edit_groups": - $elements[] = $form->form_create_element("enabled"); - $elements[] = $form->form_create_element("name"); - $elements[] = $form->form_create_element("edit_access_right_id"); - $elements[] = $form->form_create_element("edit_scheme_id"); - $elements[] = $form->form_show_list_table("edit_page_access"); + $elements[] = $form->formCreateElement("enabled"); + $elements[] = $form->formCreateElement("name"); + $elements[] = $form->formCreateElement("edit_access_right_id"); + $elements[] = $form->formCreateElement("edit_scheme_id"); + $elements[] = $form->formCreateElementListTable("edit_page_access"); break; case "edit_visible_group": - $elements[] = $form->form_create_element("name"); - $elements[] = $form->form_create_element("flag"); + $elements[] = $form->formCreateElement("name"); + $elements[] = $form->formCreateElement("flag"); break; case "edit_menu_group": - $elements[] = $form->form_create_element("name"); - $elements[] = $form->form_create_element("flag"); - $elements[] = $form->form_create_element("order_number"); + $elements[] = $form->formCreateElement("name"); + $elements[] = $form->formCreateElement("flag"); + $elements[] = $form->formCreateElement("order_number"); break; case "edit_access": - $elements[] = $form->form_create_element("name"); - $elements[] = $form->form_create_element("color"); - $elements[] = $form->form_create_element("description"); + $elements[] = $form->formCreateElement("name"); + $elements[] = $form->formCreateElement("color"); + $elements[] = $form->formCreateElement("description"); // add name/value list here - $elements[] = $form->form_show_list_table("edit_access_data"); + $elements[] = $form->formCreateElementListTable("edit_access_data"); break; default: print "[No valid page definition given]"; @@ -301,8 +294,8 @@ if ($form->yes) { } // $form->debug('edit', "Elements:
".$form->print_ar($elements));
 	$DATA['elements'] = $elements;
-	$DATA['hidden'] = $form->form_create_hidden_fields();
-	$DATA['save_delete'] = $form->form_create_save_delete();
+	$DATA['hidden'] = $form->formCreateHiddenFields();
+	$DATA['save_delete'] = $form->formCreateSaveDelete();
 }
 
 // debug data, if DEBUG flag is on, this data is print out
@@ -314,11 +307,16 @@ $CONTENT_DATA = array_merge($HEADER, $DATA, $DEBUG_DATA);
 while (list($key, $value) = each($CONTENT_DATA)) {
 	$smarty->assign($key, $value);
 }
-
-//	$smarty->assign('popup_page', 'mt_popup_'.$body_part.'.tpl');
-
+if (is_dir(BASE.TEMPLATES_C)) {
+	$smarty->setCompileDir(BASE.TEMPLATES_C);
+}
+if (is_dir(BASE.CACHE)) {
+	$smarty->setCacheDir(BASE.CACHE);
+}
 $smarty->display('edit_body.tpl');
 
 // debug output
-echo $login->print_error_msg();
-echo $form->print_error_msg();
+echo $login->printErrorMsg();
+echo $form->printErrorMsg();
+
+# __END__
diff --git a/www/admin/edit_order.php b/www/admin/edit_order.php
index 822c5e3a..ec0b4543 100644
--- a/www/admin/edit_order.php
+++ b/www/admin/edit_order.php
@@ -1,209 +1,196 @@
-db_exec("SET search_path TO ".LOGIN_DB_SCHEMA);
-	$smarty = new SmartyML($lang);
-	if (TARGET == 'live' || TARGET == 'remote')
-	{
-		// login
-		$login->debug_output_all = DEBUG ? 1 : 0;
-		$login->echo_output_all = 0;
-		$login->print_output_all = DEBUG ? 1 : 0;
-		// form
-		$db->debug_output_all = DEBUG ? 1 : 0;
-		$db->echo_output_all = 0;
-		$db->print_output_all = DEBUG ? 1 : 0;
-	}
-	// set the template dir
-	if (defined('LAYOUT'))
-	{
-		$smarty->setTemplateDir(LAYOUT.DEFAULT_TEMPLATE.TEMPLATES);
-		$DATA['css'] = LAYOUT.DEFAULT_TEMPLATE.CSS;
-		$DATA['js'] = LAYOUT.DEFAULT_TEMPLATE.JS;
-	}
-	else
-	{
-		$smarty->setTemplateDir(TEMPLATES.DEFAULT_TEMPLATE);
-		$DATA['css'] = CSS.DEFAULT_TEMPLATE;
-		$DATA['js'] = JS.DEFAULT_TEMPLATE;
-	}
-
-	// order name is _always_ order_number for the edit interface
-
-	// follwing arrays do exist here:
-	// $position ... has the positions of the array (0..max), cause in a 
+//               I can't put an number into the array field, in this array,
+//               there are the POSITION stored, that should CHANGE there order (up/down)
+// $row_data_id ... has ALL ids from the sorting part
+// $row_data_order ... has ALL order positions from the soirting part
+if (count($position)) {
+	$original_id = $row_data_id;
 
-	// all the row data
-	$options_id = array();
-	$options_name = array();
-	$options_selected = array();
-	for ($i = 0; $i < count($row_data); $i ++)
-	{
-		$options_id[] = $i;
-		$options_name[] = $row_data[$i]["name"];
-		// list of points to order
-		for ($j = 0; $j < count($position); $j++)
-		{
-			// if matches, put into select array
-			if ($original_id[$position[$j]] == $row_data[$i]["id"])
-				$options_selected[] = $i;
+	// FIRST u have to put right sort, then read again ...
+	// hast to be >0 or the first one is selected and then there is no move
+	if ($up && $position[0] > 0) {
+		for ($i = 0; $i < count($position); $i++) {
+			// change position order
+			// this gets temp, id before that, gets actual (moves one "down")
+			// this gets the old before (moves one "up")
+			// is done for every element in row
+			// echo "A: ".$row_data_id[$position[$i]]." (".$row_data_order[$position[$i]].") -- ".$row_data_id[$position[$i]-1]." (".$row_data_order[$position[$i]-1].")
"; + $temp_id = $row_data_id[$position[$i]]; + $row_data_id[$position[$i]] = $row_data_id[$position[$i]-1]; + $row_data_id[$position[$i]-1] = $temp_id; + // echo "A: ".$row_data_id[$position[$i]]." (".$row_data_order[$position[$i]].") -- ".$row_data_id[$position[$i]-1]." (".$row_data_order[$position[$i]-1].")
"; + } // for + } // if up + + // the last position id from position array is not to be the count-1 of row_data_id array, or it is the last element + if ($down && ($position[count($position) - 1] != (count($row_data_id) - 1))) { + for ($i = count($position) - 1; $i >= 0; $i --) { + // same as up, just up in other way, starts from bottom (last element) and moves "up" + // element before actuel gets temp, this element, becomes element after this, + // element after this, gets this + $temp_id = $row_data_id[$position[$i] + 1]; + $row_data_id[$position[$i] + 1] = $row_data_id[$position[$i]]; + $row_data_id[$position[$i]] = $temp_id; + } // for + } // if down + + // write data ... (which has to be abstrackt ...) + if (($up && $position[0] > 0) || ($down && ($position[count($position) - 1]!=(count($row_data_id) - 1)))) { + for ($i = 0; $i < count($row_data_id); $i ++) { + $q = "UPDATE ".$table_name." SET order_number = ".$row_data_order[$i]." WHERE ".$table_name."_id = ".$row_data_id[$i]; + $q = $db->dbExec($q); + } // for all article ids ... + } // if write +} // if there is something to move + +// get ... +$q = "SELECT ".$table_name."_id, name, order_number FROM ".$table_name." "; +if ($where_string) { + $q .= "WHERE $where_string "; +} +$q .= "ORDER BY order_number"; + +while ($res = $db->dbReturn($q)) { + $row_data[] = array ( + "id" => $res[$table_name."_id"], + "name" => $res["name"], + "order" => $res["order_number"] + ); +} // while read data ... + +// define all needed smarty stuff for the general HTML/page building +$DATA['css'] = LAYOUT.DEFAULT_TEMPLATE.CSS; +$DATA['js'] = LAYOUT.DEFAULT_TEMPLATE.JS; +$HEADER['CSS'] = CSS; +$HEADER['DEFAULT_ENCODING'] = DEFAULT_ENCODING; +$HEADER['JS'] = JS; +$HEADER['STYLESHEET'] = $EDIT_STYLESHEET; +$HEADER['JAVASCRIPT'] = $EDIT_JAVASCRIPT; +// html title +$HEADER['HTML_TITLE'] = (!$L_TITLE) ? $smarty->l10n->__($G_TITLE) : $smarty->l10n->__($L_TITLE); + +$DATA['table_width'] = $table_width; + +// error msg +if ($error) { + $messages[] = array('msg' => $msg, 'class' => 'error', 'width' => $table_width); +} +$DATA['form_error_msg'] = $messages; + +// all the row data +$options_id = array(); +$options_name = array(); +$options_selected = array(); +for ($i = 0; $i < count($row_data); $i ++) { + $options_id[] = $i; + $options_name[] = $row_data[$i]["name"]; + // list of points to order + for ($j = 0; $j < count($position); $j++) { + // if matches, put into select array + if ($original_id[$position[$j]] == $row_data[$i]["id"]) { + $options_selected[] = $i; } } - $DATA['options_id'] = $options_id; - $DATA['options_name'] = $options_name; - $DATA['options_selected'] = $options_selected; +} +$DATA['options_id'] = $options_id; +$DATA['options_name'] = $options_name; +$DATA['options_selected'] = $options_selected; - // hidden list for the data (id, order number) - $row_data_id = array(); - $row_data_order = array(); - for ($i = 0; $i < count($row_data); $i++) - { - $row_data_id[] = $row_data[$i]["id"]; - $row_data_order[] = $row_data[$i]["order"]; - } - $DATA['row_data_id'] = $row_data_id; - $DATA['row_data_order'] = $row_data_order; +// hidden list for the data (id, order number) +$row_data_id = array(); +$row_data_order = array(); +for ($i = 0; $i < count($row_data); $i++) { + $row_data_id[] = $row_data[$i]["id"]; + $row_data_order[] = $row_data[$i]["order"]; +} +$DATA['row_data_id'] = $row_data_id; +$DATA['row_data_order'] = $row_data_order; - // hidden names for the table & where string - $DATA['table_name'] = $table_name; - $DATA['where_string'] = $where_string; +// hidden names for the table & where string +$DATA['table_name'] = $table_name; +$DATA['where_string'] = $where_string; - // debug data, if DEBUG flag is on, this data is print out - $DEBUG_DATA['DEBUG'] = $DEBUG_TMPL; +// debug data, if DEBUG flag is on, this data is print out +$DEBUG_DATA['DEBUG'] = $DEBUG_TMPL; - // create main data array - $CONTENT_DATA = array_merge($HEADER, $DATA, $DEBUG_DATA); - // data is 1:1 mapping (all vars, values, etc) - while (list($key, $value) = each($CONTENT_DATA)) - { - $smarty->assign($key, $value); - } - $smarty->display('edit_order.tpl'); +// create main data array +$CONTENT_DATA = array_merge($HEADER, $DATA, $DEBUG_DATA); +// data is 1:1 mapping (all vars, values, etc) +while (list($key, $value) = each($CONTENT_DATA)) { + $smarty->assign($key, $value); +} +$smarty->display('edit_order.tpl'); + +echo $login->printErrorMsg(); +echo $db->printErrorMsg(); + +# __END__ - echo $login->print_error_msg(); - echo $db->print_error_msg(); -?> diff --git a/www/admin/files.php b/www/admin/files.php index 0966d070..489fef2a 100644 --- a/www/admin/files.php +++ b/www/admin/files.php @@ -1,4 +1,4 @@ -action == 'save') { $file = DEV_SCHEMA."_".$file_uid; // now upload the file if ($_FILES['file_up']['name']) { - $upload_file = ROOT.MEDIA.$cms->data_path[$file_type].$file; + $upload_file = BASE.MEDIA.$cms->data_path[$file_type].$file; // wipe out any old tmp data for this new upload - if (is_array(glob(ROOT.TMP."thumb_".$file."*"))) { - foreach (glob(ROOT.TMP."thumb_".$file."*") as $filename) { + if (is_array(glob(BASE.TMP."thumb_".$file."*"))) { + foreach (glob(BASE.TMP."thumb_".$file."*") as $filename) { @unlink($filename); } } @@ -213,7 +213,7 @@ if ($cms->action == 'save') { $error = move_uploaded_file($_FILES['file_up']['tmp_name'], $upload_file); $cms->debug('file_upload', "UP: $upload_file"); - $cms->debug('file_upload', "Orig: ".$cms->print_ar($_FILES['file_up'])); + $cms->debug('file_upload', "Orig: ".$cms->printAr($_FILES['file_up'])); // because I get bogus error info from move_uploaded_file ... $error = 0; @@ -242,7 +242,7 @@ if ($cms->action == 'save') { } $q .= ") VALUES ('".$cms->queue_name."', '".$file_uid."', 'file_uid', '".$sql_action."', 'file', '".$cms->db_escape_string($sql_data)."', '".$cms->queue_key."', '".$cms->action."'"; if ($_FILES['file_up']['name']) { - $q .= ", '".ROOT.MEDIA.$cms->data_path[$file_type].$file."#".ROOT.MEDIA.$cms->data_path[$file_type].PUBLIC_SCHEMA."_".$file_uid."'"; + $q .= ", '".BASE.MEDIA.$cms->data_path[$file_type].$file."#".BASE.MEDIA.$cms->data_path[$file_type].PUBLIC_SCHEMA."_".$file_uid."'"; } $q .= ")"; $cms->db_exec($q); @@ -262,9 +262,9 @@ if ($cms->action == 'delete' && $cms->action_yes == 'true') { } if (QUEUE == 'live_queue') { $q = "INSERT INTO ".GLOBAL_DB_SCHEMA.".live_queue (queue_key, key_value, key_name, type, target, data, group_key, action, file) VALUES ("; - $q .= "'".$cms->queue_name."', '".$file_uid."', 'file_uid', 'DELETE', 'file', '', '".$cms->queue_key."', '".$cms->action."', '".ROOT.MEDIA.$cms->data_path[$file_type].PUBLIC_SCHEMA."_".$file_uid."')"; + $q .= "'".$cms->queue_name."', '".$file_uid."', 'file_uid', 'DELETE', 'file', '', '".$cms->queue_key."', '".$cms->action."', '".BASE.MEDIA.$cms->data_path[$file_type].PUBLIC_SCHEMA."_".$file_uid."')"; } - @unlink(ROOT.MEDIA.$cms->data_path[$file_type].DEV_SCHEMA."_".$file_uid); + @unlink(BASE.MEDIA.$cms->data_path[$file_type].DEV_SCHEMA."_".$file_uid); unset($file_uid); unset($file_id); $delete_done = 1; @@ -296,7 +296,7 @@ if ($cms->action_flag == 'set_live' && $cms->action = 'set_delete') { while ($res = $cms->db_return($q)) { $q_del = "DELETE FROM ".PUBLIC_SCHEMA.".file WHERE file_uid = '".$res['pkid'].'"'; $cms->db_exec($q_del); - @unlink(ROOT.MEDIA.$cms->data_path[$res['type']].PUBLIC_SCHEMA."_".$res['file_uid']); + @unlink(BASE.MEDIA.$cms->data_path[$res['type']].PUBLIC_SCHEMA."_".$res['file_uid']); } $q = "DELETE FROM ".LOGIN_DB_SCHEMA.".set_live WHERE table_name = '".$cms->page_name."' AND delete_flag = 't'"; $cms->db_exec($q); diff --git a/www/admin/footer.inc b/www/admin/footer.inc index 058db58c..997bcfde 100644 --- a/www/admin/footer.inc +++ b/www/admin/footer.inc @@ -1,4 +1,4 @@ -print_error_msg(); -echo $cms->print_error_msg(); +echo $login->printErrorMsg(); +echo $cms->printErrorMsg(); diff --git a/www/admin/header.inc b/www/admin/header.inc index 3c2e5fb6..170019ec 100644 --- a/www/admin/header.inc +++ b/www/admin/header.inc @@ -1,4 +1,4 @@ -db_exec("SET search_path TO ".DB_SCHEMA); +$cms = new CoreLibs\Admin\Backend($DB_CONFIG[MAIN_DB], $lang); // the menu show flag (what menu to show) $cms->menu_show_flag = 'main'; // db nfo -$cms->db_info(); +$cms->dbInfo(); // set acl $cms->acl = $login->acl; //------------------------------ class init end diff --git a/www/admin/libs b/www/admin/libs deleted file mode 120000 index a48a2d68..00000000 --- a/www/admin/libs +++ /dev/null @@ -1 +0,0 @@ -../libs/ \ No newline at end of file diff --git a/www/admin/log b/www/admin/log deleted file mode 120000 index 3355f402..00000000 --- a/www/admin/log +++ /dev/null @@ -1 +0,0 @@ -../log/ \ No newline at end of file diff --git a/www/admin/namespace_test.php b/www/admin/namespace_test.php new file mode 100755 index 00000000..6e11a07e --- /dev/null +++ b/www/admin/namespace_test.php @@ -0,0 +1,42 @@ +ROOT: ".ROOT."
BASE: ".BASE."
"; + +$lang = 'ja_utf8'; +$base = new CoreLibs\Admin\Backend($DB_CONFIG[MAIN_DB], $lang); +ob_end_flush(); + +print "Start time: ".$base->runningTime()."
"; +print "ByteStringFormat: ".$base->ByteStringFormat(1234567.12)."
"; +print "byteStringFormat: ".$base->byteStringFormat(1234567.12)."
"; +print "get_page_name [DEPRECATED]: ".$base->get_page_name()."
"; +print "getPageName: ".$base->getPageName()."
"; + +print "DB Info: ".$base->dbInfo(1)."
"; + + +print "End Time: ".$base->runningTime()."
"; +print "Run Time: ".$base->runningTime()."
"; +$base->resetRunningtime(); + +print "Lang: ".$base->l->__getLang().", MO File: ".$base->l->__getMoFile()."
"; +print "Translate test: Year -> ".$base->l->__('Year')."
"; + +// end error print +print $base->printErrorMsg(); + +# __END__ diff --git a/www/admin/other_test.php b/www/admin/other_test.php new file mode 100755 index 00000000..777c61ff --- /dev/null +++ b/www/admin/other_test.php @@ -0,0 +1,23 @@ +foo = 'BAR'; + } + + public function otherBarBar($wrong) + { + echo "B: $wrong
"; + } + + public function barBar($wrong) + { + echo "B: $wrong
"; + } +} diff --git a/www/admin/set_paths.inc b/www/admin/set_paths.inc index 263bc3e7..192ecbb5 100644 --- a/www/admin/set_paths.inc +++ b/www/admin/set_paths.inc @@ -1,4 +1,4 @@ -page_name); $FORM_NAME = !isset($FORM_NAME) || !$FORM_NAME ? str_replace(".php", "", $cms->page_name) : $FORM_NAME; // set local page title -$L_TITLE = ucfirst(str_replace('_', ' ', $cms->get_page_name(1))).' - '.$G_TITLE; +$L_TITLE = ucfirst(str_replace('_', ' ', $cms->getPageName(1))).' - '.$G_TITLE; // strip tpl and replace it with inc // php include file per page $cms->INC_TEMPLATE_NAME = str_replace(".tpl", ".inc", $CONTENT_INCLUDE); @@ -55,13 +55,13 @@ $cms->CSS_SPECIAL_TEMPLATE_NAME = @$CSS_NAME; $cms->JS_SPECIAL_TEMPLATE_NAME = @$JS_NAME; // set basic template path (tmp) -$smarty->setTemplateDir(LAYOUT.$TEMPLATE_DIR.TEMPLATES.'/'); -$cms->lang_dir = LAYOUT.$TEMPLATE_DIR.LANG."/"; -$cms->includes = LAYOUT.$TEMPLATE_DIR.INCLUDES."/"; -$cms->javascript = LAYOUT.$TEMPLATE_DIR.JS."/"; -$cms->css = LAYOUT.$TEMPLATE_DIR.CSS."/"; -$cms->pictures = LAYOUT.$TEMPLATE_DIR.IMAGES."/"; -$cms->cache_pictures = LAYOUT.$TEMPLATE_DIR.CACHE.IMAGES.'/'; +$smarty->setTemplateDir(LAYOUT.$TEMPLATE_DIR.TEMPLATES); +$cms->lang_dir = LAYOUT.$TEMPLATE_DIR.LANG; +$cms->includes = LAYOUT.$TEMPLATE_DIR.INCLUDES; +$cms->javascript = LAYOUT.$TEMPLATE_DIR.JS; +$cms->css = LAYOUT.$TEMPLATE_DIR.CSS; +$cms->pictures = LAYOUT.$TEMPLATE_DIR.IMAGES; +$cms->cache_pictures = LAYOUT.$TEMPLATE_DIR.CACHE.IMAGES; $cms->cache_pictures_root = ROOT.$cms->cache_pictures; if (!is_dir($cms->cache_pictures_root)) { mkdir($cms->cache_pictures_root); @@ -69,13 +69,13 @@ if (!is_dir($cms->cache_pictures_root)) { $template_set = $TEMPLATE; // if we don't find the master template, set the template path back AND set the insert template as absolute path -if (!file_exists(ROOT.$smarty->getTemplateDir()[0]."/".MASTER_TEMPLATE_NAME)) { - if (file_exists(ROOT.$smarty->getTemplateDir()[0]."/".$TEMPLATE_NAME)) { - $TEMPLATE_NAME = ROOT.$smarty->getTemplateDir()[0]."/".$TEMPLATE_NAME; +if (!file_exists(ROOT.$smarty->getTemplateDir()[0].DS.MASTER_TEMPLATE_NAME)) { + if (file_exists(ROOT.$smarty->getTemplateDir()[0].DS.$TEMPLATE_NAME)) { + $TEMPLATE_NAME = ROOT.$smarty->getTemplateDir()[0].DS.$TEMPLATE_NAME; } $smarty->setTemplateDir(LAYOUT.DEFAULT_TEMPLATE.TEMPLATES); $template_set = DEFAULT_TEMPLATE; -} elseif (!file_exists(ROOT.$smarty->getTemplateDir()[0]."/".$TEMPLATE_NAME)) { +} elseif (!file_exists(ROOT.$smarty->getTemplateDir()[0].DS.$TEMPLATE_NAME)) { // check if the template exists in the template path, if not, set path to to default $smarty->setTemplateDir(LAYOUT.DEFAULT_TEMPLATE.TEMPLATES); $template_set = DEFAULT_TEMPLATE; @@ -85,25 +85,25 @@ if (!file_exists(ROOT.$smarty->getTemplateDir()[0]."/".MASTER_TEMPLATE_NAME)) { // check if the javascript folder exists in the template path, if not fall back to default if (!is_dir($cms->javascript)) { - $cms->javascript = LAYOUT.DEFAULT_TEMPLATE.JS."/"; + $cms->javascript = LAYOUT.DEFAULT_TEMPLATE.JS; } // check if lang_dir folder exists in the template path, if not fall back to default if (!is_dir($cms->lang_dir)) { - $cms->lang_dir = LAYOUT.DEFAULT_TEMPLATE.LANG."/"; + $cms->lang_dir = LAYOUT.DEFAULT_TEMPLATE.LANG; } // check if include folder exists in the template path, if not fall back to default if (!is_dir($cms->includes)) { - $cms->includes = LAYOUT.DEFAULT_TEMPLATE.INCLUDES."/"; + $cms->includes = LAYOUT.DEFAULT_TEMPLATE.INCLUDES; } // check if css folder exists in the template path, if not fall back to default if (!is_dir($cms->css)) { - $cms->css = LAYOUT.DEFAULT_TEMPLATE.CSS."/"; + $cms->css = LAYOUT.DEFAULT_TEMPLATE.CSS; } if (!is_dir($cms->pictures)) { - $cms->pictures = LAYOUT.DEFAULT_TEMPLATE.PICTURES.'/'; + $cms->pictures = LAYOUT.DEFAULT_TEMPLATE.PICTURES; } if (!is_dir($cms->cache_pictures)) { - $cms->cache_pictures = LAYOUT.DEFAULT_TEMPLATE.CACHE.IMAGES.'/'; + $cms->cache_pictures = LAYOUT.DEFAULT_TEMPLATE.CACHE.IMAGES; } // if the template_dir is != DEFAULT_TEMPLATE, then try to make a lang switch diff --git a/www/admin/smarty.inc b/www/admin/smarty.inc index 2cb730f3..b6b7707e 100644 --- a/www/admin/smarty.inc +++ b/www/admin/smarty.inc @@ -1,4 +1,4 @@ -DATA['LANG'] = $lang; $cms->DATA['TINYMCE_LANG'] = $lang_short; // debug data, if DEBUG flag is on, this data is print out -$cms->DEBUG_DATA['debug_error_msg'] = $cms->running_time(); +$cms->DEBUG_DATA['debug_error_msg'] = $cms->runningTime(); $cms->DEBUG_DATA['DEBUG'] = @$DEBUG_TMPL; // create main data array @@ -93,4 +93,10 @@ $cms->CONTENT_DATA = array_merge($cms->HEADER, $cms->DATA, $cms->DEBUG_DATA); while (list($key, $value) = each($cms->CONTENT_DATA)) { $smarty->assign($key, $value); } +if (is_dir(BASE.TEMPLATES_C)) { + $smarty->setCompileDir(BASE.TEMPLATES_C); +} +if (is_dir(BASE.CACHE)) { + $smarty->setCacheDir(BASE.CACHE); +} $smarty->display($MASTER_TEMPLATE_NAME, $TEMPLATE.$lang, $TEMPLATE.$lang); diff --git a/www/admin/smarty_test.php b/www/admin/smarty_test.php index f79455b5..702843f0 100644 --- a/www/admin/smarty_test.php +++ b/www/admin/smarty_test.php @@ -1,4 +1,4 @@ -); -// function that will be called on top of each class include to load the class -function _spl_autoload($include_file) -{ - // where to search for the files to include - $dirs = array ( - LIBDIR, - SMARTYDIR, - TABLEARRAYDIR, - '', - LIBS, - SMARTY, - TABLE_ARRAYS, - __DIR__.'/'.LIBS, - __DIR__.'/'.SMARTY - ); - // try to find and load the class ifle - foreach ($dirs as $folder) { - if (file_exists($folder.$include_file)) { - require_once($folder.$include_file); - return true; - } - } - return false; -} +// read auto loader +require BASE.LIB.'autoloader.php'; + +# __END__ diff --git a/www/layout/admin/default/lang/messages_en_utf8.po b/www/layout/admin/default/lang/messages_en_utf8.po index c8e836e7..fbfe06ce 100644 --- a/www/layout/admin/default/lang/messages_en_utf8.po +++ b/www/layout/admin/default/lang/messages_en_utf8.po @@ -10,11 +10,11 @@ msgid "" msgstr "" "Project-Id-Version: Project Version\n" -"Report-Msgid-Bugs-To: clemens.schwaighofer@e-graphics.com\n" -"POT-Creation-Date: 2005-08-09 09:26+0900\n" +"Report-Msgid-Bugs-To: clemens.schwaighofer@egplusww.com\n" +"POT-Creation-Date: 2018-03-28 10:40+0900\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: \n" -"Language-Team: E-GRAPHICS COMMUNICATIONS Japan \n" +"Language-Team: E-GRAPHICS COMMUNICATIONS Japan \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/www/layout/admin/default/lang/messages_ja_utf8.po b/www/layout/admin/default/lang/messages_ja_utf8.po index 36f8507b..6d0ae776 100644 --- a/www/layout/admin/default/lang/messages_ja_utf8.po +++ b/www/layout/admin/default/lang/messages_ja_utf8.po @@ -1,6 +1,6 @@ #******************************************************************** # AUTHOR: Clemens Schwaighofer -# CREATED: 2007/04/18 +# CREATED: 2018/03/28 # SHORT DESCRIPTION: # Backend Japanese Messages file for gettext # to craete: msgfmt -o ja.mo messages_ja.po @@ -10,14 +10,54 @@ msgid "" msgstr "" "Project-Id-Version: Project Version\n" -"Report-Msgid-Bugs-To: clemens.schwaighofer@e-graphics.com\n" -"POT-Creation-Date: 2007-04-18 17:40+0900\n" +"Report-Msgid-Bugs-To: clemens.schwaighofer@egplusww.com\n" +"POT-Creation-Date: 2018-03-28 10:40+0900\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: \n" -"Language-Team: E-GRAPHICS COMMUNICATIONS Japan \n" +"Language-Team: E-GRAPHICS COMMUNICATIONS Japan \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" msgid "Yes" -msgstr "" +msgstr "ã¯ã„" + +msgid "No" +msgstr "ã„ã„ãˆ" + +# Basic date info +msgid "Year" +msgstr "å¹´" + +msgid "Month" +msgstr "月" + +msgid "Day" +msgstr "æ—¥" + +msgid "Hour" +msgstr "時" + +msgid "Minute" +msgstr "分" + +msgid "Mon" +msgstr "月" + +msgid "Tue" +msgstr "ç«" + +msgid "Wed" +msgstr "æ°´" + +msgid "Thu" +msgstr "木" + +msgid "Fri" +msgstr "金" + +msgid "Sat" +msgstr "土" + +msgid "Sun" +msgstr "æ—¥" diff --git a/www/libs/Class.Login.inc b/www/lib/CoreLibs/ACL/Login.inc similarity index 86% rename from www/libs/Class.Login.inc rename to www/lib/CoreLibs/ACL/Login.inc index d19c20dd..32447cad 100644 --- a/www/libs/Class.Login.inc +++ b/www/lib/CoreLibs/ACL/Login.inc @@ -1,8 +1,8 @@ -log_per_class = 1; // create db connection and init base class - parent::__construct($db_config, $debug, $db_debug, $echo, $print); + if (!parent::__construct($db_config, $debug, $db_debug, $echo, $print)) { + echo "Could not connect to DB
"; + // if I can't connect to the DB to auth exit hard. No access allowed + exit; + } // no session could be found at all if (!session_id()) { @@ -100,14 +103,15 @@ class login extends db_io exit; } - // get the language sub class & init it - _spl_autoload('Class.l10n.inc'); - $this->l = new l10n($lang); + $this->l = new \CoreLibs\Language\L10n($lang); // if we have a search path we need to set it, to use the correct DB to login // check what schema to use. if there is a login schema use this, else check if there is a schema set in the config, or fall back to DB_SCHEMA if this exists, if this also does not exists use public schema $SCHEMA = defined('LOGIN_DB_SCHEMA') ? LOGIN_DB_SCHEMA : ($db_config['db_schema'] ? $db_config['db_schema'] : (defined('DB_SCHEMA') ? DB_SCHEMA : 'public')); - $this->db_exec("SET search_path TO ".$SCHEMA); + // set schema if schema differs to schema set in db conneciton + if ($this->dbGetSchema() && $this->dbGetSchema() != $SCHEMA) { + $this->dbExec("SET search_path TO ".$SCHEMA); + } $this->euid = array_key_exists('EUID', $_SESSION) ? $_SESSION['EUID'] : 0; // if there is none, there is none, saves me POST/GET check // get login vars, are so, can't be changed // prepare @@ -165,16 +169,16 @@ class login extends db_io // internal $this->class_info["login"] = array( "class_name" => "Login", - "class_version" => "4.0.0", + "class_version" => "5.0.0", "class_created" => "2000-06-01", - "class_author" => "cs/gullevek/at" + "class_author" => "Clemens Schwaighofer" ); // init default ACL list array $_SESSION['DEFAULT_ACL_LIST'] = array (); // read the current edit_access_right list into an array $q = "SELECT level, type, name FROM edit_access_right WHERE level >= 0 ORDER BY level"; - while ($res = $this->db_return($q)) { + while ($res = $this->dbReturn($q)) { // level to description format (numeric) $this->default_acl_list[$res['level']] = array ( 'type' => $res['type'], @@ -185,19 +189,19 @@ class login extends db_io $_SESSION['DEFAULT_ACL_LIST'] = $this->default_acl_list; // if username & password & !$euid start login - $this->login_login_user(); + $this->loginLoginUser(); // checks if $euid given check if user is okay for that side - $this->login_check_permissions(); + $this->loginCheckPermissions(); // logsout user - $this->login_logout_user(); + $this->loginLogoutUser(); // if the password change flag is okay, run the password change method if ($this->password_change) { - $this->login_password_change(); + $this->loginPasswordChange(); } // if !$euid || permission not okay, print login screan - echo $this->login_print_login(); + echo $this->loginPrintLogin(); // closing all connections, depending on error status, exit - if (!$this->login_close_class()) { + if (!$this->loginCloseClass()) { // do not go anywhere, quit processing here // do something with possible debug data? if (TARGET == 'live' || TARGET == 'remote') { @@ -206,14 +210,14 @@ class login extends db_io $this->echo_output_all = 0; $this->print_output_all = DEBUG ? 1 : 0; } - $status_msg = $this->print_error_msg(); + $status_msg = $this->printErrorMsg(); if ($this->echo_output_all) { echo $status_msg; } exit; } // set acls for this user/group and this page - $this->login_set_acl(); + $this->loginSetAcl(); } // METHOD: _login @@ -225,11 +229,12 @@ class login extends db_io parent::__destruct(); } - // METHOD: login_login_user + // METHOD: loginLoginUser + // WAS : login_login_user // PARAMS: none // RETURN: none // DESC : if user pressed login button this script is called, but only if there is no preview euid set - private function login_login_user() + private function loginLoginUser() { // have to get the global stuff here for setting it later if (!$this->euid && $this->login) { @@ -253,7 +258,7 @@ class login extends db_io $q .= "eg.edit_access_right_id = eareg.edit_access_right_id AND "; // password match is done in script, against old plain or new blowfish encypted $q .= "(LOWER(username) = '".strtolower($this->username)."') "; - $res = $this->db_return($q); + $res = $this->dbReturn($q); // username is wrong, but we throw for wrong username and wrong password the same error if (!$this->cursor_ext[md5($q)]["num_rows"]) { $this->login_error = 1010; @@ -280,13 +285,24 @@ class login extends db_io } elseif ($res['locked']) { // user is locked, either set or auto set $this->login_error = 105; - } elseif ((preg_match("/^\\$2(a|y)\\$/", $res['password']) && CRYPT_BLOWFISH != 1) || (preg_match("/^\\$1\\$/", $res['password']) && CRYPT_MD5 != 1) || (preg_match("/^\\$[0-9A-Za-z.]{12}$/", $res['password']) && CRYPT_STD_DES != 1)) { + } elseif ((preg_match("/^\\$2(a|y)\\$/", $res['password']) && CRYPT_BLOWFISH != 1) || + (preg_match("/^\\$1\\$/", $res['password']) && CRYPT_MD5 != 1) || + (preg_match("/^\\$[0-9A-Za-z.]{12}$/", $res['password']) && CRYPT_STD_DES != 1) + ) { // this means password cannot be decrypted because of missing crypt methods $this->login_error = 9999; - } elseif ((preg_match("/^\\$2(a|y)\\$/", $res['password']) || preg_match("/^\\$1\\$/", $res['password']) || preg_match("/^\\$[0-9A-Za-z.]{12}$/", $res['password'])) && !$this->verifyCryptString($this->password, $res['password'])) { + } elseif ((preg_match("/^\\$2(a|y)\\$/", $res['password']) || + preg_match("/^\\$1\\$/", $res['password']) || + preg_match("/^\\$[0-9A-Za-z.]{12}$/", $res['password'])) && + !$this->verifyCryptString($this->password, $res['password']) + ) { // check passwword as crypted, $2a$ or $2y$ is blowfish start, $1$ is MD5 start, $\w{12} is standard DES $this->login_error = 1011; - } elseif (!preg_match("/^\\$2(a|y)\\$/", $res['password']) && !preg_match("/^\\$1\\$/", $res['password']) && !preg_match("/^\\$[0-9A-Za-z.]{12}$/", $res['password']) && $res['password'] != $this->password) { + } elseif (!preg_match("/^\\$2(a|y)\\$/", $res['password']) && + !preg_match("/^\\$1\\$/", $res['password']) && + !preg_match("/^\\$[0-9A-Za-z.]{12}$/", $res['password']) && + $res['password'] != $this->password + ) { // check old plain password, non case sensitive $this->login_error = 1012; } else { @@ -294,7 +310,7 @@ class login extends db_io // set class var and session var $_SESSION["EUID"] = $this->euid = $res["edit_user_id"]; // check if user is okay - $this->login_check_permissions(); + $this->loginCheckPermissions(); if (!$this->login_error) { // now set all session vars and read page permissions $GLOBALS["DEBUG_ALL"] = $_SESSION["DEBUG_ALL"] = $res["debug"]; @@ -314,7 +330,7 @@ class login extends db_io // reset any login error count for this user if ($res['login_error_count'] > 0) { $q = "UPDATE edit_user SET login_error_count = 0, login_error_date_last = NULL, login_error_date_first = NULL WHERE edit_user_id = ".$res['edit_user_id']; - $this->db_exec($q); + $this->dbExec($q); } $pages = array(); $edit_page_ids = array(); @@ -324,7 +340,7 @@ class login extends db_io $q .= "WHERE ep.edit_page_id = epa.edit_page_id AND ear.edit_access_right_id = epa.edit_access_right_id "; $q .= "AND epa.enabled = 1 AND epa.edit_group_id = ".$res["edit_group_id"]." "; $q .= "ORDER BY ep.order_number"; - while ($res = $this->db_return($q)) { + while ($res = $this->dbReturn($q)) { // page id array for sub data readout $edit_page_ids[] = $res['edit_page_id']; // create the array for pages @@ -348,22 +364,26 @@ class login extends db_io } // for each page // get the visible groups for all pages and write them to the pages $_edit_page_id = 0; - $q = "SELECT epvg.edit_page_id, name, flag FROM edit_visible_group evp, edit_page_visible_group epvg WHERE evp.edit_visible_group_id = epvg.edit_visible_group_id AND epvg.edit_page_id IN (".join(', ', $edit_page_ids).") ORDER BY epvg.edit_page_id"; - while ($res = $this->db_return($q)) { + $q = "SELECT epvg.edit_page_id, name, flag "; + $q .= "FROM edit_visible_group evp, edit_page_visible_group epvg "; + $q .= "WHERE evp.edit_visible_group_id = epvg.edit_visible_group_id AND epvg.edit_page_id IN (".join(', ', $edit_page_ids).") "; + $q .= "ORDER BY epvg.edit_page_id"; + while ($res = $this->dbReturn($q)) { if ($res['edit_page_id'] != $_edit_page_id) { // search the pos in the array push - $pos = $this->array_search_recursive($res['edit_page_id'], $pages, 'edit_page_id'); + $pos = $this->arraySearchRecursive($res['edit_page_id'], $pages, 'edit_page_id'); $_edit_page_id = $res['edit_page_id']; } $pages[$pos[0]]['visible'][$res['name']] = $res['flag']; } // get the same for the query strings $_edit_page_id = 0; - $q = "SELECT eqs.edit_page_id, name, value, dynamic FROM edit_query_string eqs WHERE enabled = 1 AND edit_page_id IN (".join(', ', $edit_page_ids).") ORDER BY eqs.edit_page_id"; - while ($res = $this->db_return($q)) { + $q = "SELECT eqs.edit_page_id, name, value, dynamic FROM edit_query_string eqs "; + $q .= "WHERE enabled = 1 AND edit_page_id IN (".join(', ', $edit_page_ids).") ORDER BY eqs.edit_page_id"; + while ($res = $this->dbReturn($q)) { if ($res['edit_page_id'] != $_edit_page_id) { // search the pos in the array push - $pos = $this->array_search_recursive($res['edit_page_id'], $pages, 'edit_page_id'); + $pos = $this->arraySearchRecursive($res['edit_page_id'], $pages, 'edit_page_id'); $_edit_page_id = $res['edit_page_id']; } $pages[$pos[0]]['query'][] = array ( @@ -378,16 +398,17 @@ class login extends db_io // load the edit_access user rights $q = "SELECT ea.edit_access_id, level, type, ea.name, ea.color, ea.uid, edit_default "; $q .= "FROM edit_access_user eau, edit_access_right ear, edit_access ea "; - $q .= "WHERE eau.edit_access_id = ea.edit_access_id AND eau.edit_access_right_id = ear.edit_access_right_id AND eau.enabled = 1 AND edit_user_id = ".$this->euid." "; + $q .= "WHERE eau.edit_access_id = ea.edit_access_id AND eau.edit_access_right_id = ear.edit_access_right_id "; + $q .= "AND eau.enabled = 1 AND edit_user_id = ".$this->euid." "; $q .= "ORDER BY ea.name"; $unit_access = array(); $eauid = array(); $unit_acl = array(); - while ($res = $this->db_return($q)) { + while ($res = $this->dbReturn($q)) { // read edit access data fields and drop them into the unit access array $q_sub ="SELECT name, value FROM edit_access_data WHERE enabled = 1 AND edit_access_id = ".$res['edit_access_id']; $ea_data = array (); - while ($res_sub = $this->db_return($q_sub)) { + while ($res_sub = $this->dbReturn($q_sub)) { $ea_data[$res_sub['name']] = $res_sub['value']; } // build master unit array @@ -419,8 +440,10 @@ class login extends db_io $login_error_date_first = ', login_error_date_first = NOW()'; } // update login error count for this user - $q = "UPDATE edit_user SET login_error_count = login_error_count + 1, login_error_date_last = NOW() $login_error_date_first WHERE edit_user_id = ".$res['edit_user_id']; - $this->db_exec($q); + $q = "UPDATE edit_user "; + $q .= "SET login_error_count = login_error_count + 1, login_error_date_last = NOW() $login_error_date_first "; + $q .= "WHERE edit_user_id = ".$res['edit_user_id']; + $this->dbExec($q); // totally lock the user if error max is reached if ($res['login_error_count'] + 1 > $this->max_login_error_count) { // do some alert reporting in case this error is too big @@ -441,21 +464,22 @@ class login extends db_io } // if he pressed login at least and is not yet loggined in } - // METHOD: login_check_permission + // METHOD: loginCheckPermissions + // WAS : login_check_permission // PARAMS: none // RETUNR none // DESC : for every page the user access this script checks if he is allowed to do so - public function login_check_permissions() + public function loginCheckPermissions() { if ($this->euid && $this->login_error != 103) { $q = "SELECT filename "; $q .= "FROM edit_page ep, edit_page_access epa, edit_group eg, edit_user eu "; $q .= "WHERE ep.edit_page_id = epa.edit_page_id AND eg.edit_group_id = epa.edit_group_id AND eg.edit_group_id = eu.edit_group_id "; $q .= "AND eu.edit_user_id = ".$this->euid." AND filename = '".$this->page_name."' AND eg.enabled = 1 AND epa.enabled = 1"; - $res = $this->db_return_row($q); + $res = $this->dbReturnRow($q); // unset mem limit if debug is set to 1 -// if (($GLOBALS["DEBUG_ALL"] || $GLOBALS["DB_DEBUG"] || $_SESSION["DEBUG_ALL"] || $_SESSION["DB_DEBUG"]) && ini_get('memory_limit') != -1) -// ini_set('memory_limit', -1); + // if (($GLOBALS["DEBUG_ALL"] || $GLOBALS["DB_DEBUG"] || $_SESSION["DEBUG_ALL"] || $_SESSION["DB_DEBUG"]) && ini_get('memory_limit') != -1) + // ini_set('memory_limit', -1); if ($res["filename"] == $this->page_name) { $this->permission_okay = 1; } else { @@ -467,11 +491,12 @@ class login extends db_io return $this->permission_okay; } - // METHOD: login_logout_user + // METHOD: loginLogoutUser + // WAS : login_logout_user // PARAMS: none // RETURN: none // DESC : if a user pressed on logout, destroyes session and unsets all global vars - public function login_logout_user() + public function loginLogoutUser() { if ($this->logout || $this->login_error) { // unregister and destroy session vars @@ -495,7 +520,8 @@ class login extends db_io } } - // METHOD: login_set_acl + // METHOD: loginSetAcl + // WAS : login_set_acl // PARAMS: none // RETURN: none // DESC : sets all the basic ACLs @@ -512,7 +538,7 @@ class login extends db_io // * if an account ACL is set, set this parallel, account ACL overrides user ACL if it applies // * if edit access ACL level is set, use this, else use page // set all base ACL levels as a list keyword -> ACL number - public function login_set_acl() + public function loginSetAcl() { // we start with the default acl $this->acl['base'] = DEFAULT_ACL_LEVEL; @@ -595,11 +621,12 @@ class login extends db_io // $this->debug('ACL', $this->print_ar($this->acl)); } - // METHOD: login_check_edit_access + // METHOD: loginCheckEditAccess + // WAS : login_check_edit_access // PARAMS: edit_access_id to check // RETURN: true/false: if the edit access is not in the valid list: false // DESC : checks if this edit access id is valid - public function login_check_edit_access($edit_access_id) + public function loginCheckEditAccess($edit_access_id) { if (array_key_exists($edit_access_id, $this->acl['unit'])) { return true; @@ -608,11 +635,12 @@ class login extends db_io } } - // METHOD: login_password_change + // METHOD: loginPasswordChange + // WAS : login_password_change // PARAMS: none // RETURN: none // DESC : changes a user password - private function login_password_change() + private function loginPasswordChange() { if ($this->change_password) { $event = 'Password Change'; @@ -624,8 +652,8 @@ class login extends db_io } // check user exist, if not -> error if (!$this->login_error) { - $q = "SELECT edit_user_id FROM edit_user WHERE enabled = 1 AND username = '".$this->db_escape_string($this->pw_username)."'"; - list ($edit_user_id) = $this->db_return_row($q); + $q = "SELECT edit_user_id FROM edit_user WHERE enabled = 1 AND username = '".$this->dbEscapeString($this->pw_username)."'"; + list ($edit_user_id) = $this->dbReturnRow($q); if (!$edit_user_id) { // username wrong $this->login_error = 201; @@ -634,8 +662,8 @@ class login extends db_io } // check old passwords match -> error if (!$this->login_error) { - $q = "SELECT edit_user_id FROM edit_user WHERE enabled = 1 AND username = '".$this->db_escape_string($this->pw_username)."' AND password = '".$this->db_escape_string($this->pw_old_password)."'"; - list ($edit_user_id) = $this->db_return_row($q); + $q = "SELECT edit_user_id FROM edit_user WHERE enabled = 1 AND username = '".$this->dbEscapeString($this->pw_username)."' AND password = '".$this->dbEscapeString($this->pw_old_password)."'"; + list ($edit_user_id) = $this->dbReturnRow($q); if (!$edit_user_id) { // old password wrong $this->login_error = 202; @@ -659,8 +687,8 @@ class login extends db_io // no error change this users password if (!$this->login_error) { // update the user (edit_user_id) with the new password - $q = "UPDATE edit_user SET password = '".$this->db_escape_string($this->cryptString($this->pw_new_password))."' WHERE edit_user_id = ".$edit_user_id; - $this->db_exec($q); + $q = "UPDATE edit_user SET password = '".$this->dbEscapeString($this->cryptString($this->pw_new_password))."' WHERE edit_user_id = ".$edit_user_id; + $this->dbExec($q); $data = 'Password change for user "'.$this->pw_username.'" from "'.$this->pw_old_password.'" to "'.$this->pw_new_password.'"'; } } else { @@ -673,15 +701,16 @@ class login extends db_io } // button pressed } - // METHOD: login_print_login + // METHOD: loginPrintLogin + // WAS : login_print_login // PARAMS: none // RETURN: none // DESC : prints out login html part if no permission (error) is set - private function login_print_login() + private function loginPrintLogin() { if (!$this->permission_okay) { // set the templates now - $this->login_set_templates(); + $this->loginSetTemplates(); // if there is a global logout target ... if (file_exists($this->logout_target) && $this->logout_target) { $LOGOUT_TARGET = $this->logout_target; @@ -728,11 +757,12 @@ class login extends db_io } // if permission is 0 then print out login } - // METHOD: login_close_class + // METHOD: loginCloseClass + // WAS : login_close_class // PARAMS: none // RETURN: none // DESC : last function called, writes log and prints out error msg and exists script if permission 0 - private function login_close_class() + private function loginCloseClass() { // write to LOG table ... if ($this->login_error || $this->login || $this->logout) { @@ -750,9 +780,9 @@ class login extends db_io if ($this->euid) { // get user from user table $q = "SELECT username, password FROM edit_user WHERE edit_user_id = ".$this->euid; - list($username, $password) = $this->db_return_row($q); + list($username, $password) = $this->dbReturnRow($q); } // if euid is set, get username (or try) - $this->write_log($event, '', $this->login_error, $username, $password); + $this->writeLog($event, '', $this->login_error, $username, $password); } // write log under certain settings // now close DB connection // $this->error_msg = $this->_login(); @@ -763,11 +793,12 @@ class login extends db_io } } - // METHOD: login_set_templates + // METHOD: loginSetTemplates + // WAS : login_set_templates // PARAMS: // RETURN: none // DESC : checks if there are external templates, if not uses internal fallback ones - private function login_set_templates() + private function loginSetTemplates() { $strings = array ( 'HTML_TITLE' => $this->l->__("LOGIN"), @@ -911,13 +942,14 @@ EOM; } } - // METHOD: write_log + // METHOD: writeLog + // WAS : write_log // PARAMS: event -> string of what has been done // data -> data information (id, etc) // error -> if error, write error string (not enougth data, etc) // RETURN: none // DESC : writes detailed data into the edit user log table (keep log what user does) - private function write_log($event, $data, $error = "", $username = "", $password = "") + private function writeLog($event, $data, $error = "", $username = "", $password = "") { if ($this->login) { $this->action = 'Login'; @@ -931,31 +963,32 @@ EOM; '_FILES' => $_FILES, 'error' => $this->login_error ); - $data_binary = $this->db_escape_bytea(bzcompress(serialize($_data_binary))); + $data_binary = $this->dbEscapeBytea(bzcompress(serialize($_data_binary))); // SQL querie for log entry $q = "INSERT INTO edit_log "; $q .= "(username, password, euid, event_date, event, error, data, data_binary, page, "; $q .= "ip, user_agent, referer, script_name, query_string, server_name, http_host, http_accept, http_accept_charset, http_accept_encoding, session_id, "; $q .= "action, action_id, action_yes, action_flag, action_menu, action_loaded, action_value, action_error) "; - $q .= "VALUES ('".$this->db_escape_string($username)."', '".$this->db_escape_string($password)."', ".(($this->euid) ? $this->euid : 'NULL').", "; - $q .= "NOW(), '".$this->db_escape_string($event)."', '".$this->db_escape_string($error)."', '".$this->db_escape_string($data)."', '".$data_binary."', '".$this->page_name."', "; + $q .= "VALUES ('".$this->dbEscapeString($username)."', '".$this->dbEscapeString($password)."', ".(($this->euid) ? $this->euid : 'NULL').", "; + $q .= "NOW(), '".$this->dbEscapeString($event)."', '".$this->dbEscapeString($error)."', '".$this->dbEscapeString($data)."', '".$data_binary."', '".$this->page_name."', "; foreach (array('REMOTE_ADDR', 'HTTP_USER_AGENT', 'HTTP_REFERER', 'SCRIPT_FILENAME', 'QUERY_STRING', 'SERVER_NAME', 'HTTP_HOST', 'HTTP_ACCEPT', 'HTTP_ACCEPT_CHARSET', 'HTTP_ACCEPT_ENCODING') as $server_code) { if (array_key_exists($server_code, $_SERVER)) { - $q .= "'".$this->db_escape_string($_SERVER[$server_code])."', "; + $q .= "'".$this->dbEscapeString($_SERVER[$server_code])."', "; } else { $q .= "NULL, "; } } $q .= "'".session_id()."', "; - $q .= "'".$this->db_escape_string($this->action)."', '".$this->db_escape_string($this->username)."', NULL, '".$this->db_escape_string($this->login_error)."', NULL, NULL, '".$this->db_escape_string($this->permission_okay)."', NULL)"; - $this->db_exec($q, 'NULL'); + $q .= "'".$this->dbEscapeString($this->action)."', '".$this->dbEscapeString($this->username)."', NULL, '".$this->dbEscapeString($this->login_error)."', NULL, NULL, '".$this->dbEscapeString($this->permission_okay)."', NULL)"; + $this->dbExec($q, 'NULL'); } - // METHOD: login_check_edit_access_id + // METHOD: loginCheckEditAccessId + // WAS : login_check_edit_access_id // PARAMS: edit access id to check // RETURN: same edit access id if ok, or the default edit access id if given one is not valud // DESC : checks that the given edit access id is valid for this user - public function login_check_edit_access_id($edit_access_id) + public function loginCheckEditAccessId($edit_access_id) { if (!array_key_exists($edit_access_id, $_SESSION["UNIT"])) { return $_SESSION["UNIT_DEFAULT"]; @@ -964,11 +997,12 @@ EOM; } } - // METHOD: login_set_edit_access_data + // METHOD: loginSetEditAccessData + // WAS : login_set_edit_access_data // PARAMS: edit access id, key value to search for // RETURN: false for not found or string for found data // DESC : searchs in the data set for the unit for the data key and returns the value asociated with it - public function login_set_edit_access_data($edit_access_id, $data_key) + public function loginSetEditAccessData($edit_access_id, $data_key) { if (!$_SESSION['UNIT'][$edit_access_id]['data'][$data_key]) { return false; @@ -977,3 +1011,5 @@ EOM; } } } // close class + +# __END__ diff --git a/www/libs/Class.Admin.Backend.inc b/www/lib/CoreLibs/Admin/Backend.inc similarity index 60% rename from www/libs/Class.Admin.Backend.inc rename to www/lib/CoreLibs/Admin/Backend.inc index 1e7b5680..4566e377 100644 --- a/www/libs/Class.Admin.Backend.inc +++ b/www/lib/CoreLibs/Admin/Backend.inc @@ -1,8 +1,8 @@ -l = new l10n($lang); + $this->l = new \CoreLibs\Language\L10n($lang); // init the database class -// $this->db_io($db_config, $debug, $db_debug, $echo, $print); parent::__construct($db_config, $debug, $db_debug, $echo, $print); // internal $this->class_info["adbBackend"] = array( "class_name" => "Admin Interface Backend", - "class_version" => "0.1.0", + "class_version" => "1.0.0", "class_created" => "2006/08/15", - "class_author" => "cs/gullevek/jp" + "class_author" => "Clemens Schwaighofer" ); // set page name - $this->page_name = $this->get_page_name(); + $this->page_name = $this->getPageName(); // set the action ids foreach ($this->action_list as $_action) { @@ -122,15 +118,15 @@ class AdminBackend extends db_io // METHOD: adbEditLog() // PARAMS: event -> any kind of event description, data -> any kind of data related to that event // RETURN: none - // DESC: writes all action vars plus other info into edit_log table + // DESC : writes all action vars plus other info into edit_log table public function adbEditLog($event = '', $data = '', $write_type = 'STRING') { if ($write_type == 'BINARY') { - $data_binary = $this->db_escape_bytea(bzcompress(serialize($data))); + $data_binary = $this->dbEscapeBytea(bzcompress(serialize($data))); $data = 'see bzip compressed data_binary field'; } if ($write_type == 'STRING') { - $data = $this->db_escape_string(serialize($data)); + $data = $this->dbEscapeString(serialize($data)); } $q = "INSERT INTO ".LOGIN_DB_SCHEMA.".edit_log "; @@ -138,31 +134,24 @@ class AdminBackend extends db_io $q .= "ip, user_agent, referer, script_name, query_string, server_name, http_host, http_accept, http_accept_charset, http_accept_encoding, session_id, "; $q .= "action, action_id, action_yes, action_flag, action_menu, action_loaded, action_value, action_error) "; $q .= "VALUES "; - $q .= "(".@$_SESSION['EUID'].", NOW(), '".$this->db_escape_string($event)."', '".$data."', '".$data_binary."', '".$this->page_name."', "; - $q .= "'".@$_SERVER["REMOTE_ADDR"]."', '".$this->db_escape_string(@$_SERVER['HTTP_USER_AGENT'])."', "; - $q .= "'".$this->db_escape_string(@$_SERVER['HTTP_REFERER'])."', '".$this->db_escape_string(@$_SERVER['SCRIPT_FILENAME'])."', "; - $q .= "'".$this->db_escape_string(@$_SERVER['QUERY_STRING'])."', '".$this->db_escape_string(@$_SERVER['SERVER_NAME'])."', "; - $q .= "'".$this->db_escape_string(@$_SERVER['HTTP_HOST'])."', '".$this->db_escape_string(@$_SERVER['HTTP_ACCEPT'])."', "; - $q .= "'".$this->db_escape_string(@$_SERVER['HTTP_ACCEPT_CHARSET'])."', '".$this->db_escape_string(@$_SERVER['HTTP_ACCEPT_ENCODING'])."', "; + $q .= "(".@$_SESSION['EUID'].", NOW(), '".$this->dbEscapeString($event)."', '".$data."', '".$data_binary."', '".$this->page_name."', "; + $q .= "'".@$_SERVER["REMOTE_ADDR"]."', '".$this->dbEscapeString(@$_SERVER['HTTP_USER_AGENT'])."', "; + $q .= "'".$this->dbEscapeString(@$_SERVER['HTTP_REFERER'])."', '".$this->dbEscapeString(@$_SERVER['SCRIPT_FILENAME'])."', "; + $q .= "'".$this->dbEscapeString(@$_SERVER['QUERY_STRING'])."', '".$this->dbEscapeString(@$_SERVER['SERVER_NAME'])."', "; + $q .= "'".$this->dbEscapeString(@$_SERVER['HTTP_HOST'])."', '".$this->dbEscapeString(@$_SERVER['HTTP_ACCEPT'])."', "; + $q .= "'".$this->dbEscapeString(@$_SERVER['HTTP_ACCEPT_CHARSET'])."', '".$this->dbEscapeString(@$_SERVER['HTTP_ACCEPT_ENCODING'])."', "; $q .= "'".session_id()."', "; - $q .= "'".$this->db_escape_string($this->action)."', '".$this->db_escape_string($this->action_id)."', "; - $q .= "'".$this->db_escape_string($this->action_yes)."', '".$this->db_escape_string($this->action_flag)."', "; - $q .= "'".$this->db_escape_string($this->action_menu)."', '".$this->db_escape_string($this->action_loaded)."', "; - $q .= "'".$this->db_escape_string($this->action_value)."', '".$this->db_escape_string($this->action_error)."')"; - $this->db_exec($q, 'NULL'); + $q .= "'".$this->dbEscapeString($this->action)."', '".$this->dbEscapeString($this->action_id)."', "; + $q .= "'".$this->dbEscapeString($this->action_yes)."', '".$this->dbEscapeString($this->action_flag)."', "; + $q .= "'".$this->dbEscapeString($this->action_menu)."', '".$this->dbEscapeString($this->action_loaded)."', "; + $q .= "'".$this->dbEscapeString($this->action_value)."', '".$this->dbEscapeString($this->action_error)."')"; + $this->dbExec($q, 'NULL'); } - - // ================================== - // ALL THE PAGE RIGHTS/USER RIGHTS/ETC need to fixed and put into one - // proper settings have to be done with the defined top down rights flow - // ================================== - // all ACLs are set in the login class - // METHOD: adbTopMenu // PARAMS: level // RETURN: returns an array for the top menu with all correct settings - // DESC: menu creater + // DESC : menu creater public function adbTopMenu($flag = 0) { if ($this->menu_show_flag) { @@ -174,13 +163,11 @@ class AdminBackend extends db_io if (!is_array($pages)) { $pages = array (); } - -//$this->debug('pages', $this->print_ar($pages)); - + // $this->debug('pages', $this->print_ar($pages)); // if flag is 0, then we show all, else, we show only the matching flagges array points // array is already sorted after correct order reset($pages); - for ($i = 0; $i < count($pages); $i ++) { + for ($i = 0, $iMax = count($pages); $i < $iMax; $i ++) { $show = 0; // is it visible in the menu & is it online if ($pages[$i]["menu"] && $pages[$i]["online"]) { @@ -205,7 +192,7 @@ class AdminBackend extends db_io } $query_string = ''; if (count($pages[$i]["query"])) { - for ($j = 0; $j < count($pages[$i]["query"]); $j ++) { + for ($j = 0, $jMax = count($pages[$i]["query"]); $j < $jMax; $j ++) { if (strlen($query_string)) { $query_string .= "&"; } @@ -224,7 +211,7 @@ class AdminBackend extends db_io $name = $pages[$i]["page_name"]; // if page name matchs -> set selected flag $selected = 0; - if ($this->get_page_name() == $pages[$i]["filename"]) { + if ($this->getPageName() == $pages[$i]["filename"]) { $selected = 1; $this->page_name = $name; } @@ -244,7 +231,7 @@ class AdminBackend extends db_io // METHOD: adbShowMenuPoint // PARAMS: filename // RETURN: returns boolean true/false - // DESC: checks if this filename is in the current situation (user id, etc) available + // DESC : checks if this filename is in the current situation (user id, etc) available public function adbShowMenuPoint($filename) { $enabled = 0; @@ -260,20 +247,20 @@ class AdminBackend extends db_io // METHOD: adbAssocArray // PARAMS: db array, key, value part // RETURN: returns and associative array - // DESC: creates out of a normal db_return array an assoc array + // DESC : creates out of a normal db_return array an assoc array public function adbAssocArray($db_array, $key, $value) { - return $this->GenAssocArray($db_array, $key, $value); + return $this->genAssocArray($db_array, $key, $value); } // REMARK: below function has moved to "Class.Basic" // METHOD: adbByteStringFormat // PARAMS: int // RETURN: string - // DESC: converts bytes into formated string with KB, MB, etc + // DESC : converts bytes into formated string with KB, MB, etc public function adbByteStringFormat($number) { - return $this->ByteStringFormat($number); + return $this->byteStringFormat($number); } // REMARK: below function has moved to "Class.Basic" @@ -285,10 +272,10 @@ class AdminBackend extends db_io // path -> if source start is not ROOT path, if empty ROOT is choosen // cache -> cache path, if not given TMP is used // RETURN: thumbnail name - // DESC: converts picture to a thumbnail with max x and max y size + // DESC : converts picture to a thumbnail with max x and max y size public function adbCreateThumbnail($pic, $size_x, $size_y, $dummy = false, $path = "", $cache = "") { - return $this->CreateThumbnail($pic, $size_x, $size_y, $dummy, $path, $cache); + return $this->createThumbnail($pic, $size_x, $size_y, $dummy, $path, $cache); } // METHOD: adbMsg @@ -296,7 +283,7 @@ class AdminBackend extends db_io // msg -> string, can be printf formated // var array -> optional data for a possible printf formated msg // RETURN: none - // DESC: wrapper function to fill up the mssages array + // DESC : wrapper function to fill up the mssages array public function adbMsg($level, $msg, $vars = array ()) { if (!preg_match("/^info|warning|error$/", $level)) { @@ -329,82 +316,47 @@ class AdminBackend extends db_io // associate -> NULL for free, LOCK for first insert, group key for reference to first entry // file -> string for special file copy actions; mostyle "test#live;..." // RETURN: none - // DESC: writes live queue + // DESC : writes live queue public function adbLiveQueue($queue_key, $type, $target, $data, $key_name, $key_value, $associate = null, $file = null) { $q = "INSERT INTO ".GLOBAL_DB_SCHEMA.".live_queue ("; $q .= "queue_key, key_value, key_name, type, target, data, group_key, action, associate, file"; $q .= ") VALUES ("; - $q .= "'".$this->db_escape_string($queue_key)."', '".$this->db_escape_string($key_value)."', "; - $q .= "'".$this->db_escape_string($key_name)."', '".$this->db_escape_string($type)."', "; - $q .= "'".$this->db_escape_string($target)."', '".$this->db_escape_string($data)."', "; - $q .= "'".$this->queue_key."', '".$this->action."', '".$this->db_escape_string($associate)."', "; - $q .= "'".$this->db_escape_string($file)."')"; + $q .= "'".$this->dbEscapeString($queue_key)."', '".$this->dbEscapeString($key_value)."', "; + $q .= "'".$this->dbEscapeString($key_name)."', '".$this->dbEscapeString($type)."', "; + $q .= "'".$this->dbEscapeString($target)."', '".$this->dbEscapeString($data)."', "; + $q .= "'".$this->queue_key."', '".$this->action."', '".$this->dbEscapeString($associate)."', "; + $q .= "'".$this->dbEscapeString($file)."')"; $this->db_exec($q); } // METHOD: adbPrintDateTime // PARAMS: year, month, day, hour, min: the date and time values - // suffix: additional info printed after the date time variable in the drop down, also used for ID in the on change JS call - // minute steps, can be 1 (default), 5, 10, etc, if invalid (outside 1h range, it falls back to 1min) + // suffix: additional info printed after the date time variable in the drop down, + // also used for ID in the on change JS call + // minute steps: can be 1 (default), 5, 10, etc, if invalid (outside 1h range, + // it falls back to 1min) + // name pos back: default false, if set to true, the name will be printend + // after the drop down and not before the drop down // RETURN: HTML formated strings for drop down lists of date and time - // DESC: print the date/time drop downs, used in any queue/send/insert at date/time place - public function adbPrintDateTime($year, $month, $day, $hour, $min, $suffix = '', $min_steps = 1) + // DESC : print the date/time drop downs, used in any queue/send/insert at date/time place + // NOTE : Basic class holds exact the same, except the Year/Month/Day/etc strings + // are translated in this call + public function adbPrintDateTime($year, $month, $day, $hour, $min, $suffix = '', $min_steps = 1, $name_pos_back = false) { - // if suffix given, add _ before - if ($suffix) { - $suffix = '_'.$suffix; + // get the build layout + $html_time = $this->printDateTime($year, $month, $day, $hour, $min, $suffix, $min_steps, $name_pos_back); + // translate the strings inside + foreach (array('Year ', 'Month ', 'Day ', 'Hour ', 'Minute ') as $_time) { + $html_time = str_replace($_time, $this->l->__(str_replace(' ', '', $_time)).' ', $html_time); } - if ($min_steps < 1 || $min_steps > 59) { - $min_steps = 1; + // replace week days in short + foreach (array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun') as $_date) { + $html_time = str_replace('('.$_date.')', '('.$this->l->__($_date).')', $html_time); } - - $on_change_call = 'dt_list(\''.$suffix.'\');'; - - // always be 1h ahead (for safety) - $timestamp = time() + 3600; // in seconds - - // the max year is this year + 1; - $max_year = date("Y", $timestamp) + 1; - - // preset year, month, ... - $year = (!$year) ? date("Y", $timestamp) : $year; - $month = (!$month) ? date("m", $timestamp) : $month; - $day = (!$day) ? date("d", $timestamp) : $day; - $hour = (!$hour) ? date("H", $timestamp) : $hour; - $min = (!$min) ? date("i", $timestamp) : $min; // add to five min? - // max days in selected month - $days_in_month = date("t", strtotime($year."-".$month."-".$day." ".$hour.":".$min.":0")); - - // from now to ? - $string = $this->l->__('Year').' '; - $string .= ' '.$this->l->__('Month').' '; - $string .= ' '.$this->l->__('Day').' '; - $string .= ' '.$this->l->__('Hour').' '; - $string .= ' '.$this->l->__('Minute').' '; - $string .= ''; - // return the datetime select string - return $string; + // return the datetime select string with strings translated + return $html_time; } } + +# __END__ diff --git a/www/libs/Class.Basic.inc b/www/lib/CoreLibs/Basic.inc similarity index 73% rename from www/libs/Class.Basic.inc rename to www/lib/CoreLibs/Basic.inc index 1302e150..62480a98 100644 --- a/www/libs/Class.Basic.inc +++ b/www/lib/CoreLibs/Basic.inc @@ -1,10 +1,13 @@ - calls with "level", "string" and flag to turn off (0) the newline at the end -* debug_for -> sets debug on/off for a type (error, echo, print) for a certain level -* print_error_msg -> prints out the error message, optional parameter is a header prefix +* debugFor -> sets debug on/off for a type (error, echo, print) for a certain level +* printErrorMsg -> prints out the error message, optional parameter is a header prefix * fdebug -> prints line directly to debug_file.log in tmp * -* print_time -> prints time + microtime, optional flag to turn off (0) microtime printout -* basic -> constructor -* _basic -> desconstructor +* printTime -> prints time + microtime, optional flag to turn off (0) microtime printout * info -> info about that class -* running_time -> prints out the time of start/end (automatically called on created and error printout +* runningTime -> prints out the time of start/end (automatically called on created and error printout * checked -> returnes checked or selected for var & array -* magic_links -> parses text and makes out of links -* get_page_name -> get the filename of the current page -* array_search_recursive -> search for a value/key combination in an array of arrays -* ByteStringFormat -> format bytes into KB, MB, GB, ... -* TimeStringFormat -> format a timestamp (seconds) into days, months, ... also with ms -* StringToTime -> reverste a TimeStringFormat to a timestamp -* GenAssocArray -> generactes a new associativ array from an existing array -* CheckDate -> checks if a date is valid -* CompareDate -> compares two dates. -1 if the first is smaller, 0 if they are equal, 1 if the first is bigger -* CompareDateTime -> compares two dates with time. -1 if the first is smaller, 0 if they are equal, 1 if the first is bigger -* _crc32b -> behaves like the hash("crc32b") in php < 5.2.8. this function will flip the hash like it was (wrong) +* magicLinks -> parses text and makes out of links +* getPageName -> get the filename of the current page +* arraySearchRecursive -> search for a value/key combination in an array of arrays +* byteStringFormat -> format bytes into KB, MB, GB, ... +* timeStringFormat -> format a timestamp (seconds) into days, months, ... also with ms +* stringToTime -> reverste a TimeStringFormat to a timestamp +* genAssocArray -> generactes a new associativ array from an existing array +* checkDate -> checks if a date is valid +* compareDate -> compares two dates. -1 if the first is smaller, 0 if they are equal, 1 if the first is bigger +* compareDateTime -> compares two dates with time. -1 if the first is smaller, 0 if they are equal, 1 if the first is bigger +* __crc32b -> behaves like the hash("crc32b") in php < 5.2.8. this function will flip the hash like it was (wrong) * before if a new php version is found * crypt* -> encrypt and decrypt login string data, used by Login class * setFormToken/validateFormToken -> form protection with token @@ -92,7 +93,9 @@ * 2003-03-24: start of stub/basic class *********************************************************************/ -class basic +namespace CoreLibs; + +class Basic { public $class_info; // class info var @@ -126,8 +129,8 @@ class basic public $log_per_page = 0; // set, will split log per called file public $log_per_run = 0; // create a new log file per run (time stamp + unique ID) - public $starttime; // start time if time debug is used - public $endtime; // end time if time debug is used + private $starttime; // start time if time debug is used + private $endtime; // end time if time debug is used public $email_regex; // regex var for email check public $keitai_email_regex; // regex var for email check @@ -158,9 +161,9 @@ class basic // form token (used for form validation) private $form_token = ''; - // METHOD __construct - // PARAMS debug_all (0)/1, echo_all (1)/0, print_all (0)/1 - // RETURN none + // METHOD: __construct + // PARAMS: debug_all (0)/1, echo_all (1)/0, print_all (0)/1 + // RETURN: none // DESC constructor public function __construct($debug_all = 0, $echo_all = 1, $print_all = 0) { @@ -170,14 +173,14 @@ class basic // internal info var $this->class_info["basic"] = array ( "class_name" => "Basic", - "class_version" => "0.9.0", + "class_version" => "2.0.0", "class_created" => "2003-03-24", - "class_author" => 'Clemens "Gullevek" Schwaighofer (.at)' + "class_author" => 'Clemens Schwaighofer' ); // set the page name - $this->page_name = $this->get_page_name(); - $this->host_name = $this->get_host_name(); + $this->page_name = $this->getPageName(); + $this->host_name = $this->getHostName(); // set the paths matching to the valid file types $this->data_path = array ( @@ -341,30 +344,30 @@ class basic $this->cryptInit(); // start logging running time - $this->running_time(); + $this->runningTime(); } - // METHOD __destruct - // PARAMS none - // RETURN if debug is on, return error data - // DESC basic deconstructor (should be called from all deconstructors in higher classes) + // METHOD: __destruct + // PARAMS: none + // RETURN: if debug is on, return error data + // DESC : basic deconstructor (should be called from all deconstructors in higher classes) // writes out $error_msg to global var public function __destruct() { // this has to be changed, not returned here, this is the last class to close -// return $this->error_msg; + // return $this->error_msg; // close open file handles -// $this->fdebug_fp('c'); + // $this->fdebugFP('c'); } // ************************************************************* // GENERAL METHODS // ************************************************************* - // METHOD db_io_info - // PARAMS show, default 1, if set to 0 won't write to error_msg var - // RETURN string with info - // DESC default class info (prints out class info) + // METHOD: db_io_info + // PARAMS: show, default 1, if set to 0 won't write to error_msg var + // RETURN: string with info + // DESC : default class info (prints out class info) public function info($class_name = "basic", $stdio = 0) { unset($string); @@ -383,7 +386,13 @@ class basic return $string; } - public function running_time($simple = false) + // METHOD: runningTime + // WAS : running_time + // PARAMS: simple flag true/false, if given print non HTML info + // RETURN: string with running time for debugging + // DESC : prints start or end time in text format. On first call sets start time + // on second call it sends the end time and then also prints the running time + public function runningTime($simple = false) { list($micro, $timestamp) = explode(" ", microtime()); $string = ''; @@ -401,16 +410,26 @@ class basic $running_time = $this->endtime - $this->starttime; $string .= ($simple ? 'Run: ' : "
Script running time: ").$running_time." s"; } -// $this->debug('info', $string); + // $this->debug('info', $string); return $running_time; } - // METHOD print_time - // PARAMS $set_microtime, 0 shows none, default (-1) shows all, positive number is for rounding - // RETURN formated datetime string - // DESCRIPTION - // wrapper around microtime function to print out y-m-d h:i:s.ms - public static function print_time($set_microtime = -1) + // METHOD: resetRunningtime + // PARAMS: none + // RETURN: none + // DESC : resets start & end time for runningTime call + public function resetRunningTime() + { + $this->starttime = ''; + $this->endtime = ''; + } + + // METHOD: printTime + // WAS : print_time + // PARAMS: $set_microtime, 0 shows none, default (-1) shows all, positive number is for rounding + // RETURN: formated datetime string + // DESC : wrapper around microtime function to print out y-m-d h:i:s.ms + public static function printTime($set_microtime = -1) { list($microtime, $timestamp) = explode(" ", microtime()); $string = date("Y-m-d H:i:s", $timestamp); @@ -424,49 +443,48 @@ class basic } - // METHOD fdebug - // PARAMS $string: data to write to file + // METHOD: fdebug + // PARAMS: $string: data to write to file // $enter: default on true, if set to false, no linebreak (\n) will be put at the end - // RETURN none - // DESCRIPTION - // writes a string to a file immediatly, for fast debug output + // RETURN: none + // DESC : writes a string to a file immediatly, for fast debug output public function fdebug($string, $enter = 1) { if ($this->debug_filename) { - $this->fdebug_fp(); + $this->fdebugFP(); if ($enter) { $string .= "\n"; } - $string = "[".$this->print_time()."] [".$this->get_page_name(2)."] - ".$string; + $string = "[".$this->printTime()."] [".$this->getPageName(2)."] - ".$string; fwrite($this->debug_fp, $string); - $this->fdebug_fp(); + $this->fdebugFP(); } } - // METHOD fdebug_fp - // PARAMS $flag: default '', 'o' -> open, 'c' -> close - // RETURN none - // DESCRIPTION - // if no debug_fp found, opens a new one; if fp exists close it - private function fdebug_fp($flag = '') + // METHOD: fdebugFP + // WAS : fdebug_fp + // PARAMS: $flag: default '', 'o' -> open, 'c' -> close + // RETURN: none + // DESC : if no debug_fp found, opens a new one; if fp exists close it + private function fdebugFP($flag = '') { if (!$this->debug_fp || $flag == 'o') { - $fn = ROOT.LOG.$this->debug_filename; + $fn = BASE.LOG.$this->debug_filename; $this->debug_fp = @fopen($fn, 'a'); } elseif ($this->debug_fp || $flag == 'c') { fclose($this->debug_fp); } } - // METHOD debug_for - // PARAMS $type: error, echo, print - // $flag: on/off - // $array of levels to turn on/off debug - // RETURN none - // DESCRIPTION - // passes list of level names, to turn on debug - // eg $foo->debug_for('print', 'on', array('LOG', 'DEBUG', 'INFO')); - public function debug_for($type, $flag) + // METHOD: debugFor + // WAS : debug_for + // PARAMS: $type: error, echo, print + // $flag: on/off + // $array of levels to turn on/off debug + // RETURN: none + // DESC : passes list of level names, to turn on debug + // eg $foo->debug_for('print', 'on', array('LOG', 'DEBUG', 'INFO')); + public function debugFor($type, $flag) { $debug_on = func_get_args(); array_shift($debug_on); // kick out type @@ -482,14 +500,13 @@ class basic } } - // METHOD debug - // PARAMS $level: id for error message, groups messages together - // $string: the actual error message - // $strip: default on false, if set to true, all html tags will be stripped and
changed to \n - // this is only used for debug output - // RETURN none - // DESCRIPTION - // write debug data to error_msg array + // METHOD: debug + // PARAMS: $level: id for error message, groups messages together + // $string: the actual error message + // $strip: default on false, if set to true, all html tags will be stripped and
changed to \n + // this is only used for debug output + // RETURN: none + // DESC : write debug data to error_msg array public function debug($level, $string, $strip = false) { if (($this->debug_output[$level] || $this->debug_output_all) && !$this->debug_output_not[$level]) { @@ -497,7 +514,7 @@ class basic $this->error_msg[$level] = ''; } $error_string = '
'; - $error_string .= '['.$this->print_time().'] '; + $error_string .= '['.$this->printTime().'] '; $error_string .= '['.$level.'] '; $error_string .= '['.$this->host_name.'] '; $error_string .= '['.$this->page_name.'] '; @@ -511,10 +528,10 @@ class basic $string = preg_replace("/(<\/?)(\w+)([^>]*>)/", "", $string); } // same string put for print (no html crap inside) - $error_string_print = '['.$this->print_time().'] ['.$this->host_name.'] ['.$this->get_page_name(2).'] ['.$this->running_uid.'] {'.get_class($this).'} <'.$level.'> - '.$string; + $error_string_print = '['.$this->printTime().'] ['.$this->host_name.'] ['.$this->getPageName(2).'] ['.$this->running_uid.'] {'.get_class($this).'} <'.$level.'> - '.$string; $error_string_print .= "\n"; // write to file if set - $this->write_error_msg($level, $error_string_print); + $this->writeErrorMsg($level, $error_string_print); // write to error level if (($this->echo_output[$level] || $this->echo_output_all) && !$this->echo_output_not[$level]) { $this->error_msg[$level] .= $error_string; @@ -522,12 +539,13 @@ class basic } } - // METHOD: get_caller_method + // METHOD: getCallerMethod + // WAS : get_caller_method // PARAMS: none (optional later: which level to deb ug) // RETURN: null or the function that called the function where this methid is called // DESC : if there is a need to find out which parent method called a child method, eg for debugging, this function does this // call this method in the child method and you get the parent function that called it - public function get_caller_method($level = 2) + public function getCallerMethod($level = 2) { $traces = debug_backtrace(); // extended info (later) @@ -546,12 +564,13 @@ class basic return null; } - // METHOD merge_errors - // PARAMS error array - // RETURN none - // DESC merges the given error array with the one from this class - // only merges visible ones - public function merge_errors($error_msg = array ()) + // METHOD: mergeErrors + // WAS : merge_errors + // PARAMS: error array + // RETURN: none + // DESC : merges the given error array with the one from this class + // only merges visible ones + public function mergeErrors($error_msg = array ()) { if (!is_array($error_msg)) { $error_msg = array (); @@ -561,20 +580,20 @@ class basic } } - // METHOD print_error_msg - // PARAMS $string: prefix string for header - // RETURN error msg for all levels - // DESCRIPTION - // prints out the error string - public function print_error_msg($string = '') + // METHOD: printErrorMsg + // WAS : print_error_msg + // PARAMS: $string: prefix string for header + // RETURN: error msg for all levels + // DESC : prints out the error string + public function printErrorMsg($string = '') { $string_output = ''; if ($this->debug_output_all) { if ($this->error_msg_prefix) { $string = $this->error_msg_prefix; } - $script_end = $this->running_time(); - while (list($level, $temp_debug_output) = each($this->error_msg)) { + $script_end = $this->runningTime(); + foreach ($this->error_msg as $level => $temp_debug_output) { if (($this->debug_output[$level] || $this->debug_output_all) && !$this->debug_output_not[$level]) { if (($this->echo_output[$level] || $this->echo_output_all) && !$this->echo_output_not[$level]) { $string_output .= '
['.$level.'] '.(($string) ? "**** ".$this->htmlent($string)." ****\n" : "").'
'; @@ -594,26 +613,26 @@ class basic return $string_output; } - // METHOD write_error_msg - // PARAMS $level: the level to write - // RETURN none - // DESCRIPTION - // writes error msg data to file for current level - private function write_error_msg($level, $error_string) + // METHOD: writeErrorMsg + // WAS : write_error_msg + // PARAMS: $level: the level to write + // RETURN: none + // DESC : writes error msg data to file for current level + private function writeErrorMsg($level, $error_string) { if (($this->debug_output[$level] || $this->debug_output_all) && !$this->debug_output_not[$level]) { // only write if write is requested if (($this->print_output[$level] || $this->print_output_all) && !$this->print_output_not[$level]) { // replace all html tags - // $error_string = preg_replace("/(<\/?)(\w+)([^>]*>)/", "##\\2##", $error_string); - // $error_string = preg_replace("/(<\/?)(\w+)([^>]*>)/", "", $error_string); + // $error_string = preg_replace("/(<\/?)(\w+)([^>]*>)/", "##\\2##", $error_string); + // $error_string = preg_replace("/(<\/?)(\w+)([^>]*>)/", "", $error_string); // replace special line break tag - // $error_string = str_replace('', "\n", $error_string); + // $error_string = str_replace('', "\n", $error_string); // init output variable $output = $error_string; // output formated error string to output file // init base file path - $fn = ROOT.LOG.$this->log_print_file.'.'.$this->log_file_name_ext; + $fn = BASE.LOG.$this->log_print_file.'.'.$this->log_file_name_ext; // log ID prefix settings, if not valid, replace with empty if (preg_match("/^[A-Za-z0-9]+$/", $this->log_file_id)) { $rpl_string = '_'.$this->log_file_id; @@ -638,10 +657,10 @@ class basic $rpl_string = !$this->log_per_level ? '' : '_'.$level; // if request to write to one file $fn = str_replace('##LEVEL##', $rpl_string, $fn); // create output filename - $rpl_string = !$this->log_per_class ? '' : '_'.get_class($this); // set sub class settings + $rpl_string = !$this->log_per_class ? '' : '_'.str_replace('\\', '-', get_class($this)); // set sub class settings $fn = str_replace('##CLASS##', $rpl_string, $fn); // create output filename - $rpl_string = !$this->log_per_page ? '' : '_'.$this->get_page_name(1); // if request to write to one file + $rpl_string = !$this->log_per_page ? '' : '_'.$this->getPageName(1); // if request to write to one file $fn = str_replace('##PAGENAME##', $rpl_string, $fn); // create output filename // write to file @@ -661,13 +680,14 @@ class basic } } - // METHOD reset_error_msg - // PARAMS level -> optional level - // RETURN none - // DESC unsests the error message array - // can be used if writing is primary to file - // if no level given resets all - public function reset_error_msg($level = '') + // METHOD: resetErrorMsg + // WAS : reset_error_msg + // PARAMS: level -> optional level + // RETURN: none + // DESC : unsests the error message array + // can be used if writing is primary to file + // if no level given resets all + public function resetErrorMsg($level = '') { if (!$level) { unset($this->error_msg); @@ -676,14 +696,17 @@ class basic } } - // METHOD ErrorHandler - // PARAMS none - // RETURN none - // DESC catch function to handle all errors that are not handled by php itself - // eg all errors that would be surpressed are written to a log file if this function is enabled - // to use it call with set_error_handler(array("baisc", "ErrorHandler")); - // NOTE: this will only catch any additional erros created AFTER the set_error_hanlder was set, so mostly no strict/notices from the classes are visible - public static function ErrorHandler($type, $message, $file, $line, $context) + // METHOD: errorHandler + // WAS : ErrorHandler + // PARAMS: none + // RETURN: none + // DESC : catch function to handle all errors that are not handled by php itself + // eg all errors that would be surpressed are written to a log file if this function is enabled + // to use it call with set_error_handler(array("Basic", "ErrorHandler")); + // NOTE : this will only catch any additional erros created AFTER the set_error_handler was set, + // so mostly no strict/notices from the classes are visible + // also, this currently returns true, which will invoke the standard PHP error reporter too + public static function errorHandler($type, $message, $file, $line) { // error levels for PHP // values based on 5.3 @@ -706,32 +729,32 @@ class basic 30719 => 'E_ALL' // 6143 in 5.2, 2047 in previous versions ); - $fn = ROOT.LOG.'php_errors-'.date('Y-m-d').'.log'; - $output = '['.basic::print_time().'] {'.basic::get_page_name().'} ['.$file.'] <'.$line.'> ['.$error_level[$type].'|'.$type.']: '.$message."\n"; + $fn = BASE.LOG.'php_errors-'.date('Y-m-d').'.log'; + $output = '['.Basic::print_time().'] {'.Basic::get_page_name().'} ['.$file.'] <'.$line.'> ['.$error_level[$type].'|'.$type.']: '.$message."\n"; $fp = fopen($fn, 'a'); fwrite($fp, $output); fclose($fp); + // if set to false the PHP error reporter will be called after this return false; } - // METHOD print_ar - // PARAMS $array - // RETURN string html formatted - // DESCRIPTION - // prints a html formatted (pre) array - public static function print_ar($array) + // METHOD: printAr + // WAS : print_ar + // PARAMS: $array + // RETURN: string html formatted + // DESC : prints a html formatted (pre) array + public static function printAr($array) { return "
".print_r($array, 1)."
"; } - // METHOD checked - // PARAMS haystack (search in), needle (search for), type: 0: returns selected, 1, returns checked - // haystack can be an array or a string - // RETURN returns checked or selected, else returns nothing (empty return) - // DESCRIPTION - // returns 'checked' or 'selected' if okay - // $needle is a var, $haystack an array - // **** THE RETURN VALUE WILL CHANGE TO A DEFAULT "FALSE" **** + // METHOD: checked + // PARAMS: haystack (search in), needle (search for), type: 0: returns selected, 1, returns checked + // haystack can be an array or a string + // RETURN: returns checked or selected, else returns nothing (empty return) + // DESC : returns 'checked' or 'selected' if okay + // $needle is a var, $haystack an array + // **** THE RETURN: VALUE WILL CHANGE TO A DEFAULT "FALSE" **** public static function checked($haystack, $needle, $type = 0) { if (is_array($haystack)) { @@ -745,14 +768,14 @@ class basic } } - // METHOD magic_links - // PARAMS string: data to transform to a valud HTML url, target: default _blank - // RETURN correctly formed html url link - // DESCRIPTION - // tries to find mailto:user@bubu.at and changes it into ->
E-Mail senden - // or tries to take any url (http, ftp, etc) and transform it into a valid URL - // the string is in the format: some url|name#css|, same for email - public function magic_links($string, $target = "_blank") + // METHOD: magicLinks + // WAS : magic_links + // PARAMS: string: data to transform to a valud HTML url, target: default _blank + // RETURN: correctly formed html url link + // DESC : tries to find mailto:user@bubu.at and changes it into -> E-Mail senden + // or tries to take any url (http, ftp, etc) and transform it into a valid URL + // the string is in the format: some url|name#css|, same for email + public function magicLinks($string, $target = "_blank") { $output = $string; $protList = array("http", "https", "ftp", "news", "nntp"); @@ -784,11 +807,11 @@ class basic // _7: link name/email link name // _9: style sheet class $self = $this; -// $this->debug('URL', 'Before: '.$output); + // $this->debug('URL', 'Before: '.$output); $output = preg_replace_callback( "/(href=\")?(\>)?\b($protRegex)([\w\.\-?&=+%#~,;\/]+)\b([\.\-?&=+%#~,;\/]*)(\|([^\||^#]+)(#([^\|]+))?\|)?/", function ($matches) use ($self) { - return @$self->create_url($matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[7], $matches[9]); + return @$self->createUrl($matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[7], $matches[9]); }, $output ); @@ -796,15 +819,15 @@ class basic $output = preg_replace_callback( "/(mailto:)?(\>)?\b([\w\.-]+)@([\w\.\-]+)\.([a-zA-Z]{2,4})\b(\|([^\||^#]+)(#([^\|]+))?\|)?/", function ($matches) use ($self) { - return @$self->create_email($matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[7], $matches[9]); + return @$self->createEmail($matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[7], $matches[9]); }, $output ); $this->debug('URL', 'After: '.$output); -// // we have one slashes after the Protocol -> internal link no domain, strip out the proto -// $output = preg_replace("/($protRegex)\/(.*)/e", "\\2", $ouput); -// $this->debug('URL', "$output"); + // we have one slashes after the Protocol -> internal link no domain, strip out the proto + // $output = preg_replace("/($protRegex)\/(.*)/e", "\\2", $ouput); + // $this->debug('URL', "$output"); // post processing $output = str_replace("{TARGET}", $target, $output); @@ -815,18 +838,18 @@ class basic return $output; } - // METHOD create_url [INTERNAL] - // PARAMS url link, anchor tag (define both type or url), - // _1, _2, _3 = part of thel URL, if atag is set, _1 is not used - // target: link target, name: name for the url, if not given _2 + _3 is used - // class: style sheet - // RETURN correct string for url href process - // DESCRIPTION - // internal function, called by the magic url create functions. - // checks if title $_4 exists, if not, set url as title - private function create_url($href, $atag, $_1, $_2, $_3, $name, $class) + // METHOD: createUrl [INTERNAL] + // WAS : create_url + // PARAMS: url link, anchor tag (define both type or url), + // _1, _2, _3 = part of thel URL, if atag is set, _1 is not used + // target: link target, name: name for the url, if not given _2 + _3 is used + // class: style sheet + // RETURN: correct string for url href process + // DESC : internal function, called by the magic url create functions. + // checks if title $_4 exists, if not, set url as title + private function createUrl($href, $atag, $_1, $_2, $_3, $name, $class) { -// $this->debug('URL', "1: $_1 - 2: $_2 - $_3 - atag: $atag - name: $name - class: $class"); + // $this->debug('URL', "1: $_1 - 2: $_2 - $_3 - atag: $atag - name: $name - class: $class"); // if $_1 ends with //, then we strip $_1 complete & target is also blanked (its an internal link) if (preg_match("/\/\/$/", $_1) && preg_match("/^\//", $_2)) { $_1 = ''; @@ -844,14 +867,14 @@ class basic } } - // METHOD create_email [INTERNAL] + // METHOD: createEmail [INTERNAL] + // WAS : create_email // PARAMS: email address, atag (define type of url) // _1, _2, _3: parts of the email _1 before @, _2 after @, 3_ tld // title: name for the link, if not given use email // class: style sheet - // DESCRIPTION - // internal function for createing email, returns data to magic_url method - private function create_email($mailto, $atag, $_1, $_2, $_3, $title, $class) + // DESC : internal function for createing email, returns data to magic_url method + private function createEmail($mailto, $atag, $_1, $_2, $_3, $title, $class) { $email = $_1."@".$_2.".".$_3; if (!$mailto && !$atag) { @@ -863,12 +886,12 @@ class basic } } - // METHOD get_host_name - // PARAMS none - // RETURN host name - // DESCRIPTION - // get the host name without the port as given by the SELF var - public function get_host_name() + // METHOD: getHostName + // WAS : get_host_name + // PARAMS: none + // RETURN: host name + // DESC : get the host name without the port as given by the SELF var + public function getHostName() { $port = ''; if ($_SERVER['HTTP_HOST'] && preg_match("/:/", $_SERVER['HTTP_HOST'])) { @@ -882,14 +905,14 @@ class basic return $host_name; } - // METHOD get_page_name - // PARAMS 1: strip page file name extension - // 0: keep filename as is - // 2: keep filename as is, but add dirname too - // RETURN filename - // DESCRIPTION - // get the page name of the curronte page: - public static function get_page_name($strip_ext = 0) + // METHOD: getPageName + // WAS : get_page_name + // PARAMS: 1: strip page file name extension + // 0: keep filename as is + // 2: keep filename as is, but add dirname too + // RETURN: filename + // DESC : get the page name of the curronte page: + public static function getPageName($strip_ext = 0) { // get the file info $page_temp = pathinfo($_SERVER["PHP_SELF"]); @@ -902,26 +925,26 @@ class basic } } - // METHOD get_file_name_ending - // PARAMS filename - // RETURN extension of the file name - // DESCRIPTION - // quick return the extension of the given file name - public static function get_filename_ending($filename) + // METHOD: getFilenameEnding + // WAS : get_filename_ending + // PARAMS: filename + // RETURN: extension of the file name + // DESC : quick return the extension of the given file name + public static function getFilenameEnding($filename) { $page_temp = pathinfo($filename); return $page_temp['extension']; } - // METHOD array_search_recursive - // PARAMS needle (search for) - // haystack (search in) - // key_lookin: the key to look out for, default empty - // RETURN array with the elements where the needle can be found in the haystack array - // DESCRIPTION - // searches key = value in an array / array - // only returns the first one found - public static function array_search_recursive($needle, $haystack, $key_lookin = "") + // METHOD: arraySearchRecursive + // WAS : array_search_recursive + // PARAMS: needle (search for) + // haystack (search in) + // key_lookin: the key to look out for, default empty + // RETURN: array with the elements where the needle can be found in the haystack array + // DESC : searches key = value in an array / array + // only returns the first one found + public static function arraySearchRecursive($needle, $haystack, $key_lookin = "") { $path = null; if (!is_array($haystack)) { @@ -932,15 +955,11 @@ class basic } else { foreach ($haystack as $key => $val) { if (is_scalar($val) && $val === $needle && empty($key_lookin)) { -//echo "BAR FOUND $needle
"; - $path[] = $key; break; } elseif (is_scalar($val) && !empty($key_lookin) && $key === $key_lookin && $val == $needle) { -//echo "FOO FOUND $needle | $key | $val
"; $path[] = $key; break; - } elseif (is_array($val) && $path = basic::array_search_recursive($needle, $val, $key_lookin)) { -//echo "BAS FOUND $needle | ".print_r($path)."
"; + } elseif (is_array($val) && $path = Basic::arraySearchRecursive($needle, $val, $key_lookin)) { array_unshift($path, $key); break; } @@ -949,15 +968,15 @@ class basic return $path; } - // METHOD array_search_recursive_all - // PARAMS needle (search for) - // haystack (search in) - // key: the key to look for in - // path: recursive call for previous path - // RETURN all array elements paths where the element was found - // DESCRIPTION - // recursive array search function, which returns all found not only the first one - public static function array_search_recursive_all($needle, $haystack, $key, $path = null) + // METHOD: arraySearchRecursiveAll + // WAS : array_search_recursive_all + // PARAMS: needle (search for) + // haystack (search in) + // key: the key to look for in + // path: recursive call for previous path + // RETURN: all array elements paths where the element was found + // DESC : recursive array search function, which returns all found not only the first one + public static function arraySearchRecursiveAll($needle, $haystack, $key, $path = null) { if (!isset($path['level'])) { $path['level'] = 0; @@ -985,7 +1004,7 @@ class basic // we will up a level $path['level'] += 1; // call recursive - $path = basic::array_search_recursive_all($needle, $_value, $key, $path); + $path = Basic::arraySearchRecursiveAll($needle, $_value, $key, $path); } } // cut all that is >= level @@ -995,12 +1014,12 @@ class basic return $path; } - // METHOD array_search_simple - // PARAMS array (search in), key (key to search in), value (what to find - // RETURN true on found, false on not found - // DESCRIPTION - // array search simple. looks for key, value combination, if found, returns true - public static function array_search_simple($array, $key, $value) + // METHOD: arraySearchSimple + // WAS : array_search_simple + // PARAMS: array (search in), key (key to search in), value (what to find + // RETURN: true on found, false on not found + // DESC : array search simple. looks for key, value combination, if found, returns true + public static function arraySearchSimple($array, $key, $value) { if (!is_array($array)) { $array = array (); @@ -1009,7 +1028,7 @@ class basic // if value is an array, we search if (is_array($_value)) { // call recursive, and return result if it is true, else continue - if (($result = basic::array_search_simple($_value, $key, $value)) !== false) { + if (($result = Basic::arraySearchSimple($_value, $key, $value)) !== false) { return $result; } } elseif ($_key == $key && $_value == $value) { @@ -1020,12 +1039,61 @@ class basic return false; } - // METHOD _mb_mime_encode - // PARAMS string to encode, encoding to encode in - // RETURN encoded string - // DESCRIPTION - // wrapper function for mb mime convert, for correct conversion with long strings - public static function _mb_mime_encode($string, $encoding) + // METHOD: inArrayAny + // WAS : in_array_any + // PARAMS: needle: array + // haystack: array + // RETURN: found elements: array + // DESC : search for the needle array elements in haystack and return the ones found as an array, + // is there nothing found, it returns FALSE (boolean) + public static function inArrayAny($needle, $haystack) + { + if (!is_array($needle)) { + return false; + } + if (!is_array($haystack)) { + return false; + } + $found = array (); + foreach ($needle as $element) { + if (in_array($element, $haystack)) { + $found[] = $element; + } + } + if (count($found) == 0) { + return false; + } else { + return $found; + } + } + + // METHOD: genAssocArray + // WAS : GenAssocArray + // PARAMS: db array, key, value part, flag if set all or only set + // RETURN: returns and associative array + // DESC : creates out of a normal db_return array an assoc array + public static function genAssocArray($db_array, $key, $value, $set_only = 0) + { + // do this to only run count once + for ($i = 0, $iMax = count($db_array); $i < $iMax; $i ++) { + // if no key then we make an order reference + if ($key && $value && (($set_only && $db_array[$i][$value]) || (!$set_only))) { + $ret_array[$db_array[$i][$key]] = $db_array[$i][$value]; + } elseif (!$key && $value) { + $ret_array[] = $db_array[$i][$value]; + } elseif ($key && !$value) { + $ret_array[$db_array[$i][$key]] = $i; + } + } + return $ret_array; + } + + // METHOD: __mbMimeEncode + // WAS : _mb_mime_encode + // PARAMS: string to encode, encoding to encode in + // RETURN: encoded string + // DESC : wrapper function for mb mime convert, for correct conversion with long strings + public static function __mbMimeEncode($string, $encoding) { // set internal encoding, so the mimeheader encode works correctly mb_internal_encoding($encoding); @@ -1053,11 +1121,12 @@ class basic return $string; } - // METHOD: ByteStringFormat + // METHOD: byteStringFormat + // WAS : ByteStringFormat // PARAMS: int bytes, boolean for space, default is set // RETURN: string - // DESC: converts bytes into formated string with KB, MB, etc - public static function ByteStringFormat($number, $space = true) + // DESC : converts bytes into formated string with KB, MB, etc + public static function byteStringFormat($number, $space = true) { if (is_numeric($number) && $number > 0) { // labels in order of size @@ -1068,15 +1137,19 @@ class basic return $number; } - // METHOD: StringByteFormat + // METHOD: stringByteFormat + // WAS : StringByteFormat // PARAMS: string // RETURN: int - // DESC: calculates the bytes based on a string with nnG, nnM, etc - public static function StringByteFormat($number) + // DESC : calculates the bytes based on a string with nnG, nnM, etc + public static function stringByteFormat($number) { $number = trim($number); $last = strtolower($number[strlen($number) - 1]); switch ($last) { + case 't': + $number *= 1024; + // no break, calc down next level case 'g': $number *= 1024; // no break: if we have giga we do first multiplication before the others @@ -1089,26 +1162,27 @@ class basic return $number; } - // METHOD: DateStringFormat + // METHOD: dateStringFormat + // WAS : DateStringFormat // PARAMS: unix timestamp, true/false to show microtime // RETURN: string formated date+time in Y-M-D h:m:s // DESC : a simple wrapper for the date format - public static function DateStringFormat($timestamp, $show_micro = true) + public static function dateStringFormat($timestamp, $show_micro = true) { list ($timestamp, $ms) = explode('.', round($timestamp, 4)); + $string = date("Y-m-d H:i:s", $timestamp); if ($show_micro) { - $string = date("Y-m-d H:i:s", $timestamp).' '.$ms.'ms'; - } else { - $string = date("Y-m-d H:i:s", $timestamp); + $string .= ' '.$ms.'ms'; } return $string; } - // METHOD: TimeStringFormat + // METHOD: timeStringFormat + // WAS : TimeStringFormat // PARAMS: seconds // RETURN: formated time string - // DESC: formats a timestamp into time from. not a date - public static function TimeStringFormat($timestamp, $show_micro = true) + // DESC : formats a timestamp into time from. not a date + public static function timeStringFormat($timestamp, $show_micro = true) { // check if the timestamp has any h/m/s/ms inside, if yes skip if (!preg_match("/(h|m|s|ms)/", $timestamp)) { @@ -1117,7 +1191,7 @@ class basic $timegroups = array (86400, 3600, 60, 1); $labels = array ('d', 'h', 'm', 's'); $time_string = ''; - for ($i = 0; $i < count($timegroups); $i ++) { + for ($i = 0, $iMax = count($timegroups); $i < $iMax; $i ++) { $output = floor($timestamp / $timegroups[$i]); $timestamp = $timestamp % $timegroups[$i]; // output has days|hours|min|sec @@ -1139,12 +1213,13 @@ class basic return $time_string; } - // METHOD: StringToTime + // METHOD: stringToTime + // WAS : StringToTime // PARAMS: TimeStringFormat string // RETURN: timestamp with microseconds // DESC : does a reverse of the TimeStringFormat and converts the string from // xd xh xm xs xms to a timestamp.microtime format - public static function StringToTime($timestring) + public static function stringToTime($timestring) { $timestamp = ''; if (preg_match("/(d|h|m|s|ms)/", $timestring)) { @@ -1165,30 +1240,12 @@ class basic } } - // METHOD: GenAssocArray - // PARAMS: db array, key, value part, flag if set all or only set - // RETURN: returns and associative array - // DESC: creates out of a normal db_return array an assoc array - public static function GenAssocArray($db_array, $key, $value, $set_only = 0) - { - for ($i = 0; $i < count($db_array); $i ++) { - // if no key then we make an order reference - if ($key && $value && (($set_only && $db_array[$i][$value]) || (!$set_only))) { - $ret_array[$db_array[$i][$key]] = $db_array[$i][$value]; - } elseif (!$key && $value) { - $ret_array[] = $db_array[$i][$value]; - } elseif ($key && !$value) { - $ret_array[$db_array[$i][$key]] = $i; - } - } - return $ret_array; - } - - // METHOD: CheckDate + // METHOD: checkDate + // WAS : CheckDate // PARAMS: date (YYYY-MM-DD) // RETURN: true if valid date, false if date not valid - // DESC: splits & checks date, wrap around for check_date function - public static function CheckDate($date) + // DESC : splits & checks date, wrap around for check_date function + public static function checkDate($date) { list ($year, $month, $day) = preg_split("/[\/-]/", $date); if (!$year || !$month || !$day) { @@ -1200,11 +1257,12 @@ class basic return true; } - // METHOD: CheckDateTime + // METHOD: checkDateTime + // WAS : CheckDateTime // PARAMS: date (YYYY-MM-DD) + time (HH:MM:SS), SS can be dropped // RETURN: true if valid date, false if date not valid - // DESC: splits & checks date, wrap around for check_date function - public static function CheckDateTime($datetime) + // DESC : splits & checks date, wrap around for check_date function + public static function checkDateTime($datetime) { list ($year, $month, $day, $hour, $min, $sec) = preg_split("/[\/\- :]/", $datetime); if (!$year || !$month || !$day) { @@ -1222,11 +1280,12 @@ class basic return true; } - // METHOD: CompareDate + // METHOD: compareDate + // WAS : CompareDate // PARAMS: start_date, end_date (both: YYYY-MM-DD) // RETURN: -1 if the first date is smaller the last, 0 if both are equal, 1 if the end date is bigger than the last - // DESC: splits & checks date, wrap around for check_date function - public static function CompareDate($start_date, $end_date) + // DESC : splits & checks date, wrap around for check_date function + public static function compareDate($start_date, $end_date) { // pre check for empty or wrong if ($start_date == '--' || $end_date == '--' || !$start_date || !$end_date) { @@ -1263,11 +1322,12 @@ class basic } } - // METHOD: CompareDateTime + // METHOD: compareDateTime + // WAS : CompareDateTime // PARAMS: start_datetime, end_datetime (both YYYY-MM-DD HH:mm:ss) // RETURN: -1 if the first date is smaller the last, 0 if both are equal, 1 if the end date is bigger than the last // DESC : compares the two dates + times. if seconds missing in one set, add :00, converts / to - - public static function CompareDateTime($start_datetime, $end_datetime) + public static function compareDateTime($start_datetime, $end_datetime) { // pre check for empty or wrong if ($start_date == '--' || $end_date == '--' || !$start_date || !$end_date) { @@ -1286,11 +1346,12 @@ class basic } } - // METHOD: ArrayToString + // METHOD: arrayToString + // WAS : ArrayToString // PARAMS: array, connect char // RETRUN: string - // DESC: wrapper for join, but checks if input is an array and if not returns null - public static function ArrayToString($array, $connect_char) + // DESC : wrapper for join, but checks if input is an array and if not returns null + public static function arrayToString($array, $connect_char) { if (is_array($array)) { return join($connect_char, $array); @@ -1299,7 +1360,8 @@ class basic } } - // METHOD: CreateThumbnail + // METHOD: createThumbnail + // WAS : CreateThumbnail // PARAMS: pic -> picture where from we create a thumbnail // x -> max x size of thumbnail // y -> max y size of thumbnail @@ -1308,8 +1370,8 @@ class basic // cache -> cache path, if not given TMP is used // clear cache -> if set to true, will create thumb all the tame // RETURN: thumbnail name - // DESC: converts picture to a thumbnail with max x and max y size - public static function CreateThumbnail($pic, $size_x, $size_y, $dummy = "", $path = "", $cache_source = "", $clear_cache = false) + // DESC : converts picture to a thumbnail with max x and max y size + public static function createThumbnail($pic, $size_x, $size_y, $dummy = "", $path = "", $cache_source = "", $clear_cache = false) { // get image type flags $image_types = array ( @@ -1321,12 +1383,12 @@ class basic if ($cache_source) { $tmp_src = $cache_source; } else { - $tmp_src = ROOT.TMP; + $tmp_src = BASE.TMP; } // check if pic has a path, and override next sets if (strstr($pic, '/') === false) { if (!$path) { - $path = ROOT; + $path = BASE; } $filename = $path.MEDIA.PICTURES.$pic; } else { @@ -1414,21 +1476,13 @@ class basic return $return_data; } - // *** DEPRICATED CALL *** - // should be removed later - public function checkConvert($string, $from_encoding, $to_encoding) - { - $this->debug('DEPRICATED CALL', 'Depricated call for method: checkConvert [NOW: checkConvertEncoding]'); - return $this->checkConvertEncoding($string, $from_encoding, $to_encoding); - } - // METHOD: checkConvertEncoding // PARAMS: string: string to test // from_encoding: source encoding of this string // to_encoding: target encoding of this string // RETURN: false if no problem // on error, return array with characters that failed in the convert - // DESC: test if a string can be safely convert between encodings. mostly utf8 to shift jis + // DESC : test if a string can be safely convert between encodings. mostly utf8 to shift jis // the default compare has a possibility of failure, especially with windows // it is recommended to the following in the script which uses this method: // mb_substitute_character(0x2234); @@ -1446,11 +1500,11 @@ class basic // if string does not match anymore we have a convert problem if ($string != $compare) { // go through each character and find the ones that do not match - for ($i = 0; $i < mb_strlen($string, $from_encoding); $i ++) { + for ($i = 0, $iMax = mb_strlen($string, $from_encoding); $i < $iMax; $i ++) { $char = mb_substr($string, $i, 1, $from_encoding); $r_char = mb_substr($compare, $i, 1, $from_encoding); // the ord 194 is a hack to fix the IE7/IE8 bug with line break and illegal character -// $this->debug('CHECK CONVERTT', '['.$this->mbErrorChar.'] O: '.$char.', C: '.$r_char); + // $this->debug('CHECK CONVERTT', '['.$this->mbErrorChar.'] O: '.$char.', C: '.$r_char); if ((($char != $r_char && !$this->mbErrorChar) || ($char != $r_char && $r_char == $this->mbErrorChar && $this->mbErrorChar)) && ord($char) != 194) { $this->debug('CHARS', "'".$char."'".' == '.$r_char.' ('.ord($char).')'); $failed[] = $char; @@ -1484,42 +1538,45 @@ class basic return $string; } - // METHOD: _crc32b + // METHOD: __crc32b + // WAS : _crc32b // PARAMS: string // RETURN: old (wrong) crc32b hash - // DESC: checks php version and if >=5.2.7 it will flip the string - public function _crc32b($string) + // DESC : checks php version and if >=5.2.7 it will flip the string + public function __crc32b($string) { // do normal hash crc32b $string = hash('crc32b', $string); // if bigger than 5.2.7, we need to "unfix" the fix - if ($this->checkPHPVersion('5.2.7')) { + if (self::checkPHPVersion('5.2.7')) { // flip it back to old (two char groups) $string = preg_replace("/^([a-z0-9]{2})([a-z0-9]{2})([a-z0-9]{2})([a-z0-9]{2})$/", "$4$3$2$1", $string); } return $string; } - // METHOD: _sha1_short + // METHOD: __sha1Short + // WAS : _sha1_short // PARAMS: string, flag to use sha - // RETURN: sha1 short (9 chars), but current calls _crc32b - // DESC : replacement for _crc32b call - public function _sha1_short($string, $use_sha = false) + // RETURN: sha1 short (9 chars), but current calls __crc32b + // DESC : replacement for __crc32b call + public function __sha1Short($string, $use_sha = false) { if ($use_sha) { return substr(hash('sha1', $string), 0, 9); } else { - return $this->_crc32b($string); + return $this->__crc32b($string); } } - // METHOD: _hash + // METHOD: __hash + // WAS : _hash // PARAMS: string, type of hash to use // RETURN: hashed string - // DESC : replacemend for _crc32b call (alternate) + // DESC : replacemend for __crc32b call (alternate) // defaults to adler 32, fnv132, fnv1a32, joaat // all that create 8 char long hashes - public function _hash($string, $hash_type = 'adler32') + public function __hash($string, $hash_type = 'adler32') { if (!in_array($hash_type, array('adler32', 'fnv132', 'fnv1a32', 'joaat'))) { $hash_type = 'adler32'; @@ -1531,6 +1588,7 @@ class basic // PARAMS: $min_version: minimum version. in format x, x.y or x.y.z // $max_version: default empty, else in same format as min version // RETURN: true if ok, false if not matching version + // DESC : checks if running PHP version matches given PHP version (min or max) public static function checkPHPVersion($min_version, $max_version = '') { // exit with false if the min/max strings are wrong @@ -1575,7 +1633,7 @@ class basic // METHOD: cryptInit // PARAMS: none // RETURN: none - // DESC: inits crypt settings for the crypt functions + // DESC : inits crypt settings for the crypt functions // this function NEEDS (!) to be called BEFORE any of the crypt functions is called // there is no auto init for this at the moment private function cryptInit() @@ -1586,10 +1644,10 @@ class basic // WARNING: des is very bad, only first 6 chars get used for the password // MD5 is a bit better but is already broken // problem with PHP < 5.3 is that you mostly don't have access to blowfish - if (CRYPT_BLOWFISH == 1 || $this->checkPHPVersion('5.3.0')) { + if (CRYPT_BLOWFISH == 1 || self::checkPHPVersion('5.3.0')) { // blowfish salt prefix // for < 5.3.7 use the old one for anything newer use the new version - if ($this->checkPHPVersion('5.3.7')) { + if (self::checkPHPVersion('5.3.7')) { $this->cryptSaltPrefix = '$2y$'; } else { $this->cryptSaltPrefix = '$2a$'; @@ -1621,7 +1679,7 @@ class basic // METHOD: cryptSaltString // PARAMS: random string length, default is 22 (for blowfish crypt) // RETURN: random string - // DESC: creates a random string from alphanumeric characters: A-Z a-z 0-9 ./ + // DESC : creates a random string from alphanumeric characters: A-Z a-z 0-9 ./ private function cryptSaltString($nSize = 22) { // A-Z is 65,90 @@ -1631,7 +1689,7 @@ class basic $min = array (46, 65, 97); $max = array (57, 90, 122); $chars = array (); - for ($i = 0; $i < count($min); $i ++) { + for ($i = 0, $iMax = count($min); $i < $iMax; $i ++) { for ($j = $min[$i]; $j <= $max[$i]; $j ++) { $chars[] = chr($j); } @@ -1648,7 +1706,7 @@ class basic // METHOD: cryptString // PARAMS: string to be crypted (one way) // RETURN: encrypted string - // DESC: encrypts the string with blowfish and returns the full string + salt part that needs to be stored somewhere (eg DB) + // DESC : encrypts the string with blowfish and returns the full string + salt part that needs to be stored somewhere (eg DB) public function cryptString($string) { // the crypt prefix is set in the init of the class @@ -1660,7 +1718,7 @@ class basic // PARAMS: plain string (eg password) // full crypted string (from cryptString // RETURN: true on matching or false for not matching - // DESC: compares the string with the crypted one, is counter method to cryptString + // DESC : compares the string with the crypted one, is counter method to cryptString public function verifyCryptString($string, $crypt) { // the full crypted string needs to be passed on to the salt, so the init (for blowfish) and salt are passed on @@ -1676,7 +1734,7 @@ class basic // METHOD: hex2rgb // PARAMS: hexstring, flag to return as string (true/false), string seperator: default: , // RETURN: array with RGB or a string with the seperator - // DESC: converts a hex RGB color to the int numbers + // DESC : converts a hex RGB color to the int numbers public static function hex2rgb($hexStr, $returnAsString = false, $seperator = ',') { $hexStr = preg_replace("/[^0-9A-Fa-f]/", '', $hexStr); // Gets a proper hex string @@ -1701,7 +1759,7 @@ class basic // METHOD: rgb2hex // PARAMS: red, green, blue (0-255) // RETURN: string with hex rgb color plus # in front - // DESC: converts the rgb values from int data to the valid rgb html hex string + // DESC : converts the rgb values from int data to the valid rgb html hex string public static function rgb2hex($red, $green, $blue) { $hex_color = '#'; @@ -1860,7 +1918,7 @@ class basic // METHOD: hsl2rgb // PARAMS: hue: 0-360 (degrees) // saturation: 0-1 - // luminance: 0-1 + // luminance: 0-1 // RETURN: array with RGB as full int // DESC : converts an HSL to RGB public static function hsl2rgb($h, $s, $l) @@ -1896,7 +1954,7 @@ class basic // METHOD: rgb2html // PARAMS: red, green, blue - // RETRUN: valid # prefix hex html color string + // RETRUN valid # prefix hex html color string // DESC : converts and int RGB to the HTML color string in hex format public static function rgb2html($red, $green, $blue) { @@ -1914,36 +1972,10 @@ class basic return '#'.$red.$green.$blue; } - // METHOD: in_array_any - // PARAMS: needle: array - // haystack: array - // RETURN: found elements: array - // DESC: search for the needle array elements in haystack and return the ones found as an array, is there nothing found, it returns FALSE (boolean) - public static function in_array_any($needle, $haystack) - { - if (!is_array($needle)) { - return false; - } - if (!is_array($haystack)) { - return false; - } - $found = array (); - foreach ($needle as $element) { - if (in_array($element, $haystack)) { - $found[] = $element; - } - } - if (count($found) == 0) { - return false; - } else { - return $found; - } - } - // METHOD: getEmailType // PARAMS: email, short == false // RETURN: string for email type, eg "pc", "docomo", etc - // DESC: guesses the email type (mostly for mobile) from the domain + // DESC : guesses the email type (mostly for mobile) from the domain // if second is set to true, it will return short naming scheme (only provider) public function getEmailType($email, $short = false) { @@ -1980,16 +2012,22 @@ class basic // METHOD: printDateTime // PARAMS: year, month, day, hour, min: the date and time values - // suffix: additional info printed after the date time variable in the drop down, also used for ID in the on change JS call + // suffix: additional info printed after the date time variable in the drop down, + // also used for ID in the on change JS call // min_steps: default is 1 (minute), can set to anything, is used as sum up from 0 + // name_pos_back: default false, if set to true, the name will be printend + // after the drop down and not before the drop down // RETURN: HTML formated strings for drop down lists of date and time - // DESC: print the date/time drop downs, used in any queue/send/insert at date/time place - public static function printDateTime($year, $month, $day, $hour, $min, $suffix = '', $min_steps = 1) + // DESC : print the date/time drop downs, used in any queue/send/insert at date/time place + public static function printDateTime($year, $month, $day, $hour, $min, $suffix = '', $min_steps = 1, $name_pos_back = false) { // if suffix given, add _ before if ($suffix) { $suffix = '_'.$suffix; } + if ($min_steps < 1 || $min_steps > 59) { + $min_steps = 1; + } $on_change_call = 'dt_list(\''.$suffix.'\');'; @@ -2009,33 +2047,62 @@ class basic $days_in_month = date("t", strtotime($year."-".$month."-".$day." ".$hour.":".$min.":0")); // from now to ? - $string = 'Year '; + if ($name_pos_back === false) { + $string = 'Year '; + } $string .= ' Month '; + $string .= ' '; + if ($name_pos_back === true) { + $string .= 'Year '; + } + if ($name_pos_back === false) { + $string .= 'Month '; + } $string .= ' Day '; + $string .= ' '; + if ($name_pos_back === true) { + $string .= 'Month '; + } + if ($name_pos_back === false) { + $string .= 'Day '; + } $string .= ' Hour '; + $string .= ' '; + if ($name_pos_back === true) { + $string .= 'Day '; + } + if ($name_pos_back === false) { + $string .= 'Hour '; + } $string .= ' Minute '; + $string .= ' '; + if ($name_pos_back === true) { + $string .= 'Hour '; + } + if ($name_pos_back === false) { + $string .= 'Minute '; + } $string .= ''; + if ($name_pos_back === true) { + $string .= ' Minute '; + } // return the datetime select string return $string; } @@ -2069,4 +2136,166 @@ class basic { return $_SESSION[$name] === $token; } + + // ************************************************************* + // *** DEPRICATED CALL *** + // ************************************************************* + // should be removed later + public function checkConvert($string, $from_encoding, $to_encoding) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->checkConvertEncoding($string, $from_encoding, $to_encoding); + } + + // ************************************************************* + // *** COMPATIBILITY METHODS *** + // those methods are deprecated function call names + // they exist for backwards compatibility only + // ************************************************************* + + public function running_time($simple = false) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->runningTime($simple); + } + + public static function print_time($set_microtime = -1) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return Basic::printTime($set_microtime); + } + + private function fdebug_fp($flag = '') + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->fdebugFP($flag); + } + + public function debug_for($type, $flag) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->debugFor($type, $flag); + } + + public function get_caller_method($level = 2) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->getCallerMethod($level); + } + + public function merge_errors($error_msg = array ()) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->mergeErrors($error_msg); + } + + public function print_error_msg($string = '') + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->printErrorMsg($string); + } + + private function write_error_msg($level, $error_string) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->writeErrorMsg($level, $error_string); + } + + public function reset_error_msg($level = '') + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->resetErrorMsg($level); + } + + public static function print_ar($array) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return Basic::printAr($array); + } + + public function magic_links($string, $target = "_blank") + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->magicLinks($string, $target); + } + + private function create_url($href, $atag, $_1, $_2, $_3, $name, $class) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->createUrl($href, $atag, $_1, $_2, $_3, $name, $class); + } + + private function create_email($mailto, $atag, $_1, $_2, $_3, $title, $class) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->createEmail($mailto, $atag, $_1, $_2, $_3, $title, $class); + } + + public function get_host_name() + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->getHostName(); + } + + public static function get_page_name($strip_ext = 0) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return Basic::getPageName($strip_ext); + } + + public static function get_filename_ending($filename) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return Basic::getFilenameEnding($filename); + } + + public static function array_search_recursive($needle, $haystack, $key_lookin = "") + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return Basic::arraySearchRecursive($needle, $haystack, $key_lookin); + } + + public static function array_search_recursive_all($needle, $haystack, $key, $path = null) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return Basic::arraySearchRecursiveAll($needle, $haystack, $key, $path); + } + + public static function array_search_simple($array, $key, $value) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return Basic::arraySearchSimple($array, $key, $value); + } + + public static function _mb_mime_encode($string, $encoding) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return Basic::__mbMimeEncode($string, $encoding); + } + + public function _crc32b($string) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->__crc32b($string); + } + + public function _sha1_short($string, $use_sha = false) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->__sha1Short($string, $use_sha); + } + + public function _hash($string, $hash_type = 'adler32') + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->__hash($string, $hash_type); + } + + public static function in_array_any($needle, $haystack) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return Basic::inArrayAny($needle, $haystack); + } } + +# __END__ diff --git a/www/libs/Class.DB.Array.IO.inc b/www/lib/CoreLibs/DB/Extended/ArrayIO.inc similarity index 70% rename from www/libs/Class.DB.Array.IO.inc rename to www/lib/CoreLibs/DB/Extended/ArrayIO.inc index 70a9fcbe..3839d983 100644 --- a/www/libs/Class.DB.Array.IO.inc +++ b/www/lib/CoreLibs/DB/Extended/ArrayIO.inc @@ -1,10 +1,10 @@ - db_io class init vars - // table_array -> the array from the table - // table_name -> name of the table (for the array) - // db_debug -> turn on db_io debug output (DB_DEBUG as global var does the same) - // RETURN none - // DESC constructor for the array io class, set the - // primary key name automatically (from array) + // METHOD: db_array_io + // PARAMS: db_config -> db_io class init vars + // table_array -> the array from the table + // table_name -> name of the table (for the array) + // db_debug -> turn on db_io debug output (DB_DEBUG as global var does the same) + // RETURN: none + // DESC : constructor for the array io class, set the + // primary key name automatically (from array) public function __construct($db_config, $table_array, $table_name, $debug = 0, $db_debug = 0, $echo = 1, $print = 0) { // instance db_io class @@ -69,7 +68,7 @@ class db_array_io extends db_io // set primary key for given table_array if ($this->table_array) { - while (list($key, $value) = each($table_array)) { + foreach ($table_array as $key => $value) { if ($value["pk"]) { $this->pk_name = $key; } @@ -78,9 +77,9 @@ class db_array_io extends db_io // internal $this->class_info["db_array_io"] = array( "class_name" => "DB Array IO", - "class_version" => "0.4.0", + "class_version" => "1.0.0", "class_created" => "2002/12/17", - "class_author" => "cs/gullevek/at" + "class_author" => "Clemens Schwaighofer" ); } @@ -90,14 +89,15 @@ class db_array_io extends db_io parent::__destruct(); } - // METHOD convert_data - // PARAMS string -> the string that should be changed - // RETURN string -> the altered string - // DESC changes all previously alterd HTML code into visible one, - // works for ,, and (thought can be / or should - // be handled with the magic links functions - // used with the read function - public function convert_data($text) + // METHOD: convertData + // WAS : convert_data + // PARAMS: string -> the string that should be changed + // RETURN: string -> the altered string + // DESC : changes all previously alterd HTML code into visible one, + // works for ,, and (thought can be / or should + // be handled with the magic links functions + // used with the read function + public function convertData($text) { $text = str_replace('<b>', '', $text); $text = str_replace('</b>', '', $text); @@ -110,11 +110,12 @@ class db_array_io extends db_io return $text; } - // METHOD convert_entities - // PARAMS string -> string to be changed - // RETURN string -> altered string - // DESC changeds all HTML entities into non HTML ones - public function convert_entities($text) + // METHOD: convertEntities + // WAS : convert_entities + // PARAMS: string -> string to be changed + // RETURN: string -> altered string + // DESC : changeds all HTML entities into non HTML ones + public function convertEntities($text) { $text = str_replace('<', '<', $text); $text = str_replace('>', '>', $text); @@ -124,14 +125,15 @@ class db_array_io extends db_io return $text; } - // METHOD db_dump_array - // PARAMS none - // RETURN returns the current array - // DESC dumps the current data - public function db_dump_array($write = 0) + // METHOD: dbDumpArray + // WAS : db_dump_array + // PARAMS: none + // RETURN: returns the current array + // DESC : dumps the current data + public function dbDumpArray($write = 0) { reset($this->table_array); - while (list($column, $data_array) = each($this->table_array)) { + foreach ($this->table_array as $column => $data_array) { $string .= "".$column." -> ".$data_array["value"]."
"; } // add output to internal error_msg @@ -141,24 +143,12 @@ class db_array_io extends db_io return $string; } - // METHOD _db_error - // PARAMS none - // RETURN none - // DESC writes errors to internal error string -/* function _db_error() - { - // if error occured - if ($this->error_id) - { - $this->error_msg['db'] .= "-DB_ARRAY-error-> ".$this->error_id.": ".$this->error_string[$this->error_id]."
"; - } - } */ - - // METHOD db_check_pk_set - // PARAMS none - // RETURN none - // DESC checks if pk is set and if not, set from pk_id and if this also not set return 0 - public function db_check_pk_set() + // METHOD: dbCheckPkSet + // WAS : db_check_pk_set + // PARAMS: none + // RETURN: none + // DESC : checks if pk is set and if not, set from pk_id and if this also not set return 0 + public function dbCheckPkSet() { // if pk_id is set, overrule ... if ($this->pk_id) { @@ -168,21 +158,22 @@ class db_array_io extends db_io if (!$this->table_array[$this->pk_name]["value"]) { // if no PK found, error ... $this->error_id = 21; - $this->_db_error(); + $this->__dbError(); return 0; } else { return 1; } } - // METHOD db_reset_array - // PARAMS reset_pk -> if set reset the pk too - // RETURN none - // DESC resets the whole array - public function db_reset_array($reset_pk = 0) + // METHOD: dbResetArray + // WAS : db_reset_array + // PARAMS: reset_pk -> if set reset the pk too + // RETURN: none + // DESC : resets the whole array + public function dbResetArray($reset_pk = 0) { reset($this->table_array); - while (list($column, $data_array) = each($this->table_array)) { + foreach ($this->table_array as $column => $data_array) { if (!$this->table_array[$column]["pk"]) { unset($this->table_array[$column]["value"]); } elseif ($reset_pk) { @@ -191,16 +182,17 @@ class db_array_io extends db_io } } - // METHOD db_delete - // PARAMS optional the table_array, if not given uses class var - // RETURN 1 for successfull delete or 0 for error - // DESC deletes one dataset - public function db_delete($table_array = 0) + // METHOD: dbDelete + // WAS : db_delete + // PARAMS: optional the table_array, if not given uses class var + // RETURN: 1 for successfull delete or 0 for error + // DESC : deletes one dataset + public function dbDelete($table_array = 0) { if (is_array($table_array)) { $this->table_array = $table_array; } - if (!$this->db_check_pk_set()) { + if (!$this->dbCheckPkSet()) { return $this->table_array; } // delete query @@ -208,8 +200,8 @@ class db_array_io extends db_io $q .= $this->pk_name." = ".$this->table_array[$this->pk_name]["value"]." "; // delete files and build FK query reset($this->table_array); - while (list($column, $data_array) = each($this->table_array)) { - // suchen nach bildern und löschen ... + foreach ($this->table_array as $column => $data_array) { + // suchen nach bildern und lschen ... if ($this->table_array[$column]["file"] && file_exists($this->table_array[$column]["url"].$this->table_array[$column]["value"])) { if (file_exists($this->table_array[$column]["path"].$this->table_array[$column]["value"])) { unlink($this->table_array[$column]["path"].$this->table_array[$column]["value"]); @@ -227,7 +219,7 @@ class db_array_io extends db_io } $q_where .= $column." = ".$this->table_array[$column]["value"]; } - // allgemeines zurücksetzen des arrays + // allgemeines zurcksetzen des arrays unset($this->table_array[$column]["value"]); } @@ -237,29 +229,30 @@ class db_array_io extends db_io } // if 0, error unset($this->pk_id); - if (!$this->db_exec($q)) { + if (!$this->dbExec($q)) { $this->error_id=22; - $this->_db_error(); + $this->__dbError(); } return $this->table_array; } - // METHOD db_read - // PARAMS edit -> if 1 data will not be altered for output, optional the table_array, if not given uses class var - // RETURN true or false for reading - // DESC reads one row into the array - public function db_read($edit = 0, $table_array = 0) + // METHOD: dbRead + // WAS : db_read + // PARAMS: edit -> if 1 data will not be altered for output, optional the table_array, if not given uses class var + // RETURN: true or false for reading + // DESC : reads one row into the array + public function dbRead($edit = 0, $table_array = 0) { // if array give, overrules internal array if (is_array($table_array)) { $this->table_array = $table_array; } - if (!$this->db_check_pk_set()) { + if (!$this->dbCheckPkSet()) { return $this->table_array; } reset($this->table_array); // create select part & addition FK part - while (list($column, $data_array)=each($this->table_array)) { + foreach ($this->table_array as $column => $data_array) { if ($q_select) { $q_select .= ", "; } @@ -283,12 +276,12 @@ class db_array_io extends db_io } // if query was executed okay, else set error - if ($this->db_exec($q)) { - if ($res = $this->db_fetch_array()) { + if ($this->dbExec($q)) { + if ($res = $this->dbFetchArray()) { reset($this->table_array); - while (list($column, $data_array) = each($this->table_array)) { - // wenn "edit" dann gib daten wie in DB zurück, ansonten aufbereiten für ausgabe - // ?? sollte das nicht draußen ??? man weis ja net was da drin steht --> is noch zu überlegen + foreach ($this->table_array as $column => $data_array) { + // wenn "edit" dann gib daten wie in DB zurck, ansonten aufbereiten fr ausgabe + // ?? sollte das nicht drauen ??? man weis ja net was da drin steht --> is noch zu berlegen // echo "EDIT: $edit | Spalte: $column | type: ".$this->table_array[$column]["type"]." | Res: ".$res[$column]."
"; if ($edit) { $this->table_array[$column]["value"] = $res[$column]; @@ -297,25 +290,26 @@ class db_array_io extends db_io $this->table_array[$column]["HIDDEN_value"] = $res[$column]; } } else { - $this->table_array[$column]["value"] = $this->convert_data(nl2br($res[$column])); + $this->table_array[$column]["value"] = $this->convertData(nl2br($res[$column])); // had to put out the htmlentities from the line above as it breaks japanese characters } } } - // possible db_fetch_array errors ... + // possible dbFetchArray errors ... $this->pk_id = $this->table_array[$this->pk_name]["value"]; } else { $this->error_id = 22; - $this->_db_error(); + $this->__dbError(); } return $this->table_array; } - // METHOD db_write - // PARAMS addslashes -> if 1 will make an addslashes for each array field, optional the table_array, if not given uses class var - // RETURN true or false on write - // DESC writes on set into DB or updates one set (if PK exists) - public function db_write($addslashes = 0, $table_array = 0) + // METHOD: dbWrite + // WAS : db_write + // PARAMS: addslashes -> if 1 will make an addslashes for each array field, optional the table_array, if not given uses class var + // RETURN: true or false on write + // DESC : writes on set into DB or updates one set (if PK exists) + public function dbWrite($addslashes = 0, $table_array = 0) { if (is_array($table_array)) { $this->table_array = $table_array; @@ -332,8 +326,7 @@ class db_array_io extends db_io } reset($this->table_array); - while (list($column, $data_array) = each($this->table_array)) { - + foreach ($this->table_array as $column => $data_array) { /********************************* START FILE *************************************/ // file upload if ($this->table_array[$column]["file"]) { @@ -427,9 +420,9 @@ class db_array_io extends db_io $q_data .= "'"; // if add slashes do convert & add slashes else write AS is if ($addslashes) { - $q_data .= $this->db_escape_string($this->convert_entities($this->table_array[$column]["value"])); + $q_data .= $this->dbEscapeString($this->convertEntities($this->table_array[$column]["value"])); } else { - $q_data .= $this->db_escape_string($this->table_array[$column]["value"]); + $q_data .= $this->dbEscapeString($this->table_array[$column]["value"]); } $q_data .= "'"; } @@ -440,7 +433,7 @@ class db_array_io extends db_io // get it at the end, cause now we can be more sure of no double IDs, etc reset($this->table_array); // create select part & addition FK part - while (list($column, $data_array) = each($this->table_array)) { + foreach ($this->table_array as $column => $data_array) { // check FK ... if ($this->table_array[$column]["fk"] && $this->table_array[$column]["value"]) { if ($q_where) { @@ -454,7 +447,7 @@ class db_array_io extends db_io if (!$this->table_array[$this->pk_name]["value"]) { // max id, falls INSERT $q = "SELECT MAX(".$this->pk_name.") + 1 AS pk_id FROM ".$this->table_name; - $res = $this->db_return_row($q); + $res = $this->dbReturnRow($q); if (!$res["pk_id"]) { $res["pk_id"] = 1; } @@ -482,9 +475,9 @@ class db_array_io extends db_io // $this->pk_id = $this->table_array[$this->pk_name]["value"]; } // return success or not - if (!$this->db_exec($q)) { + if (!$this->dbExec($q)) { $this->error_id = 22; - $this->_db_error(); + $this->__dbError(); } // set primary key if ($insert) { @@ -494,4 +487,60 @@ class db_array_io extends db_io // return the table if needed return $this->table_array; } + + // ************************************************************* + // COMPATIBILITY METHODS + // those methods are deprecated function call names + // they exist for backwards compatibility only + // ************************************************************* + + public function convert_data($text) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->convertData($text); + } + + public function convert_entities($text) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->convertEntities($text); + } + + public function db_dump_array($write = 0) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbDumpArray($write); + } + + public function db_check_pk_set() + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbCheckPkSet(); + } + + public function db_reset_array($reset_pk = 0) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbResetArray($reset_pk); + } + + public function db_delete($table_array = 0) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbDelete($table_array); + } + + public function db_read($edit = 0, $table_array = 0) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbRead($edit, $table_array); + } + + public function db_write($addslashes = 0, $table_array = 0) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbWrite($addslashes, $table_array); + } } // end of class + +# __END__ diff --git a/www/libs/Class.DB.IO.inc b/www/lib/CoreLibs/DB/IO.inc similarity index 62% rename from www/libs/Class.DB.IO.inc rename to www/lib/CoreLibs/DB/IO.inc index 66bb73b5..0faf340b 100644 --- a/www/libs/Class.DB.IO.inc +++ b/www/lib/CoreLibs/DB/IO.inc @@ -1,10 +1,13 @@ -db_name = $db_config['db_name']; - $this->db_user = $db_config['db_user']; - $this->db_pwd = $db_config['db_pass']; - $this->db_host = $db_config['db_host']; + $this->db_name = $db_config['db_name'] ?? ''; + $this->db_user = $db_config['db_user'] ?? ''; + $this->db_pwd = $db_config['db_pass'] ?? ''; + $this->db_host = $db_config['db_host'] ?? ''; $this->db_port = array_key_exists('db_port', $db_config) ? $db_config['db_port'] : '5432'; $this->db_schema = array_key_exists('db_schema', $db_config) ? $db_config['db_schema'] : ''; // do not set to 'public' if not set, because the default is already public $this->db_encoding = array_key_exists('db_encoding', $db_config) ? $db_config['db_encoding'] : ''; - $this->db_type = 'db_'.$db_config['db_type']; + $this->db_type = $db_config['db_type'] ?? ''; $this->db_ssl = array_key_exists('db_ssl', $db_config) ? $db_config['db_ssl'] : 'allow'; // set the target encoding to the DEFAULT_ENCODING if it is one of them: EUC, Shift_JIS, UTF-8 @@ -324,13 +330,14 @@ class db_io extends basic $this->MAX_QUERY_CALL = 20; // error & debug stuff, error & warning ids are the same, its just in which var they get written + $this->error_string['10'] = 'Could not load DB interface functions'; $this->error_string['11'] = 'No Querystring given'; $this->error_string['12'] = 'No Cursor given, no correct query perhaps?'; $this->error_string['13'] = 'Query could not be executed without errors'; $this->error_string['14'] = 'Can\'t connect to DB server'; $this->error_string['15'] = 'Can\'t select DB'; $this->error_string['16'] = 'No DB Handler found / connect or reconnect failed'; - $this->error_string['17'] = 'All db_return* methods work only with SELECT statements, please use db_exec for everything else'; + $this->error_string['17'] = 'All dbReturn* methods work only with SELECT statements, please use dbExec for everything else'; $this->error_string['18'] = 'Query not found in cache. Nothing has been reset'; $this->error_string['19'] = 'Wrong PK name given or no PK name given at all, can\'t get Insert ID'; $this->error_string['20'] = 'Found given Prepare Statement Name in array, Query not prepared, will use existing one'; @@ -354,23 +361,36 @@ class db_io extends basic $this->db_debug = $GLOBALS['DB_DEBUG']; } - // includes sub class for db type - _spl_autoload($this->db_type.'.inc'); - $this->db_functions = new $this->db_type(); + // based on $this->db_type + // here we need to load the db pgsql include one + // How can we do this dynamic? eg for non PgSQL + // OTOH this whole class is so PgSQL specific + // that non PgSQL doesn't make much sense anymore + if ($this->db_type == 'pgsql') { + $this->db_functions = new \CoreLibs\DB\SQL\PgSQL(); + } else { + // abort error + $this->error_id = 10; + $this->__dbError(); + return false; + } // connect to DB - if (!$this->_connect_to_db()) { + if (!$this->__connectToDB()) { $this->error_id = 16; - $this->_db_error(); + $this->__dbError(); return false; } $this->class_info['db_io']=array( 'class_name' => 'DB IO', - 'class_version' => '4.1.0', + 'class_version' => '5.0.0', 'class_created' => '2000-11-23', 'class_author' => 'Clemens Schwaighofer' ); + + // all ok return true + return true; } // METHOD: __destruct @@ -379,7 +399,7 @@ class db_io extends basic // DESC: final desctruct method, closes the DB connection public function __destruct() { - $this->_close_db(); + $this->__closeDB(); parent::__destruct(); } @@ -387,75 +407,79 @@ class db_io extends basic // PRIVATE METHODS // ************************************************************* - // METHOD: _connect_to_db + // METHOD: __connectToDB + // WAS : _connect_to_db // PARAMS: none // RETURN: true on successfull connect, false if failed - // DESC: + // DESC : // internal connection function. Used to connect to the DB if there is no connection done yet. // Called before any execute - private function _connect_to_db() + private function __connectToDB() { // generate connect string - $this->dbh = $this->db_functions->_db_connect($this->db_host, $this->db_user, $this->db_pwd, $this->db_name, $this->db_port, $this->db_ssl); + $this->dbh = $this->db_functions->__dbConnect($this->db_host, $this->db_user, $this->db_pwd, $this->db_name, $this->db_port, $this->db_ssl); // if no dbh here, we couldn't connect to the DB itself if (!$this->dbh) { $this->error_id = 14; - $this->_db_error(); + $this->__dbError(); return false; } // 15 error (cant select to DB is not valid in postgres, as connect is different) // if returns 0 we couldn't select the DB if ($this->dbh == -1) { $this->error_id = 15; - $this->_db_error(); + $this->__dbError(); return false; } // set search path if needed if ($this->db_schema) { - $this->db_set_schema(); + $this->dbSetSchema(); } // set client encoding if ($this->db_encoding) { - $this->db_set_encoding(); + $this->dbSetEncoding(); } // all okay return true; } - // METHOD: _close_db + // METHOD: __closeDB + // WAS : _close_db // PARAMS: none // RETURN: none // DESC : close db connection // only used by the deconstructor - private function _close_db() + private function __closeDB() { if (isset($this->dbh) && $this->dbh) { - $this->db_functions->_db_close(); + $this->db_functions->__dbClose(); unset($this->dbh); } } - // METHOS: _check_query_for_select + // METHOD: __checkQueryForSelect + // WAS : _check_query_for_select // PARAMS: query // RETURN: true if matching, false if not - // DESC : checks if query is a SELECT, if not error, 0 return - // : NOTE: Query needs to start with SELECT. if starts with "with" it is ignored - private function _check_query_for_select($query) + // DESC : checks if query is a SELECT or SHOW, if not error, 0 return + // NOTE : Query needs to start with SELECT or SHOW. if starts with "with" it is ignored + private function __checkQueryForSelect($query) { // perhaps allow spaces before select ?!? - if (!preg_match("/^select /i", $query)) { + if (!preg_match("/^(select|show) /i", $query)) { return false; } return true; } - // METHOD: _check_query_for_insert + // METHOD: __checkQueryForInsert + // WAS : _check_query_for_insert // PARAMS: query, pure flag (boolean) // RETURN: true if matching, flase if not // DESC : check for DELETE, INSERT, UPDATE // : if pure is set to true, only when INSERT is set will return true - // : NOTE: Queries need to start with INSERT, UPDATE, DELETE. Anything else is ignored - private function _check_query_for_insert($query, $pure = false) + // NOTE : Queries need to start with INSERT, UPDATE, DELETE. Anything else is ignored + private function __checkQueryForInsert($query, $pure = false) { if (!preg_match("/^insert /i", $query) && !preg_match("/^update /i", $query) && !preg_match("/^delete /i", $query)) { return false; @@ -469,19 +493,20 @@ class db_io extends basic } } - // METHOD: _print_array + // METHOD: __printArray + // WAS : _print_array // PARAMS: array to print // RETURN: string with printed and formated array // DESC : internal funktion that creates the array - // : used in db_dump_data only - private function _print_array($array) + // NOTE : used in db_dump_data only + private function __printArray($array) { while (list($key, $value) = each($array)) { $string .= $this->nbsp.''.$key.' => '; if (is_array($value)) { $this->nbsp .= '   '; $string .= '
'; - $string .= $this->_print_array($value); + $string .= $this->__printArray($value); } else { $string .= $value.'
'; } @@ -490,14 +515,15 @@ class db_io extends basic return $string; } - // METHOD _db_debug - // PARAMS debug_id -> group id for debug - // error_string -> error message or debug data - // id -> db debug group - // type -> query identifiery (Q, I, etc) - // RETURN none - // DESC calls the basic class debug with strip command - private function _db_debug($debug_id, $error_string, $id = '', $type = '') + // METHOD: __dbDebug + // WAS : _db_debug + // PARAMS: debug_id -> group id for debug + // error_string -> error message or debug data + // id -> db debug group + // type -> query identifiery (Q, I, etc) + // RETURN: none + // DESC : calls the basic class debug with strip command + private function __dbDebug($debug_id, $error_string, $id = '', $type = '') { $prefix = ''; if ($id) { @@ -512,34 +538,36 @@ class db_io extends basic $this->debug($debug_id, $prefix.$error_string, true); } - // METHOD _db_error - // PARAMS cursor -> current cursor for pg_result_error, mysql uses dbh, pg_last_error too, - // but pg_result_error is more accurate - // msg -> optional message - // RETURN none - // DESC if error_id set, writes long error string into error_msg - // MARK: needed to make public so it can be called from DB.Array.IO too - public function _db_error($cursor = '', $msg = '') + // METHOD: __dbError + // WAS : _db_error + // PARAMS: cursor -> current cursor for pg_result_error, mysql uses dbh, pg_last_error too, + // but pg_result_error is more accurate + // msg -> optional message + // RETURN: none + // DESC : if error_id set, writes long error string into error_msg + // NOTE : needed to make public so it can be called from DB.Array.IO too + public function __dbError($cursor = '', $msg = '') { - $where_called = $this->get_caller_method(); + $pg_error_string = ''; + $where_called = $this->getCallerMethod(); if ($cursor) { - $pg_error_string = $this->db_functions->_db_print_error($cursor); + $pg_error_string = $this->db_functions->__dbPrintError($cursor); } - if (!$cursor) { - $pg_error_string = $this->db_functions->_db_print_error(); + if (!$cursor && method_exists($this->db_functions, '__dbPrintError')) { + $pg_error_string = $this->db_functions->__dbPrintError(); } if ($pg_error_string) { - $this->_db_debug('db', $pg_error_string, 'DB_ERROR', $where_called); + $this->__dbDebug('db', $pg_error_string, 'DB_ERROR', $where_called); } // okay, an error occured if ($this->error_id) { // write error msg ... - $this->_db_debug('db', 'DB-Error '.$this->error_id.': '.$this->error_string[$this->error_id].($msg ? ', '.$msg : '').'', 'DB_ERROR', $where_called); + $this->__dbDebug('db', 'DB-Error '.$this->error_id.': '.$this->error_string[$this->error_id].($msg ? ', '.$msg : '').'', 'DB_ERROR', $where_called); $this->had_error = $this->error_id; // write detailed error log } if ($this->warning_id) { - $this->_db_debug('db', 'DB-Warning '.$this->warning_id.': '.$this->error_string[$this->warning_id].($msg ? ', '.$msg : '').'', 'DB_ERROR', $where_called); + $this->__dbDebug('db', 'DB-Warning '.$this->warning_id.': '.$this->error_string[$this->warning_id].($msg ? ', '.$msg : '').'', 'DB_ERROR', $where_called); $this->had_warning = $this->warning_id; } // unset the error/warning vars @@ -547,11 +575,12 @@ class db_io extends basic $this->warning_id = 0; } - // METHOD _db_convert_encoding - // PARAMS array from fetch_row - // RETURN convert fetch_row array - // DESC if there is the 'to_encoding' var set, and the field is in the wrong encoding converts it to the target - private function _db_convert_encoding($row) + // METHOD: __dbConvertEncoding + // WAS : _db_convert_encoding + // PARAMS: array from fetch_row + // RETURN: convert fetch_row array + // DESC : if there is the 'to_encoding' var set, and the field is in the wrong encoding converts it to the target + private function __dbConvertEncoding($row) { if ($this->to_encoding && $this->db_encoding) { // go through each row and convert the encoding if needed @@ -566,27 +595,29 @@ class db_io extends basic return $row; } - // METHOD _db_debug_prepare - // PARAMS $stm_name, data array - // RETURN query in prepared form - // DESC for debug purpose replaces $1, $2, etc with actual data - private function _db_debug_prepare($stm_name, $data = array()) + // METHOD: __dbDebugPrepare + // WAS : _db_debug_prepare + // PARAMS: $stm_name, data array + // RETURN: query in prepared form + // DESC : for debug purpose replaces $1, $2, etc with actual data + private function __dbDebugPrepare($stm_name, $data = array()) { // get the keys from data array $keys = array_keys($data); // because the placeholders start with $ and at 1, we need to increase each key and prefix it with a $ char - for ($i = 0; $i < count($keys); $i ++) { + for ($i = 0, $iMax = count($keys); $i < $iMax; $i ++) { $keys[$i] = '$'.($keys[$i] + 1); } // simply replace the $1, $2, ... with the actual data and return it return str_replace(array_reverse($keys), array_reverse($data), $this->prepare_cursor[$stm_name]['query']); } - // METHOD _db_return_table - // PARAMS insert/select/update/delete query - // RETURN array with schema and table - // DESC extracts schema and table from the query, if no schema returns just empty string - private function _db_return_table($query) + // METHOD: __dbReturnTable + // WAS : _db_return_table + // PARAMS: insert/select/update/delete query + // RETURN: array with schema and table + // DESC : extracts schema and table from the query, if no schema returns just empty string + private function __dbReturnTable($query) { if (preg_match("/^SELECT /i", $query)) { preg_match("/ (FROM) (([\w_]+)\.)?([\w_]+) /i", $query, $matches); @@ -596,17 +627,18 @@ class db_io extends basic return array($matches[3], $matches[4]); } - // METHOD _db_prepare_exec - // PARAMS query, primary key [if set to NULL no returning will be added] - // RETURN md5 OR boolean false on error - // DESC sub function for db_exec and db_exec_async - // * checks query is set - // * checks there is a database handler - // * checks that here is no other query executing - // * checks for insert if returning is set/pk name - // * sets internal md5 for query - // * checks multiple call count - private function _db_prepare_exec($query, $pk_name) + // METHOD: __dbPrepareExec + // WAS : _db_prepare_exec + // PARAMS: query, primary key [if set to NULL no returning will be added] + // RETURN: md5 OR boolean false on error + // DESC : sub function for dbExec and dbExecAsync + // * checks query is set + // * checks there is a database handler + // * checks that here is no other query executing + // * checks for insert if returning is set/pk name + // * sets internal md5 for query + // * checks multiple call count + private function __dbPrepareExec($query, $pk_name) { // to either use the returning method or the guess method for getting primary keys $this->returning_id = false; @@ -616,33 +648,33 @@ class db_io extends basic } if (!$this->query) { $this->error_id = 11; - $this->_db_error(); + $this->__dbError(); return false; } // if no DB Handler drop out if (!$this->dbh) { // if reconnect fails drop out - if (!$this->_connect_to_db()) { + if (!$this->__connectToDB()) { $this->error_id = 16; - $this->_db_error(); + $this->__dbError(); return false; } } // check that no other query is running right now - if ($this->db_functions->_db_connection_busy()) { + if ($this->db_functions->__dbConnectionBusy()) { $this->error_id = 41; - $this->_db_error(); + $this->__dbError(); return false; } // if we do have an insert, check if there is no RETURNING pk_id, add it if I can get the PK id - if ($this->_check_query_for_insert($this->query, true)) { + if ($this->__checkQueryForInsert($this->query, true)) { $this->pk_name = $pk_name; if ($this->pk_name != 'NULL') { if (!$this->pk_name) { // TODO: get primary key from table name - list($schema, $table) = $this->_db_return_table($this->query); + list($schema, $table) = $this->__dbReturnTable($this->query); if (!array_key_exists($table, $this->pk_name_table) || !$this->pk_name_table[$table]) { - $this->pk_name_table[$table] = $this->db_functions->_db_primary_key($table, $schema); + $this->pk_name_table[$table] = $this->db_functions->__dbPrimaryKey($table, $schema); } $this->pk_name = $this->pk_name_table[$table] ? $this->pk_name_table[$table] : 'NULL'; } @@ -662,7 +694,7 @@ class db_io extends basic } // for DEBUG, only on first time ;) if ($this->db_debug) { - $this->_db_debug('db', $this->query, '_db_prepare_exec', 'Q'); + $this->__dbDebug('db', $this->query, '__dbPrepareExec', 'Q'); } // import protection, md5 needed $md5 = md5($this->query); @@ -677,8 +709,8 @@ class db_io extends basic // count up the run, if this is run more than the max_run then exit with error if ($this->query_called[$md5] > $this->MAX_QUERY_CALL) { $this->error_id = 30; - $this->_db_error(); - $this->_db_debug('db', $this->query, 'db_exec', 'Q[nc]'); + $this->__dbError(); + $this->__dbDebug('db', $this->query, 'dbExec', 'Q[nc]'); return false; } $this->query_called[$md5] ++; @@ -686,51 +718,52 @@ class db_io extends basic return $md5; } - // METHOD _db_post_exec - // PARAMS none - // RETURN true on success or false if an error occured - // DESC runs post execute for rows affected, field names, inserted primary key, etc - private function _db_post_exec() + // METHOD: __dbPostExec + // WAS : _db_post_exec + // PARAMS: none + // RETURN: true on success or false if an error occured + // DESC : runs post execute for rows affected, field names, inserted primary key, etc + private function __dbPostExec() { // if FALSE returned, set error stuff // if either the cursor is false - if (!$this->cursor || $this->db_functions->_db_last_error_query()) { + if (!$this->cursor || $this->db_functions->__dbLastErrorQuery()) { // printout Query if debug is turned on if ($this->db_debug) { - $this->_db_debug('db', $this->query, 'db_exec', 'Q[nc]'); + $this->__dbDebug('db', $this->query, 'dbExec', 'Q[nc]'); } // internal error handling $this->error_id = 13; - $this->_db_error($this->cursor); + $this->__dbError($this->cursor); return false; } else { // if SELECT do here ... - if ($this->_check_query_for_select($this->query)) { + if ($this->__checkQueryForSelect($this->query)) { // count the rows returned (if select) - $this->num_rows = $this->db_functions->_db_num_rows($this->cursor); + $this->num_rows = $this->db_functions->__dbNumRows($this->cursor); // count the fields - $this->num_fields = $this->db_functions->_db_num_fields($this->cursor); + $this->num_fields = $this->db_functions->__dbNumFields($this->cursor); // set field names unset($this->field_names); for ($i = 0; $i < $this->num_fields; $i ++) { - $this->field_names[] = $this->db_functions->_db_field_name($this->cursor, $i); + $this->field_names[] = $this->db_functions->__dbFieldName($this->cursor, $i); } - } elseif ($this->_check_query_for_insert($this->query)) { + } elseif ($this->__checkQueryForInsert($this->query)) { // if not select do here // count affected rows - $this->num_rows = $this->db_functions->_db_affected_rows($this->cursor); - if ($this->_check_query_for_insert($this->query, true) && $this->pk_name != 'NULL') { + $this->num_rows = $this->db_functions->__dbAffectedRows($this->cursor); + if ($this->__checkQueryForInsert($this->query, true) && $this->pk_name != 'NULL') { // set insert_id // if we do not have a returning, we try to get it via the primary key and another select if (!$this->returning_id) { - $this->insert_id = $this->db_functions->_db_insert_id($this->query, $this->pk_name); + $this->insert_id = $this->db_functions->__dbInsertId($this->query, $this->pk_name); } else { $this->insert_id = array (); $this->insert_id_ext = array (); // echo "** PREPARE RETURNING FOR CURSOR: ".$this->cursor."
"; // we have returning, now we need to check if we get one or many returned // we'll need to loop this, if we have multiple insert_id returns - while ($_insert_id = $this->db_functions->_db_fetch_array($this->cursor, PGSQL_ASSOC)) { + while ($_insert_id = $this->db_functions->__dbFetchArray($this->cursor, PGSQL_ASSOC)) { // echo "*** RETURNING: ".print_r($_insert_id, 1)."
"; $this->insert_id[] = $_insert_id; } @@ -752,7 +785,7 @@ class db_io extends basic // failed to get insert id $this->insert_id = ''; $this->warning_id = 33; - $this->_db_error($this->cursor, '[db_exec]'); + $this->__dbError($this->cursor, '[dbExec]'); } // if we have multiple, do not set the insert_id different, keep as array } @@ -760,7 +793,7 @@ class db_io extends basic // we returned an array of PKs instread of a single one if (is_array($this->insert_id)) { $this->warning_id = 32; - $this->_db_error($this->cursor, '[db_exec]'); + $this->__dbError($this->cursor, '[dbExec]'); } } } @@ -772,14 +805,15 @@ class db_io extends basic // PUBLIC METHODS // ************************************************************* - // METHOD db_set_debug - // PARAMS true/false or none - // RETURN new set debug flag - // DESC switches the debug flag on or off - // if none given, then the debug flag auto switches from - // the previous setting to either then on or off - // else override with boolean true/false - public function db_set_debug($debug = '') + // METHOD: dbSetDebug + // WAS : db_set_debug + // PARAMS: true/false or none + // RETURN: new set debug flag + // DESC : switches the debug flag on or off + // if none given, then the debug flag auto switches from + // the previous setting to either then on or off + // else override with boolean true/false + public function dbSetDebug($debug = '') { if ($debug === true) { $this->db_debug = 1; @@ -793,21 +827,23 @@ class db_io extends basic return $this->db_debug; } - // METHOD db_reset_query_called - // PARAMS query - // RETURN none - // DESC resets the call times for the max query called to 0 - // USE CAREFULLY: rather make the query prepare -> execute - public function db_reset_query_called($query) + // METHOD: dbResetQueryCalled + // WAS : db_reset_query_called + // PARAMS: query + // RETURN: none + // DESC : resets the call times for the max query called to 0 + // USE CAREFULLY: rather make the query prepare -> execute + public function dbResetQueryCalled($query) { $this->query_called[md5($query)] = 0; } - // METHOD db_get_query_called - // PARAMS query - // RETURN count of query called - // DESC gets how often a query was called already - public function db_get_query_called($query) + // METHOD: dbGetQueryCalled + // WAS : db_get_query_called + // PARAMS: query + // RETURN: count of query called + // DESC : gets how often a query was called already + public function dbGetQueryCalled($query) { $md5 = md5($query); if ($this->query_called[$md5]) { @@ -817,24 +853,26 @@ class db_io extends basic } } - // METHOD db_close - // PARAMS none - // RETURN none - // DESC closes the db_connection - // normally this is not used, as the class deconstructor closes the connection down - public function db_close() + // METHOD: dbClose + // WAS : db_close + // PARAMS: none + // RETURN: none + // DESC : closes the db_connection + // normally this is not used, as the class deconstructor closes the connection down + public function dbClose() { if ($this->dbh) { - $this->db_functions->_db_close(); + $this->db_functions->__dbClose(); unset($this->dbh); } } - // METHOD db_set_schema - // PARAMS db_schema: if not given tries internal default db schema - // RETURN false on failure to find schema values, true of db exec schema set - // DESC sets new db schema - public function db_set_schema($db_schema = '') + // METHOD: dbSetSchema + // WAS : db_set_schema + // PARAMS: db_schema: if not given tries internal default db schema + // RETURN: false on failure to find schema values, true of db exec schema set + // DESC : sets new db schema + public function dbSetSchema($db_schema = '') { if (!$db_schema && $this->db_schema) { $db_schema = $this->db_schema; @@ -842,24 +880,26 @@ class db_io extends basic if (!$db_schema) { return false; } - $q = "SET search_path TO '".$this->db_escape_string($db_schema)."'"; - return $this->db_exec($q); + $q = "SET search_path TO '".$this->dbEscapeString($db_schema)."'"; + return $this->dbExec($q); } - // METHOD db_get_schema - // PARAMS none - // RETURN db_schema current set - // DESC returns the current set db schema - public function db_get_schema() + // METHOD: dbGetSchema + // WAS : db_get_schema + // PARAMS: none + // RETURN: db_schema current set + // DESC : returns the current set db schema + public function dbGetSchema() { return $this->db_schema; } - // METHOD db_set_encoding - // PARAMS valid encoding name, so the the data gets converted to this encoding - // RETURN false, or true of db exec encoding set - // DESC sets the client encoding in the postgres database - public function db_set_encoding($db_encoding = '') + // METHOD: dbSetEncoding + // WAS : db_set_encoding + // PARAMS: valid encoding name, so the the data gets converted to this encoding + // RETURN: false, or true of db exec encoding set + // DESC : sets the client encoding in the postgres database + public function dbSetEncoding($db_encoding = '') { if (!$db_encoding && $this->db_encoding) { $db_encoding = $this->db_encoding; @@ -867,15 +907,25 @@ class db_io extends basic if (!$db_encoding) { return false; } - $q = "SET client_encoding TO '".$this->db_escape_string($db_encoding)."'"; - return $this->db_exec($q); + $q = "SET client_encoding TO '".$this->dbEscapeString($db_encoding)."'"; + return $this->dbExec($q); } - // METHOD db_info - // PARAMS show, default 1, if set to 0 won't write to error_msg var - // RETURN string with db_connection info - // DESC prints out status info from the connected DB (might be usefull for debug stuff) - public function db_info($show = 1) + // METHOD: dbGetEncoding + // PARAMS: none + // RETURN: current client encoding + // DESC : returns the current set client encoding from the connected DB + public function dbGetEncoding() + { + return $this->db_return_row('SHOW client_encoding')['client_encoding']; + } + + // METHOD: dbInfo + // WAS : db_info + // PARAMS: show, default 1, if set to 0 won't write to error_msg var + // RETURN: string with db_connection info + // DESC : prints out status info from the connected DB (might be usefull for debug stuff) + public function dbInfo($show = 1) { $string = ''; $string .= '-DB-info-> Connected to db \''.$this->db_name.'\' '; @@ -886,18 +936,19 @@ class db_io extends basic $string .= 'with ssl mode \''.$this->db_ssl.'\'
'; $string .= '-DB-info-> DB IO Class debug output: '.(($this->db_debug) ? 'Yes' : 'No').''; if ($show) { - $this->_db_debug('db', '
'.$string, 'db_info'); + $this->__dbDebug('db', $string, 'dbInfo'); } else { - $string = '
'.$string; + $string = $string.'
'; } return $string; } - // METHOD db_dump_data - // PARAMS query -> if given, only from this quey (if found) - // RETURN formated string with all the data in the array - // DESC dumps ALL data for this query, OR if no query given all in cursor_ext array - public function db_dump_data($query = 0) + // METHOD: dbDumpData + // WAS : db_dump_data + // PARAMS: query -> if given, only from this quey (if found) + // RETURN: formated string with all the data in the array + // DESC : dumps ALL data for this query, OR if no query given all in cursor_ext array + public function dbDumpData($query = 0) { // set start array if ($query) { @@ -907,28 +958,29 @@ class db_io extends basic } if (is_array($array)) { $this->nbps = ''; - $string .= $this->_print_array($array); - $this->_db_debug('db', $string, 'db_dump_data'); + $string .= $this->__printArray($array); + $this->__dbDebug('db', $string, 'dbDumpData'); } return $string; } - // METHOD db_return - // PARAMS query -> the query ... - // reset -> if set to 1, at the end of the query (last row returned), the stored array will be deleted ... - // if set to 2, the data will be read new and cached (wheres 1 reads new AND destroys at end of read) - // -> if set to 3, after EACH row, the data will be reset, no caching is done except for basic (count, etc) - // RETURN res mixed (array/hash) - // DESC single running function, if called creates md5 from - // query string and so can itself call exec/return calls - // caches data, so next time called with IDENTICAL (!!!!) - // [this means 1:1 bit to bit identical query] returns cached - // data, or with reset flag set calls data from DB again - public function db_return($query, $reset = 0) + // METHOD: dbReturn + // WAS : db_return + // PARAMS: query -> the query ... + // reset -> if set to 1, at the end of the query (last row returned), the stored array will be deleted ... + // if set to 2, the data will be read new and cached (wheres 1 reads new AND destroys at end of read) + // -> if set to 3, after EACH row, the data will be reset, no caching is done except for basic (count, etc) + // RETURN: res mixed (array/hash) + // DESC : single running function, if called creates md5 from + // query string and so can itself call exec/return calls + // caches data, so next time called with IDENTICAL (!!!!) + // [this means 1:1 bit to bit identical query] returns cached + // data, or with reset flag set calls data from DB again + public function dbReturn($query, $reset = 0) { if (!$query) { $this->error_id = 11; - $this->_db_error(); + $this->__dbError(); return false; } // create MD5 from query ... @@ -948,9 +1000,9 @@ class db_io extends basic // set the query $this->cursor_ext[$md5]['query'] = $query; // before doing ANYTHING check if query is "SELECT ..." everything else does not work - if (!$this->_check_query_for_select($this->cursor_ext[$md5]['query'])) { + if (!$this->__checkQueryForSelect($this->cursor_ext[$md5]['query'])) { $this->error_id = 17; - $this->_db_error('', $this->cursor_ext[$md5]['query']); + $this->__dbError('', $this->cursor_ext[$md5]['query']); return false; } @@ -959,38 +1011,38 @@ class db_io extends basic if ($reset && !$this->cursor_ext[$md5]['pos']) { unset($this->cursor_ext[$md5]['cursor']); } -// $this->debug('MENU', 'Reset: '.$reset.', Cursor: '.$this->cursor_ext[$md5]['cursor'].', Pos: '.$this->cursor_ext[$md5]['pos'].', Query: '.$query); + // $this->debug('MENU', 'Reset: '.$reset.', Cursor: '.$this->cursor_ext[$md5]['cursor'].', Pos: '.$this->cursor_ext[$md5]['pos'].', Query: '.$query); // if no cursor yet, execute if (!$this->cursor_ext[$md5]['cursor']) { // for DEBUG, print out each query executed if ($this->db_debug) { - $this->_db_debug('db', $this->cursor_ext[$md5]['query'], 'db_return', 'Q'); + $this->__dbDebug('db', $this->cursor_ext[$md5]['query'], 'dbReturn', 'Q'); } // if no DB Handler try to reconnect if (!$this->dbh) { // if reconnect fails drop out - if (!$this->_connect_to_db()) { + if (!$this->__connectToDB()) { $this->error_id = 16; - $this->_db_error(); + $this->__dbError(); return false; } } // check that no other query is running right now - if ($this->db_functions->_db_connection_busy()) { + if ($this->db_functions->__dbConnectionBusy()) { $this->error_id = 41; - $this->_db_error(); + $this->__dbError(); return false; } - $this->cursor_ext[$md5]['cursor'] = $this->db_functions->_db_query($this->cursor_ext[$md5]['query']); + $this->cursor_ext[$md5]['cursor'] = $this->db_functions->__dbQuery($this->cursor_ext[$md5]['query']); // if still no cursor ... if (!$this->cursor_ext[$md5]['cursor']) { if ($this->db_debug) { - $this->_db_debug('db', $this->cursor_ext[$md5]['query'], 'db_return', 'Q'); + $this->__dbDebug('db', $this->cursor_ext[$md5]['query'], 'dbReturn', 'Q'); } // internal error handling $this->error_id = 13; - $this->_db_error($this->cursor_ext[$md5]['cursor']); + $this->__dbError($this->cursor_ext[$md5]['cursor']); return false; } else { $this->cursor_ext[$md5]['firstcall'] = 1; @@ -1001,12 +1053,12 @@ class db_io extends basic if ($this->cursor_ext[$md5]['cursor']) { if ($this->cursor_ext[$md5]['firstcall'] == 1) { // count the rows returned (if select) - $this->cursor_ext[$md5]['num_rows'] = $this->db_functions->_db_num_rows($this->cursor_ext[$md5]['cursor']); + $this->cursor_ext[$md5]['num_rows'] = $this->db_functions->__dbNumRows($this->cursor_ext[$md5]['cursor']); // count the fields - $this->cursor_ext[$md5]['num_fields'] = $this->db_functions->_db_num_fields($this->cursor_ext[$md5]['cursor']); + $this->cursor_ext[$md5]['num_fields'] = $this->db_functions->__dbNumFields($this->cursor_ext[$md5]['cursor']); // set field names for ($i = 0; $i < $this->cursor_ext[$md5]['num_fields']; $i ++) { - $this->cursor_ext[$md5]['field_names'][] = $this->db_functions->_db_field_name($this->cursor_ext[$md5]['cursor'], $i); + $this->cursor_ext[$md5]['field_names'][] = $this->db_functions->__dbFieldName($this->cursor_ext[$md5]['cursor'], $i); } // reset first call vars $this->cursor_ext[$md5]['firstcall'] = 0; @@ -1019,7 +1071,7 @@ class db_io extends basic if ($this->cursor_ext[$md5]['read_rows'] == $this->cursor_ext[$md5]['num_rows']) { $return = 0; } else { - $return = $this->_db_convert_encoding($this->db_functions->_db_fetch_array($this->cursor_ext[$md5]['cursor'])); + $return = $this->__dbConvertEncoding($this->db_functions->__dbFetchArray($this->cursor_ext[$md5]['cursor'])); } // check if cached call or reset call ... if (!$return && !$reset) { @@ -1070,74 +1122,77 @@ class db_io extends basic return $return; } - // METHOD db_cache_reset - // PARAMS $query -> The Query whose cache should be cleaned - // RETURN 0 if failure (eg no query with this md5 found) - // 1 if successfull - // DESC resets all data stored to this query - public function db_cache_reset($query) + // METHOD: dbCacheReset + // WAS : db_cache_reset + // PARAMS: $query -> The Query whose cache should be cleaned + // RETURN: 0 if failure (eg no query with this md5 found) + // 1 if successfull + // DESC : resets all data stored to this query + public function dbCacheReset($query) { $md5 = md5($query); // clears cache for this query if (!$this->cursor_ext[$md5]['query']) { $this->error_id = 18; - $this->_db_error(); + $this->__dbError(); return false; } unset($this->cursor_ext[$md5]); return true; } - // METHOD db_exec - // PARAMS query -> the query, if not given, the query class var will be used - // (if this was not set, method will quit with a 0 (failure) - // pk_name -> optional primary key name, for insert id return if the pk name is very different - // if pk name is table name and _id, pk_name is not needed to be set - // if NULL is given here, no RETURNING will be auto added - // RETURN cursor for this query - // DESC executes the query and returns & sets the internal cursor - // fruthermore this functions also sets varios other vars - // like num_rows, num_fields, etc depending on query - // for INSERT INTO queries it is highly recommended to set the pk_name to avoid an additional - // read from the database for the PK NAME - public function db_exec($query = 0, $pk_name = '') + // METHOD: dbExec + // METHOD: db_exec + // PARAMS: query -> the query, if not given, the query class var will be used + // (if this was not set, method will quit with a 0 (failure) + // pk_name -> optional primary key name, for insert id return if the pk name is very different + // if pk name is table name and _id, pk_name is not needed to be set + // if NULL is given here, no RETURNING will be auto added + // RETURN: cursor for this query + // DESC : executes the query and returns & sets the internal cursor + // fruthermore this functions also sets varios other vars + // like num_rows, num_fields, etc depending on query + // for INSERT INTO queries it is highly recommended to set the pk_name to avoid an additional + // read from the database for the PK NAME + public function dbExec($query = 0, $pk_name = '') { // prepare and check if we can actually run it - if (($md5 = $this->_db_prepare_exec($query, $pk_name)) === false) { + if (($md5 = $this->__dbPrepareExec($query, $pk_name)) === false) { // bail if no md5 set return false; } // ** actual db exec call - $this->cursor = $this->db_functions->_db_query($this->query); + $this->cursor = $this->db_functions->__dbQuery($this->query); // if FALSE returned, set error stuff // run the post exec processing - if (!$this->_db_post_exec()) { + if (!$this->__dbPostExec()) { return false; } else { return $this->cursor; } } - // METHOD db_exec_async - // PARAMS query -> query to run - // pk_name -> optional primary key name, only used with insert for returning call - // RETURN true if async query was sent ok, false if error happened - // DESC executres the query async so other methods can be run during this - // for INSERT INTO queries it is highly recommended to set the pk_name to avoid an additional - // read from the database for the PK NAME - // NEEDS db_check_async - public function db_exec_async($query, $pk_name = '') + // METHOD: dbExecAsync + // WAS : db_exec_async + // PARAMS: query -> query to run + // pk_name -> optional primary key name, only used with insert for returning call + // RETURN: true if async query was sent ok, false if error happened + // DESC : executres the query async so other methods can be run during this + // for INSERT INTO queries it is highly recommended to set the pk_name to avoid an additional + // read from the database for the PK NAME + // NEEDS : dbCheckAsync + public function dbExecAsync($query, $pk_name = '') { // prepare and check if we can actually run the query - if (($md5 = $this->_db_prepare_exec($query, $pk_name)) === false) { + if (($md5 = $this->__dbPrepareExec($query, $pk_name)) === false) { // bail if no md5 set return false; } // run the async query - if (!$this->db_functions->_db_send_query($this->query)) { + if (!$this->db_functions->__dbSendQuery($this->query)) { // if failed, process here $this->error_id = 40; - $this->_db_error(); + $this->__dbError(); return false; } else { $this->async_running = $md5; @@ -1146,23 +1201,24 @@ class db_io extends basic } } - // METHOD db_check_async - // PARAMS none - // RETURN true if the query is still running, false if an error occured or cursor of that query - // DESC checks a previous async query and returns data if finished - // NEEDS db_exec_async - public function db_check_async() + // METHOD: dbCheckAsync + // WAS : db_check_async + // PARAMS: none + // RETURN: true if the query is still running, false if an error occured or cursor of that query + // DESC : checks a previous async query and returns data if finished + // NEEDS : dbExecAsync + public function dbCheckAsync() { // if there is actually a async query there if ($this->async_running) { - if ($this->db_functions->_db_connection_busy()) { + if ($this->db_functions->__dbConnectionBusy()) { return true; } else { // get the result/or error - $this->cursor = $this->db_functions->_db_get_result(); + $this->cursor = $this->db_functions->__dbGetResult(); $this->async_running = ''; // run the post exec processing - if (!$this->_db_post_exec()) { + if (!$this->__dbPostExec()) { return false; } else { return $this->cursor; @@ -1171,17 +1227,18 @@ class db_io extends basic } else { // if no async running print error $this->error_id = 42; - $this->_db_debug('db', 'DB-Error No async query has been started yet.', 'DB_ERROR'); + $this->__dbDebug('db', 'DB-Error No async query has been started yet.', 'DB_ERROR'); return false; } } - // METHOD db_fetch_array - // PARAMS cusors -> the cursor from db_exec or pg_query/pg_exec/mysql_query - // if not set will use internal cursor, if not found, stops with 0 (error) - // RETURN a mixed row - // DESC executes a cursor and returns the data, if no more data 0 will be returned - public function db_fetch_array($cursor = 0) + // METHOD: dbFetchArray + // WAS : db_fetch_array + // PARAMS: cusors -> the cursor from db_exec or pg_query/pg_exec/mysql_query + // if not set will use internal cursor, if not found, stops with 0 (error) + // RETURN: a mixed row + // DESC : executes a cursor and returns the data, if no more data 0 will be returned + public function dbFetchArray($cursor = 0) { // return false if no query or cursor set ... if (!$cursor) { @@ -1189,53 +1246,55 @@ class db_io extends basic } if (!$cursor) { $this->error_id = 12; - $this->_db_error(); + $this->__dbError(); return false; } - return $this->_db_convert_encoding($this->db_functions->_db_fetch_array($cursor)); + return $this->__dbConvertEncoding($this->db_functions->__dbFetchArray($cursor)); } - // METHOD db_return_row - // PARAMS query -> the query to be executed - // RETURN mixed db result - // DESC returns the FIRST row of the given query - public function db_return_row($query) + // METHOD: dbReturnRow + // WAS : db_return_row + // PARAMS: query -> the query to be executed + // RETURN: mixed db result + // DESC : returns the FIRST row of the given query + public function dbReturnRow($query) { if (!$query) { $this->error_id = 11; - $this->_db_error(); + $this->__dbError(); return false; } // before doing ANYTHING check if query is "SELECT ..." everything else does not work - if (!$this->_check_query_for_select($query)) { + if (!$this->__checkQueryForSelect($query)) { $this->error_id = 17; - $this->_db_error('', $query); + $this->__dbError('', $query); return false; } - $cursor = $this->db_exec($query); - $result = $this->db_fetch_array($cursor); + $cursor = $this->dbExec($query); + $result = $this->dbFetchArray($cursor); return $result; } - // METHOD db_return_array - // PARAMS query -> the query to be executed, named_only -> if true, only name ref are returned - // RETURN array of hashes (row -> fields) - // DESC createds an array of hashes of the query (all data) - public function db_return_array($query, $named_only = 0) + // METHOD: dbReturnArray + // WAS : db_return_array + // PARAMS: query -> the query to be executed, named_only -> if true, only name ref are returned + // RETURN: array of hashes (row -> fields) + // DESC : createds an array of hashes of the query (all data) + public function dbReturnArray($query, $named_only = 0) { if (!$query) { $this->error_id = 11; - $this->_db_error(); + $this->__dbError(); return false; } // before doing ANYTHING check if query is "SELECT ..." everything else does not work - if (!$this->_check_query_for_select($query)) { + if (!$this->__checkQueryForSelect($query)) { $this->error_id = 17; - $this->_db_error('', $query); + $this->__dbError('', $query); return false; } - $cursor = $this->db_exec($query); - while ($res = $this->db_fetch_array($cursor)) { + $cursor = $this->dbExec($query); + while ($res = $this->dbFetchArray($cursor)) { for ($i = 0; $i < $this->num_fields; $i ++) { // cereated mixed, first name $data[$this->field_names[$i]] = $res[$this->field_names[$i]]; @@ -1249,92 +1308,96 @@ class db_io extends basic return $rows; } - // METHOD db_cursor_pos - // PARAMS $query -> query to find in cursor_ext - // RETURN position (int) - // DESC returns the current position the read out - public function db_cursor_pos($query) + // METHOD: dbCursorPos + // WAS : db_cursor_pos + // PARAMS: $query -> query to find in cursor_ext + // RETURN: position (int) + // DESC : returns the current position the read out + public function dbCursorPos($query) { if (!$query) { $this->error_id = 11; - $this->_db_error(); + $this->__dbError(); return false; } $md5 = md5($query); return $this->cursor_ext[$md5]['pos']; } - // METHOD db_cursor_num_rows - // PARAMS $query -> query to find in cursor_ext - // RETURN row count (int) - // DESC returns the number of rows for the current select query - public function db_cursor_num_rows($query) + // METHOD: dbCursorNumRows + // WAS : db_cursor_num_rows + // PARAMS: $query -> query to find in cursor_ext + // RETURN: row count (int) + // DESC : returns the number of rows for the current select query + public function dbCursorNumRows($query) { if (!$query) { $this->error_id = 11; - $this->_db_error(); + $this->__dbError(); return false; } $md5 = md5($query); return $this->cursor_ext[$md5]['num_rows']; } - // METHOD db_show_table_meta_data - // PARAMS $table -> table name - // $schema -> optional schema name - // RETURN array of table data - // DESC returns an array of the table with columns and values. FALSE on no table found - public function db_show_table_meta_data($table, $schema = '') + // METHOD: dbShowTableMetaData + // WAS : db_show_table_meta_data + // PARAMS: $table -> table name + // $schema -> optional schema name + // RETURN: array of table data + // DESC : returns an array of the table with columns and values. FALSE on no table found + public function dbShowTableMetaData($table, $schema = '') { $table = ($schema ? $schema.'.' : '').$table; - $array = $this->db_functions->_db_meta_data($table); + $array = $this->db_functions->__dbMetaData($table); if (!is_array($array)) { $array = false; } return $array; } - // METHOD db_prepare - // PARAMS $stm_name, $query, $pk_name: optional - // RETURN false on error - // DESC prepares a query - // for INSERT INTO queries it is highly recommended to set the pk_name to avoid an additional - // read from the database for the PK NAME - public function db_prepare($stm_name, $query, $pk_name = '') + // METHOD: dbPrepare + // WAS : db_prepare + // PARAMS: $stm_name, $query, $pk_name: optional + // RETURN: false on error + // DESC : prepares a query + // for INSERT INTO queries it is highly recommended to set the pk_name to avoid an additional + // read from the database for the PK NAME + public function dbPrepare($stm_name, $query, $pk_name = '') { if (!$query) { $this->error_id = 11; - $this->_db_error(); + $this->__dbError(); return false; } // if no DB Handler drop out if (!$this->dbh) { // if reconnect fails drop out - if (!$this->_connect_to_db()) { + if (!$this->__connectToDB()) { $this->error_id = 16; - $this->_db_error(); + $this->__dbError(); return false; } } // check that no other query is running right now - if ($this->db_functions->_db_connection_busy()) { + if ($this->db_functions->__dbConnectionBusy()) { $this->error_id = 41; - $this->_db_error(); + $this->__dbError(); return false; } // check if this was already prepared if (!array_key_exists($stm_name, $this->prepare_cursor) || !is_array($this->prepare_cursor[$stm_name])) { // if this is an insert query, check if we can add a return - if ($this->_check_query_for_insert($query, true)) { + if ($this->__checkQueryForInsert($query, true)) { if ($pk_name != 'NULL') { // set primary key name // current: only via parameter if (!$pk_name) { // read the primary key from the table, if we do not have one, we get nothing in return - list($schema, $table) = $this->_db_return_table($query); + list($schema, $table) = $this->__dbReturnTable($query); if (!$this->pk_name_table[$table]) { - $this->pk_name_table[$table] = $this->db_functions->_db_primary_key($table, $schema); + $this->pk_name_table[$table] = $this->db_functions->__dbPrimaryKey($table, $schema); } $pk_name = $this->pk_name_table[$table]; } @@ -1360,14 +1423,14 @@ class db_io extends basic preg_match_all('/(\$[0-9]{1,})/', $query, $match); $this->prepare_cursor[$stm_name]['count'] = count($match[1]); $this->prepare_cursor[$stm_name]['query'] = $query; - $result = $this->db_functions->_db_prepare($stm_name, $query); + $result = $this->db_functions->__dbPrepare($stm_name, $query); if ($result) { $this->prepare_cursor[$stm_name]['result'] = $result; return $result; } else { $this->error_id = 21; - $this->_db_error(); - $this->_db_debug('db', 'DB-Error '.$stm_name.': Prepare field with: '.$stm_name.' | '.$query.'', 'DB_ERROR'); + $this->__dbError(); + $this->__dbDebug('db', 'DB-Error '.$stm_name.': Prepare field with: '.$stm_name.' | '.$query.'', 'DB_ERROR'); return $result; } } else { @@ -1377,47 +1440,48 @@ class db_io extends basic } } - // METHOD db_execute - // PARAMS $stm_name, data array - // RETURN false on error - // DESC runs a prepare query - public function db_execute($stm_name, $data = array()) + // METHOD: dbExecute + // WAS : db_execute + // PARAMS: $stm_name, data array + // RETURN: false on error + // DESC : runs a prepare query + public function dbExecute($stm_name, $data = array()) { // if we do not have no prepare cursor array entry for this statement name, abort if (!is_array($this->prepare_cursor[$stm_name])) { $this->error_id = 24; - $this->_db_debug('db', 'DB-Error '.$stm_name.': We do not have a prepared query entry for this statement name.', 'DB_ERROR'); + $this->__dbDebug('db', 'DB-Error '.$stm_name.': We do not have a prepared query entry for this statement name.', 'DB_ERROR'); return false; } if (!is_array($data)) { $this->error_id = 25; - $this->_db_debug('db', 'DB-Error '.$stm_name.': Prepared query Data has to be given in array form.', 'DB_ERROR'); + $this->__dbDebug('db', 'DB-Error '.$stm_name.': Prepared query Data has to be given in array form.', 'DB_ERROR'); return false; } if ($this->prepare_cursor[$stm_name]['count'] != count($data)) { $this->error_id = 23; - $this->_db_debug('db', 'DB-Error '.$stm_name.': Array data count does not match prepared fields. Need: '.$this->prepare_cursor[$stm_name]['count'].', has: '.count($data).'', 'DB_ERROR'); + $this->__dbDebug('db', 'DB-Error '.$stm_name.': Array data count does not match prepared fields. Need: '.$this->prepare_cursor[$stm_name]['count'].', has: '.count($data).'', 'DB_ERROR'); return false; } else { if ($this->db_debug) { - $this->_db_debug('db', $this->_db_debug_prepare($stm_name, $data), 'db_exec_prep', 'Q'); + $this->__dbDebug('db', $this->__dbDebugPrepare($stm_name, $data), 'dbExecPrep', 'Q'); } - $code = $this->db_functions->_db_execute($stm_name, $data); + $code = $this->db_functions->__dbExecute($stm_name, $data); if (!$code) { $this->debug('ExecuteData', 'ERROR in STM['.$stm_name.'|'.$this->prepare_cursor[$stm_name]['result'].']: '.$this->print_ar($data)); $this->error_id = 22; - $this->_db_error($this->prepare_cursor[$stm_name]['result']); - $this->_db_debug('db', 'DB-Error '.$stm_name.': Execution failed', 'DB_ERROR'); + $this->__dbError($this->prepare_cursor[$stm_name]['result']); + $this->__dbDebug('db', 'DB-Error '.$stm_name.': Execution failed', 'DB_ERROR'); } - if ($this->_check_query_for_insert($this->prepare_cursor[$stm_name]['query'], true) && $this->prepare_cursor[$stm_name]['pk_name'] != 'NULL') { + if ($this->__checkQueryForInsert($this->prepare_cursor[$stm_name]['query'], true) && $this->prepare_cursor[$stm_name]['pk_name'] != 'NULL') { if (!$this->prepare_cursor[$stm_name]['returning_id']) { - $this->insert_id = $this->db_functions->_db_insert_id($this->prepare_cursor[$stm_name]['query'], $this->prepare_cursor[$stm_name]['pk_name']); + $this->insert_id = $this->db_functions->__dbInsertId($this->prepare_cursor[$stm_name]['query'], $this->prepare_cursor[$stm_name]['pk_name']); } elseif ($code) { $this->insert_id = array (); $this->insert_id_ext = array (); // we have returning, now we need to check if we get one or many returned // we'll need to loop this, if we have multiple insert_id returns - while ($_insert_id = $this->db_functions->_db_fetch_array($code, PGSQL_ASSOC)) { + while ($_insert_id = $this->db_functions->__dbFetchArray($code, PGSQL_ASSOC)) { $this->insert_id[] = $_insert_id; } // if we have only one, revert from arry to single @@ -1433,63 +1497,67 @@ class db_io extends basic } elseif ($this->insert_id[0][$this->prepare_cursor[$stm_name]['pk_name']]) { $this->insert_id = $this->insert_id[0][$this->prepare_cursor[$stm_name]['pk_name']]; } - } else { + } elseif (count($this->insert_id) == 0) { // failed to get insert id $this->insert_id = ''; $this->warning_id = 33; - $this->_db_error(); - $this->_db_debug('db', 'DB-Warning '.$stm_name.': insert id returned no data', 'DB_WARNING'); + $this->__dbError(); + $this->__dbDebug('db', 'DB-Warning '.$stm_name.': insert id returned no data', 'DB_WARNING'); } } // this error handling is only for pgsql if (is_array($this->insert_id)) { $this->warning_id = 32; - $this->_db_error(); - $this->_db_debug('db', 'DB-Warning '.$stm_name.': insert id data returned as array', 'DB_WARNING'); + $this->__dbError(); + $this->__dbDebug('db', 'DB-Warning '.$stm_name.': insert id data returned as array', 'DB_WARNING'); } elseif (!$this->insert_id) { // NOTE should we keep this inside $this->warning_id = 31; - $this->_db_error(); - $this->_db_debug('db', 'DB-Warning '.$stm_name.': Could not get insert id', 'DB_WARNING'); + $this->__dbError(); + $this->__dbDebug('db', 'DB-Warning '.$stm_name.': Could not get insert id', 'DB_WARNING'); } } return $code; } } - // METHOD db_escape_string - // PARAMS $string -> string to escape - // RETURN escaped string - // DESC neutral function to escape a string for DB writing - public function db_escape_string($string) + // METHOD: dbEscapeString + // WAS : db_escape_string + // PARAMS: $string -> string to escape + // RETURN: escaped string + // DESC : neutral function to escape a string for DB writing + public function dbEscapeString($string) { - return $this->db_functions->_db_escape_string($string); + return $this->db_functions->__dbEscapeString($string); } - // METHOD db_escape_bytea - // PARAMS $bytea -> bytea to escape - // RETURN escaped bytea - // DESC neutral function to escape a bytea for DB writing - public function db_escape_bytea($bytea) + // METHOD: dbEscapeBytea + // WAS : db_escape_bytea + // PARAMS: $bytea -> bytea to escape + // RETURN: escaped bytea + // DESC : neutral function to escape a bytea for DB writing + public function dbEscapeBytea($bytea) { - return $this->db_functions->_db_escape_bytea($bytea); + return $this->db_functions->__dbEscapeBytea($bytea); } - // METHOD db_version - // PARAMS none - // RETURN database version as string - // DESC return current database version - public function db_version() + // METHOD: dbVersion + // WAS : db_version + // PARAMS: none + // RETURN: database version as string + // DESC : return current database version + public function dbVersion() { - return $this->db_functions->_db_version(); + return $this->db_functions->__dbVersion(); } - // METHOD db_compare_version - // PARAMS string to which the return will return true or false + // METHOD: dbCompareVersion + // WAS : db_compare_version + // PARAMS: string to which the return will return true or false // =X.Y, >X.Y, , < prefix, and gets stripped, if the rest is not X.Y format then error preg_match("/^([<>=]{1,2})(\d{1,2})\.(\d{1,2})/", $compare, $matches); @@ -1503,7 +1571,7 @@ class db_io extends basic } // db_version can return X.Y.Z // we only compare the first two - list ($master, $minor, $_other) = explode('.', $this->db_version()); + list ($master, $minor, $_other) = explode('.', $this->dbVersion()); $version = $master.($minor < 10 ? '0' : '').$minor; $return = false; // compare @@ -1539,11 +1607,12 @@ class db_io extends basic return $return; } - // METHOD db_boolean - // PARAMS 't' / 'f' or any string - // RETURN correct php boolean true/false - // DESC if the input is a single char 't' or 'f' it will return the boolean value instead - public function db_boolean($string, $rev = false) + // METHOD: dbBoolean + // WAS : db_boolean + // PARAMS: 't' / 'f' or any string + // RETURN: correct php boolean true/false + // DESC : if the input is a single char 't' or 'f' it will return the boolean value instead + public function dbBoolean($string, $rev = false) { if (!$rev) { if ($string == 't' || $string == 'true') { @@ -1567,14 +1636,15 @@ class db_io extends basic // db_write_data is the old without separate update no write list // db_write_data_ext is the extended with additional array for no write list for update - // METHOD: db_write_data + // METHOD: dbWriteData + // WAS : db_write_data // PARAMS: write_array -> list of elements to write // not_write_array -> list of elements not to write // primary_key -> id key to decide if we write insert or update // table -> name for the target table // RETURN: primary key id // DESC: writes into one table based on array of table columns - public function db_write_data($write_array, $not_write_array, $primary_key, $table, $data = array ()) + public function dbWriteData($write_array, $not_write_array, $primary_key, $table, $data = array ()) { if (!is_array($write_array)) { $write_array = array (); @@ -1586,21 +1656,24 @@ class db_io extends basic return false; } $not_write_update_array = array (); - return $this->db_write_data_ext($write_array, $primary_key, $table, $not_write_array, $not_write_update_array, $data); + return $this->dbWriteData_ext($write_array, $primary_key, $table, $not_write_array, $not_write_update_array, $data); } - // METHOD: db_write_data_ext + // METHOD: dbWriteDataExt + // WAS : db_write_data_ext // PARAMS: write_array -> list of elements to write // primary_key -> id key to decide if we write insert or update - // -> alternate the primary key can be an array with 'row' => 'row name', 'value' => 'data' to use a different column as the primary key + // -> alternate the primary key can be an array with + // 'row' => 'row name', 'value' => 'data' to use a + // different column as the primary key // table -> name for the target table // (optional) // not_write_array -> list of elements not to write // not_write_update_array -> list of elements not to write during update // data -> optional array with data, if not _POST vars are used // RETURN: primary key id - // DESC: writes into one table based on array of table columns - public function db_write_data_ext($write_array, $primary_key, $table, $not_write_array = array (), $not_write_update_array = array (), $data = array ()) + // DESC : writes into one table based on array of table columns + public function dbWriteDataExt($write_array, $primary_key, $table, $not_write_array = array (), $not_write_update_array = array (), $data = array ()) { if (!is_array($primary_key)) { $primary_key = array ( @@ -1612,7 +1685,7 @@ class db_io extends basic $q_sub_value = ''; $q_sub_data = ''; // get the table layout and row types - $table_data = $this->db_show_table_meta_data(($this->db_schema ? $this->db_schema.'.' : '').$table); + $table_data = $this->dbShowTableMetaData(($this->db_schema ? $this->db_schema.'.' : '').$table); foreach ($write_array as $field) { if ((!$primary_key['value'] || ($primary_key['value'] && !in_array($field, $not_write_update_array))) && !in_array($field, $not_write_array)) { // data from external or data field @@ -1656,7 +1729,7 @@ class db_io extends basic $q_sub_data .= (is_numeric($_data) && isset($_data)) ? $_data : 'NULL'; } else { // if bool -> set bool, else write data - $q_sub_data .= isset($_data) ? "'".($is_bool ? $this->db_boolean($_data, true) : $this->db_escape_string($_data))."'" : 'NULL'; + $q_sub_data .= isset($_data) ? "'".($is_bool ? $this->dbBoolean($_data, true) : $this->dbEscapeString($_data))."'" : 'NULL'; } } } @@ -1676,7 +1749,7 @@ class db_io extends basic $q .= ')'; $this->temp_sql = $q; } - if (!$this->db_exec($q)) { + if (!$this->dbExec($q)) { return false; } if (!$primary_key['value']) { @@ -1686,12 +1759,13 @@ class db_io extends basic return $primary_key['value']; } - // METHOD: db_time_format + // METHOD: dbTimeFormat + // WAS : db_time_format // PARAMS: age or datetime difference // micro on off (default false) // RETURN: Y/M/D/h/m/s formatted string (like TimeStringFormat - // DESC: only for postgres. pretty formats an age or datetime difference string - public function db_time_format($age, $show_micro = false) + // DESC : only for postgres. pretty formats an age or datetime difference string + public function dbTimeFormat($age, $show_micro = false) { // in string (datetime diff): 1786 days 22:11:52.87418 // or (age): 4 years 10 mons 21 days 12:31:11.87418 @@ -1708,21 +1782,23 @@ class db_io extends basic return $prefix.($hour ? $hour.'h ' : '').($minutes ? $minutes.'m ' : '').($seconds ? $seconds.'s' : '').($show_micro && $milliseconds? ' '.$milliseconds.'ms' : ''); } - // METHOD: db_array_parse + // METHOD: dbArrayParse + // WAS : db_array_parse // PARAMS: text: input text to parse to an array // RETURN: PHP array of the parsed data - // DESC: this is only needed for Postgresql. Converts postgresql arrays to PHP - public function db_array_parse($text) + // DESC : this is only needed for Postgresql. Converts postgresql arrays to PHP + public function dbArrayParse($text) { - return $this->db_functions->_db_array_parse($text, $output); + return $this->db_functions->__dbArrayParse($text, $output); } - // METHOD: db_sql_escape + // METHOD: dbSqlEscape + // WAS : db_sql_escape // PARAMS: value -> to escape data - // kbn -> escape trigger type + // kbn -> escape trigger type // RETURN: escaped value // DESC : clear up any data for valid DB insert - public function db_sql_escape($value, $kbn = "") + public function dbSqlEscape($value, $kbn = "") { switch ($kbn) { case "i": @@ -1732,10 +1808,10 @@ class db_io extends basic $value = (!isset($value) || $value === "") ? "NULL" : floatval($value); break; case "t": - $value = (!isset($value) || $value === "") ? "NULL" : "'".$this->db_escape_string($value)."'"; + $value = (!isset($value) || $value === "") ? "NULL" : "'".$this->dbEscapeString($value)."'"; break; case "d": - $value = (!isset($value) || $value === "") ? "NULL" : "'".$this->db_escape_string($value)."'"; + $value = (!isset($value) || $value === "") ? "NULL" : "'".$this->dbEscapeString($value)."'"; break; case "i2": $value = (!isset($value) || $value === "") ? 0 : intval($value); @@ -1743,4 +1819,274 @@ class db_io extends basic } return $value; } + + // ************************************************************* + // COMPATIBILITY METHODS + // those methods are deprecated function call names + // they exist for backwards compatibility only + // ************************************************************* + + private function _connect_to_db() + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->__connectToDB(); + } + + private function _close_db() + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->__closeDB(); + } + + private function _check_query_for_select($query) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->__checkQueryForSelect($query); + } + + private function _check_query_for_insert($query, $pure = false) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->__checkQueryForInsert($query, $pure); + } + + private function _print_array($array) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->__printArray($array); + } + + private function _db_debug($debug_id, $error_string, $id = '', $type = '') + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->__dbDebug($debug_id, $error_string, $id, $type); + } + + public function _db_error($cursor = '', $msg = '') + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->__dbError($cursor, $msg); + } + + private function _db_convert_encoding($row) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->__dbConvertEncoding($row); + } + + private function _db_debug_prepare($stm_name, $data = array()) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->__dbDebugPrepare($stm_name, $data); + } + + private function _db_return_table($query) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->__dbReturnTable($query); + } + + private function _db_prepare_exec($query, $pk_name) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->__dbPrepareExec($query, $pk_name); + } + + private function _db_post_exec() + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->__dbPostExec(); + } + + public function db_set_debug($debug = '') + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbSetDebug($debug); + } + + public function db_reset_query_called($query) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbResetQueryCalled($query); + } + + public function db_get_query_called($query) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbGetQueryCalled($query); + } + + public function db_close() + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbClose(); + } + + public function db_set_schema($db_schema = '') + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbSetSchema($db_schema); + } + + public function db_get_schema() + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbGetSchema(); + } + + public function db_set_encoding($db_encoding = '') + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbSetEncoding($db_encoding); + } + + public function db_info($show = 1) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbInfo($show); + } + + public function db_dump_data($query = 0) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbDumpData($query); + } + + public function db_return($query, $reset = 0) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbReturn($query, $reset); + } + + public function db_cache_reset($query) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbCacheReset($query); + } + + public function db_exec($query = 0, $pk_name = '') + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbExec($query, $pk_name); + } + + public function db_exec_async($query, $pk_name = '') + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbExecAsync($query, $pk_name); + } + + public function db_check_async() + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbCheckAsync(); + } + + public function db_fetch_array($cursor = 0) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbFetchArray($cursor); + } + + public function db_return_row($query) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbReturnRow($query); + } + + public function db_return_array($query, $named_only = 0) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbReturnArray($query, $named_only); + } + + public function db_cursor_pos($query) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbCursorPos($query); + } + + public function db_cursor_num_rows($query) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbCursorNumRows($query); + } + + public function db_show_table_meta_data($table, $schema = '') + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbShowTableMetaData($table, $schema); + } + + public function db_prepare($stm_name, $query, $pk_name = '') + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbPrepare($stm_name, $query, $pk_name); + } + + public function db_execute($stm_name, $data = array()) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbExecute($stm_name, $data); + } + + public function db_escape_string($string) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbEscapeString($string); + } + + public function db_escape_bytea($bytea) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbEscapeBytea($bytea); + } + + public function db_version() + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbVersion(); + } + + public function db_compare_version($compare) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbCompareVersion($compare); + } + + public function db_boolean($string, $rev = false) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbBoolean($string, $rev); + } + + public function db_write_data($write_array, $not_write_array, $primary_key, $table, $data = array ()) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbWriteData($write_array, $not_write_array, $primary_key, $table, $data); + } + + public function db_write_data_ext($write_array, $primary_key, $table, $not_write_array = array (), $not_write_update_array = array (), $data = array ()) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbWriteDataExt($write_array, $primary_key, $table, $not_write_array, $not_write_update_array, $data); + } + + public function db_time_format($age, $show_micro = false) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbTimeFormat($age, $show_micro); + } + + public function db_array_parse($text) + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbArrayParse($text); + } + + public function db_sql_escape($value, $kbn = "") + { + error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']); + return $this->dbSqlEscape($value, $kbn); + } } // end if db class diff --git a/www/libs/db_pgsql.inc b/www/lib/CoreLibs/DB/SQL/PgSQL.inc similarity index 76% rename from www/libs/db_pgsql.inc rename to www/lib/CoreLibs/DB/SQL/PgSQL.inc index 13715d9c..bff0ce7e 100644 --- a/www/libs/db_pgsql.inc +++ b/www/lib/CoreLibs/DB/SQL/PgSQL.inc @@ -1,10 +1,14 @@ -last_error_query) { return true; @@ -59,11 +70,12 @@ class db_pgsql } } - // METHOD: _db_query + // METHOD: __dbQuery + // WAS : _db_query // PARAMS: query // RETURN: query result // DESC : wrapper for gp_query, catches error and stores it in class var - public function _db_query($query) + public function __dbQuery($query) { $this->last_error_query = ''; // read out the query status and save the query if needed @@ -74,20 +86,22 @@ class db_pgsql return $result; } - // METHOD: _db_send_query + // METHOD: __dbSendQuery + // WAS : _db_send_query // PARAMS: query // RETURN: true/false if query was sent successful // DESC : sends an async query to the server - public function _db_send_query($query) + public function __dbSendQuery($query) { return pg_send_query($this->dbh, $query); } - // METHOD: _db_get_result + // METHOD: __dbGetResult + // WAS : _db_get_result // PARAMS: none // RETURN: resource handler // DESC : wrapper for pg_get_result - public function _db_get_result() + public function __dbGetResult() { $this->last_error_query = ''; $result = pg_get_result($this->dbh); @@ -97,11 +111,12 @@ class db_pgsql return $result; } - // METHOD: _db_close + // METHOD: __dbClose + // WAS : _db_close // PARAMS: none // RETURN: none // DESC : wrapper for pg_close - public function _db_close() + public function __dbClose() { if (is_resource($this->dbh)) { if (pg_connection_status($this->dbh) === PGSQL_CONNECTION_OK) { @@ -110,11 +125,12 @@ class db_pgsql } } - // METHOD: _db_prepare + // METHOD: __dbPrepare + // WAS : _db_prepare // PARAMS: prepare name, query // RETURN: prepared statement handler // DESC : wrapper for pg_prepare - public function _db_prepare($name, $query) + public function __dbPrepare($name, $query) { $result = pg_prepare($this->dbh, $name, $query); if (!$result) { @@ -123,11 +139,12 @@ class db_pgsql return $result; } - // METHOD: _db_execute + // METHOD: __dbExecute + // WAS : _db_execute // PARAMS: prepare name, data for query // RETURN: returns status // DESC : wrapper for pg_execute for running a prepared statement - public function _db_execute($name, $data) + public function __dbExecute($name, $data) { $result = pg_execute($this->dbh, $name, $data); if (!$result) { @@ -136,38 +153,42 @@ class db_pgsql return $result; } - // METHOD: _db_num_rows + // METHOD: __dbNumRows + // WAS : _db_num_rows // PARAMS: cursor // RETURN: rows // DESC : wrapper for pg_num_rows - public function _db_num_rows($cursor) + public function __dbNumRows($cursor) { return pg_num_rows($cursor); } - // METHOD: _db_num_fields + // METHOD: __dbNumFields + // WAS : _db_num_fields // PARAMS: cursor // RETURN: number for fields in query // DESC : wrapper for pg_num_fields - public function _db_num_fields($cursor) + public function __dbNumFields($cursor) { return pg_num_fields($cursor); } - // METHOD: _db_field_name + // METHOD: __dbFieldName + // WAS : _db_field_name // PARAMS: cursor, field position // RETURN: name of field // DESC : wrapper for pg_field_name - public function _db_field_name($cursor, $i) + public function __dbFieldName($cursor, $i) { return pg_field_name($cursor, $i); } - // METHOD: _db_fetch_array + // METHOD: __dbFetchArray + // WAS : _db_fetch_array // PARAMS: cursor, opt result type // RETURN: row // DESC : wrapper for pg_fetch_array - public function _db_fetch_array($cursor, $result_type = '') + public function __dbFetchArray($cursor, $result_type = '') { // result type is passed on as is [should be checked] if ($result_type) { @@ -177,32 +198,35 @@ class db_pgsql } } - // METHOD: _db_fetch_all + // METHOD: __dbFetchAll + // WAS : _db_fetch_all // PARAMS: cursor // RETURN: all rows as array // DESC : wrapper for pg_fetch_array - public function _db_fetch_all($cursor) + public function __dbFetchAll($cursor) { return pg_fetch_all($cursor); } - // METHOD: _db_affected_ros + // METHOD: __dbAffectedRows + // WAS : _db_affected_rows // PARAMS: cursor // RETURN: number for rows // DESC : wrapper for pg_affected_rows - public function _db_affected_rows($cursor) + public function __dbAffectedRows($cursor) { return pg_affected_rows($cursor); } - // METHOD: _db_insert_id + // METHOD: __dbInsertId + // WAS : _db_insert_id // PARAMS: query, primary key name // RETURN: last insert primary key // DESC : reads the last inserted primary key for the query // if ther is no pk_name tries to auto built it from the table name // this only works if db schema is after "no plural names. and pk name is table name + _id // detects schema prefix in table name - public function _db_insert_id($query, $pk_name) + public function __dbInsertId($query, $pk_name) { // only if an insert has been done if (preg_match("/^insert /i", $query)) { @@ -227,8 +251,8 @@ class db_pgsql $seq = (($schema) ? $schema.'.' : '').$table."_".$pk_name."_seq"; $q = "SELECT CURRVAL('$seq') AS insert_id"; // I have to do manually or I overwrite the original insert internal vars ... - if ($q = $this->_db_query($q)) { - list($id) = $this->_db_fetch_array($q); + if ($q = $this->__dbQuery($q)) { + list($id) = $this->__dbFetchArray($q); } else { $id = array(-1, $q); } @@ -236,19 +260,20 @@ class db_pgsql } } - // METHOD: _db_primary_key + // METHOD: __dbPrimaryKey + // WAS : _db_primary_key // PARAMS: table and optional schema // RETURN: primary key name OR false if not possible // DESC : queries database for the primary key name to this table in the selected schema - public function _db_primary_key($table, $schema = '') + public function __dbPrimaryKey($table, $schema = '') { if ($table) { // check if schema set is different from schema given, only needed if schema is not empty $table_prefix = ''; if ($schema) { $q = "SHOW search_path"; - $cursor = $this->_db_query($q); - $search_path = $this->_db_fetch_array($cursor)['search_path']; + $cursor = $this->__dbQuery($q); + $search_path = $this->__dbFetchArray($cursor)['search_path']; if ($search_path != $schema) { $table_prefix = $schema.'.'; } @@ -271,9 +296,9 @@ class db_pgsql $q .= "pg_attribute.attrelid = pg_class.oid AND "; $q .= "pg_attribute.attnum = any(pg_index.indkey) "; $q .= "AND indisprimary"; - $cursor = $this->_db_query($q); + $cursor = $this->__dbQuery($q); if ($cursor) { - return $this->_db_fetch_array($cursor)['column_name']; + return $this->__dbFetchArray($cursor)['column_name']; } else { return false; } @@ -282,11 +307,12 @@ class db_pgsql } } - // METHOD: _db_connect + // METHOD: __dbConnect + // WAS : _db_connect // PARAMS: host name, user name, password, database name, optional port (defaults to default postgres port), optional ssl (default allow) // RETURN: database handler // DESC : wrapper for pg_connect, writes out failure to screen if error occurs (hidden var) - public function _db_connect($db_host, $db_user, $db_pass, $db_name, $db_port = 5432, $db_ssl = 'allow') + public function __dbConnect($db_host, $db_user, $db_pass, $db_name, $db_port = 5432, $db_ssl = 'allow') { // to avoid empty db_port if (!$db_port) { @@ -299,11 +325,12 @@ class db_pgsql return $this->dbh; } - // METHOD: _db_print_error + // METHOD: __dbPrintError + // WAS : _db_print_error // PARAMS: database handler, cursor // RETURN: error string (HTML) // DESC : reads the last error for this cursor - public function _db_print_error($cursor = '') + public function __dbPrintError($cursor = '') { // run the query again for the error result here if (!$cursor && $this->last_error_query) { @@ -316,47 +343,52 @@ class db_pgsql } } - // METHOD: _db_meta_data + // METHOD: __dbMetaData + // WAS : _db_meta_data // PARAMS: table name // RETURN: array with table data // DESC : wrapper for pg_emta_data - public function _db_meta_data($table) + public function __dbMetaData($table) { return pg_meta_data($this->dbh, $table); } - // METHOD: _db_escape_string + // METHOD: __dbEscapeString + // WAS : _db_escape_string // PARAMS: string // RETURN: escaped string for postgres // DESC : wrapper for pg_escape_string - public function _db_escape_string($string) + public function __dbEscapeString($string) { return pg_escape_string($this->dbh, $string); } - // METHOD: _db_escape_bytea + // METHOD: __dbEscapeBytea + // WAS : _db_escape_bytea // PARAMS: string // RETURN: escape bytes for postgres // DESC : wrapper for pg_escape_bytea - public function _db_escape_bytea($bytea) + public function __dbEscapeBytea($bytea) { return pg_escape_bytea($this->dbh, $bytea); } - // METHOD: _db_connection_busy + // METHOD: __dbConnectionBusy + // WAS : _db_connection_busy // PARAMS: none // RETURN: true/false for busy connection // DESC : wrapper for pg_connection_busy - public function _db_connection_busy() + public function __dbConnectionBusy() { return pg_connection_busy($this->dbh); } - // METHOD: _db_version + // METHOD: __dbVersion + // WAS : _db_version // PARAMS: none // RETURN: databse version // DESC : wrapper for pg_version - public function _db_version() + public function __dbVersion() { // array has client, protocol, server // we just need the server @@ -364,13 +396,14 @@ class db_pgsql return $v['server']; } - // METHOD: _db_array_parse + // METHOD: __dbArrayParse + // WAS : _db_array_parse // PARAMS: input text, output array [needed] // [internal] limit: are we at the end of the parse // [internal] offset: shift for {} // RETURN: array with the elements // DESC : postgresql array to php array - public function _db_array_parse($text, &$output, $limit = false, $offset = 1) + public function __dbArrayParse($text, &$output, $limit = false, $offset = 1) { if (false === $limit) { $limit = strlen($text) - 1; @@ -393,3 +426,5 @@ class db_pgsql return $output; } } + +# __END__ diff --git a/www/lib/CoreLibs/Language/Core/CachedFileReader.inc b/www/lib/CoreLibs/Language/Core/CachedFileReader.inc new file mode 100755 index 00000000..a2245e5e --- /dev/null +++ b/www/lib/CoreLibs/Language/Core/CachedFileReader.inc @@ -0,0 +1,48 @@ +. + + This file is part of PHP-gettext. + + PHP-gettext is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + PHP-gettext is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with PHP-gettext; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +namespace CoreLibs\Language\Core; + +// Preloads entire file in memory first, then creates a StringReader +// over it (it assumes knowledge of StringReader internals) +class CachedFileReader extends CoreLibs\Language\Core\StringReader +{ + public function __construct($filename) + { + if (file_exists($filename)) { + $length = filesize($filename); + $fd = fopen($filename, 'rb'); + + if (!$fd) { + $this->error = 3; // Cannot read file, probably permissions + return false; + } + $this->_str = fread($fd, $length); + fclose($fd); + } else { + $this->error = 2; // File doesn't exist + return false; + } + } +} + +# __END__ diff --git a/www/lib/CoreLibs/Language/Core/FileReader.inc b/www/lib/CoreLibs/Language/Core/FileReader.inc new file mode 100755 index 00000000..bfbdba78 --- /dev/null +++ b/www/lib/CoreLibs/Language/Core/FileReader.inc @@ -0,0 +1,91 @@ +. + + This file is part of PHP-gettext. + + PHP-gettext is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + PHP-gettext is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with PHP-gettext; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +namespace CoreLibs\Language\Core; + +class FileReader +{ + public $fr_pos; + public $fr_fd; + public $fr_length; + + public function __construct($filename) + { + if (file_exists($filename)) { + $this->fr_length = filesize($filename); + $this->fr_pos = 0; + $this->fr_fd = fopen($filename, 'rb'); + if (!$this->fr_fd) { + $this->error = 3; // Cannot read file, probably permissions + return false; + } + } else { + $this->error = 2; // File doesn't exist + return false; + } + } + + public function read($bytes) + { + if ($bytes) { + fseek($this->fr_fd, $this->fr_pos); + + // PHP 5.1.1 does not read more than 8192 bytes in one fread() + // the discussions at PHP Bugs suggest it's the intended behaviour + $data = ''; + while ($bytes > 0) { + $chunk = fread($this->fr_fd, $bytes); + $data .= $chunk; + $bytes -= strlen($chunk); + } + $this->fr_pos = ftell($this->fr_fd); + + return $data; + } else { + return ''; + } + } + + public function seekto($pos) + { + fseek($this->fr_fd, $pos); + $this->fr_pos = ftell($this->fr_fd); + return $this->fr_pos; + } + + public function currentpos() + { + return $this->fr_pos; + } + + public function length() + { + return $this->fr_length; + } + + public function close() + { + fclose($this->fr_fd); + } +} + +# __END__ diff --git a/www/libs/gettext.php b/www/lib/CoreLibs/Language/Core/GetTextReader.inc old mode 100644 new mode 100755 similarity index 99% rename from www/libs/gettext.php rename to www/lib/CoreLibs/Language/Core/GetTextReader.inc index 71a2fddb..f0f77eaa --- a/www/libs/gettext.php +++ b/www/lib/CoreLibs/Language/Core/GetTextReader.inc @@ -20,6 +20,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +namespace CoreLibs\Language\Core; + /** * Provides a simple gettext replacement that works independently from * the system's gettext abilities. @@ -32,7 +34,7 @@ * second parameter in the constructor (e.g. whenusing very large MO files * that you don't want to keep in memory) */ -class gettext_reader +class GetTextReader { // public: public $error = 0; // public variable that holds error code (0 if no error) @@ -454,3 +456,5 @@ class gettext_reader } } } + +# __END__ \ No newline at end of file diff --git a/www/lib/CoreLibs/Language/Core/StreamReader.inc b/www/lib/CoreLibs/Language/Core/StreamReader.inc new file mode 100755 index 00000000..805db260 --- /dev/null +++ b/www/lib/CoreLibs/Language/Core/StreamReader.inc @@ -0,0 +1,54 @@ +. + + This file is part of PHP-gettext. + + PHP-gettext is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + PHP-gettext is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with PHP-gettext; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +namespace CoreLibs\Language\Core; + +// Simple class to wrap file streams, string streams, etc. +// seek is essential, and it should be byte stream +class StreamReader +{ + // should return a string [FIXME: perhaps return array of bytes?] + public function read($bytes) + { + return false; + } + + // should return new position + public function seekto($position) + { + return false; + } + + // returns current position + public function currentpos() + { + return false; + } + + // returns length of entire stream (limit for seekto()s) + public function length() + { + return false; + } +} + +# __END__ diff --git a/www/lib/CoreLibs/Language/Core/StringReader.inc b/www/lib/CoreLibs/Language/Core/StringReader.inc new file mode 100755 index 00000000..e1c63818 --- /dev/null +++ b/www/lib/CoreLibs/Language/Core/StringReader.inc @@ -0,0 +1,67 @@ +. + + This file is part of PHP-gettext. + + PHP-gettext is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + PHP-gettext is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with PHP-gettext; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +namespace CoreLibs\Language\Core; + +class StringReader +{ + public $sr_pos; + public $sr_str; + + public function __construct($str = '') + { + $this->sr_str = $str; + $this->sr_pos = 0; + } + + public function read($bytes) + { + $data = substr($this->sr_str, $this->sr_pos, $bytes); + $this->sr_pos += $bytes; + if (strlen($this->sr_str) < $this->sr_pos) { + $this->sr_pos = strlen($this->sr_str); + } + + return $data; + } + + public function seekto($pos) + { + $this->sr_pos = $pos; + if (strlen($this->sr_str) < $this->sr_pos) { + $this->sr_pos = strlen($this->sr_str); + } + return $this->sr_pos; + } + + public function currentpos() + { + return $this->sr_pos; + } + + public function length() + { + return strlen($this->sr_str); + } +} + +# __END__ diff --git a/www/libs/Class.l10n.inc b/www/lib/CoreLibs/Language/L10n.inc similarity index 81% rename from www/libs/Class.l10n.inc rename to www/lib/CoreLibs/Language/L10n.inc index 7b22cefd..e511a2b0 100644 --- a/www/libs/Class.l10n.inc +++ b/www/lib/CoreLibs/Language/L10n.inc @@ -1,8 +1,8 @@ -lang = 'en'; } else { @@ -60,7 +58,7 @@ class l10n extends basic $this->input = false; } - $this->l10n = new gettext_reader($this->input); + $this->l10n = new GetTextReader($this->input); } // reloads the mofile, if the location of the lang file changes @@ -82,7 +80,7 @@ class l10n extends basic // check if get a readable mofile if (is_readable($this->mofile)) { $this->input = new FileReader($this->mofile); - $this->l10n = new gettext_reader($this->input); + $this->l10n = new GetTextReader($this->input); } else { // else fall back to the old ones $this->mofile = $old_mofile; @@ -95,7 +93,7 @@ class l10n extends basic return $this->l10n->translate($text); } - public function _e($text) + public function __e($text) { echo $this->l10n->translate($text); } @@ -106,12 +104,12 @@ class l10n extends basic return $this->l10n->ngettext($single, $plural, $number); } - public function __get_lang() + public function __getLang() { return $this->lang; } - public function __get_mofile() + public function __getMoFile() { return $this->mofile; } diff --git a/www/libs/Class.Form.Generate.inc b/www/lib/CoreLibs/Output/Form/Generate.inc similarity index 87% rename from www/libs/Class.Form.Generate.inc rename to www/lib/CoreLibs/Output/Form/Generate.inc index 00eed11c..e78e5994 100644 --- a/www/libs/Class.Form.Generate.inc +++ b/www/lib/CoreLibs/Output/Form/Generate.inc @@ -1,8 +1,8 @@ - connect to DB - // $lang -> language code ("en", "ja", etc) - // $table_width -> width of table - // $db_debug -> turns db_io debug on/off (DB_DEBUG as global var does the same) + // METHOD: constructor + // PARAMS: $db_config -> connect to DB + // $lang -> language code ("en", "ja", etc) + // $table_width -> width of table + // $db_debug -> turns db_io debug on/off (DB_DEBUG as global var does the same) public function __construct($db_config, $lang, $table_width = 750, $debug = 0, $db_debug = 0, $echo = 1, $print = 0) { - $this->my_page_name = $this->get_page_name(1); + $this->my_page_name = $this->getPageName(1); // init the language class - _spl_autoload('Class.l10n.inc'); - $this->l = new l10n($lang); + $this->l = new \CoreLibs\Language\L10n($lang); // load config array // get table array definitions for current page name // WARNING: auto spl load does not work with this as it is an array and not a function/object -// $flag = _spl_autoload('array_'.$this->my_page_name.'.inc'); include(TABLE_ARRAYS."array_".$this->my_page_name.".inc"); - $config_array = ${$this->my_page_name}; // start the array_io class which will start db_io ... @@ -309,14 +305,14 @@ class form extends db_array_io // internal $this->class_info["form"] = array( "class_name" => "Form create", - "class_version" => "2.4.9", + "class_version" => "3.0.0", "class_created" => "2002-10-22", - "class_author" => "cs/gullevek/at" + "class_author" => "Clemens Schwaighofer" ); } // dumps all values into output (for error msg) - public function form_dump_table_array() + public function formDumpTableArray() { if (!is_array($this->table_array)) { $this->table_array = array (); @@ -338,49 +334,14 @@ class form extends db_array_io parent::__destruct(); } - /***************************************************** - Along here are wrapper functions for the former, old names - */ - - public function form_load() - { - return $this->form_create_load(); - } - - public function form_new($hide_new_checkbox = 0) - { - return $this->form_create_new($hide_new_checkbox); - } - - public function form_delete_save($hide_delete = 0, $hide_delete_checkbox = 0) - { - return $this->form_create_save_delete($hide_delete, $hide_delete_checkbox); - } - - public function form_error_msg() - { - return $this->form_print_msg(); - } - - public function form_show_reference_table($table_name) - { - return $this->form_create_element_reference_table($table_name); - } - - public function form_show_list_table($table_name) - { - return $this->form_create_element_list_table($table_name); - } - - // END wrapper - - // METHOD form_get_col_name_from_key - // PARAMS $want_key: the key where u want the data from - // $key_value: if set searches for special right value - // RETURN the value of the $want_key array field - // works only with fields that appear only ONCE - // if multiple gets only FIRST - public function form_get_col_name_from_key($want_key, $key_value = "") + // METHOD: formGetColNameFromKey + // WAS : form_get_col_name_from_key + // PARAMS: $want_key: the key where u want the data from + // $key_value: if set searches for special right value + // RETURN: the value of the $want_key array field + // works only with fields that appear only ONCE + // if multiple gets only FIRST + public function formGetColNameFromKey($want_key, $key_value = "") { if (!is_array($this->table_array)) { $this->table_array = array (); @@ -395,11 +356,12 @@ class form extends db_array_io } } - // METHOD form_get_col_name_array_from_key - // PARAMS $want_key: the key where u want the data from - // $key_value: if set searches for special right value - // RETURN array of fields - public function form_get_col_name_array_from_key($want_key, $key_value = "") + // METHOD: formGetColNameArrayFromKey + // WAS : form_get_col_name_array_from_key + // PARAMS: $want_key: the key where u want the data from + // $key_value: if set searches for special right value + // RETURN: array of fields + public function formGetColNameArrayFromKey($want_key, $key_value = "") { $key_array = array(); if (!is_array($this->table_array)) { @@ -417,10 +379,11 @@ class form extends db_array_io return $key_array; } - // METHOD form_print_msg - // PARAMS none - // RETURN formated output for the error && warning msg - public function form_print_msg() + // METHOD: formPrintMsg + // WAS : form_print_msg + // PARAMS: none + // RETURN: formated output for the error && warning msg + public function formPrintMsg() { if ($this->error) { $class = "error"; @@ -432,27 +395,29 @@ class form extends db_array_io } // next for functions are pre_test fkts for easier default new,load, etc handling - // METHOD form_procedure_load - // PARAMS archive_id - which ID should be loaded - // RETURN none - // DESC default load procedure - public function form_procedure_load($archive_id) + // METHOD: formProcedureLoad + // WAS : form_procedure_load + // PARAMS: archive_id - which ID should be loaded + // RETURN: none + // DESC : default load procedure + public function formProcedureLoad($archive_id) { if ($this->archive && $archive_id && $this->group_level_user <= $this->security_level["load"]) { - $this->form_load_table_array($archive_id); + $this->formLoadTableArray($archive_id); $this->yes = 1; } } - // METHOD form_procedure_new - // PARAMS none - // RETURN none - // DESC default new procedure - public function form_procedure_new() + // METHOD: formProcedureNew + // WAS : form_procedure_new + // PARAMS: none + // RETURN: none + // DESC : default new procedure + public function formProcedureNew() { if ($this->new && $this->group_level_user <= $this->security_level["new"]) { if ($this->really_new == "yes") { - $this->form_unset_table_array(); + $this->formUnsetTablearray(); } else { $this->msg .= $this->l->__("You have to select the Checkbox for New!
"); $this->error = 2; @@ -461,26 +426,28 @@ class form extends db_array_io } } - // METHOD form_procedure_save - // PARAMS none - // RETURN none - // DESC default save procedure - public function form_procedure_save() + // METHOD: formProcedureSave + // WAS : form_procedure_save + // PARAMS: none + // RETURN: none + // DESC : default save procedure + public function formProcedureSave() { if ($this->save && $this->group_level_user <= $this->security_level["save"]) { - $this->form_error_check(); + $this->formErrorCheck(); if (!$this->error) { - $this->form_save_table_array(); + $this->formSaveTableArray(); } $this->yes = 1; } } - // METHOD form_procedure_delete - // PARAMS none - // RETURN none - // DESC default delete procedure - public function form_procedure_delete() + // METHOD: formProcedureDelete + // WAS : form_procedure_delete + // PARAMS: none + // RETURN: none + // DESC : default delete procedure + public function formProcedureDelete() { // delete is also by "protected" if ($this->delete && $this->group_level_user <= $this->security_level["delete"] && !$this->table_array["protected"]["value"]) { @@ -489,7 +456,7 @@ class form extends db_array_io $this->error = 2; } if ($this->really_delete == "yes") { - $this->form_delete_table_array(); + $this->formDeleteTableArray(); } else { $this->msg .= $this->l->__("You have to select the Checkbox for Delete!
"); $this->error = 2; @@ -498,16 +465,17 @@ class form extends db_array_io } } - // METHOD form_procedure_delete_from_element_list - // PARAMS none - // RETURN none - // DESC default delete procedure - public function form_procedure_delete_from_element_list($element_list, $remove_name) + // METHOD: formProcedureDeleteFromElementList + // WAS : form_procedure_delete_from_element_list + // PARAMS: none + // RETURN: none + // DESC : default delete procedure + public function formProcedureDeleteFromElementList($element_list, $remove_name) { // only do if the user is allowed to delete if ($this->group_level_user <= $this->security_level["delete"] && !$this->table_array["protected"]["value"] && !$this->error) { for ($i = 0; $i < count($element_list); $i ++) { -//$this->debug('form_error', "Array: ".is_array($this->element_list[$element_list[$i]]["read_data"])." | ".$this->element_list[$element_list[$i]]["delete"]); + // $this->debug('form_error', "Array: ".is_array($this->element_list[$element_list[$i]]["read_data"])." | ".$this->element_list[$element_list[$i]]["delete"]); // if prefix, set it $prfx = ($this->element_list[$element_list[$i]]["prefix"]) ? $this->element_list[$element_list[$i]]["prefix"]."_" : ''; // get the primary key @@ -524,7 +492,7 @@ class form extends db_array_io if ($_POST[$flag] == "true") { $q = "DELETE FROM ".$element_list[$i]." WHERE ".$pk_name." = ".$_POST[$id]; - $this->db_exec($q); + $this->dbExec($q); $this->msg .= $this->l->__("Removed entry from list
"); $this->warning = 1; } // post okay true -> delete @@ -534,20 +502,20 @@ class form extends db_array_io if (!$_POST[$remove_name[$i]][$j]) { $q = "UPDATE ".$element_list[$i]." WHERE ".$pk_name." = ".$_POST[$prfx.$pk_name][$j]; // $this->debug('edit_db', "UP: $q"); - // $this->db_exec($q); + // $this->dbExec($q); $this->msg .= $this->l->__("Disabled deselected entries from list
"); $this->warning = 1; } } } elseif (is_array($this->element_list[$element_list[$i]]["read_data"]) && $this->element_list[$element_list[$i]]["delete"]) { -//$this->debug('form_clean', "ID [$id] [$prfx.$pk_name]"); -//$this->debug('form_clean', "ID arr: ".$this->print_ar($_POST[$id])); -//$this->debug('form_clean', "PK arr: ".$this->print_ar($_POST[$prfx.$pk_name])); + // $this->debug('form_clean', "ID [$id] [$prfx.$pk_name]"); + // $this->debug('form_clean', "ID arr: ".$this->print_ar($_POST[$id])); + // $this->debug('form_clean', "PK arr: ".$this->print_ar($_POST[$prfx.$pk_name])); for ($j = 0; $j < count($_POST[$prfx.$pk_name]); $j ++) { if (!$_POST[$remove_name[$i]][$j] && $_POST[$prfx.$pk_name][$j]) { $q = "DELETE FROM ".$element_list[$i]." WHERE ".$pk_name." = ".$_POST[$prfx.$pk_name][$j]; -// $this->debug('edit_db', "DEL: $q"); - $this->db_exec($q); + // $this->debug('edit_db', "DEL: $q"); + $this->dbExec($q); $this->msg .= $this->l->__("Deleted deselected entries from list
"); $this->warning = 1; } @@ -560,17 +528,18 @@ class form extends db_array_io } } - // METHOD form_create_load - // PARAMS none - // RETURN string from "load" part of form ... - public function form_create_load() + // METHOD: formCreateLoad + // WAS : form_create_load + // PARAMS: none + // RETURN: string from "load" part of form ... + public function formCreateLoad() { // when security leve is okay ... if ($this->group_level_user <= $this->security_level["load"]) { $t_pk_name = $this->archive_pk_name; // lade liste - $this->db_exec($this->load_query); + $this->dbExec($this->load_query); while ($res = $this->db_fetch_array()) { $pk_ids[] = $res[$this->int_pk_name]; if ($res[$this->int_pk_name] == $this->table_array[$this->int_pk_name]["value"]) { @@ -590,19 +559,17 @@ class form extends db_array_io $t_string .= $res[$this->field_array[$i]["name"]]; } } -/* -// -*/ $pk_names[] = $t_string; } } // show it at all return array('t_pk_name' => $t_pk_name, 'pk_ids' => $pk_ids, 'pk_names' => $pk_names, 'pk_selected' => $pk_selected); } - // METHOD form_create_new - // PARAMS none - // RETURN part for new - public function form_create_new($hide_new_checkbox = 0) + // METHOD: formCreateNew + // WAS : form_create_new + // PARAMS: none + // RETURN: part for new + public function formCreateNew($hide_new_checkbox = 0) { // when security level is okay if ($this->group_level_user <= $this->security_level["new"]) { @@ -619,10 +586,11 @@ class form extends db_array_io return array('new_name' => $new_name, 'show_checkbox' => $show_checkbox); } - // METHOD form_create_save_delete - // PARAMS none - // RETURN string for delete / save part - public function form_create_save_delete($hide_delete = 0, $hide_delete_checkbox = 0) + // METHOD: formCreateSaveDelete + // WAS : form_create_save_delete + // PARAMS: none + // RETURN: string for delete / save part + public function formCreateSaveDelete($hide_delete = 0, $hide_delete_checkbox = 0) { if ($this->group_level_user <= $this->security_level["save"] || $this->group_level_user <= $this->security_level["delete"]) { $old_school_hidden = 0; @@ -647,13 +615,14 @@ class form extends db_array_io return array('seclevel_okay' => $seclevel_okay, 'save' => $save, 'pk_name' => $pk_name, 'pk_value' => $pk_value, 'show_delete' => $show_delete, 'hide_delete_checkbox' => $hide_delete_checkbox); } // end of function - // METHOD form_create_element - // PARAMS $element_name: the name from the array, you want to have build - // $query: can overrule internal query data, - // for drop down, as data comes from a reference table - // for drop_down_text it has to be an array with $key->$value - // RETURN element in HTML - public function form_create_element($element_name, $query = "") + // METHOD: formCreateElement + // WAS : form_create_element + // PARAMS: $element_name: the name from the array, you want to have build + // $query: can overrule internal query data, + // for drop down, as data comes from a reference table + // for drop_down_text it has to be an array with $key->$value + // RETURN: element in HTML + public function formCreateElement($element_name, $query = "") { // special 2nd color for "binary" attribut if ($this->table_array[$element_name]["type"] == "binary" && !$this->table_array[$element_name]["value"]) { @@ -824,13 +793,14 @@ class form extends db_array_io return array('output_name' => $output_name, 'color' => $EDIT_FGCOLOR_T, 'type' => $type, 'data' => $data); } - // METHOD form_error_check - // PARAMS none - // RETURNS full error message string for output + // METHOD: formErrorCheck + // WAS : form_error_check + // PARAMS: none + // RETURN: full error message string for output // should be cought like this ... // if ($msg=$form->form_error_check()) // $error=1; - public function form_error_check() + public function formErrorCheck() { if (!is_array($this->table_array)) { $this->table_array = array (); @@ -841,7 +811,7 @@ class form extends db_array_io // if error value set && somethign input, check if input okay if ($value["error_check"] && $this->table_array[$key]["value"]) { // each error check can be a piped seperated value, lets split it -//$this->debug('edit', $value["error_check"]); + // $this->debug('edit', $value["error_check"]); foreach (explode('|', $value["error_check"]) as $error_check) { switch ($error_check) { case "number": @@ -878,7 +848,7 @@ class form extends db_array_io if ($this->table_array[$this->int_pk_name]["value"]) { $q .= " AND ".$this->int_pk_name." <> ".$this->table_array[$this->int_pk_name]["value"]; } - list($$key) = $this->db_return_row($q); + list($$key) = $this->dbReturnRow($q); if ($$key) { $this->msg .= sprintf($this->l->__("The field %s can be used only once!
"), $this->table_array[$key]["output_name"]); } @@ -889,20 +859,20 @@ class form extends db_array_io } break; case "alphanumericspace": -//$this->debug('edit', 'IN Alphanumericspace'); + // $this->debug('edit', 'IN Alphanumericspace'); if (!preg_match("/^[0-9A-Za-z\ ]+$/", $this->table_array[$key]["value"])) { $this->msg .= sprintf($this->l->__("Please enter a valid alphanumeric (Numbers and Letters, spaces allowed) value for the %s Field!
"), $this->table_array[$key]["output_name"]); } break; case "alphanumeric": -//$this->debug('edit', 'IN Alphanumeric'); + // $this->debug('edit', 'IN Alphanumeric'); if (!preg_match("/^[0-9A-Za-z_\-]+$/", $this->table_array[$key]["value"])) { $this->msg .= sprintf($this->l->__("Please enter a valid alphanumeric (Numbers and Letters only also - and _, no spaces) value for the %s Field!
"), $this->table_array[$key]["output_name"]); } break; // this one also allows @ and . case "alphanumericextended": -//$this->debug('edit', 'IN Alphanumericextended'); + // $this->debug('edit', 'IN Alphanumericextended'); if (!preg_match("/^[0-9A-Za-z_\-@\.]+$/", $this->table_array[$key]["value"])) { $this->msg .= sprintf($this->l->__("Please enter a valid alphanumeric extended (Numbers, Letters, -, _, @ and . only, no spaces) value for the %s Field!
"), $this->table_array[$key]["output_name"]); } @@ -928,7 +898,7 @@ class form extends db_array_io // main if end ) { // if mandatory && no input -//$this->debug('form', "A: ".$this->table_array[$key]["type"]." -- ".$this->table_array[$key]["input_value"]." -- ".$this->table_array[$key]["value"]); + // $this->debug('form', "A: ".$this->table_array[$key]["type"]." -- ".$this->table_array[$key]["input_value"]." -- ".$this->table_array[$key]["value"]); if (!$this->table_array[$key]["value"] && $this->table_array[$key]["type"] != "binary") { $this->msg .= sprintf($this->l->__("Please enter something into the %s field!
"), $this->table_array[$key]["output_name"]); } @@ -964,7 +934,7 @@ class form extends db_array_io } } } -//$this->debug('edit_error', "QS:
".print_r($_POST, 1)."
"); + // $this->debug('edit_error', "QS:
".print_r($_POST, 1)."
"); if (is_array($this->element_list)) { // check the mandatory stuff // if mandatory, check that at least on pk exists or if at least the mandatory field is filled @@ -988,10 +958,10 @@ class form extends db_array_io if (count($_POST[$prfx.$key]) > $max) { $max = count($_POST[$prfx.$key]); } -//$this->debug('edit_error_chk', "KEY: $prfx$key | count: ".count($_POST[$prfx.$key])." | M: $max"); -//$this->debug('edit_error_chk', "K: ".$_POST[$prfx.$key]." | ".$_POST[$prfx.$key][0]); + // $this->debug('edit_error_chk', "KEY: $prfx$key | count: ".count($_POST[$prfx.$key])." | M: $max"); + // $this->debug('edit_error_chk', "K: ".$_POST[$prfx.$key]." | ".$_POST[$prfx.$key][0]); } -//$this->debug('post_array', $this->print_ar($_POST)); + $this->debug('post_array', $this->print_ar($_POST)); # check each row for ($i = 0; $i < $max; $i ++) { // either one of the post pks is set, or the mandatory @@ -1005,18 +975,18 @@ class form extends db_array_io } // we found a mandatory field. check now if one is set to satisfy the main mandatory // also check, if this field is mandatory and its not set, but any other, throw an error -//$this->debug('edit_error_chk', "RG error - Data[".$prfx.$el_name.": ".$_POST[$prfx.$el_name][$i]." | ".$_POST[$prfx.$el_name]." - ".$reference_array['enable_name']." - ".$_POST[$reference_array['enable_name']][$_POST[$prfx.$el_name][$i]]); + // $this->debug('edit_error_chk', "RG error - Data[".$prfx.$el_name.": ".$_POST[$prfx.$el_name][$i]." | ".$_POST[$prfx.$el_name]." - ".$reference_array['enable_name']." - ".$_POST[$reference_array['enable_name']][$_POST[$prfx.$el_name][$i]]); if ($data_array["mandatory"] && $_POST[$prfx.$el_name][$i]) { $mand_okay = 1; $row_okay[$i] = 1; } elseif ($data_array['type'] == 'radio_group' && !isset($_POST[$prfx.$el_name])) { // radio group and set where one not active -//$this->debug('edit_error_chk', "RADIO GROUP"); + // $this->debug('edit_error_chk', "RADIO GROUP"); $row_okay[$_POST[$prfx.$el_name][$i]] = 0; $default_wrong[$_POST[$prfx.$el_name][$i]] = 1; $error[$_POST[$prfx.$el_name][$i]] = 1; } elseif ($_POST[$prfx.$el_name][$i] && !$error[$i]) { -//$this->debug('edit_error_chk', "[$i]"); + // $this->debug('edit_error_chk', "[$i]"); $element_set[$i] = 1; $row_okay[$i] = 1; } elseif ($data_array["mandatory"] && !$_POST[$prfx.$el_name][$i]) { @@ -1033,7 +1003,7 @@ class form extends db_array_io if ($this->table_array[$this->int_pk_name]["value"]) { $q .= " AND ".$this->int_pk_name." <> ".$this->table_array[$this->int_pk_name]["value"]; } - list($$key) = $this->db_return_row($q); + list($$key) = $this->dbReturnRow($q); if ($$key) { $this->msg .= sprintf($this->l->__("The field %s in row %s can be used only once!
"), $reference_array["output_name"], $i); } @@ -1068,38 +1038,40 @@ class form extends db_array_io } } - // METHOD form_set_order - // PARAMS none - // RETURN the table array - // DOES sets the order to the maximum, if order flag is set in array - public function form_set_order() + // METHOD: formSetOrder + // WAS: form_set_order + // PARAMS: none + // RETURN: the table array + // DESC : sets the order to the maximum, if order flag is set in array + public function formSetOrder() { // get order name - $order_name = $this->form_get_col_name_from_key("order"); + $order_name = $this->formGetColNameFromKey("order"); if ($order_name) { // first check out of order ... if (!$this->table_array[$order_name]["value"]) { // set order (read max) $q = "SELECT MAX(".$order_name.") + 1 AS max_page_order FROM ".$this->table_name; - list($this->table_array[$order_name]["value"]) = $this->db_return_row($q); + list($this->table_array[$order_name]["value"]) = $this->dbReturnRow($q); // frist element is 0 because NULL gets returned, set to 1 if (!$this->table_array[$order_name]["value"]) { $this->table_array[$order_name]["value"] = 1; } } elseif ($this->table_array[$this->int_pk_name]["value"]) { $q = "SELECT $order_name FROM ".$this->table_name." WHERE ".$this->int_pk_name." = ".$this->table_array[$this->int_pk_name]["value"]; - list($this->table_array[$order_name]["value"]) = $this->db_return_row($q); + list($this->table_array[$order_name]["value"]) = $this->dbReturnRow($q); } } return $this->table_array; } - // METHOD form_unsert_table_array - // PARAMS none - // RETURN none - // DOES resets all values in table_array and in the reference tables - public function form_unset_table_array() + // METHOD: formUnsetTableArray + // WAS : form_unsert_table_array + // PARAMS: none + // RETURN: none + // DESC : resets all values in table_array and in the reference tables + public function formUnsetTableArray() { unset($this->pk_id); if (!is_array($this->table_array)) { @@ -1127,11 +1099,12 @@ class form extends db_array_io $this->msg = $this->l->__("Cleared for new Dataset!"); } - // METHOD form_load_table_array - // PARAMS pk_id - overrule pk_id - // RETURN none - // DESC load a table & reference - public function form_load_table_array($pk_id = 0) + // METHOD: formLoadTableArray + // WAS : form_load_table_array + // PARAMS: pk_id - overrule pk_id + // RETURN: none + // DESC : load a table & reference + public function formLoadTableArray($pk_id = 0) { if ($pk_id) { $this->pk_id = $pk_id; @@ -1165,11 +1138,12 @@ class form extends db_array_io $this->msg = $this->l->__("Dataset has been loaded!
"); } - // METHOD form_save_table_array - // PARAMS addslashes - if one, passes 1 to the db_write function - // RETURN none - // DESC save a table, reference and all input fields - public function form_save_table_array($addslashes = 0) + // METHOD: formSaveTableArray + // WAS : form_save_table_array + // PARAMS: addslashes - if one, passes 1 to the db_write function + // RETURN: none + // DESC : save a table, reference and all input fields + public function formSaveTableArray($addslashes = 0) { // global $_FILES; // for drop_down_db_input check if text field is filled and if, if not yet in db ... @@ -1189,20 +1163,20 @@ class form extends db_array_io if ($this->table_array[$key]["where"]) { $q .= " AND ".$this->table_array[$key]["where"]; } - list($pk_name_temp) = $this->db_return_row($q); + list($pk_name_temp) = $this->dbReturnRow($q); if ($this->num_rows >= 1) { $this->table_array[$key]["value"] = $pk_name_temp; } else { // if a where was given, set this key also [dangerous!] // postgreSQL compatible insert $q = "INSERT INTO ".$this->table_array[$key]["table_name"]." (".$this->table_array[$key]["input_name"].") VALUES ('".$this->db_escape_string($this->table_array[$key]["input_value"])."')"; - $this->db_exec($q); + $this->dbExec($q); if ($this->table_array[$key]["where"]) { // make an update on the just inseted data with the where data als update values $q = "UPDATE ".$this->table_array[$key]["table_name"]." SET "; $q .= $this->table_array[$key]["where"]." "; $q .= "WHERE ".$this->table_array[$key]["pk_name"]." = ".$this->insert_id; - $this->db_exec($q); + $this->dbExec($q); } $this->table_array[$key]["value"] = $this->insert_id; } // set value from DB through select or insert @@ -1218,7 +1192,7 @@ class form extends db_array_io if ($this->table_array[$key]["where"]) { $q .= " AND ".$this->table_array[$key]["where"]; } - list($temp) = $this->db_return_row($q); + list($temp) = $this->dbReturnRow($q); // nothing found in table, use new inserted key if (!$temp) { $this->table_array[$key]["value"] = $this->table_array[$key]["input_value"]; @@ -1276,9 +1250,9 @@ class form extends db_array_io } // go through each field // set object order (if necessary) - $this->form_set_order(); + $this->formSetOrder(); // write the object - $this->db_write($addslashes); + $this->dbWrite($addslashes); // write reference array(s) if necessary if (is_array($this->reference_array)) { if (!is_array($this->reference_array)) { @@ -1287,11 +1261,11 @@ class form extends db_array_io reset($this->reference_array); foreach ($this->reference_array as $reference_array) { $q = "DELETE FROM ".$reference_array["table_name"]." WHERE ".$this->int_pk_name."=".$this->table_array[$this->int_pk_name]["value"]; - $this->db_exec($q); + $this->dbExec($q); $q = "INSERT INTO ".$reference_array["table_name"]." (".$reference_array["other_table_pk"].", ".$this->int_pk_name.") VALUES "; for ($i = 0; $i < count($reference_array["selected"]); $i ++) { $t_q = "(".$reference_array["selected"][$i].", ".$this->table_array[$this->int_pk_name]["value"].")"; - $this->db_exec($q.$t_q); + $this->dbExec($q.$t_q); } } // foreach reference arrays } // if reference arrays @@ -1409,7 +1383,7 @@ class form extends db_array_io $this->debug('edit', "Pos[$i] => ".$type[$i]." Q: ".$q."
"); // write the dataset if ($q) { - $this->db_exec($q); + $this->dbExec($q); } } } // for each created query @@ -1419,11 +1393,12 @@ class form extends db_array_io $this->msg = $this->l->__("Dataset has been saved!
"); } - // METHOD form_delete_table_array - // PARAMS none - // RETURN none - // DESC delete a table and reference fields - public function form_delete_table_array() + // METHOD: formDeleteTableArray + // WAS : form_delete_table_array + // PARAMS: none + // RETURN: none + // DESC : delete a table and reference fields + public function formDeleteTableArray() { // remove any reference arrays if (is_array($this->reference_array)) { @@ -1433,7 +1408,7 @@ class form extends db_array_io reset($this->reference_array); foreach ($this->reference_array as $reference_array) { $q = "DELETE FROM ".$reference_array["table_name"]." WHERE ".$this->int_pk_name." = ".$this->table_array[$this->int_pk_name]["value"]; - $this->db_exec($q); + $this->dbExec($q); } } // remove any element list references @@ -1444,7 +1419,7 @@ class form extends db_array_io reset($this->element_list); while (list($table_name, $data_array) = each($this->element_list)) { $q = "DELETE FROM ".$table_name." WHERE ".$this->int_pk_name." = ".$this->table_array[$this->int_pk_name]["value"]; - $this->db_exec($q); + $this->dbExec($q); } } // unlink ALL files @@ -1462,11 +1437,12 @@ class form extends db_array_io $this->msg = $this->l->__("Dataset has been deleted!"); } - // METHOD form_create_hidden_fields - // PARAMS $hidden_array - // RETURNS the input fields (html) - // creates HTML hidden input fields out of an hash array - public function form_create_hidden_fields($hidden_array = "") + // METHOD: formCreateHiddenFields + // WAS : form_create_hidden_fields + // PARAMS: $hidden_array + // RETURN: the input fields (html) + // DESC : creates HTML hidden input fields out of an hash array + public function formCreateHiddenFields($hidden_array = "") { $hidden = array (); if (!is_array($this->table_array)) { @@ -1487,11 +1463,12 @@ class form extends db_array_io return $hidden; } - // METHOD form_create_element_reference_table - // PARAMS show which reference table - // RETURN array for output - // DESC creates the multiple select part for a reference_table - public function form_create_element_reference_table($table_name) + // METHOD: formCreateElementReferenceTable + // WAS : form_create_element_reference_table + // PARAMS: show which reference table + // RETURN: array for output + // DESC : creates the multiple select part for a reference_table + public function formCreateElementReferenceTable($table_name) { $output_name = $this->reference_array[$table_name]["output_name"]; if ($this->reference_array[$table_name]["mandatory"]) { @@ -1508,13 +1485,14 @@ class form extends db_array_io return array('output_name' => $output_name, 'type' => $type, 'color' => 'edit_fgcolor', 'data' => $data); } - // METHOD form_create_element_list - // PARAMS show which element list - // RETURN array for output - // DESC create list of elements next to each other for a group of data in an input field - // this currently only works for a list that is filled from a sub table and creates only a connection to this one - // new version will allow a sub list with free input fields to directly fill a sub table to a master table - public function form_create_element_list_table($table_name) + // METHOD: formCreateElementListTable + // WAS : form_create_element_list_table + // PARAMS: show which element list + // RETURN: array for output + // DESC : create list of elements next to each other for a group of data in an input field + // this currently only works for a list that is filled from a sub table and creates only a connection to this one + // new version will allow a sub list with free input fields to directly fill a sub table to a master table + public function formCreateElementListTable($table_name) { // output name for the viewable left table td box, prefixed with * if mandatory $output_name = $this->element_list[$table_name]["output_name"]; @@ -1547,7 +1525,7 @@ class form extends db_array_io // generic data read in (counts for all rows) // visible list data output while (list($el_name, $data_array) = each($this->element_list[$table_name]["elements"])) { -// $this->debug('CFG', 'El: '.$el_name.' -> '.$this->print_ar($data_array)); + $this->debug('CFG', 'El: '.$el_name.' -> '.$this->print_ar($data_array)); // if the element name matches the read array, then set the table as a name prefix $q_select[] = $el_name; // this is for reading the data // prefix the name for any further data parts @@ -1566,7 +1544,7 @@ class form extends db_array_io if ($data_array['type'] == 'drop_down_db') { $md_q = md5($data_array['query']); while ($res = $this->db_return($data_array['query'])) { -//$this->debug('edit', "Q[$md_q] pos: ".$this->cursor_ext[$md_q]["pos"]." | want: ".$data_array["preset"]." | set: ".$data['preset'][$el_name]); + $this->debug('edit', "Q[$md_q] pos: ".$this->cursor_ext[$md_q]["pos"]." | want: ".$data_array["preset"]." | set: ".$data['preset'][$el_name]); // first is default for this element if (!$data['preset'][$el_name] && ($this->cursor_ext[$md_q]["pos"] == $data_array['preset'])) { $data['preset'][$el_name] = $res[0]; @@ -1580,11 +1558,11 @@ class form extends db_array_io } $proto[$el_name] = ($this->error) ? $_POST[$el_name][(count($_POST[$el_name]) - 1)] : ''; // this is for the new line } -// $this->debug('CFG DATA', 'Data: '.$this->print_ar($data)); -// $this->debug('CFG PROTO', 'Proto: '.$this->print_ar($proto)); -// $this->debug('CFG SELECT', 'Proto: '.$this->print_ar($q_select)); + // $this->debug('CFG DATA', 'Data: '.$this->print_ar($data)); + // $this->debug('CFG PROTO', 'Proto: '.$this->print_ar($proto)); + // $this->debug('CFG SELECT', 'Proto: '.$this->print_ar($q_select)); // query for reading in the data -//$this->debug('edit_error', "ERR: ".$this->error); + $this->debug('edit_error', "ERR: ".$this->error); // if we got a read data, build the read select for the read, and read out the "selected" data if ($this->element_list[$table_name]["read_data"]) { // we need a second one for the query build only @@ -1604,18 +1582,18 @@ class form extends db_array_io $data['type'][$data["prefix"].$this->element_list[$table_name]["read_data"]["name"]] = 'string'; // build the read query $q = "SELECT "; -// if (!$this->table_array[$this->int_pk_name]["value"]) -// $q .= "DISTINCT "; + // if (!$this->table_array[$this->int_pk_name]["value"]) + // $q .= "DISTINCT "; // prefix join key with table name, and implode the query select part $q .= str_replace($table_name.'.'.$this->element_list[$table_name]["read_data"]["pk_id"], $this->element_list[$table_name]["read_data"]["table_name"].'.'.$this->element_list[$table_name]["read_data"]["pk_id"], implode(', ', $_q_select)).' '; -// if (!$this->table_array[$this->int_pk_name]["value"] && $this->element_list[$table_name]["read_data"]["order"]) -// $q .= ", ".$this->element_list[$table_name]["read_data"]["order"]." "; + // if (!$this->table_array[$this->int_pk_name]["value"] && $this->element_list[$table_name]["read_data"]["order"]) + // $q .= ", ".$this->element_list[$table_name]["read_data"]["order"]." "; // read from the read table as main, and left join to the sub table to read the actual data $q .= "FROM ".$this->element_list[$table_name]["read_data"]["table_name"]." "; $q .= "LEFT JOIN ".$table_name." "; $q .= "ON ("; $q .= $this->element_list[$table_name]["read_data"]["table_name"].".".$this->element_list[$table_name]["read_data"]["pk_id"]." = ".$table_name.".".$this->element_list[$table_name]["read_data"]["pk_id"]." "; -// if ($this->table_array[$this->int_pk_name]["value"]) + // if ($this->table_array[$this->int_pk_name]["value"]) $q .= "AND ".$table_name.".".$this->int_pk_name." = ".(($this->table_array[$this->int_pk_name]["value"]) ? $this->table_array[$this->int_pk_name]["value"] : 'NULL')." "; $q .= ") "; if ($this->element_list[$table_name]["read_data"]["order"]) { @@ -1628,7 +1606,7 @@ class form extends db_array_io $q = "SELECT ".implode(", ", $q_select)." FROM ".$table_name." WHERE ".$this->int_pk_name." = ".$this->table_array[$this->int_pk_name]["value"]; } } -// $this->debug('CFG QUERY', 'Q: '.$q); + // $this->debug('CFG QUERY', 'Q: '.$q); // only run if we have query strnig if ($q) { $pos = 0; // position in while for overwrite if needed @@ -1640,7 +1618,7 @@ class form extends db_array_io for ($i = 0; $i < count($q_select); $i ++) { // query select part, set to the element name $el_name = $q_select[$i]; -//$this->debug('edit_error', "[$i] ELNAME: $el_name | POS[$prfx$el_name]: ".$_POST[$prfx.$el_name][$pos]." | RES: ".$res[$el_name]); + // $this->debug('edit_error', "[$i] ELNAME: $el_name | POS[$prfx$el_name]: ".$_POST[$prfx.$el_name][$pos]." | RES: ".$res[$el_name]); // if we have an error, we take what we have in the vars, if not we take the data from the db if ($this->error) { // if we have a radio group, set a bit different @@ -1700,8 +1678,10 @@ class form extends db_array_io if ($data['delete_name']) { $data['content'][] = $proto; } -//$this->debug('edit', "A:
".print_r($data, 1)."
"); + // $this->debug('edit', "A:
".print_r($data, 1)."
"); $type = 'element_list'; return array('output_name' => $output_name, 'type' => $type, 'color' => 'edit_fgcolor', 'data' => $data); } } // end of class + +# __END__ diff --git a/www/libs/Class.Progressbar.inc b/www/lib/CoreLibs/Output/Progressbar.inc similarity index 92% rename from www/libs/Class.Progressbar.inc rename to www/lib/CoreLibs/Output/Progressbar.inc index 73e5067d..6fa9e139 100644 --- a/www/libs/Class.Progressbar.inc +++ b/www/lib/CoreLibs/Output/Progressbar.inc @@ -8,9 +8,13 @@ * Update: Clemens Schwaighofer * Date: 2012.9.5 [stacked output] * Date: 2013.2.21 [proper class formatting] +* Date: 2017.4.13 [no output fix with cache overload] +* Date: 2018.3.28 [PHPCS + namespace] * */ +namespace CoreLibs\Output; + class ProgressBar { // private vars @@ -80,13 +84,13 @@ class ProgressBar $this->height = $height; } // needs to be called twice or I do not get any output - $this->_flushCache($this->clear_buffer_size_init); - $this->_flushCache($this->clear_buffer_size_init); + $this->__flushCache($this->clear_buffer_size_init); + $this->__flushCache($this->clear_buffer_size_init); } // private functions - private function _flushCache($clear_buffer_size = 0) + private function __flushCache($clear_buffer_size = 0) { if (!$clear_buffer_size) { $clear_buffer_size = $this->clear_buffer_size; @@ -96,7 +100,7 @@ class ProgressBar flush(); } - private function _calculatePercent($step) + private function __calculatePercent($step) { // avoid divison through 0 if ($this->max - $this->min == 0) { @@ -109,7 +113,7 @@ class ProgressBar return $percent; } - private function _calculatePosition($step) + private function __calculatePosition($step) { switch ($this->direction) { case 'right': @@ -162,7 +166,7 @@ class ProgressBar return $position; } - private function _setStep($step) + private function __setStep($step) { if ($step > $this->max) { $step = $this->max; @@ -300,7 +304,7 @@ class ProgressBar public function setLabelPosition($name, $left, $top, $width, $height, $align = '') { -// print "SET POSITION[$name]: $left
"; + // print "SET POSITION[$name]: $left
"; // if this is percent, we ignore anything, it is auto positioned if ($this->label[$name]['type'] != 'percent') { foreach (array('top', 'left', 'width', 'height') as $pos_name) { @@ -323,7 +327,7 @@ class ProgressBar $output .= 'document.getElementById("plbl'.$name.$this->code.'").style.align="'.$this->label[$name]['align'].'";'; $output .= ''."\n"; echo $output; - $this->_flushCache(); + $this->__flushCache(); } } @@ -332,7 +336,7 @@ class ProgressBar $this->label[$name]['color'] = $color; if ($this->status != 'new') { echo ''."\n"; - $this->_flushCache(); + $this->__flushCache(); } } @@ -341,7 +345,7 @@ class ProgressBar $this->label[$name]['bgr_color'] = $color; if ($this->status != 'new') { echo ''."\n"; - $this->_flushCache(); + $this->__flushCache(); } } @@ -359,7 +363,7 @@ class ProgressBar if ($this->label[$name]['type'] == 'percent') { $this->label[$name]['top'] = round(($this->height - intval($size)) / log($this->height - intval($size), 7), 0) - $this->pedding; } -// print "HEIGHT: ".$this->height.", Size: ".intval($size).", Pedding: ".$this->pedding.", Calc: ".round($this->height - intval($size)).", Log: ".log($this->height - intval($size), 7)."
"; + // print "HEIGHT: ".$this->height.", Size: ".intval($size).", Pedding: ".$this->pedding.", Calc: ".round($this->height - intval($size)).", Log: ".log($this->height - intval($size), 7)."
"; // then set like usual $this->label[$name]['font-size'] = intval($size); if ($family != '') { @@ -376,17 +380,17 @@ class ProgressBar $output .= 'document.getElementById("plbl'.$name.$this->code.'").style.font-weight="'.$this->label[$name]['font-weight'].'";'; $output .= ''."\n"; echo $output; - $this->_flushCache(); + $this->__flushCache(); } } public function setLabelValue($name, $value) { $this->label[$name]['value'] = $value; -// print "NAME[$name], Status: ".$this->status.": ".$value."
"; + // print "NAME[$name], Status: ".$this->status.": ".$value."
"; if ($this->status != 'new') { echo ''."\n"; - $this->_flushCache(); + $this->__flushCache(); } } @@ -395,7 +399,7 @@ class ProgressBar $this->color = $color; if ($this->status != 'new') { echo ''."\n"; - $this->_flushCache(); + $this->__flushCache(); } } @@ -404,7 +408,7 @@ class ProgressBar $this->bgr_color = $color; if ($this->status != 'new') { echo ''."\n"; - $this->_flushCache(); + $this->__flushCache(); } } @@ -413,7 +417,7 @@ class ProgressBar $this->direction = $direction; if ($this->status != 'new') { - $this->position = $this->_calculatePosition($this->step); + $this->position = $this->__calculatePosition($this->step); echo ''."\n"; - $this->_flushCache(); + $this->__flushCache(); } } @@ -431,8 +435,8 @@ class ProgressBar $js = ''; $html_button = ''; - $this->_setStep($this->step); - $this->position = $this->_calculatePosition($this->step); + $this->__setStep($this->step); + $this->position = $this->__calculatePosition($this->step); if ($this->top || $this->left) { $style_master = 'position:relative;top:'.$this->top.'px;left:'.$this->left.'px;width:'.($this->width + 10).'px;'; @@ -477,7 +481,7 @@ class ProgressBar $js .= ' }'."\n"; $js .= '}'."\n"; -//print "DUMP LABEL:
".print_r($this->label, 1)."

"; + // print "DUMP LABEL:
".print_r($this->label, 1)."

"; foreach ($this->label as $name => $data) { // set what type of move we do $move_prefix = $data['type'] == 'button' ? 'margin' : 'padding'; @@ -522,13 +526,13 @@ class ProgressBar break; case 'percent': // only one inner percent -// print "STYLE[$name]: ".$style_lbl."
"; + // print "STYLE[$name]: ".$style_lbl."
"; if (!$html_percent) { - $html_percent = '
'.$this->_calculatePercent($this->step).'%
'."\n"; + $html_percent = '
'.$this->__calculatePercent($this->step).'%
'."\n"; } break; case 'percentlbl': - $html .= '
'.$this->_calculatePercent($this->step).'%
'."\n"; + $html .= '
'.$this->__calculatePercent($this->step).'%
'."\n"; break; case 'crossbar': $html .= '
'.$data['value'].'
'."\n"; @@ -578,16 +582,16 @@ class ProgressBar { $this->status = 'show'; echo $this->getHtml(); - $this->_flushCache(); + $this->__flushCache(); } public function moveStep($step) { $last_step = $this->step; - $this->_setStep($step); + $this->__setStep($step); $js = ''; - $new_position = $this->_calculatePosition($this->step); + $new_position = $this->__calculatePosition($this->step); if ($new_position['width'] != $this->position['width'] && ($this->direction == 'right' || $this->direction == 'left')) { if ($this->direction=='left') { $js .= 'PBposition'.$this->code.'("left",'.$new_position['left'].');'; @@ -603,7 +607,7 @@ class ProgressBar $this->position = $new_position; foreach ($this->label as $name => $data) { if (array_key_exists('type', $data)) { - switch($data['type']) { + switch ($data['type']) { case 'step': if ($this->step != $last_step) { $js .= 'PBlabelText'.$this->code.'("'.$name.'","'.$this->step.'/'.$this->max.'");'; @@ -611,8 +615,8 @@ class ProgressBar break; case 'percentlbl': case 'percent': - $percent = $this->_calculatePercent($this->step); - if ($percent != $this->_calculatePercent($last_step)) { + $percent = $this->__calculatePercent($this->step); + if ($percent != $this->__calculatePercent($last_step)) { $js .= 'PBlabelText'.$this->code.'("'.$name.'","'.$percent.'%");'; } break; @@ -624,7 +628,7 @@ class ProgressBar } if ($js != '') { echo ''."\n"; - $this->_flushCache(); + $this->__flushCache(); } } @@ -647,7 +651,7 @@ class ProgressBar $output .= 'document.getElementById("pbm'.$this->code.'").style.visibility="hidden";document.getElementById("pbm'.$this->code.'").style.display="none";'; $output .= ''."\n"; echo $output; - $this->_flushCache(); + $this->__flushCache(); } } @@ -660,7 +664,10 @@ class ProgressBar $output .= 'document.getElementById("pbm'.$this->code.'").style.visibility="visible";document.getElementById("pbm'.$this->code.'").style.visibility="block";'; $output .= ''."\n"; echo $output; - $this->_flushCache(); + $this->__flushCache(); } } } + +# __END__ + diff --git a/www/libs/Class.Smarty.Extend.inc b/www/lib/CoreLibs/Template/SmartyExtend.inc similarity index 65% rename from www/libs/Class.Smarty.Extend.inc rename to www/lib/CoreLibs/Template/SmartyExtend.inc index 67b72b3c..e7382e3f 100644 --- a/www/libs/Class.Smarty.Extend.inc +++ b/www/lib/CoreLibs/Template/SmartyExtend.inc @@ -1,4 +1,4 @@ -l10n = new l10n($lang); + $this->l10n = new \CoreLibs\Language\L10n($lang); // variable variable register $this->register_modifier('getvar', array(&$this, 'get_template_vars')); } } + +# __END__ diff --git a/www/lib/CoreLibs/Upload/Core/qqUploadedFileForm.inc b/www/lib/CoreLibs/Upload/Core/qqUploadedFileForm.inc new file mode 100755 index 00000000..2c58a26e --- /dev/null +++ b/www/lib/CoreLibs/Upload/Core/qqUploadedFileForm.inc @@ -0,0 +1,31 @@ +getSize()) { + return false; + } + + $target = fopen($path, "w"); + fseek($temp, 0, SEEK_SET); + stream_copy_to_stream($temp, $target); + fclose($target); + + return true; + } + public function getName() + { + return $_GET['qqfile']; + } + public function getSize() + { + if (isset($_SERVER["CONTENT_LENGTH"])) { + return (int)$_SERVER["CONTENT_LENGTH"]; + } else { + throw new Exception('Getting content length is not supported.'); + } + } +} + +# __END__ diff --git a/www/libs/FileUploader.inc b/www/lib/CoreLibs/Upload/qqFileUploader.inc old mode 100644 new mode 100755 similarity index 68% rename from www/libs/FileUploader.inc rename to www/lib/CoreLibs/Upload/qqFileUploader.inc index b45e464d..d926119e --- a/www/libs/FileUploader.inc +++ b/www/lib/CoreLibs/Upload/qqFileUploader.inc @@ -1,71 +1,9 @@ getSize()) { - return false; - } - - $target = fopen($path, "w"); - fseek($temp, 0, SEEK_SET); - stream_copy_to_stream($temp, $target); - fclose($target); - - return true; - } - public function getName() - { - return $_GET['qqfile']; - } - public function getSize() - { - if (isset($_SERVER["CONTENT_LENGTH"])) { - return (int)$_SERVER["CONTENT_LENGTH"]; - } else { - throw new Exception('Getting content length is not supported.'); - } - } -} - -/** - * Handle file uploads via regular form post (uses the $_FILES array) - */ -class qqUploadedFileForm -{ - /** - * Save the file to the specified path - * @return boolean TRUE on success - */ - public function save($path) - { - if (!move_uploaded_file($_FILES['qqfile']['tmp_name'], $path)) { - return false; - } - return true; - } - public function getName() - { - return $_FILES['qqfile']['name']; - } - public function getSize() - { - return $_FILES['qqfile']['size']; - } -} +use \CoreLibs\Upload\Core\qqUploadedFileForm; +use \CoreLibs\Upload\Core\qqUploadedFileXhr; class qqFileUploader { @@ -170,3 +108,5 @@ class qqFileUploader } } } + +# __END__ diff --git a/www/libs/Error.Handling.inc b/www/lib/Error.Handling.inc similarity index 99% rename from www/libs/Error.Handling.inc rename to www/lib/Error.Handling.inc index 2567f673..166e14ee 100644 --- a/www/libs/Error.Handling.inc +++ b/www/lib/Error.Handling.inc @@ -1,4 +1,4 @@ -"; + // set directory seperator (we need to replace from namespace) + $ds = DS ?? DIRECTORY_SEPARATOR; + // base lib + $LIB = LIB ?? 'lib'; + // if lib is in path, do not add lib again + if (strpos(__DIR__, $LIB) !== false) { + $LIB .= DS; + } else { + $LIB = ''; + } + // default path is unset + $path = false; + // set path on full dir + // if we have the namespace in the class, strip it out + $len = 0; + if (strpos($class, __NAMESPACE__) !== false) { + $len = strlen(__NAMESPACE__); + } + // set default extension + $extension = '.inc'; + // set full include path + $path = __DIR__.$ds.$LIB.substr($class, $len); + // replace namespace \ with dir sepeator + $path = str_replace('\\', $ds, $path).$extension; + // print "(2) Class clean: $path
"; + // if path is set and a valid file + if ($path !== false && is_file($path)) { + // echo "(3) Load Path: $path
"; + // we should sub that + // self::loadFile($path); + include $path; + return true; + } + return false; + } + } // end class define + + spl_autoload_register('Autoloader\Autoload::load', true, true); +} // end check for already defined + +# __END__ diff --git a/www/libs/pChart b/www/lib/pChart similarity index 100% rename from www/libs/pChart rename to www/lib/pChart diff --git a/www/libs/pChart2.1.4/class/pBarcode128.class.php b/www/lib/pChart2.1.4/class/pBarcode128.class.php similarity index 100% rename from www/libs/pChart2.1.4/class/pBarcode128.class.php rename to www/lib/pChart2.1.4/class/pBarcode128.class.php diff --git a/www/libs/pChart2.1.4/class/pBarcode39.class.php b/www/lib/pChart2.1.4/class/pBarcode39.class.php similarity index 100% rename from www/libs/pChart2.1.4/class/pBarcode39.class.php rename to www/lib/pChart2.1.4/class/pBarcode39.class.php diff --git a/www/libs/pChart2.1.4/class/pBubble.class.php b/www/lib/pChart2.1.4/class/pBubble.class.php similarity index 100% rename from www/libs/pChart2.1.4/class/pBubble.class.php rename to www/lib/pChart2.1.4/class/pBubble.class.php diff --git a/www/libs/pChart2.1.4/class/pCache.class.php b/www/lib/pChart2.1.4/class/pCache.class.php similarity index 100% rename from www/libs/pChart2.1.4/class/pCache.class.php rename to www/lib/pChart2.1.4/class/pCache.class.php diff --git a/www/libs/pChart2.1.4/class/pData.class.php b/www/lib/pChart2.1.4/class/pData.class.php similarity index 100% rename from www/libs/pChart2.1.4/class/pData.class.php rename to www/lib/pChart2.1.4/class/pData.class.php diff --git a/www/libs/pChart2.1.4/class/pDraw.class.php b/www/lib/pChart2.1.4/class/pDraw.class.php similarity index 100% rename from www/libs/pChart2.1.4/class/pDraw.class.php rename to www/lib/pChart2.1.4/class/pDraw.class.php diff --git a/www/libs/pChart2.1.4/class/pImage.class.php b/www/lib/pChart2.1.4/class/pImage.class.php similarity index 100% rename from www/libs/pChart2.1.4/class/pImage.class.php rename to www/lib/pChart2.1.4/class/pImage.class.php diff --git a/www/libs/pChart2.1.4/class/pIndicator.class.php b/www/lib/pChart2.1.4/class/pIndicator.class.php similarity index 100% rename from www/libs/pChart2.1.4/class/pIndicator.class.php rename to www/lib/pChart2.1.4/class/pIndicator.class.php diff --git a/www/libs/pChart2.1.4/class/pPie.class.php b/www/lib/pChart2.1.4/class/pPie.class.php similarity index 100% rename from www/libs/pChart2.1.4/class/pPie.class.php rename to www/lib/pChart2.1.4/class/pPie.class.php diff --git a/www/libs/pChart2.1.4/class/pRadar.class.php b/www/lib/pChart2.1.4/class/pRadar.class.php similarity index 100% rename from www/libs/pChart2.1.4/class/pRadar.class.php rename to www/lib/pChart2.1.4/class/pRadar.class.php diff --git a/www/libs/pChart2.1.4/class/pScatter.class.php b/www/lib/pChart2.1.4/class/pScatter.class.php similarity index 100% rename from www/libs/pChart2.1.4/class/pScatter.class.php rename to www/lib/pChart2.1.4/class/pScatter.class.php diff --git a/www/libs/pChart2.1.4/class/pSplit.class.php b/www/lib/pChart2.1.4/class/pSplit.class.php similarity index 100% rename from www/libs/pChart2.1.4/class/pSplit.class.php rename to www/lib/pChart2.1.4/class/pSplit.class.php diff --git a/www/libs/pChart2.1.4/class/pSpring.class.php b/www/lib/pChart2.1.4/class/pSpring.class.php similarity index 100% rename from www/libs/pChart2.1.4/class/pSpring.class.php rename to www/lib/pChart2.1.4/class/pSpring.class.php diff --git a/www/libs/pChart2.1.4/class/pStock.class.php b/www/lib/pChart2.1.4/class/pStock.class.php similarity index 100% rename from www/libs/pChart2.1.4/class/pStock.class.php rename to www/lib/pChart2.1.4/class/pStock.class.php diff --git a/www/libs/pChart2.1.4/class/pSurface.class.php b/www/lib/pChart2.1.4/class/pSurface.class.php similarity index 100% rename from www/libs/pChart2.1.4/class/pSurface.class.php rename to www/lib/pChart2.1.4/class/pSurface.class.php diff --git a/www/libs/pChart2.1.4/data/128B.db b/www/lib/pChart2.1.4/data/128B.db similarity index 100% rename from www/libs/pChart2.1.4/data/128B.db rename to www/lib/pChart2.1.4/data/128B.db diff --git a/www/libs/pChart2.1.4/data/39.db b/www/lib/pChart2.1.4/data/39.db similarity index 100% rename from www/libs/pChart2.1.4/data/39.db rename to www/lib/pChart2.1.4/data/39.db diff --git a/www/libs/pChart2.1.4/fonts/Bedizen.ttf b/www/lib/pChart2.1.4/fonts/Bedizen.ttf similarity index 100% rename from www/libs/pChart2.1.4/fonts/Bedizen.ttf rename to www/lib/pChart2.1.4/fonts/Bedizen.ttf diff --git a/www/libs/pChart2.1.4/fonts/Forgotte.ttf b/www/lib/pChart2.1.4/fonts/Forgotte.ttf similarity index 100% rename from www/libs/pChart2.1.4/fonts/Forgotte.ttf rename to www/lib/pChart2.1.4/fonts/Forgotte.ttf diff --git a/www/libs/pChart2.1.4/fonts/GeosansLight.ttf b/www/lib/pChart2.1.4/fonts/GeosansLight.ttf similarity index 100% rename from www/libs/pChart2.1.4/fonts/GeosansLight.ttf rename to www/lib/pChart2.1.4/fonts/GeosansLight.ttf diff --git a/www/libs/pChart2.1.4/fonts/MankSans.ttf b/www/lib/pChart2.1.4/fonts/MankSans.ttf similarity index 100% rename from www/libs/pChart2.1.4/fonts/MankSans.ttf rename to www/lib/pChart2.1.4/fonts/MankSans.ttf diff --git a/www/libs/pChart2.1.4/fonts/Silkscreen.ttf b/www/lib/pChart2.1.4/fonts/Silkscreen.ttf similarity index 100% rename from www/libs/pChart2.1.4/fonts/Silkscreen.ttf rename to www/lib/pChart2.1.4/fonts/Silkscreen.ttf diff --git a/www/libs/pChart2.1.4/fonts/advent_light.ttf b/www/lib/pChart2.1.4/fonts/advent_light.ttf similarity index 100% rename from www/libs/pChart2.1.4/fonts/advent_light.ttf rename to www/lib/pChart2.1.4/fonts/advent_light.ttf diff --git a/www/libs/pChart2.1.4/fonts/calibri.ttf b/www/lib/pChart2.1.4/fonts/calibri.ttf similarity index 100% rename from www/libs/pChart2.1.4/fonts/calibri.ttf rename to www/lib/pChart2.1.4/fonts/calibri.ttf diff --git a/www/libs/pChart2.1.4/fonts/pf_arma_five.ttf b/www/lib/pChart2.1.4/fonts/pf_arma_five.ttf similarity index 100% rename from www/libs/pChart2.1.4/fonts/pf_arma_five.ttf rename to www/lib/pChart2.1.4/fonts/pf_arma_five.ttf diff --git a/www/libs/pChart2.1.4/fonts/verdana.ttf b/www/lib/pChart2.1.4/fonts/verdana.ttf similarity index 100% rename from www/libs/pChart2.1.4/fonts/verdana.ttf rename to www/lib/pChart2.1.4/fonts/verdana.ttf diff --git a/www/libs/pChart2.1.4/palettes/autumn.color b/www/lib/pChart2.1.4/palettes/autumn.color similarity index 100% rename from www/libs/pChart2.1.4/palettes/autumn.color rename to www/lib/pChart2.1.4/palettes/autumn.color diff --git a/www/libs/pChart2.1.4/palettes/blind.color b/www/lib/pChart2.1.4/palettes/blind.color similarity index 100% rename from www/libs/pChart2.1.4/palettes/blind.color rename to www/lib/pChart2.1.4/palettes/blind.color diff --git a/www/libs/pChart2.1.4/palettes/evening.color b/www/lib/pChart2.1.4/palettes/evening.color similarity index 100% rename from www/libs/pChart2.1.4/palettes/evening.color rename to www/lib/pChart2.1.4/palettes/evening.color diff --git a/www/libs/pChart2.1.4/palettes/kitchen.color b/www/lib/pChart2.1.4/palettes/kitchen.color similarity index 100% rename from www/libs/pChart2.1.4/palettes/kitchen.color rename to www/lib/pChart2.1.4/palettes/kitchen.color diff --git a/www/libs/pChart2.1.4/palettes/light.color b/www/lib/pChart2.1.4/palettes/light.color similarity index 100% rename from www/libs/pChart2.1.4/palettes/light.color rename to www/lib/pChart2.1.4/palettes/light.color diff --git a/www/libs/pChart2.1.4/palettes/navy.color b/www/lib/pChart2.1.4/palettes/navy.color similarity index 100% rename from www/libs/pChart2.1.4/palettes/navy.color rename to www/lib/pChart2.1.4/palettes/navy.color diff --git a/www/libs/pChart2.1.4/palettes/shade.color b/www/lib/pChart2.1.4/palettes/shade.color similarity index 100% rename from www/libs/pChart2.1.4/palettes/shade.color rename to www/lib/pChart2.1.4/palettes/shade.color diff --git a/www/libs/pChart2.1.4/palettes/spring.color b/www/lib/pChart2.1.4/palettes/spring.color similarity index 100% rename from www/libs/pChart2.1.4/palettes/spring.color rename to www/lib/pChart2.1.4/palettes/spring.color diff --git a/www/libs/pChart2.1.4/palettes/summer.color b/www/lib/pChart2.1.4/palettes/summer.color similarity index 100% rename from www/libs/pChart2.1.4/palettes/summer.color rename to www/lib/pChart2.1.4/palettes/summer.color diff --git a/www/smarty-3.1.27/.gitattributes b/www/lib/smarty-3.1.30/.gitattributes similarity index 100% rename from www/smarty-3.1.27/.gitattributes rename to www/lib/smarty-3.1.30/.gitattributes diff --git a/www/smarty-3.1.27/.gitignore b/www/lib/smarty-3.1.30/.gitignore similarity index 100% rename from www/smarty-3.1.27/.gitignore rename to www/lib/smarty-3.1.30/.gitignore diff --git a/www/smarty-3.1.27/.travis.yml b/www/lib/smarty-3.1.30/.travis.yml similarity index 100% rename from www/smarty-3.1.27/.travis.yml rename to www/lib/smarty-3.1.30/.travis.yml diff --git a/www/smarty-3.1.30/Autoloader.php b/www/lib/smarty-3.1.30/Autoloader.php similarity index 100% rename from www/smarty-3.1.30/Autoloader.php rename to www/lib/smarty-3.1.30/Autoloader.php diff --git a/www/smarty-3.1.30/Smarty.class.php b/www/lib/smarty-3.1.30/Smarty.class.php similarity index 100% rename from www/smarty-3.1.30/Smarty.class.php rename to www/lib/smarty-3.1.30/Smarty.class.php diff --git a/www/smarty-3.1.30/SmartyBC.class.php b/www/lib/smarty-3.1.30/SmartyBC.class.php similarity index 100% rename from www/smarty-3.1.30/SmartyBC.class.php rename to www/lib/smarty-3.1.30/SmartyBC.class.php diff --git a/www/smarty-3.1.30/debug.tpl b/www/lib/smarty-3.1.30/debug.tpl similarity index 100% rename from www/smarty-3.1.30/debug.tpl rename to www/lib/smarty-3.1.30/debug.tpl diff --git a/www/smarty-3.1.27/plugins/block.t.php b/www/lib/smarty-3.1.30/plugins/block.t.php similarity index 100% rename from www/smarty-3.1.27/plugins/block.t.php rename to www/lib/smarty-3.1.30/plugins/block.t.php diff --git a/www/smarty-3.1.30/plugins/block.textformat.php b/www/lib/smarty-3.1.30/plugins/block.textformat.php similarity index 100% rename from www/smarty-3.1.30/plugins/block.textformat.php rename to www/lib/smarty-3.1.30/plugins/block.textformat.php diff --git a/www/smarty-3.1.30/plugins/function.counter.php b/www/lib/smarty-3.1.30/plugins/function.counter.php similarity index 100% rename from www/smarty-3.1.30/plugins/function.counter.php rename to www/lib/smarty-3.1.30/plugins/function.counter.php diff --git a/www/smarty-3.1.30/plugins/function.cycle.php b/www/lib/smarty-3.1.30/plugins/function.cycle.php similarity index 100% rename from www/smarty-3.1.30/plugins/function.cycle.php rename to www/lib/smarty-3.1.30/plugins/function.cycle.php diff --git a/www/smarty-3.1.30/plugins/function.fetch.php b/www/lib/smarty-3.1.30/plugins/function.fetch.php similarity index 100% rename from www/smarty-3.1.30/plugins/function.fetch.php rename to www/lib/smarty-3.1.30/plugins/function.fetch.php diff --git a/www/smarty-3.1.27/plugins/function.html_checkboxes.php b/www/lib/smarty-3.1.30/plugins/function.html_checkboxes.php similarity index 100% rename from www/smarty-3.1.27/plugins/function.html_checkboxes.php rename to www/lib/smarty-3.1.30/plugins/function.html_checkboxes.php diff --git a/www/smarty-3.1.30/plugins/function.html_image.php b/www/lib/smarty-3.1.30/plugins/function.html_image.php similarity index 100% rename from www/smarty-3.1.30/plugins/function.html_image.php rename to www/lib/smarty-3.1.30/plugins/function.html_image.php diff --git a/www/smarty-3.1.27/plugins/function.html_options.php b/www/lib/smarty-3.1.30/plugins/function.html_options.php similarity index 100% rename from www/smarty-3.1.27/plugins/function.html_options.php rename to www/lib/smarty-3.1.30/plugins/function.html_options.php diff --git a/www/smarty-3.1.30/plugins/function.html_radios.php b/www/lib/smarty-3.1.30/plugins/function.html_radios.php similarity index 100% rename from www/smarty-3.1.30/plugins/function.html_radios.php rename to www/lib/smarty-3.1.30/plugins/function.html_radios.php diff --git a/www/smarty-3.1.30/plugins/function.html_select_date.php b/www/lib/smarty-3.1.30/plugins/function.html_select_date.php similarity index 100% rename from www/smarty-3.1.30/plugins/function.html_select_date.php rename to www/lib/smarty-3.1.30/plugins/function.html_select_date.php diff --git a/www/smarty-3.1.30/plugins/function.html_select_time.php b/www/lib/smarty-3.1.30/plugins/function.html_select_time.php similarity index 100% rename from www/smarty-3.1.30/plugins/function.html_select_time.php rename to www/lib/smarty-3.1.30/plugins/function.html_select_time.php diff --git a/www/smarty-3.1.30/plugins/function.html_table.php b/www/lib/smarty-3.1.30/plugins/function.html_table.php similarity index 100% rename from www/smarty-3.1.30/plugins/function.html_table.php rename to www/lib/smarty-3.1.30/plugins/function.html_table.php diff --git a/www/smarty-3.1.30/plugins/function.mailto.php b/www/lib/smarty-3.1.30/plugins/function.mailto.php similarity index 100% rename from www/smarty-3.1.30/plugins/function.mailto.php rename to www/lib/smarty-3.1.30/plugins/function.mailto.php diff --git a/www/smarty-3.1.30/plugins/function.math.php b/www/lib/smarty-3.1.30/plugins/function.math.php similarity index 100% rename from www/smarty-3.1.30/plugins/function.math.php rename to www/lib/smarty-3.1.30/plugins/function.math.php diff --git a/www/smarty-3.1.27/plugins/function.popup.php b/www/lib/smarty-3.1.30/plugins/function.popup.php similarity index 100% rename from www/smarty-3.1.27/plugins/function.popup.php rename to www/lib/smarty-3.1.30/plugins/function.popup.php diff --git a/www/smarty-3.1.27/plugins/function.popup_init.php b/www/lib/smarty-3.1.30/plugins/function.popup_init.php similarity index 100% rename from www/smarty-3.1.27/plugins/function.popup_init.php rename to www/lib/smarty-3.1.30/plugins/function.popup_init.php diff --git a/www/smarty-3.1.30/plugins/modifier.capitalize.php b/www/lib/smarty-3.1.30/plugins/modifier.capitalize.php similarity index 100% rename from www/smarty-3.1.30/plugins/modifier.capitalize.php rename to www/lib/smarty-3.1.30/plugins/modifier.capitalize.php diff --git a/www/smarty-3.1.27/plugins/modifier.date_format.php b/www/lib/smarty-3.1.30/plugins/modifier.date_format.php similarity index 100% rename from www/smarty-3.1.27/plugins/modifier.date_format.php rename to www/lib/smarty-3.1.30/plugins/modifier.date_format.php diff --git a/www/smarty-3.1.30/plugins/modifier.debug_print_var.php b/www/lib/smarty-3.1.30/plugins/modifier.debug_print_var.php similarity index 100% rename from www/smarty-3.1.30/plugins/modifier.debug_print_var.php rename to www/lib/smarty-3.1.30/plugins/modifier.debug_print_var.php diff --git a/www/smarty-3.1.30/plugins/modifier.escape.php b/www/lib/smarty-3.1.30/plugins/modifier.escape.php similarity index 100% rename from www/smarty-3.1.30/plugins/modifier.escape.php rename to www/lib/smarty-3.1.30/plugins/modifier.escape.php diff --git a/www/smarty-3.1.30/plugins/modifier.regex_replace.php b/www/lib/smarty-3.1.30/plugins/modifier.regex_replace.php similarity index 100% rename from www/smarty-3.1.30/plugins/modifier.regex_replace.php rename to www/lib/smarty-3.1.30/plugins/modifier.regex_replace.php diff --git a/www/smarty-3.1.27/plugins/modifier.replace.php b/www/lib/smarty-3.1.30/plugins/modifier.replace.php similarity index 100% rename from www/smarty-3.1.27/plugins/modifier.replace.php rename to www/lib/smarty-3.1.30/plugins/modifier.replace.php diff --git a/www/smarty-3.1.27/plugins/modifier.spacify.php b/www/lib/smarty-3.1.30/plugins/modifier.spacify.php similarity index 100% rename from www/smarty-3.1.27/plugins/modifier.spacify.php rename to www/lib/smarty-3.1.30/plugins/modifier.spacify.php diff --git a/www/smarty-3.1.30/plugins/modifier.truncate.php b/www/lib/smarty-3.1.30/plugins/modifier.truncate.php similarity index 100% rename from www/smarty-3.1.30/plugins/modifier.truncate.php rename to www/lib/smarty-3.1.30/plugins/modifier.truncate.php diff --git a/www/smarty-3.1.27/plugins/modifiercompiler.cat.php b/www/lib/smarty-3.1.30/plugins/modifiercompiler.cat.php similarity index 100% rename from www/smarty-3.1.27/plugins/modifiercompiler.cat.php rename to www/lib/smarty-3.1.30/plugins/modifiercompiler.cat.php diff --git a/www/smarty-3.1.30/plugins/modifiercompiler.count_characters.php b/www/lib/smarty-3.1.30/plugins/modifiercompiler.count_characters.php similarity index 100% rename from www/smarty-3.1.30/plugins/modifiercompiler.count_characters.php rename to www/lib/smarty-3.1.30/plugins/modifiercompiler.count_characters.php diff --git a/www/smarty-3.1.30/plugins/modifiercompiler.count_paragraphs.php b/www/lib/smarty-3.1.30/plugins/modifiercompiler.count_paragraphs.php similarity index 100% rename from www/smarty-3.1.30/plugins/modifiercompiler.count_paragraphs.php rename to www/lib/smarty-3.1.30/plugins/modifiercompiler.count_paragraphs.php diff --git a/www/smarty-3.1.30/plugins/modifiercompiler.count_sentences.php b/www/lib/smarty-3.1.30/plugins/modifiercompiler.count_sentences.php similarity index 100% rename from www/smarty-3.1.30/plugins/modifiercompiler.count_sentences.php rename to www/lib/smarty-3.1.30/plugins/modifiercompiler.count_sentences.php diff --git a/www/smarty-3.1.30/plugins/modifiercompiler.count_words.php b/www/lib/smarty-3.1.30/plugins/modifiercompiler.count_words.php similarity index 100% rename from www/smarty-3.1.30/plugins/modifiercompiler.count_words.php rename to www/lib/smarty-3.1.30/plugins/modifiercompiler.count_words.php diff --git a/www/smarty-3.1.30/plugins/modifiercompiler.default.php b/www/lib/smarty-3.1.30/plugins/modifiercompiler.default.php similarity index 100% rename from www/smarty-3.1.30/plugins/modifiercompiler.default.php rename to www/lib/smarty-3.1.30/plugins/modifiercompiler.default.php diff --git a/www/smarty-3.1.30/plugins/modifiercompiler.escape.php b/www/lib/smarty-3.1.30/plugins/modifiercompiler.escape.php similarity index 100% rename from www/smarty-3.1.30/plugins/modifiercompiler.escape.php rename to www/lib/smarty-3.1.30/plugins/modifiercompiler.escape.php diff --git a/www/smarty-3.1.30/plugins/modifiercompiler.from_charset.php b/www/lib/smarty-3.1.30/plugins/modifiercompiler.from_charset.php similarity index 100% rename from www/smarty-3.1.30/plugins/modifiercompiler.from_charset.php rename to www/lib/smarty-3.1.30/plugins/modifiercompiler.from_charset.php diff --git a/www/smarty-3.1.30/plugins/modifiercompiler.indent.php b/www/lib/smarty-3.1.30/plugins/modifiercompiler.indent.php similarity index 100% rename from www/smarty-3.1.30/plugins/modifiercompiler.indent.php rename to www/lib/smarty-3.1.30/plugins/modifiercompiler.indent.php diff --git a/www/smarty-3.1.30/plugins/modifiercompiler.lower.php b/www/lib/smarty-3.1.30/plugins/modifiercompiler.lower.php similarity index 100% rename from www/smarty-3.1.30/plugins/modifiercompiler.lower.php rename to www/lib/smarty-3.1.30/plugins/modifiercompiler.lower.php diff --git a/www/smarty-3.1.27/plugins/modifiercompiler.noprint.php b/www/lib/smarty-3.1.30/plugins/modifiercompiler.noprint.php similarity index 100% rename from www/smarty-3.1.27/plugins/modifiercompiler.noprint.php rename to www/lib/smarty-3.1.30/plugins/modifiercompiler.noprint.php diff --git a/www/smarty-3.1.30/plugins/modifiercompiler.string_format.php b/www/lib/smarty-3.1.30/plugins/modifiercompiler.string_format.php similarity index 100% rename from www/smarty-3.1.30/plugins/modifiercompiler.string_format.php rename to www/lib/smarty-3.1.30/plugins/modifiercompiler.string_format.php diff --git a/www/smarty-3.1.30/plugins/modifiercompiler.strip.php b/www/lib/smarty-3.1.30/plugins/modifiercompiler.strip.php similarity index 100% rename from www/smarty-3.1.30/plugins/modifiercompiler.strip.php rename to www/lib/smarty-3.1.30/plugins/modifiercompiler.strip.php diff --git a/www/smarty-3.1.30/plugins/modifiercompiler.strip_tags.php b/www/lib/smarty-3.1.30/plugins/modifiercompiler.strip_tags.php similarity index 100% rename from www/smarty-3.1.30/plugins/modifiercompiler.strip_tags.php rename to www/lib/smarty-3.1.30/plugins/modifiercompiler.strip_tags.php diff --git a/www/smarty-3.1.30/plugins/modifiercompiler.to_charset.php b/www/lib/smarty-3.1.30/plugins/modifiercompiler.to_charset.php similarity index 100% rename from www/smarty-3.1.30/plugins/modifiercompiler.to_charset.php rename to www/lib/smarty-3.1.30/plugins/modifiercompiler.to_charset.php diff --git a/www/smarty-3.1.30/plugins/modifiercompiler.unescape.php b/www/lib/smarty-3.1.30/plugins/modifiercompiler.unescape.php similarity index 100% rename from www/smarty-3.1.30/plugins/modifiercompiler.unescape.php rename to www/lib/smarty-3.1.30/plugins/modifiercompiler.unescape.php diff --git a/www/smarty-3.1.30/plugins/modifiercompiler.upper.php b/www/lib/smarty-3.1.30/plugins/modifiercompiler.upper.php similarity index 100% rename from www/smarty-3.1.30/plugins/modifiercompiler.upper.php rename to www/lib/smarty-3.1.30/plugins/modifiercompiler.upper.php diff --git a/www/smarty-3.1.30/plugins/modifiercompiler.wordwrap.php b/www/lib/smarty-3.1.30/plugins/modifiercompiler.wordwrap.php similarity index 100% rename from www/smarty-3.1.30/plugins/modifiercompiler.wordwrap.php rename to www/lib/smarty-3.1.30/plugins/modifiercompiler.wordwrap.php diff --git a/www/smarty-3.1.30/plugins/outputfilter.trimwhitespace.php b/www/lib/smarty-3.1.30/plugins/outputfilter.trimwhitespace.php similarity index 100% rename from www/smarty-3.1.30/plugins/outputfilter.trimwhitespace.php rename to www/lib/smarty-3.1.30/plugins/outputfilter.trimwhitespace.php diff --git a/www/smarty-3.1.30/plugins/shared.escape_special_chars.php b/www/lib/smarty-3.1.30/plugins/shared.escape_special_chars.php similarity index 100% rename from www/smarty-3.1.30/plugins/shared.escape_special_chars.php rename to www/lib/smarty-3.1.30/plugins/shared.escape_special_chars.php diff --git a/www/smarty-3.1.30/plugins/shared.literal_compiler_param.php b/www/lib/smarty-3.1.30/plugins/shared.literal_compiler_param.php similarity index 100% rename from www/smarty-3.1.30/plugins/shared.literal_compiler_param.php rename to www/lib/smarty-3.1.30/plugins/shared.literal_compiler_param.php diff --git a/www/smarty-3.1.30/plugins/shared.make_timestamp.php b/www/lib/smarty-3.1.30/plugins/shared.make_timestamp.php similarity index 100% rename from www/smarty-3.1.30/plugins/shared.make_timestamp.php rename to www/lib/smarty-3.1.30/plugins/shared.make_timestamp.php diff --git a/www/smarty-3.1.30/plugins/shared.mb_str_replace.php b/www/lib/smarty-3.1.30/plugins/shared.mb_str_replace.php similarity index 100% rename from www/smarty-3.1.30/plugins/shared.mb_str_replace.php rename to www/lib/smarty-3.1.30/plugins/shared.mb_str_replace.php diff --git a/www/smarty-3.1.27/plugins/shared.mb_unicode.php b/www/lib/smarty-3.1.30/plugins/shared.mb_unicode.php similarity index 100% rename from www/smarty-3.1.27/plugins/shared.mb_unicode.php rename to www/lib/smarty-3.1.30/plugins/shared.mb_unicode.php diff --git a/www/smarty-3.1.30/plugins/shared.mb_wordwrap.php b/www/lib/smarty-3.1.30/plugins/shared.mb_wordwrap.php similarity index 100% rename from www/smarty-3.1.30/plugins/shared.mb_wordwrap.php rename to www/lib/smarty-3.1.30/plugins/shared.mb_wordwrap.php diff --git a/www/smarty-3.1.27/plugins/variablefilter.htmlspecialchars.php b/www/lib/smarty-3.1.30/plugins/variablefilter.htmlspecialchars.php similarity index 100% rename from www/smarty-3.1.27/plugins/variablefilter.htmlspecialchars.php rename to www/lib/smarty-3.1.30/plugins/variablefilter.htmlspecialchars.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_cacheresource.php b/www/lib/smarty-3.1.30/sysplugins/smarty_cacheresource.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_cacheresource.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_cacheresource.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_cacheresource_custom.php b/www/lib/smarty-3.1.30/sysplugins/smarty_cacheresource_custom.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_cacheresource_custom.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_cacheresource_custom.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_cacheresource_keyvaluestore.php b/www/lib/smarty-3.1.30/sysplugins/smarty_cacheresource_keyvaluestore.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_cacheresource_keyvaluestore.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_cacheresource_keyvaluestore.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_data.php b/www/lib/smarty-3.1.30/sysplugins/smarty_data.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_data.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_data.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_block.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_block.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_block.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_block.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_cacheresource_file.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_cacheresource_file.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_cacheresource_file.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_cacheresource_file.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_append.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_append.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_append.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_append.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_assign.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_assign.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_assign.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_assign.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_block.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_block.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_block.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_block.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_break.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_break.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_break.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_break.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_call.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_call.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_call.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_call.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_capture.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_capture.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_capture.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_capture.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_config_load.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_config_load.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_config_load.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_config_load.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_continue.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_continue.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_continue.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_continue.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_debug.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_debug.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_debug.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_debug.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_eval.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_eval.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_eval.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_eval.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_extends.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_extends.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_extends.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_extends.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_for.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_for.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_for.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_for.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_foreach.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_foreach.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_foreach.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_foreach.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_function.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_function.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_function.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_function.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_if.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_if.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_if.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_if.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_include.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_include.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_include.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_include.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_include_php.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_include_php.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_include_php.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_include_php.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_insert.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_insert.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_insert.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_insert.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_ldelim.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_ldelim.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_ldelim.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_ldelim.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_make_nocache.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_make_nocache.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_make_nocache.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_make_nocache.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_nocache.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_nocache.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_nocache.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_nocache.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_private_block_plugin.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_private_block_plugin.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_private_block_plugin.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_private_block_plugin.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_private_foreachsection.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_private_foreachsection.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_private_foreachsection.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_private_foreachsection.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_private_function_plugin.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_private_function_plugin.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_private_function_plugin.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_private_function_plugin.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_private_modifier.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_private_modifier.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_private_modifier.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_private_modifier.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_private_object_block_function.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_private_object_block_function.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_private_object_block_function.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_private_object_block_function.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_private_object_function.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_private_object_function.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_private_object_function.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_private_object_function.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_private_php.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_private_php.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_private_php.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_private_php.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_private_print_expression.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_private_print_expression.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_private_print_expression.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_private_print_expression.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_private_registered_block.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_private_registered_block.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_private_registered_block.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_private_registered_block.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_private_registered_function.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_private_registered_function.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_private_registered_function.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_private_registered_function.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_private_special_variable.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_private_special_variable.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_private_special_variable.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_private_special_variable.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_rdelim.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_rdelim.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_rdelim.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_rdelim.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_section.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_section.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_section.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_section.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_setfilter.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_setfilter.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_setfilter.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_setfilter.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_shared_inheritance.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_shared_inheritance.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_shared_inheritance.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_shared_inheritance.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compile_while.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_while.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compile_while.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compile_while.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_compilebase.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_compilebase.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_compilebase.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_compilebase.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_config_file_compiler.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_config_file_compiler.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_config_file_compiler.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_config_file_compiler.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_configfilelexer.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_configfilelexer.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_configfilelexer.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_configfilelexer.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_configfileparser.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_configfileparser.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_configfileparser.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_configfileparser.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_data.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_data.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_data.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_data.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_debug.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_debug.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_debug.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_debug.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_extension_clear.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_extension_clear.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_extension_clear.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_extension_clear.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_extension_handler.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_extension_handler.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_extension_handler.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_extension_handler.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_addautoloadfilters.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_addautoloadfilters.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_addautoloadfilters.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_addautoloadfilters.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_adddefaultmodifiers.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_adddefaultmodifiers.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_adddefaultmodifiers.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_adddefaultmodifiers.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_append.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_append.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_append.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_append.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_appendbyref.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_appendbyref.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_appendbyref.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_appendbyref.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_assignbyref.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_assignbyref.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_assignbyref.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_assignbyref.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_assignglobal.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_assignglobal.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_assignglobal.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_assignglobal.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_clearallassign.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_clearallassign.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_clearallassign.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_clearallassign.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_clearallcache.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_clearallcache.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_clearallcache.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_clearallcache.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_clearassign.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_clearassign.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_clearassign.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_clearassign.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_clearcache.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_clearcache.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_clearcache.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_clearcache.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_clearcompiledtemplate.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_clearcompiledtemplate.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_clearcompiledtemplate.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_clearcompiledtemplate.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_clearconfig.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_clearconfig.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_clearconfig.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_clearconfig.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_compileallconfig.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_compileallconfig.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_compileallconfig.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_compileallconfig.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_compilealltemplates.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_compilealltemplates.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_compilealltemplates.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_compilealltemplates.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_configload.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_configload.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_configload.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_configload.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_createdata.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_createdata.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_createdata.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_createdata.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_getautoloadfilters.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_getautoloadfilters.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_getautoloadfilters.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_getautoloadfilters.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_getconfigvars.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_getconfigvars.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_getconfigvars.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_getconfigvars.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_getdebugtemplate.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_getdebugtemplate.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_getdebugtemplate.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_getdebugtemplate.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_getdefaultmodifiers.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_getdefaultmodifiers.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_getdefaultmodifiers.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_getdefaultmodifiers.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_getglobal.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_getglobal.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_getglobal.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_getglobal.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_getregisteredobject.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_getregisteredobject.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_getregisteredobject.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_getregisteredobject.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_getstreamvariable.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_getstreamvariable.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_getstreamvariable.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_getstreamvariable.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_gettags.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_gettags.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_gettags.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_gettags.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_gettemplatevars.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_gettemplatevars.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_gettemplatevars.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_gettemplatevars.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_loadfilter.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_loadfilter.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_loadfilter.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_loadfilter.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_loadplugin.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_loadplugin.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_loadplugin.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_loadplugin.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_mustcompile.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_mustcompile.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_mustcompile.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_mustcompile.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_registercacheresource.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_registercacheresource.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_registercacheresource.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_registercacheresource.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_registerclass.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_registerclass.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_registerclass.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_registerclass.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_registerdefaultconfighandler.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_registerdefaultconfighandler.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_registerdefaultconfighandler.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_registerdefaultconfighandler.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_registerdefaultpluginhandler.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_registerdefaultpluginhandler.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_registerdefaultpluginhandler.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_registerdefaultpluginhandler.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_registerdefaulttemplatehandler.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_registerdefaulttemplatehandler.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_registerdefaulttemplatehandler.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_registerdefaulttemplatehandler.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_registerfilter.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_registerfilter.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_registerfilter.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_registerfilter.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_registerobject.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_registerobject.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_registerobject.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_registerobject.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_registerplugin.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_registerplugin.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_registerplugin.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_registerplugin.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_registerresource.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_registerresource.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_registerresource.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_registerresource.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_setautoloadfilters.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_setautoloadfilters.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_setautoloadfilters.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_setautoloadfilters.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_setdebugtemplate.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_setdebugtemplate.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_setdebugtemplate.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_setdebugtemplate.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_setdefaultmodifiers.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_setdefaultmodifiers.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_setdefaultmodifiers.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_setdefaultmodifiers.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_unloadfilter.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_unloadfilter.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_unloadfilter.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_unloadfilter.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_unregistercacheresource.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_unregistercacheresource.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_unregistercacheresource.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_unregistercacheresource.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_unregisterfilter.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_unregisterfilter.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_unregisterfilter.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_unregisterfilter.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_unregisterobject.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_unregisterobject.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_unregisterobject.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_unregisterobject.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_unregisterplugin.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_unregisterplugin.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_unregisterplugin.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_unregisterplugin.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_method_unregisterresource.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_unregisterresource.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_method_unregisterresource.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_method_unregisterresource.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_nocache_insert.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_nocache_insert.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_nocache_insert.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_nocache_insert.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_parsetree.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_parsetree.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_parsetree.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_parsetree.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_parsetree_code.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_parsetree_code.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_parsetree_code.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_parsetree_code.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_parsetree_dq.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_parsetree_dq.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_parsetree_dq.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_parsetree_dq.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_parsetree_dqcontent.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_parsetree_dqcontent.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_parsetree_dqcontent.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_parsetree_dqcontent.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_parsetree_tag.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_parsetree_tag.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_parsetree_tag.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_parsetree_tag.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_parsetree_template.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_parsetree_template.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_parsetree_template.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_parsetree_template.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_parsetree_text.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_parsetree_text.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_parsetree_text.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_parsetree_text.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_resource_eval.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_resource_eval.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_resource_eval.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_resource_eval.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_resource_extends.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_resource_extends.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_resource_extends.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_resource_extends.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_resource_file.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_resource_file.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_resource_file.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_resource_file.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_resource_php.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_resource_php.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_resource_php.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_resource_php.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_resource_registered.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_resource_registered.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_resource_registered.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_resource_registered.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_resource_stream.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_resource_stream.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_resource_stream.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_resource_stream.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_resource_string.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_resource_string.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_resource_string.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_resource_string.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_runtime_cachemodify.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_runtime_cachemodify.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_runtime_cachemodify.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_runtime_cachemodify.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_runtime_capture.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_runtime_capture.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_runtime_capture.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_runtime_capture.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_runtime_codeframe.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_runtime_codeframe.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_runtime_codeframe.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_runtime_codeframe.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_runtime_filterhandler.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_runtime_filterhandler.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_runtime_filterhandler.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_runtime_filterhandler.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_runtime_foreach.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_runtime_foreach.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_runtime_foreach.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_runtime_foreach.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_runtime_getincludepath.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_runtime_getincludepath.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_runtime_getincludepath.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_runtime_getincludepath.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_runtime_inheritance.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_runtime_inheritance.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_runtime_inheritance.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_runtime_inheritance.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_runtime_make_nocache.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_runtime_make_nocache.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_runtime_make_nocache.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_runtime_make_nocache.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_runtime_tplfunction.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_runtime_tplfunction.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_runtime_tplfunction.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_runtime_tplfunction.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_runtime_updatecache.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_runtime_updatecache.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_runtime_updatecache.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_runtime_updatecache.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_runtime_updatescope.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_runtime_updatescope.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_runtime_updatescope.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_runtime_updatescope.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_runtime_writefile.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_runtime_writefile.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_runtime_writefile.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_runtime_writefile.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_smartytemplatecompiler.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_smartytemplatecompiler.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_smartytemplatecompiler.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_smartytemplatecompiler.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_template.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_template.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_template.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_template.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_templatebase.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_templatebase.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_templatebase.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_templatebase.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_templatecompilerbase.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_templatecompilerbase.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_templatecompilerbase.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_templatecompilerbase.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_templatelexer.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_templatelexer.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_templatelexer.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_templatelexer.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_templateparser.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_templateparser.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_templateparser.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_templateparser.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_testinstall.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_testinstall.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_testinstall.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_testinstall.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_internal_undefined.php b/www/lib/smarty-3.1.30/sysplugins/smarty_internal_undefined.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_internal_undefined.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_internal_undefined.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_resource.php b/www/lib/smarty-3.1.30/sysplugins/smarty_resource.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_resource.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_resource.php diff --git a/www/smarty-3.1.27/sysplugins/smarty_resource_custom.php b/www/lib/smarty-3.1.30/sysplugins/smarty_resource_custom.php similarity index 100% rename from www/smarty-3.1.27/sysplugins/smarty_resource_custom.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_resource_custom.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_resource_recompiled.php b/www/lib/smarty-3.1.30/sysplugins/smarty_resource_recompiled.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_resource_recompiled.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_resource_recompiled.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_resource_uncompiled.php b/www/lib/smarty-3.1.30/sysplugins/smarty_resource_uncompiled.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_resource_uncompiled.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_resource_uncompiled.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_security.php b/www/lib/smarty-3.1.30/sysplugins/smarty_security.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_security.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_security.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_template_cached.php b/www/lib/smarty-3.1.30/sysplugins/smarty_template_cached.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_template_cached.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_template_cached.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_template_compiled.php b/www/lib/smarty-3.1.30/sysplugins/smarty_template_compiled.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_template_compiled.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_template_compiled.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_template_config.php b/www/lib/smarty-3.1.30/sysplugins/smarty_template_config.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_template_config.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_template_config.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_template_resource_base.php b/www/lib/smarty-3.1.30/sysplugins/smarty_template_resource_base.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_template_resource_base.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_template_resource_base.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_template_source.php b/www/lib/smarty-3.1.30/sysplugins/smarty_template_source.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_template_source.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_template_source.php diff --git a/www/smarty-3.1.27/sysplugins/smarty_undefined_variable.php b/www/lib/smarty-3.1.30/sysplugins/smarty_undefined_variable.php similarity index 100% rename from www/smarty-3.1.27/sysplugins/smarty_undefined_variable.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_undefined_variable.php diff --git a/www/smarty-3.1.30/sysplugins/smarty_variable.php b/www/lib/smarty-3.1.30/sysplugins/smarty_variable.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smarty_variable.php rename to www/lib/smarty-3.1.30/sysplugins/smarty_variable.php diff --git a/www/smarty-3.1.30/sysplugins/smartycompilerexception.php b/www/lib/smarty-3.1.30/sysplugins/smartycompilerexception.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smartycompilerexception.php rename to www/lib/smarty-3.1.30/sysplugins/smartycompilerexception.php diff --git a/www/smarty-3.1.30/sysplugins/smartyexception.php b/www/lib/smarty-3.1.30/sysplugins/smartyexception.php similarity index 100% rename from www/smarty-3.1.30/sysplugins/smartyexception.php rename to www/lib/smarty-3.1.30/sysplugins/smartyexception.php diff --git a/www/libs/class.progressbar.php b/www/libs/class.progressbar.php deleted file mode 120000 index 4770db78..00000000 --- a/www/libs/class.progressbar.php +++ /dev/null @@ -1 +0,0 @@ -Class.Progressbar.inc \ No newline at end of file diff --git a/www/libs/streams.php b/www/libs/streams.php deleted file mode 100644 index 2037fab3..00000000 --- a/www/libs/streams.php +++ /dev/null @@ -1,182 +0,0 @@ -. - - This file is part of PHP-gettext. - - PHP-gettext is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - PHP-gettext is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with PHP-gettext; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - - // Simple class to wrap file streams, string streams, etc. - // seek is essential, and it should be byte stream -class StreamReader -{ - // should return a string [FIXME: perhaps return array of bytes?] - public function read($bytes) - { - return false; - } - - // should return new position - public function seekto($position) - { - return false; - } - - // returns current position - public function currentpos() - { - return false; - } - - // returns length of entire stream (limit for seekto()s) - public function length() - { - return false; - } -} - -class StringReader -{ - public $_pos; - public $_str; - - public function __construct($str = '') - { - $this->_str = $str; - $this->_pos = 0; - } - - public function read($bytes) - { - $data = substr($this->_str, $this->_pos, $bytes); - $this->_pos += $bytes; - if (strlen($this->_str) < $this->_pos) { - $this->_pos = strlen($this->_str); - } - - return $data; - } - - public function seekto($pos) - { - $this->_pos = $pos; - if (strlen($this->_str) < $this->_pos) { - $this->_pos = strlen($this->_str); - } - return $this->_pos; - } - - public function currentpos() - { - return $this->_pos; - } - - public function length() - { - return strlen($this->_str); - } -} - - -class FileReader -{ - public $_pos; - public $_fd; - public $_length; - - public function __construct($filename) - { - if (file_exists($filename)) { - $this->_length = filesize($filename); - $this->_pos = 0; - $this->_fd = fopen($filename, 'rb'); - if (!$this->_fd) { - $this->error = 3; // Cannot read file, probably permissions - return false; - } - } else { - $this->error = 2; // File doesn't exist - return false; - } - } - - public function read($bytes) - { - if ($bytes) { - fseek($this->_fd, $this->_pos); - - // PHP 5.1.1 does not read more than 8192 bytes in one fread() - // the discussions at PHP Bugs suggest it's the intended behaviour - $data = ''; - while ($bytes > 0) { - $chunk = fread($this->_fd, $bytes); - $data .= $chunk; - $bytes -= strlen($chunk); - } - $this->_pos = ftell($this->_fd); - - return $data; - } else { - return ''; - } - } - - public function seekto($pos) - { - fseek($this->_fd, $pos); - $this->_pos = ftell($this->_fd); - return $this->_pos; - } - - public function currentpos() - { - return $this->_pos; - } - - public function length() - { - return $this->_length; - } - - public function close() - { - fclose($this->_fd); - } -} - -// Preloads entire file in memory first, then creates a StringReader -// over it (it assumes knowledge of StringReader internals) -class CachedFileReader extends StringReader -{ - public function __construct($filename) - { - if (file_exists($filename)) { - $length = filesize($filename); - $fd = fopen($filename, 'rb'); - - if (!$fd) { - $this->error = 3; // Cannot read file, probably permissions - return false; - } - $this->_str = fread($fd, $length); - fclose($fd); - } else { - $this->error = 2; // File doesn't exist - return false; - } - } -} diff --git a/www/smarty-3.1.27/Autoloader.php b/www/smarty-3.1.27/Autoloader.php deleted file mode 100644 index a24cad6f..00000000 --- a/www/smarty-3.1.27/Autoloader.php +++ /dev/null @@ -1,158 +0,0 @@ - 'Smarty.class.php', - 'SmartyBC' => 'SmartyBC.class.php', - ); - - private static $syspluginsClasses = array( - 'smarty_config_source' => true, - 'smarty_security' => true, - 'smarty_cacheresource' => true, - 'smarty_compiledresource' => true, - 'smarty_cacheresource_custom' => true, - 'smarty_cacheresource_keyvaluestore' => true, - 'smarty_resource' => true, - 'smarty_resource_custom' => true, - 'smarty_resource_uncompiled' => true, - 'smarty_resource_recompiled' => true, - 'smarty_template_source' => true, - 'smarty_template_compiled' => true, - 'smarty_template_cached' => true, - 'smarty_template_config' => true, - 'smarty_data' => true, - 'smarty_variable' => true, - 'smarty_undefined_variable' => true, - 'smartyexception' => true, - 'smartycompilerexception' => true, - 'smarty_internal_data' => true, - 'smarty_internal_template' => true, - 'smarty_internal_templatebase' => true, - 'smarty_internal_resource_file' => true, - 'smarty_internal_resource_extends' => true, - 'smarty_internal_resource_eval' => true, - 'smarty_internal_resource_string' => true, - 'smarty_internal_resource_registered' => true, - 'smarty_internal_extension_codeframe' => true, - 'smarty_internal_extension_config' => true, - 'smarty_internal_filter_handler' => true, - 'smarty_internal_function_call_handler' => true, - 'smarty_internal_cacheresource_file' => true, - 'smarty_internal_write_file' => true, - ); - - /** - * Registers Smarty_Autoloader backward compatible to older installations. - * - * @param bool $prepend Whether to prepend the autoloader or not. - */ - public static function registerBC($prepend = false) - { - /** - * register the class autoloader - */ - if (!defined('SMARTY_SPL_AUTOLOAD')) { - define('SMARTY_SPL_AUTOLOAD', 0); - } - if (SMARTY_SPL_AUTOLOAD && set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false) { - $registeredAutoLoadFunctions = spl_autoload_functions(); - if (!isset($registeredAutoLoadFunctions['spl_autoload'])) { - spl_autoload_register(); - } - } else { - self::register($prepend); - } - } - - /** - * Registers Smarty_Autoloader as an SPL autoloader. - * - * @param bool $prepend Whether to prepend the autoloader or not. - */ - public static function register($prepend = false) - { - self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : dirname(__FILE__) . '/'; - self::$SMARTY_SYSPLUGINS_DIR = defined('SMARTY_SYSPLUGINS_DIR') ? SMARTY_SYSPLUGINS_DIR : self::$SMARTY_DIR . 'sysplugins/'; - if (version_compare(phpversion(), '5.3.0', '>=')) { - spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend); - } else { - spl_autoload_register(array(__CLASS__, 'autoload')); - } - } - - /** - * Handles autoloading of classes. - * - * @param string $class A class name. - */ - public static function autoload($class) - { - // Request for Smarty or already unknown class - if (isset(self::$unknown[$class])) { - return; - } - $_class = strtolower($class); - if (isset(self::$syspluginsClasses[$_class])) { - $_class = (self::$syspluginsClasses[$_class] === true) ? $_class : self::$syspluginsClasses[$_class]; - $file = self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php'; - require_once $file; - return; - } elseif (0 !== strpos($_class, 'smarty_internal_')) { - if (isset(self::$rootClasses[$class])) { - $file = self::$SMARTY_DIR . self::$rootClasses[$class]; - require_once $file; - return; - } - self::$unknown[$class] = true; - return; - } - $file = self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php'; - if (is_file($file)) { - require_once $file; - return; - } - self::$unknown[$class] = true; - return; - } -} diff --git a/www/smarty-3.1.27/Smarty.class.php b/www/smarty-3.1.27/Smarty.class.php deleted file mode 100644 index 1f0f2634..00000000 --- a/www/smarty-3.1.27/Smarty.class.php +++ /dev/null @@ -1,1802 +0,0 @@ - - * @author Uwe Tews - * @author Rodney Rehm - * @package Smarty - * @version 3.1.27 - */ - -/** - * define shorthand directory separator constant - */ -if (!defined('DS')) { - define('DS', DIRECTORY_SEPARATOR); -} - -/** - * set SMARTY_DIR to absolute path to Smarty library files. - * Sets SMARTY_DIR only if user application has not already defined it. - */ -if (!defined('SMARTY_DIR')) { - define('SMARTY_DIR', dirname(__FILE__) . DS); -} - -/** - * set SMARTY_SYSPLUGINS_DIR to absolute path to Smarty internal plugins. - * Sets SMARTY_SYSPLUGINS_DIR only if user application has not already defined it. - */ -if (!defined('SMARTY_SYSPLUGINS_DIR')) { - define('SMARTY_SYSPLUGINS_DIR', SMARTY_DIR . 'sysplugins' . DS); -} -if (!defined('SMARTY_PLUGINS_DIR')) { - define('SMARTY_PLUGINS_DIR', SMARTY_DIR . 'plugins' . DS); -} -if (!defined('SMARTY_MBSTRING')) { - define('SMARTY_MBSTRING', function_exists('mb_get_info')); -} -if (!defined('SMARTY_RESOURCE_CHAR_SET')) { - // UTF-8 can only be done properly when mbstring is available! - /** - * @deprecated in favor of Smarty::$_CHARSET - */ - define('SMARTY_RESOURCE_CHAR_SET', SMARTY_MBSTRING ? 'UTF-8' : 'ISO-8859-1'); -} -if (!defined('SMARTY_RESOURCE_DATE_FORMAT')) { - /** - * @deprecated in favor of Smarty::$_DATE_FORMAT - */ - define('SMARTY_RESOURCE_DATE_FORMAT', '%b %e, %Y'); -} - -/** - * Try loading the Smarty_Internal_Data class - * If we fail we must load Smarty's autoloader. - * Otherwise we may have a global autoloader like Composer - */ -if (!class_exists('Smarty_Autoloader', false)) { - if (!class_exists('Smarty_Internal_Data', true)) { - require_once 'Autoloader.php'; - Smarty_Autoloader::registerBC(); - } -} - -/** - * Load always needed external class files - */ - -if (!class_exists('Smarty_Internal_Data', false)) { - require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_data.php'; -} -require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_templatebase.php'; -require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_template.php'; -require_once SMARTY_SYSPLUGINS_DIR . 'smarty_resource.php'; -require_once SMARTY_SYSPLUGINS_DIR . 'smarty_variable.php'; -require_once SMARTY_SYSPLUGINS_DIR . 'smarty_template_source.php'; - -/** - * This is the main Smarty class - * - * @package Smarty - */ -class Smarty extends Smarty_Internal_TemplateBase -{ - /**#@+ - * constant definitions - */ - - /** - * smarty version - */ - const SMARTY_VERSION = '3.1.27'; - - /** - * define variable scopes - */ - const SCOPE_LOCAL = 0; - - const SCOPE_PARENT = 1; - - const SCOPE_ROOT = 2; - - const SCOPE_GLOBAL = 3; - - /** - * define caching modes - */ - const CACHING_OFF = 0; - - const CACHING_LIFETIME_CURRENT = 1; - - const CACHING_LIFETIME_SAVED = 2; - - /** - * define constant for clearing cache files be saved expiration datees - */ - const CLEAR_EXPIRED = - 1; - - /** - * define compile check modes - */ - const COMPILECHECK_OFF = 0; - - const COMPILECHECK_ON = 1; - - const COMPILECHECK_CACHEMISS = 2; - - /** - * define debug modes - */ - const DEBUG_OFF = 0; - - const DEBUG_ON = 1; - - const DEBUG_INDIVIDUAL = 2; - - /** - * modes for handling of "" tags in templates. - */ - const PHP_PASSTHRU = 0; //-> print tags as plain text - - const PHP_QUOTE = 1; //-> escape tags as entities - - const PHP_REMOVE = 2; //-> escape tags as entities - - const PHP_ALLOW = 3; //-> escape tags as entities - - /** - * filter types - */ - const FILTER_POST = 'post'; - - const FILTER_PRE = 'pre'; - - const FILTER_OUTPUT = 'output'; - - const FILTER_VARIABLE = 'variable'; - - /** - * plugin types - */ - const PLUGIN_FUNCTION = 'function'; - - const PLUGIN_BLOCK = 'block'; - - const PLUGIN_COMPILER = 'compiler'; - - const PLUGIN_MODIFIER = 'modifier'; - - const PLUGIN_MODIFIERCOMPILER = 'modifiercompiler'; - - /**#@-*/ - - /** - * assigned global tpl vars - */ - public static $global_tpl_vars = array(); - - /** - * error handler returned by set_error_hanlder() in Smarty::muteExpectedErrors() - */ - public static $_previous_error_handler = null; - - /** - * contains directories outside of SMARTY_DIR that are to be muted by muteExpectedErrors() - */ - public static $_muted_directories = array('./templates_c/' => null, './cache/' => null); - - /** - * Flag denoting if Multibyte String functions are available - */ - public static $_MBSTRING = SMARTY_MBSTRING; - - /** - * The character set to adhere to (e.g. "UTF-8") - */ - public static $_CHARSET = SMARTY_RESOURCE_CHAR_SET; - - /** - * The date format to be used internally - * (accepts date() and strftime()) - */ - public static $_DATE_FORMAT = SMARTY_RESOURCE_DATE_FORMAT; - - /** - * Flag denoting if PCRE should run in UTF-8 mode - */ - public static $_UTF8_MODIFIER = 'u'; - - /** - * Flag denoting if operating system is windows - */ - public static $_IS_WINDOWS = false; - - /**#@+ - * variables - */ - - /** - * auto literal on delimiters with whitspace - * - * @var boolean - */ - public $auto_literal = true; - - /** - * display error on not assigned variables - * - * @var boolean - */ - public $error_unassigned = false; - - /** - * look up relative filepaths in include_path - * - * @var boolean - */ - public $use_include_path = false; - - /** - * template directory - * - * @var array - */ - private $template_dir = array('./templates/'); - - /** - * joined template directory string used in cache keys - * - * @var string - */ - public $joined_template_dir = './templates/'; - - /** - * joined config directory string used in cache keys - * - * @var string - */ - public $joined_config_dir = './configs/'; - - /** - * default template handler - * - * @var callable - */ - public $default_template_handler_func = null; - - /** - * default config handler - * - * @var callable - */ - public $default_config_handler_func = null; - - /** - * default plugin handler - * - * @var callable - */ - public $default_plugin_handler_func = null; - - /** - * compile directory - * - * @var string - */ - private $compile_dir = './templates_c/'; - - /** - * plugins directory - * - * @var array - */ - private $plugins_dir = null; - - /** - * cache directory - * - * @var string - */ - private $cache_dir = './cache/'; - - /** - * config directory - * - * @var array - */ - private $config_dir = array('./configs/'); - - /** - * force template compiling? - * - * @var boolean - */ - public $force_compile = false; - - /** - * check template for modifications? - * - * @var boolean - */ - public $compile_check = true; - - /** - * use sub dirs for compiled/cached files? - * - * @var boolean - */ - public $use_sub_dirs = false; - - /** - * allow ambiguous resources (that are made unique by the resource handler) - * - * @var boolean - */ - public $allow_ambiguous_resources = false; - - /** - * merge compiled includes - * - * @var boolean - */ - public $merge_compiled_includes = false; - - /** - * template inheritance merge compiled includes - * - * @var boolean - */ - public $inheritance_merge_compiled_includes = true; - - /** - * force cache file creation - * - * @var boolean - */ - public $force_cache = false; - - /** - * template left-delimiter - * - * @var string - */ - public $left_delimiter = "{"; - - /** - * template right-delimiter - * - * @var string - */ - public $right_delimiter = "}"; - - /**#@+ - * security - */ - /** - * class name - * This should be instance of Smarty_Security. - * - * @var string - * @see Smarty_Security - */ - public $security_class = 'Smarty_Security'; - - /** - * implementation of security class - * - * @var Smarty_Security - */ - public $security_policy = null; - - /** - * controls handling of PHP-blocks - * - * @var integer - */ - public $php_handling = self::PHP_PASSTHRU; - - /** - * controls if the php template file resource is allowed - * - * @var bool - */ - public $allow_php_templates = false; - - /** - * Should compiled-templates be prevented from being called directly? - * {@internal - * Currently used by Smarty_Internal_Template only. - * }} - * - * @var boolean - */ - public $direct_access_security = true; - - /**#@-*/ - /** - * debug mode - * Setting this to true enables the debug-console. - * - * @var boolean - */ - public $debugging = false; - - /** - * This determines if debugging is enable-able from the browser. - *
    - *
  • NONE => no debugging control allowed
  • - *
  • URL => enable debugging when SMARTY_DEBUG is found in the URL.
  • - *
- * - * @var string - */ - public $debugging_ctrl = 'NONE'; - - /** - * Name of debugging URL-param. - * Only used when $debugging_ctrl is set to 'URL'. - * The name of the URL-parameter that activates debugging. - * - * @var string - */ - public $smarty_debug_id = 'SMARTY_DEBUG'; - - /** - * Path of debug template. - * - * @var string - */ - public $debug_tpl = null; - - /** - * When set, smarty uses this value as error_reporting-level. - * - * @var int - */ - public $error_reporting = null; - - /** - * Internal flag for getTags() - * - * @var boolean - */ - public $get_used_tags = false; - - /**#@+ - * config var settings - */ - - /** - * Controls whether variables with the same name overwrite each other. - * - * @var boolean - */ - public $config_overwrite = true; - - /** - * Controls whether config values of on/true/yes and off/false/no get converted to boolean. - * - * @var boolean - */ - public $config_booleanize = true; - - /** - * Controls whether hidden config sections/vars are read from the file. - * - * @var boolean - */ - public $config_read_hidden = false; - - /**#@-*/ - - /**#@+ - * resource locking - */ - - /** - * locking concurrent compiles - * - * @var boolean - */ - public $compile_locking = true; - - /** - * Controls whether cache resources should emply locking mechanism - * - * @var boolean - */ - public $cache_locking = false; - - /** - * seconds to wait for acquiring a lock before ignoring the write lock - * - * @var float - */ - public $locking_timeout = 10; - - /**#@-*/ - - /** - * resource type used if none given - * Must be an valid key of $registered_resources. - * - * @var string - */ - public $default_resource_type = 'file'; - - /** - * caching type - * Must be an element of $cache_resource_types. - * - * @var string - */ - public $caching_type = 'file'; - - /** - * internal config properties - * - * @var array - */ - public $properties = array(); - - /** - * config type - * - * @var string - */ - public $default_config_type = 'file'; - - /** - * cached template objects - * - * @var array - */ - public $source_objects = array(); - - /** - * cached template objects - * - * @var array - */ - public $template_objects = array(); - - /** - * enable resource caching - * - * @var bool - */ - public $resource_caching = false; - - /** - * enable template resource caching - * - * @var bool - */ - public $template_resource_caching = true; - - /** - * check If-Modified-Since headers - * - * @var boolean - */ - public $cache_modified_check = false; - - /** - * registered plugins - * - * @var array - */ - public $registered_plugins = array(); - - /** - * plugin search order - * - * @var array - */ - public $plugin_search_order = array('function', 'block', 'compiler', 'class'); - - /** - * registered objects - * - * @var array - */ - public $registered_objects = array(); - - /** - * registered classes - * - * @var array - */ - public $registered_classes = array(); - - /** - * registered filters - * - * @var array - */ - public $registered_filters = array(); - - /** - * registered resources - * - * @var array - */ - public $registered_resources = array(); - - /** - * resource handler cache - * - * @var array - */ - public $_resource_handlers = array(); - - /** - * registered cache resources - * - * @var array - */ - public $registered_cache_resources = array(); - - /** - * cache resource handler cache - * - * @var array - */ - public $_cacheresource_handlers = array(); - - /** - * autoload filter - * - * @var array - */ - public $autoload_filters = array(); - - /** - * default modifier - * - * @var array - */ - public $default_modifiers = array(); - - /** - * autoescape variable output - * - * @var boolean - */ - public $escape_html = false; - - /** - * global internal smarty vars - * - * @var array - */ - public static $_smarty_vars = array(); - - /** - * start time for execution time calculation - * - * @var int - */ - public $start_time = 0; - - /** - * default file permissions - * - * @var int - */ - public $_file_perms = 0644; - - /** - * default dir permissions - * - * @var int - */ - public $_dir_perms = 0771; - - /** - * block tag hierarchy - * - * @var array - */ - public $_tag_stack = array(); - - /** - * required by the compiler for BC - * - * @var string - */ - public $_current_file = null; - - /** - * internal flag to enable parser debugging - * - * @var bool - */ - public $_parserdebug = false; - - /** - * Cache of is_file results of loadPlugin() - * - * @var array - */ - public $_is_file_cache = array(); - - /**#@-*/ - - /** - * Initialize new Smarty object - */ - public function __construct() - { - if (is_callable('mb_internal_encoding')) { - mb_internal_encoding(Smarty::$_CHARSET); - } - $this->start_time = microtime(true); - // check default dirs for overloading - if ($this->template_dir[0] !== './templates/' || isset($this->template_dir[1])) { - $this->setTemplateDir($this->template_dir); - } - if ($this->config_dir[0] !== './configs/' || isset($this->config_dir[1])) { - $this->setConfigDir($this->config_dir); - } - if ($this->compile_dir !== './templates_c/') { - unset(self::$_muted_directories['./templates_c/']); - $this->setCompileDir($this->compile_dir); - } - if ($this->cache_dir !== './cache/') { - unset(self::$_muted_directories['./cache/']); - $this->setCacheDir($this->cache_dir); - } - if (isset($this->plugins_dir)) { - $this->setPluginsDir($this->plugins_dir); - } else { - $this->setPluginsDir(SMARTY_PLUGINS_DIR); - } - if (isset($_SERVER['SCRIPT_NAME'])) { - Smarty::$global_tpl_vars['SCRIPT_NAME'] = new Smarty_Variable($_SERVER['SCRIPT_NAME']); - } - - // Check if we're running on windows - Smarty::$_IS_WINDOWS = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; - - // let PCRE (preg_*) treat strings as ISO-8859-1 if we're not dealing with UTF-8 - if (Smarty::$_CHARSET !== 'UTF-8') { - Smarty::$_UTF8_MODIFIER = ''; - } - } - - /** - * fetches a rendered Smarty template - * - * @param string $template the resource handle of the template file or template object - * @param mixed $cache_id cache id to be used with this template - * @param mixed $compile_id compile id to be used with this template - * @param object $parent next higher level of Smarty variables - * @param bool $display true: display, false: fetch - * @param bool $merge_tpl_vars not used - left for BC - * @param bool $no_output_filter not used - left for BC - * - * @throws Exception - * @throws SmartyException - * @return string rendered template output - */ - public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null, $display = false, $merge_tpl_vars = true, $no_output_filter = false) - { - if ($cache_id !== null && is_object($cache_id)) { - $parent = $cache_id; - $cache_id = null; - } - if ($parent === null) { - $parent = $this; - } - // get template object - $_template = is_object($template) ? $template : $this->createTemplate($template, $cache_id, $compile_id, $parent, false); - // set caching in template object - $_template->caching = $this->caching; - // fetch template content - return $_template->render(true, false, $display); - } - - /** - * displays a Smarty template - * - * @param string $template the resource handle of the template file or template object - * @param mixed $cache_id cache id to be used with this template - * @param mixed $compile_id compile id to be used with this template - * @param object $parent next higher level of Smarty variables - */ - public function display($template = null, $cache_id = null, $compile_id = null, $parent = null) - { - // display template - $this->fetch($template, $cache_id, $compile_id, $parent, true); - } - - /** - * Check if a template resource exists - * - * @param string $resource_name template name - * - * @return boolean status - */ - public function templateExists($resource_name) - { - // create template object - $save = $this->template_objects; - $tpl = new $this->template_class($resource_name, $this); - // check if it does exists - $result = $tpl->source->exists; - $this->template_objects = $save; - - return $result; - } - - /** - * Returns a single or all global variables - * - * @param string $varname variable name or null - * - * @return string variable value or or array of variables - */ - public function getGlobal($varname = null) - { - if (isset($varname)) { - if (isset(self::$global_tpl_vars[$varname])) { - return self::$global_tpl_vars[$varname]->value; - } else { - return ''; - } - } else { - $_result = array(); - foreach (self::$global_tpl_vars AS $key => $var) { - $_result[$key] = $var->value; - } - - return $_result; - } - } - - /** - * Empty cache folder - * - * @param integer $exp_time expiration time - * @param string $type resource type - * - * @return integer number of cache files deleted - */ - public function clearAllCache($exp_time = null, $type = null) - { - // load cache resource and call clearAll - $_cache_resource = Smarty_CacheResource::load($this, $type); - Smarty_CacheResource::invalidLoadedCache($this); - - return $_cache_resource->clearAll($this, $exp_time); - } - - /** - * Empty cache for a specific template - * - * @param string $template_name template name - * @param string $cache_id cache id - * @param string $compile_id compile id - * @param integer $exp_time expiration time - * @param string $type resource type - * - * @return integer number of cache files deleted - */ - public function clearCache($template_name, $cache_id = null, $compile_id = null, $exp_time = null, $type = null) - { - // load cache resource and call clear - $_cache_resource = Smarty_CacheResource::load($this, $type); - Smarty_CacheResource::invalidLoadedCache($this); - - return $_cache_resource->clear($this, $template_name, $cache_id, $compile_id, $exp_time); - } - - /** - * Loads security class and enables security - * - * @param string|Smarty_Security $security_class if a string is used, it must be class-name - * - * @return Smarty current Smarty instance for chaining - * @throws SmartyException when an invalid class name is provided - */ - public function enableSecurity($security_class = null) - { - if ($security_class instanceof Smarty_Security) { - $this->security_policy = $security_class; - - return $this; - } elseif (is_object($security_class)) { - throw new SmartyException("Class '" . get_class($security_class) . "' must extend Smarty_Security."); - } - if ($security_class == null) { - $security_class = $this->security_class; - } - if (!class_exists($security_class)) { - throw new SmartyException("Security class '$security_class' is not defined"); - } elseif ($security_class !== 'Smarty_Security' && !is_subclass_of($security_class, 'Smarty_Security')) { - throw new SmartyException("Class '$security_class' must extend Smarty_Security."); - } else { - $this->security_policy = new $security_class($this); - } - - return $this; - } - - /** - * Disable security - * - * @return Smarty current Smarty instance for chaining - */ - public function disableSecurity() - { - $this->security_policy = null; - - return $this; - } - - /** - * Set template directory - * - * @param string|array $template_dir directory(s) of template sources - * - * @return Smarty current Smarty instance for chaining - */ - public function setTemplateDir($template_dir) - { - $this->template_dir = array(); - foreach ((array) $template_dir as $k => $v) { - $this->template_dir[$k] = rtrim($v, '/\\') . DS; - } - $this->joined_template_dir = join(' # ', $this->template_dir); - return $this; - } - - /** - * Add template directory(s) - * - * @param string|array $template_dir directory(s) of template sources - * @param string $key of the array element to assign the template dir to - * - * @return Smarty current Smarty instance for chaining - * @throws SmartyException when the given template directory is not valid - */ - public function addTemplateDir($template_dir, $key = null) - { - $this->_addDir('template_dir', $template_dir, $key); - $this->joined_template_dir = join(' # ', $this->template_dir); - return $this; - } - - /** - * Get template directories - * - * @param mixed $index index of directory to get, null to get all - * - * @return array|string list of template directories, or directory of $index - */ - public function getTemplateDir($index = null) - { - if ($index !== null) { - return isset($this->template_dir[$index]) ? $this->template_dir[$index] : null; - } - return (array) $this->template_dir; - } - - /** - * Set config directory - * - * @param $config_dir - * - * @return Smarty current Smarty instance for chaining - */ - public function setConfigDir($config_dir) - { - $this->config_dir = array(); - foreach ((array) $config_dir as $k => $v) { - $this->config_dir[$k] = rtrim($v, '/\\') . DS; - } - $this->joined_config_dir = join(' # ', $this->config_dir); - return $this; - } - - /** - * Add config directory(s) - * - * @param string|array $config_dir directory(s) of config sources - * @param mixed $key key of the array element to assign the config dir to - * - * @return Smarty current Smarty instance for chaining - */ - public function addConfigDir($config_dir, $key = null) - { - $this->_addDir('config_dir', $config_dir, $key); - $this->joined_config_dir = join(' # ', $this->config_dir); - return $this; - } - - /** - * Get config directory - * - * @param mixed $index index of directory to get, null to get all - * - * @return array|string configuration directory - */ - public function getConfigDir($index = null) - { - if ($index !== null) { - return isset($this->config_dir[$index]) ? $this->config_dir[$index] : null; - } - return (array) $this->config_dir; - } - - /** - * Set plugins directory - * - * @param string|array $plugins_dir directory(s) of plugins - * - * @return Smarty current Smarty instance for chaining - */ - public function setPluginsDir($plugins_dir) - { - $this->plugins_dir = array(); - $this->addPluginsDir($plugins_dir); - return $this; - } - - /** - * Adds directory of plugin files - * - * @param $plugins_dir - * - * @return Smarty current Smarty instance for chaining - */ - public function addPluginsDir($plugins_dir) - { - // make sure we're dealing with an array - $this->plugins_dir = (array) $this->plugins_dir; - foreach ((array) $plugins_dir as $v) { - $this->plugins_dir[] = rtrim($v, '/\\') . DS; - } - $this->plugins_dir = array_unique($this->plugins_dir); - $this->_is_file_cache = array(); - return $this; - } - - /** - * Get plugin directories - * - * @return array list of plugin directories - */ - public function getPluginsDir() - { - return (array) $this->plugins_dir; - } - - /** - * Set compile directory - * - * @param string $compile_dir directory to store compiled templates in - * - * @return Smarty current Smarty instance for chaining - */ - public function setCompileDir($compile_dir) - { - $this->compile_dir = rtrim($compile_dir, '/\\') . DS; - if (!isset(Smarty::$_muted_directories[$this->compile_dir])) { - Smarty::$_muted_directories[$this->compile_dir] = null; - } - - return $this; - } - - /** - * Get compiled directory - * - * @return string path to compiled templates - */ - public function getCompileDir() - { - return $this->compile_dir; - } - - /** - * Set cache directory - * - * @param string $cache_dir directory to store cached templates in - * - * @return Smarty current Smarty instance for chaining - */ - public function setCacheDir($cache_dir) - { - $this->cache_dir = rtrim($cache_dir, '/\\') . DS; - if (!isset(Smarty::$_muted_directories[$this->cache_dir])) { - Smarty::$_muted_directories[$this->cache_dir] = null; - } - return $this; - } - - /** - * Get cache directory - * - * @return string path of cache directory - */ - public function getCacheDir() - { - return $this->cache_dir; - } - - /** - * add directories to given property name - * - * @param string $dirName directory property name - * @param string|array $dir directory string or array of strings - * @param mixed $key optional key - */ - private function _addDir($dirName, $dir, $key = null) - { - // make sure we're dealing with an array - $this->$dirName = (array) $this->$dirName; - - if (is_array($dir)) { - foreach ($dir as $k => $v) { - if (is_int($k)) { - // indexes are not merged but appended - $this->{$dirName}[] = rtrim($v, '/\\') . DS; - } else { - // string indexes are overridden - $this->{$dirName}[$k] = rtrim($v, '/\\') . DS; - } - } - } else { - if ($key !== null) { - // override directory at specified index - $this->{$dirName}[$key] = rtrim($dir, '/\\') . DS; - } else { - // append new directory - $this->{$dirName}[] = rtrim($dir, '/\\') . DS; - } - } - } - - /** - * Set default modifiers - * - * @param array|string $modifiers modifier or list of modifiers to set - * - * @return Smarty current Smarty instance for chaining - */ - public function setDefaultModifiers($modifiers) - { - $this->default_modifiers = (array) $modifiers; - - return $this; - } - - /** - * Add default modifiers - * - * @param array|string $modifiers modifier or list of modifiers to add - * - * @return Smarty current Smarty instance for chaining - */ - public function addDefaultModifiers($modifiers) - { - if (is_array($modifiers)) { - $this->default_modifiers = array_merge($this->default_modifiers, $modifiers); - } else { - $this->default_modifiers[] = $modifiers; - } - - return $this; - } - - /** - * Get default modifiers - * - * @return array list of default modifiers - */ - public function getDefaultModifiers() - { - return $this->default_modifiers; - } - - /** - * Set autoload filters - * - * @param array $filters filters to load automatically - * @param string $type "pre", "output", … specify the filter type to set. Defaults to none treating $filters' - * keys as the appropriate types - * - * @return Smarty current Smarty instance for chaining - */ - public function setAutoloadFilters($filters, $type = null) - { - if ($type !== null) { - $this->autoload_filters[$type] = (array) $filters; - } else { - $this->autoload_filters = (array) $filters; - } - - return $this; - } - - /** - * Add autoload filters - * - * @param array $filters filters to load automatically - * @param string $type "pre", "output", … specify the filter type to set. Defaults to none treating $filters' - * keys as the appropriate types - * - * @return Smarty current Smarty instance for chaining - */ - public function addAutoloadFilters($filters, $type = null) - { - if ($type !== null) { - if (!empty($this->autoload_filters[$type])) { - $this->autoload_filters[$type] = array_merge($this->autoload_filters[$type], (array) $filters); - } else { - $this->autoload_filters[$type] = (array) $filters; - } - } else { - foreach ((array) $filters as $key => $value) { - if (!empty($this->autoload_filters[$key])) { - $this->autoload_filters[$key] = array_merge($this->autoload_filters[$key], (array) $value); - } else { - $this->autoload_filters[$key] = (array) $value; - } - } - } - - return $this; - } - - /** - * Get autoload filters - * - * @param string $type type of filter to get autoloads for. Defaults to all autoload filters - * - * @return array array( 'type1' => array( 'filter1', 'filter2', … ) ) or array( 'filter1', 'filter2', …) if $type - * was specified - */ - public function getAutoloadFilters($type = null) - { - if ($type !== null) { - return isset($this->autoload_filters[$type]) ? $this->autoload_filters[$type] : array(); - } - - return $this->autoload_filters; - } - - /** - * return name of debugging template - * - * @return string - */ - public function getDebugTemplate() - { - return $this->debug_tpl; - } - - /** - * set the debug template - * - * @param string $tpl_name - * - * @return Smarty current Smarty instance for chaining - * @throws SmartyException if file is not readable - */ - public function setDebugTemplate($tpl_name) - { - if (!is_readable($tpl_name)) { - throw new SmartyException("Unknown file '{$tpl_name}'"); - } - $this->debug_tpl = $tpl_name; - - return $this; - } - - /** - * creates a template object - * - * @param string $template the resource handle of the template file - * @param mixed $cache_id cache id to be used with this template - * @param mixed $compile_id compile id to be used with this template - * @param object $parent next higher level of Smarty variables - * @param boolean $do_clone flag is Smarty object shall be cloned - * - * @return object template object - */ - public function createTemplate($template, $cache_id = null, $compile_id = null, $parent = null, $do_clone = true) - { - if ($cache_id !== null && (is_object($cache_id) || is_array($cache_id))) { - $parent = $cache_id; - $cache_id = null; - } - if ($parent !== null && is_array($parent)) { - $data = $parent; - $parent = null; - } else { - $data = null; - } - $_templateId = $this->getTemplateId($template, $cache_id, $compile_id); - if (isset($this->template_objects[$_templateId])) { - if ($do_clone) { - $tpl = clone $this->template_objects[$_templateId]; - $tpl->smarty = clone $tpl->smarty; - } else { - $tpl = $this->template_objects[$_templateId]; - } - $tpl->parent = $parent; - $tpl->tpl_vars = array(); - $tpl->config_vars = array(); - } else { - $tpl = new $this->template_class($template, $this, $parent, $cache_id, $compile_id); - if ($do_clone) { - $tpl->smarty = clone $tpl->smarty; - } - $tpl->templateId = $_templateId; - } - // fill data if present - if (!empty($data) && is_array($data)) { - // set up variable values - foreach ($data as $_key => $_val) { - $tpl->tpl_vars[$_key] = new Smarty_Variable($_val); - } - } - if ($this->debugging) { - Smarty_Internal_Debug::register_template($tpl); - } - return $tpl; - } - - /** - * Takes unknown classes and loads plugin files for them - * class name format: Smarty_PluginType_PluginName - * plugin filename format: plugintype.pluginname.php - * - * @param string $plugin_name class plugin name to load - * @param bool $check check if already loaded - * - * @throws SmartyException - * @return string |boolean filepath of loaded file or false - */ - public function loadPlugin($plugin_name, $check = true) - { - // if function or class exists, exit silently (already loaded) - if ($check && (is_callable($plugin_name) || class_exists($plugin_name, false))) { - return true; - } - // Plugin name is expected to be: Smarty_[Type]_[Name] - $_name_parts = explode('_', $plugin_name, 3); - // class name must have three parts to be valid plugin - // count($_name_parts) < 3 === !isset($_name_parts[2]) - if (!isset($_name_parts[2]) || strtolower($_name_parts[0]) !== 'smarty') { - throw new SmartyException("plugin {$plugin_name} is not a valid name format"); - } - // if type is "internal", get plugin from sysplugins - if (strtolower($_name_parts[1]) == 'internal') { - $file = SMARTY_SYSPLUGINS_DIR . strtolower($plugin_name) . '.php'; - if (isset($this->_is_file_cache[$file]) ? $this->_is_file_cache[$file] : $this->_is_file_cache[$file] = is_file($file)) { - require_once($file); - return $file; - } else { - return false; - } - } - // plugin filename is expected to be: [type].[name].php - $_plugin_filename = "{$_name_parts[1]}.{$_name_parts[2]}.php"; - - $_stream_resolve_include_path = function_exists('stream_resolve_include_path'); - - // loop through plugin dirs and find the plugin - foreach ($this->getPluginsDir() as $_plugin_dir) { - $names = array($_plugin_dir . $_plugin_filename, $_plugin_dir . strtolower($_plugin_filename),); - foreach ($names as $file) { - if (isset($this->_is_file_cache[$file]) ? $this->_is_file_cache[$file] : $this->_is_file_cache[$file] = is_file($file)) { - require_once($file); - return $file; - } - if ($this->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) { - // try PHP include_path - if ($_stream_resolve_include_path) { - $file = stream_resolve_include_path($file); - } else { - $file = Smarty_Internal_Get_Include_Path::getIncludePath($file); - } - - if ($file !== false) { - require_once($file); - - return $file; - } - } - } - } - // no plugin loaded - return false; - } - - /** - * Compile all template files - * - * @param string $extension file extension - * @param bool $force_compile force all to recompile - * @param int $time_limit - * @param int $max_errors - * - * @return integer number of template files recompiled - */ - public function compileAllTemplates($extension = '.tpl', $force_compile = false, $time_limit = 0, $max_errors = null) - { - return Smarty_Internal_Utility::compileAllTemplates($extension, $force_compile, $time_limit, $max_errors, $this); - } - - /** - * Compile all config files - * - * @param string $extension file extension - * @param bool $force_compile force all to recompile - * @param int $time_limit - * @param int $max_errors - * - * @return integer number of template files recompiled - */ - public function compileAllConfig($extension = '.conf', $force_compile = false, $time_limit = 0, $max_errors = null) - { - return Smarty_Internal_Utility::compileAllConfig($extension, $force_compile, $time_limit, $max_errors, $this); - } - - /** - * Delete compiled template file - * - * @param string $resource_name template name - * @param string $compile_id compile id - * @param integer $exp_time expiration time - * - * @return integer number of template files deleted - */ - public function clearCompiledTemplate($resource_name = null, $compile_id = null, $exp_time = null) - { - return Smarty_Internal_Utility::clearCompiledTemplate($resource_name, $compile_id, $exp_time, $this); - } - - /** - * Return array of tag/attributes of all tags used by an template - * - * @param Smarty_Internal_Template $template - * - * @return array of tag/attributes - */ - public function getTags(Smarty_Internal_Template $template) - { - return Smarty_Internal_Utility::getTags($template); - } - - /** - * Run installation test - * - * @param array $errors Array to write errors into, rather than outputting them - * - * @return boolean true if setup is fine, false if something is wrong - */ - public function testInstall(&$errors = null) - { - return Smarty_Internal_TestInstall::testInstall($this, $errors); - } - - /** - * @param boolean $compile_check - */ - public function setCompileCheck($compile_check) - { - $this->compile_check = $compile_check; - } - - /** - * @param boolean $use_sub_dirs - */ - public function setUseSubDirs($use_sub_dirs) - { - $this->use_sub_dirs = $use_sub_dirs; - } - - /** - * @param boolean $caching - */ - public function setCaching($caching) - { - $this->caching = $caching; - } - - /** - * @param int $cache_lifetime - */ - public function setCacheLifetime($cache_lifetime) - { - $this->cache_lifetime = $cache_lifetime; - } - - /** - * @param string $compile_id - */ - public function setCompileId($compile_id) - { - $this->compile_id = $compile_id; - } - - /** - * @param string $cache_id - */ - public function setCacheId($cache_id) - { - $this->cache_id = $cache_id; - } - - /** - * @param int $error_reporting - */ - public function setErrorReporting($error_reporting) - { - $this->error_reporting = $error_reporting; - } - - /** - * @param boolean $escape_html - */ - public function setEscapeHtml($escape_html) - { - $this->escape_html = $escape_html; - } - - /** - * @param boolean $auto_literal - */ - public function setAutoLiteral($auto_literal) - { - $this->auto_literal = $auto_literal; - } - - /** - * @param boolean $force_compile - */ - public function setForceCompile($force_compile) - { - $this->force_compile = $force_compile; - } - - /** - * @param boolean $merge_compiled_includes - */ - public function setMergeCompiledIncludes($merge_compiled_includes) - { - $this->merge_compiled_includes = $merge_compiled_includes; - } - - /** - * @param string $left_delimiter - */ - public function setLeftDelimiter($left_delimiter) - { - $this->left_delimiter = $left_delimiter; - } - - /** - * @param string $right_delimiter - */ - public function setRightDelimiter($right_delimiter) - { - $this->right_delimiter = $right_delimiter; - } - - /** - * @param boolean $debugging - */ - public function setDebugging($debugging) - { - $this->debugging = $debugging; - } - - /** - * @param boolean $config_overwrite - */ - public function setConfigOverwrite($config_overwrite) - { - $this->config_overwrite = $config_overwrite; - } - - /** - * @param boolean $config_booleanize - */ - public function setConfigBooleanize($config_booleanize) - { - $this->config_booleanize = $config_booleanize; - } - - /** - * @param boolean $config_read_hidden - */ - public function setConfigReadHidden($config_read_hidden) - { - $this->config_read_hidden = $config_read_hidden; - } - - /** - * @param boolean $compile_locking - */ - public function setCompileLocking($compile_locking) - { - $this->compile_locking = $compile_locking; - } - - /** - * Class destructor - */ - public function __destruct() - { - // intentionally left blank - } - - /** - * <> Generic getter. - * Calls the appropriate getter function. - * Issues an E_USER_NOTICE if no valid getter is found. - * - * @param string $name property name - * - * @return mixed - */ - public function __get($name) - { - $allowed = array('template_dir' => 'getTemplateDir', 'config_dir' => 'getConfigDir', - 'plugins_dir' => 'getPluginsDir', 'compile_dir' => 'getCompileDir', - 'cache_dir' => 'getCacheDir',); - - if (isset($allowed[$name])) { - return $this->{$allowed[$name]}(); - } else { - trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE); - } - } - - /** - * <> Generic setter. - * Calls the appropriate setter function. - * Issues an E_USER_NOTICE if no valid setter is found. - * - * @param string $name property name - * @param mixed $value parameter passed to setter - */ - public function __set($name, $value) - { - $allowed = array('template_dir' => 'setTemplateDir', 'config_dir' => 'setConfigDir', - 'plugins_dir' => 'setPluginsDir', 'compile_dir' => 'setCompileDir', - 'cache_dir' => 'setCacheDir',); - - if (isset($allowed[$name])) { - $this->{$allowed[$name]}($value); - } else { - trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE); - } - } - - /** - * Error Handler to mute expected messages - * - * @link http://php.net/set_error_handler - * - * @param integer $errno Error level - * @param $errstr - * @param $errfile - * @param $errline - * @param $errcontext - * - * @return boolean - */ - public static function mutingErrorHandler($errno, $errstr, $errfile, $errline, $errcontext) - { - $_is_muted_directory = false; - - // add the SMARTY_DIR to the list of muted directories - if (!isset(Smarty::$_muted_directories[SMARTY_DIR])) { - $smarty_dir = realpath(SMARTY_DIR); - if ($smarty_dir !== false) { - Smarty::$_muted_directories[SMARTY_DIR] = array('file' => $smarty_dir, - 'length' => strlen($smarty_dir),); - } - } - - // walk the muted directories and test against $errfile - foreach (Smarty::$_muted_directories as $key => &$dir) { - if (!$dir) { - // resolve directory and length for speedy comparisons - $file = realpath($key); - if ($file === false) { - // this directory does not exist, remove and skip it - unset(Smarty::$_muted_directories[$key]); - continue; - } - $dir = array('file' => $file, 'length' => strlen($file),); - } - if (!strncmp($errfile, $dir['file'], $dir['length'])) { - $_is_muted_directory = true; - break; - } - } - - // pass to next error handler if this error did not occur inside SMARTY_DIR - // or the error was within smarty but masked to be ignored - if (!$_is_muted_directory || ($errno && $errno & error_reporting())) { - if (Smarty::$_previous_error_handler) { - return call_user_func(Smarty::$_previous_error_handler, $errno, $errstr, $errfile, $errline, $errcontext); - } else { - return false; - } - } - } - - /** - * Enable error handler to mute expected messages - * - * @return void - */ - public static function muteExpectedErrors() - { - /* - error muting is done because some people implemented custom error_handlers using - http://php.net/set_error_handler and for some reason did not understand the following paragraph: - - It is important to remember that the standard PHP error handler is completely bypassed for the - error types specified by error_types unless the callback function returns FALSE. - error_reporting() settings will have no effect and your error handler will be called regardless - - however you are still able to read the current value of error_reporting and act appropriately. - Of particular note is that this value will be 0 if the statement that caused the error was - prepended by the @ error-control operator. - - Smarty deliberately uses @filemtime() over file_exists() and filemtime() in some places. Reasons include - - @filemtime() is almost twice as fast as using an additional file_exists() - - between file_exists() and filemtime() a possible race condition is opened, - which does not exist using the simple @filemtime() approach. - */ - $error_handler = array('Smarty', 'mutingErrorHandler'); - $previous = set_error_handler($error_handler); - - // avoid dead loops - if ($previous !== $error_handler) { - Smarty::$_previous_error_handler = $previous; - } - } - - /** - * Disable error handler muting expected messages - * - * @return void - */ - public static function unmuteExpectedErrors() - { - restore_error_handler(); - } -} diff --git a/www/smarty-3.1.27/SmartyBC.class.php b/www/smarty-3.1.27/SmartyBC.class.php deleted file mode 100644 index 76dd8bd0..00000000 --- a/www/smarty-3.1.27/SmartyBC.class.php +++ /dev/null @@ -1,448 +0,0 @@ - - * @author Uwe Tews - * @author Rodney Rehm - * @package Smarty - */ -/** - * @ignore - */ -require_once(dirname(__FILE__) . '/Smarty.class.php'); - -/** - * Smarty Backward Compatability Wrapper Class - * - * @package Smarty - */ -class SmartyBC extends Smarty -{ - /** - * Smarty 2 BC - * - * @var string - */ - public $_version = self::SMARTY_VERSION; - - /** - * Initialize new SmartyBC object - * - * @param array $options options to set during initialization, e.g. array( 'forceCompile' => false ) - */ - public function __construct(array $options = array()) - { - parent::__construct($options); - } - - /** - * wrapper for assign_by_ref - * - * @param string $tpl_var the template variable name - * @param mixed &$value the referenced value to assign - */ - public function assign_by_ref($tpl_var, &$value) - { - $this->assignByRef($tpl_var, $value); - } - - /** - * wrapper for append_by_ref - * - * @param string $tpl_var the template variable name - * @param mixed &$value the referenced value to append - * @param boolean $merge flag if array elements shall be merged - */ - public function append_by_ref($tpl_var, &$value, $merge = false) - { - $this->appendByRef($tpl_var, $value, $merge); - } - - /** - * clear the given assigned template variable. - * - * @param string $tpl_var the template variable to clear - */ - public function clear_assign($tpl_var) - { - $this->clearAssign($tpl_var); - } - - /** - * Registers custom function to be used in templates - * - * @param string $function the name of the template function - * @param string $function_impl the name of the PHP function to register - * @param bool $cacheable - * @param mixed $cache_attrs - */ - public function register_function($function, $function_impl, $cacheable = true, $cache_attrs = null) - { - $this->registerPlugin('function', $function, $function_impl, $cacheable, $cache_attrs); - } - - /** - * Unregisters custom function - * - * @param string $function name of template function - */ - public function unregister_function($function) - { - $this->unregisterPlugin('function', $function); - } - - /** - * Registers object to be used in templates - * - * @param string $object name of template object - * @param object $object_impl the referenced PHP object to register - * @param array $allowed list of allowed methods (empty = all) - * @param boolean $smarty_args smarty argument format, else traditional - * @param array $block_methods list of methods that are block format - * - * @throws SmartyException - * @internal param array $block_functs list of methods that are block format - */ - public function register_object($object, $object_impl, $allowed = array(), $smarty_args = true, $block_methods = array()) - { - settype($allowed, 'array'); - settype($smarty_args, 'boolean'); - $this->registerObject($object, $object_impl, $allowed, $smarty_args, $block_methods); - } - - /** - * Unregisters object - * - * @param string $object name of template object - */ - public function unregister_object($object) - { - $this->unregisterObject($object); - } - - /** - * Registers block function to be used in templates - * - * @param string $block name of template block - * @param string $block_impl PHP function to register - * @param bool $cacheable - * @param mixed $cache_attrs - */ - public function register_block($block, $block_impl, $cacheable = true, $cache_attrs = null) - { - $this->registerPlugin('block', $block, $block_impl, $cacheable, $cache_attrs); - } - - /** - * Unregisters block function - * - * @param string $block name of template function - */ - public function unregister_block($block) - { - $this->unregisterPlugin('block', $block); - } - - /** - * Registers compiler function - * - * @param string $function name of template function - * @param string $function_impl name of PHP function to register - * @param bool $cacheable - */ - public function register_compiler_function($function, $function_impl, $cacheable = true) - { - $this->registerPlugin('compiler', $function, $function_impl, $cacheable); - } - - /** - * Unregisters compiler function - * - * @param string $function name of template function - */ - public function unregister_compiler_function($function) - { - $this->unregisterPlugin('compiler', $function); - } - - /** - * Registers modifier to be used in templates - * - * @param string $modifier name of template modifier - * @param string $modifier_impl name of PHP function to register - */ - public function register_modifier($modifier, $modifier_impl) - { - $this->registerPlugin('modifier', $modifier, $modifier_impl); - } - - /** - * Unregisters modifier - * - * @param string $modifier name of template modifier - */ - public function unregister_modifier($modifier) - { - $this->unregisterPlugin('modifier', $modifier); - } - - /** - * Registers a resource to fetch a template - * - * @param string $type name of resource - * @param array $functions array of functions to handle resource - */ - public function register_resource($type, $functions) - { - $this->registerResource($type, $functions); - } - - /** - * Unregisters a resource - * - * @param string $type name of resource - */ - public function unregister_resource($type) - { - $this->unregisterResource($type); - } - - /** - * Registers a prefilter function to apply - * to a template before compiling - * - * @param callable $function - */ - public function register_prefilter($function) - { - $this->registerFilter('pre', $function); - } - - /** - * Unregisters a prefilter function - * - * @param callable $function - */ - public function unregister_prefilter($function) - { - $this->unregisterFilter('pre', $function); - } - - /** - * Registers a postfilter function to apply - * to a compiled template after compilation - * - * @param callable $function - */ - public function register_postfilter($function) - { - $this->registerFilter('post', $function); - } - - /** - * Unregisters a postfilter function - * - * @param callable $function - */ - public function unregister_postfilter($function) - { - $this->unregisterFilter('post', $function); - } - - /** - * Registers an output filter function to apply - * to a template output - * - * @param callable $function - */ - public function register_outputfilter($function) - { - $this->registerFilter('output', $function); - } - - /** - * Unregisters an outputfilter function - * - * @param callable $function - */ - public function unregister_outputfilter($function) - { - $this->unregisterFilter('output', $function); - } - - /** - * load a filter of specified type and name - * - * @param string $type filter type - * @param string $name filter name - */ - public function load_filter($type, $name) - { - $this->loadFilter($type, $name); - } - - /** - * clear cached content for the given template and cache id - * - * @param string $tpl_file name of template file - * @param string $cache_id name of cache_id - * @param string $compile_id name of compile_id - * @param string $exp_time expiration time - * - * @return boolean - */ - public function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null) - { - return $this->clearCache($tpl_file, $cache_id, $compile_id, $exp_time); - } - - /** - * clear the entire contents of cache (all templates) - * - * @param string $exp_time expire time - * - * @return boolean - */ - public function clear_all_cache($exp_time = null) - { - return $this->clearCache(null, null, null, $exp_time); - } - - /** - * test to see if valid cache exists for this template - * - * @param string $tpl_file name of template file - * @param string $cache_id - * @param string $compile_id - * - * @return boolean - */ - public function is_cached($tpl_file, $cache_id = null, $compile_id = null) - { - return $this->isCached($tpl_file, $cache_id, $compile_id); - } - - /** - * clear all the assigned template variables. - */ - public function clear_all_assign() - { - $this->clearAllAssign(); - } - - /** - * clears compiled version of specified template resource, - * or all compiled template files if one is not specified. - * This function is for advanced use only, not normally needed. - * - * @param string $tpl_file - * @param string $compile_id - * @param string $exp_time - * - * @return boolean results of {@link smarty_core_rm_auto()} - */ - public function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null) - { - return $this->clearCompiledTemplate($tpl_file, $compile_id, $exp_time); - } - - /** - * Checks whether requested template exists. - * - * @param string $tpl_file - * - * @return boolean - */ - public function template_exists($tpl_file) - { - return $this->templateExists($tpl_file); - } - - /** - * Returns an array containing template variables - * - * @param string $name - * - * @return array - */ - public function get_template_vars($name = null) - { - return $this->getTemplateVars($name); - } - - /** - * Returns an array containing config variables - * - * @param string $name - * - * @return array - */ - public function get_config_vars($name = null) - { - return $this->getConfigVars($name); - } - - /** - * load configuration values - * - * @param string $file - * @param string $section - * @param string $scope - */ - public function config_load($file, $section = null, $scope = 'global') - { - $this->ConfigLoad($file, $section, $scope); - } - - /** - * return a reference to a registered object - * - * @param string $name - * - * @return object - */ - public function get_registered_object($name) - { - return $this->getRegisteredObject($name); - } - - /** - * clear configuration values - * - * @param string $var - */ - public function clear_config($var = null) - { - $this->clearConfig($var); - } - - /** - * trigger Smarty error - * - * @param string $error_msg - * @param integer $error_type - */ - public function trigger_error($error_msg, $error_type = E_USER_WARNING) - { - trigger_error("Smarty error: $error_msg", $error_type); - } -} diff --git a/www/smarty-3.1.27/debug.tpl b/www/smarty-3.1.27/debug.tpl deleted file mode 100644 index 5b09c5bd..00000000 --- a/www/smarty-3.1.27/debug.tpl +++ /dev/null @@ -1,160 +0,0 @@ -{capture name='_smarty_debug' assign=debug_output} - - - - Smarty Debug Console - - - - -

Smarty {Smarty::SMARTY_VERSION} Debug Console - - {if isset($template_name)}{$template_name|debug_print_var nofilter} {/if}{if !empty($template_data)}Total Time {$execution_time|string_format:"%.5f"}{/if}

- - {if !empty($template_data)} -

included templates & config files (load time in seconds)

-
- {foreach $template_data as $template} - {$template.name} -
   - (compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"}) - -
- {/foreach} -
- {/if} - -

assigned template variables

- - - {foreach $assigned_vars as $vars} - - - - - {/foreach} -

${$vars@key}

- {if isset($vars['nocache'])}Nocache
{/if} - {if isset($vars['scope'])}Origin: {$vars['scope']|debug_print_var:10:80 nofilter}{/if} -

Value

{$vars['value']|debug_print_var:10:80 nofilter}
{if isset($vars['attributes'])}

Attributes

{$vars['attributes']|debug_print_var nofilter} {/if}
- -

assigned config file variables

- - - {foreach $config_vars as $vars} - - - - - {/foreach} - -

#{$vars@key}#

- {if isset($vars['scope'])}Origin: {$vars['scope']|debug_print_var:10:80 nofilter}{/if} -
{$vars['value']|debug_print_var:10:80 nofilter}
- - -{/capture} - diff --git a/www/smarty-3.1.27/plugins/block.textformat.php b/www/smarty-3.1.27/plugins/block.textformat.php deleted file mode 100644 index abf54493..00000000 --- a/www/smarty-3.1.27/plugins/block.textformat.php +++ /dev/null @@ -1,110 +0,0 @@ - - * Name: textformat
- * Purpose: format text a certain way with preset styles - * or custom wrap/indent settings
- * Params: - *
- * - style         - string (email)
- * - indent        - integer (0)
- * - wrap          - integer (80)
- * - wrap_char     - string ("\n")
- * - indent_char   - string (" ")
- * - wrap_boundary - boolean (true)
- * 
- * - * @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat} - * (Smarty online manual) - * - * @param array $params parameters - * @param string $content contents of the block - * @param Smarty_Internal_Template $template template object - * @param boolean &$repeat repeat flag - * - * @return string content re-formatted - * @author Monte Ohrt - */ -function smarty_block_textformat($params, $content, $template, &$repeat) -{ - if (is_null($content)) { - return; - } - - $style = null; - $indent = 0; - $indent_first = 0; - $indent_char = ' '; - $wrap = 80; - $wrap_char = "\n"; - $wrap_cut = false; - $assign = null; - - foreach ($params as $_key => $_val) { - switch ($_key) { - case 'style': - case 'indent_char': - case 'wrap_char': - case 'assign': - $$_key = (string) $_val; - break; - - case 'indent': - case 'indent_first': - case 'wrap': - $$_key = (int) $_val; - break; - - case 'wrap_cut': - $$_key = (bool) $_val; - break; - - default: - trigger_error("textformat: unknown attribute '$_key'"); - } - } - - if ($style == 'email') { - $wrap = 72; - } - // split into paragraphs - $_paragraphs = preg_split('![\r\n]{2}!', $content); - - foreach ($_paragraphs as &$_paragraph) { - if (!$_paragraph) { - continue; - } - // convert mult. spaces & special chars to single space - $_paragraph = preg_replace(array('!\s+!' . Smarty::$_UTF8_MODIFIER, '!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER), array(' ', ''), $_paragraph); - // indent first line - if ($indent_first > 0) { - $_paragraph = str_repeat($indent_char, $indent_first) . $_paragraph; - } - // wordwrap sentences - if (Smarty::$_MBSTRING) { - require_once(SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php'); - $_paragraph = smarty_mb_wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut); - } else { - $_paragraph = wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut); - } - // indent lines - if ($indent > 0) { - $_paragraph = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraph); - } - } - $_output = implode($wrap_char . $wrap_char, $_paragraphs); - - if ($assign) { - $template->assign($assign, $_output); - } else { - return $_output; - } -} diff --git a/www/smarty-3.1.27/plugins/function.counter.php b/www/smarty-3.1.27/plugins/function.counter.php deleted file mode 100644 index 4da85a14..00000000 --- a/www/smarty-3.1.27/plugins/function.counter.php +++ /dev/null @@ -1,78 +0,0 @@ - - * Name: counter
- * Purpose: print out a counter value - * - * @author Monte Ohrt - * @link http://www.smarty.net/manual/en/language.function.counter.php {counter} - * (Smarty online manual) - * - * @param array $params parameters - * @param Smarty_Internal_Template $template template object - * - * @return string|null - */ -function smarty_function_counter($params, $template) -{ - static $counters = array(); - - $name = (isset($params['name'])) ? $params['name'] : 'default'; - if (!isset($counters[$name])) { - $counters[$name] = array( - 'start' => 1, - 'skip' => 1, - 'direction' => 'up', - 'count' => 1 - ); - } - $counter =& $counters[$name]; - - if (isset($params['start'])) { - $counter['start'] = $counter['count'] = (int) $params['start']; - } - - if (!empty($params['assign'])) { - $counter['assign'] = $params['assign']; - } - - if (isset($counter['assign'])) { - $template->assign($counter['assign'], $counter['count']); - } - - if (isset($params['print'])) { - $print = (bool) $params['print']; - } else { - $print = empty($counter['assign']); - } - - if ($print) { - $retval = $counter['count']; - } else { - $retval = null; - } - - if (isset($params['skip'])) { - $counter['skip'] = $params['skip']; - } - - if (isset($params['direction'])) { - $counter['direction'] = $params['direction']; - } - - if ($counter['direction'] == "down") { - $counter['count'] -= $counter['skip']; - } else { - $counter['count'] += $counter['skip']; - } - - return $retval; -} diff --git a/www/smarty-3.1.27/plugins/function.cycle.php b/www/smarty-3.1.27/plugins/function.cycle.php deleted file mode 100644 index 8dc5cd9d..00000000 --- a/www/smarty-3.1.27/plugins/function.cycle.php +++ /dev/null @@ -1,107 +0,0 @@ - - * Name: cycle
- * Date: May 3, 2002
- * Purpose: cycle through given values
- * Params: - *
- * - name      - name of cycle (optional)
- * - values    - comma separated list of values to cycle, or an array of values to cycle
- *               (this can be left out for subsequent calls)
- * - reset     - boolean - resets given var to true
- * - print     - boolean - print var or not. default is true
- * - advance   - boolean - whether or not to advance the cycle
- * - delimiter - the value delimiter, default is ","
- * - assign    - boolean, assigns to template var instead of printed.
- * 
- * Examples:
- *
- * {cycle values="#eeeeee,#d0d0d0d"}
- * {cycle name=row values="one,two,three" reset=true}
- * {cycle name=row}
- * 
- * - * @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle} - * (Smarty online manual) - * @author Monte Ohrt - * @author credit to Mark Priatel - * @author credit to Gerard - * @author credit to Jason Sweat - * @version 1.3 - * - * @param array $params parameters - * @param Smarty_Internal_Template $template template object - * - * @return string|null - */ - -function smarty_function_cycle($params, $template) -{ - static $cycle_vars; - - $name = (empty($params['name'])) ? 'default' : $params['name']; - $print = (isset($params['print'])) ? (bool) $params['print'] : true; - $advance = (isset($params['advance'])) ? (bool) $params['advance'] : true; - $reset = (isset($params['reset'])) ? (bool) $params['reset'] : false; - - if (!isset($params['values'])) { - if (!isset($cycle_vars[$name]['values'])) { - trigger_error("cycle: missing 'values' parameter"); - - return; - } - } else { - if (isset($cycle_vars[$name]['values']) - && $cycle_vars[$name]['values'] != $params['values'] - ) { - $cycle_vars[$name]['index'] = 0; - } - $cycle_vars[$name]['values'] = $params['values']; - } - - if (isset($params['delimiter'])) { - $cycle_vars[$name]['delimiter'] = $params['delimiter']; - } elseif (!isset($cycle_vars[$name]['delimiter'])) { - $cycle_vars[$name]['delimiter'] = ','; - } - - if (is_array($cycle_vars[$name]['values'])) { - $cycle_array = $cycle_vars[$name]['values']; - } else { - $cycle_array = explode($cycle_vars[$name]['delimiter'], $cycle_vars[$name]['values']); - } - - if (!isset($cycle_vars[$name]['index']) || $reset) { - $cycle_vars[$name]['index'] = 0; - } - - if (isset($params['assign'])) { - $print = false; - $template->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]); - } - - if ($print) { - $retval = $cycle_array[$cycle_vars[$name]['index']]; - } else { - $retval = null; - } - - if ($advance) { - if ($cycle_vars[$name]['index'] >= count($cycle_array) - 1) { - $cycle_vars[$name]['index'] = 0; - } else { - $cycle_vars[$name]['index'] ++; - } - } - - return $retval; -} diff --git a/www/smarty-3.1.27/plugins/function.fetch.php b/www/smarty-3.1.27/plugins/function.fetch.php deleted file mode 100644 index 3506d4a8..00000000 --- a/www/smarty-3.1.27/plugins/function.fetch.php +++ /dev/null @@ -1,221 +0,0 @@ - - * Name: fetch
- * Purpose: fetch file, web or ftp data and display results - * - * @link http://www.smarty.net/manual/en/language.function.fetch.php {fetch} - * (Smarty online manual) - * @author Monte Ohrt - * - * @param array $params parameters - * @param Smarty_Internal_Template $template template object - * - * @throws SmartyException - * @return string|null if the assign parameter is passed, Smarty assigns the result to a template variable - */ -function smarty_function_fetch($params, $template) -{ - if (empty($params['file'])) { - trigger_error("[plugin] fetch parameter 'file' cannot be empty", E_USER_NOTICE); - - return; - } - - // strip file protocol - if (stripos($params['file'], 'file://') === 0) { - $params['file'] = substr($params['file'], 7); - } - - $protocol = strpos($params['file'], '://'); - if ($protocol !== false) { - $protocol = strtolower(substr($params['file'], 0, $protocol)); - } - - if (isset($template->smarty->security_policy)) { - if ($protocol) { - // remote resource (or php stream, …) - if (!$template->smarty->security_policy->isTrustedUri($params['file'])) { - return; - } - } else { - // local file - if (!$template->smarty->security_policy->isTrustedResourceDir($params['file'])) { - return; - } - } - } - - $content = ''; - if ($protocol == 'http') { - // http fetch - if ($uri_parts = parse_url($params['file'])) { - // set defaults - $host = $server_name = $uri_parts['host']; - $timeout = 30; - $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; - $agent = "Smarty Template Engine " . Smarty::SMARTY_VERSION; - $referer = ""; - $uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/'; - $uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : ''; - $_is_proxy = false; - if (empty($uri_parts['port'])) { - $port = 80; - } else { - $port = $uri_parts['port']; - } - if (!empty($uri_parts['user'])) { - $user = $uri_parts['user']; - } - if (!empty($uri_parts['pass'])) { - $pass = $uri_parts['pass']; - } - // loop through parameters, setup headers - foreach ($params as $param_key => $param_value) { - switch ($param_key) { - case "file": - case "assign": - case "assign_headers": - break; - case "user": - if (!empty($param_value)) { - $user = $param_value; - } - break; - case "pass": - if (!empty($param_value)) { - $pass = $param_value; - } - break; - case "accept": - if (!empty($param_value)) { - $accept = $param_value; - } - break; - case "header": - if (!empty($param_value)) { - if (!preg_match('![\w\d-]+: .+!', $param_value)) { - trigger_error("[plugin] invalid header format '" . $param_value . "'", E_USER_NOTICE); - - return; - } else { - $extra_headers[] = $param_value; - } - } - break; - case "proxy_host": - if (!empty($param_value)) { - $proxy_host = $param_value; - } - break; - case "proxy_port": - if (!preg_match('!\D!', $param_value)) { - $proxy_port = (int) $param_value; - } else { - trigger_error("[plugin] invalid value for attribute '" . $param_key . "'", E_USER_NOTICE); - - return; - } - break; - case "agent": - if (!empty($param_value)) { - $agent = $param_value; - } - break; - case "referer": - if (!empty($param_value)) { - $referer = $param_value; - } - break; - case "timeout": - if (!preg_match('!\D!', $param_value)) { - $timeout = (int) $param_value; - } else { - trigger_error("[plugin] invalid value for attribute '" . $param_key . "'", E_USER_NOTICE); - - return; - } - break; - default: - trigger_error("[plugin] unrecognized attribute '" . $param_key . "'", E_USER_NOTICE); - - return; - } - } - if (!empty($proxy_host) && !empty($proxy_port)) { - $_is_proxy = true; - $fp = fsockopen($proxy_host, $proxy_port, $errno, $errstr, $timeout); - } else { - $fp = fsockopen($server_name, $port, $errno, $errstr, $timeout); - } - - if (!$fp) { - trigger_error("[plugin] unable to fetch: $errstr ($errno)", E_USER_NOTICE); - - return; - } else { - if ($_is_proxy) { - fputs($fp, 'GET ' . $params['file'] . " HTTP/1.0\r\n"); - } else { - fputs($fp, "GET $uri HTTP/1.0\r\n"); - } - if (!empty($host)) { - fputs($fp, "Host: $host\r\n"); - } - if (!empty($accept)) { - fputs($fp, "Accept: $accept\r\n"); - } - if (!empty($agent)) { - fputs($fp, "User-Agent: $agent\r\n"); - } - if (!empty($referer)) { - fputs($fp, "Referer: $referer\r\n"); - } - if (isset($extra_headers) && is_array($extra_headers)) { - foreach ($extra_headers as $curr_header) { - fputs($fp, $curr_header . "\r\n"); - } - } - if (!empty($user) && !empty($pass)) { - fputs($fp, "Authorization: BASIC " . base64_encode("$user:$pass") . "\r\n"); - } - - fputs($fp, "\r\n"); - while (!feof($fp)) { - $content .= fgets($fp, 4096); - } - fclose($fp); - $csplit = preg_split("!\r\n\r\n!", $content, 2); - - $content = $csplit[1]; - - if (!empty($params['assign_headers'])) { - $template->assign($params['assign_headers'], preg_split("!\r\n!", $csplit[0])); - } - } - } else { - trigger_error("[plugin fetch] unable to parse URL, check syntax", E_USER_NOTICE); - - return; - } - } else { - $content = @file_get_contents($params['file']); - if ($content === false) { - throw new SmartyException("{fetch} cannot read resource '" . $params['file'] . "'"); - } - } - - if (!empty($params['assign'])) { - $template->assign($params['assign'], $content); - } else { - return $content; - } -} diff --git a/www/smarty-3.1.27/plugins/function.html_image.php b/www/smarty-3.1.27/plugins/function.html_image.php deleted file mode 100644 index 5037e8bd..00000000 --- a/www/smarty-3.1.27/plugins/function.html_image.php +++ /dev/null @@ -1,163 +0,0 @@ - - * Name: html_image
- * Date: Feb 24, 2003
- * Purpose: format HTML tags for the image
- * Examples: {html_image file="/images/masthead.gif"}
- * Output:
- * Params: - *
- * - file        - (required) - file (and path) of image
- * - height      - (optional) - image height (default actual height)
- * - width       - (optional) - image width (default actual width)
- * - basedir     - (optional) - base directory for absolute paths, default is environment variable DOCUMENT_ROOT
- * - path_prefix - prefix for path output (optional, default empty)
- * 
- * - * @link http://www.smarty.net/manual/en/language.function.html.image.php {html_image} - * (Smarty online manual) - * @author Monte Ohrt - * @author credits to Duda - * @version 1.0 - * - * @param array $params parameters - * @param Smarty_Internal_Template $template template object - * - * @throws SmartyException - * @return string - * @uses smarty_function_escape_special_chars() - */ -function smarty_function_html_image($params, $template) -{ - require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); - - $alt = ''; - $file = ''; - $height = ''; - $width = ''; - $extra = ''; - $prefix = ''; - $suffix = ''; - $path_prefix = ''; - $basedir = isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : ''; - foreach ($params as $_key => $_val) { - switch ($_key) { - case 'file': - case 'height': - case 'width': - case 'dpi': - case 'path_prefix': - case 'basedir': - $$_key = $_val; - break; - - case 'alt': - if (!is_array($_val)) { - $$_key = smarty_function_escape_special_chars($_val); - } else { - throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); - } - break; - - case 'link': - case 'href': - $prefix = '
'; - $suffix = ''; - break; - - default: - if (!is_array($_val)) { - $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"'; - } else { - throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); - } - break; - } - } - - if (empty($file)) { - trigger_error("html_image: missing 'file' parameter", E_USER_NOTICE); - - return; - } - - if ($file[0] == '/') { - $_image_path = $basedir . $file; - } else { - $_image_path = $file; - } - - // strip file protocol - if (stripos($params['file'], 'file://') === 0) { - $params['file'] = substr($params['file'], 7); - } - - $protocol = strpos($params['file'], '://'); - if ($protocol !== false) { - $protocol = strtolower(substr($params['file'], 0, $protocol)); - } - - if (isset($template->smarty->security_policy)) { - if ($protocol) { - // remote resource (or php stream, …) - if (!$template->smarty->security_policy->isTrustedUri($params['file'])) { - return; - } - } else { - // local file - if (!$template->smarty->security_policy->isTrustedResourceDir($_image_path)) { - return; - } - } - } - - if (!isset($params['width']) || !isset($params['height'])) { - // FIXME: (rodneyrehm) getimagesize() loads the complete file off a remote resource, use custom [jpg,png,gif]header reader! - if (!$_image_data = @getimagesize($_image_path)) { - if (!file_exists($_image_path)) { - trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE); - - return; - } elseif (!is_readable($_image_path)) { - trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE); - - return; - } else { - trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE); - - return; - } - } - - if (!isset($params['width'])) { - $width = $_image_data[0]; - } - if (!isset($params['height'])) { - $height = $_image_data[1]; - } - } - - if (isset($params['dpi'])) { - if (strstr($_SERVER['HTTP_USER_AGENT'], 'Mac')) { - // FIXME: (rodneyrehm) wrong dpi assumption - // don't know who thought this up… even if it was true in 1998, it's definitely wrong in 2011. - $dpi_default = 72; - } else { - $dpi_default = 96; - } - $_resize = $dpi_default / $params['dpi']; - $width = round($width * $_resize); - $height = round($height * $_resize); - } - - return $prefix . '' . $alt . '' . $suffix; -} diff --git a/www/smarty-3.1.27/plugins/function.html_radios.php b/www/smarty-3.1.27/plugins/function.html_radios.php deleted file mode 100644 index f121d5ea..00000000 --- a/www/smarty-3.1.27/plugins/function.html_radios.php +++ /dev/null @@ -1,221 +0,0 @@ - - * Type: function
- * Name: html_radios
- * Date: 24.Feb.2003
- * Purpose: Prints out a list of radio input types
- * Params: - *
- * - name       (optional) - string default "radio"
- * - values     (required) - array
- * - options    (required) - associative array
- * - checked    (optional) - array default not set
- * - separator  (optional) - ie 
or   - * - output (optional) - the output next to each radio button - * - assign (optional) - assign the output as an array to this variable - * - escape (optional) - escape the content (not value), defaults to true - *
- * Examples: - *
- * {html_radios values=$ids output=$names}
- * {html_radios values=$ids name='box' separator='
' output=$names} - * {html_radios values=$ids checked=$checked separator='
' output=$names} - *
- * - * @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios} - * (Smarty online manual) - * @author Christopher Kvarme - * @author credits to Monte Ohrt - * @version 1.0 - * - * @param array $params parameters - * @param Smarty_Internal_Template $template template object - * - * @return string - * @uses smarty_function_escape_special_chars() - */ -function smarty_function_html_radios($params, $template) -{ - require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); - - $name = 'radio'; - $values = null; - $options = null; - $selected = null; - $separator = ''; - $escape = true; - $labels = true; - $label_ids = false; - $output = null; - $extra = ''; - - foreach ($params as $_key => $_val) { - switch ($_key) { - case 'name': - case 'separator': - $$_key = (string) $_val; - break; - - case 'checked': - case 'selected': - if (is_array($_val)) { - trigger_error('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING); - } elseif (is_object($_val)) { - if (method_exists($_val, "__toString")) { - $selected = smarty_function_escape_special_chars((string) $_val->__toString()); - } else { - trigger_error("html_radios: selected attribute is an object of class '" . get_class($_val) . "' without __toString() method", E_USER_NOTICE); - } - } else { - $selected = (string) $_val; - } - break; - - case 'escape': - case 'labels': - case 'label_ids': - $$_key = (bool) $_val; - break; - - case 'options': - $$_key = (array) $_val; - break; - - case 'values': - case 'output': - $$_key = array_values((array) $_val); - break; - - case 'radios': - trigger_error('html_radios: the use of the "radios" attribute is deprecated, use "options" instead', E_USER_WARNING); - $options = (array) $_val; - break; - - case 'assign': - break; - - case 'strict': - break; - - case 'disabled': - case 'readonly': - if (!empty($params['strict'])) { - if (!is_scalar($_val)) { - trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute", E_USER_NOTICE); - } - - if ($_val === true || $_val === $_key) { - $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"'; - } - - break; - } - // omit break; to fall through! - - default: - if (!is_array($_val)) { - $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"'; - } else { - trigger_error("html_radios: extra attribute '$_key' cannot be an array", E_USER_NOTICE); - } - break; - } - } - - if (!isset($options) && !isset($values)) { - /* raise error here? */ - - return ''; - } - - $_html_result = array(); - - if (isset($options)) { - foreach ($options as $_key => $_val) { - $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids, $escape); - } - } else { - foreach ($values as $_i => $_key) { - $_val = isset($output[$_i]) ? $output[$_i] : ''; - $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids, $escape); - } - } - - if (!empty($params['assign'])) { - $template->assign($params['assign'], $_html_result); - } else { - return implode("\n", $_html_result); - } -} - -function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids, $escape) -{ - $_output = ''; - - if (is_object($value)) { - if (method_exists($value, "__toString")) { - $value = (string) $value->__toString(); - } else { - trigger_error("html_options: value is an object of class '" . get_class($value) . "' without __toString() method", E_USER_NOTICE); - - return ''; - } - } else { - $value = (string) $value; - } - - if (is_object($output)) { - if (method_exists($output, "__toString")) { - $output = (string) $output->__toString(); - } else { - trigger_error("html_options: output is an object of class '" . get_class($output) . "' without __toString() method", E_USER_NOTICE); - - return ''; - } - } else { - $output = (string) $output; - } - - if ($labels) { - if ($label_ids) { - $_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_', $name . '_' . $value)); - $_output .= '
\n"; - } - - return $status; - } -} diff --git a/www/smarty-3.1.27/sysplugins/smarty_internal_utility.php b/www/smarty-3.1.27/sysplugins/smarty_internal_utility.php deleted file mode 100644 index cd027dec..00000000 --- a/www/smarty-3.1.27/sysplugins/smarty_internal_utility.php +++ /dev/null @@ -1,303 +0,0 @@ - - * @author Uwe Tews - * @package Smarty - * @subpackage PluginsInternal - * @version 3-SVN$Rev: 3286 $ - */ - -/** - * Utility class - * - * @package Smarty - * @subpackage Security - */ -class Smarty_Internal_Utility -{ - /** - * private constructor to prevent calls creation of new instances - */ - final private function __construct() - { - // intentionally left blank - } - - /** - * Compile all template files - * - * @param string $extension template file name extension - * @param bool $force_compile force all to recompile - * @param int $time_limit set maximum execution time - * @param int $max_errors set maximum allowed errors - * @param Smarty $smarty Smarty instance - * - * @return integer number of template files compiled - */ - public static function compileAllTemplates($extension, $force_compile, $time_limit, $max_errors, Smarty $smarty) - { - // switch off time limit - if (function_exists('set_time_limit')) { - @set_time_limit($time_limit); - } - $smarty->force_compile = $force_compile; - $_count = 0; - $_error_count = 0; - // loop over array of template directories - foreach ($smarty->getTemplateDir() as $_dir) { - $_compileDirs = new RecursiveDirectoryIterator($_dir); - $_compile = new RecursiveIteratorIterator($_compileDirs); - foreach ($_compile as $_fileinfo) { - $_file = $_fileinfo->getFilename(); - if (substr(basename($_fileinfo->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) { - continue; - } - if (!substr_compare($_file, $extension, - strlen($extension)) == 0) { - continue; - } - if ($_fileinfo->getPath() == substr($_dir, 0, - 1)) { - $_template_file = $_file; - } else { - $_template_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file; - } - echo '
', $_dir, '---', $_template_file; - flush(); - $_start_time = microtime(true); - try { - $_tpl = $smarty->createTemplate($_template_file, null, null, null, false); - if ($_tpl->mustCompile()) { - $_tpl->compileTemplateSource(); - $_count ++; - echo ' compiled in ', microtime(true) - $_start_time, ' seconds'; - flush(); - } else { - echo ' is up to date'; - flush(); - } - } - catch (Exception $e) { - echo 'Error: ', $e->getMessage(), "

"; - $_error_count ++; - } - // free memory - $smarty->template_objects = array(); - $_tpl->smarty->template_objects = array(); - $_tpl = null; - if ($max_errors !== null && $_error_count == $max_errors) { - echo '

too many errors'; - exit(); - } - } - } - - return $_count; - } - - /** - * Compile all config files - * - * @param string $extension config file name extension - * @param bool $force_compile force all to recompile - * @param int $time_limit set maximum execution time - * @param int $max_errors set maximum allowed errors - * @param Smarty $smarty Smarty instance - * - * @return integer number of config files compiled - */ - public static function compileAllConfig($extension, $force_compile, $time_limit, $max_errors, Smarty $smarty) - { - // switch off time limit - if (function_exists('set_time_limit')) { - @set_time_limit($time_limit); - } - $smarty->force_compile = $force_compile; - $_count = 0; - $_error_count = 0; - // loop over array of template directories - foreach ($smarty->getConfigDir() as $_dir) { - $_compileDirs = new RecursiveDirectoryIterator($_dir); - $_compile = new RecursiveIteratorIterator($_compileDirs); - foreach ($_compile as $_fileinfo) { - $_file = $_fileinfo->getFilename(); - if (substr(basename($_fileinfo->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) { - continue; - } - if (!substr_compare($_file, $extension, - strlen($extension)) == 0) { - continue; - } - if ($_fileinfo->getPath() == substr($_dir, 0, - 1)) { - $_config_file = $_file; - } else { - $_config_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file; - } - echo '
', $_dir, '---', $_config_file; - flush(); - $_start_time = microtime(true); - try { - $_config = new Smarty_Internal_Config($_config_file, $smarty); - if ($_config->mustCompile()) { - $_config->compileConfigSource(); - $_count ++; - echo ' compiled in ', microtime(true) - $_start_time, ' seconds'; - flush(); - } else { - echo ' is up to date'; - flush(); - } - } - catch (Exception $e) { - echo 'Error: ', $e->getMessage(), "

"; - $_error_count ++; - } - if ($max_errors !== null && $_error_count == $max_errors) { - echo '

too many errors'; - exit(); - } - } - } - - return $_count; - } - - /** - * Delete compiled template file - * - * @param string $resource_name template name - * @param string $compile_id compile id - * @param integer $exp_time expiration time - * @param Smarty $smarty Smarty instance - * - * @return integer number of template files deleted - */ - public static function clearCompiledTemplate($resource_name, $compile_id, $exp_time, Smarty $smarty) - { - $_compile_dir = realpath($smarty->getCompileDir()) . '/'; - if ($_compile_dir == '/') { //We should never want to delete this! - return 0; - } - $_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null; - $_dir_sep = $smarty->use_sub_dirs ? '/' : '^'; - if (isset($resource_name)) { - $_save_stat = $smarty->caching; - $smarty->caching = false; - $tpl = new $smarty->template_class($resource_name, $smarty); - $smarty->caching = $_save_stat; - - // remove from template cache - $tpl->source; // have the template registered before unset() - if ($smarty->allow_ambiguous_resources) { - $_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id; - } else { - $_templateId = $smarty->joined_template_dir . '#' . $resource_name . $tpl->cache_id . $tpl->compile_id; - } - if (isset($_templateId[150])) { - $_templateId = sha1($_templateId); - } - unset($smarty->template_objects[$_templateId]); - - if ($tpl->source->exists) { - $_resource_part_1 = basename(str_replace('^', '/', $tpl->compiled->filepath)); - $_resource_part_1_length = strlen($_resource_part_1); - } else { - return 0; - } - - $_resource_part_2 = str_replace('.php', '.cache.php', $_resource_part_1); - $_resource_part_2_length = strlen($_resource_part_2); - } - $_dir = $_compile_dir; - if ($smarty->use_sub_dirs && isset($_compile_id)) { - $_dir .= $_compile_id . $_dir_sep; - } - if (isset($_compile_id)) { - $_compile_id_part = str_replace('\\', '/', $_compile_dir . $_compile_id . $_dir_sep); - $_compile_id_part_length = strlen($_compile_id_part); - } - $_count = 0; - try { - $_compileDirs = new RecursiveDirectoryIterator($_dir); - // NOTE: UnexpectedValueException thrown for PHP >= 5.3 - } - catch (Exception $e) { - return 0; - } - $_compile = new RecursiveIteratorIterator($_compileDirs, RecursiveIteratorIterator::CHILD_FIRST); - foreach ($_compile as $_file) { - if (substr(basename($_file->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) { - continue; - } - - $_filepath = str_replace('\\', '/', (string) $_file); - - if ($_file->isDir()) { - if (!$_compile->isDot()) { - // delete folder if empty - @rmdir($_file->getPathname()); - } - } else { - $unlink = false; - if ((!isset($_compile_id) || (isset($_filepath[$_compile_id_part_length]) && $a = !strncmp($_filepath, $_compile_id_part, $_compile_id_part_length))) - && (!isset($resource_name) - || (isset($_filepath[$_resource_part_1_length]) - && substr_compare($_filepath, $_resource_part_1, - $_resource_part_1_length, $_resource_part_1_length) == 0) - || (isset($_filepath[$_resource_part_2_length]) - && substr_compare($_filepath, $_resource_part_2, - $_resource_part_2_length, $_resource_part_2_length) == 0)) - ) { - if (isset($exp_time)) { - if (time() - @filemtime($_filepath) >= $exp_time) { - $unlink = true; - } - } else { - $unlink = true; - } - } - - if ($unlink && @unlink($_filepath)) { - $_count ++; - } - } - } - // clear compiled cache - Smarty_Resource::$sources = array(); - Smarty_Resource::$compileds = array(); - - return $_count; - } - - /** - * Return array of tag/attributes of all tags used by an template - * - * @param Smarty_Internal_Template $template - * - * @throws Exception - * @throws SmartyException - * @return array of tag/attributes - */ - public static function getTags(Smarty_Internal_Template $template) - { - $template->smarty->get_used_tags = true; - $template->compileTemplateSource(); - - return $template->used_tags; - } -} diff --git a/www/smarty-3.1.27/sysplugins/smarty_internal_write_file.php b/www/smarty-3.1.27/sysplugins/smarty_internal_write_file.php deleted file mode 100644 index 9ecc7c0c..00000000 --- a/www/smarty-3.1.27/sysplugins/smarty_internal_write_file.php +++ /dev/null @@ -1,88 +0,0 @@ -_file_perms !== null) { - $old_umask = umask(0); - } - - $_dirpath = dirname($_filepath); - // if subdirs, create dir structure - if ($_dirpath !== '.' && !file_exists($_dirpath)) { - mkdir($_dirpath, $smarty->_dir_perms === null ? 0777 : $smarty->_dir_perms, true); - } - - // write to tmp file, then move to overt file lock race condition - $_tmp_file = $_dirpath . DS . str_replace(array('.', ','), '_', uniqid('wrt', true)); - if (!file_put_contents($_tmp_file, $_contents)) { - error_reporting($_error_reporting); - throw new SmartyException("unable to write file {$_tmp_file}"); - } - - /* - * Windows' rename() fails if the destination exists, - * Linux' rename() properly handles the overwrite. - * Simply unlink()ing a file might cause other processes - * currently reading that file to fail, but linux' rename() - * seems to be smart enough to handle that for us. - */ - if (Smarty::$_IS_WINDOWS) { - // remove original file - if (is_file($_filepath)) { - @unlink($_filepath); - } - // rename tmp file - $success = @rename($_tmp_file, $_filepath); - } else { - // rename tmp file - $success = @rename($_tmp_file, $_filepath); - if (!$success) { - // remove original file - if (is_file($_filepath)) { - @unlink($_filepath); - } - // rename tmp file - $success = @rename($_tmp_file, $_filepath); - } - } - if (!$success) { - error_reporting($_error_reporting); - throw new SmartyException("unable to write file {$_filepath}"); - } - if ($smarty->_file_perms !== null) { - // set file permissions - chmod($_filepath, $smarty->_file_perms); - umask($old_umask); - } - error_reporting($_error_reporting); - - return true; - } -} diff --git a/www/smarty-3.1.27/sysplugins/smarty_resource.php b/www/smarty-3.1.27/sysplugins/smarty_resource.php deleted file mode 100644 index 5d5e368d..00000000 --- a/www/smarty-3.1.27/sysplugins/smarty_resource.php +++ /dev/null @@ -1,284 +0,0 @@ - 'smarty_internal_resource_file.php', - 'string' => 'smarty_internal_resource_string.php', - 'extends' => 'smarty_internal_resource_extends.php', - 'stream' => 'smarty_internal_resource_stream.php', - 'eval' => 'smarty_internal_resource_eval.php', - 'php' => 'smarty_internal_resource_php.php' - ); - - /** - * Name of the Class to compile this resource's contents with - * - * @var string - */ - public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler'; - - /** - * Name of the Class to tokenize this resource's contents with - * - * @var string - */ - public $template_lexer_class = 'Smarty_Internal_Templatelexer'; - - /** - * Name of the Class to parse this resource's contents with - * - * @var string - */ - public $template_parser_class = 'Smarty_Internal_Templateparser'; - - /** - * Load template's source into current template object - * {@internal The loaded source is assigned to $_template->source->content directly.}} - * - * @param Smarty_Template_Source $source source object - * - * @return string template source - * @throws SmartyException if source cannot be loaded - */ - abstract public function getContent(Smarty_Template_Source $source); - - /** - * populate Source Object with meta data from Resource - * - * @param Smarty_Template_Source $source source object - * @param Smarty_Internal_Template $_template template object - */ - abstract public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null); - - /** - * populate Source Object with timestamp and exists from Resource - * - * @param Smarty_Template_Source $source source object - */ - public function populateTimestamp(Smarty_Template_Source $source) - { - // intentionally left blank - } - - /** - * modify resource_name according to resource handlers specifications - * - * @param Smarty $smarty Smarty instance - * @param string $resource_name resource_name to make unique - * @param boolean $isConfig flag for config resource - * - * @return string unique resource name - */ - public function buildUniqueResourceName(Smarty $smarty, $resource_name, $isConfig = false) - { - if ($isConfig) { - return get_class($this) . '#' . $smarty->joined_config_dir . '#' . $resource_name; - } else { - return get_class($this) . '#' . $smarty->joined_template_dir . '#' . $resource_name; - } - } - - /** - * Determine basename for compiled filename - * - * @param Smarty_Template_Source $source source object - * - * @return string resource's basename - */ - public function getBasename(Smarty_Template_Source $source) - { - return null; - } - - /** - * Load Resource Handler - * - * @param Smarty $smarty smarty object - * @param string $type name of the resource - * - * @throws SmartyException - * @return Smarty_Resource Resource Handler - */ - public static function load(Smarty $smarty, $type) - { - // try smarty's cache - if (isset($smarty->_resource_handlers[$type])) { - return $smarty->_resource_handlers[$type]; - } - - // try registered resource - if (isset($smarty->registered_resources[$type])) { - if ($smarty->registered_resources[$type] instanceof Smarty_Resource) { - $smarty->_resource_handlers[$type] = $smarty->registered_resources[$type]; - } else { - $smarty->_resource_handlers[$type] = new Smarty_Internal_Resource_Registered(); - } - - return $smarty->_resource_handlers[$type]; - } - - // try sysplugins dir - if (isset(self::$sysplugins[$type])) { - $_resource_class = 'Smarty_Internal_Resource_' . ucfirst($type); - if (!class_exists($_resource_class, false)) { - require SMARTY_SYSPLUGINS_DIR . self::$sysplugins[$type]; - } - return $smarty->_resource_handlers[$type] = new $_resource_class(); - } - - // try plugins dir - $_resource_class = 'Smarty_Resource_' . ucfirst($type); - if ($smarty->loadPlugin($_resource_class)) { - if (class_exists($_resource_class, false)) { - return $smarty->_resource_handlers[$type] = new $_resource_class(); - } else { - $smarty->registerResource($type, array( - "smarty_resource_{$type}_source", - "smarty_resource_{$type}_timestamp", - "smarty_resource_{$type}_secure", - "smarty_resource_{$type}_trusted" - )); - // give it another try, now that the resource is registered properly - return self::load($smarty, $type); - } - } - - // try streams - $_known_stream = stream_get_wrappers(); - if (in_array($type, $_known_stream)) { - // is known stream - if (is_object($smarty->security_policy)) { - $smarty->security_policy->isTrustedStream($type); - } - return $smarty->_resource_handlers[$type] = new Smarty_Internal_Resource_Stream();; - } - - // TODO: try default_(template|config)_handler - - // give up - throw new SmartyException("Unknown resource type '{$type}'"); - } - - /** - * extract resource_type and resource_name from template_resource and config_resource - * @note "C:/foo.tpl" was forced to file resource up till Smarty 3.1.3 (including). - * - * @param string $resource_name template_resource or config_resource to parse - * @param string $default_resource the default resource_type defined in $smarty - * - * @return array with parsed resource name and type - */ - public static function parseResourceName($resource_name, $default_resource) - { - if (preg_match('/^([A-Za-z0-9_\-]{2,})[:]/', $resource_name, $match)) { - $type = $match[1]; - $name = substr($resource_name, strlen($match[0])); - } else { - // no resource given, use default - // or single character before the colon is not a resource type, but part of the filepath - $type = $default_resource; - $name = $resource_name; - - } - return array($name, $type); - } - - /** - * modify resource_name according to resource handlers specifications - * - * @param Smarty $smarty Smarty instance - * @param string $resource_name resource_name to make unique - * - * @return string unique resource name - */ - - /** - * modify template_resource according to resource handlers specifications - * - * @param Smarty_Internal_template $template Smarty instance - * @param string $template_resource template_resource to extract resource handler and name of - * - * @return string unique resource name - */ - public static function getUniqueTemplateName($template, $template_resource) - { - $smarty = isset($template->smarty) ? $template->smarty : $template; - list($name, $type) = self::parseResourceName($template_resource, $smarty->default_resource_type); - // TODO: optimize for Smarty's internal resource types - $resource = Smarty_Resource::load($smarty, $type); - // go relative to a given template? - $_file_is_dotted = $name[0] == '.' && ($name[1] == '.' || $name[1] == '/'); - if ($template instanceof Smarty_Internal_Template && $_file_is_dotted && ($template->source->type == 'file' || $template->parent->source->type == 'extends')) { - $name = dirname($template->source->filepath) . DS . $name; - } - return $resource->buildUniqueResourceName($smarty, $name); - } - - /** - * initialize Source Object for given resource - * wrapper for backward compatibility to versions < 3.1.22 - * Either [$_template] or [$smarty, $template_resource] must be specified - * - * @param Smarty_Internal_Template $_template template object - * @param Smarty $smarty smarty object - * @param string $template_resource resource identifier - * - * @return Smarty_Template_Source Source Object - */ - public static function source(Smarty_Internal_Template $_template = null, Smarty $smarty = null, $template_resource = null) - { - return Smarty_Template_Source::load($_template, $smarty, $template_resource); - } -} - diff --git a/www/smarty-3.1.27/sysplugins/smarty_resource_recompiled.php b/www/smarty-3.1.27/sysplugins/smarty_resource_recompiled.php deleted file mode 100644 index c823387b..00000000 --- a/www/smarty-3.1.27/sysplugins/smarty_resource_recompiled.php +++ /dev/null @@ -1,40 +0,0 @@ -filepath = false; - $compiled->timestamp = false; - $compiled->exists = false; - } -} diff --git a/www/smarty-3.1.27/sysplugins/smarty_resource_uncompiled.php b/www/smarty-3.1.27/sysplugins/smarty_resource_uncompiled.php deleted file mode 100644 index a52d86e8..00000000 --- a/www/smarty-3.1.27/sysplugins/smarty_resource_uncompiled.php +++ /dev/null @@ -1,72 +0,0 @@ -filepath = false; - $compiled->timestamp = false; - $compiled->exists = false; - } - - /** - * render compiled template code - * - * @param Smarty_Internal_Template $_template - * - * @return string - * @throws Exception - */ - public function render($_template) - { - $level = ob_get_level(); - ob_start(); - try { - $this->renderUncompiled($_template->source, $_template); - return ob_get_clean(); - } - catch (Exception $e) { - while (ob_get_level() > $level) { - ob_end_clean(); - } - throw $e; - } - } -} diff --git a/www/smarty-3.1.27/sysplugins/smarty_security.php b/www/smarty-3.1.27/sysplugins/smarty_security.php deleted file mode 100644 index af1ca553..00000000 --- a/www/smarty-3.1.27/sysplugins/smarty_security.php +++ /dev/null @@ -1,644 +0,0 @@ -" tags in templates. - * possible values: - *
    - *
  • Smarty::PHP_PASSTHRU -> echo PHP tags as they are
  • - *
  • Smarty::PHP_QUOTE -> escape tags as entities
  • - *
  • Smarty::PHP_REMOVE -> remove php tags
  • - *
  • Smarty::PHP_ALLOW -> execute php tags
  • - *
- * - * @var integer - */ - public $php_handling = Smarty::PHP_PASSTHRU; - /** - * This is the list of template directories that are considered secure. - * $template_dir is in this list implicitly. - * - * @var array - */ - public $secure_dir = array(); - /** - * This is an array of directories where trusted php scripts reside. - * {@link $security} is disabled during their inclusion/execution. - * - * @var array - */ - public $trusted_dir = array(); - /** - * List of regular expressions (PCRE) that include trusted URIs - * - * @var array - */ - public $trusted_uri = array(); - /** - * List of trusted constants names - * - * @var array - */ - public $trusted_constants = array(); - /** - * This is an array of trusted static classes. - * If empty access to all static classes is allowed. - * If set to 'none' none is allowed. - * - * @var array - */ - public $static_classes = array(); - - /** - * This is an nested array of trusted classes and static methods. - * If empty access to all static classes and methods is allowed. - * Format: - * array ( - * 'class_1' => array('method_1', 'method_2'), // allowed methods listed - * 'class_2' => array(), // all methods of class allowed - * ) - * If set to null none is allowed. - * - * @var array - */ - public $trusted_static_methods = array(); - - /** - * This is an array of trusted static properties. - * If empty access to all static classes and properties is allowed. - * Format: - * array ( - * 'class_1' => array('prop_1', 'prop_2'), // allowed properties listed - * 'class_2' => array(), // all properties of class allowed - * ) - * If set to null none is allowed. - * - * @var array - */ - public $trusted_static_properties = array(); - /** - * This is an array of trusted PHP functions. - * If empty all functions are allowed. - * To disable all PHP functions set $php_functions = null. - * - * @var array - */ - public $php_functions = array( - 'isset', 'empty', - 'count', 'sizeof', - 'in_array', 'is_array', - 'time', - ); - /** - * This is an array of trusted PHP modifiers. - * If empty all modifiers are allowed. - * To disable all modifier set $php_modifiers = null. - * - * @var array - */ - public $php_modifiers = array( - 'escape', - 'count', - 'nl2br', - ); - /** - * This is an array of allowed tags. - * If empty no restriction by allowed_tags. - * - * @var array - */ - public $allowed_tags = array(); - /** - * This is an array of disabled tags. - * If empty no restriction by disabled_tags. - * - * @var array - */ - public $disabled_tags = array(); - /** - * This is an array of allowed modifier plugins. - * If empty no restriction by allowed_modifiers. - * - * @var array - */ - public $allowed_modifiers = array(); - /** - * This is an array of disabled modifier plugins. - * If empty no restriction by disabled_modifiers. - * - * @var array - */ - public $disabled_modifiers = array(); - /** - * This is an array of disabled special $smarty variables. - * - * @var array - */ - public $disabled_special_smarty_vars = array(); - /** - * This is an array of trusted streams. - * If empty all streams are allowed. - * To disable all streams set $streams = null. - * - * @var array - */ - public $streams = array('file'); - /** - * + flag if constants can be accessed from template - * - * @var boolean - */ - public $allow_constants = true; - /** - * + flag if super globals can be accessed from template - * - * @var boolean - */ - public $allow_super_globals = true; - /** - * max template nesting level - * - * @var int - */ - public $max_template_nesting = 0; - /** - * current template nesting level - * - * @var int - */ - private $_current_template_nesting = 0; - /** - * Cache for $resource_dir lookup - * - * @var array - */ - protected $_resource_dir = null; - /** - * Cache for $template_dir lookup - * - * @var array - */ - protected $_template_dir = null; - /** - * Cache for $config_dir lookup - * - * @var array - */ - protected $_config_dir = null; - /** - * Cache for $secure_dir lookup - * - * @var array - */ - protected $_secure_dir = null; - /** - * Cache for $php_resource_dir lookup - * - * @var array - */ - protected $_php_resource_dir = null; - /** - * Cache for $trusted_dir lookup - * - * @var array - */ - protected $_trusted_dir = null; - - /** - * @param Smarty $smarty - */ - public function __construct($smarty) - { - $this->smarty = $smarty; - } - - /** - * Check if PHP function is trusted. - * - * @param string $function_name - * @param object $compiler compiler object - * - * @return boolean true if function is trusted - * @throws SmartyCompilerException if php function is not trusted - */ - public function isTrustedPhpFunction($function_name, $compiler) - { - if (isset($this->php_functions) && (empty($this->php_functions) || in_array($function_name, $this->php_functions))) { - return true; - } - - $compiler->trigger_template_error("PHP function '{$function_name}' not allowed by security setting"); - - return false; // should not, but who knows what happens to the compiler in the future? - } - - /** - * Check if static class is trusted. - * - * @param string $class_name - * @param object $compiler compiler object - * - * @return boolean true if class is trusted - * @throws SmartyCompilerException if static class is not trusted - */ - public function isTrustedStaticClass($class_name, $compiler) - { - if (isset($this->static_classes) && (empty($this->static_classes) || in_array($class_name, $this->static_classes))) { - return true; - } - - $compiler->trigger_template_error("access to static class '{$class_name}' not allowed by security setting"); - - return false; // should not, but who knows what happens to the compiler in the future? - } - - /** - * Check if static class method/property is trusted. - * - * @param string $class_name - * @param string $params - * @param object $compiler compiler object - * - * @return boolean true if class method is trusted - * @throws SmartyCompilerException if static class method is not trusted - */ - public function isTrustedStaticClassAccess($class_name, $params, $compiler) - { - if (!isset($params[2])) { - // fall back - return $this->isTrustedStaticClass($class_name, $compiler); - } - if ($params[2] == 'method') { - $allowed = $this->trusted_static_methods; - $name = substr($params[0], 0, strpos($params[0], '(')); - } else { - $allowed = $this->trusted_static_properties; - // strip '$' - $name = substr($params[0], 1); - } - if (isset($allowed)) { - if (empty($allowed)) { - // fall back - return $this->isTrustedStaticClass($class_name, $compiler); - } - if (isset($allowed[$class_name]) - && (empty($allowed[$class_name]) - || in_array($name, $allowed[$class_name])) - ) { - return true; - } - } - $compiler->trigger_template_error("access to static class '{$class_name}' {$params[2]} '{$name}' not allowed by security setting"); - return false; // should not, but who knows what happens to the compiler in the future? - } - - /** - * Check if PHP modifier is trusted. - * - * @param string $modifier_name - * @param object $compiler compiler object - * - * @return boolean true if modifier is trusted - * @throws SmartyCompilerException if modifier is not trusted - */ - public function isTrustedPhpModifier($modifier_name, $compiler) - { - if (isset($this->php_modifiers) && (empty($this->php_modifiers) || in_array($modifier_name, $this->php_modifiers))) { - return true; - } - - $compiler->trigger_template_error("modifier '{$modifier_name}' not allowed by security setting"); - - return false; // should not, but who knows what happens to the compiler in the future? - } - - /** - * Check if tag is trusted. - * - * @param string $tag_name - * @param object $compiler compiler object - * - * @return boolean true if tag is trusted - * @throws SmartyCompilerException if modifier is not trusted - */ - public function isTrustedTag($tag_name, $compiler) - { - // check for internal always required tags - if (in_array($tag_name, array('assign', 'call', 'private_filter', 'private_block_plugin', 'private_function_plugin', 'private_object_block_function', - 'private_object_function', 'private_registered_function', 'private_registered_block', 'private_special_variable', 'private_print_expression', 'private_modifier')) - ) { - return true; - } - // check security settings - if (empty($this->allowed_tags)) { - if (empty($this->disabled_tags) || !in_array($tag_name, $this->disabled_tags)) { - return true; - } else { - $compiler->trigger_template_error("tag '{$tag_name}' disabled by security setting", $compiler->lex->taglineno); - } - } elseif (in_array($tag_name, $this->allowed_tags) && !in_array($tag_name, $this->disabled_tags)) { - return true; - } else { - $compiler->trigger_template_error("tag '{$tag_name}' not allowed by security setting", $compiler->lex->taglineno); - } - - return false; // should not, but who knows what happens to the compiler in the future? - } - - /** - * Check if special $smarty variable is trusted. - * - * @param string $var_name - * @param object $compiler compiler object - * - * @return boolean true if tag is trusted - * @throws SmartyCompilerException if modifier is not trusted - */ - public function isTrustedSpecialSmartyVar($var_name, $compiler) - { - if (!in_array($var_name, $this->disabled_special_smarty_vars)) { - return true; - } else { - $compiler->trigger_template_error("special variable '\$smarty.{$var_name}' not allowed by security setting", $compiler->lex->taglineno); - } - - return false; // should not, but who knows what happens to the compiler in the future? - } - - /** - * Check if modifier plugin is trusted. - * - * @param string $modifier_name - * @param object $compiler compiler object - * - * @return boolean true if tag is trusted - * @throws SmartyCompilerException if modifier is not trusted - */ - public function isTrustedModifier($modifier_name, $compiler) - { - // check for internal always allowed modifier - if (in_array($modifier_name, array('default'))) { - return true; - } - // check security settings - if (empty($this->allowed_modifiers)) { - if (empty($this->disabled_modifiers) || !in_array($modifier_name, $this->disabled_modifiers)) { - return true; - } else { - $compiler->trigger_template_error("modifier '{$modifier_name}' disabled by security setting", $compiler->lex->taglineno); - } - } elseif (in_array($modifier_name, $this->allowed_modifiers) && !in_array($modifier_name, $this->disabled_modifiers)) { - return true; - } else { - $compiler->trigger_template_error("modifier '{$modifier_name}' not allowed by security setting", $compiler->lex->taglineno); - } - - return false; // should not, but who knows what happens to the compiler in the future? - } - - /** - * Check if constants are enabled or trusted - * - * @param string $const contant name - * @param object $compiler compiler object - * - * @return bool - */ - public function isTrustedConstant($const, $compiler) - { - if (in_array($const, array('true', 'false', 'null'))) { - return true; - } - if (!empty($this->trusted_constants)) { - if (!in_array($const, $this->trusted_constants)) { - $compiler->trigger_template_error("Security: access to constant '{$const}' not permitted"); - return false; - } - return true; - } - if ($this->allow_constants) { - return true; - } - $compiler->trigger_template_error("Security: access to constants not permitted"); - return false; - } - - /** - * Check if stream is trusted. - * - * @param string $stream_name - * - * @return boolean true if stream is trusted - * @throws SmartyException if stream is not trusted - */ - public function isTrustedStream($stream_name) - { - if (isset($this->streams) && (empty($this->streams) || in_array($stream_name, $this->streams))) { - return true; - } - - throw new SmartyException("stream '{$stream_name}' not allowed by security setting"); - } - - /** - * Check if directory of file resource is trusted. - * - * @param string $filepath - * - * @return boolean true if directory is trusted - * @throws SmartyException if directory is not trusted - */ - public function isTrustedResourceDir($filepath) - { - $_template = false; - $_config = false; - $_secure = false; - - $_template_dir = $this->smarty->getTemplateDir(); - $_config_dir = $this->smarty->getConfigDir(); - - // check if index is outdated - if ((!$this->_template_dir || $this->_template_dir !== $_template_dir) - || (!$this->_config_dir || $this->_config_dir !== $_config_dir) - || (!empty($this->secure_dir) && (!$this->_secure_dir || $this->_secure_dir !== $this->secure_dir)) - ) { - $this->_resource_dir = array(); - $_template = true; - $_config = true; - $_secure = !empty($this->secure_dir); - } - - // rebuild template dir index - if ($_template) { - $this->_template_dir = $_template_dir; - foreach ($_template_dir as $directory) { - $directory = realpath($directory); - $this->_resource_dir[$directory] = true; - } - } - - // rebuild config dir index - if ($_config) { - $this->_config_dir = $_config_dir; - foreach ($_config_dir as $directory) { - $directory = realpath($directory); - $this->_resource_dir[$directory] = true; - } - } - - // rebuild secure dir index - if ($_secure) { - $this->_secure_dir = $this->secure_dir; - foreach ((array) $this->secure_dir as $directory) { - $directory = realpath($directory); - $this->_resource_dir[$directory] = true; - } - } - - $_filepath = realpath($filepath); - $directory = dirname($_filepath); - $_directory = array(); - while (true) { - // remember the directory to add it to _resource_dir in case we're successful - $_directory[$directory] = true; - // test if the directory is trusted - if (isset($this->_resource_dir[$directory])) { - // merge sub directories of current $directory into _resource_dir to speed up subsequent lookup - $this->_resource_dir = array_merge($this->_resource_dir, $_directory); - - return true; - } - // abort if we've reached root - if (($pos = strrpos($directory, DS)) === false || !isset($directory[1])) { - break; - } - // bubble up one level - $directory = substr($directory, 0, $pos); - } - - // give up - throw new SmartyException("directory '{$_filepath}' not allowed by security setting"); - } - - /** - * Check if URI (e.g. {fetch} or {html_image}) is trusted - * To simplify things, isTrustedUri() resolves all input to "{$PROTOCOL}://{$HOSTNAME}". - * So "http://username:password@hello.world.example.org:8080/some-path?some=query-string" - * is reduced to "http://hello.world.example.org" prior to applying the patters from {@link $trusted_uri}. - * - * @param string $uri - * - * @return boolean true if URI is trusted - * @throws SmartyException if URI is not trusted - * @uses $trusted_uri for list of patterns to match against $uri - */ - public function isTrustedUri($uri) - { - $_uri = parse_url($uri); - if (!empty($_uri['scheme']) && !empty($_uri['host'])) { - $_uri = $_uri['scheme'] . '://' . $_uri['host']; - foreach ($this->trusted_uri as $pattern) { - if (preg_match($pattern, $_uri)) { - return true; - } - } - } - - throw new SmartyException("URI '{$uri}' not allowed by security setting"); - } - - /** - * Check if directory of file resource is trusted. - * - * @param string $filepath - * - * @return boolean true if directory is trusted - * @throws SmartyException if PHP directory is not trusted - */ - public function isTrustedPHPDir($filepath) - { - if (empty($this->trusted_dir)) { - throw new SmartyException("directory '{$filepath}' not allowed by security setting (no trusted_dir specified)"); - } - - // check if index is outdated - if (!$this->_trusted_dir || $this->_trusted_dir !== $this->trusted_dir) { - $this->_php_resource_dir = array(); - - $this->_trusted_dir = $this->trusted_dir; - foreach ((array) $this->trusted_dir as $directory) { - $directory = realpath($directory); - $this->_php_resource_dir[$directory] = true; - } - } - - $_filepath = realpath($filepath); - $directory = dirname($_filepath); - $_directory = array(); - while (true) { - // remember the directory to add it to _resource_dir in case we're successful - $_directory[] = $directory; - // test if the directory is trusted - if (isset($this->_php_resource_dir[$directory])) { - // merge sub directories of current $directory into _resource_dir to speed up subsequent lookup - $this->_php_resource_dir = array_merge($this->_php_resource_dir, $_directory); - - return true; - } - // abort if we've reached root - if (($pos = strrpos($directory, DS)) === false || !isset($directory[2])) { - break; - } - // bubble up one level - $directory = substr($directory, 0, $pos); - } - - throw new SmartyException("directory '{$_filepath}' not allowed by security setting"); - } - - /** - * Start template processing - * - * @param $template - * - * @throws SmartyException - */ - public function startTemplate($template) - { - if ($this->max_template_nesting > 0 && $this->_current_template_nesting ++ >= $this->max_template_nesting) { - throw new SmartyException("maximum template nesting level of '{$this->max_template_nesting}' exceeded when calling '{$template->template_resource}'"); - } - } - - /** - * Exit template processing - * - * @param $template - */ - public function exitTemplate($template) - { - if ($this->max_template_nesting > 0) { - $this->_current_template_nesting --; - } - } -} diff --git a/www/smarty-3.1.27/sysplugins/smarty_template_cached.php b/www/smarty-3.1.27/sysplugins/smarty_template_cached.php deleted file mode 100644 index 5b904395..00000000 --- a/www/smarty-3.1.27/sysplugins/smarty_template_cached.php +++ /dev/null @@ -1,403 +0,0 @@ -compile_id = $_template->compile_id; - $this->cache_id = $_template->cache_id; - if (!isset($_template->source)) { - $_template->loadSource(); - } - $this->source = $_template->source; - if (!class_exists('Smarty_CacheResource', false)) { - require SMARTY_SYSPLUGINS_DIR . 'smarty_cacheresource.php'; - } - $this->handler = Smarty_CacheResource::load($_template->smarty); - } - - /** - * @param Smarty_Internal_Template $_template - * - * @return Smarty_Template_Cached - */ - static function load(Smarty_Internal_Template $_template) - { - $_template->cached = $cached = new Smarty_Template_Cached($_template); - $cached->handler->populate($cached, $_template); - // caching enabled ? - if (!($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || $_template->caching == Smarty::CACHING_LIFETIME_SAVED) || $_template->source->recompiled) { - $cached->valid = false; - } - return $cached; - } - - /** - * Check if cache is valid, lock cache if required - * - * @param \Smarty_Internal_Template $_template - * - * @return bool flag true if cache is valid - */ - public function isCached(Smarty_Internal_Template $_template) - { - if ($this->valid !== null) { - return $this->valid; - } - while (true) { - while (true) { - if ($this->exists === false || $_template->smarty->force_compile || $_template->smarty->force_cache) { - $this->valid = false; - } else { - $this->valid = true; - } - if ($this->valid && $_template->caching == Smarty::CACHING_LIFETIME_CURRENT && $_template->cache_lifetime >= 0 && time() > ($this->timestamp + $_template->cache_lifetime)) { - // lifetime expired - $this->valid = false; - } - if ($this->valid && $_template->source->timestamp > $this->timestamp) { - $this->valid = false; - } - if ($this->valid || !$_template->smarty->cache_locking) { - break; - } - if (!$this->handler->locked($_template->smarty, $this)) { - $this->handler->acquireLock($_template->smarty, $this); - break 2; - } - $this->handler->populate($this, $_template); - } - if ($this->valid) { - if (!$_template->smarty->cache_locking || $this->handler->locked($_template->smarty, $this) === null) { - // load cache file for the following checks - if ($_template->smarty->debugging) { - Smarty_Internal_Debug::start_cache($_template); - } - if ($this->handler->process($_template, $this) === false) { - $this->valid = false; - } else { - $this->processed = true; - } - if ($_template->smarty->debugging) { - Smarty_Internal_Debug::end_cache($_template); - } - } else { - $this->is_locked = true; - continue; - } - } else { - return $this->valid; - } - if ($this->valid && $_template->caching === Smarty::CACHING_LIFETIME_SAVED && $_template->properties['cache_lifetime'] >= 0 && (time() > ($_template->cached->timestamp + $_template->properties['cache_lifetime']))) { - $this->valid = false; - } - if ($_template->smarty->cache_locking) { - if (!$this->valid) { - $this->handler->acquireLock($_template->smarty, $this); - } elseif ($this->is_locked) { - $this->handler->releaseLock($_template->smarty, $this); - } - } - return $this->valid; - } - return $this->valid; - } - - /** - * Process cached template - * - * @param Smarty_Internal_Template $_template template object - */ - public function process(Smarty_Internal_Template $_template) - { - if ($this->handler->process($_template, $this) === false) { - $this->valid = false; - } - if ($this->valid) { - $this->processed = true; - } else { - $this->processed = false; - } - } - - /** - * Render cached template - * - * @param Smarty_Internal_Template $_template - * - * @return string - * @throws Exception - */ - public function render(Smarty_Internal_Template $_template) - { - if (!$this->processed) { - $this->process($_template); - } - return $_template->getRenderedTemplateCode(); - } - - /** - * Write this cache object to handler - * - * @param Smarty_Internal_Template $_template template object - * @param string $content content to cache - * - * @return boolean success - */ - public function write(Smarty_Internal_Template $_template, $content) - { - if (!$_template->source->recompiled) { - if ($this->handler->writeCachedContent($_template, $content)) { - $this->content = null; - $this->timestamp = time(); - $this->exists = true; - $this->valid = true; - $this->processed = false; - if ($_template->smarty->cache_locking) { - $this->handler->releaseLock($_template->smarty, $this); - } - - return true; - } - $this->content = null; - $this->timestamp = false; - $this->exists = false; - $this->valid = false; - $this->processed = false; - } - - return false; - } - - /** - * Read cache content from handler - * - * @param Smarty_Internal_Template $_template template object - * - * @return string content - */ - public function read(Smarty_Internal_Template $_template) - { - if (!$_template->source->recompiled) { - return $this->handler->readCachedContent($_template); - } - return false; - } - - /** - * Sanitize content and write it to cache resource - * - * @param Smarty_Internal_Template $_template - * @param string $content - * @param bool $no_output_filter - * - * @throws SmartyException - */ - public function updateCache(Smarty_Internal_Template $_template, $content, $no_output_filter) - { - $_template->properties['has_nocache_code'] = false; - // get text between non-cached items - $cache_split = preg_split("!/\*%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*\/(.+?)/\*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*/!s", $content); - // get non-cached items - preg_match_all("!/\*%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*\/(.+?)/\*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*/!s", $content, $cache_parts); - $output = ''; - // loop over items, stitch back together - foreach ($cache_split as $curr_idx => $curr_split) { - // escape PHP tags in template content - $output .= preg_replace('/(<%|%>|<\?php|<\?|\?>|)/', "\n", $curr_split); - if (isset($cache_parts[0][$curr_idx])) { - $_template->properties['has_nocache_code'] = true; - $output .= $cache_parts[1][$curr_idx]; - } - } - if (!$no_output_filter && !$_template->has_nocache_code && (isset($_template->smarty->autoload_filters['output']) || isset($_template->smarty->registered_filters['output']))) { - $output = Smarty_Internal_Filter_Handler::runFilter('output', $output, $_template); - } - // write cache file content - $this->writeCachedContent($_template, $output); - } - - /** - * Writes the content to cache resource - * - * @param Smarty_Internal_Template $_template - * @param string $content - * - * @return bool - */ - public function writeCachedContent(Smarty_Internal_Template $_template, $content) - { - if ($_template->source->recompiled || !($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || $_template->caching == Smarty::CACHING_LIFETIME_SAVED)) { - // don't write cache file - return false; - } - $_template->properties['cache_lifetime'] = $_template->cache_lifetime; - $_template->properties['unifunc'] = 'content_' . str_replace(array('.', ','), '_', uniqid('', true)); - $content = Smarty_Internal_Extension_CodeFrame::create($_template, $content, true); - if (!empty($_template->properties['tpl_function'])) { - foreach ($_template->properties['tpl_function'] as $funcParam) { - if (is_file($funcParam['compiled_filepath'])) { - // read compiled file - $code = file_get_contents($funcParam['compiled_filepath']); - // grab template function - if (preg_match("/\/\* {$funcParam['call_name']} \*\/([\S\s]*?)\/\*\/ {$funcParam['call_name']} \*\//", $code, $match)) { - unset($code); - $content .= "\n"; - } - } - } - } - return $this->write($_template, $content); - } - - /** - * check client side cache - * - * @param Smarty_Internal_Template $_template - * @param string $content - */ - public function cacheModifiedCheck(Smarty_Internal_Template $_template, $content) - { - $_isCached = $_template->isCached() && !$_template->has_nocache_code; - $_last_modified_date = @substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_SERVER['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3); - if ($_isCached && $this->timestamp <= strtotime($_last_modified_date)) { - switch (PHP_SAPI) { - case 'cgi': // php-cgi < 5.3 - case 'cgi-fcgi': // php-cgi >= 5.3 - case 'fpm-fcgi': // php-fpm >= 5.3.3 - header('Status: 304 Not Modified'); - break; - - case 'cli': - if ( /* ^phpunit */ - !empty($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS']) /* phpunit$ */ - ) { - $_SERVER['SMARTY_PHPUNIT_HEADERS'][] = '304 Not Modified'; - } - break; - - default: - header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified'); - break; - } - } else { - switch (PHP_SAPI) { - case 'cli': - if ( /* ^phpunit */ - !empty($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS']) /* phpunit$ */ - ) { - $_SERVER['SMARTY_PHPUNIT_HEADERS'][] = 'Last-Modified: ' . gmdate('D, d M Y H:i:s', $this->timestamp) . ' GMT'; - } - break; - - default: - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $this->timestamp) . ' GMT'); - break; - } - echo $content; - } - } -} diff --git a/www/smarty-3.1.27/sysplugins/smarty_template_compiled.php b/www/smarty-3.1.27/sysplugins/smarty_template_compiled.php deleted file mode 100644 index 3ff8fa89..00000000 --- a/www/smarty-3.1.27/sysplugins/smarty_template_compiled.php +++ /dev/null @@ -1,288 +0,0 @@ -source)) { - $_template->loadSource(); - } - // check runtime cache - if (!$_template->source->recompiled && $_template->smarty->resource_caching) { - $_cache_key = $_template->source->unique_resource . '#'; - if ($_template->caching) { - $_cache_key .= 'caching#'; - } - $_cache_key .= $_template->compile_id; - if (isset($_template->source->compileds[$_cache_key])) { - return $_template->source->compileds[$_cache_key]; - } - } - $compiled = new Smarty_Template_Compiled(); - if (method_exists($_template->source->handler, 'populateCompiledFilepath')) { - $_template->source->handler->populateCompiledFilepath($compiled, $_template); - } else { - $compiled->populateCompiledFilepath($_template); - } - // runtime cache - if (!$_template->source->recompiled && $_template->smarty->resource_caching) { - $_template->source->compileds[$_cache_key] = $compiled; - } - return $compiled; - } - - /** - * populate Compiled Object with compiled filepath - * - * @param Smarty_Internal_Template $_template template object - **/ - public function populateCompiledFilepath(Smarty_Internal_Template $_template) - { - $_compile_id = isset($_template->compile_id) ? preg_replace('![^\w\|]+!', '_', $_template->compile_id) : null; - if ($_template->source->isConfig) { - $_flag = '_' . ((int) $_template->smarty->config_read_hidden + (int) $_template->smarty->config_booleanize * 2 - + (int) $_template->smarty->config_overwrite * 4); - } else { - $_flag = '_' . ((int) $_template->smarty->merge_compiled_includes + (int) $_template->smarty->escape_html * 2); - } - $_filepath = $_template->source->uid . $_flag; - // if use_sub_dirs, break file into directories - if ($_template->smarty->use_sub_dirs) { - $_filepath = substr($_filepath, 0, 2) . DS - . substr($_filepath, 2, 2) . DS - . substr($_filepath, 4, 2) . DS - . $_filepath; - } - $_compile_dir_sep = $_template->smarty->use_sub_dirs ? DS : '^'; - if (isset($_compile_id)) { - $_filepath = $_compile_id . $_compile_dir_sep . $_filepath; - } - // caching token - if ($_template->caching) { - $_cache = '.cache'; - } else { - $_cache = ''; - } - $_compile_dir = $_template->smarty->getCompileDir(); - // set basename if not specified - $_basename = $_template->source->handler->getBasename($_template->source); - if ($_basename === null) { - $_basename = basename(preg_replace('![^\w\/]+!', '_', $_template->source->name)); - } - // separate (optional) basename by dot - if ($_basename) { - $_basename = '.' . $_basename; - } - - $this->filepath = $_compile_dir . $_filepath . '.' . $_template->source->type . $_basename . $_cache . '.php'; - $this->timestamp = $this->exists = is_file($this->filepath); - if ($this->exists) { - $this->timestamp = @filemtime($this->filepath); - } - } - - /** - * load compiled template or compile from source - * - * @param Smarty_Internal_Template $_template - * - * @throws Exception - */ - public function process(Smarty_Internal_Template $_template) - { - $_smarty_tpl = $_template; - if ($_template->source->recompiled || !$_template->compiled->exists || $_template->smarty->force_compile) { - $this->compileTemplateSource($_template); - $compileCheck = $_template->smarty->compile_check; - $_template->smarty->compile_check = false; - if ($_template->source->recompiled) { - $level = ob_get_level(); - ob_start(); - try { - eval("?>" . $this->code); - } - catch (Exception $e) { - while (ob_get_level() > $level) { - ob_end_clean(); - } - throw $e; - } - ob_get_clean(); - $this->code = null; - } else { - include($_template->compiled->filepath); - } - $_template->smarty->compile_check = $compileCheck; - } else { - include($_template->compiled->filepath); - if ($_template->mustCompile) { - $this->compileTemplateSource($_template); - $compileCheck = $_template->smarty->compile_check; - $_template->smarty->compile_check = false; - include($_template->compiled->filepath); - $_template->smarty->compile_check = $compileCheck; - } - } - $this->unifunc = $_template->properties['unifunc']; - $this->processed = true; - } - - /** - * render compiled template code - * - * @param Smarty_Internal_Template $_template - * - * @return string - * @throws Exception - */ - public function render(Smarty_Internal_Template $_template) - { - - if (!$this->processed) { - $this->process($_template); - } - $_template->properties['unifunc'] = $this->unifunc; - return $_template->getRenderedTemplateCode(); - } - - /** - * compile template from source - * - * @param Smarty_Internal_Template $_template - * - * @return string - * @throws Exception - */ - public function compileTemplateSource(Smarty_Internal_Template $_template) - { - if (!$_template->source->recompiled) { - $_template->properties['file_dependency'] = array(); - } - // compile locking - if (!$_template->source->recompiled) { - if ($saved_timestamp = $_template->compiled->timestamp) { - touch($_template->compiled->filepath); - } - } - // call compiler - try { - $code = $_template->compiler->compileTemplate($_template); - } - catch (Exception $e) { - // restore old timestamp in case of error - if (!$_template->source->recompiled && $saved_timestamp) { - touch($_template->compiled->filepath, $saved_timestamp); - } - throw $e; - } - // compiling succeeded - if ($_template->compiler->write_compiled_code) { - // write compiled template - $this->write($_template, $code); - $code = ''; - } - // release compiler object to free memory - unset($_template->compiler); - return $code; - } - - /** - * Write compiled code by handler - * - * @param Smarty_Internal_Template $_template template object - * @param string $code compiled code - * - * @return boolean success - */ - public function write(Smarty_Internal_Template $_template, $code) - { - if (!$_template->source->recompiled) { - $obj = new Smarty_Internal_Write_File(); - if ($obj->writeFile($this->filepath, $code, $_template->smarty) === true) { - $this->timestamp = $this->exists = is_file($this->filepath); - if ($this->exists) { - $this->timestamp = @filemtime($this->filepath); - return true; - } - } - return false; - } else { - $this->code = $code; - } - $this->timestamp = time(); - $this->exists = true; - return true; - } - - /** - * Read compiled content from handler - * - * @param Smarty_Internal_Template $_template template object - * - * @return string content - */ - public function read(Smarty_Internal_Template $_template) - { - if (!$_template->source->recompiled) { - return file_get_contents($this->filepath); - } - return isset($this->content) ? $this->content : false; - } -} diff --git a/www/smarty-3.1.27/sysplugins/smarty_template_config.php b/www/smarty-3.1.27/sysplugins/smarty_template_config.php deleted file mode 100644 index f48d4711..00000000 --- a/www/smarty-3.1.27/sysplugins/smarty_template_config.php +++ /dev/null @@ -1,118 +0,0 @@ -handler = clone $handler; // Note: prone to circular references - $this->resource = $resource; - $this->type = $type; - $this->name = $name; - $this->smarty = $smarty; - } - - /** - * initialize Source Object for given resource - * Either [$_template] or [$smarty, $template_resource] must be specified - * - * @param Smarty_Internal_Template $_template template object - * @param Smarty $smarty smarty object - * @param string $template_resource resource identifier - * - * @return Smarty_Template_Source Source Object - * @throws SmartyException - */ - public static function load(Smarty_Internal_Template $_template = null, Smarty $smarty = null, $template_resource = null) - { - static $_incompatible_resources = array('extends' => true, 'php' => true); - $smarty = $_template->smarty; - $template_resource = $_template->template_resource; - if (empty($template_resource)) { - throw new SmartyException('Missing config name'); - } - // parse resource_name, load resource handler - list($name, $type) = Smarty_Resource::parseResourceName($template_resource, $smarty->default_config_type); - // make sure configs are not loaded via anything smarty can't handle - if (isset($_incompatible_resources[$type])) { - throw new SmartyException ("Unable to use resource '{$type}' for config"); - } - $resource = Smarty_Resource::load($smarty, $type); - $source = new Smarty_Template_Config($resource, $smarty, $template_resource, $type, $name); - $resource->populate($source, $_template); - if ((!isset($source->exists) || !$source->exists) && isset($_template->smarty->default_config_handler_func)) { - Smarty_Internal_Extension_DefaultTemplateHandler::_getDefault($_template, $source, $resource); - } - $source->unique_resource = $resource->buildUniqueResourceName($smarty, $name, true); - return $source; - } -} diff --git a/www/smarty-3.1.27/sysplugins/smarty_template_source.php b/www/smarty-3.1.27/sysplugins/smarty_template_source.php deleted file mode 100644 index dd537f0e..00000000 --- a/www/smarty-3.1.27/sysplugins/smarty_template_source.php +++ /dev/null @@ -1,285 +0,0 @@ -handler = $handler; // Note: prone to circular references - - $this->recompiled = $handler->recompiled; - $this->uncompiled = $handler->uncompiled; - $this->compiler_class = $handler->compiler_class; - $this->template_lexer_class = $handler->template_lexer_class; - $this->template_parser_class = $handler->template_parser_class; - - $this->smarty = $smarty; - $this->resource = $resource; - $this->type = $type; - $this->name = $name; - } - - /** - * initialize Source Object for given resource - * Either [$_template] or [$smarty, $template_resource] must be specified - * - * @param Smarty_Internal_Template $_template template object - * @param Smarty $smarty smarty object - * @param string $template_resource resource identifier - * - * @return Smarty_Template_Source Source Object - * @throws SmartyException - */ - public static function load(Smarty_Internal_Template $_template = null, Smarty $smarty = null, $template_resource = null) - { - if ($_template) { - $smarty = $_template->smarty; - $template_resource = $_template->template_resource; - } - if (empty($template_resource)) { - throw new SmartyException('Missing template name'); - } - // parse resource_name, load resource handler, identify unique resource name - list($name, $type) = Smarty_Resource::parseResourceName($template_resource, $smarty->default_resource_type); - $resource = Smarty_Resource::load($smarty, $type); - // if resource is not recompiling and resource name is not dotted we can check the source cache - if ($smarty->resource_caching && !$resource->recompiled && !(isset($name[1]) && $name[0] == '.' && ($name[1] == '.' || $name[1] == '/'))) { - $unique_resource = $resource->buildUniqueResourceName($smarty, $name); - if (isset($smarty->source_objects[$unique_resource])) { - return $smarty->source_objects[$unique_resource]; - } - } else { - $unique_resource = null; - } - // create new source object - $source = new Smarty_Template_Source($resource, $smarty, $template_resource, $type, $name); - $resource->populate($source, $_template); - if ((!isset($source->exists) || !$source->exists) && isset($_template->smarty->default_template_handler_func)) { - Smarty_Internal_Extension_DefaultTemplateHandler::_getDefault($_template, $source, $resObj); - } - // on recompiling resources we are done - if ($smarty->resource_caching && !$resource->recompiled) { - // may by we have already $unique_resource - $is_relative = false; - if (!isset($unique_resource)) { - $is_relative = isset($name[1]) && $name[0] == '.' && ($name[1] == '.' || $name[1] == '/') && - ($type == 'file' || (isset($_template->parent->source) && $_template->parent->source->type == 'extends')); - $unique_resource = $resource->buildUniqueResourceName($smarty, $is_relative ? $source->filepath . $name : $name); - } - $source->unique_resource = $unique_resource; - // save in runtime cache if not relative - if (!$is_relative) { - $smarty->source_objects[$unique_resource] = $source; - } - } - return $source; - } - - /** - * render the uncompiled source - * - * @param Smarty_Internal_Template $_template template object - */ - public function renderUncompiled(Smarty_Internal_Template $_template) - { - $level = ob_get_level(); - ob_start(); - try { - $this->handler->renderUncompiled($_template->source, $_template); - return ob_get_clean(); - } - catch (Exception $e) { - while (ob_get_level() > $level) { - ob_end_clean(); - } - throw $e; - } - } - - /** - * <> Generic Setter. - * - * @param string $property_name valid: timestamp, exists, content, template - * @param mixed $value new value (is not checked) - * - * @throws SmartyException if $property_name is not valid - */ - public function __set($property_name, $value) - { - switch ($property_name) { - // regular attributes - case 'timestamp': - case 'exists': - case 'content': - // required for extends: only - case 'template': - $this->$property_name = $value; - break; - - default: - throw new SmartyException("source property '$property_name' does not exist."); - } - } - - /** - * <> Generic getter. - * - * @param string $property_name valid: timestamp, exists, content - * - * @return mixed - * @throws SmartyException if $property_name is not valid - */ - public function __get($property_name) - { - switch ($property_name) { - case 'timestamp': - case 'exists': - $this->handler->populateTimestamp($this); - - return $this->$property_name; - - case 'content': - return $this->content = $this->handler->getContent($this); - - default: - throw new SmartyException("source property '$property_name' does not exist."); - } - } -} diff --git a/www/smarty-3.1.27/sysplugins/smarty_variable.php b/www/smarty-3.1.27/sysplugins/smarty_variable.php deleted file mode 100644 index c1de93cb..00000000 --- a/www/smarty-3.1.27/sysplugins/smarty_variable.php +++ /dev/null @@ -1,55 +0,0 @@ -value = $value; - $this->nocache = $nocache; - $this->scope = $scope; - } - - /** - * <> String conversion - * - * @return string - */ - public function __toString() - { - return (string) $this->value; - } -} - diff --git a/www/smarty-3.1.27/sysplugins/smartycompilerexception.php b/www/smarty-3.1.27/sysplugins/smartycompilerexception.php deleted file mode 100644 index 4d5d7787..00000000 --- a/www/smarty-3.1.27/sysplugins/smartycompilerexception.php +++ /dev/null @@ -1,39 +0,0 @@ - Smarty Compiler: ' . $this->message . ' <-- '; - } - - /** - * The line number of the template error - * - * @type int|null - */ - public $line = null; - /** - * The template source snippet relating to the error - * - * @type string|null - */ - public $source = null; - /** - * The raw text of the error message - * - * @type string|null - */ - public $desc = null; - /** - * The resource identifier or template name - * - * @type string|null - */ - public $template = null; -} diff --git a/www/smarty-3.1.27/sysplugins/smartyexception.php b/www/smarty-3.1.27/sysplugins/smartyexception.php deleted file mode 100644 index 3da16c27..00000000 --- a/www/smarty-3.1.27/sysplugins/smartyexception.php +++ /dev/null @@ -1,15 +0,0 @@ - Smarty: ' . (self::$escape ? htmlentities($this->message) : $this->message) . ' <-- '; - } -} diff --git a/www/smarty-3.1.30/.gitattributes b/www/smarty-3.1.30/.gitattributes deleted file mode 100644 index 412eeda7..00000000 --- a/www/smarty-3.1.30/.gitattributes +++ /dev/null @@ -1,22 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto - -# Custom for Visual Studio -*.cs diff=csharp -*.sln merge=union -*.csproj merge=union -*.vbproj merge=union -*.fsproj merge=union -*.dbproj merge=union - -# Standard to msysgit -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain diff --git a/www/smarty-3.1.30/.gitignore b/www/smarty-3.1.30/.gitignore deleted file mode 100644 index 51c201bf..00000000 --- a/www/smarty-3.1.30/.gitignore +++ /dev/null @@ -1,222 +0,0 @@ -################# -## Eclipse -################# - -*.pydevproject -.project -.metadata -bin/ -tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties -.classpath -.settings/ -.loadpath - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# CDT-specific -.cproject - -# PDT-specific -.buildpath - - -################# -## Visual Studio -################# - -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.sln.docstates - -# Build results - -[Dd]ebug/ -[Rr]elease/ -x64/ -build/ -[Bb]in/ -[Oo]bj/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -*_i.c -*_p.c -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.log -*.scc - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -*.ncrunch* -.*crunch*.local.xml - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.Publish.xml -*.pubxml - -# NuGet Packages Directory -## TODO: If you have NuGet Package Restore enabled, uncomment the next line -#packages/ - -# Windows Azure Build Output -csx -*.build.csdef - -# Windows Store app package directory -AppPackages/ - -# Others -sql/ -*.Cache -ClientBin/ -[Ss]tyle[Cc]op.* -~$* -*~ -*.dbmdl -*.[Pp]ublish.xml -*.pfx -*.publishsettings - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file to a newer -# Visual Studio version. Backup files are not needed, because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -App_Data/*.mdf -App_Data/*.ldf - -############# -## Windows detritus -############# - -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Mac crap -.DS_Store - - -############# -## Python -############# - -*.py[co] - -# Packages -*.egg -*.egg-info -dist/ -build/ -eggs/ -parts/ -var/ -sdist/ -develop-eggs/ -.installed.cfg - -# Installer logs -pip-log.txt - -# Unit test / coverage reports -.coverage -.tox - -#Translations -*.mo - -#Mr Developer -.mr.developer.cfg - -.idea/ -.idea\ - -# Smarty -lexer/*.php -lexer/*.out \ No newline at end of file diff --git a/www/smarty-3.1.30/.travis.yml b/www/smarty-3.1.30/.travis.yml deleted file mode 100644 index baca1979..00000000 --- a/www/smarty-3.1.30/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: php - -php: - - 5.3 - - 5.4 - - 5.5 - - 5.6 - -allow_failures: - - php: hhvm - -install: - - git clone --depth=50 --branch=master git://github.com/smarty-php/smarty-phpunit.git - -script: - - cd smarty-phpunit - - phpunit ./ - diff --git a/www/smarty-3.1.30/plugins/block.t.php b/www/smarty-3.1.30/plugins/block.t.php deleted file mode 100644 index fb34307f..00000000 --- a/www/smarty-3.1.30/plugins/block.t.php +++ /dev/null @@ -1,120 +0,0 @@ -register_block('t', 'smarty_translate'); - * - * @package smarty-gettext - * @version $Id: block.t.php 4737 2013-12-11 06:29:51Z gullevek $ - * @link http://smarty-gettext.sf.net/ - * @author Sagi Bashari - * @copyright 2004 Sagi Bashari - */ - -/** - * Replace arguments in a string with their values. Arguments are represented by % followed by their number. - * - * @param string Source string - * @param mixed Arguments, can be passed in an array or through single variables. - * @returns string Modified string - */ -function strarg($str) -{ - $tr = array(); - $p = 0; - - for ($i=1; $i < func_num_args(); $i++) { - $arg = func_get_arg($i); - - if (is_array($arg)) { - foreach ($arg as $aarg) { - $tr['%'.++$p] = $aarg; - } - } else { - $tr['%'.++$p] = $arg; - } - } - - return strtr($str, $tr); -} - -/** - * Smarty block function, provides gettext support for smarty. - * - * The block content is the text that should be translated. - * - * Any parameter that is sent to the function will be represented as %n in the translation text, - * where n is 1 for the first parameter. The following parameters are reserved: - * - escape - sets escape mode: - * - 'html' for HTML escaping, this is the default. - * - 'js' for javascript escaping. - * - 'no'/'off'/0 - turns off escaping - * - plural - The plural version of the text (2nd parameter of ngettext()) - * - count - The item count for plural mode (3rd parameter of ngettext()) - */ - -// cs modified: __ calls instead of direct gettext calls - -function smarty_block_t($params, $text, $template, &$repeat) -{ - if ($text) { - $text = stripslashes($text); - - // set escape mode - if (isset($params['escape'])) { - $escape = $params['escape']; - unset($params['escape']); - } - - // set plural version - if (isset($params['plural'])) { - $plural = $params['plural']; - unset($params['plural']); - - // set count - if (isset($params['count'])) { - $count = $params['count']; - unset($params['count']); - } - } - - // use plural if required parameters are set - if (isset($count) && isset($plural)) { - $text = $template->l10n->__ngettext($text, $plural, $count); - } else { // use normal - $text = $template->l10n->__($text); - } - - // run strarg if there are parameters - if (count($params)) { - $text = strarg($text, $params); - } - - if (!isset($escape) || $escape == 'html') { // html escape, default - $text = nl2br(htmlspecialchars($text)); - } elseif (isset($escape) && ($escape == 'javascript' || $escape == 'js')) { // javascript escape - $text = str_replace('\'','\\\'',stripslashes($text)); - } - - return $text; - } -} - -?> diff --git a/www/smarty-3.1.30/plugins/function.html_checkboxes.php b/www/smarty-3.1.30/plugins/function.html_checkboxes.php deleted file mode 100644 index 82e93300..00000000 --- a/www/smarty-3.1.30/plugins/function.html_checkboxes.php +++ /dev/null @@ -1,256 +0,0 @@ - - * Type: function
- * Name: html_checkboxes
- * Date: 24.Feb.2003
- * Purpose: Prints out a list of checkbox input types
- * Examples: - *
- * {html_checkboxes values=$ids output=$names}
- * {html_checkboxes values=$ids name='box' separator='
' output=$names} - * {html_checkboxes values=$ids checked=$checked separator='
' output=$names} - *
- * Params: - *
- * - name       (optional) - string default "checkbox"
- * - values     (required) - array
- * - options    (optional) - associative array
- * - checked    (optional) - array default not set
- * - separator  (optional) - ie 
or   - * - output (optional) - the output next to each checkbox - * - assign (optional) - assign the output as an array to this variable - * - escape (optional) - escape the content (not value), defaults to true - *
- * - * @link http://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes} - * (Smarty online manual) - * @author Christopher Kvarme - * @author credits to Monte Ohrt - * @version 1.0 - * - * @param array $params parameters - * @param object $template template object - * - * @return string - * @uses smarty_function_escape_special_chars() - */ -function smarty_function_html_checkboxes($params, $template) -{ - require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); - - $name = 'checkbox'; - $values = null; - $options = null; - $selected = array(); - $separator = ''; - $escape = true; - $labels = true; - $label_ids = false; - $output = null; - $pos = null; - - $extra = ''; - - foreach ($params as $_key => $_val) { - switch ($_key) { - case 'name': - case 'separator': - $$_key = (string) $_val; - break; - - case 'escape': - case 'labels': - case 'label_ids': - $$_key = (bool) $_val; - break; - - case 'options': - $$_key = (array) $_val; - break; - - case 'values': - case 'output': - $$_key = array_values((array) $_val); - break; - - case 'checked': - case 'selected': - if (is_array($_val)) { - $selected = array(); - foreach ($_val as $_sel) { - if (is_object($_sel)) { - if (method_exists($_sel, "__toString")) { - $_sel = smarty_function_escape_special_chars((string) $_sel->__toString()); - } else { - trigger_error("html_checkboxes: selected attribute contains an object of class '" . - get_class($_sel) . "' without __toString() method", E_USER_NOTICE); - continue; - } - } else { - $_sel = smarty_function_escape_special_chars((string) $_sel); - } - $selected[ $_sel ] = true; - } - } elseif (is_object($_val)) { - if (method_exists($_val, "__toString")) { - $selected = smarty_function_escape_special_chars((string) $_val->__toString()); - } else { - trigger_error("html_checkboxes: selected attribute is an object of class '" . get_class($_val) . - "' without __toString() method", E_USER_NOTICE); - } - } else { - $selected = smarty_function_escape_special_chars((string) $_val); - } - break; - - case 'checkboxes': - trigger_error('html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead', - E_USER_WARNING); - $options = (array) $_val; - break; - - case 'assign': - break; - - case 'pos': - $$_key = array_values((array)$_val); - break; - - case 'strict': - break; - - case 'disabled': - case 'readonly': - if (!empty($params[ 'strict' ])) { - if (!is_scalar($_val)) { - trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute", - E_USER_NOTICE); - } - - if ($_val === true || $_val === $_key) { - $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"'; - } - - break; - } - // omit break; to fall through! - - default: - if (!is_array($_val)) { - $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"'; - } else { - trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE); - } - break; - } - } - - if (!isset($options) && !isset($values)) { - return ''; - } /* raise error here? */ - - $_html_result = array(); - - if (isset($options)) { - foreach ($options as $_key => $_val) { - $_pos = isset($pos[ $_key ]) ? $pos[ $_key ] : ''; - $_html_result[] = - smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels, - $label_ids, $_pos, $escape); - } - } else { - foreach ($values as $_i => $_key) { - $_val = isset($output[ $_i ]) ? $output[ $_i ] : ''; - $_pos = isset($pos[ $_i ]) ? $pos[ $_i ] : ''; - $_html_result[] = - smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels, - $label_ids, $_pos, $escape); - } - } - - if (!empty($params[ 'assign' ])) { - $template->assign($params[ 'assign' ], $_html_result); - } else { - return implode("\n", $_html_result); - } -} - -function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels, - $label_ids, $pos, $escape = true) -{ - $_output = ''; - - if (is_object($value)) { - if (method_exists($value, "__toString")) { - $value = (string) $value->__toString(); - } else { - trigger_error("html_options: value is an object of class '" . get_class($value) . - "' without __toString() method", E_USER_NOTICE); - - return ''; - } - } else { - $value = (string) $value; - } - - if (is_object($output)) { - if (method_exists($output, "__toString")) { - $output = (string) $output->__toString(); - } else { - trigger_error("html_options: output is an object of class '" . get_class($output) . - "' without __toString() method", E_USER_NOTICE); - - return ''; - } - } else { - $output = (string) $output; - } - - if ($labels) { - if ($label_ids) { - $_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_', - $name . '_' . $value)); - $_output .= '