Compare commits

...

20 Commits

Author SHA1 Message Date
Clemens Schwaighofer
2e85bf5ee8 Bug fix in DB IO for wrong db debug check
Some debug print checks were done wrong
2017-11-02 18:42:41 +09:00
Clemens Schwaighofer
ff94efee8d Fix in class db io returning on insert
Skip add RETURNING on auto set if 'NULL' is set as a primary key.
On return, also run if count of returned ids is > 0 (so it actually runs
the extended return flow)
2017-11-02 17:04:43 +09:00
Clemens Schwaighofer
93f2cf9b73 DB IO Class: if not PK auto found, set to NULL to skip return
In case no primary key is set and the auto detect does not return a
primary key, set the primary key variable to 'NULL' string to trigger
skip in returning insert id flow.
2017-11-02 16:05:06 +09:00
Clemens Schwaighofer
c39e48a709 Bug fix Class DB IO data write function
The data write function did not write data correctly if it was empty or
null. Especially for boolean ones when set 0 was set NULL and not 'f'.

This is fixed now.
Also filles MUST set not null fields with 0/'' but does not add missing
column to list yet
2017-10-24 16:51:21 +09:00
Clemens Schwaighofer
1cc010818d Fix DB IO write array method
Data was not written correctly in connection with boolean field types as
the "has default" was used as if a default value, but it is just a flag
IF it has a default value
2017-09-26 13:33:52 +09:00
Clemens Schwaighofer
1e164f3b93 Delete wrong symlink, remove create_function call
create_function call is deprecated with PHP 7.2, so creat_function is
replaced by the correct anonymous function call for it
2017-09-11 14:28:47 +09:00
Clemens Schwaighofer
9f7ab65a15 Update Basic, DB IO, Login class
- DB IO: update the write data method to update data that is empty (aka
null) and not skip it (aka never unset data)
- Basic: add date time compare method based on strtotime
- Login: ACL for page level check if array is set before setting
anything
2017-09-07 18:24:52 +09:00
Clemens Schwaighofer
c69607323a Class DB IO update for db write
on UPDATE check if field is bool and then force write for unfilled (not
set) data
2017-09-04 19:02:20 +09:00
Clemens Schwaighofer
13a7900bd6 fix globals set check 2017-07-28 18:08:17 +09:00
Clemens Schwaighofer
dc94fa1cd5 PG class updates, basic class updates
In basic class, do SET_SESSION_NAME check with isset to avoid notice log
entries.

Change log/error return for execute data error

base postgresql calss calls set the last run query on error if no result
is returned for prepare and execute
2017-07-28 15:52:37 +09:00
Clemens Schwaighofer
fd191877cd Fix for not showing progress bar with single progress bar 2017-06-05 16:48:19 +09:00
Clemens Schwaighofer
65a5785ce5 Changed progress bar buffer clear
- send initial big buffer clear
- then do just flush/ob_flush
2017-04-13 14:52:07 +09:00
Clemens Schwaighofer
adcfaf5fa0 Progress bar class: centralize buffer clear method
Because browsers buffer size increased again I centralized the buffer
clear flow.

It now sends a 1024*256 bytes empty string before it runs an ob_flush
and flush call.

This should work with most browsers out there. Tested on macOS
firefox/safari/chrome
2017-04-13 14:28:43 +09:00
Clemens Schwaighofer
f7685463b4 error log ID settings added via global define
A global define for LOG_FILE_ID before any class is initialized (or any
place later allowed too) will add a sub id to the error_msg log file
before any other (level, class, etc) id.

This can be used to easily split between frontend and backend logs or
logs for a certain page without using pagename (eg to group all ajax
logs into one)
2017-04-11 10:25:07 +09:00
Clemens Schwaighofer
dd92fa6031 Do not auto return PK for edit log insert in Admin Backend class 2017-04-07 11:07:05 +09:00
Clemens Schwaighofer
6606f30ceb Basic date compare fix
The date compare now uses correct preg_split for splitting with - and /
as date separators
2017-04-03 17:52:49 +09:00
Clemens Schwaighofer
e1255e0872 DB IO: prepare pk null fix, split -> explode in Basic
- Basic class still had a "split" call -> change that to explode
- The prepare DB IO part missed setting pk name for the cursor to null
so no returning is assumed
2017-04-03 17:46:06 +09:00
Clemens Schwaighofer
5c53621f96 Update DB IO to skip returning on prepare statements
Same as normal exec if pk name is set to NULL
2017-04-03 17:38:33 +09:00
Clemens Schwaighofer
581518963b Fix bug in prepared statement returning ID
The wrong direct insert id primary key was used, not the statement based
one
2017-04-03 14:58:10 +09:00
Clemens Schwaighofer
23735eba92 add datepickr, update frontend default templates 2017-03-31 15:32:27 +09:00
12 changed files with 280 additions and 96 deletions

View File

@@ -1 +0,0 @@
smarty-3.1.27/

View File

@@ -19,7 +19,8 @@
_spl_autoload('Class.'.$class.'.inc');
$lang = 'en_utf8';
DEFINE('LOG_FILE_ID', 'classTest');
$login = new login($DB_CONFIG[LOGIN_DB], $lang);
// init with standard
// $basic = new db_io($DB_CONFIG[MAIN_DB]);
@@ -85,6 +86,26 @@
$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>";
# db write class test
$table = 'foo';
print "TABLE META DATA: ".$basic->print_ar($basic->db_show_table_meta_data($table))."<br>";
$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);
print "Wrote to DB tabel $table and got primary key $primary_key<br>";
$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);
print "Wrote to DB tabel $table and got primary key $primary_key<br>";
$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);
print "Wrote to DB tabel $table and got primary key $primary_key<br>";
$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);
print "Wrote to DB tabel $table and got primary key $primary_key<br>";
# 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)");
@@ -158,6 +179,11 @@
print $basic->magic_links('user@bubu.at').'<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 $basic->print_error_msg();

View File

@@ -0,0 +1 @@
.datepickr-wrapper{display:inline-block;position:relative}.datepickr-calendar{font-family:'Trebuchet MS',Tahoma,Verdana,Arial,sans-serif;font-size:12px;background-color:#eee;color:#333;border:1px solid #ddd;-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;padding:2px;display:none;position:absolute;top:100%;left:0;z-index:100}.open .datepickr-calendar{display:block}.datepickr-calendar .datepickr-months{background-color:#f6af3a;border:1px solid #e78f08;-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;color:#fff;padding:2px;text-align:center;font-size:120%}.datepickr-calendar .datepickr-next-month,.datepickr-calendar .datepickr-prev-month{color:#fff;text-decoration:none;padding:0 .4em;-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;cursor:pointer}.datepickr-calendar .datepickr-prev-month{float:left}.datepickr-calendar .datepickr-next-month{float:right}.datepickr-calendar .datepickr-current-month{padding:0 .5em}.datepickr-calendar .datepickr-next-month:hover,.datepickr-calendar .datepickr-prev-month:hover{background-color:#fdf5ce;color:#c77405}.datepickr-calendar table{border-collapse:collapse;padding:0;width:100%}.datepickr-calendar thead{font-size:90%}.datepickr-calendar td,.datepickr-calendar th{width:14.3%}.datepickr-calendar th{text-align:center;padding:5px}.datepickr-calendar td{text-align:right;padding:1px}.datepickr-calendar .datepickr-day{display:block;color:#1c94c4;background-color:#f6f6f6;border:1px solid #ccc;padding:5px;cursor:pointer}.datepickr-calendar .datepickr-day:hover{color:#C77405;background-color:#fdf5ce;border:1px solid #fbcb09}.datepickr-calendar .today .datepickr-day{background-color:#fff0A5;border:1px solid #fed22f;color:#363636}.datepickr-calendar .selected .datepickr-day{background-color:#1c94c4;color:#f6f6f6}.datepickr-calendar .disabled .datepickr-day,.datepickr-calendar .disabled .datepickr-day:hover{background-color:#eee;border:1px dotted #ccc;color:#bbb;cursor:default}

View File

@@ -0,0 +1,13 @@
var datepickr=function(d,c){var f,h,a=[],k;datepickr.prototype=datepickr.init.prototype;h=function(a){a._datepickr&&a._datepickr.destroy();a._datepickr=new datepickr.init(a,c);return a._datepickr};if(d.nodeName)return h(d);f=datepickr.prototype.querySelectorAll(d);if(1===f.length)return h(f[0]);for(k=0;k<f.length;k++)a.push(h(f[k]));return a};
datepickr.init=function(d,c){var f,h,a=this,k={dateFormat:"F j, Y",altFormat:null,altInput:null,minDate:null,maxDate:null,shorthandCurrentMonth:!1},l=document.createElement("div"),t=document.createElement("span"),u=document.createElement("table"),v=document.createElement("tbody"),g,m=new Date,B,n,p,w,C,r,x,D,E,s,F,G,y,H,z,A,I;l.className="datepickr-calendar";t.className="datepickr-current-month";c=c||{};B=function(){g=document.createElement("div");g.className="datepickr-wrapper";a.element.parentNode.insertBefore(g,
a.element);g.appendChild(a.element)};f={year:function(){return m.getFullYear()},month:{integer:function(){return m.getMonth()},string:function(a){var e=m.getMonth();return p(e,a)}},day:function(){return m.getDate()}};h={string:function(){return p(a.currentMonthView,a.config.shorthandCurrentMonth)},numDays:function(){return 1===a.currentMonthView&&(0===a.currentYearView%4&&0!==a.currentYearView%100||0===a.currentYearView%400)?29:a.l10n.daysInMonth[a.currentMonthView]}};n=function(b,e){var q="",d=new Date(e),
c={d:function(){var a=c.j();return 10>a?"0"+a:a},D:function(){return a.l10n.weekdays.shorthand[c.w()]},j:function(){return d.getDate()},l:function(){return a.l10n.weekdays.longhand[c.w()]},w:function(){return d.getDay()},F:function(){return p(c.n()-1,!1)},m:function(){var a=c.n();return 10>a?"0"+a:a},M:function(){return p(c.n()-1,!0)},n:function(){return d.getMonth()+1},U:function(){return d.getTime()/1E3},y:function(){return String(c.Y()).substring(2)},Y:function(){return d.getFullYear()}},f=b.split("");
a.forEach(f,function(a,b){c[a]&&"\\"!==f[b-1]?q+=c[a]():"\\"!==a&&(q+=a)});return q};p=function(b,e){return!0===e?a.l10n.months.shorthand[b]:a.l10n.months.longhand[b]};w=function(b,e,c,d){return b===d&&a.currentMonthView===e&&a.currentYearView===c};C=function(){var b=document.createElement("thead"),e=a.l10n.firstDayOfWeek,c=a.l10n.weekdays.shorthand;0<e&&e<c.length&&(c=[].concat(c.splice(e,c.length),c.splice(0,e)));b.innerHTML="<tr><th>"+c.join("</th><th>")+"</th></tr>";u.appendChild(b)};r=function(){var b=
(new Date(a.currentYearView,a.currentMonthView,1)).getDay(),c=h.numDays(),d=document.createDocumentFragment(),g=document.createElement("tr"),k,l="",p="",m="",n,b=b-a.l10n.firstDayOfWeek;0>b&&(b+=7);k=b;v.innerHTML="";0<b&&(g.innerHTML+='<td colspan="'+b+'">&nbsp;</td>');for(b=1;b<=c;b++){7===k&&(d.appendChild(g),g=document.createElement("tr"),k=0);l=w(f.day(),f.month.integer(),f.year(),b)?" today":"";a.selectedDate&&(p=w(a.selectedDate.day,a.selectedDate.month,a.selectedDate.year,b)?" selected":"");
if(a.config.minDate||a.config.maxDate)n=(new Date(a.currentYearView,a.currentMonthView,b)).getTime(),m="",a.config.minDate&&n<a.config.minDate&&(m=" disabled"),a.config.maxDate&&n>a.config.maxDate&&(m=" disabled");g.innerHTML+='<td class="'+l+p+m+'"><span class="datepickr-day">'+b+"</span></td>";k++}d.appendChild(g);v.appendChild(d)};x=function(){t.innerHTML=a.currentYearView+" "+h.string()};D=function(){var a=document.createElement("div");a.className="datepickr-months";a.innerHTML='<span class="datepickr-prev-month">&lt;</span><span class="datepickr-next-month">&gt;</span>';
a.appendChild(t);x();l.appendChild(a)};E=function(){0>a.currentMonthView&&(a.currentYearView--,a.currentMonthView=11);11<a.currentMonthView&&(a.currentYearView++,a.currentMonthView=0)};s=function(b){if(b.target!==a.element&&b.target!==g&&(b=b.target.parentNode,b!==g))for(;b!==g;)if(b=b.parentNode,null===b){A();break}};F=function(b){b=b.target;var c=b.className;c&&("datepickr-prev-month"===c||"datepickr-next-month"===c?("datepickr-prev-month"===c?a.currentMonthView--:a.currentMonthView++,E(),x(),r()):
"datepickr-day"!==c||a.hasClass(b.parentNode,"disabled")||(a.selectedDate={day:parseInt(b.innerHTML,10),month:a.currentMonthView,year:a.currentYearView},b=(new Date(a.currentYearView,a.currentMonthView,a.selectedDate.day)).getTime(),a.config.altInput&&(a.config.altInput.value=a.config.altFormat?n(a.config.altFormat,b):n(a.config.dateFormat,b)),a.element.value=n(a.config.dateFormat,b),A(),r()))};G=function(){D();C();r();u.appendChild(v);l.appendChild(u);g.appendChild(l)};y=function(){return"INPUT"===
a.element.nodeName?"focus":"click"};H=function(){a.addEventListener(a.element,y(),z);a.addEventListener(l,"click",F)};z=function(){a.addEventListener(document,"click",s);a.addClass(g,"open")};A=function(){a.removeEventListener(document,"click",s);a.removeClass(g,"open")};I=function(){var b,c;a.removeEventListener(document,"click",s);a.removeEventListener(a.element,y(),z);b=a.element.parentNode;b.removeChild(l);c=b.removeChild(a.element);b.parentNode.replaceChild(c,b)};(function(){var b,e;a.config=
{};a.destroy=I;for(b in k)a.config[b]=c[b]||k[b];a.element=d;a.element.value&&(e=Date.parse(a.element.value));e&&!isNaN(e)?(e=new Date(e),a.selectedDate={day:e.getDate(),month:e.getMonth(),year:e.getFullYear()},a.currentYearView=a.selectedDate.year,a.currentMonthView=a.selectedDate.month,a.currentDayView=a.selectedDate.day):(a.selectedDate=null,a.currentYearView=f.year(),a.currentMonthView=f.month.integer(),a.currentDayView=f.day());B();G();H()})();return a};
datepickr.init.prototype={hasClass:function(d,c){return d.classList.contains(c)},addClass:function(d,c){d.classList.add(c)},removeClass:function(d,c){d.classList.remove(c)},forEach:function(d,c){[].forEach.call(d,c)},querySelectorAll:document.querySelectorAll.bind(document),isArray:Array.isArray,addEventListener:function(d,c,f,h){d.addEventListener(c,f,h)},removeEventListener:function(d,c,f,h){d.removeEventListener(c,f,h)},l10n:{weekdays:{shorthand:"Sun Mon Tue Wed Thu Fri Sat".split(" "),longhand:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" ")},
months:{shorthand:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),longhand:"January February March April May June July August September October November December".split(" ")},daysInMonth:[31,28,31,30,31,30,31,31,30,31,30,31],firstDayOfWeek:0}};

View File

@@ -0,0 +1,62 @@
{*
********************************************************************
* AUTHOR: Clemens Schwaighofer
* DATE: 2008/12/24
* DESCRIPTION:
* main body
* HISTORY:
********************************************************************
*}
<html>
<head>
<title>{$HTML_TITLE}</title>
<meta http-equiv="Content-Type" content="text/html; charset={$DEFAULT_ENCODING}">
{if $STYLESHEET}
<link rel=stylesheet type="text/css" href="{$CSS}{$STYLESHEET}">
{/if}
<script language="JavaScript">
<!--
var DEBUG = {$JS_DEBUG};
//-->
</script>
<script language="JavaScript" src="{$js}/firebug.js"></script>
<script language="JavaScript" src="{$js}/debug.js"></script>
{if $JAVASCRIPT}
<script language="JavaScript" src="{$JS}{$JAVASCRIPT}"></script>
{/if}
{if $ajax_javascript}
<script language="JavaScript">
{$ajax_javascript}
</script>
{/if}
{if $JS_INCLUDE}
<script language="JavaScript" src="{$JS_INCLUDE}"></script>
{/if}
{* for including datepickr *}
{if $JS_DATEPICKR}
<link rel=stylesheet type="text/css" href="{$js}/datepickr/datepickr.min.css">
<script language="JavaScript" src="{$js}/datepickr/datepickr.min.js"></script>
{/if}
{* {popup_init src="`$js`/overlib/overlib.js"} *}
</head>
<body>
<form name="product_search" method="get">
<div style="border: 1px solid black; margin: 15px; padding: 5px;">
{include file="top_menu.tpl"}
</div>
<div>
{include file="$INCLUDE_TEMPLATE"}
</div>
</form>
{* debug info *}
{if $DEBUG}
<div style="width:{$table_width}px;" class="debug_message">
{$Id}<br>
<b>{$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}</b><br>
{$debug_error_msg}
</div>
{/if}
</body>
</html>

View File

@@ -1,57 +1,52 @@
{*
********************************************************************
* AUTHOR: Clemens Schwaighofer
* DATE: 2008/12/24
* DATE: 2005/06/23
* DESCRIPTION:
* main body
* edit body part
* HISTORY:
********************************************************************
*}
<html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>{$HTML_TITLE}</title>
<meta http-equiv="Content-Type" content="text/html; charset={$DEFAULT_ENCODING}">
{if $STYLESHEET}
<link rel=stylesheet type="text/css" href="{$CSS}{$STYLESHEET}">
<link rel=stylesheet type="text/css" href="{$css}{$STYLESHEET}">
{/if}
{if $CSS_INCLUDE}
<link rel=stylesheet type="text/css" href="{$CSS_INCLUDE}">
{/if}
{if $CSS_SPECIAL_INCLUDE}
<link rel=stylesheet type="text/css" href="{$CSS_SPECIAL_INCLUDE}">
{/if}
<script language="JavaScript">
<!--
var DEBUG = {$JS_DEBUG};
//-->
</script>
<script language="JavaScript" src="{$js}/firebug.js"></script>
<script language="JavaScript" src="{$js}/debug.js"></script>
{if $JAVASCRIPT}
<script language="JavaScript" src="{$JS}{$JAVASCRIPT}"></script>
<script language="JavaScript" src="{$js}{$JAVASCRIPT}"></script>
{/if}
{if $ajax_javascript}
<script language="JavaScript">
{$ajax_javascript}
</script>
{* declare prototype everywhere *}
<script src="{$js}/scriptaculous/prototype.js" type="text/javascript"></script>
{if $USE_SCRIPTACULOUS}
<script src="{$js}/scriptaculous/scriptaculous.js" type="text/javascript"></script>
{/if}
{if $JS_INCLUDE}
<script language="JavaScript" src="{$JS_INCLUDE}"></script>
{/if}
{* {popup_init src="`$js`/overlib/overlib.js"} *}
{if $JS_SPECIAL_INCLUDE}
<script language="JavaScript" src="{$JS_SPECIAL_INCLUDE}"></script>
{/if}
{* for including datepickr *}
{if $JS_DATEPICKR}
<link rel=stylesheet type="text/css" href="{$js}/datepickr/datepickr.min.css">
<script language="JavaScript" src="{$js}/datepickr/datepickr.min.js"></script>
{/if}
{if $USE_OVERLIB}
{popup_init src="`$js`/overlib/overlib.js"}
{/if}
</head>
<body>
<form name="product_search" method="get">
<div style="border: 1px solid black; margin: 15px; padding: 5px;">
{include file="top_menu.tpl"}
</div>
<div>
{include file="$INCLUDE_TEMPLATE"}
</div>
</form>
{* debug info *}
{if $DEBUG}
<div style="width:{$table_width}px;" class="debug_message">
{$Id}<br>
<b>{$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}</b><br>
{$debug_error_msg}
</div>
{/if}
{include file="$TEMPLATE_NAME"}
</body>
</html>

View File

@@ -99,7 +99,7 @@
// queue key
if (preg_match("/^(add|save|delete|remove|move|up|down|push_live)$/", $this->action))
{
$this->queue_key = join('', array_map(create_function('', '$range = $GLOBALS["_KEY_RANGE"]; return $range[rand(0, (count($range) - 1))];'), range(1, 3)));
$this->queue_key = join('', array_map(function () { $range = $GLOBALS['_KEY_RANGE']; return $range[rand(0, (count($range) - 1))]; }, range(1, 3)));
}
}
@@ -138,7 +138,7 @@
$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 .= "'".$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');
}

View File

@@ -54,6 +54,7 @@
* 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
@@ -118,9 +119,10 @@
// log file name
private $log_file_name_ext = 'log'; // use this for date rotate
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
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_class = 0; // set, will split log per class
public $log_per_page = 0; // set, will split log per called file
@@ -311,7 +313,7 @@
if (!session_id())
{
// 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
$this->session_name = SET_SESSION_NAME;
@@ -611,6 +613,12 @@
$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;
// 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)
{
@@ -1239,8 +1247,8 @@
return FALSE;
// splits the data up with / or -
list ($start_year, $start_month, $start_day) = split('[/-]', $start_date);
list ($end_year, $end_month, $end_day) = split('[/-]', $end_date);
list ($start_year, $start_month, $start_day) = preg_split('/[\/-]/', $start_date);
list ($end_year, $end_month, $end_day) = preg_split('/[\/-]/', $end_date);
// check that month & day are two digits and then combine
foreach (array('start', 'end') as $prefix)
{
@@ -1267,6 +1275,25 @@
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
// PARAMS: array, connect char
// RETRUN: string

View File

@@ -332,7 +332,7 @@
$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 db_return* methods work only with SELECT statements, please use db_exec 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';
@@ -344,7 +344,7 @@
$this->error_string['30'] = 'Query call in a possible endless loop. Was called more than '.$this->MAX_QUERY_CALL.' times';
$this->error_string['31'] = 'Could not fetch PK after query insert';
$this->error_string['32'] = 'Multiple PK return as array';
$this->error_string['33'] = 'returning PK was not found';
$this->error_string['33'] = 'Returning PK was not found';
$this->error_string['40'] = 'Query async call failed.';
$this->error_string['41'] = 'Connection is busy with a different query. Cannot execute.';
$this->error_string['42'] = 'Cannot check for async query, none has been started yet.';
@@ -661,14 +661,14 @@
{
$this->pk_name_table[$table] = $this->db_functions->_db_primary_key($table, $schema);
}
$this->pk_name = $this->pk_name_table[$table];
$this->pk_name = $this->pk_name_table[$table] ? $this->pk_name_table[$table] : 'NULL';
}
if (!preg_match("/ returning /i", $this->query) && $this->pk_name)
if (!preg_match("/ returning /i", $this->query) && $this->pk_name && $this->pk_name != 'NULL')
{
$this->query .= " RETURNING ".$this->pk_name;
$this->returning_id = true;
}
elseif (preg_match("/ returning (.*)/i", $this->query, $matches) && $this->pk_name)
elseif (preg_match("/ returning (.*)/i", $this->query, $matches) && $this->pk_name && $this->pk_name != 'NULL')
{
// add the primary key if it is not in the returning set
if (!preg_match("/$this->pk_name/", $matches[1]))
@@ -714,7 +714,7 @@
if (!$this->cursor || $this->db_functions->_db_last_error_query())
{
// printout Query if debug is turned on
if (!$this->db_debug)
if ($this->db_debug)
$this->_db_debug('db', $this->query, 'db_exec', 'Q[nc]');
// internal error handling
$this->error_id = 13;
@@ -763,7 +763,7 @@
$this->insert_id[] = $_insert_id;
}
// if we have only one, revert from array to single
if (count($this->insert_id) == 1)
if (count($this->insert_id) >= 1)
{
// echo "* SINGLE DATA CONVERT: ".count($this->insert_id[0])." => ".array_key_exists($this->pk_name, $this->insert_id[0])."<br>";
// echo "* PK DIRECT: ".$this->insert_id[0][$this->pk_name]."<Br>";
@@ -1015,7 +1015,7 @@
// if still no cursor ...
if (!$this->cursor_ext[$md5]['cursor'])
{
if (!$this->db_debug)
if ($this->db_debug)
$this->_db_debug('db', $this->cursor_ext[$md5]['query'], 'db_return', 'Q');
// internal error handling
$this->error_id = 13;
@@ -1391,34 +1391,41 @@
// if this is an insert query, check if we can add a return
if ($this->_check_query_for_insert($query, true))
{
// set primary key name
// current: only via parameter
if (!$pk_name)
if ($pk_name != 'NULL')
{
// 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])
// set primary key name
// current: only via parameter
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;
// 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
@@ -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_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'])
{
@@ -1493,6 +1500,7 @@ $this->debug('ExecuteData', 'ERROR in STM['.$stm_name.'|'.$this->prepare_cursor[
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))
@@ -1512,11 +1520,19 @@ $this->debug('ExecuteData', 'ERROR in STM['.$stm_name.'|'.$this->prepare_cursor[
$this->insert_id_ext = $this->insert_id[0];
$this->insert_id = $this->insert_id[0][$this->prepare_cursor[$stm_name]['pk_name']];
}
elseif ($this->insert_id[0][$this->pk_name])
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
{
// failed to get insert id
$this->insert_id = '';
$this->warning_id = 33;
$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
if (is_array($this->insert_id))
@@ -1525,6 +1541,7 @@ $this->debug('ExecuteData', 'ERROR in STM['.$stm_name.'|'.$this->prepare_cursor[
$this->_db_error();
$this->_db_debug('db', '<span style="color: orange;"><b>DB-Warning</b> '.$stm_name.': insert id data returned as array</span>', 'DB_WARNING');
}
// NOTE should we keep this inside
elseif (!$this->insert_id)
{
$this->warning_id = 31;
@@ -1650,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
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);
}
@@ -1674,7 +1697,9 @@ $this->debug('ExecuteData', 'ERROR in STM['.$stm_name.'|'.$this->prepare_cursor[
'value' => $primary_key
);
}
// var set for strings
$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);
foreach ($write_array as $field)
@@ -1682,11 +1707,25 @@ $this->debug('ExecuteData', 'ERROR in STM['.$stm_name.'|'.$this->prepare_cursor[
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
$_data = (count($data) >= 1) ? $data[$field] : $GLOBALS[$field];
$_data = null;
if (count($data) >= 1 && array_key_exists($field, $data))
$_data = $data[$field];
elseif (array_key_exists($field, $GLOBALS))
$_data = $GLOBALS[$field];
$has_default = $table_data[$field]['has default'];
$not_null = $table_data[$field]['not null'];
// 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 and string => '', if not null and int or numeric => 0, if bool => skip, all others skip
if ($not_null && !isset($_data))
{
if (strstr($table_data[$field]['type'], 'int') || strstr($table_data[$field]['type'], 'numeric'))
$_data = 0;
else
$_data = '';
}
// 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 or if this is an update and there is no data (set null)
if (($not_null && isset($_data)) || (!$has_default && !isset($_data)) || (is_numeric($_data) && isset($_data)) || ($primary_key['value'] && !isset($_data)) || isset($_data))
{
if ($q_sub_value && !$primary_key['value'])
$q_sub_value .= ', ';
@@ -1701,9 +1740,10 @@ $this->debug('ExecuteData', 'ERROR in STM['.$stm_name.'|'.$this->prepare_cursor[
$_data = '';
// write data into sql string
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 : 'NULL';
else
$q_sub_data .= ($_data) ? "'".$this->db_escape_string($_data)."'" : ($has_default ? "'".$this->db_escape_string($has_default)."'" : 'NULL');
// 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';
}
}
}

View File

@@ -581,7 +581,7 @@
{
$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];
}

View File

@@ -19,6 +19,9 @@ class ProgressBar
public $status = 'new'; // current status (new,show,hide)
public $step = 0; // current step
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
@@ -74,10 +77,22 @@ class ProgressBar
$this->width = $width;
if ($height > 0)
$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 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)
{
// avoid divison through 0
@@ -298,7 +313,7 @@ class ProgressBar
$output .= 'document.getElementById("plbl'.$name.$this->code.'").style.align="'.$this->label[$name]['align'].'";';
$output .= '</script>'."\n";
echo $output;
flush();
$this->_flushCache();
}
}
@@ -308,7 +323,7 @@ class ProgressBar
if ($this->status != 'new')
{
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')
{
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 .= '</script>'."\n";
echo $output;
flush();
$this->_flushCache();
}
}
@@ -360,7 +375,7 @@ class ProgressBar
if ($this->status != 'new')
{
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')
{
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')
{
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.'("height",'.$this->position['height'].');';
echo '</script>'."\n";
flush();
$this->_flushCache();
}
}
@@ -547,7 +562,7 @@ class ProgressBar
{
$this->status = 'show';
echo $this->getHtml();
flush();
$this->_flushCache();
}
public function moveStep($step)
@@ -603,7 +618,7 @@ class ProgressBar
if ($js != '')
{
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 .= '</script>'."\n";
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 .= '</script>'."\n";
echo $output;
flush();
$this->_flushCache();
}
}

View File

@@ -112,7 +112,10 @@
// DESC : wrapper for pg_prepare
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
@@ -121,7 +124,10 @@
// DESC : wrapper for pg_execute for running a prepared statement
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