Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f7685463b4 | ||
|
|
dd92fa6031 | ||
|
|
6606f30ceb | ||
|
|
e1255e0872 | ||
|
|
5c53621f96 |
@@ -19,7 +19,8 @@
|
|||||||
_spl_autoload('Class.'.$class.'.inc');
|
_spl_autoload('Class.'.$class.'.inc');
|
||||||
|
|
||||||
$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]);
|
||||||
@@ -158,6 +159,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');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -118,9 +118,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
|
||||||
@@ -611,6 +612,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 +1246,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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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,12 @@ $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('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))
|
||||||
|
|||||||
Reference in New Issue
Block a user