]> andersk Git - sql-web.git/blobdiff - lib/joe/joe.lib.php
git-svn-id: svn://presbrey.mit.edu/php/php@97 a142d4bd-2cfb-0310-9673-cb33a7e74f58
[sql-web.git] / lib / joe / joe.lib.php
index 26723218b3064bf77c1b6051e6c84ba15c04b21e..0bf1fb034a21da6178ebc1383827eb6597b024d3 100644 (file)
@@ -3,28 +3,29 @@
     (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 {
@@ -45,28 +46,30 @@ function stopSess() {
   @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();
@@ -104,17 +107,24 @@ function fetchRows($rs, $key = null) {
     }
 }
 
-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;
@@ -136,7 +146,7 @@ function buildSQLSet($fields, $values=NULL) {
     return $sql;
 }
 
-function buildSQLInsert($array, $table=NULL) {
+function buildSQLInsert($array, $table=null) {
     $ex = array('NOW()','NULL');
     $sql = '(';
     $c = 0;
@@ -169,10 +179,13 @@ function build_str($query_array) {
     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()) {
This page took 0.14407 seconds and 4 git commands to generate.