]> git.mxchange.org Git - mailer.git/blobdiff - inc/mysql-manager.php
Several fixes for module/action/what handling.
[mailer.git] / inc / mysql-manager.php
index a96b22392bb58706bb7de976607f4033388ccad9..1f3ea2d2d287f5f7e47ba2b92e39efa2b490eb62 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                                *
@@ -611,17 +611,15 @@ function isMember () {
                                $ret = true;
                        } else {
                                // Maybe got locked etc.
-                               //* DEBUG: */ print(__LINE__."!!!<br />");
+                               logDebugMessage(__FUNCTION__, __LINE__, 'status=' . getUserData('status'));
                                destroyMemberSession();
                        }
                } else {
                        // Cookie data is invalid!
-                       //* DEBUG: */ print(__LINE__."***<br />");
                        destroyMemberSession();
                }
        } else {
                // Cookie data is invalid!
-               //* DEBUG: */ print(__LINE__."///<br />");
                destroyMemberSession();
        }
 
@@ -1024,7 +1022,20 @@ 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 (isWhatSet()) {
+                       // Use setted what
+                       $what = getWhat();
+               } elseif ($mode == 'admin') {
+                       // Admin area
+                       $what = 'overview';
+               } else {
+                       // Everywhere else
+                       $what = 'welcome';
+               }
+       } elseif ((empty($what)) && ($mode != 'admin')) {
+               // Use configured 'home'
                $what = getConfig('index_home');
        } // END - if
 
@@ -1064,7 +1075,7 @@ function getModeAction ($mode, $what) {
 
                // Free memory
                SQL_FREERESULT($result);
-       } elseif ((!isExtensionInstalled('sql_patches')) && ($mode != 'admin')) {
+       } elseif ((!isExtensionInstalled('sql_patches')) && (($mode != 'admin') && ($mode != 'unknown'))) {
                // No sql_patches installed, but maybe we need to register an admin?
                if (isAdminRegistered()) {
                        // Redirect to admin area
@@ -1646,22 +1657,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()
@@ -1735,7 +1753,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
@@ -1871,7 +1889,10 @@ function generateCategoryOptionsList ($mode) {
        );
 
        // Get categories
-       $result = SQL_QUERY("SELECT id, cat FROM `{?_MYSQL_PREFIX?}_cats`".$whereStatement." ORDER BY `sort`", __FUNCTION__, __LINE__);
+       $result = SQL_QUERY("SELECT `id`, `cat` FROM `{?_MYSQL_PREFIX?}_cats`".$whereStatement." ORDER BY `sort` ASC",
+               __FUNCTION__, __LINE__);
+
+       // Do we have entries?
        if (SQL_NUMROWS($result) > 0) {
                // ... and begin loading stuff
                while ($content = SQL_FETCHARRAY($result)) {
@@ -1892,7 +1913,9 @@ function generateCategoryOptionsList ($mode) {
 FROM
        `{?_MYSQL_PREFIX?}_user_data`
 WHERE
-       `userid`=%s AND `status`='CONFIRMED' AND `receive_mails` > 0".runFilterChain('exclude_users', $mode)."
+       `userid`=%s AND
+       `status`='CONFIRMED' AND
+       `receive_mails` > 0".runFilterChain('exclude_users', $mode)."
 LIMIT 1",
                                        array(bigintval($ucat)), __FUNCTION__, __LINE__);
 
@@ -2224,7 +2247,7 @@ function reduceRecipientReceivedMails ($column, $id, $count) {
 function createNewTask ($subject, $notes, $taskType, $userid = '0', $adminId = '0', $strip = true) {
        // Insert the task data into the database
        SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_task_system` (`assigned_admin`, `userid`, `status`, `task_type`, `subject`, `text`, `task_created`) VALUES (%s,%s,'NEW','%s','%s','%s', UNIX_TIMESTAMP())",
-               array($adminId, $userid, $taskType, $subject, smartAddSlashes($notes)), __FUNCTION__, __LINE__, true, $strip);
+               array($adminId, $userid, $taskType, $subject, escapeQuotes($notes)), __FUNCTION__, __LINE__, true, $strip);
 }
 
 // Updates last module / online time