X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fguest%2Fwhat-sponsor_infos.php;h=2539e16300381cc65e277c1f90a87f51b06e4418;hp=a47c9567da87068fa177ba7419fc600c3c141950;hb=4001187f22197f55e5a1f211fc8defcc180f7c32;hpb=82d53dfb7f59fa1e37bd500e3db3d10a9d4a78da diff --git a/inc/modules/guest/what-sponsor_infos.php b/inc/modules/guest/what-sponsor_infos.php index a47c9567da..2539e16300 100644 --- a/inc/modules/guest/what-sponsor_infos.php +++ b/inc/modules/guest/what-sponsor_infos.php @@ -31,104 +31,90 @@ ************************************************************************/ // Some security stuff... -if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) -{ +if (!defined('__SECURITY')) { $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php"; require($INC); +} elseif ((!EXT_IS_ACTIVE("sponsor"))) { + addFatalMessage(__FILE__, __LINE__, getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), "sponsor"); + return; } // Add description as navigation point -ADD_DESCR("guest", basename(__FILE__)); +ADD_DESCR("guest", __FILE__); -// Remove result_act -unset($result_act); +// Init both results (see footer of this file) +$result_act = false; +$result_pay = false; // Load all sponsor actions $result_act = SQL_QUERY("SELECT DISTINCT m.title, c.conv_rate, c.conv_name -FROM "._MYSQL_PREFIX."_sponsor_menu AS m -LEFT JOIN "._MYSQL_PREFIX."_sponsor_action_convert AS c ON m.what=c.ext_name -LEFT JOIN "._MYSQL_PREFIX."_sponsor_registry AS r ON m.what=r.ext_name +FROM `{!_MYSQL_PREFIX!}_sponsor_menu` AS m +LEFT JOIN `{!_MYSQL_PREFIX!}_sponsor_action_convert` AS c ON m.what=c.ext_name +LEFT JOIN `{!_MYSQL_PREFIX!}_sponsor_registry` AS r ON m.what=r.ext_name WHERE m.action='actions' AND r.is_active='Y' ORDER BY m.sort ASC", __FILE__, __LINE__); -$num_act = SQL_NUMROWS($result_act); -if ($num_act > 0) -{ +if (SQL_NUMROWS($result_act) > 0) { // Load all actions $OUT_ACT = ""; $SW = 2; - while (list($title, $conv, $name) = SQL_FETCHROW($result_act)) - { + while ($content = SQL_FETCHARRAY($result_act)) { // Prepare data for the row template + // @TODO Rewritings: conv->conv_rate,name->conv_name in template $content = array( 'sw' => $SW, - 'title' => $title, - 'conv' => round($conv), - 'name' => $name, + 'title' => $content['title'], + 'conv' => round($content['conv_rate']), + 'name' => $content['conv_name'], ); // Load row template and switch color $OUT_ACT .= LOAD_TEMPLATE("guest_sponsor_act_row", true, $content); $SW = 3 - $SW; - } + } // END - while // Check for pay types - $result_pay = SQL_QUERY("SELECT pay_name, pay_rate, pay_min_count, pay_currency FROM "._MYSQL_PREFIX."_sponsor_paytypes ORDER BY pay_name", __FILE__, __LINE__); - if (SQL_NUMROWS($result_pay) > 0) - { + $result_pay = SQL_QUERY("SELECT pay_name, pay_rate, pay_min_count, pay_currency FROM `{!_MYSQL_PREFIX!}_sponsor_paytypes` ORDER BY pay_name", __FILE__, __LINE__); + if (SQL_NUMROWS($result_pay) > 0) { // Load all pay types $OUT_PAY = ""; $SW = 2; - while (list($name, $rate, $min, $curr) = SQL_FETCHROW($result_pay)) - { + while ($content = SQL_FETCHARRAY($result_pay)) { // Prepare data for the row template + // @TODO Rewritings: name->pay_name,min->pay_min_count,min->pay_min_count,curr->pay_currency $content = array( 'sw' => $SW, - 'name' => $name, - 'rate' => TRANSLATE_COMMA($rate), - 'min' => $min, - 'curr' => $curr, - 'price' => $min, + 'name' => $content['pay_name'], + 'rate' => TRANSLATE_COMMA($content['pay_rate']), + 'min' => $content['pay_min_count'], + 'curr' => $content['pay_currency'], + 'price' => TRANSLATE_COMMA($content['pay_min_count']), ); - if (!ereg(",", $content['price'])) - { - // Add missing zeros - $content['price'] .= ",".str_repeat("0", $_CONFIG['max_comma']); - } - // Load row template and switch color $OUT_PAY .= LOAD_TEMPLATE("guest_sponsor_pay_row", true, $content); $SW = 3 - $SW; } - } - else - { + } else { // No pay types setuped so far! - $OUT_PAY = " - ".LOAD_TEMPLATE("admin_settings_saved", true, SPONSOR_NO_ACTIONS_ACTIVATED)." -"; + $OUT_PAY = LOAD_TEMPLATE("guest_sponsor_infos_none_row", LOAD_TEMPLATE("admin_settings_saved", true, getMessage('SPONSOR_NO_ACTIONS_ACTIVATED'))); } -} - else -{ +} else { // No actions activated so far! - $OUT_ACT = " - ".LOAD_TEMPLATE("admin_settings_saved", true, SPONSOR_NO_ACTIONS_ACTIVATED)." -"; - $OUT_PAY = " - ".LOAD_TEMPLATE("admin_settings_saved", true, SPONSOR_NO_ACTIONS_ACTIVATED)." -"; + $OUT_ACT = LOAD_TEMPLATE("guest_sponsor_infos_none_row", LOAD_TEMPLATE("admin_settings_saved", true, getMessage('SPONSOR_NO_ACTIONS_ACTIVATED'))); + $OUT_PAY = LOAD_TEMPLATE("guest_sponsor_infos_none_row", LOAD_TEMPLATE("admin_settings_saved", true, getMessage('SPONSOR_NO_ACTIONS_ACTIVATED'))); } -// Transfer rows to constans -define('__SPONSOR_ACTIONS' , $OUT_ACT); -define('__SPONSOR_PAYTYPES', $OUT_PAY); - // Free memory -if (isset($result_act)) SQL_FREERESULT($result_act); -if (isset($result_pay)) SQL_FREERESULT($result_pay); +SQL_FREERESULT($result_act); +SQL_FREERESULT($result_pay); + +// Transfer rows to an array +$content = array( + 'actions' => $OUT_ACT, + 'paytypes' => $OUT_PAY +); // Load main template -LOAD_TEMPLATE("guest_sponsor_infos"); +LOAD_TEMPLATE("guest_sponsor_infos", false, $content); // ?>