]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/admin-inc.php
Missing SVN properties set
[mailer.git] / inc / modules / admin / admin-inc.php
index ec8bb508a9fc06ac504afe8ff66d432da8142ecf..7d38f8fa16b9719549f716baacd2003db3def04a 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
- * MXChange v0.2.1                                    Start: 08/31/2003 *
- * ===============                              Last change: 11/23/2004 *
+ * Mailer v0.2.1-FINAL                                Start: 08/31/2003 *
+ * ===================                          Last change: 11/23/2004 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : admin-inc.php                                    *
@@ -59,6 +59,8 @@ function addAdminAccount ($user, $md5, $email) {
                                $md5,
                                $email
                        ), __FUNCTION__, __LINE__);
+
+               // All done
                $ret = 'done';
        } // END - if
 
@@ -114,12 +116,13 @@ function ifAdminLoginDataIsValid ($admin, $password) {
                SQL_FREERESULT($result);
        }
 
-       //* DEBUG: */ outputHtml("*".$data['password'].'/'.md5($password).'/'.$ret."<br />");
+       //* DEBUG: */ outputHtml('*' . $data['password'] . '/' . md5($password) .'/' . $ret . '*<br />');
        if ((isset($data['password'])) && (strlen($data['password']) == 32) && ($data['password'] == md5($password))) {
                // Generate new hash
                $data['password'] = generateHash($password);
 
                // Is the sql_patches not installed, than we cannot have a valid hashed password here!
+               //* DEBUG: */ outputHtml($ret . ',' . intval(isExtensionInstalledAndOlder('sql_patches', '0.3.6')) . '/' . intval(!isExtensionInstalled('sql_patches')).'<br />');
                if (($ret == 'pass') && ((isExtensionInstalledAndOlder('sql_patches', '0.3.6')) || (!isExtensionInstalled('sql_patches')))) $ret = 'done';
        } elseif ((isExtensionInstalledAndOlder('sql_patches', '0.3.6')) || (!isExtensionInstalled('sql_patches'))) {
                // Old hashing way
@@ -133,8 +136,8 @@ function ifAdminLoginDataIsValid ($admin, $password) {
        $salt = substr($data['password'], 0, -40);
 
        // Check if password is same
-       //* DEBUG: */ outputHtml("*".$ret.','.$data['password'].','.$password.','.$salt."*<br />");
-       if (($ret == 'pass') && ($data['password'] == generateHash($password, $salt)) && ((!empty($salt))) || ($data['password'] == $password)) {
+       //* DEBUG: */ outputHtml('*' . $ret . ',' . $data['password'] . ',' . $password . ',' . $salt . '*<br />');
+       if (($ret == 'pass') && ($data['password'] == generateHash($password, $salt)) && ((!empty($salt))) || ($data['password'] == md5($password))) {
                // Re-hash the plain passord with new random salt
                $data['password'] = generateHash($password);
 
@@ -210,8 +213,6 @@ function doAdminLogin ($adminLogin, $passHash) {
                setSession('admin_login', $adminLogin)
        ) && (
                setSession('admin_last', time())
-       ) && (
-               setSession('admin_to', bigintval(postRequestElement('timeout')))
        ));
 }
 
@@ -272,12 +273,6 @@ function doAdminAction () {
        // Tableset header
        loadTemplate('admin_main_header', false, $content);
 
-       // Is sql_patches not yet installed?
-       if (!isExtensionInstalled('sql_patches')) {
-               // Output warning
-               loadTemplate('admin_settings_saved', false, getMessage('ADMIN_WARNING_SQL_PATCHES_MISSING'));
-       } // END - if
-
        // Check if action/what pair is valid
        $result_action = SQL_QUERY_ESC("SELECT
        `id`
@@ -297,7 +292,13 @@ WHERE
                )
        )
 LIMIT 1",
-               array($action, $what, $what), __FUNCTION__, __LINE__);
+               array(
+                       $action,
+                       $what,
+                       $what
+               ), __FUNCTION__, __LINE__);
+
+       // Do we have an entry?
        if (SQL_NUMROWS($result_action) == 1) {
                // Is valid but does the inlcude file exists?
                $inc = sprintf("inc/modules/admin/action-%s.php", $action);
@@ -313,7 +314,7 @@ LIMIT 1",
                }
        } else {
                // Invalid action/what pair found!
-               loadTemplate('admin_menu_failed', false, sprintf(getMessage('ADMIN_ACTION_INVALID'), $action.'/'.$what));
+               loadTemplate('admin_menu_failed', false, sprintf(getMessage('ADMIN_ACTION_INVALID'), $action . '/' . $what));
        }
 
        // Free memory
@@ -346,8 +347,8 @@ ORDER BY
 
        // Do we have entries?
        if (SQL_NUMROWS($result_main) > 0) {
-               $OUT = "<div style=\"height:7px\" class=\"seperator\">&nbsp;</div>\n";
-               $OUT .= "<ul class=\"admin_menu_main\">\n";
+               $OUT  = '<div style="height:7px" class="seperator">&nbsp;</div>';
+               $OUT .= '<ul class="admin_menu_main">';
                // @TODO Rewrite this to $content = SQL_FETCHARRAY()
                while (list($menu, $title, $descr) = SQL_FETCHROW($result_main)) {
                        if ((isExtensionActive('admins')) && (getExtensionVersion('admins') > '0.2.0')) {
@@ -369,33 +370,33 @@ ORDER BY
                                        $GLOBALS['menu']['title'][$menu]      = $title;
                                        $GLOBALS['menu']['description'][$menu] = $descr;
                                }
-                               $OUT .= "<li class=\"admin_menu\">
-<div class=\"nobr\"><strong>&middot;</strong>&nbsp;";
+                               $OUT .= '<li class="admin_menu">
+<div class="nobr"><strong>&middot;</strong>&nbsp;';
 
                                if ($readable === true) {
                                        if (($menu == $action) && (empty($what))) {
-                                               $OUT .= "<strong>";
+                                               $OUT .= '<strong>';
                                        } else {
-                                               $OUT .= "[<a href=\"{?URL?}/modules.php?module=admin&amp;action=".$menu."\">";
+                                               $OUT .= '[<a href="{?URL?}/modules.php?module=admin&amp;action=' . $menu . '">';
                                        }
                                } else {
-                                       $OUT .= "<em style=\"cursor:help\" class=\"admin_note\" title=\"{--MENU_ACTION_404--}\">";
+                                       $OUT .= '<em style="cursor:help" class="admin_note" title="{--MENU_ACTION_404--}">';
                                }
 
                                $OUT .= $title;
 
                                if ($readable === true) {
                                        if (($menu == $action) && (empty($what))) {
-                                               $OUT .= "</strong>";
+                                               $OUT .= '</strong>';
                                        } else {
-                                               $OUT .= "</a>]";
+                                               $OUT .= '</a>]';
                                        }
                                } else {
-                                       $OUT .= "</em>";
+                                       $OUT .= '</em>';
                                }
 
-                               $OUT .= "</div>
-</li>\n";
+                               $OUT .= '</div>
+</li>';
 
                                // Check for menu entries
                                $result_what = SQL_QUERY_ESC("SELECT
@@ -418,7 +419,7 @@ ORDER BY
                                if ((ifAdminMenuHasEntries($menu)) && (SQL_NUMROWS($result_what) > 0)) {
                                        $GLOBALS['menu']['description'] = array();
                                        $GLOBALS['menu']['title'] = array(); $SUB = true;
-                                       $OUT .= "<li class=\"admin_menu_sub\"><ul class=\"admin_menu_sub\">\n";
+                                       $OUT .= '<li class="admin_menu_sub"><ul class="admin_menu_sub">';
                                        // @TODO Rewrite this to $content = SQL_FETCHARRAY()
                                        while (list($what_sub, $title_what, $desc_what) = SQL_FETCHROW($result_what)) {
                                                // Check for access level
@@ -440,47 +441,47 @@ ORDER BY
                                                        // Insert compiled title and description
                                                        $GLOBALS['menu']['title'][$what_sub]      = $title_what;
                                                        $GLOBALS['menu']['description'][$what_sub] = $desc_what;
-                                                       $OUT .= "<li class=\"admin_menu\">
-               <div class=\"nobr\"><strong>--&gt;</strong>&nbsp;";
+                                                       $OUT .= '<li class="admin_menu">
+<div class="nobr"><strong>--&gt;</strong>&nbsp;';
                                                        if ($readable === true) {
                                                                if ($what == $what_sub) {
-                                                                       $OUT .= "<strong>";
+                                                                       $OUT .= '<strong>';
                                                                } else {
-                                                                       $OUT .= "[<a href=\"{?URL?}/modules.php?module=admin&amp;what=".$what_sub."\">";
+                                                                       $OUT .= '[<a href="{?URL?}/modules.php?module=admin&amp;what=' . $what_sub . '">';
                                                                }
                                                        } else {
-                                                               $OUT .= "<em style=\"cursor:help\" class=\"admin_note\" title=\"{--MENU_WHAT_404--}\">";
+                                                               $OUT .= '<em style="cursor:help" class="admin_note" title="{--MENU_WHAT_404--}">';
                                                        }
 
                                                        $OUT .= $title_what;
 
                                                        if ($readable === true) {
                                                                if ($what == $what_sub) {
-                                                                       $OUT .= "</strong>";
+                                                                       $OUT .= '</strong>';
                                                                } else {
-                                                                       $OUT .= "</a>]";
+                                                                       $OUT .= '</a>]';
                                                                }
                                                        } else {
-                                                               $OUT .= "</em>";
+                                                               $OUT .= '</em>';
                                                        }
-                                                       $OUT .= "</div>
-</li>\n";
+                                                       $OUT .= '</div>
+</li>';
                                                } // END - if
                                        } // END - while
 
                                        // Free memory
                                        SQL_FREERESULT($result_what);
-                                       $OUT .= "</ul>
-</li>\n";
+                                       $OUT .= '</ul>
+</li>';
                                } // END - if
 
-                               $OUT .= "<li style=\"height:7px\" class=\"seperator\">&nbsp;</li>\n";
+                               $OUT .= '<li style="height:7px" class="seperator">&nbsp;</li>';
                        } // END - if
                } // END - while
 
                // Free memory
                SQL_FREERESULT($result_main);
-               $OUT .= "</ul>\n";
+               $OUT .= '</ul>';
        }
 
        // Is there a cache instance again?
@@ -501,13 +502,13 @@ function addMemberSelectionBox ($def=0, $add_all=false, $return=false, $none=fal
        $OUT = '';
 
        // USe this only for adding points (e.g. adding refs really makes no sence ;-) )
-       if ($add_all === true)   $OUT = "      <option value=\"all\">{--ALL_MEMBERS--}</option>\n";
-        elseif ($none === true) $OUT = "      <option value=\"0\">{--SELECT_NONE--}</option>\n";
+       if ($add_all === true)   $OUT = '      <option value="all">{--ALL_MEMBERS--}</option>';
+        elseif ($none === true) $OUT = '      <option value="0">{--SELECT_NONE--}</option>';
 
        while ($content = SQL_FETCHARRAY($result)) {
-               $OUT .= "      <option value=\"".bigintval($content['userid'])."\"";
+               $OUT .= '      <option value="' . bigintval($content['userid']) . '"';
                if ($def == $content['userid']) $OUT .= ' selected="selected"';
-               $OUT .= ">".$content['surname']." ".$content['family']." (".bigintval($content['userid']).")</option>\n";
+               $OUT .= '>' . $content['surname'] . ' ' . $content['family'] . ' (' . bigintval($content['userid']) . ')</option>';
        } // END - while
 
        // Free memory
@@ -522,7 +523,7 @@ function addMemberSelectionBox ($def=0, $add_all=false, $return=false, $none=fal
                loadTemplate('admin_member_selection_box', false, $content);
        } else {
                // Return content in selection frame
-               return "<select class=\"admin_select\" name=\"".$field."\" size=\"1\">\n".$OUT."</select>\n";
+               return '<select class="admin_select" name="' . $field . '" size="1">' . $OUT . '</select>';
        }
 }
 
@@ -532,7 +533,7 @@ function addMemberSelectionBox ($def=0, $add_all=false, $return=false, $none=fal
 function adminMenuSelectionBox_DEPRECATED ($mode, $default = '', $defid = '') {
        $what = "`what` != ''";
        if ($mode == 'action') $what = "(`what`='' OR `what` IS NULL) AND action !='login'";
-       $result = SQL_QUERY_ESC("SELECT %s, title FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$what." ORDER BY `sort`",
+       $result = SQL_QUERY_ESC("SELECT %s, `title` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$what." ORDER BY `sort` ASC",
                array($mode), __FUNCTION__, __LINE__);
        if (SQL_NUMROWS($result) > 0) {
                // Load menu as selection
@@ -560,16 +561,16 @@ function adminMenuSelectionBox_DEPRECATED ($mode, $default = '', $defid = '') {
 }
 
 // Wrapper for $_POST and adminSaveSettings
-function adminSaveSettingsFromPostData ($tableName = '_config', $whereStatement = '`config`=0', $translateComma = array(), $alwaysAdd = false) {
+function adminSaveSettingsFromPostData ($tableName = '_config', $whereStatement = '`config`=0', $translateComma = array(), $alwaysAdd = false, $displayMessage = true) {
        // Get the array
        $postData = postRequestArray();
 
        // Call the lower function
-       adminSaveSettings($postData, $tableName, $whereStatement, $translateComma, $alwaysAdd);
+       adminSaveSettings($postData, $tableName, $whereStatement, $translateComma, $alwaysAdd, $displayMessage);
 }
 
 // Save settings to the database
-function adminSaveSettings (&$postData, $tableName = '_config', $whereStatement = '`config`=0', $translateComma = array(), $alwaysAdd = false) {
+function adminSaveSettings (&$postData, $tableName = '_config', $whereStatement = '`config`=0', $translateComma = array(), $alwaysAdd = false, $displayMessage = true) {
        // Prepare all arrays, variables
        $DATA = array();
        $skip = false;
@@ -655,11 +656,17 @@ function adminSaveSettings (&$postData, $tableName = '_config', $whereStatement
        // Simply run generated SQL string
        SQL_QUERY($sql, __FUNCTION__, __LINE__);
 
+       // Remember affected rows
+       $affected = SQL_AFFECTEDROWS();
+
        // Rebuild cache
        rebuildCacheFile('config', 'config');
 
-       // Settings saved
-       loadTemplate('admin_settings_saved', false, getMessage('SETTINGS_SAVED'));
+       // Settings saved, so display message?
+       if ($displayMessage === true) loadTemplate('admin_settings_saved', false, getMessage('SETTINGS_SAVED'));
+
+       // Return affected rows
+       return $affected;
 }
 
 // Generate a selection box