]> git.mxchange.org Git - mailer.git/blobdiff - 0.2.1/inc/modules/admin/what-list_rallyes.php
win32 to unix line delimiters changed
[mailer.git] / 0.2.1 / inc / modules / admin / what-list_rallyes.php
index 551721e29ec8402a78ea7160d018dce5d316370a..ffe00d085a345f2ee60a23ccb3516df5318def8f 100644 (file)
-<?php\r
-/************************************************************************\r
- * MXChange v0.2.1                                    Start: 06/29/2004 *\r
- * ================                             Last change: 02/11/2005 *\r
- *                                                                      *\r
- * -------------------------------------------------------------------- *\r
- * File              : what-list_rallyes.php                            *\r
- * -------------------------------------------------------------------- *\r
- * Short description : List existing rallyes                            *\r
- * -------------------------------------------------------------------- *\r
- * Kurzbeschreibung  : Bestehende Rallyes auflisten                     *\r
- * -------------------------------------------------------------------- *\r
- *                                                                      *\r
- * -------------------------------------------------------------------- *\r
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *\r
- * For more information visit: http://www.mxchange.org                  *\r
- *                                                                      *\r
- * This program is free software; you can redistribute it and/or modify *\r
- * it under the terms of the GNU General Public License as published by *\r
- * the Free Software Foundation; either version 2 of the License, or    *\r
- * (at your option) any later version.                                  *\r
- *                                                                      *\r
- * This program is distributed in the hope that it will be useful,      *\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of       *\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *\r
- * GNU General Public License for more details.                         *\r
- *                                                                      *\r
- * You should have received a copy of the GNU General Public License    *\r
- * along with this program; if not, write to the Free Software          *\r
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *\r
- * MA  02110-1301  USA                                                  *\r
- ************************************************************************/\r
-\r
-// Some security stuff...\r
-if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))\r
-{\r
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";\r
-       require($INC);\r
-}\r
-\r
-// Add description as navigation point\r
-ADD_DESCR("admin", basename(__FILE__));\r
-\r
-if (empty($_GET['sub'])) $_GET['sub'] = "";\r
-$MSG = "";\r
-\r
-// Quick actions on a rallye\r
-if (isset($_GET['rallye']))\r
-{\r
-       // Activate / deactivate\r
-       $SQL = "";\r
-       if (isset($_GET['activate']))\r
-       {\r
-               switch ($_GET['activate'])\r
-               {\r
-               case "1": // Activate\r
-                       $SQL = "UPDATE "._MYSQL_PREFIX."_rallye_data SET is_active='Y' WHERE id=%d AND is_active='N' LIMIT 1";\r
-                       break;\r
-\r
-               case "0": // Deactivate\r
-                       $SQL = "UPDATE "._MYSQL_PREFIX."_rallye_data SET is_active='N' WHERE id=%d AND is_active='Y' LIMIT 1";\r
-                       break;\r
-               }\r
-       }\r
-\r
-       // Automatic notification\r
-       if (isset($_GET['notify']))\r
-       {\r
-               switch ($_GET['notify'])\r
-               {\r
-               case "1": // Activate\r
-                       $SQL = "UPDATE "._MYSQL_PREFIX."_rallye_data SET send_notify='Y' WHERE id=%d AND send_notify='N' LIMIT 1";\r
-                       break;\r
-\r
-               case "0": // Deactivate\r
-                       $SQL = "UPDATE "._MYSQL_PREFIX."_rallye_data SET send_notify='N' WHERE id=%d AND send_notify='Y' LIMIT 1";\r
-                       break;\r
-               }\r
-       }\r
-\r
-       // Automatic adding of new members\r
-       if (isset($_GET['auto']))\r
-       {\r
-               switch ($_GET['auto'])\r
-               {\r
-               case "1": // Activate\r
-                       $SQL = "UPDATE "._MYSQL_PREFIX."_rallye_data SET auto_add_new_user='Y' WHERE id=%d AND auto_add_new_user='N' LIMIT 1";\r
-                       break;\r
-\r
-               case "0": // Deactivate\r
-                       $SQL = "UPDATE "._MYSQL_PREFIX."_rallye_data SET auto_add_new_user='N' WHERE id=%d AND auto_add_new_user='Y' LIMIT 1";\r
-                       break;\r
-               }\r
-       }\r
-\r
-       // Run SQL command\r
-       if (!empty($SQL))\r
-       {\r
-               $result = SQL_QUERY_ESC($SQL, array(bigintval($_GET['rallye'])), __FILE__, __LINE__);\r
-       }\r
-}\r
- elseif (isset($_POST['remove']))\r
-{\r
-       // Delete rallyes\r
-       $SEL = SELECTION_COUNT($_POST['sel']);\r
-       if ($SEL > 0)\r
-       {\r
-               // Delete selected rallyes and all it's data\r
-               foreach ($_POST['sel'] as $id=>$sel)\r
-               {\r
-                       // Remove selected rallye entirely...\r
-                       $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_rallye_data WHERE id=%d LIMIT 1",\r
-                        array(bigintval($id)), __FILE__, __LINE__);\r
-                       $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_rallye_prices WHERE rallye_id=%d",\r
-                        array(bigintval($id)), __FILE__, __LINE__);\r
-                       $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_rallye_users WHERE rallye_id=%d",\r
-                        array(bigintval($id)), __FILE__, __LINE__);\r
-               }\r
-\r
-               // Output message\r
-               $MSG = RALLYE_DELETED;\r
-       }\r
-        else\r
-       {\r
-               // No rallye selected to delete!\r
-               $MSG = RALLYE_DELETE_NOTHING_SELECTED;\r
-       }\r
-}\r
- elseif (isset($_POST['change']))\r
-{\r
-       // Change rallye\r
-       $SEL = SELECTION_COUNT($_POST['title']);\r
-       if ($SEL > 0)\r
-       {\r
-               // Change selected rallyes and all it's data\r
-               foreach ($_POST['title'] as $id=>$title)\r
-               {\r
-                       // Secure ID number\r
-                       $id = bigintval($id);\r
-\r
-                       // Generate timestamps\r
-                       $START = mktime($_POST['start_hour'][$id], $_POST['start_min'][$id], $_POST['start_sec'][$id], $_POST['start_month'][$id], $_POST['start_day'][$id], $_POST['start_year'][$id]);\r
-                       $END   = mktime($_POST['end_hour'][$id]  , $_POST['end_min'][$id]  , $_POST['end_sec'][$id]  , $_POST['end_month'][$id]  , $_POST['end_day'][$id]  , $_POST['end_year'][$id]  );\r
-\r
-                       // Update entry\r
-                       $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_rallye_data SET\r
-title='%s',\r
-descr='%s',\r
-template='%s',\r
-start_time='%s',\r
-end_time='%s',\r
-min_users='%s',\r
-min_prices='%s'\r
-WHERE id='".$id."' LIMIT 1",\r
- array($title, $_POST['descr'][$id], $_POST['templ'][$id], bigintval($START), bigintval($END), bigintval($_POST['min_users'][$id]), bigintval($_POST['min_prices'][$id]), $id),\r
- __FILE__, __LINE__);\r
-               }\r
-\r
-               // Output message\r
-               $MSG = RALLYE_CHANGED;\r
-       }\r
-}\r
-\r
-if (isset($_POST['edit']))\r
-{\r
-       // Check for selections\r
-       $SEL = SELECTION_COUNT($_POST['sel']);\r
-       if ($SEL > 0)\r
-       {\r
-               // Make all selected and deactivated rallyes editable\r
-               $SW = 2; $OUT = "";\r
-               foreach ($_POST['sel'] as $id=>$sel)\r
-               {\r
-                       // Load rallye basic data\r
-                       $result = SQL_QUERY_ESC("SELECT title, descr, template, start_time, end_time, min_users, min_prices FROM "._MYSQL_PREFIX."_rallye_data WHERE id=%d LIMIT 1",\r
-                        array(bigintval($id)), __FILE__, __LINE__);\r
-                       list($title, $descr, $templ, $start, $end, $min_users, $min_prices) = SQL_FETCHROW($result);\r
-                       SQL_FREERESULT($result);\r
-\r
-                       // Starting day\r
-                       $content['s_sec']   = ADD_SELECTION("sec"  , date("s", $start), "start", $id);\r
-                       $content['s_min']   = ADD_SELECTION("min"  , date("i", $start), "start", $id);\r
-                       $content['s_hour']  = ADD_SELECTION("hour" , date("G", $start), "start", $id);\r
-                       $content['s_day']   = ADD_SELECTION("day"  , date("d", $start), "start", $id);\r
-                       $content['s_month'] = ADD_SELECTION("month", date("m", $start), "start", $id);\r
-                       $content['s_year']  = ADD_SELECTION("year" , date("Y", $start), "start", $id);\r
-\r
-                       // Ending day\r
-                       $content['e_sec']   = ADD_SELECTION("sec"  , date("s", $end)  , "end"  , $id);\r
-                       $content['e_min']   = ADD_SELECTION("min"  , date("i", $end)  , "end"  , $id);\r
-                       $content['e_hour']  = ADD_SELECTION("hour" , date("G", $end)  , "end"  , $id);\r
-                       $content['e_day']   = ADD_SELECTION("day"  , date("d", $end)  , "end"  , $id);\r
-                       $content['e_month'] = ADD_SELECTION("month", date("m", $end)  , "end"  , $id);\r
-                       $content['e_year']  = ADD_SELECTION("year" , date("Y", $end)  , "end"  , $id);\r
-\r
-                       // Remember over values\r
-                       $content['templ']      = RALLYE_TEMPLATE_SELECTION("templ[".$id."]", $templ);\r
-                       $content['sw']         = $SW;\r
-                       $content['id']         = $id;\r
-                       $content['title']      = $title;\r
-                       $content['descr']      = $descr;\r
-                       $content['min_users']  = $min_users;\r
-                       $content['min_prices'] = $min_prices;\r
-\r
-                       // Output row\r
-                       $OUT .= LOAD_TEMPLATE("admin_edit_rallyes_row", true, $content);\r
-\r
-                       // Color switching\r
-                       $SW = 3 - $SW;\r
-               }\r
-               // Remember rows in constant\r
-               define('__RALLYE_ROWS', $OUT);\r
-\r
-               // Load final template\r
-               LOAD_TEMPLATE("admin_edit_rallyes");\r
-       }\r
-        else\r
-       {\r
-               // Nothing selected to edit\r
-               LOAD_TEMPLATE("admin_settings_saved", false, LOAD_TEMPLATE("admin_list_rallye_noselect", true));\r
-       }\r
-}\r
- elseif (($_GET['sub'] == "users") && ($_GET['rallye'] > 0))\r
-{\r
-       // List users and their refs before start and current\r
-       $result = SQL_QUERY_ESC("SELECT userid, refs, curr_points FROM "._MYSQL_PREFIX."_rallye_users WHERE rallye_id=%d ORDER BY userid",\r
-        array(bigintval($_GET['rallye'])), __FILE__, __LINE__);\r
-       if (SQL_NUMROWS($result) > 0)\r
-       {\r
-               $SW = 2; $OUT = "";\r
-               define('__RALLYE_VALUE', $_GET['rallye']);\r
-               while (list($uid, $old, $opoints) = SQL_FETCHROW($result))\r
-               {\r
-                       // Check for referral count\r
-                       $cnt = RALLYE_GET_REFCOUNT($uid, $old);\r
-\r
-                       // Output row\r
-                       $Bl = ""; $Br = "";\r
-                       if (($opoints > 0) && ($cnt > 0)) { $Bl = "<STRONG>"; $Br = "</STRONG>"; }\r
-                       if (($old > 0) || ($cnt > 0))\r
-                       {\r
-                               // Insert link to referral list\r
-                               //* DEBUG: */ echo "-".$uid."/".$cnt."/".$old."-<BR>";\r
-                               $cnt = ADMIN_USER_PROFILE_LINK($uid, $cnt, "list_refs");\r
-                               $old = ADMIN_USER_PROFILE_LINK($uid, $old, "list_refs");\r
-                       }\r
-                       $content = array(\r
-                               'sw'      => $SW ,\r
-                               'uid'     => $uid,\r
-                               'bold_l'  => $Bl ,\r
-                               'bold_r'  => $Br ,\r
-                               'old'     => $old,\r
-                               'cnt'     => $cnt,\r
-                               'opoints' => TRANSLATE_COMMA($opoints),\r
-                       );\r
-                       $OUT .= LOAD_TEMPLATE("admin_list_rallye_usr_row", true, $content);\r
-                       $SW = 3 - $SW;\r
-               }\r
-\r
-               // Free memory\r
-               SQL_FREERESULT($result);\r
-               define('__RALLYE_USER_ROWS', $OUT);\r
-\r
-               // Load template\r
-               LOAD_TEMPLATE("admin_list_rallye_usr");\r
-       }\r
-        else\r
-       {\r
-               // No entries found?\r
-               LOAD_TEMPLATE("admin_settings_saved", false, RALLYE_ADMIN_USERS_404);\r
-       }\r
-}\r
- else\r
-{\r
-       // Start listing rallyes\r
-       $result = SQL_QUERY("SELECT id, admin_id, title, descr, template, start_time, end_time, auto_add_new_user, is_active, send_notify, notified, min_users, min_prices\r
-FROM "._MYSQL_PREFIX."_rallye_data\r
-ORDER BY start_time DESC",\r
- __FILE__, __LINE__);\r
-       if (SQL_NUMROWS($result) > 0)\r
-       {\r
-               // List found rallyes\r
-               $SW = 2; $OUT = "";\r
-               while (list($id, $aid, $title, $descr, $templ, $start, $end, $auto_add, $active, $notify, $notified, $min_users, $min_prices) = SQL_FETCHROW($result))\r
-               {\r
-                       // Load admin login\r
-                       $alogin = GET_ADMIN_LOGIN($aid);\r
-\r
-                       // Count assigned prices\r
-                       $result_prices = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_rallye_prices WHERE rallye_id=%d",\r
-                        array(bigintval($id)), __FILE__, __LINE__);\r
-\r
-                       // Count joined userids\r
-                       $result_user = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_rallye_users WHERE rallye_id=%d",\r
-                        array($id), __FILE__, __LINE__);\r
-                       $joined = SQL_NUMROWS($result_user);\r
-\r
-                       // Did some users joined this rallye?\r
-                       if ($joined > 0)\r
-                       {\r
-                               // List joined users\r
-                               $joined = "<A href=\"".URL."/modules.php?module=admin&amp;what=list_rallyes&amp;sub=users&amp;rallye=".$id."\" title=\"".RALLYE_LIST_USERS."\">".$joined."</A>";\r
-                       }\r
-\r
-                       // Alter some variables\r
-                       if (empty($alogin)) $alogin = "???";\r
-                       if (empty($templ))  $templ  = "---";\r
-                       if (empty($descr))  $descr  = "---";\r
-\r
-                       // Transfer data into array for the template\r
-                       $content = array(\r
-                               'select'     => "<INPUT type=\"checkbox\" name=\"sel[".$id."]\" class=\"admin_normal\" value=\"1\">",\r
-                               'aid'        => $aid,\r
-                               'email_link' => CREATE_EMAIL_LINK($aid),\r
-                               'alogin'     => $alogin,\r
-                               'id'         => $id,\r
-                               'sw'         => $SW,\r
-                               'title'      => $title,\r
-                               'template'   => $templ,\r
-                               'joined'     => $joined,\r
-                               'start_date' => MAKE_DATETIME($start, "2"),\r
-                               'end_date'   => MAKE_DATETIME($end  , "2"),\r
-                               'active_lnk' => TRANSLATE_YESNO($active),\r
-                               'notify_lnk' => TRANSLATE_YESNO($notify),\r
-                               'auto_lnk'   => TRANSLATE_YESNO($auto_add),\r
-                               'notified'   => TRANSLATE_YESNO($notified),\r
-                               'prices_cnt' => SQL_NUMROWS($result_prices),\r
-                               'descr'      => COMPILE_CODE($descr),\r
-                               'min_users'  => $min_users,\r
-                               'min_prices' => $min_prices,\r
-                       );\r
-\r
-                       // Free memory\r
-                       SQL_FREERESULT($result_prices);\r
-                       SQL_FREERESULT($result_user);\r
-\r
-                       // Is the rallye active or not?\r
-                       switch ($active)\r
-                       {\r
-                       case "Y":\r
-                               // Rallye is active so do not edit it!\r
-                               $content['select'] = "<STRONG class=\"big\">".$id."</STRONG>";\r
-                               $content['active_title'] = RALLYE_DEACTIVATE_NOW;\r
-                               $content['active'] = "0";\r
-                               break;\r
-\r
-                       case "N":\r
-                               $content['active_title'] = RALLYE_ACTIVATE_NOW;\r
-                               $content['active'] = "1";\r
-                               break;\r
-                       }\r
-\r
-                       // Notification to members?\r
-                       switch ($notify)\r
-                       {\r
-                       case "Y":\r
-                               $content['notify_title'] = RALLYE_STOP_NOTIFY_NOW;\r
-                               $content['notify'] = "0";\r
-                               break;\r
-\r
-                       case "N":\r
-                               $content['notify_title'] = RALLYE_START_NOTIFY_NOW;\r
-                               $content['notify'] = "1";\r
-                               break;\r
-                       }\r
-\r
-                       // Auto-add of new joined members?\r
-                       switch ($auto_add)\r
-                       {\r
-                       case "Y":\r
-                               $content['auto_title'] = RALLYE_STOP_AUTO_ADD_NOW;\r
-                               $content['auto'] = "0";\r
-                               break;\r
-\r
-                       case "N":\r
-                               $content['auto_title'] = RALLYE_START_AUTO_ADD_NOW;\r
-                               $content['auto'] = "1";\r
-                               break;\r
-                       }\r
-\r
-                       // Output row\r
-                       $OUT .= LOAD_TEMPLATE("admin_list_rallyes_row", true, $content);\r
-                       $SW = 3 - $SW;\r
-               }\r
-\r
-               // Free memory\r
-               SQL_FREERESULT($result);\r
-               define('__RALLYE_ROWS', $OUT);\r
-\r
-               // Load template\r
-               LOAD_TEMPLATE("admin_list_rallyes");\r
-       }\r
-        else\r
-       {\r
-               // No rallyes setup so far\r
-               LOAD_TEMPLATE("admin_settings_saved", false, RALLYE_NO_RALLYES_SETUP);\r
-       }\r
-}\r
-//\r
-?>\r
+<?php
+/************************************************************************
+ * MXChange v0.2.1                                    Start: 06/29/2004 *
+ * ================                             Last change: 02/11/2005 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : what-list_rallyes.php                            *
+ * -------------------------------------------------------------------- *
+ * Short description : List existing rallyes                            *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Bestehende Rallyes auflisten                     *
+ * -------------------------------------------------------------------- *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * For more information visit: http://www.mxchange.org                  *
+ *                                                                      *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or    *
+ * (at your option) any later version.                                  *
+ *                                                                      *
+ * This program is distributed in the hope that it will be useful,      *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
+ * GNU General Public License for more details.                         *
+ *                                                                      *
+ * You should have received a copy of the GNU General Public License    *
+ * along with this program; if not, write to the Free Software          *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
+ * MA  02110-1301  USA                                                  *
+ ************************************************************************/
+
+// Some security stuff...
+if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
+{
+       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+       require($INC);
+}
+
+// Add description as navigation point
+ADD_DESCR("admin", basename(__FILE__));
+
+if (empty($_GET['sub'])) $_GET['sub'] = "";
+$MSG = "";
+
+// Quick actions on a rallye
+if (isset($_GET['rallye']))
+{
+       // Activate / deactivate
+       $SQL = "";
+       if (isset($_GET['activate']))
+       {
+               switch ($_GET['activate'])
+               {
+               case "1": // Activate
+                       $SQL = "UPDATE "._MYSQL_PREFIX."_rallye_data SET is_active='Y' WHERE id=%d AND is_active='N' LIMIT 1";
+                       break;
+
+               case "0": // Deactivate
+                       $SQL = "UPDATE "._MYSQL_PREFIX."_rallye_data SET is_active='N' WHERE id=%d AND is_active='Y' LIMIT 1";
+                       break;
+               }
+       }
+
+       // Automatic notification
+       if (isset($_GET['notify']))
+       {
+               switch ($_GET['notify'])
+               {
+               case "1": // Activate
+                       $SQL = "UPDATE "._MYSQL_PREFIX."_rallye_data SET send_notify='Y' WHERE id=%d AND send_notify='N' LIMIT 1";
+                       break;
+
+               case "0": // Deactivate
+                       $SQL = "UPDATE "._MYSQL_PREFIX."_rallye_data SET send_notify='N' WHERE id=%d AND send_notify='Y' LIMIT 1";
+                       break;
+               }
+       }
+
+       // Automatic adding of new members
+       if (isset($_GET['auto']))
+       {
+               switch ($_GET['auto'])
+               {
+               case "1": // Activate
+                       $SQL = "UPDATE "._MYSQL_PREFIX."_rallye_data SET auto_add_new_user='Y' WHERE id=%d AND auto_add_new_user='N' LIMIT 1";
+                       break;
+
+               case "0": // Deactivate
+                       $SQL = "UPDATE "._MYSQL_PREFIX."_rallye_data SET auto_add_new_user='N' WHERE id=%d AND auto_add_new_user='Y' LIMIT 1";
+                       break;
+               }
+       }
+
+       // Run SQL command
+       if (!empty($SQL))
+       {
+               $result = SQL_QUERY_ESC($SQL, array(bigintval($_GET['rallye'])), __FILE__, __LINE__);
+       }
+}
+ elseif (isset($_POST['remove']))
+{
+       // Delete rallyes
+       $SEL = SELECTION_COUNT($_POST['sel']);
+       if ($SEL > 0)
+       {
+               // Delete selected rallyes and all it's data
+               foreach ($_POST['sel'] as $id=>$sel)
+               {
+                       // Remove selected rallye entirely...
+                       $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_rallye_data WHERE id=%d LIMIT 1",
+                        array(bigintval($id)), __FILE__, __LINE__);
+                       $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_rallye_prices WHERE rallye_id=%d",
+                        array(bigintval($id)), __FILE__, __LINE__);
+                       $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_rallye_users WHERE rallye_id=%d",
+                        array(bigintval($id)), __FILE__, __LINE__);
+               }
+
+               // Output message
+               $MSG = RALLYE_DELETED;
+       }
+        else
+       {
+               // No rallye selected to delete!
+               $MSG = RALLYE_DELETE_NOTHING_SELECTED;
+       }
+}
+ elseif (isset($_POST['change']))
+{
+       // Change rallye
+       $SEL = SELECTION_COUNT($_POST['title']);
+       if ($SEL > 0)
+       {
+               // Change selected rallyes and all it's data
+               foreach ($_POST['title'] as $id=>$title)
+               {
+                       // Secure ID number
+                       $id = bigintval($id);
+
+                       // Generate timestamps
+                       $START = mktime($_POST['start_hour'][$id], $_POST['start_min'][$id], $_POST['start_sec'][$id], $_POST['start_month'][$id], $_POST['start_day'][$id], $_POST['start_year'][$id]);
+                       $END   = mktime($_POST['end_hour'][$id]  , $_POST['end_min'][$id]  , $_POST['end_sec'][$id]  , $_POST['end_month'][$id]  , $_POST['end_day'][$id]  , $_POST['end_year'][$id]  );
+
+                       // Update entry
+                       $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_rallye_data SET
+title='%s',
+descr='%s',
+template='%s',
+start_time='%s',
+end_time='%s',
+min_users='%s',
+min_prices='%s'
+WHERE id='".$id."' LIMIT 1",
+ array($title, $_POST['descr'][$id], $_POST['templ'][$id], bigintval($START), bigintval($END), bigintval($_POST['min_users'][$id]), bigintval($_POST['min_prices'][$id]), $id),
+ __FILE__, __LINE__);
+               }
+
+               // Output message
+               $MSG = RALLYE_CHANGED;
+       }
+}
+
+if (isset($_POST['edit']))
+{
+       // Check for selections
+       $SEL = SELECTION_COUNT($_POST['sel']);
+       if ($SEL > 0)
+       {
+               // Make all selected and deactivated rallyes editable
+               $SW = 2; $OUT = "";
+               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=%d LIMIT 1",
+                        array(bigintval($id)), __FILE__, __LINE__);
+                       list($title, $descr, $templ, $start, $end, $min_users, $min_prices) = SQL_FETCHROW($result);
+                       SQL_FREERESULT($result);
+
+                       // Starting day
+                       $content['s_sec']   = ADD_SELECTION("sec"  , date("s", $start), "start", $id);
+                       $content['s_min']   = ADD_SELECTION("min"  , date("i", $start), "start", $id);
+                       $content['s_hour']  = ADD_SELECTION("hour" , date("G", $start), "start", $id);
+                       $content['s_day']   = ADD_SELECTION("day"  , date("d", $start), "start", $id);
+                       $content['s_month'] = ADD_SELECTION("month", date("m", $start), "start", $id);
+                       $content['s_year']  = ADD_SELECTION("year" , date("Y", $start), "start", $id);
+
+                       // Ending day
+                       $content['e_sec']   = ADD_SELECTION("sec"  , date("s", $end)  , "end"  , $id);
+                       $content['e_min']   = ADD_SELECTION("min"  , date("i", $end)  , "end"  , $id);
+                       $content['e_hour']  = ADD_SELECTION("hour" , date("G", $end)  , "end"  , $id);
+                       $content['e_day']   = ADD_SELECTION("day"  , date("d", $end)  , "end"  , $id);
+                       $content['e_month'] = ADD_SELECTION("month", date("m", $end)  , "end"  , $id);
+                       $content['e_year']  = ADD_SELECTION("year" , date("Y", $end)  , "end"  , $id);
+
+                       // Remember over values
+                       $content['templ']      = RALLYE_TEMPLATE_SELECTION("templ[".$id."]", $templ);
+                       $content['sw']         = $SW;
+                       $content['id']         = $id;
+                       $content['title']      = $title;
+                       $content['descr']      = $descr;
+                       $content['min_users']  = $min_users;
+                       $content['min_prices'] = $min_prices;
+
+                       // Output row
+                       $OUT .= LOAD_TEMPLATE("admin_edit_rallyes_row", true, $content);
+
+                       // Color switching
+                       $SW = 3 - $SW;
+               }
+               // Remember rows in constant
+               define('__RALLYE_ROWS', $OUT);
+
+               // Load final template
+               LOAD_TEMPLATE("admin_edit_rallyes");
+       }
+        else
+       {
+               // Nothing selected to edit
+               LOAD_TEMPLATE("admin_settings_saved", false, LOAD_TEMPLATE("admin_list_rallye_noselect", true));
+       }
+}
+ 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=%d ORDER BY userid",
+        array(bigintval($_GET['rallye'])), __FILE__, __LINE__);
+       if (SQL_NUMROWS($result) > 0)
+       {
+               $SW = 2; $OUT = "";
+               define('__RALLYE_VALUE', $_GET['rallye']);
+               while (list($uid, $old, $opoints) = SQL_FETCHROW($result))
+               {
+                       // Check for referral count
+                       $cnt = RALLYE_GET_REFCOUNT($uid, $old);
+
+                       // Output row
+                       $Bl = ""; $Br = "";
+                       if (($opoints > 0) && ($cnt > 0)) { $Bl = "<STRONG>"; $Br = "</STRONG>"; }
+                       if (($old > 0) || ($cnt > 0))
+                       {
+                               // Insert link to referral list
+                               //* DEBUG: */ echo "-".$uid."/".$cnt."/".$old."-<BR>";
+                               $cnt = ADMIN_USER_PROFILE_LINK($uid, $cnt, "list_refs");
+                               $old = ADMIN_USER_PROFILE_LINK($uid, $old, "list_refs");
+                       }
+                       $content = array(
+                               'sw'      => $SW ,
+                               'uid'     => $uid,
+                               'bold_l'  => $Bl ,
+                               'bold_r'  => $Br ,
+                               'old'     => $old,
+                               'cnt'     => $cnt,
+                               'opoints' => TRANSLATE_COMMA($opoints),
+                       );
+                       $OUT .= LOAD_TEMPLATE("admin_list_rallye_usr_row", true, $content);
+                       $SW = 3 - $SW;
+               }
+
+               // Free memory
+               SQL_FREERESULT($result);
+               define('__RALLYE_USER_ROWS', $OUT);
+
+               // Load template
+               LOAD_TEMPLATE("admin_list_rallye_usr");
+       }
+        else
+       {
+               // No entries found?
+               LOAD_TEMPLATE("admin_settings_saved", false, RALLYE_ADMIN_USERS_404);
+       }
+}
+ else
+{
+       // Start listing rallyes
+       $result = SQL_QUERY("SELECT id, admin_id, title, descr, template, start_time, end_time, auto_add_new_user, is_active, send_notify, notified, min_users, min_prices
+FROM "._MYSQL_PREFIX."_rallye_data
+ORDER BY start_time DESC",
+ __FILE__, __LINE__);
+       if (SQL_NUMROWS($result) > 0)
+       {
+               // List found rallyes
+               $SW = 2; $OUT = "";
+               while (list($id, $aid, $title, $descr, $templ, $start, $end, $auto_add, $active, $notify, $notified, $min_users, $min_prices) = SQL_FETCHROW($result))
+               {
+                       // Load admin login
+                       $alogin = GET_ADMIN_LOGIN($aid);
+
+                       // Count assigned prices
+                       $result_prices = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_rallye_prices WHERE rallye_id=%d",
+                        array(bigintval($id)), __FILE__, __LINE__);
+
+                       // Count joined userids
+                       $result_user = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_rallye_users WHERE rallye_id=%d",
+                        array($id), __FILE__, __LINE__);
+                       $joined = SQL_NUMROWS($result_user);
+
+                       // Did some users joined this rallye?
+                       if ($joined > 0)
+                       {
+                               // List joined users
+                               $joined = "<A href=\"".URL."/modules.php?module=admin&amp;what=list_rallyes&amp;sub=users&amp;rallye=".$id."\" title=\"".RALLYE_LIST_USERS."\">".$joined."</A>";
+                       }
+
+                       // Alter some variables
+                       if (empty($alogin)) $alogin = "???";
+                       if (empty($templ))  $templ  = "---";
+                       if (empty($descr))  $descr  = "---";
+
+                       // Transfer data into array for the template
+                       $content = array(
+                               'select'     => "<INPUT type=\"checkbox\" name=\"sel[".$id."]\" class=\"admin_normal\" value=\"1\">",
+                               'aid'        => $aid,
+                               'email_link' => CREATE_EMAIL_LINK($aid),
+                               'alogin'     => $alogin,
+                               'id'         => $id,
+                               'sw'         => $SW,
+                               'title'      => $title,
+                               'template'   => $templ,
+                               'joined'     => $joined,
+                               'start_date' => MAKE_DATETIME($start, "2"),
+                               'end_date'   => MAKE_DATETIME($end  , "2"),
+                               'active_lnk' => TRANSLATE_YESNO($active),
+                               'notify_lnk' => TRANSLATE_YESNO($notify),
+                               'auto_lnk'   => TRANSLATE_YESNO($auto_add),
+                               'notified'   => TRANSLATE_YESNO($notified),
+                               'prices_cnt' => SQL_NUMROWS($result_prices),
+                               'descr'      => COMPILE_CODE($descr),
+                               'min_users'  => $min_users,
+                               'min_prices' => $min_prices,
+                       );
+
+                       // Free memory
+                       SQL_FREERESULT($result_prices);
+                       SQL_FREERESULT($result_user);
+
+                       // Is the rallye active or not?
+                       switch ($active)
+                       {
+                       case "Y":
+                               // Rallye is active so do not edit it!
+                               $content['select'] = "<STRONG class=\"big\">".$id."</STRONG>";
+                               $content['active_title'] = RALLYE_DEACTIVATE_NOW;
+                               $content['active'] = "0";
+                               break;
+
+                       case "N":
+                               $content['active_title'] = RALLYE_ACTIVATE_NOW;
+                               $content['active'] = "1";
+                               break;
+                       }
+
+                       // Notification to members?
+                       switch ($notify)
+                       {
+                       case "Y":
+                               $content['notify_title'] = RALLYE_STOP_NOTIFY_NOW;
+                               $content['notify'] = "0";
+                               break;
+
+                       case "N":
+                               $content['notify_title'] = RALLYE_START_NOTIFY_NOW;
+                               $content['notify'] = "1";
+                               break;
+                       }
+
+                       // Auto-add of new joined members?
+                       switch ($auto_add)
+                       {
+                       case "Y":
+                               $content['auto_title'] = RALLYE_STOP_AUTO_ADD_NOW;
+                               $content['auto'] = "0";
+                               break;
+
+                       case "N":
+                               $content['auto_title'] = RALLYE_START_AUTO_ADD_NOW;
+                               $content['auto'] = "1";
+                               break;
+                       }
+
+                       // Output row
+                       $OUT .= LOAD_TEMPLATE("admin_list_rallyes_row", true, $content);
+                       $SW = 3 - $SW;
+               }
+
+               // Free memory
+               SQL_FREERESULT($result);
+               define('__RALLYE_ROWS', $OUT);
+
+               // Load template
+               LOAD_TEMPLATE("admin_list_rallyes");
+       }
+        else
+       {
+               // No rallyes setup so far
+               LOAD_TEMPLATE("admin_settings_saved", false, RALLYE_NO_RALLYES_SETUP);
+       }
+}
+//
+?>