]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/what-list_rallyes.php
More fixes for rallye
[mailer.git] / inc / modules / admin / what-list_rallyes.php
index aee3d15034f01867335af24c4eba27d2df25e0bc..523ff1a9587dcdc77057d4343e27ebc295ad52fd 100644 (file)
@@ -32,8 +32,7 @@
  ************************************************************************/
 
 // Some security stuff...
-if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
-{
+if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
        $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
        require($INC);
 }
@@ -106,7 +105,7 @@ if (isset($_GET['rallye']))
        if ($SEL > 0)
        {
                // Delete selected rallyes and all it's data
-               foreach ($_POST['sel'] as $id=>$sel)
+               foreach ($_POST['sel'] as $id => $sel)
                {
                        // Remove selected rallye entirely...
                        $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_rallye_data WHERE id=%s LIMIT 1",
@@ -133,7 +132,7 @@ if (isset($_GET['rallye']))
        if ($SEL > 0)
        {
                // Change selected rallyes and all it's data
-               foreach ($_POST['title'] as $id=>$title)
+               foreach ($_POST['title'] as $id => $title)
                {
                        // Secure ID number
                        $id = bigintval($id);
@@ -169,7 +168,7 @@ if (isset($_POST['edit']))
        {
                // Make all selected and deactivated rallyes editable
                $SW = 2; $OUT = "";
-               foreach ($_POST['sel'] as $id=>$sel)
+               foreach ($_POST['sel'] as $id => $sel)
                {
                        // Load rallye basic data
                        $result = SQL_QUERY_ESC("SELECT title, descr, template, start_time, end_time, min_users, min_prices FROM "._MYSQL_PREFIX."_rallye_data WHERE id=%s LIMIT 1",
@@ -219,9 +218,7 @@ if (isset($_POST['edit']))
                // Nothing selected to edit
                LOAD_TEMPLATE("admin_settings_saved", false, LOAD_TEMPLATE("admin_list_rallye_noselect", true));
        }
-}
- elseif (($_GET['sub'] == "users") && ($_GET['rallye'] > 0))
-{
+} elseif (($_GET['sub'] == "users") && ($_GET['rallye'] > 0)) {
        // List users and their refs before start and current
        $result = SQL_QUERY_ESC("SELECT userid, refs, curr_points FROM "._MYSQL_PREFIX."_rallye_users WHERE rallye_id=%s ORDER BY userid",
         array(bigintval($_GET['rallye'])), __FILE__, __LINE__);
@@ -244,6 +241,10 @@ if (isset($_POST['edit']))
                                $cnt = ADMIN_USER_PROFILE_LINK($uid, $cnt, "list_refs");
                                $old = ADMIN_USER_PROFILE_LINK($uid, $old, "list_refs");
                        }
+
+                       // Get user points
+                       $points = GET_TOTAL_DATA($uid, "user_points", "points", "userid", false, " AND ref_depth=1 LIMIT 1");
+                       //* DEBUG: */ echo basename(__FILE__).":uid={$uid},points={$points},opoints={$opoints}<br />\n";
                        $content = array(
                                'sw'      => $SW ,
                                'uid'     => $uid,
@@ -251,7 +252,7 @@ if (isset($_POST['edit']))
                                'bold_r'  => $Br ,
                                'old'     => $old,
                                'cnt'     => $cnt,
-                               'opoints' => TRANSLATE_COMMA($opoints),
+                               'opoints' => TRANSLATE_COMMA($points - $opoints),
                        );
                        $OUT .= LOAD_TEMPLATE("admin_list_rallye_usr_row", true, $content);
                        $SW = 3 - $SW;
@@ -341,7 +342,7 @@ ORDER BY start_time DESC",
                                // Rallye is active so do not edit it!
                                $content['select'] = "<STRONG class=\"big\">".$id."</STRONG>";
                                $content['active_title'] = RALLYE_DEACTIVATE_NOW;
-                               $content['active'] = "0";
+                               $content['active'] = 0;
                                break;
 
                        case 'N':
@@ -355,7 +356,7 @@ ORDER BY start_time DESC",
                        {
                        case 'Y':
                                $content['notify_title'] = RALLYE_STOP_NOTIFY_NOW;
-                               $content['notify'] = "0";
+                               $content['notify'] = 0;
                                break;
 
                        case 'N':
@@ -369,7 +370,7 @@ ORDER BY start_time DESC",
                        {
                        case 'Y':
                                $content['auto_title'] = RALLYE_STOP_AUTO_ADD_NOW;
-                               $content['auto'] = "0";
+                               $content['auto'] = 0;
                                break;
 
                        case 'N':