(c) 2005 Joe Presbrey
joepresbrey@gmail.com
- ATTN: This library was compiled and completed in its entirety independent of
- any and all corporate projects and/or work environment.
+ ATTN: This library was assembled and completed in its entirety independent of
+ any and all corporate projects and/or work environ.
You may NOT use this library elsewhere!
*/
-function isFormPost() {
+function isPost() {
if($_SERVER['REQUEST_METHOD'] == 'POST') {
return true;
} else {
return false;
}
}
+function isFormPost() { return isPost(); }
function isSess($id) {
return isset($_SESSION[$id]);
}
-function sess($id,$val=NULL) {
+function sess($id,$val=null) {
if (is_null($val)) {
- return (isSess($id)?$_SESSION[$id]:NULL);
+ return (isSess($id)?$_SESSION[$id]:null);
} elseif (empty($val)) {
unset($_SESSION[$id]);
} else {
@session_destroy();
foreach($sid as $id) {
- @unlink(SESSIONS_PATH.'/sess_'.$id);
+ @unlink(session_save_path().'/sess_'.$id);
}
}
function sessTime($query=null) {
+ global $timingc;
global $timings;
if(!isset($timings)) {
$timings = array();
}
- if (!isSess('TIMING')) {
- sess('TIMING', '1');
+ if (!isset($timingc) || empty($timingc)) {
+ $timingc = 1;
} elseif (!is_null($query)) {
- $current = sess('TIMING');
- $current++;
- sess('TIMING', $current);
+ $current = $timingc;
+ $timingc = ++$current;
}
- $key = sess('TIMING');
+ $key = $timingc;
if (is_null($query)) {
$timings[$key]['time'] = microtime(true)-$timings[$key]['time'];
+ if (mysql_error())
+ $timings[$key]['error'] = mysql_error();
return true;
} else {
$timings[$key] = array();
}
}
-function printErrors($errArray) {
- if (isset($errArray) && count($errArray)) {
- echo '<ul style="color:red;">';
- foreach($errArray as $err) {
- echo '<li style="color:red;"><p>',$err,'</p></li>';
+function printErrors($err) { printList('err', $err); }
+function printMsgs($err) { printList('msg', $err); }
+
+function printList($class,$err) {
+ if (is_array($err) && count($err)) {
+ echo '<div class="',$class,'">',(count($err)>1?'<ul>':'');
+ foreach($err as $e) {
+ if (count($err)>1) {
+ echo '<li><p>',$e,'</p></li>';
+ } else {
+ echo '<p>',$e,'</p>';
+ }
}
- echo '</ul>';
+ echo (count($err)>1?'</ul>':''),'</div>';
}
}
-function buildSQLSet($fields, $values=NULL) {
+function buildSQLSet($fields, $values=null) {
$ex = array('NOW()','NULL');
$sql = 'SET';
$c = 0;
return $sql;
}
-function buildSQLInsert($array, $table=NULL) {
+function buildSQLInsert($array, $table=null) {
$ex = array('NOW()','NULL');
$sql = '(';
$c = 0;
return join('&', $query_string);
}
-function newQS($key, $val) {
+function newQS($key, $val=null) {
+ /*
parse_str($_SERVER['QUERY_STRING'], $arr);
$arr[$key] = $val;
return '?'.build_str($arr);
+ */
+ return newQSA(array($key=>$val));
}
function newQSA($array=array()) {