Refback will be payed now (user cannot setup currently)
[mailer.git] / inc / modules / admin / what-config_points.php
index 1f028aa..7241b97 100644 (file)
  ************************************************************************/
 
 // 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);
 }
 
-global $link;
-
 // Add description as navigation point
 ADD_DESCR("admin", basename(__FILE__));
 
-OPEN_TABLE("100%", "admin_content admin_content_align", "");
-if (!empty($_GET['sub']))
-{
+if (!empty($_GET['sub'])) {
        switch ($_GET['sub'])
        {
        case "points":
-               if ((empty($_POST['points_register'])) || (empty($_POST['points_ref'])))
-               {
+               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"))
-                       {
+               if (isset($_GET['do'])) {
+                       if (((empty($_POST['lvl'])) || (empty($_POST['perc']))) && ($_GET['do'] == "add")) {
                                unset($_POST['ok']);
                        }
                }
                break;
        }
-}
- else
-{
+} else {
        // Display overview
        $_GET['sub'] = "overview";
 }
 
-if (isset($_POST['ok']))
-{
+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";
+               $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']."')";
+                       $SQL[] = "INSERT INTO "._MYSQL_PREFIX."_refdepths (level, percents) VALUES ('".$_POST['lvl']."','".$_POST['perc']."')";
                        break;
 
                case "edit": // Change entries
-                       foreach ($_POST['lvl'] as $id=>$value)
-                       {
+                       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",
+                               $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_refdepths SET level=%s, percents='%s' WHERE id=%s 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",
+                       foreach ($_POST['id'] as $id => $value) {
+                               $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_refdepths WHERE id=%s LIMIT 1",
                                 array(bigintval($id)), __FILE__, __LINE__);
                        }
                        $TEXT = REF_DEPTHS_DELETED;
@@ -112,9 +99,8 @@ if (isset($_POST['ok']))
                }
 
                // Update cache file
-               if (GET_EXT_VERSION("cache") >= "0.1.2")
-               {
-                       if ($CACHE->cache_file("refdepths", true)) $CACHE->cache_destroy();
+               if (GET_EXT_VERSION("cache") >= "0.1.2") {
+                       if ($cacheInstance->cache_file("refdepths", true)) $cacheInstance->cache_destroy();
                }
                break;
 
@@ -123,19 +109,19 @@ if (isset($_POST['ok']))
                $SQL[] = sprintf("UPDATE "._MYSQL_PREFIX."_config SET
 allow_direct_pay='%s',
 reg_points_mode='%s',
-ref_payout='%d'
-WHERE config='0' LIMIT 1",
+ref_payout='%s'
+WHERE config=0 LIMIT 1",
  $_POST['allow_direct_pay'],
- $_POST['refmode'],
+ $_POST['reg_points_mode'],
  $REF
                );
-               if (($CONFIG['ref_payout'] == 0) && ($_POST['ref_payout'] > 0))
+               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);
+                       $SQL[] = sprintf("UPDATE "._MYSQL_PREFIX."_user_data SET ref_payout=(%s - mails_confirmed)
+WHERE mails_confirmed < %s", $REF, $REF);
                }
-                elseif (($CONFIG['ref_payout'] > 0) && ($_POST['ref_payout'] == 0))
+                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";
@@ -148,7 +134,7 @@ WHERE mails_confirmed < %d", $REF, $REF);
        {
                if (strpos($SQL[0], "INSERT") > -1)
                {
-                       $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_refdepths WHERE level='%s' LIMIT 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);
                }
@@ -163,11 +149,7 @@ WHERE mails_confirmed < %d", $REF, $REF);
                        $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);
-                       }
+                       REBUILD_CACHE("config", "config");
                }
                 else
                {
@@ -185,7 +167,7 @@ WHERE mails_confirmed < %d", $REF, $REF);
 {
        // Setup some settings like direct pay and so on
        // Including new add-mode for one-time referral bonus
-       switch ($CONFIG['allow_direct_pay'])
+       switch ($_CONFIG['allow_direct_pay'])
        {
        case 'Y':
                define('__DIRECT_Y', " checked");
@@ -199,14 +181,14 @@ WHERE mails_confirmed < %d", $REF, $REF);
        }
 
        // One-time referral bonus add-mode
-       switch ($CONFIG['reg_points_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']));
+       define('__REF_PAYOUT', round($_CONFIG['ref_payout']));
 
        // Load template
        LOAD_TEMPLATE("admin_config_point_settings");
@@ -217,9 +199,9 @@ WHERE mails_confirmed < %d", $REF, $REF);
        {
                // Delete entries
                $SW = 2; $OUT = "";
-               foreach ($_POST['sel'] as $id=>$value)
+               foreach ($_POST['sel'] as $id => $value)
                {
-                       $result = SQL_QUERY_ESC("SELECT level, percents FROM "._MYSQL_PREFIX."_refdepths WHERE id=%d LIMIT 1",
+                       $result = SQL_QUERY_ESC("SELECT level, percents FROM "._MYSQL_PREFIX."_refdepths WHERE id=%s LIMIT 1",
                         array(bigintval($id)), __FILE__, __LINE__);
                        list($lvl, $perc) = SQL_FETCHROW($result);
                        SQL_FREERESULT($result);
@@ -245,9 +227,9 @@ WHERE mails_confirmed < %d", $REF, $REF);
        {
                // Edit entries
                $SW = 2; $OUT = "";
-               foreach ($_POST['sel'] as $id=>$value)
+               foreach ($_POST['sel'] as $id => $value)
                {
-                       $result = SQL_QUERY_ESC("SELECT level, percents FROM "._MYSQL_PREFIX."_refdepths WHERE id=%d LIMIT 1",
+                       $result = SQL_QUERY_ESC("SELECT level, percents FROM "._MYSQL_PREFIX."_refdepths WHERE id=%s LIMIT 1",
                         array(bigintval($id)), __FILE__, __LINE__);
                        list($lvl, $perc) = SQL_FETCHROW($result);
                        SQL_FREERESULT($result);
@@ -309,8 +291,8 @@ WHERE mails_confirmed < %d", $REF, $REF);
  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']);
+       define('P_REG_VALUE', $_CONFIG['points_register']);
+       define('P_REF_VALUE', $_CONFIG['points_ref']);
 
        // Load templates
        LOAD_TEMPLATE("admin_config_sub_points");
@@ -321,6 +303,5 @@ WHERE mails_confirmed < %d", $REF, $REF);
        LOAD_TEMPLATE("admin_config_points");
 }
 
-CLOSE_TABLE();
 //
 ?>