Switch php code tag, fix php code

all files use <?php for code tag open
fix various bugs & speed problems. eg switch from while (each ...) to
foreach, ...
This commit is contained in:
Clemens Schwaighofer
2018-04-03 16:39:57 +09:00
parent 8a6a83ef06
commit bf5486a59e
20 changed files with 41 additions and 40 deletions

View File

@@ -1,4 +1,4 @@
<?
<?php
$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations
$DEBUG_ALL = 1;
$PRINT_ALL = 1;

View File

@@ -1,4 +1,4 @@
<?
<?php
/********************************************************************
* AUTHOR: Clemens "Gullevek" Schwaighofer (www.gullevek.org)
* CREATED: 2003/06/10

View File

@@ -1,4 +1,4 @@
<?
<?php
/********************************************************************
* AUTHOR: Clemens Schwaighofer
* CREATED: 2001/07/11

View File

@@ -1,4 +1,4 @@
<?
<?php
/********************************************************************
* AUTHOR: Clemens Schwaighofer
* CREATED: 2005/07/13

View File

@@ -1,4 +1,4 @@
<?
<?php
/********************************************************************
* AUTHOR: Clemens Schwaighofer
* CREATED: 2008/08/14

View File

@@ -1,4 +1,4 @@
<?
<?php
/********************************************************************
* AUTHOR: Clemens Schwaighofer
* CREATED: 2008/08/01

View File

@@ -1,4 +1,4 @@
<?
<?php
/********************************************************************
* AUTHOR: Clemens Schwaighofer
* CREATED: 2007/09/03

View File

@@ -1,4 +1,4 @@
<?
<?php
/********************************************************************
* AUTHOR: Clemens Schwaighofer
* CREATED: 2005/07/12

View File

@@ -1,4 +1,4 @@
<?
<?php
$ENABLE_ERROR_HANDLING = 0;
$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations
$DEBUG_ALL = 1;

View File

@@ -1,4 +1,4 @@
<?
<?php
/********************************************************************
* AUTHOR: Clemens "Gullevek" Schwaighofer (www.gullevek.org)
* CREATED: 2003/06/10

View File

@@ -1,4 +1,4 @@
<?
<?php
/*********************************************************************
* AUTHOR: Clemens "Gullevek" Schwaighofer (www.gullevek.org)
* CREATED: 2000/06/01

View File

@@ -1,4 +1,4 @@
<?
<?php
/*********************************************************************
* AUTHOR: Clemens "Gullevek" Schwaighofer (www.gullevek.org)
* CREATED: 2006/08/15
@@ -167,7 +167,7 @@ class Backend extends \CoreLibs\DB\IO
// 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"]) {
@@ -192,7 +192,7 @@ class Backend extends \CoreLibs\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 .= "&";
}

View File

@@ -1,4 +1,5 @@
<?/*********************************************************************
<?php
/*********************************************************************
* AUTHOR: Clemens "Gullevek" Schwaighofer (www.gullevek.org)
* CREATED: 2003/03/24
* VERSION: 2.0.0
@@ -590,7 +591,7 @@ class Basic
$string = $this->error_msg_prefix;
}
$script_end = $this->runningTime();
while (list($level, $temp_debug_output) = each($this->error_msg)) {
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 .= '<div style="font-size: 12px;">[<span style="font-style: italic; color: #c56c00;">'.$level.'</span>] '.(($string) ? "<b>**** ".$this->htmlent($string)." ****</b>\n" : "").'</div>';
@@ -1071,7 +1072,8 @@ class Basic
// 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 ++) {
// 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];
@@ -1187,7 +1189,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
@@ -1496,7 +1498,7 @@ 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
@@ -1544,7 +1546,7 @@ class Basic
// 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);
}
@@ -1640,10 +1642,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$';
@@ -1685,7 +1687,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);
}

View File

@@ -1,4 +1,4 @@
<?
<?php
/*********************************************************************
* AUTHOR: Clemens "Gullevek" Schwaighofer (www.gullevek.org)
* CREATED: 2002/12/17
@@ -68,7 +68,7 @@ class ArrayIO extends \CoreLibs\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;
}
@@ -133,7 +133,7 @@ class ArrayIO extends \CoreLibs\DB\IO
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 .= "<b>".$column."</b> -> ".$data_array["value"]."<br>";
}
// add output to internal error_msg
@@ -173,7 +173,7 @@ class ArrayIO extends \CoreLibs\DB\IO
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) {
@@ -200,7 +200,7 @@ class ArrayIO extends \CoreLibs\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)) {
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"])) {
@@ -252,7 +252,7 @@ class ArrayIO extends \CoreLibs\DB\IO
}
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 .= ", ";
}
@@ -279,7 +279,7 @@ class ArrayIO extends \CoreLibs\DB\IO
if ($this->dbExec($q)) {
if ($res = $this->dbFetchArray()) {
reset($this->table_array);
while (list($column, $data_array) = each($this->table_array)) {
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]."<br>";
@@ -326,8 +326,7 @@ class ArrayIO extends \CoreLibs\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"]) {
@@ -434,7 +433,7 @@ class ArrayIO extends \CoreLibs\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) {

View File

@@ -1,4 +1,4 @@
<?
<?php
/********************************************************************
* AUTHOR: Clemens "Gullevek" Schwaighofer (www.gullevek.org)
* CREATED: 2000/11/23
@@ -605,7 +605,7 @@ class IO extends \CoreLibs\Basic
// 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

View File

@@ -1,4 +1,4 @@
<?
<?php
/*********************************************************************
* AUTHOR: Clemens "Gullevek" Schwaighofer (www.gullevek.org)
* CREATED: 2003/04/09

View File

@@ -1,4 +1,4 @@
<?
<?php
/*********************************************************************
* AUTHOR: Clemens "Gullevek" Schwaighofer (www.gullevek.org)
* CREATED: 2004/11/18

View File

@@ -1,4 +1,4 @@
<?
<?php
/********************************************************************
* AUTHOR: Clemens "Gullevek" Schwaighofer (www.gullevek.org)
* CREATED: 2002/10/22

View File

@@ -1,4 +1,4 @@
<?
<?php
/********************************************************************
* AUTHOR: Clemens "Gullevek" Schwaighofer (www.gullevek.org)
* CREATED: 2004/12/21

View File

@@ -1,4 +1,4 @@
<?
<?php
/*********************************************************************
* AUTHOR: Clemens Schwaighofer
* CREATED: 2011/2/8