referral levels are saved now. the script was telling you they were not.
[mailer.git] / 0.2.1 / inc / modules / admin / what-config_points.php
index 018fee1af798fdf1ec3908f80f43a8b1ab0b309d..a1e35996d6f3bad91e09dc34c61850c6e59e5e8c 100644 (file)
-<?php\r
-/************************************************************************\r
- * MXChange v0.2.1                                    Start: 10/12/2003 *\r
- * ===============                              Last change: 12/12/2004 *\r
- *                                                                      *\r
- * -------------------------------------------------------------------- *\r
- * File              : what-config_points.php                           *\r
- * -------------------------------------------------------------------- *\r
- * Short description : Setup welcome-points for registration etc.       *\r
- * -------------------------------------------------------------------- *\r
- * Kurzbeschreibung  : Einstellen der Willkommensgutschrift usw.        *\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
-global $link;\r
-\r
-// Add description as navigation point\r
-ADD_DESCR("admin", basename(__FILE__));\r
-\r
-OPEN_TABLE("100%", "admin_content admin_content_align", "");\r
-if (!empty($_GET['sub']))\r
-{\r
-       switch ($_GET['sub'])\r
-       {\r
-       case "points":\r
-               if ((empty($_POST['points_register'])) || (empty($_POST['points_ref'])))\r
-               {\r
-                       unset($_POST['ok']);\r
-               }\r
-               break;\r
-\r
-       case "ref":\r
-               if (isset($_GET['do']))\r
-               {\r
-                       if (((empty($_POST['lvl'])) || (empty($_POST['perc']))) && ($_GET['do'] == "add"))\r
-                       {\r
-                               unset($_POST['ok']);\r
-                       }\r
-               }\r
-               break;\r
-       }\r
-}\r
- else\r
-{\r
-       // Display overview\r
-       $_GET['sub'] = "overview";\r
-}\r
-\r
-if (isset($_POST['ok']))\r
-{\r
-       $SQL = array();\r
-       switch ($_GET['sub'])\r
-       {\r
-       case "points":\r
-               $SQL[] = "UPDATE "._MYSQL_PREFIX."_config SET points_register='".$_POST['points_register']."', points_ref='".$_POST['points_ref']."' WHERE config='0' LIMIT 1";\r
-               break;\r
-\r
-       case "ref":\r
-               switch ($_GET['do'])\r
-               {\r
-               case "add":\r
-                       $SQL[] = "INSERT INTO "._MYSQL_PREFIX."_refdepths (level, percents) VALUES ('".$_POST['lvl']."', '".$_POST['perc']."')";\r
-                       break;\r
-\r
-               case "edit": // Change entries\r
-                       foreach ($_POST['lvl'] as $id=>$value)\r
-                       {\r
-                               // Secure ID\r
-                               $id = bigintval($id);\r
-\r
-                               // Update entry\r
-                               $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_refdepths SET level='%s', percents='%s' WHERE id=%d LIMIT 1",\r
-                                array(bigintval($value), $_POST['perc'][$id], $id), __FILE__, __LINE__);\r
-                       }\r
-                       $TEXT = REF_DEPTHS_SAVED;\r
-                       break;\r
-\r
-               case "del":\r
-                       foreach ($_POST['id'] as $id=>$value)\r
-                       {\r
-                               $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_refdepths WHERE id=%d LIMIT 1",\r
-                                array(bigintval($id)), __FILE__, __LINE__);\r
-                       }\r
-                       $TEXT = REF_DEPTHS_DELETED;\r
-                       break;\r
-               }\r
-\r
-               // Update cache file\r
-               if (GET_EXT_VERSION("cache") >= "0.1.2")\r
-               {\r
-                       if ($CACHE->cache_file("refdepths", true)) $CACHE->cache_destroy();\r
-               }\r
-               break;\r
-\r
-       case "settings":\r
-               $REF = bigintval($_POST['ref_payout']);\r
-               $SQL[] = sprintf("UPDATE "._MYSQL_PREFIX."_config SET\r
-allow_direct_pay='%s',\r
-reg_points_mode='%s',\r
-ref_payout='%d'\r
-WHERE config='0' LIMIT 1",\r
- $_POST['direct_pay'],\r
- $_POST['refmode'],\r
- $REF\r
-               );\r
-               if (($CONFIG['ref_payout'] == 0) && ($_POST['ref_payout'] > 0))\r
-               {\r
-                       // Update account's ref_payout for "must-confirm"\r
-                       $SQL[] = sprintf("UPDATE "._MYSQL_PREFIX."_user_data SET ref_payout=(%d - mails_confirmed)\r
-WHERE mails_confirmed < %d", $REF, $REF);\r
-               }\r
-                elseif (($CONFIG['ref_payout'] > 0) && ($_POST['ref_payout'] == 0))\r
-               {\r
-                       // Update account's ref_payout for "not-must-confirm"\r
-                       $SQL[] = "UPDATE "._MYSQL_PREFIX."_user_data SET ref_payout=0 WHERE ref_payout > 0";\r
-                       $SQL[] = "UPDATE "._MYSQL_PREFIX."_user_points SET points=points+locked_points WHERE locked_points>0";\r
-                       $SQL[] = "UPDATE "._MYSQL_PREFIX."_user_points SET locked_points=0 WHERE locked_points>0";\r
-               }\r
-               break;\r
-       }\r
-       if (isset($SQL))\r
-       {\r
-               if (strpos($SQL[0], "INSERT") > -1)\r
-               {\r
-                       $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_refdepths WHERE level='%s' LIMIT 1",\r
-                        array(bigintval($_POST['lvl'])), __FILE__, __LINE__);\r
-                       SQL_FREERESULT($result);\r
-               }\r
-               if (count($SQL) > 0)\r
-               {\r
-                       // Run all SQL commands\r
-                       foreach ($SQL as $s)\r
-                       {\r
-                               $result = SQL_QUERY($s, __FILE__, __LINE__);\r
-                       }\r
-\r
-                       $content = "<SPAN class=\"admin_done\">".SETTINGS_SAVED."</SPAN>";\r
-\r
-                       // Destroy config cache file here...\r
-                       if (GET_EXT_VERSION("cache") >= "0.1.2")\r
-                       {\r
-                               if ($CACHE->cache_file("config", true)) $CACHE->cache_destroy();\r
-                               unset($CFG_CACHE);\r
-                       }\r
-               }\r
-                else\r
-               {\r
-                       $content = "<SPAN class=\"admin_failed\">".SETTINGS_NOT_SAVED."</SPAN>";\r
-               }\r
-               unset($SQL);\r
-               LOAD_TEMPLATE("admin_settings_saved", false, $content);\r
-       }\r
-        elseif (isset($TEXT))\r
-       {\r
-               LOAD_TEMPLATE("admin_settings_saved", false, $TEXT);\r
-       }\r
-}\r
- elseif ($_GET['sub'] == "settings")\r
-{\r
-       // Setup some settings like direct pay and so on\r
-       // Including new add-mode for one-time referral bonus\r
-       switch ($CONFIG['direct_pay'])\r
-       {\r
-       case "Y":\r
-               define('__DIRECT_Y', " checked");\r
-               define('__DIRECT_N', "");\r
-               break;\r
-\r
-       case "N":\r
-               define('__DIRECT_Y', "");\r
-               define('__DIRECT_N', " checked");\r
-               break;\r
-       }\r
-\r
-       // One-time referral bonus add-mode\r
-       switch ($CONFIG['reg_points_mode'])\r
-       {\r
-               case "ref"   : define('__MODE_REF', " checked"); define('__MODE_DIRECT', "");         break;\r
-               case "direct": define('__MODE_REF', "");         define('__MODE_DIRECT', " checked"); break;\r
-       }\r
-\r
-       // Referral payout value\r
-       define('__REF_PAYOUT', round($CONFIG['ref_payout']));\r
-\r
-       // Load template\r
-       LOAD_TEMPLATE("admin_config_point_settings");\r
-}\r
- elseif ($_GET['sub'] == "ref")\r
-{\r
-        if ((isset($_POST['del'])) && ((SELECTION_COUNT($_POST['sel']) > 0) || (isset($_POST['sel'][0]))))\r
-       {\r
-               // Delete entries\r
-               $SW = 2; $OUT = "";\r
-               foreach ($_POST['sel'] as $id=>$value)\r
-               {\r
-                       $result = SQL_QUERY_ESC("SELECT level, percents FROM "._MYSQL_PREFIX."_refdepths WHERE id=%d LIMIT 1",\r
-                        array(bigintval($id)), __FILE__, __LINE__);\r
-                       list($lvl, $perc) = SQL_FETCHROW($result);\r
-                       SQL_FREERESULT($result);\r
-\r
-                       // Prepare data for the row template\r
-                       $content = array(\r
-                               'sw'  => $SW,\r
-                               'id'  => $id,\r
-                               'lvl' => $lvl,\r
-                               'per' => $perc,\r
-                       );\r
-\r
-                       // Load row template and switch color\r
-                       $OUT .= LOAD_TEMPLATE("admin_points_del_row", true, $content);\r
-                       $SW = 3 - $SW;\r
-               }\r
-               define('__LEVEL_ROWS', $OUT);\r
-\r
-               // Load main template\r
-               LOAD_TEMPLATE("admin_points_del");\r
-       }\r
-        elseif ((isset($_POST['edit'])) && ((SELECTION_COUNT($_POST['sel']) > 0) || (isset($_POST['sel'][0]))))\r
-       {\r
-               // Edit entries\r
-               $SW = 2; $OUT = "";\r
-               foreach ($_POST['sel'] as $id=>$value)\r
-               {\r
-                       $result = SQL_QUERY_ESC("SELECT level, percents FROM "._MYSQL_PREFIX."_refdepths WHERE id=%d LIMIT 1",\r
-                        array(bigintval($id)), __FILE__, __LINE__);\r
-                       list($lvl, $perc) = SQL_FETCHROW($result);\r
-                       SQL_FREERESULT($result);\r
-\r
-                       // Prepare data for the row template\r
-                       $content = array(\r
-                               'sw'  => $SW,\r
-                               'id'  => $id,\r
-                               'lvl' => $lvl,\r
-                               'per' => $perc,\r
-                       );\r
-\r
-                       // Load row template and switch color\r
-                       $OUT .= LOAD_TEMPLATE("admin_points_edit_row", true, $content);\r
-                       $SW = 3 - $SW;\r
-               }\r
-               define('__LEVEL_ROWS', $OUT);\r
-\r
-               // Load main template\r
-               LOAD_TEMPLATE("admin_points_edit");\r
-       }\r
-        else\r
-       {\r
-               // Referral levels\r
-               $result = SQL_QUERY("SELECT id, level, percents FROM "._MYSQL_PREFIX."_refdepths ORDER BY level", __FILE__, __LINE__);\r
-               if (SQL_NUMROWS($result) > 0)\r
-               {\r
-                       // Make referral levels editable and deletable\r
-                       $SW = 2; $OUT = "";\r
-\r
-                       // List already existing categories for editing\r
-                       while (list($id, $lvl, $perc) = SQL_FETCHROW($result))\r
-                       {\r
-                               // Prepare data for the row template\r
-                               $content = array(\r
-                                       'sw'  => $SW,\r
-                                       'id'  => $id,\r
-                                       'lvl' => $lvl,\r
-                                       'per' => $perc,\r
-                               );\r
-\r
-                               // Load row template and switch color\r
-                               $OUT .= LOAD_TEMPLATE("admin_points_row", true, $content);\r
-                               $SW = 3 - $SW;\r
-                       }\r
-\r
-                       // Free memory\r
-                       SQL_FREERESULT($result);\r
-                       define('__LEVEL_ROWS', $OUT);\r
-\r
-                       // Load main template\r
-                       LOAD_TEMPLATE("admin_points");\r
-               }\r
-\r
-               // Form for adding new referral levels\r
-               LOAD_TEMPLATE("admin_add_reflvl");\r
-       }\r
-}\r
- elseif ($_GET['sub'] == "points")\r
-{\r
-       // First points for registration and other fixed points including new add-mode for one-time referral bonus...\r
-       define('P_REG_VALUE', $CONFIG['points_register']);\r
-       define('P_REF_VALUE', $CONFIG['points_ref']);\r
-\r
-       // Load templates\r
-       LOAD_TEMPLATE("admin_config_sub_points");\r
-}\r
- else\r
-{\r
-       // Display selection box\r
-       LOAD_TEMPLATE("admin_config_points");\r
-}\r
-\r
-CLOSE_TABLE();\r
-//\r
-?>\r
+<?php
+/************************************************************************
+ * MXChange v0.2.1                                    Start: 10/12/2003 *
+ * ===============                              Last change: 12/12/2004 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : what-config_points.php                           *
+ * -------------------------------------------------------------------- *
+ * Short description : Setup welcome-points for registration etc.       *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Einstellen der Willkommensgutschrift usw.        *
+ * -------------------------------------------------------------------- *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * 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);
+}
+
+global $link;
+
+// Add description as navigation point
+ADD_DESCR("admin", basename(__FILE__));
+
+OPEN_TABLE("100%", "admin_content admin_content_align", "");
+if (!empty($_GET['sub']))
+{
+       switch ($_GET['sub'])
+       {
+       case "points":
+               if ((empty($_POST['points_register'])) || (empty($_POST['points_ref'])))
+               {
+                       unset($_POST['ok']);
+               }
+               break;
+
+       case "ref":
+               if (isset($_GET['do']))
+               {
+                       if (((empty($_POST['lvl'])) || (empty($_POST['perc']))) && ($_GET['do'] == "add"))
+                       {
+                               unset($_POST['ok']);
+                       }
+               }
+               break;
+       }
+}
+ else
+{
+       // Display overview
+       $_GET['sub'] = "overview";
+}
+
+if (isset($_POST['ok']))
+{
+       $SQL = array();
+       switch ($_GET['sub'])
+       {
+       case "points":
+               $SQL[] = "UPDATE "._MYSQL_PREFIX."_config SET points_register='".$_POST['points_register']."', points_ref='".$_POST['points_ref']."' WHERE config='0' LIMIT 1";
+               break;
+
+       case "ref":
+               switch ($_GET['do'])
+               {
+               case "add":
+                       $SQL[] = "INSERT INTO "._MYSQL_PREFIX."_refdepths (level, percents) VALUES ('".$_POST['lvl']."', '".$_POST['perc']."')";
+                       break;
+
+               case "edit": // Change entries
+                       foreach ($_POST['lvl'] as $id=>$value)
+                       {
+                               // Secure ID
+                               $id = bigintval($id);
+
+                               // Update entry
+                               $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_refdepths SET level='%s', percents='%s' WHERE id=%d LIMIT 1",
+                                array(bigintval($value), $_POST['perc'][$id], $id), __FILE__, __LINE__);
+                       }
+                       $TEXT = REF_DEPTHS_SAVED;
+                       break;
+
+               case "del":
+                       foreach ($_POST['id'] as $id=>$value)
+                       {
+                               $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_refdepths WHERE id=%d LIMIT 1",
+                                array(bigintval($id)), __FILE__, __LINE__);
+                       }
+                       $TEXT = REF_DEPTHS_DELETED;
+                       break;
+               }
+
+               // Update cache file
+               if (GET_EXT_VERSION("cache") >= "0.1.2")
+               {
+                       if ($CACHE->cache_file("refdepths", true)) $CACHE->cache_destroy();
+               }
+               break;
+
+       case "settings":
+               $REF = bigintval($_POST['ref_payout']);
+               $SQL[] = sprintf("UPDATE "._MYSQL_PREFIX."_config SET
+allow_direct_pay='%s',
+reg_points_mode='%s',
+ref_payout='%d'
+WHERE config='0' LIMIT 1",
+ $_POST['allow_direct_pay'],
+ $_POST['refmode'],
+ $REF
+               );
+               if (($CONFIG['ref_payout'] == 0) && ($_POST['ref_payout'] > 0))
+               {
+                       // Update account's ref_payout for "must-confirm"
+                       $SQL[] = sprintf("UPDATE "._MYSQL_PREFIX."_user_data SET ref_payout=(%d - mails_confirmed)
+WHERE mails_confirmed < %d", $REF, $REF);
+               }
+                elseif (($CONFIG['ref_payout'] > 0) && ($_POST['ref_payout'] == 0))
+               {
+                       // Update account's ref_payout for "not-must-confirm"
+                       $SQL[] = "UPDATE "._MYSQL_PREFIX."_user_data SET ref_payout=0 WHERE ref_payout > 0";
+                       $SQL[] = "UPDATE "._MYSQL_PREFIX."_user_points SET points=points+locked_points WHERE locked_points>0";
+                       $SQL[] = "UPDATE "._MYSQL_PREFIX."_user_points SET locked_points=0 WHERE locked_points>0";
+               }
+               break;
+       }
+       if ((isset($SQL)) && (is_array($SQL)) && (!empty($SQL[0])))
+       {
+               if (strpos($SQL[0], "INSERT") > -1)
+               {
+                       $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_refdepths WHERE level='%s' LIMIT 1",
+                        array(bigintval($_POST['lvl'])), __FILE__, __LINE__);
+                       SQL_FREERESULT($result);
+               }
+               if (count($SQL) > 0)
+               {
+                       // Run all SQL commands
+                       foreach ($SQL as $s)
+                       {
+                               $result = SQL_QUERY($s, __FILE__, __LINE__);
+                       }
+
+                       $content = "<SPAN class=\"admin_done\">".SETTINGS_SAVED."</SPAN>";
+
+                       // Destroy config cache file here...
+                       if (GET_EXT_VERSION("cache") >= "0.1.2")
+                       {
+                               if ($CACHE->cache_file("config", true)) $CACHE->cache_destroy();
+                               unset($CFG_CACHE);
+                       }
+               }
+                else
+               {
+                       $content = "<SPAN class=\"admin_failed\">".SETTINGS_NOT_SAVED."</SPAN>";
+               }
+               unset($SQL);
+               LOAD_TEMPLATE("admin_settings_saved", false, $content);
+       }
+        elseif (isset($TEXT))
+       {
+               LOAD_TEMPLATE("admin_settings_saved", false, $TEXT);
+       }
+}
+ elseif ($_GET['sub'] == "settings")
+{
+       // Setup some settings like direct pay and so on
+       // Including new add-mode for one-time referral bonus
+       switch ($CONFIG['allow_direct_pay'])
+       {
+       case "Y":
+               define('__DIRECT_Y', " checked");
+               define('__DIRECT_N', "");
+               break;
+
+       case "N":
+               define('__DIRECT_Y', "");
+               define('__DIRECT_N', " checked");
+               break;
+       }
+
+       // One-time referral bonus add-mode
+       switch ($CONFIG['reg_points_mode'])
+       {
+               case "ref"   : define('__MODE_REF', " checked"); define('__MODE_DIRECT', "");         break;
+               case "direct": define('__MODE_REF', "");         define('__MODE_DIRECT', " checked"); break;
+       }
+
+       // Referral payout value
+       define('__REF_PAYOUT', round($CONFIG['ref_payout']));
+
+       // Load template
+       LOAD_TEMPLATE("admin_config_point_settings");
+}
+ elseif ($_GET['sub'] == "ref")
+{
+        if ((isset($_POST['del'])) && ((SELECTION_COUNT($_POST['sel']) > 0) || (isset($_POST['sel'][0]))))
+       {
+               // Delete entries
+               $SW = 2; $OUT = "";
+               foreach ($_POST['sel'] as $id=>$value)
+               {
+                       $result = SQL_QUERY_ESC("SELECT level, percents FROM "._MYSQL_PREFIX."_refdepths WHERE id=%d LIMIT 1",
+                        array(bigintval($id)), __FILE__, __LINE__);
+                       list($lvl, $perc) = SQL_FETCHROW($result);
+                       SQL_FREERESULT($result);
+
+                       // Prepare data for the row template
+                       $content = array(
+                               'sw'  => $SW,
+                               'id'  => $id,
+                               'lvl' => $lvl,
+                               'per' => $perc,
+                       );
+
+                       // Load row template and switch color
+                       $OUT .= LOAD_TEMPLATE("admin_points_del_row", true, $content);
+                       $SW = 3 - $SW;
+               }
+               define('__LEVEL_ROWS', $OUT);
+
+               // Load main template
+               LOAD_TEMPLATE("admin_points_del");
+       }
+        elseif ((isset($_POST['edit'])) && ((SELECTION_COUNT($_POST['sel']) > 0) || (isset($_POST['sel'][0]))))
+       {
+               // Edit entries
+               $SW = 2; $OUT = "";
+               foreach ($_POST['sel'] as $id=>$value)
+               {
+                       $result = SQL_QUERY_ESC("SELECT level, percents FROM "._MYSQL_PREFIX."_refdepths WHERE id=%d LIMIT 1",
+                        array(bigintval($id)), __FILE__, __LINE__);
+                       list($lvl, $perc) = SQL_FETCHROW($result);
+                       SQL_FREERESULT($result);
+
+                       // Prepare data for the row template
+                       $content = array(
+                               'sw'  => $SW,
+                               'id'  => $id,
+                               'lvl' => $lvl,
+                               'per' => $perc,
+                       );
+
+                       // Load row template and switch color
+                       $OUT .= LOAD_TEMPLATE("admin_points_edit_row", true, $content);
+                       $SW = 3 - $SW;
+               }
+               define('__LEVEL_ROWS', $OUT);
+
+               // Load main template
+               LOAD_TEMPLATE("admin_points_edit");
+       }
+        else
+       {
+               // Referral levels
+               $result = SQL_QUERY("SELECT id, level, percents FROM "._MYSQL_PREFIX."_refdepths ORDER BY level", __FILE__, __LINE__);
+               if (SQL_NUMROWS($result) > 0)
+               {
+                       // Make referral levels editable and deletable
+                       $SW = 2; $OUT = "";
+
+                       // List already existing categories for editing
+                       while (list($id, $lvl, $perc) = SQL_FETCHROW($result))
+                       {
+                               // Prepare data for the row template
+                               $content = array(
+                                       'sw'  => $SW,
+                                       'id'  => $id,
+                                       'lvl' => $lvl,
+                                       'per' => $perc,
+                               );
+
+                               // Load row template and switch color
+                               $OUT .= LOAD_TEMPLATE("admin_points_row", true, $content);
+                               $SW = 3 - $SW;
+                       }
+
+                       // Free memory
+                       SQL_FREERESULT($result);
+                       define('__LEVEL_ROWS', $OUT);
+
+                       // Load main template
+                       LOAD_TEMPLATE("admin_points");
+               }
+
+               // Form for adding new referral levels
+               LOAD_TEMPLATE("admin_add_reflvl");
+       }
+}
+ elseif ($_GET['sub'] == "points")
+{
+       // First points for registration and other fixed points including new add-mode for one-time referral bonus...
+       define('P_REG_VALUE', $CONFIG['points_register']);
+       define('P_REF_VALUE', $CONFIG['points_ref']);
+
+       // Load templates
+       LOAD_TEMPLATE("admin_config_sub_points");
+}
+ else
+{
+       // Display selection box
+       LOAD_TEMPLATE("admin_config_points");
+}
+
+CLOSE_TABLE();
+//
+?>