CLEANUP: all email now uses the standard header and footer
[e-DoKo.git] / include / db.php
index da005a16e03c77759f34faebac5f29de36cda8e9..3d9d98c9cf9272b83b5d0f5390fc359398f6bb56 100644 (file)
@@ -18,8 +18,10 @@ function DB_open()
       mysql_select_db($DB_database) or die('Could not select database');
     }
   else
-    return -1;
-
+    {
+      echo mysql_errno() . ": " . mysql_error(). "\n";
+      return -1;
+    }
   return 0;
 }
 
@@ -59,16 +61,17 @@ function DB_test()
 function DB_query($query)
 {
   /* debug/optimize the database
-  $logfile=fopen('/tmp/DBlog.log','a+');
-  fwrite($logfile,"EXPLAIN $query ;\n");
-
   $time = microtime();
   $return = mysql_query($query);
   $time = $time - microtime();
 
-  fwrite($logfile,"time of above query: $time\n");
-
-  fclose($logfile);
+  if($time > 0.05) // this way we can find only the long ones
+  {
+    $logfile=fopen('/tmp/DBlog.log','a+');
+    fwrite($logfile,"EXPLAIN $query ;\n");
+    fwrite($logfile,"time of above query: $time\n");
+    fclose($logfile);
+  };
 
   return $return;
   */
@@ -1035,7 +1038,7 @@ function DB_get_userid($type,$var1="",$var2="")
       /* test if a recovery password has been set */
       if(!$r)
        {
-         echo "testing alternative password";
+         /* testing alternative password */
          $result = DB_query("SELECT User.id FROM User".
                             " LEFT JOIN Recovery ON User.id=Recovery.user_id".
                             " WHERE email=".DB_quote_smart($var1).