]> git.mxchange.org Git - mailer.git/blobdiff - inc/mysql-manager.php
Mailer used in many places, we still need a good 'selling' title
[mailer.git] / inc / mysql-manager.php
index 4b7d94ccc4e2b8f2f939c4139a0afc07a45fc577..e33b1b395e995c187edbccd29b2fbde77684f250 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
- * MXChange v0.2.1                                    Start: 08/26/2003 *
- * ===============                              Last change: 11/29/2004 *
+ * Mailer v0.2.1-FINAL                                Start: 08/26/2003 *
+ * ===================                          Last change: 11/29/2004 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : mysql-manager.php                                *
@@ -1022,7 +1022,15 @@ function getModeAction ($mode, $what) {
        $ret = '';
 
        //* DEBUG: */ print(__LINE__.'='.$mode.'/'.$what.'/'.getAction()."=<br />");
-       if ((empty($what)) && ($mode != 'admin')) {
+       if (!isExtensionInstalledAndNewer('sql_patches', '0.0.5')) {
+               // sql_patches is missing so choose depending on mode
+               if ($mode == 'admin') {
+                       $what = 'overview';
+               } else {
+                       $what = 'welcome';
+               }
+       } elseif ((empty($what)) && ($mode != 'admin')) {
+               // Use configured 'home'
                $what = getConfig('index_home');
        } // END - if
 
@@ -1644,22 +1652,29 @@ function generateOptionList ($table, $id, $name, $default='', $special='', $wher
        $ret = '';
        if ($table == '/ARRAY/') {
                // Selection from array
-               if (is_array($id) && is_array($name) && count($id) == count($name)) {
+               if ((is_array($id)) && (is_array($name)) && (count($id)) == (count($name))) {
                        // Both are arrays
                        foreach ($id as $idx => $value) {
                                $ret .= '<option value="' . $value . '"';
                                if ($default == $value) $ret .= ' selected="selected"';
                                $ret .= '>' . $name[$idx] . '</option>';
                        } // END - foreach
-               } // END - if
+               } else {
+                       // Problem in request
+                       debug_report_bug('Not all are arrays: id[' . count($id) . ']=' . gettype($id) . ',name[' . count($name) . ']=' . gettype($name));
+               }
        } else {
                // Data from database
-               $SPEC = ', '.$id;
+               $SPEC = ', `' . $id . '`';
                if (!empty($special)) $SPEC = ', ' . $special;
-               $ORDER = $name.$SPEC;
+               $ORDER = $name . $SPEC;
                if ($table == 'country') $ORDER = $special;
-               $result = SQL_QUERY_ESC("SELECT %s, %s".$SPEC." FROM `{?_MYSQL_PREFIX?}_%s` ".$where." ORDER BY %s",
-               array($id, $ORDER, $table, $name), __FUNCTION__, __LINE__);
+
+               // Query the database
+               $result = SQL_QUERY_ESC("SELECT `%s`, `%s`".$SPEC." FROM `{?_MYSQL_PREFIX?}_%s` ".$where." ORDER BY %s",
+                       array($id, $ORDER, $table, $name), __FUNCTION__, __LINE__);
+
+               // Do we have rows?
                if (SQL_NUMROWS($result) > 0) {
                        // Found data so add them as OPTION lines: $id is the value and $name is the "name" of the option
                        // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
@@ -1733,7 +1748,7 @@ WHERE
                SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `userid`=%s", array(bigintval($userid)), __FUNCTION__, __LINE__);
 
                // Update mediadata as well
-               if (getExtensionVersion('mediadata') >= '0.0.4') {
+               if (isExtensionInstalledAndNewer('mediadata', '0.0.4')) {
                        // Update database
                        updateMediadataEntry(array('total_points'), 'sub', $points);
                } // END - if