Core libs clean up

- end comments from # to //
- clean up not initialzed vars and wrong named vars
This commit is contained in:
Clemens Schwaighofer
2019-04-22 10:28:01 +09:00
parent 4f73a88a8b
commit be03bc96cb
33 changed files with 131 additions and 92 deletions

View File

@@ -1,4 +1,4 @@
<? <?php
/******************************************************************** /********************************************************************
* AUTHOR: Clemens Schwaighofer * AUTHOR: Clemens Schwaighofer
* CREATED: 2005/07/19 * CREATED: 2005/07/19
@@ -7,45 +7,55 @@
* HISTORY: * HISTORY:
*********************************************************************/ *********************************************************************/
$day_short[1] = "Mon"; $day_short = array (
$day_short[2] = "Tue"; 1 => 'Mon',
$day_short[3] = "Wed"; 2 => 'Tue',
$day_short[4] = "Thu"; 3 => 'Wed',
$day_short[5] = "Fri"; 4 => 'Thu',
$day_short[6] = "Sat"; 5 => 'Fri',
$day_short[7] = "Sun"; 6 => 'Sat',
7 => 'Sun'
);
$day_long[1] = "Monday"; $day_long = array (
$day_long[2] = "Tuesday"; 1 => 'Monday',
$day_long[3] = "Wednesday"; 2 => 'Tuesday',
$day_long[4] = "Thursday"; 3 => 'Wednesday',
$day_long[5] = "Friday"; 4 => 'Thursday',
$day_long[6] = "Saturday"; 5 => 'Friday',
$day_long[7] = "Sunday"; 6 => 'Saturday',
7 => 'Sunday'
);
// monate // months
$month_long[1] = "January"; $month_long = array (
$month_long[2] = "February"; 1 => 'January',
$month_long[3] = "March"; 2 => 'February',
$month_long[4] = "April"; 3 => 'March',
$month_long[5] = "May"; 4 => 'April',
$month_long[6] = "June"; 5 => 'May',
$month_long[7] = "July"; 6 => 'June',
$month_long[8] = "August"; 7 => 'July',
$month_long[9] = "September"; 8 => 'August',
$month_long[10] = "October"; 9 => 'September',
$month_long[11] = "November"; 10 => 'October',
$month_long[12] = "December"; 11 => 'November',
12 => 'December'
);
$month_short[1] = "Jan"; $month_short = array (
$month_short[2] = "Feb"; 1 => 'Jan',
$month_short[3] = "Mar"; 2 => 'Feb',
$month_short[4] = "Apr"; 3 => 'Mar',
$month_short[5] = "May"; 4 => 'Apr',
$month_short[6] = "Jun"; 5 => 'May',
$month_short[7] = "Jul"; 6 => 'Jun',
$month_short[8] = "Aug"; 7 => 'Jul',
$month_short[9] = "Sep"; 8 => 'Aug',
$month_short[10] = "Oct"; 9 => 'Sep',
$month_short[11] = "Nov"; 10 => 'Oct',
$month_short[12] = "Dec"; 11 => 'Nov',
12 => 'Dec'
);
// __END__

View File

@@ -10,3 +10,5 @@
// print debug messages // print debug messages
echo $login->printErrorMsg(); echo $login->printErrorMsg();
echo $cms->printErrorMsg(); echo $cms->printErrorMsg();
// __END__

View File

@@ -94,3 +94,5 @@ if ((TARGET == 'live' || TARGET == 'remote') && !$DEBUG_ALL_OVERRIDE) {
$cms->print_output_all = 0; $cms->print_output_all = 0;
} }
$cms->DATA['JS_DEBUG'] = DEBUG; $cms->DATA['JS_DEBUG'] = DEBUG;
// __END__

View File

@@ -144,4 +144,4 @@ if (!file_exists($smarty->getTemplateDir()[0].DS.$TEMPLATE_TRANSLATE)) {
$cms->debug("LANGUAGE", "SL: ".$_SESSION['DEFAULT_CHARSET']." | ".$_SESSION['LANG']." | ".$_SESSION['DEFAULT_LANG']); $cms->debug("LANGUAGE", "SL: ".$_SESSION['DEFAULT_CHARSET']." | ".$_SESSION['LANG']." | ".$_SESSION['DEFAULT_LANG']);
$cms->debug("TEMPLATE", "P: ".$smarty->getTemplateDir()[0]); $cms->debug("TEMPLATE", "P: ".$smarty->getTemplateDir()[0]);
# __END__ // __END__

View File

@@ -101,4 +101,4 @@ if (is_dir(BASE.CACHE)) {
} }
$smarty->display($MASTER_TEMPLATE_NAME, $TEMPLATE.$lang, $TEMPLATE.$lang); $smarty->display($MASTER_TEMPLATE_NAME, $TEMPLATE.$lang, $TEMPLATE.$lang);
# __END__ // __END__

View File

@@ -325,4 +325,4 @@ $smarty->display('edit_body.tpl');
echo $login->printErrorMsg(); echo $login->printErrorMsg();
echo $form->printErrorMsg(); echo $form->printErrorMsg();
# __END__ // __END__

View File

@@ -1,4 +1,5 @@
<?php <?php
$edit_access = array ( $edit_access = array (
"table_array" => array ( "table_array" => array (
"edit_access_id" => array ( "edit_access_id" => array (
@@ -95,4 +96,4 @@ $edit_access = array (
) )
); );
# __END__ // __END__

View File

@@ -1,4 +1,5 @@
<?php <?php
$edit_groups = array ( $edit_groups = array (
"table_array" => array ( "table_array" => array (
"edit_group_id" => array ( "edit_group_id" => array (
@@ -98,4 +99,4 @@ $edit_groups = array (
) )
); );
# __END__ // __END__

View File

@@ -1,4 +1,5 @@
<?php <?php
$edit_languages=array ( $edit_languages=array (
"table_array" => array ( "table_array" => array (
"edit_language_id" => array ( "edit_language_id" => array (
@@ -71,4 +72,4 @@ $edit_languages=array (
"table_name" => "edit_language" "table_name" => "edit_language"
); );
# __END__ // __END__

View File

@@ -1,4 +1,5 @@
<?php <?php
$edit_menu_group = array ( $edit_menu_group = array (
"table_array" => array ( "table_array" => array (
"edit_menu_group_id" => array ( "edit_menu_group_id" => array (
@@ -36,4 +37,4 @@ $edit_menu_group = array (
) )
); );
# __END__ // __END__

View File

@@ -1,4 +1,5 @@
<?php <?php
$edit_pages = array ( $edit_pages = array (
"table_array" => array ( "table_array" => array (
"edit_page_id" => array ( "edit_page_id" => array (
@@ -176,4 +177,4 @@ $edit_pages = array (
) // element list ) // element list
); );
# __END__ // __END__

View File

@@ -1,4 +1,5 @@
<?php <?php
$edit_schemes = array ( $edit_schemes = array (
"table_array" => array ( "table_array" => array (
"edit_scheme_id" => array ( "edit_scheme_id" => array (
@@ -53,4 +54,4 @@ $edit_schemes = array (
) )
); // main array ); // main array
# __END__ // __END__

View File

@@ -1,4 +1,5 @@
<?php <?php
$edit_users = array ( $edit_users = array (
"table_array" => array ( "table_array" => array (
"edit_user_id" => array ( "edit_user_id" => array (
@@ -257,4 +258,4 @@ $edit_users = array (
) )
); );
# __END__ // __END__

View File

@@ -1,4 +1,5 @@
<?php <?php
$edit_visible_group = array ( $edit_visible_group = array (
"table_array" => array ( "table_array" => array (
"edit_visible_group_id" => array ( "edit_visible_group_id" => array (
@@ -29,4 +30,4 @@ $edit_visible_group = array (
) )
); );
# __END__ // __END__

View File

@@ -1192,4 +1192,4 @@ EOM;
} }
} // close class } // close class
# __END__ // __END__

View File

@@ -359,4 +359,4 @@ class Backend extends \CoreLibs\DB\IO
} }
} }
# __END__ // __END__

View File

@@ -419,6 +419,7 @@ class Basic
{ {
unset($string); unset($string);
list($major, $minor, $patchlvl) = explode(".", $this->class_info[$class_name]["class_version"]); list($major, $minor, $patchlvl) = explode(".", $this->class_info[$class_name]["class_version"]);
$string = '';
$string .= "<b>-Class-info-[".$class_name."]-></b> Class Name: <b>".$this->class_info[$class_name]["class_name"]."</b><br>"; $string .= "<b>-Class-info-[".$class_name."]-></b> Class Name: <b>".$this->class_info[$class_name]["class_name"]."</b><br>";
$string .= "<b>-Class-info-[".$class_name."]-></b> Class Author: <b>".$this->class_info[$class_name]["class_author"]."</b><br>"; $string .= "<b>-Class-info-[".$class_name."]-></b> Class Author: <b>".$this->class_info[$class_name]["class_author"]."</b><br>";
$string .= "<b>-Class-info-[".$class_name."]-></b> Class Version: <b>".$this->class_info[$class_name]["class_version"]."</b><br>"; $string .= "<b>-Class-info-[".$class_name."]-></b> Class Version: <b>".$this->class_info[$class_name]["class_version"]."</b><br>";
@@ -1196,6 +1197,7 @@ class Basic
$pos = 0; $pos = 0;
$split = 36; // after 36 single bytes characters, if then comes MB, it is broken $split = 36; // after 36 single bytes characters, if then comes MB, it is broken
// has to 2 x 36 < 74 so the mb_encode_mimeheader 74 hardcoded split does not get triggered // has to 2 x 36 < 74 so the mb_encode_mimeheader 74 hardcoded split does not get triggered
$_string = '';
while ($pos < mb_strlen($string, $encoding)) { while ($pos < mb_strlen($string, $encoding)) {
$output = mb_strimwidth($string, $pos, $split, "", $encoding); $output = mb_strimwidth($string, $pos, $split, "", $encoding);
$pos += mb_strlen($output, $encoding); $pos += mb_strlen($output, $encoding);
@@ -1786,6 +1788,7 @@ class Basic
} }
// max should be 63 for this case // max should be 63 for this case
$max_rand = count($chars) - 1; $max_rand = count($chars) - 1;
$salt_string = '';
// create the salt part // create the salt part
for ($i = 1; $i <= $nSize; $i ++) { for ($i = 1; $i <= $nSize; $i ++) {
$salt_string .= $chars[mt_rand(0, $max_rand)]; $salt_string .= $chars[mt_rand(0, $max_rand)];
@@ -2490,4 +2493,4 @@ class Basic
} }
} }
# __END__ // __END__

View File

@@ -133,6 +133,7 @@ class ArrayIO extends \CoreLibs\DB\IO
public function dbDumpArray($write = 0) public function dbDumpArray($write = 0)
{ {
reset($this->table_array); reset($this->table_array);
$string = '';
foreach ($this->table_array as $column => $data_array) { foreach ($this->table_array as $column => $data_array) {
$string .= "<b>".$column."</b> -> ".$data_array["value"]."<br>"; $string .= "<b>".$column."</b> -> ".$data_array["value"]."<br>";
} }
@@ -200,20 +201,21 @@ class ArrayIO extends \CoreLibs\DB\IO
$q .= $this->pk_name." = ".$this->table_array[$this->pk_name]["value"]." "; $q .= $this->pk_name." = ".$this->table_array[$this->pk_name]["value"]." ";
// delete files and build FK query // delete files and build FK query
reset($this->table_array); reset($this->table_array);
$q_where = '';
foreach ($this->table_array as $column => $data_array) { foreach ($this->table_array as $column => $data_array) {
// suchen nach bildern und lschen ... // suchen nach bildern und lschen ...
if ($this->table_array[$column]["file"] && file_exists($this->table_array[$column]["url"].$this->table_array[$column]["value"])) { 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"])) { if (file_exists($this->table_array[$column]["path"].$this->table_array[$column]["value"])) {
unlink($this->table_array[$column]["path"].$this->table_array[$column]["value"]); unlink($this->table_array[$column]["path"].$this->table_array[$column]["value"]);
} }
$dateiname = str_replace("_tn", "", $this->table_array[$column]["value"]); $file_name = str_replace("_tn", "", $this->table_array[$column]["value"]);
if (file_exists($this->table_array[$column]["path"].$dateiname)) { if (file_exists($this->table_array[$column]["path"].$file_name)) {
unlink($this->table_array[$column]["path"].$dateiname); unlink($this->table_array[$column]["path"].$file_name);
} }
} }
// if we have a foreign key
if ($this->table_array[$column]["fk"]) { if ($this->table_array[$column]["fk"]) {
// zusammenstellen der FKs // create FK constraint checks
if ($q_where) { if ($q_where) {
$q_where .= " AND "; $q_where .= " AND ";
} }
@@ -251,6 +253,8 @@ class ArrayIO extends \CoreLibs\DB\IO
return $this->table_array; return $this->table_array;
} }
reset($this->table_array); reset($this->table_array);
$q_select = '';
$q_where = '';
// create select part & addition FK part // create select part & addition FK part
foreach ($this->table_array as $column => $data_array) { foreach ($this->table_array as $column => $data_array) {
if ($q_select) { if ($q_select) {
@@ -326,6 +330,9 @@ class ArrayIO extends \CoreLibs\DB\IO
} }
reset($this->table_array); reset($this->table_array);
$q_data = '';
$q_vars = '';
$q_where = '';
foreach ($this->table_array as $column => $data_array) { foreach ($this->table_array as $column => $data_array) {
/********************************* START FILE *************************************/ /********************************* START FILE *************************************/
// file upload // file upload
@@ -338,9 +345,9 @@ class ArrayIO extends \CoreLibs\DB\IO
if (file_exists($this->table_array[$column]["path"].$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"]); unlink($this->table_array[$column]["path"].$this->table_array[$column]["value"]);
} }
$dateiname = str_replace("_tn", "", $this->table_array[$column]["value"]); $file_name = str_replace("_tn", "", $this->table_array[$column]["value"]);
if (file_exists($this->table_array[$column]["path"].$dateiname)) { if (file_exists($this->table_array[$column]["path"].$file_name)) {
unlink($this->table_array[$column]["path"].$dateiname); unlink($this->table_array[$column]["path"].$file_name);
} }
$this->table_array[$column]["value"] = ""; $this->table_array[$column]["value"] = "";
} else { } else {
@@ -355,20 +362,19 @@ class ArrayIO extends \CoreLibs\DB\IO
$ext = end($filename_parts); $ext = end($filename_parts);
array_splice($filename_parts, -1, 1); array_splice($filename_parts, -1, 1);
$name = str_replace(" ", "_", implode(".", $filename_parts)); $name = str_replace(" ", "_", implode(".", $filename_parts));
//echo "PK: $pk_ids_file<br>"; $file_name = $name.".".$ext;
$dateiname = $name.$pk_ids_file.".".$ext; //echo "Dn: $file_name";
//echo "Dn: $dateiname"; copy($this->table_array[$column]["tmp"], $this->table_array[$column]["path"].$file_name);
copy($this->table_array[$column]["tmp"], $this->table_array[$column]["path"].$dateiname);
// automatisch thumbnail generieren, geht nur mit convert (ImageMagic!!!), aber nur bei bild .. // automatisch thumbnail generieren, geht nur mit convert (ImageMagic!!!), aber nur bei bild ..
if (strtolower($ext) == "jpeg" || strtolower($ext) == "jpg" || strtolower($ext) == "gif" || strtolower($ext) == "png") { if (strtolower($ext) == "jpeg" || strtolower($ext) == "jpg" || strtolower($ext) == "gif" || strtolower($ext) == "png") {
$dateiname_tn = $name.$pk_ids_file."_tn.".$ext; $file_name_tn = $name."_tn.".$ext;
$eingang = $this->table_array[$column]["path"].$dateiname; $eingang = $this->table_array[$column]["path"].$file_name;
$ausgang = $this->table_array[$column]["path"].$dateiname_tn; $ausgang = $this->table_array[$column]["path"].$file_name_tn;
$com = "convert -geometry 115 $eingang $ausgang"; $com = "convert -geometry 115 $eingang $ausgang";
exec($com); exec($com);
$this->table_array[$column]["value"] = $dateiname_tn; $this->table_array[$column]["value"] = $file_name_tn;
} else { } else {
$this->table_array[$column]["value"] = $dateiname; $this->table_array[$column]["value"] = $file_name;
} }
} elseif (file_exists($this->table_array[$column]["path"].$this->table_array[$column]["value"])) { } elseif (file_exists($this->table_array[$column]["path"].$this->table_array[$column]["value"])) {
// mach gar nix, wenn bild schon da ??? // mach gar nix, wenn bild schon da ???
@@ -546,4 +552,4 @@ class ArrayIO extends \CoreLibs\DB\IO
} }
} // end of class } // end of class
# __END__ // __END__

View File

@@ -511,6 +511,7 @@ class IO extends \CoreLibs\Basic
// NOTE : used in db_dump_data only // NOTE : used in db_dump_data only
private function __printArray($array) private function __printArray($array)
{ {
$string = '';
foreach ($array as $key => $value) { foreach ($array as $key => $value) {
$string .= $this->nbsp.'<b>'.$key.'</b> => '; $string .= $this->nbsp.'<b>'.$key.'</b> => ';
if (is_array($value)) { if (is_array($value)) {
@@ -977,6 +978,7 @@ class IO extends \CoreLibs\Basic
} else { } else {
$array = $this->cursor_ext; $array = $this->cursor_ext;
} }
$string = '';
if (is_array($array)) { if (is_array($array)) {
$this->nbps = ''; $this->nbps = '';
$string .= $this->__printArray($array); $string .= $this->__printArray($array);
@@ -1816,6 +1818,7 @@ class IO extends \CoreLibs\Basic
// DESC : this is only needed for Postgresql. Converts postgresql arrays to PHP // DESC : this is only needed for Postgresql. Converts postgresql arrays to PHP
public function dbArrayParse($text) public function dbArrayParse($text)
{ {
$output = array ();
return $this->db_functions->__dbArrayParse($text, $output); return $this->db_functions->__dbArrayParse($text, $output);
} }

View File

@@ -148,7 +148,7 @@ class PgSQL
{ {
$result = pg_execute($this->dbh, $name, $data); $result = pg_execute($this->dbh, $name, $data);
if (!$result) { if (!$result) {
$this->last_error_query = $query; $this->last_error_query = $name;
} }
return $result; return $result;
} }
@@ -428,4 +428,4 @@ class PgSQL
} }
} }
# __END__ // __END__

View File

@@ -45,4 +45,4 @@ class CachedFileReader extends CoreLibs\Language\Core\StringReader
} }
} }
# __END__ // __END__

View File

@@ -88,4 +88,4 @@ class FileReader
} }
} }
# __END__ // __END__

View File

@@ -146,8 +146,8 @@ class GetTextReader
private function load_tables() private function load_tables()
{ {
if (is_array($this->cache_translations) && if (is_array($this->cache_translations) &&
is_array($this->table_originals) && is_array($this->table_originals) &&
is_array($this->table_translations)) { is_array($this->table_translations)) {
return; return;
} }
@@ -457,4 +457,4 @@ class GetTextReader
} }
} }
# __END__ // __END__

View File

@@ -51,4 +51,4 @@ class StreamReader
} }
} }
# __END__ // __END__

View File

@@ -64,4 +64,4 @@ class StringReader
} }
} }
# __END__ // __END__

View File

@@ -323,7 +323,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
$this->table_array = array (); $this->table_array = array ();
} }
reset($this->table_array); reset($this->table_array);
$string .= "<b>TABLE ARRAY DUMP:</b> ".$this->table_name."<br>"; $string = "<b>TABLE ARRAY DUMP:</b> ".$this->table_name."<br>";
foreach ($this->table_array as $key => $value) { foreach ($this->table_array as $key => $value) {
$string .= "<b>$key</b>: ".$value["value"]."<br>"; $string .= "<b>$key</b>: ".$value["value"]."<br>";
} }
@@ -557,7 +557,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
if ($res[$this->int_pk_name] == $this->table_array[$this->int_pk_name]["value"]) { if ($res[$this->int_pk_name] == $this->table_array[$this->int_pk_name]["value"]) {
$pk_selected = $res[$this->int_pk_name]; $pk_selected = $res[$this->int_pk_name];
} }
unset($t_string); $t_string = '';
for ($i = 0, $i_max = count($this->field_array); $i < $i_max; $i ++) { for ($i = 0, $i_max = count($this->field_array); $i < $i_max; $i ++) {
if ($t_string) { if ($t_string) {
$t_string .= ", "; $t_string .= ", ";
@@ -1013,7 +1013,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
} }
// do optional error checks like for normal fields // do optional error checks like for normal fields
// currently active: unique/alphanumeric // currently active: unique/alphanumeric
if ($data_rray['error_check']) { if ($data_array['error_check']) {
foreach (explode('|', $value["error_check"]) as $error_check) { foreach (explode('|', $value["error_check"]) as $error_check) {
switch ($error_check) { switch ($error_check) {
// check unique, check if field in table is not yet exist // check unique, check if field in table is not yet exist
@@ -1314,6 +1314,9 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
// go through all submitted data // go through all submitted data
// for ($i = 0; $i < count($_POST[$el_name]); $i ++) // for ($i = 0; $i < count($_POST[$el_name]); $i ++)
for ($i = 0; $i < $max; $i ++) { for ($i = 0; $i < $max; $i ++) {
$q_data[$i] = '';
$q_names[$i] = '';
$q_values[$i] = '';
// if we have enable name & delete set, then only insert/update those which are flagged as active // if we have enable name & delete set, then only insert/update those which are flagged as active
// check if mandatory field is set, if not set "do not write flag" // check if mandatory field is set, if not set "do not write flag"
if ($data_array["mandatory"] && !$_POST[$prfx.$el_name][$i]) { if ($data_array["mandatory"] && !$_POST[$prfx.$el_name][$i]) {
@@ -1718,4 +1721,4 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
} }
} // end of class } // end of class
# __END__ // __END__

View File

@@ -527,7 +527,7 @@ class ProgressBar
case 'percent': case 'percent':
// only one inner percent // only one inner percent
// print "STYLE[$name]: ".$style_lbl."<br>"; // print "STYLE[$name]: ".$style_lbl."<br>";
if (!$html_percent) { if (!isset($html_percent)) {
$html_percent = '<div id="plbl'.$name.$this->code.'" style="'.$style_lbl.'width:'.$data['width'].'px;line-height:1;text-shadow: 0 0 .2em white, 0 0 .5em white;">'.$this->__calculatePercent($this->step).'%</div>'."\n"; $html_percent = '<div id="plbl'.$name.$this->code.'" style="'.$style_lbl.'width:'.$data['width'].'px;line-height:1;text-shadow: 0 0 .2em white, 0 0 .5em white;">'.$this->__calculatePercent($this->step).'%</div>'."\n";
} }
break; break;
@@ -669,4 +669,4 @@ class ProgressBar
} }
} }
# __END__ // __END__

View File

@@ -29,4 +29,4 @@ class SmartyExtend extends SmartyBC
} }
} }
# __END__ // __END__

View File

@@ -28,4 +28,4 @@ class qqUploadedFileForm
} }
} }
# __END__ // __END__

View File

@@ -43,4 +43,4 @@ class qqUploadedFileXhr
} }
} }
# __END__ // __END__

View File

@@ -109,4 +109,4 @@ class qqFileUploader
} }
} }
# __END__ // __END__

View File

@@ -108,3 +108,5 @@ function MyErrorHandler($type, $message, $file, $line, $context)
// init the error handler // init the error handler
set_error_handler("MyErrorHandler"); set_error_handler("MyErrorHandler");
// __END__

View File

@@ -54,4 +54,4 @@ if (class_exists('Autoload', false) === false) {
spl_autoload_register('Autoloader\Autoload::load', true, true); spl_autoload_register('Autoloader\Autoload::load', true, true);
} // end check for already defined } // end check for already defined
# __END__ // __END__