Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f7ab65a15 | ||
|
|
c69607323a | ||
|
|
13a7900bd6 | ||
|
|
dc94fa1cd5 | ||
|
|
fd191877cd | ||
|
|
65a5785ce5 | ||
|
|
adcfaf5fa0 | ||
|
|
f7685463b4 | ||
|
|
dd92fa6031 | ||
|
|
6606f30ceb | ||
|
|
e1255e0872 | ||
|
|
5c53621f96 |
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
$lang = 'en_utf8';
|
$lang = 'en_utf8';
|
||||||
|
|
||||||
|
DEFINE('LOG_FILE_ID', 'classTest');
|
||||||
$login = new login($DB_CONFIG[LOGIN_DB], $lang);
|
$login = new login($DB_CONFIG[LOGIN_DB], $lang);
|
||||||
// init with standard
|
// init with standard
|
||||||
// $basic = new db_io($DB_CONFIG[MAIN_DB]);
|
// $basic = new db_io($DB_CONFIG[MAIN_DB]);
|
||||||
@@ -85,6 +86,18 @@
|
|||||||
$status = $basic->db_exec("INSERT INTO foo (test) values ('BAR 1 ".time()."'), ('BAR 2 ".time()."'), ('BAR 3 ".time()."') RETURNING foo_id, test");
|
$status = $basic->db_exec("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)."<br>";
|
print "DIRECT MULTIPLE INSERT STATUS: $status | PRIMARY KEYS: ".print_r($basic->insert_id, 1)." | PRIMARY KEY EXT: ".print_r($basic->insert_id_ext, 1)."<br>";
|
||||||
|
|
||||||
|
# db write class test
|
||||||
|
$table = 'foo';
|
||||||
|
$primary_key = ''; # unset
|
||||||
|
$db_write_table = array ('test');
|
||||||
|
$object_fields_not_touch = array ();
|
||||||
|
$object_fields_not_update = array ();
|
||||||
|
$data = array ('test' => 'SOMETHING '.time());
|
||||||
|
$primary_key = $basic->db_write_data_ext($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<br>";
|
||||||
|
$data = array ('test' => '');
|
||||||
|
$primary_key = $basic->db_write_data_ext($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<br>";
|
||||||
|
|
||||||
# async test queries
|
# 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->db_exec_async("SELECT test FROM foo, (SELECT pg_sleep(10)) as sub WHERE foo_id IN (27, 50, 67, 44, 10)");
|
||||||
@@ -158,6 +171,11 @@
|
|||||||
print $basic->magic_links('user@bubu.at').'<br>';
|
print $basic->magic_links('user@bubu.at').'<br>';
|
||||||
print $basic->magic_links('http://test.com/foo/bar.php?foo=1').'<br>';
|
print $basic->magic_links('http://test.com/foo/bar.php?foo=1').'<br>';
|
||||||
|
|
||||||
|
// compare date
|
||||||
|
$date_1 = '2017/1/5';
|
||||||
|
$date_2 = '2017-01-05';
|
||||||
|
print "COMPARE DATE: ".$basic->CompareDate($date_1, $date_2)."<br>";
|
||||||
|
|
||||||
// print error messages
|
// print error messages
|
||||||
print $basic->print_error_msg();
|
print $basic->print_error_msg();
|
||||||
|
|
||||||
|
|||||||
@@ -138,7 +138,7 @@
|
|||||||
$q .= "(".@$_SESSION['EUID'].", NOW(), '".$this->db_escape_string($event)."', '".$data."', '".$data_binary."', '".$this->page_name."', ";
|
$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'])."', '".$this->db_escape_string(@$_SERVER['HTTP_REFERER'])."', '".$this->db_escape_string(@$_SERVER['SCRIPT_FILENAME'])."', '".$this->db_escape_string(@$_SERVER['QUERY_STRING'])."', '".$this->db_escape_string(@$_SERVER['SERVER_NAME'])."', '".$this->db_escape_string(@$_SERVER['HTTP_HOST'])."', '".$this->db_escape_string(@$_SERVER['HTTP_ACCEPT'])."', '".$this->db_escape_string(@$_SERVER['HTTP_ACCEPT_CHARSET'])."', '".$this->db_escape_string(@$_SERVER['HTTP_ACCEPT_ENCODING'])."', '".session_id()."', ";
|
$q .= "'".@$_SERVER["REMOTE_ADDR"]."', '".$this->db_escape_string(@$_SERVER['HTTP_USER_AGENT'])."', '".$this->db_escape_string(@$_SERVER['HTTP_REFERER'])."', '".$this->db_escape_string(@$_SERVER['SCRIPT_FILENAME'])."', '".$this->db_escape_string(@$_SERVER['QUERY_STRING'])."', '".$this->db_escape_string(@$_SERVER['SERVER_NAME'])."', '".$this->db_escape_string(@$_SERVER['HTTP_HOST'])."', '".$this->db_escape_string(@$_SERVER['HTTP_ACCEPT'])."', '".$this->db_escape_string(@$_SERVER['HTTP_ACCEPT_CHARSET'])."', '".$this->db_escape_string(@$_SERVER['HTTP_ACCEPT_ENCODING'])."', '".session_id()."', ";
|
||||||
$q .= "'".$this->db_escape_string($this->action)."', '".$this->db_escape_string($this->action_id)."', '".$this->db_escape_string($this->action_yes)."', '".$this->db_escape_string($this->action_flag)."', '".$this->db_escape_string($this->action_menu)."', '".$this->db_escape_string($this->action_loaded)."', '".$this->db_escape_string($this->action_value)."', '".$this->db_escape_string($this->action_error)."')";
|
$q .= "'".$this->db_escape_string($this->action)."', '".$this->db_escape_string($this->action_id)."', '".$this->db_escape_string($this->action_yes)."', '".$this->db_escape_string($this->action_flag)."', '".$this->db_escape_string($this->action_menu)."', '".$this->db_escape_string($this->action_loaded)."', '".$this->db_escape_string($this->action_value)."', '".$this->db_escape_string($this->action_error)."')";
|
||||||
$this->db_exec($q, 'edit_log_id');
|
$this->db_exec($q, 'NULL');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@
|
|||||||
* GenAssocArray -> generactes a new associativ array from an existing array
|
* GenAssocArray -> generactes a new associativ array from an existing array
|
||||||
* CheckDate -> checks if a date is valid
|
* 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
|
* 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)
|
* _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
|
* before if a new php version is found
|
||||||
* crypt* -> encrypt and decrypt login string data, used by Login class
|
* crypt* -> encrypt and decrypt login string data, used by Login class
|
||||||
@@ -118,9 +119,10 @@
|
|||||||
// log file name
|
// log file name
|
||||||
private $log_file_name_ext = 'log'; // use this for date rotate
|
private $log_file_name_ext = 'log'; // use this for date rotate
|
||||||
public $log_max_filesize = 0; // set in kilobytes
|
public $log_max_filesize = 0; // set in kilobytes
|
||||||
private $log_print_file = 'error_msg##LEVEL####CLASS####PAGENAME####DATE##';
|
private $log_print_file = 'error_msg##LOGID####LEVEL####CLASS####PAGENAME####DATE##';
|
||||||
private $log_file_unique_id; // a unique ID set only once for call derived from this class
|
private $log_file_unique_id; // a unique ID set only once for call derived from this class
|
||||||
public $log_print_file_date = 1; // if set add Y-m-d and do automatic daily rotation
|
public $log_print_file_date = 1; // if set add Y-m-d and do automatic daily rotation
|
||||||
|
private $log_file_id = LOG_FILE_ID ? LOG_FILE_ID : ''; // a alphanumeric name that has to be set as global definition
|
||||||
public $log_per_level = 0; // set, it will split per level (first parameter in debug call)
|
public $log_per_level = 0; // set, it will split per level (first parameter in debug call)
|
||||||
public $log_per_class = 0; // set, will split log per class
|
public $log_per_class = 0; // set, will split log per class
|
||||||
public $log_per_page = 0; // set, will split log per called file
|
public $log_per_page = 0; // set, will split log per called file
|
||||||
@@ -311,7 +313,7 @@
|
|||||||
if (!session_id())
|
if (!session_id())
|
||||||
{
|
{
|
||||||
// check if we have an external session name given, else skip this step
|
// check if we have an external session name given, else skip this step
|
||||||
if (SET_SESSION_NAME)
|
if (isset($GLOBALS['SET_SESSION_NAME']))
|
||||||
{
|
{
|
||||||
// set the session name for possible later check
|
// set the session name for possible later check
|
||||||
$this->session_name = SET_SESSION_NAME;
|
$this->session_name = SET_SESSION_NAME;
|
||||||
@@ -611,6 +613,12 @@
|
|||||||
$output = $error_string; // output formated error string to output file
|
$output = $error_string; // output formated error string to output file
|
||||||
// init base file path
|
// init base file path
|
||||||
$fn = ROOT.LOG.$this->log_print_file.'.'.$this->log_file_name_ext;
|
$fn = ROOT.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;
|
||||||
|
else
|
||||||
|
$rpl_string = '';
|
||||||
|
$fn = str_replace('##LOGID##', $rpl_string, $fn); // log id (like a log file prefix)
|
||||||
|
|
||||||
if ($this->log_per_run)
|
if ($this->log_per_run)
|
||||||
{
|
{
|
||||||
@@ -1239,8 +1247,8 @@
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
// splits the data up with / or -
|
// splits the data up with / or -
|
||||||
list ($start_year, $start_month, $start_day) = split('[/-]', $start_date);
|
list ($start_year, $start_month, $start_day) = preg_split('/[\/-]/', $start_date);
|
||||||
list ($end_year, $end_month, $end_day) = split('[/-]', $end_date);
|
list ($end_year, $end_month, $end_day) = preg_split('/[\/-]/', $end_date);
|
||||||
// check that month & day are two digits and then combine
|
// check that month & day are two digits and then combine
|
||||||
foreach (array('start', 'end') as $prefix)
|
foreach (array('start', 'end') as $prefix)
|
||||||
{
|
{
|
||||||
@@ -1267,6 +1275,25 @@
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// METHOD: 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)
|
||||||
|
{
|
||||||
|
// pre check for empty or wrong
|
||||||
|
if ($start_date == '--' || $end_date == '--' || !$start_date || !$end_date)
|
||||||
|
return FALSE;
|
||||||
|
$start_timestamp = strtotime($start_datetime);
|
||||||
|
$end_timestamp = strtotime($end_datetime);
|
||||||
|
if ($start_timestamp < $end_timestamp)
|
||||||
|
return -1;
|
||||||
|
if ($start_timestamp == $end_timestamp)
|
||||||
|
return 0;
|
||||||
|
if ($start_timestamp > $end_timestamp)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// METHOD: ArrayToString
|
// METHOD: ArrayToString
|
||||||
// PARAMS: array, connect char
|
// PARAMS: array, connect char
|
||||||
// RETRUN: string
|
// RETRUN: string
|
||||||
|
|||||||
@@ -1391,34 +1391,41 @@
|
|||||||
// if this is an insert query, check if we can add a return
|
// if this is an insert query, check if we can add a return
|
||||||
if ($this->_check_query_for_insert($query, true))
|
if ($this->_check_query_for_insert($query, true))
|
||||||
{
|
{
|
||||||
// set primary key name
|
if ($pk_name != 'NULL')
|
||||||
// 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
|
// set primary key name
|
||||||
list($schema, $table) = $this->_db_return_table($query);
|
// current: only via parameter
|
||||||
if (!$this->pk_name_table[$table])
|
if (!$pk_name)
|
||||||
{
|
{
|
||||||
$this->pk_name_table[$table] = $this->db_functions->_db_primary_key($table, $schema);
|
// 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);
|
||||||
|
if (!$this->pk_name_table[$table])
|
||||||
|
{
|
||||||
|
$this->pk_name_table[$table] = $this->db_functions->_db_primary_key($table, $schema);
|
||||||
|
}
|
||||||
|
$pk_name = $this->pk_name_table[$table];
|
||||||
|
}
|
||||||
|
if ($pk_name)
|
||||||
|
$this->prepare_cursor[$stm_name]['pk_name'] = $pk_name;
|
||||||
|
// if no returning, then add it
|
||||||
|
if (!preg_match("/ returning /i", $query) && $this->prepare_cursor[$stm_name]['pk_name'])
|
||||||
|
{
|
||||||
|
$query .= " RETURNING ".$this->prepare_cursor[$stm_name]['pk_name'];
|
||||||
|
$this->prepare_cursor[$stm_name]['returning_id'] = true;
|
||||||
|
}
|
||||||
|
// if returning exists but not pk_name, add it
|
||||||
|
else if (preg_match("/ returning (.*)/i", $query, $matches) && $this->prepare_cursor[$stm_name]['pk_name'])
|
||||||
|
{
|
||||||
|
if (!preg_match("/{$this->prepare_cursor[$stm_name]['pk_name']}/", $matches[1]))
|
||||||
|
{
|
||||||
|
$query .= " , ".$this->prepare_cursor[$stm_name]['pk_name'];
|
||||||
|
}
|
||||||
|
$this->prepare_cursor[$stm_name]['returning_id'] = true;
|
||||||
}
|
}
|
||||||
$pk_name = $this->pk_name_table[$table];
|
|
||||||
}
|
}
|
||||||
if ($pk_name)
|
else
|
||||||
|
{
|
||||||
$this->prepare_cursor[$stm_name]['pk_name'] = $pk_name;
|
$this->prepare_cursor[$stm_name]['pk_name'] = $pk_name;
|
||||||
// if no returning, then add it
|
|
||||||
if (!preg_match("/ returning /i", $query) && $this->prepare_cursor[$stm_name]['pk_name'])
|
|
||||||
{
|
|
||||||
$query .= " RETURNING ".$this->prepare_cursor[$stm_name]['pk_name'];
|
|
||||||
$this->prepare_cursor[$stm_name]['returning_id'] = true;
|
|
||||||
}
|
|
||||||
// if returning exists but not pk_name, add it
|
|
||||||
else if (preg_match("/ returning (.*)/i", $query, $matches) && $this->prepare_cursor[$stm_name]['pk_name'])
|
|
||||||
{
|
|
||||||
if (!preg_match("/{$this->prepare_cursor[$stm_name]['pk_name']}/", $matches[1]))
|
|
||||||
{
|
|
||||||
$query .= " , ".$this->prepare_cursor[$stm_name]['pk_name'];
|
|
||||||
}
|
|
||||||
$this->prepare_cursor[$stm_name]['returning_id'] = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// search for $1, $2, in the query and push it into the control array
|
// search for $1, $2, in the query and push it into the control array
|
||||||
@@ -1484,7 +1491,7 @@ $this->debug('ExecuteData', 'ERROR in STM['.$stm_name.'|'.$this->prepare_cursor[
|
|||||||
$this->_db_error($this->prepare_cursor[$stm_name]['result']);
|
$this->_db_error($this->prepare_cursor[$stm_name]['result']);
|
||||||
$this->_db_debug('db', '<span style="color: red;"><b>DB-Error</b> '.$stm_name.': Execution failed</span>', 'DB_ERROR');
|
$this->_db_debug('db', '<span style="color: red;"><b>DB-Error</b> '.$stm_name.': Execution failed</span>', 'DB_ERROR');
|
||||||
}
|
}
|
||||||
if ($this->_check_query_for_insert($this->prepare_cursor[$stm_name]['query'], true))
|
if ($this->_check_query_for_insert($this->prepare_cursor[$stm_name]['query'], true) && $this->prepare_cursor[$stm_name]['pk_name'] != 'NULL')
|
||||||
{
|
{
|
||||||
if (!$this->prepare_cursor[$stm_name]['returning_id'])
|
if (!$this->prepare_cursor[$stm_name]['returning_id'])
|
||||||
{
|
{
|
||||||
@@ -1493,6 +1500,7 @@ $this->debug('ExecuteData', 'ERROR in STM['.$stm_name.'|'.$this->prepare_cursor[
|
|||||||
elseif ($code)
|
elseif ($code)
|
||||||
{
|
{
|
||||||
$this->insert_id = array ();
|
$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 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
|
// 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->_db_fetch_array($code, PGSQL_ASSOC))
|
||||||
@@ -1518,12 +1526,13 @@ $this->debug('ExecuteData', 'ERROR in STM['.$stm_name.'|'.$this->prepare_cursor[
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// failed to get insert id
|
// failed to get insert id
|
||||||
$this->insert_id = '';
|
$this->insert_id = '';
|
||||||
$this->warning_id = 33;
|
$this->warning_id = 33;
|
||||||
$this->_db_error('db', '<span style="color: orange;"><b>DB-Warning</b> '.$stm_name.': insert id returned no data</span>', 'DB_WARNING');
|
$this->_db_error();
|
||||||
}
|
$this->_db_debug('db', '<span style="color: orange;"><b>DB-Warning</b> '.$stm_name.': insert id returned no data</span>', 'DB_WARNING');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// this error handling is only for pgsql
|
// this error handling is only for pgsql
|
||||||
if (is_array($this->insert_id))
|
if (is_array($this->insert_id))
|
||||||
@@ -1658,7 +1667,13 @@ $this->debug('ExecuteData', 'ERROR in STM['.$stm_name.'|'.$this->prepare_cursor[
|
|||||||
// DESC: writes into one table based on array of table columns
|
// 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 db_write_data($write_array, $not_write_array, $primary_key, $table, $data = array ())
|
||||||
{
|
{
|
||||||
$not_write_upodate_array = array ();
|
if (!is_array($write_array))
|
||||||
|
$write_array = array ();
|
||||||
|
if (!is_array($not_write_array))
|
||||||
|
$not_write_array = array ();
|
||||||
|
if (is_array($table))
|
||||||
|
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->db_write_data_ext($write_array, $primary_key, $table, $not_write_array, $not_write_update_array, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1682,7 +1697,9 @@ $this->debug('ExecuteData', 'ERROR in STM['.$stm_name.'|'.$this->prepare_cursor[
|
|||||||
'value' => $primary_key
|
'value' => $primary_key
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
// var set for strings
|
||||||
|
$q_sub_value = '';
|
||||||
|
$q_sub_data = '';
|
||||||
// get the table layout and row types
|
// 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->db_show_table_meta_data(($this->db_schema ? $this->db_schema.'.' : '').$table);
|
||||||
foreach ($write_array as $field)
|
foreach ($write_array as $field)
|
||||||
@@ -1693,8 +1710,10 @@ $this->debug('ExecuteData', 'ERROR in STM['.$stm_name.'|'.$this->prepare_cursor[
|
|||||||
$_data = (count($data) >= 1) ? $data[$field] : $GLOBALS[$field];
|
$_data = (count($data) >= 1) ? $data[$field] : $GLOBALS[$field];
|
||||||
$has_default = $table_data[$field]['has default'];
|
$has_default = $table_data[$field]['has default'];
|
||||||
$not_null = $table_data[$field]['not null'];
|
$not_null = $table_data[$field]['not null'];
|
||||||
|
// we detect bool, so we can force a write on "false"
|
||||||
|
$is_bool = $table_data[$field]['type'] == 'bool' ? true : false;
|
||||||
// write if the field has to be not null, or if there is no data and the field has no default values or if there is data
|
// write if the field has to be not null, or if there is no data and the field has no default values or if there is data
|
||||||
if (($not_null && !$_data) || (!$has_default && !$_data) || (is_numeric($_data) && isset($_data)) || $_data)
|
if (($not_null && !$_data) || (!$has_default && !$_data) || ($is_bool && !$_data) || (is_numeric($_data) && isset($_data)) || ($primary_key['value'] && !$_data) || $_data)
|
||||||
{
|
{
|
||||||
if ($q_sub_value && !$primary_key['value'])
|
if ($q_sub_value && !$primary_key['value'])
|
||||||
$q_sub_value .= ', ';
|
$q_sub_value .= ', ';
|
||||||
@@ -1711,7 +1730,7 @@ $this->debug('ExecuteData', 'ERROR in STM['.$stm_name.'|'.$this->prepare_cursor[
|
|||||||
if (strstr($table_data[$field]['type'], 'int'))
|
if (strstr($table_data[$field]['type'], 'int'))
|
||||||
$q_sub_data .= (is_numeric($_data) && isset($_data)) ? $_data : ($has_default ? $has_default : 'NULL');
|
$q_sub_data .= (is_numeric($_data) && isset($_data)) ? $_data : ($has_default ? $has_default : 'NULL');
|
||||||
else
|
else
|
||||||
$q_sub_data .= ($_data) ? "'".$this->db_escape_string($_data)."'" : ($has_default ? "'".$this->db_escape_string($has_default)."'" : 'NULL');
|
$q_sub_data .= ($_data ? "'".$this->db_escape_string($_data)."'" : (($primary_key['value'] && $is_bool) ? "'".$this->db_boolean($_data, true)."'" : ($has_default ? "'".$this->db_escape_string($has_default)."'" : 'NULL')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -581,7 +581,7 @@
|
|||||||
{
|
{
|
||||||
$this->acl['page'] = $_SESSION['GROUP_ACL_LEVEL'];
|
$this->acl['page'] = $_SESSION['GROUP_ACL_LEVEL'];
|
||||||
}
|
}
|
||||||
if ($_SESSION['PAGES_ACL_LEVEL'][$this->page_name] != -1)
|
if (isset($_SESSION['PAGES_ACL_LEVEL'][$this->page_name]) && $_SESSION['PAGES_ACL_LEVEL'][$this->page_name] != -1)
|
||||||
{
|
{
|
||||||
$this->acl['page'] = $_SESSION['PAGES_ACL_LEVEL'][$this->page_name];
|
$this->acl['page'] = $_SESSION['PAGES_ACL_LEVEL'][$this->page_name];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ class ProgressBar
|
|||||||
public $step = 0; // current step
|
public $step = 0; // current step
|
||||||
public $position = array(); // current bar position
|
public $position = array(); // current bar position
|
||||||
|
|
||||||
|
public $clear_buffer_size = 1; // we need to send this before the lfush to get browser output
|
||||||
|
public $clear_buffer_size_init = 1024*1024; // if I don't send that junk, it won't send anything
|
||||||
|
|
||||||
// public vars
|
// public vars
|
||||||
|
|
||||||
public $min = 0; // minimal steps
|
public $min = 0; // minimal steps
|
||||||
@@ -74,10 +77,22 @@ class ProgressBar
|
|||||||
$this->width = $width;
|
$this->width = $width;
|
||||||
if ($height > 0)
|
if ($height > 0)
|
||||||
$this->height = $height;
|
$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);
|
||||||
}
|
}
|
||||||
|
|
||||||
// private functions
|
// private functions
|
||||||
|
|
||||||
|
private function _flushCache($clear_buffer_size = 0)
|
||||||
|
{
|
||||||
|
if (!$clear_buffer_size)
|
||||||
|
$clear_buffer_size = $this->clear_buffer_size;
|
||||||
|
echo str_repeat(' ', $clear_buffer_size);
|
||||||
|
ob_flush();
|
||||||
|
flush();
|
||||||
|
}
|
||||||
|
|
||||||
private function _calculatePercent($step)
|
private function _calculatePercent($step)
|
||||||
{
|
{
|
||||||
// avoid divison through 0
|
// avoid divison through 0
|
||||||
@@ -298,7 +313,7 @@ class ProgressBar
|
|||||||
$output .= 'document.getElementById("plbl'.$name.$this->code.'").style.align="'.$this->label[$name]['align'].'";';
|
$output .= 'document.getElementById("plbl'.$name.$this->code.'").style.align="'.$this->label[$name]['align'].'";';
|
||||||
$output .= '</script>'."\n";
|
$output .= '</script>'."\n";
|
||||||
echo $output;
|
echo $output;
|
||||||
flush();
|
$this->_flushCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,7 +323,7 @@ class ProgressBar
|
|||||||
if ($this->status != 'new')
|
if ($this->status != 'new')
|
||||||
{
|
{
|
||||||
echo '<script type="text/JavaScript">document.getElementById("plbl'.$name.$this->code.'").style.color="'.$color.'";</script>'."\n";
|
echo '<script type="text/JavaScript">document.getElementById("plbl'.$name.$this->code.'").style.color="'.$color.'";</script>'."\n";
|
||||||
flush();
|
$this->_flushCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,7 +333,7 @@ class ProgressBar
|
|||||||
if ($this->status != 'new')
|
if ($this->status != 'new')
|
||||||
{
|
{
|
||||||
echo '<script type="text/JavaScript">document.getElementById("plbl'.$name.$this->code.'").style.background="'.$color.'";</script>'."\n";
|
echo '<script type="text/JavaScript">document.getElementById("plbl'.$name.$this->code.'").style.background="'.$color.'";</script>'."\n";
|
||||||
flush();
|
$this->_flushCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,7 +364,7 @@ class ProgressBar
|
|||||||
$output .= 'document.getElementById("plbl'.$name.$this->code.'").style.font-weight="'.$this->label[$name]['font-weight'].'";';
|
$output .= 'document.getElementById("plbl'.$name.$this->code.'").style.font-weight="'.$this->label[$name]['font-weight'].'";';
|
||||||
$output .= '</script>'."\n";
|
$output .= '</script>'."\n";
|
||||||
echo $output;
|
echo $output;
|
||||||
flush();
|
$this->_flushCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,7 +375,7 @@ class ProgressBar
|
|||||||
if ($this->status != 'new')
|
if ($this->status != 'new')
|
||||||
{
|
{
|
||||||
echo '<script type="text/JavaScript">PBlabelText'.$this->code.'("'.$name.'","'.$this->label[$name]['value'].'");</script>'."\n";
|
echo '<script type="text/JavaScript">PBlabelText'.$this->code.'("'.$name.'","'.$this->label[$name]['value'].'");</script>'."\n";
|
||||||
flush();
|
$this->_flushCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,7 +385,7 @@ class ProgressBar
|
|||||||
if ($this->status != 'new')
|
if ($this->status != 'new')
|
||||||
{
|
{
|
||||||
echo '<script type="text/JavaScript">document.getElementById("pbar'.$this->code.'").style.background="'.$color.'";</script>'."\n";
|
echo '<script type="text/JavaScript">document.getElementById("pbar'.$this->code.'").style.background="'.$color.'";</script>'."\n";
|
||||||
flush();
|
$this->_flushCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,7 +395,7 @@ class ProgressBar
|
|||||||
if ($this->status != 'new')
|
if ($this->status != 'new')
|
||||||
{
|
{
|
||||||
echo '<script type="text/JavaScript">document.getElementById("pbrd'.$this->code.'").style.background="'.$color.'";</script>'."\n";
|
echo '<script type="text/JavaScript">document.getElementById("pbrd'.$this->code.'").style.background="'.$color.'";</script>'."\n";
|
||||||
flush();
|
$this->_flushCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,7 +413,7 @@ class ProgressBar
|
|||||||
echo 'PBposition'.$this->code.'("width",'.$this->position['width'].');';
|
echo 'PBposition'.$this->code.'("width",'.$this->position['width'].');';
|
||||||
echo 'PBposition'.$this->code.'("height",'.$this->position['height'].');';
|
echo 'PBposition'.$this->code.'("height",'.$this->position['height'].');';
|
||||||
echo '</script>'."\n";
|
echo '</script>'."\n";
|
||||||
flush();
|
$this->_flushCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -547,7 +562,7 @@ class ProgressBar
|
|||||||
{
|
{
|
||||||
$this->status = 'show';
|
$this->status = 'show';
|
||||||
echo $this->getHtml();
|
echo $this->getHtml();
|
||||||
flush();
|
$this->_flushCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function moveStep($step)
|
public function moveStep($step)
|
||||||
@@ -603,7 +618,7 @@ class ProgressBar
|
|||||||
if ($js != '')
|
if ($js != '')
|
||||||
{
|
{
|
||||||
echo '<script type="text/JavaScript">'.$js.'</script>'."\n";
|
echo '<script type="text/JavaScript">'.$js.'</script>'."\n";
|
||||||
flush();
|
$this->_flushCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -627,7 +642,7 @@ class ProgressBar
|
|||||||
$output .= 'document.getElementById("pbm'.$this->code.'").style.visibility="hidden";document.getElementById("pbm'.$this->code.'").style.display="none";';
|
$output .= 'document.getElementById("pbm'.$this->code.'").style.visibility="hidden";document.getElementById("pbm'.$this->code.'").style.display="none";';
|
||||||
$output .= '</script>'."\n";
|
$output .= '</script>'."\n";
|
||||||
echo $output;
|
echo $output;
|
||||||
flush();
|
$this->_flushCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -641,7 +656,7 @@ class ProgressBar
|
|||||||
$output .= 'document.getElementById("pbm'.$this->code.'").style.visibility="visible";document.getElementById("pbm'.$this->code.'").style.visibility="block";';
|
$output .= 'document.getElementById("pbm'.$this->code.'").style.visibility="visible";document.getElementById("pbm'.$this->code.'").style.visibility="block";';
|
||||||
$output .= '</script>'."\n";
|
$output .= '</script>'."\n";
|
||||||
echo $output;
|
echo $output;
|
||||||
flush();
|
$this->_flushCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,10 @@
|
|||||||
// DESC : wrapper for pg_prepare
|
// DESC : wrapper for pg_prepare
|
||||||
public function _db_prepare($name, $query)
|
public function _db_prepare($name, $query)
|
||||||
{
|
{
|
||||||
return @pg_prepare($this->dbh, $name, $query);
|
$result = @pg_prepare($this->dbh, $name, $query);
|
||||||
|
if (!$result)
|
||||||
|
$this->last_error_query = $query;
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// METHOD: _db_execute
|
// METHOD: _db_execute
|
||||||
@@ -121,7 +124,10 @@
|
|||||||
// DESC : wrapper for pg_execute for running a prepared statement
|
// DESC : wrapper for pg_execute for running a prepared statement
|
||||||
public function _db_execute($name, $data)
|
public function _db_execute($name, $data)
|
||||||
{
|
{
|
||||||
return @pg_execute($this->dbh, $name, $data);
|
$result = @pg_execute($this->dbh, $name, $data);
|
||||||
|
if (!$result)
|
||||||
|
$this->last_error_query = $query;
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// METHOD: _db_num_rows
|
// METHOD: _db_num_rows
|
||||||
|
|||||||
Reference in New Issue
Block a user