]> git.mxchange.org Git - mailer.git/blobdiff - inc/db/lib-mysql3.php
Queries for de-/activation and removal of extensions fixed
[mailer.git] / inc / db / lib-mysql3.php
index 182b88895a08b7bd9bfe3253bc6fd6a80beb2ae7..c9b5b320c19610731c1f96c21181ca1d3d8c0eea 100644 (file)
@@ -32,7 +32,7 @@
  ************************************************************************/
 
 // Some security stuff...
-if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
+if (!defined('__SECURITY')) {
        $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
        require($INC);
 }
@@ -105,33 +105,44 @@ function SQL_NUMROWS($result) {
                $lines = @mysql_num_rows($result);
 
                // Is the result empty? Then we have an error!
-               if (empty($lines)) $lines = "0";
+               if (empty($lines)) $lines = 0;
        } else {
                // No resource given, no lines found!
-               $lines = "0";
+               $lines = 0;
        }
        return $lines;
 }
 
 // SQL affected rows
-function SQL_AFFECTEDROWS($lnk="x", $F="dummy", $L="dummy") {
+function SQL_AFFECTEDROWS() {
        global $link;
-       // $lnk will be ignored for now!
+
+       // Valid link resource?
+       if (!is_resource($link)) return false;
+
+       // Get affected rows
        $lines = @mysql_affected_rows($link);
+
+       // Return it
        return $lines;
 }
 
 // SQL fetch row
 function SQL_FETCHROW($result) {
+       // Init data
        $DATA = array();
+
+       // Is a result resource set?
+       if (!is_resource($result)) return false;
+
        $DATA = @mysql_fetch_row($result);
        return $DATA;
 }
 
 // SQL fetch array
-function SQL_FETCHARRAY($res=false, $nr=0, $remove_numerical=true) {
+function SQL_FETCHARRAY($res, $nr=0, $remove_numerical=true) {
        // Is a result resource set?
-       if (!$res) return false;
+       if (!is_resource($res)) return false;
 
        // Initialize array
        $row = array();
@@ -263,6 +274,7 @@ function SQL_ESCAPE($str, $secureString = true) {
 
        if (function_exists('mysql_real_escape_string')) {
                // The new and improved version
+               //* DEBUG: */ echo __FUNCTION__.":str={$str}<br />\n";
                return mysql_real_escape_string($str, $link);
        } elseif (function_exists('mysql_escape_string')) {
                // The obsulete function
@@ -273,12 +285,12 @@ function SQL_ESCAPE($str, $secureString = true) {
        }
 }
 // SELECT query string from table, columns and so on... ;-)
-function SQL_RESULT_FROM_ARRAY ($table, $columns, $idRow, $id) {
+function SQL_RESULT_FROM_ARRAY ($table, $columns, $idRow, $id, $F, $L) {
        // Prepare the SQL statement
        $SQL = "SELECT ".implode(", ", $columns)." FROM "._MYSQL_PREFIX."_".$table." WHERE ".$idRow."=%s LIMIT 1";
 
        // Return the result
-       return SQL_QUERY_ESC($SQL, array(bigintval($id)), __FILE__, __LINE__);
+       return SQL_QUERY_ESC($SQL, array(bigintval($id)), $F, $L);
 }
 // ALTER TABLE wrapper function
 function SQL_ALTER_TABLE($sql, $F, $L) {
@@ -293,7 +305,7 @@ function SQL_ALTER_TABLE($sql, $F, $L) {
 
                // Get column information
                $result = SQL_QUERY_ESC("SHOW COLUMNS FROM %s LIKE '%s'",
-                       array($tableName, $columnName), __FILE__, __LINE__);
+                       array($tableName, $columnName), $F, $L);
 
                // Do we have no entry?
                if (SQL_NUMROWS($result) == 0) {