X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=inc%2Fmodules%2Fadmin%2Fwhat-config_points.php;h=6cfa96aa661d939c3a5ec9652c770b982cab2986;hb=ccc4a69ce9b17aa8d7b1554a3b2b017db091821b;hp=f6fa31bbfa8ec9f7bf1e45c1b6387c47b5fa9926;hpb=a090e351c49fe021fb3064325694da03402332e0;p=mailer.git diff --git a/inc/modules/admin/what-config_points.php b/inc/modules/admin/what-config_points.php index f6fa31bbfa..6cfa96aa66 100644 --- a/inc/modules/admin/what-config_points.php +++ b/inc/modules/admin/what-config_points.php @@ -38,7 +38,7 @@ // Some security stuff... if ((!defined('__SECURITY')) || (!IS_ADMIN())) { - $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php"; + $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php'; require($INC); } @@ -53,98 +53,98 @@ if (REQUEST_ISSET_GET('sub')) { // Yes, then do some sanity-checks switch (REQUEST_GET('sub')) { - case "points": - if ((!REQUEST_ISSET_POST(('points_register'))) || (!REQUEST_ISSET_POST(('points_ref')))) { - REQUEST_UNSET_POST('ok'); - } - break; - - case "ref": - if (REQUEST_ISSET_GET('do')) { - if (((!REQUEST_ISSET_POST(('lvl'))) || (!REQUEST_ISSET_POST(('perc')))) && (REQUEST_GET('do') == 'add')) { + case "points": + if ((!REQUEST_ISSET_POST(('points_register'))) || (!REQUEST_ISSET_POST(('points_ref')))) { REQUEST_UNSET_POST('ok'); } - } - break; + break; + + case "ref": + if (REQUEST_ISSET_GET('do')) { + if (((!REQUEST_ISSET_POST(('lvl'))) || (!REQUEST_ISSET_POST(('perc')))) && (REQUEST_GET('do') == 'add')) { + REQUEST_UNSET_POST('ok'); + } + } + break; } } else { // Display overview REQUEST_SET_GET('sub', "overview"); } -if (IS_FORM_SENT()) { +if (isFormSent()) { INIT_SQLS(); switch (REQUEST_GET('sub')) { - case "points": - ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_config` SET points_register='".REQUEST_POST('points_register')."', points_ref='".REQUEST_POST('points_ref')."' WHERE config=0 LIMIT 1"); - break; - - case "ref": - switch (REQUEST_GET('do')) - { - case 'add': - ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_refdepths` (level, percents) VALUES ('".REQUEST_POST('lvl')."','".REQUEST_POST('perc')."')"); + case "points": + ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_config` SET points_register='".REQUEST_POST('points_register')."', points_ref='".REQUEST_POST('points_ref')."' WHERE config=0 LIMIT 1"); break; - case "edit": // Change entries - foreach (REQUEST_POST('lvl') as $id => $value) { - // Secure ID - $id = bigintval($id); - - // Revert german commata - REQUEST_SET_POST(array('perc', $id), REVERT_COMMA(REQUEST_POST('perc', $id))); - - // Update entry - SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_refdepths` SET level='%s', percents='%s' WHERE id=%s LIMIT 1", - array(bigintval($value), REQUEST_POST('perc', $id), $id), __FILE__, __LINE__); + case "ref": + switch (REQUEST_GET('do')) + { + case 'add': + ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_refdepths` (level, percents) VALUES ('".REQUEST_POST('lvl')."','".REQUEST_POST('perc')."')"); + break; + + case 'edit': // Change entries + foreach (REQUEST_POST('lvl') as $id => $value) { + // Secure ID + $id = bigintval($id); + + // Revert german commata + REQUEST_SET_POST(array('perc', $id), convertCommaToDot(REQUEST_POST('perc', $id))); + + // Update entry + SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_refdepths` SET level='%s', percents='%s' WHERE `id`=%s LIMIT 1", + array(bigintval($value), REQUEST_POST('perc', $id), $id), __FILE__, __LINE__); + } + $message = getMessage('REF_DEPTHS_SAVED'); + break; + + case 'del': + foreach (REQUEST_POST('id') as $id => $value) { + SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_refdepths` WHERE `id`=%s LIMIT 1", + array(bigintval($id)), __FILE__, __LINE__); + } + $message = getMessage('REF_DEPTHS_DELETED'); + break; } - $message = getMessage('REF_DEPTHS_SAVED'); - break; - case "del": - foreach (REQUEST_POST('id') as $id => $value) { - SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_refdepths` WHERE id=%s LIMIT 1", - array(bigintval($id)), __FILE__, __LINE__); + // Update cache file + if (GET_EXT_VERSION('cache') >= '0.1.2') { + if ($GLOBALS['cache_instance']->loadCacheFile("refdepths")) $GLOBALS['cache_instance']->destroyCacheFile(); } - $message = getMessage('REF_DEPTHS_DELETED'); break; - } - - // Update cache file - if (GET_EXT_VERSION('cache') >= '0.1.2') { - if ($GLOBALS['cache_instance']->loadCacheFile("refdepths")) $GLOBALS['cache_instance']->destroyCacheFile(); - } - break; - case "settings": - $REF = bigintval(REQUEST_POST('ref_payout')); - ADD_SQL(sprintf("UPDATE `{!_MYSQL_PREFIX!}_config` SET + case "settings": + $REF = bigintval(REQUEST_POST('ref_payout')); + ADD_SQL(sprintf("UPDATE `{!_MYSQL_PREFIX!}_config` SET allow_direct_pay='%s', reg_points_mode='%s', ref_payout='%s' WHERE config=0 LIMIT 1", - REQUEST_POST('allow_direct_pay'), - REQUEST_POST('reg_points_mode'), - $REF - )); - if ((getConfig('ref_payout') == 0) && (REQUEST_POST('ref_payout') > 0)) { - // Update account's ref_payout for "must-confirm" - ADD_SQL(sprintf("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET ref_payout=(%s - mails_confirmed) + REQUEST_POST('allow_direct_pay'), + REQUEST_POST('reg_points_mode'), + $REF + )); + if ((getConfig('ref_payout') == 0) && (REQUEST_POST('ref_payout') > 0)) { + // Update account's ref_payout for "must-confirm" + ADD_SQL(sprintf("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET ref_payout=(%s - mails_confirmed) WHERE mails_confirmed < %s", $REF, $REF)); - } elseif ((getConfig('ref_payout') > 0) && (REQUEST_POST('ref_payout') == 0)) { - // Update account's ref_payout for "not-must-confirm" - ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET ref_payout=0 WHERE ref_payout > 0"); - ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_user_points` SET points=points+locked_points WHERE locked_points>0"); - ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_user_points` SET locked_points=0 WHERE locked_points>0"); - } - break; + } elseif ((getConfig('ref_payout') > 0) && (REQUEST_POST('ref_payout') == 0)) { + // Update account's ref_payout for "not-must-confirm" + ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET ref_payout=0 WHERE ref_payout > 0"); + ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_user_points` SET points=points+locked_points WHERE locked_points>0"); + ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_user_points` SET locked_points=0 WHERE locked_points>0"); + } + break; } if ((IS_SQLS_VALID()) && (IS_SQLS_VALID())) { if (strpos($GLOBALS['sqls'][0], "INSERT") > -1) { - $result = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_refdepths` WHERE level='%s' LIMIT 1", - array(bigintval(REQUEST_POST('lvl'))), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_refdepths` WHERE level='%s' LIMIT 1", + array(bigintval(REQUEST_POST('lvl'))), __FILE__, __LINE__); SQL_FREERESULT($result); } // END - if @@ -175,21 +175,28 @@ WHERE mails_confirmed < %s", $REF, $REF)); // Setup some settings like direct pay and so on // Including new add-mode for one-time referal bonus switch (getConfig('allow_direct_pay')) { - case 'Y': - define('__DIRECT_Y', ' chkecked="checked"'); - define('__DIRECT_N', ''); - break; - - case 'N': - define('__DIRECT_Y', ''); - define('__DIRECT_N', ' chkecked="checked"'); - break; + case 'Y': + define('__DIRECT_Y', ' checked="checked"'); + define('__DIRECT_N', ''); + break; + + case 'N': + define('__DIRECT_Y', ''); + define('__DIRECT_N', ' checked="checked"'); + break; } // One-time referal bonus add-mode switch (getConfig('reg_points_mode')) { - case "ref" : define('__MODE_REF', ' chkecked="checked"'); define('__MODE_DIRECT', ''); break; - case "direct": define('__MODE_REF', ''); define('__MODE_DIRECT', ' chkecked="checked"'); break; + case 'ref' : + define('__MODE_REF', ' checked="checked"'); + define('__MODE_DIRECT', ''); + break; + + case 'direct': + define('__MODE_REF', ''); + define('__MODE_DIRECT', ' checked="checked"'); + break; } // Referal payout value @@ -199,12 +206,12 @@ WHERE mails_confirmed < %s", $REF, $REF)); LOAD_TEMPLATE("admin_config_point_settings"); } elseif (REQUEST_GET('sub') == "ref") { // 12 3 32 2 3 32 2 3 4 43 21 - if ((REQUEST_ISSET_POST('del')) && (REQUEST_ISSET_POST('sel')) && (SELECTION_COUNT(REQUEST_POST('sel')) > 0)) { + if ((REQUEST_ISSET_POST('del')) && (REQUEST_ISSET_POST('sel')) && (countPostSelection() > 0)) { // Delete entries $OUT = ''; $SW = 2; foreach (REQUEST_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__); + $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); @@ -213,7 +220,7 @@ WHERE mails_confirmed < %s", $REF, $REF)); 'sw' => $SW, 'id' => $id, 'lvl' => $lvl, - 'per' => TRANSLATE_COMMA($perc), + 'per' => translateComma($perc), ); // Load row template and switch color @@ -224,12 +231,12 @@ WHERE mails_confirmed < %s", $REF, $REF)); // Load main template LOAD_TEMPLATE("admin_points_del"); - } elseif ((REQUEST_ISSET_POST('edit')) && (REQUEST_ISSET_POST('sel')) && (SELECTION_COUNT(REQUEST_POST('sel')) > 0)) { + } elseif ((REQUEST_ISSET_POST('edit')) && (REQUEST_ISSET_POST('sel')) && (countPostSelection() > 0)) { // Edit entries $OUT = ''; $SW = 2; foreach (REQUEST_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__); + $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); @@ -238,7 +245,7 @@ WHERE mails_confirmed < %s", $REF, $REF)); 'sw' => $SW, 'id' => $id, 'lvl' => $lvl, - 'per' => TRANSLATE_COMMA($perc), + 'per' => translateComma($perc), ); // Load row template and switch color @@ -264,7 +271,7 @@ WHERE mails_confirmed < %s", $REF, $REF)); 'sw' => $SW, 'id' => $content['id'], 'lvl' => $content['level'], - 'per' => TRANSLATE_COMMA($content['percents']), + 'per' => translateComma($content['percents']), ); // Load row template and switch color