// Add description as navigation point
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":
switch ($_GET['sub'])
{
case "points":
- $SQLs[] = "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":
- $SQLs[] = "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
$_POST['perc'][$id] = REVERT_COMMA($_POST['perc'][$id]);
// Update entry
- SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_refdepths SET level='%s', percents='%s' WHERE id=%s LIMIT 1",
+ 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) {
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_refdepths WHERE id=%s LIMIT 1",
+ 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;
}
case "settings":
$REF = bigintval($_POST['ref_payout']);
- $SQLs[] = 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 ((getConfig('ref_payout') == 0) && ($_POST['ref_payout'] > 0))
- {
+ if ((getConfig('ref_payout') == 0) && ($_POST['ref_payout'] > 0)) {
// Update account's ref_payout for "must-confirm"
- $SQLs[] = 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 ((getConfig('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"
- $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";
+ $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($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",
+ 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);
- }
+ } // END - if
+
if (count($SQLs) > 0) {
// Run all SQL commands
RUN_FILTER('run_sqls', array('dry_run' => false, 'sqls' => $SQLs));
- $content = "<SPAN class=\"admin_done\">".SETTINGS_SAVED."</SPAN>";
+ // Entry saved...
+ $message = SETTINGS_SAVED;
// Destroy config cache file here...
REBUILD_CACHE("config", "config");
} else {
- $content = "<SPAN class=\"admin_failed\">".SETTINGS_NOT_SAVED."</SPAN>";
+ // Prepare failed-message
+ $message = "<span class=\"admin_failed\">{--SETTINGS_NOT_SAVED--}</span>";
}
+
+ // Remove SQL queries
unset($SQLs);
- LOAD_TEMPLATE("admin_settings_saved", false, $content);
- } 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") {
// Setup some settings like direct pay and so on
// 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",
+ $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);
// 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",
+ $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);
LOAD_TEMPLATE("admin_points_edit");
} else {
// Referal levels
- $result = SQL_QUERY("SELECT id, level, percents FROM "._MYSQL_PREFIX."_refdepths ORDER BY level", __FILE__, __LINE__);
+ $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 = "";