X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=inc%2Fmodules%2Fadmin%2Fwhat-config_points.php;h=07698bc9c0a5f08f572e2c88d9494f35f825aa02;hb=ab92fb7241d00636b0eb940f147449758820cba1;hp=d5a7b23b927889e9c53a44f2d15a69cf82e27fd2;hpb=dbe56bb043ba16ca1ec1e9efa9effdc1f0612261;p=mailer.git
diff --git a/inc/modules/admin/what-config_points.php b/inc/modules/admin/what-config_points.php
index d5a7b23b92..07698bc9c0 100644
--- a/inc/modules/admin/what-config_points.php
+++ b/inc/modules/admin/what-config_points.php
@@ -38,9 +38,14 @@ if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
}
// Add description as navigation point
-ADD_DESCR("admin", basename(__FILE__));
+ADD_DESCR("admin", __FILE__);
+// Init variables
+$message = "";
+
+// Is the 'sub' parameter set?
if (!empty($_GET['sub'])) {
+ // Yes, then do some sanity-checks
switch ($_GET['sub'])
{
case "points":
@@ -63,18 +68,18 @@ if (!empty($_GET['sub'])) {
}
if (isset($_POST['ok'])) {
- $SQL = array();
+ $SQLs = 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";
+ $SQLs[] = "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']."')";
+ $SQLs[] = "INSERT INTO `{!_MYSQL_PREFIX!}_refdepths` (level, percents) VALUES ('".$_POST['lvl']."','".$_POST['perc']."')";
break;
case "edit": // Change entries
@@ -86,126 +91,114 @@ if (isset($_POST['ok'])) {
$_POST['perc'][$id] = REVERT_COMMA($_POST['perc'][$id]);
// Update entry
- $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__);
+ 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;
+ $message = 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=%s LIMIT 1",
- array(bigintval($id)), __FILE__, __LINE__);
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_refdepths` WHERE id=%s LIMIT 1",
+ array(bigintval($id)), __FILE__, __LINE__);
}
- $TEXT = REF_DEPTHS_DELETED;
+ $message = REF_DEPTHS_DELETED;
break;
}
// Update cache file
if (GET_EXT_VERSION("cache") >= "0.1.2") {
- if ($cacheInstance->cache_file("refdepths", true)) $cacheInstance->cache_destroy();
+ if ($cacheInstance->loadCacheFile("refdepths")) $cacheInstance->destroyCacheFile();
}
break;
case "settings":
$REF = bigintval($_POST['ref_payout']);
- $SQL[] = sprintf("UPDATE "._MYSQL_PREFIX."_config SET
+ $SQLs[] = sprintf("UPDATE `{!_MYSQL_PREFIX!}_config` SET
allow_direct_pay='%s',
reg_points_mode='%s',
ref_payout='%s'
WHERE config=0 LIMIT 1",
- $_POST['allow_direct_pay'],
- $_POST['reg_points_mode'],
- $REF
+ $_POST['allow_direct_pay'],
+ $_POST['reg_points_mode'],
+ $REF
);
- if (($_CONFIG['ref_payout'] == 0) && ($_POST['ref_payout'] > 0))
- {
+ if ((getConfig('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=(%s - mails_confirmed)
+ $SQLs[] = 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 ((getConfig('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";
+ $SQLs[] = "UPDATE `{!_MYSQL_PREFIX!}_user_data` SET ref_payout=0 WHERE ref_payout > 0";
+ $SQLs[] = "UPDATE `{!_MYSQL_PREFIX!}_user_points` SET points=points+locked_points WHERE locked_points>0";
+ $SQLs[] = "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__);
+
+ if ((isset($SQLs)) && (is_array($SQLs)) && (!empty($SQLs[0]))) {
+ if (strpos($SQLs[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)
- {
+ } // END - if
+
+ if (count($SQLs) > 0) {
// Run all SQL commands
- foreach ($SQL as $s)
- {
- $result = SQL_QUERY($s, __FILE__, __LINE__);
- }
+ RUN_FILTER('run_sqls', array('dry_run' => false, 'sqls' => $SQLs));
- $content = "".SETTINGS_SAVED."";
+ // Entry saved...
+ $message = SETTINGS_SAVED;
// Destroy config cache file here...
REBUILD_CACHE("config", "config");
+ } else {
+ // Prepare failed-message
+ $message = "".SETTINGS_NOT_SAVED."";
}
- else
- {
- $content = "".SETTINGS_NOT_SAVED."";
- }
- unset($SQL);
- LOAD_TEMPLATE("admin_settings_saved", false, $content);
+
+ // Remove SQL queries
+ unset($SQLs);
}
- elseif (isset($TEXT))
- {
- LOAD_TEMPLATE("admin_settings_saved", false, $TEXT);
+
+ // Shall we display a message?
+ if (!empty($message)) {
+ // When do so...
+ LOAD_TEMPLATE("admin_settings_saved", false, $message);
}
-}
- elseif ($_GET['sub'] == "settings")
-{
+} 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':
+ // Including new add-mode for one-time referal bonus
+ switch (getConfig('allow_direct_pay')) {
+ case "Y":
define('__DIRECT_Y', " checked=\"checked\"");
define('__DIRECT_N', "");
break;
- case 'N':
+ case "N":
define('__DIRECT_Y', "");
define('__DIRECT_N', " checked=\"checked\"");
break;
}
- // One-time referral bonus add-mode
- switch ($_CONFIG['reg_points_mode'])
- {
+ // One-time referal bonus add-mode
+ switch (getConfig('reg_points_mode')) {
case "ref" : define('__MODE_REF', " checked=\"checked\""); define('__MODE_DIRECT', ""); break;
case "direct": define('__MODE_REF', ""); define('__MODE_DIRECT', " checked=\"checked\""); break;
}
- // Referral payout value
- define('__REF_PAYOUT', round($_CONFIG['ref_payout']));
+ // Referal payout value
+ define('__REF_PAYOUT', round(getConfig('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]))))
- {
+} elseif ($_GET['sub'] == "ref") {
+ if ((isset($_POST['del'])) && (isset($_POST['sel'])) && ((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=%s LIMIT 1",
- array(bigintval($id)), __FILE__, __LINE__);
+ foreach ($_POST['sel'] as $id => $value) {
+ $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);
@@ -225,14 +218,11 @@ WHERE mails_confirmed < %s", $REF, $REF);
// Load main template
LOAD_TEMPLATE("admin_points_del");
- }
- elseif ((isset($_POST['edit'])) && ((SELECTION_COUNT($_POST['sel']) > 0) || (isset($_POST['sel'][0]))))
- {
+ } elseif ((isset($_POST['edit'])) && (isset($_POST['sel'])) && ((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=%s LIMIT 1",
+ foreach ($_POST['sel'] as $id => $value) {
+ $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);
@@ -253,19 +243,15 @@ WHERE mails_confirmed < %s", $REF, $REF);
// 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
+ } else {
+ // Referal levels
+ $result = SQL_QUERY("SELECT id, level, percents FROM `{!_MYSQL_PREFIX!}_refdepths` ORDER BY level", __FILE__, __LINE__);
+ if (SQL_NUMROWS($result) > 0) {
+ // Make referal levels editable and deletable
$SW = 2; $OUT = "";
// List already existing categories for editing
- while (list($id, $lvl, $perc) = SQL_FETCHROW($result))
- {
+ while (list($id, $lvl, $perc) = SQL_FETCHROW($result)) {
// Prepare data for the row template
$content = array(
'sw' => $SW,
@@ -287,21 +273,17 @@ WHERE mails_confirmed < %s", $REF, $REF);
LOAD_TEMPLATE("admin_points");
}
- // Form for adding new referral levels
+ // Form for adding new referal 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']);
+} elseif ($_GET['sub'] == "points") {
+ // First points for registration and other fixed points including new add-mode for one-time referal bonus...
+ define('P_REG_VALUE', getConfig('points_register'));
+ define('P_REF_VALUE', getConfig('points_ref'));
// Load templates
LOAD_TEMPLATE("admin_config_sub_points");
-}
- else
-{
+} else {
// Display selection box
LOAD_TEMPLATE("admin_config_points");
}