示例#1
0
 /**
  * Standard actualisation stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function action_done()
 {
     $class = str_replace('hook_pointstore_', '', strtolower(get_class($this)));
     if (get_option('is_on_' . $class . '_buy') == '0' || get_forum_type() != 'ocf') {
         return new ocp_tempcode();
     }
     if ($GLOBALS['FORUM_DRIVER']->get_member_row_field(get_member(), 'm_highlighted_name') == 1) {
         warn_exit(do_lang_tempcode('_ALREADY_HAVE'));
     }
     $title = get_page_title('NAME_HIGHLIGHTING');
     post_param_integer('confirm');
     // To make sure we're not being passed by a GET
     // Check points
     $cost = intval(get_option($class));
     $points_left = available_points(get_member());
     if ($points_left < $cost && !has_specific_permission(get_member(), 'give_points_self')) {
         return warn_screen($title, do_lang_tempcode('_CANT_AFFORD', integer_format($cost), integer_format($points_left)));
     }
     // Actuate
     $GLOBALS['FORUM_DB']->query_update('f_members', array('m_highlighted_name' => 1), array('id' => get_member()), '', 1);
     require_code('points2');
     charge_member(get_member(), $cost, do_lang('NAME_HIGHLIGHTING'));
     $GLOBALS['SITE_DB']->query_insert('sales', array('date_and_time' => time(), 'memberid' => get_member(), 'purchasetype' => 'NAME_HIGHLIGHTING', 'details' => '', 'details2' => ''));
     // Show message
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('ORDER_GENERAL_DONE'));
 }
示例#2
0
 /**
  * Standard actualisation stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function action_done()
 {
     $class = str_replace('hook_pointstore_', '', strtolower(get_class($this)));
     if (get_option('is_on_' . $class . '_buy') == '0') {
         return new ocp_tempcode();
     }
     $amount = post_param_integer('amount', -1);
     $title = get_page_title('GAMBLING');
     // Check points
     $cost = intval(get_option('minimum_gamble_amount'));
     $points_left = available_points(get_member());
     $max = min(intval(get_option('maximum_gamble_amount')), $points_left);
     if (!has_specific_permission(get_member(), 'give_points_self') || $amount < 0) {
         if ($amount < $cost || $amount > $max) {
             warn_exit(do_lang_tempcode('INVALID_GAMBLE_AMOUNT'));
         }
         if ($points_left < $amount) {
             return warn_screen($title, do_lang_tempcode('_CANT_AFFORD', integer_format($cost), integer_format($points_left)));
         }
     }
     // Calculate
     $average_gamble_multiplier = floatval(get_option('average_gamble_multiplier')) / 100.0;
     $maximum_gamble_multiplier = floatval(get_option('maximum_gamble_multiplier')) / 100.0;
     $above_average = mt_rand(0, 10) < 5;
     if ($above_average) {
         //			$winnings=round($average_gamble_multiplier*$amount+mt_rand(0,round($maximum_gamble_multiplier*$amount-$average_gamble_multiplier*$amount)));	  Even distribution is NOT wise
         $peak = $maximum_gamble_multiplier * $amount;
         $under = 0.0;
         $number = intval(round($average_gamble_multiplier * $amount + mt_rand(0, intval(round($maximum_gamble_multiplier * $amount - $average_gamble_multiplier * $amount)))));
         for ($x = 1; $x < intval($peak); $x++) {
             $p = $peak * (1.0 / pow(floatval($x) + 0.4, 2.0) - 1.0 / pow($maximum_gamble_multiplier * floatval($amount), 2.0));
             // Using a 1/x^2 curve. 0.4 is a bit of a magic number to get the averaging right
             $under += $p;
             if ($under > floatval($number)) {
                 break;
             }
         }
         $winnings = intval(round($average_gamble_multiplier * $amount + $x * 1.1));
         // 1.1 is a magic number to make it seem a bit fairer
     } else {
         $winnings = mt_rand(0, intval(round($average_gamble_multiplier * $amount)));
     }
     // Actuate
     require_code('points2');
     charge_member(get_member(), $amount - $winnings, do_lang('GAMBLING'));
     $GLOBALS['SITE_DB']->query_insert('sales', array('date_and_time' => time(), 'memberid' => get_member(), 'purchasetype' => 'GAMBLING', 'details' => strval($amount), 'details2' => ''));
     // Show message
     if ($winnings > $amount) {
         $result = do_lang_tempcode('GAMBLE_CONGRATULATIONS', integer_format($winnings - $amount), integer_format($amount));
     } else {
         $result = do_lang_tempcode('GAMBLE_COMMISERATIONS', integer_format($amount - $winnings), integer_format($amount));
     }
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, $result);
 }
示例#3
0
 /**
  * Standard actualisation stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function action_done()
 {
     $class = str_replace('hook_pointstore_', '', strtolower(get_class($this)));
     //if (get_option('is_on_'.$class.'_buy')=='0')  return new ocp_tempcode();
     $amount = post_param_integer('amount', 0);
     $bank_dividend = intval(get_option('bank_divident'));
     $title = get_page_title('BANKING');
     // Check points
     $points_left = available_points(get_member());
     if (!has_specific_permission(get_member(), 'give_points_self')) {
         if ($points_left < $amount) {
             return warn_screen($title, do_lang_tempcode('_CANT_AFFORD_BANK'));
         }
     }
     // Actuate
     require_code('points2');
     charge_member(get_member(), $amount, do_lang('BANKING'));
     $GLOBALS['SITE_DB']->query_insert('bank', array('add_time' => time(), 'user_id' => get_member(), 'amount' => strval($amount), 'divident' => $bank_dividend));
     // Show message
     $result = do_lang_tempcode('BANKING_CONGRATULATIONS', integer_format($amount), integer_format($bank_dividend));
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, $result);
 }
示例#4
0
 /**
  * Standard actualisation stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function action_done2()
 {
     $class = str_replace('hook_pointstore_', '', strtolower(get_class($this)));
     $title = get_page_title('OCGIFTS_TITLE');
     $gift_id = get_param_integer('gift');
     $member_id = get_member();
     $to_member = post_param('username', '');
     $gift_message = post_param('gift_message', '');
     $member_row = $GLOBALS['FORUM_DB']->query_select('f_members', array('*'), array('m_username' => $to_member), '', 1);
     if (isset($member_row[0]['id']) && $member_row[0]['id'] > 0) {
         $to_member_id = $member_row[0]['id'];
         $anonymous = post_param_integer('anonymous', 0);
         $gift_row = $GLOBALS['SITE_DB']->query_select('ocgifts', array('*'), array('id' => $gift_id));
         if (isset($gift_row[0]['id']) && $gift_row[0]['id'] > 0) {
             //check available points and charge
             $available_points = available_points($member_id);
             if ($gift_row[0]['price'] > $available_points) {
                 warn_exit(do_lang_tempcode('CANT_AFFORD'));
             }
             require_code('points2');
             //get gift points
             charge_member($member_id, $gift_row[0]['price'], do_lang('GIFT_PURCHASING') . ' - ' . strval($gift_row[0]['price']) . ' point(-s).');
             $gift_row_id = $GLOBALS['SITE_DB']->query_insert('members_gifts', array('to_user_id' => $to_member_id, 'from_user_id' => $member_id, 'gift_id' => $gift_id, 'add_time' => time(), 'is_anonymous' => $anonymous, 'topic_id' => NULL, 'gift_message' => $gift_message), true);
         }
         if (isset($gift_row[0]['id']) && $gift_row[0]['id'] > 0) {
             require_code('notifications');
             if ($anonymous == 0) {
                 $subject = do_lang('GOT_GIFT');
                 $message = '[html]' . do_lang('GIFT_EXPLANATION1', $GLOBALS['FORUM_DRIVER']->get_username($member_id), $gift_row[0]['name']) . '[/html].' . "\n\n" . '[img]' . get_custom_base_url() . '/' . $gift_row[0]['image'] . '[/img]' . "\n\n" . $gift_message;
                 dispatch_notification('gift', NULL, $subject, $message, array($to_member_id));
             } else {
                 $subject = do_lang('GOT_GIFT', NULL, NULL, NULL, get_lang($to_member_id));
                 $message = '[html]' . do_lang('GIFT_EXPLANATION2', $gift_row[0]['name'], NULL, NULL, get_lang($to_member_id)) . '[/html].' . "\n\n" . '[img]' . get_custom_base_url() . '/' . $gift_row[0]['image'] . '[/img]' . "\n\n" . $gift_message;
                 dispatch_notification('gift', NULL, $subject, $message, array($to_member_id), A_FROM_SYSTEM_UNPRIVILEGED);
             }
         }
     } else {
         warn_exit(do_lang_tempcode('NO_MEMBER_SELECTED'));
     }
     // Show message
     $result = do_lang_tempcode('GIFT_CONGRATULATIONS');
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, $result);
 }
示例#5
0
 /**
  * Standard actualisation stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function action_done()
 {
     $class = str_replace('hook_pointstore_', '', strtolower(get_class($this)));
     if (get_option('is_on_' . $class . '_buy') == '0') {
         return new ocp_tempcode();
     }
     $topic_id = post_param_integer('select_topic_id', -1);
     if ($topic_id == -1) {
         $_topic_id = post_param('manual_topic_id');
         $topic_id = intval($_topic_id);
     }
     $title = get_page_title('TOPIC_PINNING');
     // Check points
     $cost = intval(get_option($class));
     $points_left = available_points(get_member());
     if ($points_left < $cost && !has_specific_permission(get_member(), 'give_points_self')) {
         return warn_screen($title, do_lang_tempcode('_CANT_AFFORD', integer_format($cost), integer_format($points_left)));
     }
     // Actuate
     $GLOBALS['FORUM_DRIVER']->pin_topic($topic_id);
     require_code('points2');
     charge_member(get_member(), $cost, do_lang('TOPIC_PINNING'));
     $GLOBALS['SITE_DB']->query_insert('sales', array('date_and_time' => time(), 'memberid' => get_member(), 'purchasetype' => 'TOPIC_PINNING', 'details' => strval($topic_id), 'details2' => ''));
     // Show message
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('ORDER_GENERAL_DONE'));
 }
示例#6
0
 /**
  * Standard stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function _upgradebanner()
 {
     if (get_option('is_on_banner_buy') == '0') {
         return new ocp_tempcode();
     }
     $title = get_page_title('TITLE_BANNER_UPGRADE');
     $member_id = get_member();
     $pointsleft = available_points($member_id);
     $myrow = $this->handle_has_no_banner();
     $curhit = $myrow['campaign_remaining'];
     $curimp = $myrow['importance_modulus'];
     $name = $myrow['name'];
     //So we don't have to call these big ugly names, again...
     $futhit = post_param_integer('hits');
     $futimp = post_param_integer('importance');
     //Checking to be sure we've ordered numbers that are positive
     if (!($futimp >= 0 && $futhit >= 0)) {
         return warn_screen($title, do_lang_tempcode('BAD_INPUT'));
     }
     //Checking to be sure we haven't ordered nothing...
     if ($futimp == 0 && $futhit == 0) {
         return warn_screen($title, do_lang_tempcode('SILLY_INPUT'));
     }
     //How many importance and hits will we have after this?
     $afthit = $curhit + $futhit;
     $aftimp = $curimp + $futimp;
     //Getting the prices of hits and importance...
     $impprice = intval(get_option('banner_imp'));
     $hitprice = intval(get_option('banner_hit'));
     //Figuring out the price of importance and hits, depedning on how many they bought.
     $impcost = $futimp * $impprice;
     $hitcost = $futhit * $hitprice;
     $total_price = $hitcost + $impcost;
     $points_after = $pointsleft - $total_price;
     //Check to see this isn't costing us more than we can afford
     if ($points_after < 0 && !has_specific_permission(get_member(), 'give_points_self')) {
         return warn_screen($title, do_lang_tempcode('CANT_AFFORD'));
     }
     //If this is *not* our first time through, do a confirmation screen. Else, make the purchase.
     $ord = post_param_integer('ord', 0);
     if ($ord == 0) {
         $proceed_url = build_url(array('page' => '_SELF', 'type' => '_upgradebanner', 'id' => 'banners'), '_SELF');
         $keep = new ocp_tempcode();
         $keep->attach(form_input_hidden('hits', strval($futhit)));
         $keep->attach(form_input_hidden('importance', strval($futimp)));
         $keep->attach(form_input_hidden('ord', '1'));
         $action = do_lang_tempcode('BANNER_UPGRADE_CONFIRM', integer_format($futimp), integer_format($futhit));
         return do_template('POINTSTORE_CONFIRM_SCREEN', array('_GUID' => 'acdde0bd41ccd1459bbd7a1e9ca5ed68', 'TITLE' => $title, 'MESSAGE' => $action, 'ACTION' => '', 'COST' => integer_format($total_price), 'POINTS_AFTER' => integer_format($points_after), 'CANCEL_URL' => build_url(array('page' => '_SELF'), '_SELF'), 'PROCEED_URL' => $proceed_url, 'KEEP' => $keep));
     }
     // Our Query
     $GLOBALS['SITE_DB']->query_update('banners', array('campaign_remaining' => $afthit, 'importance_modulus' => $aftimp), array('name' => $name), '', 1);
     //Charge the user for their purchase
     require_code('points2');
     charge_member($member_id, $total_price, do_lang('BANNER_UPGRADE_LINE', integer_format($futhit), integer_format($futimp)));
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('BANNER_UPGRADED'));
 }
示例#7
0
 /**
  * Standard stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function ___text()
 {
     if (get_option('is_on_flagrant_buy') == '0') {
         return new ocp_tempcode();
     }
     $title = get_page_title('TITLE_NEWTEXT');
     // Define variables
     $member_id = get_member();
     $message = post_param('message');
     $days = post_param_integer('days');
     $points_left = available_points($member_id);
     // First we need to know the price of the number of days we ordered. After that, compare that price with our users current number of points.
     $dayprice = intval(get_option('text'));
     $total = $dayprice * $days;
     if ($points_left < $total && !has_specific_permission(get_member(), 'give_points_self')) {
         return warn_screen($title, do_lang_tempcode('FLAGRANT_LACK_POINTS', integer_format($days), integer_format($total), integer_format($points_left)));
     }
     // Add this to the database
     $GLOBALS['SITE_DB']->query_insert('text', array('notes' => '', 'activation_time' => NULL, 'active_now' => 0, 'user_id' => $member_id, 'the_message' => insert_lang_comcode($message, 2), 'days' => $days, 'order_time' => time()));
     // Mail off the notice
     require_code('notifications');
     $_url = build_url(array('page' => 'admin_flagrant'), 'adminzone', NULL, false, false, true);
     $manage_url = $_url->evaluate();
     dispatch_notification('pointstore_request_flagrant', NULL, do_lang('TITLE_NEWTEXT', NULL, NULL, NULL, get_site_default_lang()), do_lang('MAIL_FLAGRANT_TEXT', $message, comcode_escape($manage_url), NULL, get_site_default_lang()));
     // Now, deduct the points from our user's account
     require_code('points2');
     charge_member($member_id, $total, do_lang('PURCHASED_FLAGRANT'));
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('ORDER_FLAGRANT_DONE'));
 }
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     unset($map);
     require_css('side_blocks');
     $member = get_member();
     $forum = get_forum_type();
     $content = new ocp_tempcode();
     $links = new ocp_tempcode();
     if (!is_guest()) {
         // Admins can jump user
         $has_su = get_option('ocp_show_su') == '1' && has_specific_permission(get_member(), 'assume_any_member');
         $staff_actions = new ocp_tempcode();
         $username = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
         if ($forum != 'none') {
             if (!has_no_forum() && get_option('forum_show_personal_stats_posts') == '1') {
                 // Post count
                 $content->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINE', array('_GUID' => '371dfee46e8c40b1b109e0350055f8cc', 'KEY' => do_lang_tempcode('COUNT_POSTSCOUNT'), 'VALUE' => integer_format($GLOBALS['FORUM_DRIVER']->get_post_count($member)))));
             }
             if (!has_no_forum() && get_option('forum_show_personal_stats_topics') == '1') {
                 // Topic count
                 $content->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINE', array('KEY' => do_lang_tempcode('COUNT_TOPICSCOUNT'), 'VALUE' => integer_format($GLOBALS['FORUM_DRIVER']->get_topic_count($member)))));
             }
             // Member profile view link
             if (get_option('ocf_show_profile_link') == '1') {
                 $url = $GLOBALS['FORUM_DRIVER']->member_profile_url($member, true, true);
                 $links->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINK', array('_GUID' => '2c8648c953c802a9de41c3adeef0e97f', 'NAME' => do_lang_tempcode('MY_PROFILE'), 'URL' => $url, 'REL' => 'me')));
             }
         }
         // Point count and point profile link
         if (addon_installed('points')) {
             require_lang('points');
             require_code('points');
             if (get_option('points_show_personal_stats_points_left') == '1') {
                 $content->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINE', array('_GUID' => '6241e58e30457576735f3a2618fd7fff', 'KEY' => do_lang_tempcode('COUNT_POINTS_LEFT'), 'VALUE' => integer_format(available_points($member)))));
             }
             if (get_option('points_show_personal_stats_points_used') == '1') {
                 $content->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINE', array('_GUID' => '6241e58edfdsf735f3a2618fd7fff', 'KEY' => do_lang_tempcode('COUNT_POINTS_USED'), 'VALUE' => integer_format(points_used($member)))));
             }
             if (get_option('points_show_personal_stats_total_points') == '1') {
                 $content->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINE', array('_GUID' => '3e6183abf9054574c0cd292d25a4fe5c', 'KEY' => do_lang_tempcode('COUNT_POINTS_EVER'), 'VALUE' => integer_format(total_points($member)))));
             }
             if (get_option('points_show_personal_stats_gift_points_left') == '1') {
                 $content->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINE', array('_GUID' => '6241e5ssd45ddsdsdsa2618fd7fff', 'KEY' => do_lang_tempcode('COUNT_GIFT_POINTS_LEFT'), 'VALUE' => integer_format(get_gift_points_to_give($member)))));
             }
             if (get_option('points_show_personal_stats_gift_points_used') == '1') {
                 $content->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINE', array('_GUID' => '6241eddsd4sdddssdsa2618fd7fff', 'KEY' => do_lang_tempcode('COUNT_GIFT_POINTS_USED'), 'VALUE' => integer_format(get_gift_points_used($member)))));
             }
         }
         if (get_option('ocp_show_personal_usergroup') == '1') {
             $group_id = $GLOBALS['FORUM_DRIVER']->pname_group($GLOBALS['FORUM_DRIVER']->pget_row($username));
             $usergroups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list();
             if (array_key_exists($group_id, $usergroups)) {
                 if (get_forum_type() == 'ocf') {
                     $group_url = build_url(array('page' => 'groups', 'type' => 'view', 'id' => $group_id), get_module_zone('groups'));
                     $hyperlink = hyperlink($group_url, $usergroups[$group_id], false, true);
                     $content->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINE_COMPLEX', array('_GUID' => 'sas41eddsd4sdddssdsa2618fd7fff', 'KEY' => do_lang_tempcode('GROUP'), 'VALUE' => $hyperlink)));
                 } else {
                     $content->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINE', array('_GUID' => '65180134fbc4cf7e227011463d466677', 'KEY' => do_lang_tempcode('GROUP'), 'VALUE' => $usergroups[$group_id])));
                 }
             }
         }
         if (get_option('ocp_show_personal_last_visit') == '1') {
             $row = $GLOBALS['FORUM_DRIVER']->pget_row($username);
             if (get_forum_type() == 'ocf') {
                 $last_visit = intval(ocp_admirecookie('last_visit', strval($GLOBALS['FORUM_DRIVER']->pnamelast_visit($row))));
             } else {
                 $last_visit = $GLOBALS['FORUM_DRIVER']->pnamelast_visit($row);
             }
             $_last_visit = get_timezoned_date($last_visit, false);
             $content->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINE', array('_GUID' => 'sas41eddsdsdsdsdsa2618fd7fff', 'KEY' => do_lang_tempcode('LAST_HERE'), 'RAW_KEY' => strval($last_visit), 'VALUE' => $_last_visit)));
         }
         $avatar_url = '';
         if (!has_no_forum()) {
             if (get_option('ocp_show_avatar') === '1') {
                 $avatar_url = $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($member);
             }
         }
         // Subscription links
         if (get_forum_type() == 'ocf' && addon_installed('ecommerce') && get_option('ocp_show_personal_sub_links') == '1' && !has_zone_access(get_member(), 'adminzone') && has_actual_page_access(get_member(), 'purchase')) {
             $usergroup_subs = $GLOBALS['FORUM_DB']->query_select('f_usergroup_subs', array('id', 's_title', 's_group_id', 's_cost'), array('s_enabled' => 1));
             $in_one = false;
             $members_groups = $GLOBALS['FORUM_DRIVER']->get_members_groups($member);
             foreach ($usergroup_subs as $i => $sub) {
                 $usergroup_subs[$i]['s_cost'] = floatval($sub['s_cost']);
                 if (in_array($sub['s_group_id'], $members_groups)) {
                     $in_one = true;
                     break;
                 }
             }
             if (!$in_one) {
                 global $M_SORT_KEY;
                 $M_SORT_KEY = 's_cost';
                 usort($usergroup_subs, 'multi_sort');
                 foreach ($usergroup_subs as $sub) {
                     $url = build_url(array('page' => 'purchase', 'type' => 'message', 'product' => 'USERGROUP' . strval($sub['id'])), get_module_zone('purchase'));
                     $links->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINK', array('NAME' => do_lang_tempcode('UPGRADE_TO', escape_html(get_translated_text($sub['s_title']))), 'URL' => $url)));
                 }
             }
         }
         // Admin Zone link
         if (get_option('ocp_show_personal_adminzone_link') == '1' && has_zone_access(get_member(), 'adminzone')) {
             $url = build_url(array('page' => ''), 'adminzone');
             $links->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINK', array('_GUID' => 'ae243058f780f9528016f7854763a5fa', 'ACCESSKEY' => 'I', 'NAME' => do_lang_tempcode('ADMIN_ZONE'), 'URL' => $url)));
         }
         // Conceded mode link
         if ($GLOBALS['SESSION_CONFIRMED'] == 1 && get_option('ocp_show_conceded_mode_link') == '1') {
             $url = build_url(array('page' => 'login', 'type' => 'concede', 'redirect' => get_page_name() == 'login' ? NULL : SELF_REDIRECT), get_module_zone('login'));
             $links->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINK_2', array('_GUID' => '81fa81cfd3130e42996bf72b0e03d8aa', 'POST' => true, 'NAME' => do_lang_tempcode('CONCEDED_MODE'), 'DESCRIPTION' => do_lang_tempcode('DESCRIPTION_CONCEDED_MODE'), 'URL' => $url)));
         }
         // Becomes-invisible link
         if (get_option('is_on_invisibility') == '1') {
             $visible = array_key_exists(get_session_id(), $GLOBALS['SESSION_CACHE']) && $GLOBALS['SESSION_CACHE'][get_session_id()]['session_invisible'] == 0;
             $url = build_url(array('page' => 'login', 'type' => 'invisible', 'redirect' => get_page_name() == 'login' ? NULL : SELF_REDIRECT), get_module_zone('login'));
             $links->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LINK_2', array('NAME' => do_lang_tempcode($visible ? 'INVISIBLE' : 'BE_VISIBLE'), 'DESCRIPTION' => '', 'URL' => $url)));
         }
         // Logout link
         $url = build_url(array('page' => 'login', 'type' => 'logout'), get_module_zone('login'));
         if (!is_httpauth_login()) {
             $links->attach(do_template('BLOCK_SIDE_PERSONAL_STATS_LOGOUT', array('_GUID' => 'd1caacba272a7ee3bf5b2a758e4e54ee', 'NAME' => do_lang_tempcode('LOGOUT'), 'URL' => $url)));
         }
         return do_template('BLOCK_SIDE_PERSONAL_STATS', array('_GUID' => '99f9bc3387102daaeeedf99843b0502e', 'AVATAR_URL' => $avatar_url, 'LINKS' => $links, 'HAS_SU' => $has_su, 'CONTENT' => $content, 'USERNAME' => $username, 'STAFF_ACTIONS' => $staff_actions));
     } else {
         $title = do_lang_tempcode('NOT_LOGGED_IN');
         if (get_page_name() != 'join' && get_page_name() != 'login') {
             if (count($_POST) > 0) {
                 $_this_url = build_url(array('page' => ''), '', array('keep_session' => 1, 'redirect' => 1));
             } else {
                 $_this_url = build_url(array('page' => '_SELF'), '_SELF', array('keep_session' => 1, 'redirect' => 1), true);
             }
         } else {
             $_this_url = build_url(array('page' => ''), '', array('keep_session' => 1, 'redirect' => 1));
         }
         $this_url = $_this_url->evaluate();
         $login_url = build_url(array('page' => 'login', 'type' => 'login', 'redirect' => $this_url), get_module_zone('login'));
         $full_link = build_url(array('page' => 'login', 'type' => 'misc', 'redirect' => $this_url), get_module_zone('login'));
         $join_url = get_forum_type() != 'none' ? $GLOBALS['FORUM_DRIVER']->join_url() : '';
         return do_template('BLOCK_SIDE_PERSONAL_STATS_NO', array('_GUID' => '32aade68b98dfd191f0f84c6648f7dde', 'TITLE' => $title, 'FULL_LINK' => $full_link, 'JOIN_LINK' => $join_url, 'LOGIN_URL' => $login_url));
     }
 }
示例#9
0
/**
 * The actualiser for a member to buy an item from the room they are in. Does not return.
 *
 * @param  MEMBER		The member buying the item
 * @param  string		The name of the item
 * @param  MEMBER		The owner of the item copy
 */
function buy($member_id, $item_name, $copy_owner)
{
    // Check we have the points and that it exists
    list($realm, $x, $y) = get_loc_details($member_id);
    $cost = $GLOBALS['SITE_DB']->query_value_null_ok('w_items', 'cost', array('name' => $item_name, 'location_x' => $x, 'location_y' => $y, 'location_realm' => $realm, 'copy_owner' => $copy_owner));
    if (is_null($cost)) {
        ocw_refresh_with_message(do_lang_tempcode('ACCESS_DENIED__I_ERROR', $GLOBALS['FORUM_DRIVER']->get_username(get_member())), 'warn');
    }
    if ($cost > available_points($member_id)) {
        ocw_refresh_with_message(do_lang_tempcode('W_EXPENSIVE', integer_format($cost)), 'warn');
    }
    if ($cost == 0) {
        ocw_refresh_with_message(do_lang_tempcode('ACCESS_DENIED__I_ERROR', $GLOBALS['FORUM_DRIVER']->get_username(get_member())), 'warn');
    }
    // Charge them
    if (!has_specific_permission($member_id, 'administer_ocworld') || !is_guest($copy_owner)) {
        require_code('points2');
        $price = $cost;
        if (available_points($member_id) < $price) {
            ocw_refresh_with_message(do_lang_tempcode('W_EXPENSIVE', integer_format($price)), 'warn');
        }
        charge_member($member_id, $price, do_lang('W_BOUGHT_OCWORLD', escape_html($item_name)));
        charge_member($copy_owner, -$price * 0.7, do_lang('W_SOLD_OCWORLD', escape_html($item_name)));
    }
    basic_pickup($member_id, $item_name, $copy_owner);
    ocw_refresh_with_message(do_lang_tempcode('W_BOUGHT', escape_html($item_name), integer_format($cost)));
}
示例#10
0
 /**
  * Standard actualisation stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function action_done()
 {
     $class = str_replace('hook_pointstore_', '', strtolower(get_class($this)));
     $disease_id = get_param('disease', 0);
     $member_id = get_member();
     //default values
     $sick = 0;
     $get_cure = get_param_integer('cure', 0);
     $get_immunization = get_param_integer('immunization', 0);
     $cure = $get_cure == 1 ? 1 : 0;
     $immunization = $get_immunization == 1 ? 1 : 0;
     $member_rows = $GLOBALS['SITE_DB']->query_select('members_diseases', array('*'), array('user_id' => $member_id, 'disease_id' => $disease_id));
     $insert = true;
     if (isset($member_rows[0]['user_id']) && $member_rows[0]['user_id'] != 0) {
         //there is already a db member disease record
         $insert = false;
         $sick = $get_cure == 1 && $member_rows[0]['sick'] == 1 ? 0 : $sick;
     } else {
         //we should insert a new db member disease record
     }
     $rows = $GLOBALS['SITE_DB']->query_select('diseases', array('*'), array('id' => $disease_id));
     $cure_price = isset($rows[0]['cure_price']) && intval($rows[0]['cure_price']) > 0 ? intval($rows[0]['cure_price']) : 0;
     $immunization_price = isset($rows[0]['immunisation_price']) && intval($rows[0]['immunisation_price']) > 0 ? intval($rows[0]['immunisation_price']) : 0;
     $amount = $get_immunization == 1 ? $immunization_price : $cure_price;
     $title = get_page_title('DISEASES_CURES_IMMUNIZATIONS_TITLE');
     // Check points
     $points_left = available_points(get_member());
     if (!has_specific_permission(get_member(), 'give_points_self')) {
         if ($points_left < $amount) {
             return warn_screen($title, do_lang_tempcode('_CANT_AFFORD_THIS'));
         }
     }
     // Actuate
     require_code('points2');
     if ($get_immunization == 1) {
         charge_member(get_member(), $amount, do_lang('IMMUNIZATION_PURCHASED'));
     } else {
         charge_member(get_member(), $amount, do_lang('CURE_PURCHASED'));
     }
     if ($insert) {
         $GLOBALS['SITE_DB']->query_insert('members_diseases', array('user_id' => $member_id, 'disease_id' => $disease_id, 'sick' => strval($sick), 'cure' => strval($cure), 'immunisation' => strval($immunization)));
     } else {
         $GLOBALS['SITE_DB']->query_update('members_diseases', array('user_id' => $member_id, 'disease_id' => $disease_id, 'sick' => strval($sick), 'cure' => strval($cure), 'immunisation' => strval($immunization)), array('user_id' => $member_id, 'disease_id' => $disease_id), '', 1);
     }
     if ($get_immunization == 1) {
         // Show message
         $result = do_lang_tempcode('IMMUNIZATION_CONGRATULATIONS');
     } else {
         // Show message
         $result = do_lang_tempcode('CURE_CONGRATULATIONS');
     }
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, $result);
 }
示例#11
0
 /**
  * Get tempcode for a warning adding/editing form.
  *
  * @param  boolean		Whether it is a new warning/punishment record
  * @param  LONG_TEXT		The explanation for the warning/punishment record
  * @param  BINARY			Whether to make this a formal warning
  * @param  ?MEMBER		The member the warning is for (NULL: get from environment)
  * @return array			A pair: the tempcode for the visible fields, and the tempcode for the hidden fields
  */
 function get_form_fields($new = true, $explanation = '', $is_warning = 0, $member_id = NULL)
 {
     if (is_null($member_id)) {
         $member_id = get_param_integer('id', get_member());
     }
     $hidden = new ocp_tempcode();
     $fields = new ocp_tempcode();
     require_code('form_templates');
     // Information about their history, and the rules - to educate the warner/punisher
     if ($new) {
         $post_id = get_param_integer('post_id', NULL);
         $hidden->attach(form_input_hidden('member_id', strval($member_id)));
         $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id);
         $num_warnings = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_cache_warnings');
         $_rules_url = build_url(array('page' => 'rules'), '_SEARCH');
         $rules_url = $_rules_url->evaluate();
         $_history_url = build_url(array('page' => '_SELF', 'type' => 'history', 'id' => $member_id), '_SELF');
         $history_url = $_history_url->evaluate();
         $profile_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($member_id, false, true);
         if (is_object($profile_url)) {
             $profile_url = $profile_url->evaluate();
         }
         $this->add_text = do_lang_tempcode('HAS_ALREADY_X_WARNINGS', escape_html($username), integer_format($num_warnings), array(escape_html(get_site_name()), escape_html($rules_url), escape_html($history_url), escape_html($profile_url)));
     }
     $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('MODULE_TRANS_NAME_warnings'))));
     $fields->attach(form_input_tick(do_lang_tempcode('WHETHER_MAKE_WARNING'), do_lang_tempcode('DESCRIPTION_WHETHER_MAKE_WARNING'), 'is_warning', $is_warning == 1));
     // Punitive actions
     if ($new) {
         $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('PUNITIVE_ACTIONS'))));
         if (!is_null($post_id)) {
             $topic_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_posts', 'p_topic_id', array('id' => $post_id));
             if (!is_null($topic_id)) {
                 $forum_id = $GLOBALS['FORUM_DB']->query_value('f_topics', 't_forum_id', array('id' => $topic_id));
                 $hidden->attach(form_input_hidden('topic_id', strval($topic_id)));
                 $hidden->attach(form_input_hidden('forum_id', strval($forum_id)));
                 $silence_topic_time = NULL;
                 //time()+60*60*24*7;
                 $silence_forum_time = NULL;
                 //time()+60*60*24*7;
                 $active_until = $GLOBALS['SITE_DB']->query_value_null_ok('msp', 'active_until', array('member_id' => $member_id, 'specific_permission' => 'submit_lowrange_content', 'the_page' => '', 'module_the_name' => 'topics', 'category_name' => strval($topic_id)));
                 if (!is_null($active_until)) {
                     $silence_topic_time = $active_until;
                 }
                 $active_until = $GLOBALS['SITE_DB']->query_value_null_ok('msp', 'active_until', array('member_id' => $member_id, 'specific_permission' => 'submit_lowrange_content', 'the_page' => '', 'module_the_name' => 'forums', 'category_name' => strval($forum_id)));
                 if (!is_null($active_until)) {
                     $silence_forum_time = $active_until;
                 }
                 $fields->attach(form_input_date(do_lang_tempcode('SILENCE_FROM_TOPIC'), do_lang_tempcode('DESCRIPTION_SILENCE_FROM_TOPIC'), 'silence_from_topic', true, true, true, $silence_topic_time, 2));
                 $fields->attach(form_input_date(do_lang_tempcode('SILENCE_FROM_FORUM'), do_lang_tempcode('DESCRIPTION_SILENCE_FROM_FORUM'), 'silence_from_forum', true, true, true, $silence_forum_time, 2));
             }
         }
         if (has_specific_permission(get_member(), 'probate_members')) {
             $fields->attach(form_input_integer(do_lang_tempcode('EXTEND_PROBATION'), do_lang_tempcode('DESCRIPTION_EXTEND_PROBATION'), 'probation', 0, true));
         }
         if (addon_installed('securitylogging')) {
             if (has_actual_page_access(get_member(), 'admin_ipban')) {
                 $fields->attach(form_input_tick(do_lang_tempcode('WHETHER_BANNED_IP'), do_lang_tempcode('DESCRIPTION_WHETHER_BANNED_IP'), 'banned_ip', false));
             }
         }
         if (addon_installed('points')) {
             if (has_actual_page_access(get_member(), 'admin_points')) {
                 require_code('points');
                 $num_points_currently = available_points($member_id);
                 $fields->attach(form_input_integer(do_lang_tempcode('CHARGED_POINTS'), do_lang_tempcode('DESCRIPTION_CHARGED_POINTS', escape_html(integer_format($num_points_currently))), 'charged_points', 0, true));
             }
         }
         if (has_specific_permission(get_member(), 'member_maintenance')) {
             $fields->attach(form_input_tick(do_lang_tempcode('BANNED_MEMBER'), do_lang_tempcode('DESCRIPTION_BANNED_MEMBER'), 'banned_member', false));
             $rows = $GLOBALS['FORUM_DB']->query_select('f_groups', array('id', 'g_name'), array('g_is_private_club' => 0));
             $groups = new ocp_tempcode();
             $groups->attach(form_input_list_entry('-1', false, do_lang_tempcode('NA_EM')));
             foreach ($rows as $group) {
                 if ($group['id'] != db_get_first_id()) {
                     $groups->attach(form_input_list_entry(strval($group['id']), false, get_translated_text($group['g_name'], $GLOBALS['FORUM_DB'])));
                 }
             }
             $fields->attach(form_input_list(do_lang_tempcode('CHANGE_USERGROUP_TO'), do_lang_tempcode('DESCRIPTION_CHANGE_USERGROUP_TO'), 'changed_usergroup_from', $groups));
         }
     }
     // Explanatory text
     $keep = symbol_tempcode('KEEP');
     $load_url = find_script('warnings') . '?type=load' . $keep->evaluate();
     $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('EXPLANATORY_TEXT'), 'HELP' => do_lang_tempcode('LOAD_SAVED_WARNING', escape_html($load_url)))));
     $fields->attach(form_input_line_comcode(do_lang_tempcode('EXPLANATION'), do_lang_tempcode('DESCRIPTION_EXPLANATION'), 'explanation', $explanation, true));
     if ($new) {
         $message = '';
         if (!is_null($post_id)) {
             $_postdetails_text = $GLOBALS['FORUM_DB']->query_value_null_ok('f_posts', 'p_post', array('id' => $post_id));
             if (!is_null($_postdetails_text)) {
                 $message = '[quote="' . $username . '"]' . chr(10) . get_translated_text($_postdetails_text) . chr(10) . '[/quote]';
             }
         }
         $fields->attach(form_input_text_comcode(do_lang_tempcode('MESSAGE'), do_lang_tempcode('DESCRIPTION_PP_MESSAGE'), 'message', $message, false));
         $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS'))));
         $fields->attach(form_input_line(do_lang_tempcode('SAVE_WARNING_DETAILS'), do_lang_tempcode('DESCRIPTION_SAVE_WARNING_DETAILS'), 'save', '', false));
     }
     return array($fields, $hidden);
 }
示例#12
0
 /**
  * Standard actualisation stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function action_done()
 {
     $class = str_replace('hook_pointstore_', '', strtolower(get_class($this)));
     post_param_integer('confirm');
     // Make sure POSTed
     $id = get_param_integer('sub_id');
     $rows = $GLOBALS['SITE_DB']->query_select('pstore_customs', array('id', 'c_title', 'c_cost', 'c_one_per_member'), array('id' => $id, 'c_enabled' => 1));
     if (!array_key_exists(0, $rows)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $cost = $rows[0]['c_cost'];
     $c_title = get_translated_text($rows[0]['c_title']);
     $title = get_page_title('PURCHASE_SOME_PRODUCT', true, array(escape_html($c_title)));
     // Check points
     $points_left = available_points(get_member());
     if ($points_left < $cost && !has_specific_permission(get_member(), 'give_points_self')) {
         return warn_screen($title, do_lang_tempcode('_CANT_AFFORD', integer_format($cost), integer_format($points_left)));
     }
     if ($rows[0]['c_one_per_member'] == 1) {
         // Test to see if it's been bought
         $test = $GLOBALS['SITE_DB']->query_value_null_ok('sales', 'id', array('purchasetype' => 'PURCHASE_CUSTOM_PRODUCT', 'details2' => strval($rows[0]['id']), 'memberid' => get_member()));
         if (!is_null($test)) {
             warn_exit(do_lang_tempcode('ONE_PER_MEMBER_ONLY'));
         }
     }
     require_code('points2');
     charge_member(get_member(), $cost, $c_title);
     $sale_id = $GLOBALS['SITE_DB']->query_insert('sales', array('date_and_time' => time(), 'memberid' => get_member(), 'purchasetype' => 'PURCHASE_CUSTOM_PRODUCT', 'details' => $c_title, 'details2' => strval($rows[0]['id'])), true);
     require_code('notifications');
     $subject = do_lang('MAIL_REQUEST_CUSTOM', comcode_escape($c_title), NULL, NULL, get_site_default_lang());
     $username = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
     $message_raw = do_lang('MAIL_REQUEST_CUSTOM_BODY', comcode_escape($c_title), $username, NULL, get_site_default_lang());
     dispatch_notification('pointstore_request_custom', 'custom' . strval($id) . '_' . strval($sale_id), $subject, $message_raw, NULL, NULL, 3, true);
     // Show message
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('ORDER_GENERAL_DONE'));
 }
示例#13
0
/**
 * Evaluate a conventional tempcode variable, handling escaping
 *
 * @param  LANGUAGE_NAME	The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array				Array of escaping operations
 * @param  integer			The type of symbol this is (TC_SYMBOL, TC_LANGUAGE_REFERENCE)
 * @set    0 2
 * @param  ID_TEXT			The name of the symbol
 * @param  array				Parameters to the symbol. For all but directive it is an array of strings. For directives it is an array of Tempcode objects. Actually there may be template-style parameters in here, as an influence of singular_bind and these may be Tempcode, but we ignore them.
 * @return mixed				The result. Either tempcode, or a string.
 */
function ecv($lang, $escaped, $type, $name, $param)
{
    global $TEMPCODE_SETGET, $CYCLES, $PREPROCESSABLE_SYMBOLS, $DISPLAYED_TITLE;
    //echo '<!--'.$name.'-->'."\n";
    if ($type == TC_SYMBOL) {
        $escaped_codes = $name . ($escaped == array() ? '' : serialize($escaped));
        $cacheable = $param == array() && !isset($GLOBALS['NON_CACHEABLE_SYMBOLS'][$name]);
        if ($cacheable) {
            global $SYMBOL_CACHE;
            if (isset($SYMBOL_CACHE[$escaped_codes])) {
                return $SYMBOL_CACHE[$escaped_codes];
            }
        }
        $value = '';
        if ($GLOBALS['XSS_DETECT']) {
            ocp_mark_as_escaped($value);
        }
        $temp_array = array();
        if (isset($PREPROCESSABLE_SYMBOLS[$name]) && $name != 'PAGE_LINK') {
            handle_symbol_preprocessing(array($escaped, $type, $name, $param), $temp_array);
        }
        // Late preprocessing. Should not be needed in case of full screen output (as this was properly preprocessed), but is in other cases
        switch ($name) {
            case 'PAGE_LINK':
                if (isset($param[0])) {
                    list($zone, $map, $hash) = page_link_decode(is_object($param[0]) ? $param[0]->evaluate() : $param[0]);
                    $skip = NULL;
                    if (isset($param[4])) {
                        $skip = array_flip(explode('|', $param[4]));
                    }
                    $avoid_remap = isset($param[1]) && $param[1] == '1';
                    $skip_keep = isset($param[2]) && $param[2] == '1';
                    $keep_all = isset($param[3]) && $param[3] == '1';
                    foreach ($map as $key => $val) {
                        if (is_object($val)) {
                            $map[$key] = $val->evaluate();
                        }
                    }
                    $value = _build_url($map, $zone, $skip, $keep_all, $avoid_remap, $skip_keep, $hash);
                } else {
                    $value = get_zone_name() . ':' . get_page_name();
                    foreach ($_GET as $key => $val) {
                        if ($key == 'page') {
                            continue;
                        }
                        if (is_array($val)) {
                            continue;
                        }
                        if (substr($key, 0, 5) == 'keep_' && !skippable_keep($key, $val)) {
                            continue;
                        }
                        $value .= ':' . $key . '=' . $val;
                    }
                }
                break;
            case 'SET':
                if (isset($param[1])) {
                    if (isset($param[1]) && is_object($param[1])) {
                        $TEMPCODE_SETGET[$param[0]] = $param[1];
                    } else {
                        $param_copy = $param;
                        unset($param_copy[0]);
                        $TEMPCODE_SETGET[$param[0]] = implode(',', $param_copy);
                    }
                }
                break;
            case 'GET':
                if (isset($param[0])) {
                    if (isset($TEMPCODE_SETGET[$param[0]])) {
                        if (is_object($TEMPCODE_SETGET[$param[0]])) {
                            $TEMPCODE_SETGET[$param[0]] = $TEMPCODE_SETGET[$param[0]]->evaluate();
                        }
                        $value = $TEMPCODE_SETGET[$param[0]];
                    }
                }
                break;
            case 'EQ':
                if (isset($param[1])) {
                    $first = array_shift($param);
                    $count = 0;
                    foreach ($param as $test) {
                        if ($first == $test) {
                            $count++;
                            break;
                        }
                    }
                    $value = $count != 0 ? '1' : '0';
                }
                break;
            case 'NEQ':
                if (isset($param[1])) {
                    $first = array_shift($param);
                    $count = 0;
                    foreach ($param as $test) {
                        if ($first == $test) {
                            $count++;
                        }
                    }
                    $value = $count == 0 ? '1' : '0';
                }
                break;
            case 'NOT':
                if (isset($param[0])) {
                    $value = $param[0] == '1' || $param[0] == '1' ? '0' : '1';
                }
                break;
            case 'OR':
                $count = 0;
                foreach ($param as $test) {
                    if ($test == '1' || $test == '1') {
                        $count++;
                    }
                }
                $value = $count > 0 ? '1' : '0';
                break;
            case 'AND':
                $count = 0;
                foreach ($param as $test) {
                    if ($test == '1' || $test == '1') {
                        $count++;
                    }
                }
                $value = $count == count($param) ? '1' : '0';
                break;
            case 'HAS_ACTUAL_PAGE_ACCESS':
                if (isset($param[0])) {
                    $value = has_actual_page_access($param !== NULL && isset($param[2]) ? intval($param[2]) : get_member(), $param[0], isset($param[1]) ? $param[1] : NULL) ? '1' : '0';
                }
                break;
            case '?':
                if (isset($param[1])) {
                    $value = $param[0] == '1' || $param[0] == '1' ? $param[1] : (isset($param[2]) ? $param[2] : $value);
                }
                break;
            case 'IMG':
                if (isset($param[0]) && isset($GLOBALS['SITE_DB']) && function_exists('find_theme_image') && $GLOBALS['IN_MINIKERNEL_VERSION'] == 0) {
                    $value = find_theme_image($param[0], isset($param[3]) && $param[3] == '1', false, array_key_exists(2, $param) && $param[2] != '' ? $param[2] : NULL, NULL, isset($param[1]) && $param[1] == '1' ? $GLOBALS['FORUM_DB'] : $GLOBALS['SITE_DB']);
                }
                break;
            case '':
                break;
            case 'META_DATA':
                if (isset($param[0])) {
                    global $META_DATA;
                    if (isset($param[1])) {
                        $matches = array();
                        if ($param[0] == 'image' && preg_match('#^' . preg_quote(find_script('attachment'), '#') . '\\?id=(\\d+)#', $param[1], $matches) != 0) {
                            require_code('attachments');
                            if (!has_attachment_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), intval($matches[1]))) {
                                break;
                            }
                        }
                        $META_DATA[$param[0]] = $param[1];
                    } else {
                        $value = isset($META_DATA[$param[0]]) ? strip_comcode($META_DATA[$param[0]]) : '';
                        if ($value === NULL) {
                            $value = '';
                        }
                    }
                }
                break;
            case 'SPECIAL_CLICK_TO_EDIT':
                $_value = do_lang_tempcode('SPECIAL_CLICK_TO_EDIT');
                $value = $_value->evaluate();
                break;
            case 'KEEP':
                // What needs preserving in the URL
                $value = keep_symbol($param);
                break;
            case 'BROWSER':
                if (isset($param[1])) {
                    $q = false;
                    foreach (explode('|', $param[0]) as $browser) {
                        $q = browser_matches($browser);
                        if ($q) {
                            break;
                        }
                    }
                    $value = $q ? $param[1] : (isset($param[2]) ? $param[2] : '');
                    if ($GLOBALS['XSS_DETECT']) {
                        ocp_mark_as_escaped($value);
                    }
                }
                break;
            case 'JAVASCRIPT_INCLUDE':
                if (isset($param[0])) {
                    require_javascript($param[0]);
                    /*// Has to do this inline, as you're not allowed to reference scripts outside head
                    		if (!array_key_exists($param[0],$GLOBALS['JAVASCRIPTS']))
                    		{
                    			$GLOBALS['JAVASCRIPTS'][$param[0]]=1;
                    			$file=javascript_enforce($param[0]);
                    			$_value=do_template('JAVASCRIPT_NEED_INLINE',array('_GUID'=>'d6c907e26c5a8dd8c65f1d36a1a674a9','CODE'=>file_get_contents($file,FILE_TEXT)));
                    			$value=$_value->evaluate();
                    		}*/
                }
                break;
            case 'FACILITATE_AJAX_BLOCK_CALL':
                if (isset($param[0])) {
                    require_javascript('javascript_ajax');
                    require_code('blocks');
                    $_block_constraints = block_params_to_block_signature(block_params_str_to_arr($param[0]));
                    if (array_key_exists(1, $param)) {
                        $_block_constraints = array_merge($_block_constraints, block_params_str_to_arr($param[1]));
                        ksort($_block_constraints);
                    }
                    $block_constraints = block_params_arr_to_str($_block_constraints);
                    // Store permissions
                    $_auth_key = $GLOBALS['SITE_DB']->query_select('temp_block_permissions', array('id', 'p_time'), array('p_session_id' => get_session_id(), 'p_block_constraints' => $block_constraints), '', 1);
                    if (!array_key_exists(0, $_auth_key)) {
                        $auth_key = $GLOBALS['SITE_DB']->query_insert('temp_block_permissions', array('p_session_id' => get_session_id(), 'p_block_constraints' => $block_constraints, 'p_time' => time()), true);
                    } else {
                        $auth_key = $_auth_key[0]['id'];
                        if (time() - $_auth_key[0]['p_time'] > 100) {
                            $GLOBALS['SITE_DB']->query_update('temp_block_permissions', array('p_time' => time()), array('p_session_id' => get_session_id(), 'p_block_constraints' => $block_constraints), '', 1);
                        }
                    }
                    $keep = symbol_tempcode('KEEP');
                    $value = find_script('snippet') . '?snippet=block&auth_key=' . urlencode(strval($auth_key)) . '&block_map=' . urlencode($param[0]) . $keep->evaluate();
                }
                break;
            case 'LANG':
                $value = user_lang();
                break;
            case '_GET':
                if (isset($param[0])) {
                    $value = get_param($param[0], isset($param[1]) ? $param[1] : '', true);
                }
                break;
            case 'QUERY_STRING':
                $value = ocp_srv('QUERY_STRING');
                break;
            case 'USER_AGENT':
                $value = ocp_srv('HTTP_USER_AGENT');
                break;
            case 'STRIP_TAGS':
                if (isset($param[0])) {
                    if (isset($param[1]) && $param[1] == '1') {
                        $value = strip_tags(str_replace('))', ')', str_replace('((', '(', str_replace('<em>', '(', str_replace('</em>', ')', $param[0])))));
                    } else {
                        $value = strip_tags($param[0], array_key_exists(2, $param) ? $param[2] : '');
                    }
                    if (isset($param[1]) && $param[1] == '1') {
                        $value = @html_entity_decode($value, ENT_QUOTES, get_charset());
                    }
                }
                break;
            case 'CONFIG_OPTION':
                if (isset($param[0])) {
                    if (!isset($GLOBALS['OPTIONS'])) {
                        $value = '0';
                    } else {
                        $value = get_option($param[0], true);
                        if ($value === NULL) {
                            $value = '';
                        }
                    }
                }
                break;
            case 'TRUNCATE_LEFT':
                // Truncate the left length of a string. 0: text to truncate, 1: the truncate length, 2: whether to use a tooltip mouse-over if it is truncated, 3: whether it is encoded as HTML (0=no [default, plain-text], 1=yes)
                $value = symbol_truncator($param, 'left');
                break;
            case 'TRUNCATE_RIGHT':
                $value = symbol_truncator($param, 'right');
                break;
            case 'TRUNCATE_SPREAD':
                $value = symbol_truncator($param, 'spread');
                break;
            case 'TRUNCATE_EXPAND':
                $value = symbol_truncator($param, 'expand');
                break;
            case 'THEME':
                if (isset($GLOBALS['FORUM_DRIVER'])) {
                    $value = $GLOBALS['FORUM_DRIVER']->get_theme();
                } else {
                    $value = 'default';
                }
                break;
            case 'REVERSE':
                if (isset($param[0])) {
                    $value = implode(',', array_reverse(explode(',', $param[0])));
                }
                break;
            case 'COMMA_LIST_GET':
                if (isset($param[1])) {
                    require_code('blocks');
                    $values = block_params_str_to_arr($param[0]);
                    $value = isset($values[$param[1]]) ? $values[$param[1]] : '';
                }
                break;
            case 'COMMA_LIST_SET':
                if (isset($param[2])) {
                    require_code('blocks');
                    $values = block_params_str_to_arr($param[0]);
                    $values[$param[1]] = $param[2];
                    $value = block_params_arr_to_str($values);
                }
                break;
            case 'IS_EMPTY':
                if (isset($param[0])) {
                    $value = $param[0] == '' ? '1' : '0';
                }
                break;
            case 'IS_NON_EMPTY':
                if (isset($param[0])) {
                    $value = $param[0] != '' ? '1' : '0';
                }
                break;
            case 'CUSTOM_BASE_URL':
                $value = get_custom_base_url(isset($param[0]) && $param[0] != '' ? $param[0] == '1' : NULL);
                if (isset($param[1]) && $param[1] == '1') {
                    $value = cdn_filter($value);
                }
                break;
            case 'LOAD_PANEL':
                foreach ($param as $i => $p) {
                    if (is_object($p)) {
                        $param[$i] = $p->evaluate();
                    }
                }
                global $LOADED_PANELS;
                if (strpos($param[0], ':') !== false) {
                    $param = array_reverse(explode(':', $param[0], 2));
                }
                if (substr($param[0], 0, 6) == 'panel_') {
                    $param[0] = substr($param[0], 6);
                }
                $sr = serialize($param);
                $value = array_key_exists($sr, $LOADED_PANELS) ? $LOADED_PANELS[$sr] : '';
                break;
            case 'HAS_JS':
            case 'JS_ON':
                if (isset($param[1])) {
                    $value = has_js() ? $param[0] : $param[1];
                } else {
                    $value = has_js() ? '1' : '0';
                }
                break;
            case 'BASE_URL_NOHTTP':
                $value = preg_replace('#^https?://[^/]+#', '', get_base_url());
                if (substr($value, 0, 2) == '//') {
                    $value = substr($value, 1);
                }
                if (!$GLOBALS['DEBUG_MODE']) {
                    break;
                }
                // Debug mode changes base domain so we need to actually use it in full (fine, we don't have HTTPS in debug mode). Bubble on...
            // Debug mode changes base domain so we need to actually use it in full (fine, we don't have HTTPS in debug mode). Bubble on...
            case 'CUSTOM_BASE_URL_NOHTTP':
                $value = preg_replace('#^https?://[^/]+/#', '/', get_custom_base_url());
                if (substr($value, 0, 2) == '//') {
                    $value = substr($value, 1);
                }
                if (!$GLOBALS['DEBUG_MODE']) {
                    break;
                }
                // Debug mode changes base domain so we need to actually use it in full (fine, we don't have HTTPS in debug mode). Bubble on...
            // Debug mode changes base domain so we need to actually use it in full (fine, we don't have HTTPS in debug mode). Bubble on...
            case 'BASE_URL':
                $value = get_base_url(isset($param[0]) ? $param[0] == '1' : NULL);
                break;
            case 'ZONE':
                $value = get_zone_name();
                break;
            case 'PAGE':
                $value = get_page_name();
                break;
            case 'SITE_NAME':
                $value = get_site_name();
                break;
            case 'HEADER_TEXT':
                global $ZONE;
                $value = $ZONE['zone_header_text_trans'];
                break;
            case 'PANEL_WIDTH':
                if (isset($TEMPCODE_SETGET['PANEL_WIDTH']) && $TEMPCODE_SETGET['PANEL_WIDTH'] != '') {
                    $value = $TEMPCODE_SETGET['PANEL_WIDTH'];
                } else {
                    $value = get_option('panel_width', true);
                    if ($value === NULL) {
                        $value = '13.3em';
                    }
                }
                break;
            case 'PANEL_WIDTH_SPACED':
                if (isset($TEMPCODE_SETGET['PANEL_WIDTH_SPACED']) && $TEMPCODE_SETGET['PANEL_WIDTH_SPACED'] != '') {
                    $value = $TEMPCODE_SETGET['PANEL_WIDTH_SPACED'];
                } else {
                    $value = get_option('panel_width_spaced', true);
                    if (is_null($value)) {
                        $value = '14.3em';
                    }
                }
                break;
            case 'TRIM':
                if (isset($param[0])) {
                    $value = preg_replace(array('#^\\s+#', '#^(<br\\s*/?' . '>\\s*)+#', '#^(&nbsp;)+#', '#\\s+$#', '#(<br\\s*/?' . '>\\s*)+$#', '#(&nbsp;)+$#'), array('', '', '', '', '', ''), $param[0]);
                }
                break;
            case 'CPF_VALUE':
                if (isset($param[0])) {
                    if (is_numeric($param[0])) {
                        require_code('ocf_members');
                        $fields = ocf_get_custom_fields_member(isset($param[1]) ? intval($param[1]) : get_member());
                        if (array_key_exists(intval($param[0]), $fields)) {
                            $_value = $fields[intval($param[0])];
                        }
                    } elseif (substr($param[0], 0, 2) == 'm_' && strpos(strtolower($param[0]), 'hash') === false && strpos(strtolower($param[0]), 'salt') === false) {
                        $_value = $GLOBALS['FORUM_DRIVER']->get_member_row_field(isset($param[1]) ? intval($param[1]) : get_member(), $param[0]);
                    } else {
                        $_value = get_ocp_cpf($param[0], isset($param[1]) ? intval($param[1]) : NULL);
                    }
                    if (!is_string($_value)) {
                        $value = is_null($_value) ? '' : strval($_value);
                    } else {
                        $value = $_value;
                    }
                }
                break;
            case 'BANNER':
                if (addon_installed('banners')) {
                    global $SITE_INFO;
                    $is_on_banners = get_option('is_on_banners') == '1' && (!has_specific_permission(get_member(), 'banner_free') || $GLOBALS['FORUM_DRIVER']->is_super_admin(get_member()) && get_option('admin_banners') == '1' || !is_null($GLOBALS['CURRENT_SHARE_USER']));
                    if (array_key_exists('throttle_bandwidth_registered', $SITE_INFO)) {
                        $views_till_now = intval(get_value('page_views'));
                        $bandwidth_allowed = $SITE_INFO['throttle_bandwidth_registered'];
                        $total_bandwidth = intval(get_value('download_bandwidth'));
                        if ($bandwidth_allowed * 1024 * 1024 >= $total_bandwidth) {
                            $is_on_banners = false;
                        }
                    }
                    if ($is_on_banners && !is_page_https(get_zone_name(), get_page_name())) {
                        require_code('banners');
                        $b_type = isset($param[0]) ? $param[0] : '';
                        $internal_only = isset($param[1]) ? intval($param[1]) : ($b_type == '' ? 0 : 1);
                        if (isset($GLOBALS['NON_CACHEABLE_SYMBOLS']['SET_RAND'])) {
                            $_value = banners_script(true, '', '', $b_type, $internal_only, '');
                            $value = $_value->evaluate();
                        } else {
                            $value = 'Banner goes here';
                        }
                    }
                }
                break;
            case 'AVATAR':
                $value = $GLOBALS['FORUM_DRIVER']->get_member_avatar_url(isset($param[0]) ? intval($param[0]) : get_member());
                if (url_is_local($value) && $value != '') {
                    $value = get_custom_base_url() . '/' . $value;
                }
                break;
            case 'IS_GUEST':
                if (isset($param[0])) {
                    $value = is_guest(intval($param[0])) ? '1' : '0';
                } else {
                    $value = is_guest() ? '1' : '0';
                }
                break;
            case 'MEMBER':
                $value = strval(get_member());
                break;
            case 'USER':
                if (!isset($param[0])) {
                    $value = strval(get_member());
                } else {
                    $member_id = $GLOBALS['FORUM_DRIVER']->get_member_from_username($param[0]);
                    $value = is_null($member_id) ? '' : strval($member_id);
                }
                break;
            case 'CSS_INCLUDE':
                if (isset($param[0])) {
                    require_css($param[0]);
                    /*// Has to do this inline, as you're not allowed to reference sheets outside head
                    		if (!array_key_exists($param[0],$GLOBALS['CSSS']))
                    		{
                    			$GLOBALS['CSSS'][$param[0]]=1;
                    			$file=css_enforce($param[0]);
                    			$_value=do_template('CSS_NEED_INLINE',array('_GUID'=>'9de994d2f6d47a622d49347feb7ebe96','CSS'=>str_replace('../../../../',get_base_url().'/',file_get_contents($file,FILE_TEXT))));
                    			$value=$_value->evaluate();
                    		}*/
                }
                break;
            case 'USER_OVERIDE':
                $value = get_param('id', '');
                if (!is_numeric($value) || $value == '') {
                    $value = strval(get_member());
                }
                break;
            case 'IS_HTTPAUTH_LOGIN':
                $value = is_httpauth_login() ? '1' : '0';
                break;
            case 'MEMBER_PROFILE_LINK':
                $value = $GLOBALS['FORUM_DRIVER']->member_profile_url(!is_null($param) && isset($param[0]) ? intval($param[0]) : get_member(), false, true);
                if (is_null($value)) {
                    $value = '';
                }
                break;
            case 'USERNAME':
                $value = $GLOBALS['FORUM_DRIVER']->get_username(!is_null($param) && isset($param[0]) ? intval($param[0]) : get_member());
                if (is_null($value)) {
                    $value = do_lang('UNKNOWN');
                }
                break;
            case 'CYCLE':
                if (isset($param[0])) {
                    if (!isset($CYCLES[$param[0]])) {
                        $CYCLES[$param[0]] = 0;
                    }
                    if (!isset($param[1])) {
                        $value = strval($CYCLES[$param[0]]);
                    } else {
                        if (count($param) == 2) {
                            $param = array_merge(array($param[0]), explode(',', $param[1]));
                        }
                        ++$CYCLES[$param[0]];
                        if (!array_key_exists($CYCLES[$param[0]], $param)) {
                            $CYCLES[$param[0]] = 1;
                        }
                        $value = $param[$CYCLES[$param[0]]];
                    }
                }
                break;
            case 'THUMBNAIL':
                require_code('images');
                $value = _symbol_thumbnail($param);
                break;
            case 'IMAGE_WIDTH':
                require_code('images');
                list($value, ) = _symbol_image_dims($param);
                break;
            case 'IMAGE_HEIGHT':
                require_code('images');
                list(, $value) = _symbol_image_dims($param);
                break;
            case 'IS_IN_GROUP':
                if (isset($param[0])) {
                    if (in_array($param[count($param) - 1], array('', 'primary', 'secondary'))) {
                        $last_param = $param[count($param) - 1];
                        unset($param[count($param) - 1]);
                    } else {
                        $last_param = '';
                    }
                    $member_id = get_member();
                    $new_param = '';
                    $param_2 = array();
                    foreach ($param as $group) {
                        if (substr($group, 0, 1) == '!' && is_numeric(substr($group, 1))) {
                            $member_id = intval(substr($group, 1));
                        } else {
                            $param_2 = array_merge($param_2, explode(',', $group));
                        }
                    }
                    foreach ($param_2 as $group) {
                        if ($new_param != '') {
                            $new_param .= ',';
                        }
                        $new_param .= $group;
                    }
                    if ($last_param == 'primary') {
                        $member_row = $GLOBALS['FORUM_DRIVER']->get_member_row($member_id);
                        $real_group_list = array($GLOBALS['FORUM_DRIVER']->pname_group($member_row));
                    } elseif ($last_param == 'secondary') {
                        $real_group_list = $GLOBALS['FORUM_DRIVER']->get_members_groups($member_id);
                        $member_row = $GLOBALS['FORUM_DRIVER']->get_member_row($member_id);
                        $real_group_list = array_diff($real_group_list, array($GLOBALS['FORUM_DRIVER']->pname_group($member_row)));
                    } else {
                        $real_group_list = $GLOBALS['FORUM_DRIVER']->get_members_groups($member_id);
                    }
                    require_code('ocfiltering');
                    $value = count(array_intersect(ocfilter_to_idlist_using_memory($new_param, $GLOBALS['FORUM_DRIVER']->get_usergroup_list()), $real_group_list)) != 0 ? '1' : '0';
                }
                break;
            case 'IS_STAFF':
                if (isset($GLOBALS['FORUM_DRIVER'])) {
                    $value = $GLOBALS['FORUM_DRIVER']->is_staff(!is_null($param) && isset($param[0]) ? intval($param[0]) : get_member()) ? '1' : '0';
                } else {
                    $value = '0';
                }
                break;
            case 'IS_SUPER_ADMIN':
                if (isset($GLOBALS['FORUM_DRIVER'])) {
                    $value = $GLOBALS['FORUM_DRIVER']->is_super_admin(!is_null($param) && isset($param[0]) ? intval($param[0]) : get_member()) ? '1' : '0';
                } else {
                    $value = '0';
                }
                break;
            case 'PHOTO':
                if (isset($param[0])) {
                    $value = $GLOBALS['FORUM_DRIVER']->get_member_photo_url(intval($param[0]));
                    if (url_is_local($value) && $value != '') {
                        $value = get_custom_base_url() . '/' . $value;
                    }
                }
                break;
            case 'OCF_RANK_IMAGE':
                if (addon_installed('ocf_forum')) {
                    require_code('ocf_groups');
                    $rank_images = new ocp_tempcode();
                    $member_id = isset($param[0]) ? intval($param[0]) : get_member();
                    $posters_groups = $GLOBALS['FORUM_DRIVER']->get_members_groups($member_id, true);
                    foreach ($posters_groups as $group) {
                        $rank_image = ocf_get_group_property($group, 'rank_image');
                        $group_leader = ocf_get_group_property($group, 'group_leader');
                        $group_name = ocf_get_group_name($group);
                        $rank_image_pri_only = ocf_get_group_property($group, 'rank_image_pri_only');
                        if ($rank_image != '' && ($rank_image_pri_only == 0 || $group == $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_primary_group'))) {
                            $rank_images->attach(do_template('OCF_RANK_IMAGE', array('USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($member_id), 'GROUP_NAME' => $group_name, 'IMG' => $rank_image, 'IS_LEADER' => $group_leader == $member_id)));
                        }
                    }
                    $value = $rank_images->evaluate();
                }
                break;
            case 'TOTAL_POINTS':
                if (addon_installed('points')) {
                    require_code('points');
                    $value = strval(total_points(isset($param[0]) ? intval($param[0]) : get_member()));
                }
                break;
            case 'POINTS_USED':
                if (addon_installed('points')) {
                    require_code('points');
                    $value = strval(points_used(isset($param[0]) ? intval($param[0]) : get_member()));
                }
                break;
            case 'AVAILABLE_POINTS':
                if (addon_installed('points')) {
                    require_code('points');
                    $value = strval(available_points(isset($param[0]) ? intval($param[0]) : get_member()));
                }
                break;
            case 'URL_FOR_GET_FORM':
                if (isset($param[0])) {
                    $url_bits = parse_url($param[0]);
                    if (array_key_exists('scheme', $url_bits)) {
                        $value = $url_bits['scheme'] . '://' . (array_key_exists('host', $url_bits) ? $url_bits['host'] : 'localhost');
                        if (array_key_exists('port', $url_bits) && $url_bits['port'] != 80) {
                            $value .= ':' . strval($url_bits['port']);
                        }
                    }
                    if (array_key_exists('path', $url_bits)) {
                        $value .= $url_bits['path'];
                    }
                }
                break;
            case 'HIDDENS_FOR_GET_FORM':
                $_value = new ocp_tempcode();
                $url_bits = parse_url($param[0]);
                if (array_key_exists('query', $url_bits) && $url_bits['query'] != '') {
                    foreach (explode('&', $url_bits['query']) as $exp) {
                        $parts = explode('=', $exp, 2);
                        if (count($parts) == 2) {
                            if (!in_array($parts[0], $param)) {
                                $_value->attach(form_input_hidden($parts[0], urldecode($parts[1])));
                            }
                        }
                    }
                }
                $value = $_value->evaluate();
                break;
            case 'NOTIFICATIONS_ENABLED':
                $value = '';
                if (array_key_exists(0, $param)) {
                    require_code('notifications');
                    $value = notifications_enabled(array_key_exists(1, $param) ? $param[1] : get_page_name(), $param[0]) ? '1' : '0';
                }
                break;
            case 'DOCUMENT_HELP':
                global $DOCUMENT_HELP, $HELPER_PANEL_TUTORIAL;
                $value = $DOCUMENT_HELP;
                if ($value == '' && $HELPER_PANEL_TUTORIAL != '') {
                    $value = brand_base_url() . '/docs' . strval(ocp_version()) . '/pg/' . $HELPER_PANEL_TUTORIAL;
                }
                break;
            case 'HTTP_STATUS_CODE':
                global $HTTP_STATUS_CODE;
                $value = $HTTP_STATUS_CODE;
                break;
            case 'TEMPCODE':
                if (isset($param[0])) {
                    require_code('tempcode_compiler');
                    $_value = template_to_tempcode($param[0]);
                    $value = $_value->evaluate();
                }
                break;
            case 'COMCODE':
                if (isset($param[0])) {
                    $_value = comcode_to_tempcode($param[0], NULL, true);
                    $value = $_value->evaluate();
                }
                break;
            case 'FLAGRANT':
                $_value = get_flagrant();
                $value = $_value->evaluate();
                break;
            case 'IMG_WIDTH':
            case 'IMG_HEIGHT':
                if (isset($param[0]) && isset($GLOBALS['SITE_DB']) && function_exists('find_theme_image') && $GLOBALS['IN_MINIKERNEL_VERSION'] == 0) {
                    global $THEME_IMG_DIMS_CACHE;
                    if (!isset($THEME_IMG_DIMS_CACHE)) {
                        $THEME_IMG_DIMS_CACHE = function_exists('persistant_cache_get') ? persistant_cache_get('THEME_IMG_DIMS') : array();
                    }
                    if (isset($THEME_IMG_DIMS_CACHE[$param[0]])) {
                        list($width, $height) = $THEME_IMG_DIMS_CACHE[$param[0]];
                        $value = $name == 'IMG_WIDTH' ? $width : $height;
                    } else {
                        if (strpos($param[0], '://') === false) {
                            $img_url = find_theme_image($param[0], false, false, array_key_exists(2, $param) ? $param[2] : NULL, NULL, isset($param[1]) && $param[1] == '1' ? $GLOBALS['FORUM_DB'] : $GLOBALS['SITE_DB']);
                        } else {
                            $img_url = $param[0];
                        }
                        require_code('images');
                        list($width, $height) = _symbol_image_dims(array($img_url));
                        $value = $name == 'IMG_WIDTH' ? $width : $height;
                        $THEME_IMG_DIMS_CACHE[$param[0]] = array($width, $height);
                        if (function_exists('persistant_cache_set')) {
                            persistant_cache_set('THEME_IMG_DIMS', $THEME_IMG_DIMS_CACHE);
                        }
                    }
                }
                break;
            case 'CLEAN_FILE_SIZE':
                if (isset($param[0])) {
                    $bytes = is_numeric($param[0]) ? intval($param[0]) : NULL;
                    require_code('files');
                    $value = clean_file_size($bytes);
                }
                break;
            case 'TIME_PERIOD':
                if (isset($param[0])) {
                    $value = display_time_period(intval($param[0]));
                }
                break;
            case 'MAKE_RELATIVE_DATE':
                if (isset($param[0])) {
                    if (get_option('use_contextual_dates') == '0' && (!array_key_exists(1, $param) || $param[1] != '1')) {
                        $value = get_timezoned_date(intval($param[0]));
                    } else {
                        $value = display_time_period(time() - intval($param[0]));
                    }
                }
                break;
            case 'TIMEZONE':
                $value = make_nice_timezone_name(get_site_timezone());
                break;
            case 'LOAD_PAGE':
                foreach ($param as $i => $p) {
                    if (is_object($p)) {
                        $param[$i] = $p->evaluate();
                    }
                }
                global $LOADED_PAGES;
                if (strpos($param[0], ':') !== false) {
                    $param = array_reverse(explode(':', $param[0], 2));
                }
                $_value = $LOADED_PAGES[serialize($param)];
                $value = $_value->evaluate();
                break;
            case 'RUNNING_SCRIPT':
                if (isset($param[0])) {
                    $value = running_script($param[0]) ? '1' : '0';
                }
                break;
            case 'MATCH_KEY_MATCH':
                $value = '0';
                foreach ($param as $match_key) {
                    if ($match_key == '1' || $match_key == '0' || $match_key == '') {
                        continue;
                    }
                    if (match_key_match($match_key, isset($param[1]) && $match_key == '1')) {
                        $value = '1';
                    }
                }
                break;
            case 'VERSION':
                $value = strval(ocp_version());
                break;
            case 'PREVIEW_VALIDATION':
                $value = get_option('is_on_preview_validation') == '1' ? '1' : '0';
                break;
            case 'BLOCK':
                if (isset($GLOBALS['NON_CACHEABLE_SYMBOLS']['SET_RAND'])) {
                    foreach ($param as $i => $p) {
                        if (is_object($p)) {
                            $param[$i] = $p->evaluate();
                        }
                    }
                    if (count($param) == 1 && strpos($param[0], ',') !== false) {
                        $param = preg_split('#((?<!\\\\)|(?<=\\\\\\\\)|(?<=^)),#', $param[0]);
                        foreach ($param as $key => $val) {
                            $param[$key] = str_replace('\\,', ',', $val);
                        }
                    }
                    global $LOADED_BLOCKS;
                    if (isset($LOADED_BLOCKS[serialize($param)])) {
                        // Will always be set
                        $value = $LOADED_BLOCKS[serialize($param)]->evaluate();
                    }
                }
                break;
            case 'CURRENCY':
                if (addon_installed('ecommerce')) {
                    if (isset($param[0])) {
                        require_code('currency');
                        $value = currency_convert(floatval(str_replace(',', '', $param[0])), isset($param[1]) && $param[1] != '' ? $param[1] : get_option('currency'), isset($param[2]) && $param[2] != '' ? $param[2] : NULL, isset($param[3]) && $param[3] == '1');
                        if (is_null($value)) {
                            $value = do_lang('INTERNAL_ERROR');
                        }
                    } else {
                        $value = get_option('currency');
                    }
                }
                break;
            case 'CURRENCY_SYMBOL':
                if (addon_installed('ecommerce')) {
                    require_code('ecommerce');
                    $value = ecommerce_get_currency_symbol();
                }
                break;
            case 'GEOLOCATE':
                $value = geolocate_ip(isset($param[0]) ? $param[0] : NULL);
                break;
            case 'NO_SAFE_MODE':
                $value = str_replace(array('on', 'true', 'yes'), array('1', '1', '1'), strtolower(ini_get('safe_mode'))) == '1' ? '0' : '1';
                break;
            case 'FORCE_PREVIEWS':
                if (get_option('forced_preview_option') == '1') {
                    if (get_forum_type() == 'ocf') {
                        if (is_guest() && get_option('default_preview_guests') == '0') {
                            $value = '0';
                        } else {
                            $value = $GLOBALS['FORUM_DRIVER']->get_member_row_field(get_member(), 'm_preview_posts') == 1 ? '1' : '0';
                        }
                    } else {
                        $value = get_option('default_preview_guests') == '0' ? '0' : '1';
                    }
                } else {
                    $value = '0';
                }
                break;
            case 'PREVIEW_URL':
                $value = find_script('preview');
                $value .= '?page=' . get_page_name();
                $value .= '&type=' . get_param('type', '', true);
                break;
            case 'ADDON_INSTALLED':
                if (isset($param[0]) && !running_script('install')) {
                    $value = addon_installed($param[0]) ? '1' : '0';
                }
                break;
            case 'VALUE_OPTION':
                if (isset($param[0])) {
                    $value = function_exists('get_value') ? get_value($param[0]) : '';
                    if (is_null($value)) {
                        $value = function_exists('get_long_value') ? get_long_value($param[0]) : '';
                        if (is_null($value)) {
                            $value = isset($param[1]) ? $param[1] : '';
                            if ($param[0] == 'textmate' && (ocp_srv('HTTP_HOST') == 'localhost' && strpos(ocp_srv('HTTP_USER_AGENT'), 'Macintosh') !== false)) {
                                $value = '1';
                            }
                        }
                    }
                }
                break;
            case 'KEEP_INDEX':
                // What needs preserving in the URL
                $value = 'index.php';
                if (count($_GET) > 0) {
                    foreach ($_GET as $key => $val) {
                        if (is_array($val)) {
                            continue;
                        }
                        if (get_magic_quotes_gpc()) {
                            $val = stripslashes($val);
                        }
                        if (substr($key, 0, 5) == 'keep_' && !skippable_keep($key, $val) && strpos($key, '_expand_') === false) {
                            $value .= ($value == 'index.php' ? '?' : '&') . urlencode($key) . '=' . ocp_url_encode($val);
                        }
                    }
                }
                break;
            case 'HIDE_HELP_PANEL':
                $value = array_key_exists('hide_help_panel', $_COOKIE) && $_COOKIE['hide_help_panel'] == '1' ? '1' : '0';
                break;
            case 'URLISE_LANG':
                if (isset($param[1])) {
                    $_value = urlise_lang($param[0], $param[1], isset($param[2]) ? $param[2] : '', isset($param[3]) ? $param[3] == '1' : false);
                    $value = $_value->evaluate();
                }
                break;
            case 'FIND_SCRIPT_NOHTTP':
                if (isset($param[0]) && function_exists('find_script')) {
                    $value = preg_replace('#^https?://[^/]+#', '', find_script($param[0], false, isset($param[1]) ? intval($param[1]) : 0));
                }
                if (!$GLOBALS['DEBUG_MODE']) {
                    break;
                }
                // Debug mode changes base domain so we need to actually use it in full (fine, we don't have HTTPS in debug mode). Bubble on...
            // Debug mode changes base domain so we need to actually use it in full (fine, we don't have HTTPS in debug mode). Bubble on...
            case 'FIND_SCRIPT':
                if (isset($param[0]) && function_exists('find_script')) {
                    $value = find_script($param[0], false, isset($param[1]) ? intval($param[1]) : 0);
                }
                break;
            case 'MOBILE':
                $value = is_mobile(NULL, array_key_exists(0, $param) ? $param[0] == '1' : false) ? '1' : '0';
                break;
            case 'VALID_FILE_TYPES':
                $value = get_option('valid_types');
                $types = array_flip(explode(',', $value));
                $value = '';
                ksort($types);
                foreach (array_flip($types) as $val) {
                    $value .= $val . ',';
                }
                $value = substr($value, 0, strlen($value) - 1);
                break;
            case 'BROWSER_UA':
                $browser = get_browser_string();
                $value = $browser;
                break;
            case 'OS':
                $os = get_os_string();
                if (is_null($os)) {
                    $os = '';
                }
                $value = $os;
                break;
            case 'ANCHOR':
                if (isset($param[0])) {
                    $_value = do_template('ANCHOR', array('_GUID' => '8795c70c9dd7c6217bb765264ac24092', 'NAME' => $param[0]));
                    $value = $_value->evaluate();
                }
                break;
            case 'CSS_TEMPCODE':
                $_value = css_tempcode();
                $value = $_value->evaluate();
                break;
            case 'JS_TEMPCODE':
                $_value = javascript_tempcode(isset($param[0]) ? $param[0] : NULL);
                $value = $_value->evaluate();
                break;
            case 'PAD_LEFT':
                if (array_key_exists(1, $param)) {
                    $value = str_pad($param[0], intval($param[1]), array_key_exists(2, $param) ? $param[2] : '', STR_PAD_LEFT);
                }
                break;
            case 'PAD_RIGHT':
                if (array_key_exists(1, $param)) {
                    $value = str_pad($param[0], intval($param[1]), array_key_exists(2, $param) ? $param[2] : '', STR_PAD_RIGHT);
                }
                break;
            case 'PAGE_TITLE':
                $value = is_null($DISPLAYED_TITLE) ? '' : $DISPLAYED_TITLE->evaluate();
                break;
            case 'SET_TITLE':
                if (array_key_exists(0, $param)) {
                    get_page_title($param[0], false);
                }
                break;
            case 'EXTRA_HEAD':
                $_value = $GLOBALS['EXTRA_HEAD'];
                if ($_value === NULL) {
                    $_value = new ocp_tempcode();
                }
                $value = $_value->evaluate();
                break;
            case 'EXTRA_FOOT':
                if ($GLOBALS['EXTRA_FOOT'] === NULL) {
                    $GLOBALS['EXTRA_FOOT'] = new ocp_tempcode();
                }
                $_value = $GLOBALS['EXTRA_FOOT'];
                if (array_key_exists(0, $param)) {
                    $GLOBALS['EXTRA_FOOT']->attach($param[0]);
                } else {
                    $value = $_value->evaluate();
                }
                break;
            case 'RAND':
                if (isset($GLOBALS['NON_CACHEABLE_SYMBOLS']['RAND'])) {
                    $GLOBALS['NO_EVAL_CACHE'] = true;
                    $value = strval(mt_rand(0, 32000));
                } else {
                    $value = '4';
                }
                break;
            case 'SET_RAND':
                if (isset($param[0])) {
                    if (isset($GLOBALS['NON_CACHEABLE_SYMBOLS']['SET_RAND'])) {
                        $GLOBALS['NO_EVAL_CACHE'] = true;
                        $value = $param[mt_rand(0, count($param) - 1)];
                    } else {
                        $value = $param[0];
                    }
                }
                break;
            case 'COPYRIGHT':
                $value = str_replace('$CURRENT_YEAR', date('Y'), get_option('copyright'));
                break;
            case 'KEYWORDS_SPACED':
                $value = str_replace(',', ' ', get_option('keywords'));
                break;
            case 'STAFF_ADDRESS_PURE':
                $value = get_option('staff_address');
                break;
            case 'STAFF_ADDRESS':
                require_code('obfuscate');
                $value = obfuscate_email_address(get_option('staff_address'));
                break;
            case 'DOMAIN':
                $value = get_domain();
                break;
            case 'BRAND_NAME':
                $value = function_exists('get_value') ? get_value('rebrand_name') : NULL;
                if (is_null($value)) {
                    $value = 'ocPortal';
                }
                break;
            case 'BRAND_BASE_URL':
                $value = brand_base_url();
                break;
            case 'SHOW_DOCS':
                $value = get_option('show_docs') === '0' ? '0' : '1';
                break;
            case 'MEMBER_EMAIL':
                $value = $GLOBALS['FORUM_DRIVER']->get_member_email_address(isset($param[0]) ? intval($param[0]) : get_member());
                break;
            case 'OCF_MEMBER_HTML':
                if (get_forum_type() == 'ocf') {
                    require_code('ocf_members');
                    require_code('ocf_members2');
                    $_value = ocf_show_member_box(isset($param[0]) ? intval($param[0]) : get_member());
                    $value = $_value->evaluate();
                }
                break;
            case 'HAS_SPECIFIC_PERMISSION':
                if (isset($param[0])) {
                    $value = has_specific_permission(!is_null($param) && isset($param[1]) ? intval($param[1]) : get_member(), $param[0]) ? '1' : '0';
                }
                break;
            case 'HAS_ZONE_ACCESS':
                if (isset($param[0])) {
                    $value = has_zone_access(!is_null($param) && isset($param[1]) ? intval($param[1]) : get_member(), $param[0]) ? '1' : '0';
                }
                break;
            case 'HAS_PAGE_ACCESS':
                if (isset($param[0]) && isset($param[1])) {
                    $value = has_page_access(!is_null($param) && isset($param[2]) ? intval($param[2]) : get_member(), $param[0], $param[1], !is_null($param) && isset($param[3]) ? $param[3] == '1' : false) ? '1' : '0';
                }
                break;
            case 'HAS_CATEGORY_ACCESS':
                if (isset($param[0])) {
                    $value = has_category_access(!is_null($param) && isset($param[2]) ? intval($param[2]) : get_member(), $param[0], $param[1]) ? '1' : '0';
                }
                break;
            case 'HAS_ATTACHMENT_ACCESS':
                if (isset($param[0])) {
                    require_code('attachments');
                    $value = has_attachment_access(!is_null($param) && isset($param[1]) ? intval($param[1]) : get_member(), $param[0]) ? '1' : '0';
                }
                break;
            case 'HAS_SUBMIT_PERMISSION':
                if (isset($param[0]) && (strtolower($param[0]) == 'low' || strtolower($param[0]) == 'mid' || strtolower($param[0]) == 'high')) {
                    $value = has_submit_permission(strtolower($param[0]), !is_null($param) && isset($param[1]) ? intval($param[1]) : get_member(), !is_null($param) && isset($param[2]) ? $param[2] : get_ip_address(), !is_null($param) && isset($param[3]) ? $param[3] : get_page_name()) ? '1' : '0';
                }
                break;
            case 'HAS_DELETE_PERMISSION':
                if (isset($param[0]) && (strtolower($param[0]) == 'low' || strtolower($param[0]) == 'mid' || strtolower($param[0]) == 'high') && isset($param[1])) {
                    $value = has_delete_permission(strtolower($param[0]), !is_null($param) && isset($param[2]) ? intval($param[2]) : get_member(), intval($param[1]), !is_null($param) && isset($param[3]) ? $param[3] : get_page_name()) ? '1' : '0';
                }
                break;
            case 'HAS_EDIT_PERMISSION':
                if (isset($param[0]) && (strtolower($param[0]) == 'low' || strtolower($param[0]) == 'mid' || strtolower($param[0]) == 'high') && isset($param[1])) {
                    $value = has_edit_permission(strtolower($param[0]), !is_null($param) && isset($param[2]) ? intval($param[2]) : get_member(), intval($param[1]), !is_null($param) && isset($param[3]) ? $param[3] : get_page_name()) ? '1' : '0';
                }
                break;
            case 'ENTITY_DECODE':
                if (isset($param[0])) {
                    $value = @html_entity_decode($param[0], ENT_QUOTES, get_charset());
                }
                break;
            case 'RESET_CYCLE':
                if (isset($param[0])) {
                    $CYCLES[$param[0]] = 0;
                }
                break;
            case 'SITE_SCOPE':
                $value = get_option('site_scope');
                break;
            case 'LAST_VISIT_TIME':
                if (get_forum_type() == 'ocf') {
                    $member_info = ocf_read_in_member_profile(get_member(), true);
                    $value = strval($member_info['last_visit_time']);
                }
                break;
            case 'NUM_NEW_TOPICS':
                if (get_forum_type() == 'ocf') {
                    $member_info = ocf_read_in_member_profile(get_member(), true);
                    $_new_topics = $GLOBALS['FORUM_DB']->query('SELECT COUNT(*) AS mycnt FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics WHERE NOT t_forum_id IS NULL AND t_cache_first_time>' . strval((int) $member_info['last_visit_time']));
                    $new_topics = $_new_topics[0]['mycnt'];
                    $value = strval($new_topics);
                }
                break;
            case 'NUM_NEW_POSTS':
                if (get_forum_type() == 'ocf') {
                    $member_info = ocf_read_in_member_profile(get_member(), true);
                    $_new_posts = $GLOBALS['FORUM_DB']->query('SELECT COUNT(*) AS mycnt FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE NOT p_cache_forum_id IS NULL AND p_time>' . strval((int) $member_info['last_visit_time']));
                    $new_posts = $_new_posts[0]['mycnt'];
                    $value = strval($new_posts);
                }
                break;
            case 'HAS_FORUM':
                $value = has_no_forum() ? '0' : '1';
                break;
            case 'OCF':
                $value = get_forum_type() == 'ocf' ? '1' : '0';
                break;
            case 'BOARD_PREFIX':
                $value = get_forum_base_url();
                break;
            case 'DATE_AND_TIME':
                $use_contextual_dates = isset($param[0]) && $param[0] == '1';
                $verbose = isset($param[1]) && $param[1] == '1';
                $server_time = isset($param[2]) && $param[2] == '1';
                $time = isset($param[3]) ? intval($param[3]) : time();
                $value = get_timezoned_date($time, true, $verbose, $server_time, !$use_contextual_dates);
                break;
            case 'DATE':
                $use_contextual_dates = isset($param[0]) && $param[0] == '1';
                $verbose = isset($param[1]) && $param[1] == '1';
                $server_time = isset($param[2]) && $param[2] == '1';
                $time = isset($param[3]) ? intval($param[3]) : time();
                $value = get_timezoned_date($time, false, $verbose, $server_time, !$use_contextual_dates);
                break;
            case 'TIME':
                $time = isset($param[0]) ? intval($param[0]) : time();
                $value = get_timezoned_time($time);
                break;
            case 'SECONDS_PERIOD':
                if (array_key_exists(0, $param)) {
                    $value = display_seconds_period(intval($param[0]));
                }
                break;
            case 'FROM_TIMESTAMP':
                if (isset($param[0])) {
                    $timestamp = isset($param[1]) ? intval($param[1]) : time();
                    if (!array_key_exists(2, $param) || $param[2] == '1') {
                        $timestamp = utctime_to_usertime($timestamp);
                    }
                    $value = locale_filter(my_strftime($param[0], $timestamp));
                    if ($value == $param[0]) {
                        // If no conversion happened then the syntax must have been for 'date' not 'strftime'
                        $value = date($param[0], $timestamp);
                    }
                } else {
                    $timestamp = time();
                    $value = strval($timestamp);
                }
                break;
            case 'TO_TIMESTAMP':
                if (isset($param[0])) {
                    $value = strval(strtotime($param[0]));
                    if (array_key_exists(1, $param) && $param[1] == '1') {
                        $value = strval(usertime_to_utctime(intval($value)));
                    }
                    // '1' means date was in user-time so needs converting to a UTC timestamp
                } else {
                    $value = strval(time());
                }
                break;
            case 'SESSION_HASHED':
                $value = md5(strval(get_session_id()));
                break;
            case 'SESSION':
                $value = strval(get_session_id());
                break;
            case 'IN_ARRAY':
                if (isset($param[1])) {
                    $array = array_slice($param, 1);
                    $value = in_array($param[0], $array) ? '1' : '0';
                }
                break;
            case 'MULT':
                if (isset($param[1])) {
                    $value = float_to_raw_string(floatval($param[0]) * floatval($param[1]), 2, true);
                }
                break;
            case 'ROUND':
                if (isset($param[0])) {
                    $amount = isset($param[1]) ? intval($param[1]) : 0;
                    if ($amount > 0) {
                        $value = float_format(floatval($param[0]), $amount);
                    } else {
                        $value = strval(intval(round(floatval($param[0]), $amount)));
                    }
                }
                break;
            case 'DEV_MODE':
                $value = $GLOBALS['DEBUG_MODE'] ? '1' : '0';
                break;
            case 'BROWSER_MATCHES':
                if (isset($param[0])) {
                    $q = false;
                    foreach (explode('|', $param[0]) as $browser) {
                        $q = browser_matches($browser);
                        if ($q) {
                            break;
                        }
                    }
                    $value = $q ? '1' : '0';
                }
                break;
            case 'ISSET':
                if (isset($param[0])) {
                    $value = isset($TEMPCODE_SETGET[$param[0]]) ? '1' : '0';
                }
                break;
            case 'INIT':
                if (isset($param[1])) {
                    if (!isset($TEMPCODE_SETGET[$param[0]])) {
                        $TEMPCODE_SETGET[$param[0]] = $param[1];
                    }
                }
                break;
            case 'INC':
                if (isset($param[0])) {
                    if (!isset($TEMPCODE_SETGET[$param[0]])) {
                        $TEMPCODE_SETGET[$param[0]] = '0';
                    }
                    $TEMPCODE_SETGET[$param[0]] = strval(intval($TEMPCODE_SETGET[$param[0]]) + 1);
                }
                break;
            case 'DEC':
                if (isset($param[0])) {
                    if (!isset($TEMPCODE_SETGET[$param[0]])) {
                        $TEMPCODE_SETGET[$param[0]] = '0';
                    }
                    $TEMPCODE_SETGET[$param[0]] = strval(intval($TEMPCODE_SETGET[$param[0]]) - 1);
                }
                break;
            case 'PREG_MATCH':
                if (isset($param[1])) {
                    $value = preg_match('#' . str_replace('#', '\\#', $param[0]) . '#' . (isset($param[2]) ? str_replace('e', '', $param[2]) : ''), $param[1]) != 0 ? '1' : '0';
                }
                break;
            case 'PREG_REPLACE':
                if (isset($param[2])) {
                    $value = preg_replace('#' . str_replace('#', '\\#', $param[0]) . '#' . (isset($param[3]) ? str_replace('e', '', $param[3]) : ''), $param[1], $param[2]);
                }
                break;
            case 'MAX':
                if (isset($param[0])) {
                    $value = strval(max(intval($param[0]), intval($param[1])));
                }
                break;
            case 'MIN':
                if (isset($param[0])) {
                    $value = strval(min(intval($param[0]), intval($param[1])));
                }
                break;
            case 'MOD':
                if (isset($param[0])) {
                    $value = strval(max(intval($param[0]), -intval($param[0])));
                }
                break;
            case 'REM':
                if (isset($param[1])) {
                    $value = strval(intval($param[0]) % intval($param[1]));
                }
                break;
            case 'DIV_FLOAT':
                if (isset($param[1])) {
                    $value = float_to_raw_string(floatval($param[0]) / floatval($param[1]), 2, true);
                }
                break;
            case 'DIV':
                if (isset($param[1])) {
                    $value = strval(intval(floor(floatval($param[0]) / floatval($param[1]))));
                }
                break;
            case 'SUBTRACT':
                if (isset($param[1])) {
                    $value = float_to_raw_string(floatval(str_replace(',', '', $param[0])) - floatval(str_replace(',', '', $param[1])), 2, true);
                }
                break;
            case 'ADD':
                if (isset($param[1])) {
                    $value = float_to_raw_string(floatval(str_replace(',', '', $param[0])) + floatval(str_replace(',', '', $param[1])), 2, true);
                }
                break;
            case 'WCASE':
                if (isset($param[0])) {
                    $value = ucwords($param[0]);
                }
                break;
            case 'LCASE':
                if (isset($param[0])) {
                    $value = ocp_mb_strtolower($param[0]);
                }
                break;
            case 'UCASE':
                if (isset($param[0])) {
                    $value = ocp_mb_strtoupper($param[0]);
                }
                break;
            case '_POST':
                if (isset($param[0])) {
                    $value = post_param($param[0], isset($param[1]) ? $param[1] : '');
                }
                break;
            case 'REPLACE':
                if (isset($param[2])) {
                    $value = str_replace($param[0], $param[1], $param[2]);
                    if ($GLOBALS['XSS_DETECT'] && ocp_is_escaped($param[0])) {
                        ocp_mark_as_escaped($value);
                    }
                }
                break;
            case 'AT':
                if (isset($param[1])) {
                    $value = ocp_mb_substr($param[0], intval($param[1]), 1);
                }
                break;
            case 'STRPOS':
                if (isset($param[1])) {
                    $t_value = strpos($param[0], $param[1]);
                    $value = $t_value === false ? '0' : strval($t_value);
                }
                break;
            case 'IN_STR':
                if (isset($param[1])) {
                    if ($param[1] == '') {
                        $value = '0';
                    } else {
                        $value = '0';
                        foreach ($param as $i => $check) {
                            if (is_integer($i) && $i != 0 && $check != '') {
                                if (strpos($param[0], $check) !== false) {
                                    $value = '1';
                                    break;
                                }
                            }
                        }
                    }
                }
                break;
            case 'SUBSTR_COUNT':
                if (isset($param[1])) {
                    $value = strval(substr_count($param[0], $param[1]));
                }
                break;
            case 'SUBSTR':
                if (isset($param[1])) {
                    $value = ocp_mb_substr($param[0], intval($param[1]), isset($param[2]) ? intval($param[2]) : strlen($param[0]));
                }
                break;
            case 'LENGTH':
                if (isset($param[0])) {
                    $value = strval(ocp_mb_strlen($param[0]));
                }
                break;
            case 'WORDWRAP':
                if (isset($param[1])) {
                    $cut = isset($param[3]) && $param[3] == '1';
                    $value = wordwrap($param[0], intval($param[1]), isset($param[2]) ? $param[2] : '<br />', $cut);
                    if ($GLOBALS['XSS_DETECT'] && ocp_is_escaped($param[0])) {
                        ocp_mark_as_escaped($value);
                    }
                }
                break;
            case 'ALTERNATOR_TRUNCATED':
                // Alternate values according to whether some given text WOULD have been truncated. 0: text to check against, 1: the truncate length, 2:IF would not be do this, 3: if it would be do this, 4: whether given text is encoded as HTML (0=no [default, plain-text], 1=yes)
                if (isset($param[3])) {
                    $amount = intval($param[1]);
                    $is_html = isset($param[4]) && $param[4] == '1';
                    if (strlen($is_html ? strip_tags($param[0]) : $param[0]) > $amount) {
                        $value = $param[3];
                    } else {
                        $value = $param[2];
                    }
                }
                break;
            case 'ESCAPE':
                if (isset($param[0])) {
                    $d_escaping = array(isset($param[1]) ? constant($param[1]) : ENTITY_ESCAPED);
                    if (is_string($param[0])) {
                        apply_tempcode_escaping($d_escaping, $param[0]);
                    }
                    $value = $param[0];
                }
                break;
            case 'COOKIE_PATH':
                $value = function_exists('get_cookie_path') ? get_cookie_path() : '/';
                break;
            case 'COOKIE_DOMAIN':
                $s_value = function_exists('get_cookie_domain') ? get_cookie_domain() : '';
                $value = is_null($s_value) ? '' : $s_value;
                break;
            case 'IS_A_COOKIE_LOGIN':
                global $IS_A_COOKIE_LOGIN;
                $value = $IS_A_COOKIE_LOGIN && ini_get('suhosin.cookie.max_name_length') !== '64' ? '1' : '0';
                break;
            case 'GROUP_ID':
                if (isset($param[0])) {
                    $groups = $GLOBALS['FORUM_DRIVER']->get_members_groups(isset($param[1]) ? intval($param[1]) : get_member());
                    $value = array_key_exists(intval($param[0]), $groups) ? strval($groups[intval($param[0])]) : '';
                }
                break;
            case 'GROUP_NAME':
                if (isset($param[0])) {
                    $groups = $GLOBALS['FORUM_DRIVER']->get_members_groups(isset($param[1]) ? intval($param[1]) : get_member());
                    if (array_key_exists(intval($param[0]), $groups)) {
                        $all_usergroups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list();
                        $value = $all_usergroups[$groups[intval($param[0])]];
                    }
                    if ($GLOBALS['XSS_DETECT'] && ocp_is_escaped($param[0])) {
                        ocp_mark_as_escaped($value);
                    }
                }
                break;
            case 'NEGATE':
                if (isset($param[0])) {
                    $value = strval(-intval($param[0]));
                }
                break;
            case 'XOR':
                $count = 0;
                foreach ($param as $test) {
                    if ($test == '1' || $test == '1') {
                        $count++;
                    }
                }
                $value = $count == 1 ? '1' : '0';
                break;
            case 'NOR':
                $count = 0;
                foreach ($param as $test) {
                    if ($test == '1' || $test == '1') {
                        $count++;
                    }
                }
                $value = $count > 0 ? '0' : '1';
                break;
            case 'NAND':
                $count = 0;
                foreach ($param as $test) {
                    if ($test == '1' || $test == '1') {
                        $count++;
                    }
                }
                $value = $count == count($param) ? '0' : '1';
                break;
            case 'LT':
                if (isset($param[1])) {
                    $value = intval($param[0]) < intval($param[1]) ? '1' : '0';
                }
                break;
            case 'GT':
                if (isset($param[1])) {
                    $value = intval($param[0]) > intval($param[1]) ? '1' : '0';
                }
                break;
            case 'COPPA_ON':
                $value = get_option('is_on_coppa') == '1' ? '1' : '0';
                break;
            case 'OBFUSCATE':
                if (isset($param[0])) {
                    require_code('obfuscate');
                    $value = obfuscate_entities($param[0]);
                }
                break;
            case 'FIX_ID':
                if (isset($param[0])) {
                    $value = fix_id($param[0]);
                    if ($GLOBALS['XSS_DETECT']) {
                        ocp_mark_as_escaped($value);
                    }
                }
                break;
            case 'MAILTO':
                require_code('obfuscate');
                $value = mailto_obfuscated();
                break;
            case 'INLINE_STATS':
                $value = get_option('show_inline_stats') == '1' ? '1' : '0';
                break;
            case 'ATTACHMENT_DOWNLOADS':
                if (isset($param[0])) {
                    $db = $GLOBALS['SITE_DB'];
                    if (isset($param[1]) && $param[1] == '1') {
                        $db = $GLOBALS['FORUM_DB'];
                    }
                    $_value = $db->query_value_null_ok('attachments', 'a_num_downloads', array('id' => intval($param[0])));
                    $value = is_null($_value) ? '?' : strval($_value);
                }
                break;
            case 'CSS_DIMENSION_REDUCE':
                if (isset($param[1])) {
                    $value = $param[0];
                    if (substr($value, -2) == 'px') {
                        $b = $param[1];
                        $value = strval(intval(substr($value, 0, -2)) - intval($b)) . 'px';
                    }
                    if ($value == '') {
                        $value = '0px';
                    }
                }
                break;
            case 'COMMENT_COUNT':
                if (isset($param[1])) {
                    if (get_option('is_on_comments') == '1') {
                        $count = 0;
                        $_comments = $GLOBALS['FORUM_DRIVER']->get_forum_topic_posts($GLOBALS['FORUM_DRIVER']->find_topic_id_for_topic_identifier(get_option('comments_forum_name'), $param[0] . '_' . $param[1]), $count, 0, 0, false);
                        $_value = do_lang_tempcode('_COMMENTS', integer_format(0));
                        if (is_array($_comments)) {
                            $_value = do_lang_tempcode('_COMMENTS', escape_html(integer_format($count)));
                        }
                        $value = $_value->evaluate();
                    } else {
                        $value = do_lang('VIEW');
                    }
                }
                break;
            case 'CAN_SPELLCHECK':
                $value = function_exists('pspell_check') ? '1' : '0';
                break;
            case 'AWARD_ID':
                if (array_key_exists(0, $param)) {
                    $value = $GLOBALS['SITE_DB']->query_value_null_ok('award_archive', 'content_id', array('a_type_id' => intval($param[0])), 'ORDER BY date_and_time DESC');
                    if (is_null($value)) {
                        $value = '';
                    }
                }
                break;
            case 'SELF_PAGE_LINK':
                $value = '';
                if (running_script('index') || running_script('iframe')) {
                    $value = get_zone_name() . ':' . get_page_name();
                    foreach ($_GET as $key => $val) {
                        if ($key == 'page') {
                            continue;
                        }
                        if (is_array($val)) {
                            continue;
                        }
                        if (substr($key, 0, 5) == 'keep_') {
                            continue;
                        }
                        $value .= ':' . $key . '=' . $val;
                    }
                }
                break;
            case 'SET_TUTORIAL_LINK':
                $value = '';
                if (array_key_exists(1, $param) && $param[1] != '' && $param[1][0] != '#') {
                    set_tutorial_link($param[0], $param[1]);
                }
                break;
            case 'DISPLAY_CONCEPT':
                $value = '';
                if (array_key_exists(0, $param)) {
                    $key = $param[0];
                    $page_link = get_tutorial_link('concept___' . preg_replace('#[^\\w_]#', '_', $key));
                    if (is_null($page_link)) {
                        $temp_tpl = make_string_tempcode($key);
                    } else {
                        list($zone, $attributes, $hash) = page_link_decode($page_link);
                        $_url = build_url($attributes, $zone, NULL, false, false, false, $hash);
                        $temp_tpl = do_template('COMCODE_CONCEPT', array('_GUID' => 'ee0cd05f87329923f05145180004d8a8', 'TEXT' => $key, 'URL' => $_url));
                    }
                    $value = $temp_tpl->evaluate();
                }
                break;
            case 'SELF_URL':
                $extra_params = NULL;
                if (isset($param[3])) {
                    $extra_params = array();
                    $i = 3;
                    while (isset($param[$i])) {
                        $bits = explode('=', $param[$i], 2);
                        if ($bits[1] == '<null>') {
                            $bits[1] = NULL;
                        }
                        $extra_params[$bits[0]] = $bits[1];
                        $i++;
                    }
                }
                $value = get_self_url(true, isset($param[0]) && $param[0] == '1', $extra_params, isset($param[1]) && $param[1] == '1', isset($param[2]) && $param[2] == '1');
                break;
            case 'SHIFT_DECODE':
                if (isset($param[0])) {
                    global $SHIFT_VARIABLES;
                    $key = $param[0];
                    $value = isset($SHIFT_VARIABLES[$key]) ? $SHIFT_VARIABLES[$key]->evaluate() : '';
                }
                break;
            case 'NUMBER_FORMAT':
                if (isset($param[0])) {
                    $value = integer_format(intval($param[0]));
                }
                break;
            case 'FLOAT_FORMAT':
                if (isset($param[0])) {
                    $value = float_format(floatval($param[0]));
                }
                break;
            case 'CURRENTLY_INVISIBLE':
                $value = is_invisible() ? '1' : '0';
                break;
            case 'IS_FRIEND':
                if (isset($param[0])) {
                    $test = $GLOBALS['SITE_DB']->query_value_null_ok('chat_buddies', 'member_likes', array('member_likes' => isset($param[1]) ? intval($param[1]) : get_member(), 'member_liked' => intval($param[0])));
                    $value = is_null($test) ? '0' : '1';
                }
                break;
            case 'SSW':
                $value = get_option('ssw') == '1' ? '1' : '0';
                break;
            case 'RATING':
                if (isset($param[1])) {
                    require_code('feedback');
                    $rating = get_rating_simple_array(array_key_exists(3, $param) ? $param[3] : get_self_url(true), array_key_exists(4, $param) ? $param[4] : (is_null($DISPLAYED_TITLE) ? '' : $DISPLAYED_TITLE->evaluate()), $param[0], $param[1], array_key_exists(5, $param) ? $param[5] : 'RATING_FORM', array_key_exists(2, $param) ? $param[2] : NULL);
                    if ($rating !== NULL) {
                        if (!array_key_exists(2, $param) || $param[2] == '0') {
                            $value = isset($rating['ALL_RATING_CRITERIA'][0]['RATING']) ? $rating['ALL_RATING_CRITERIA'][0]['RATING'] : '';
                        } else {
                            $value = do_template('RATING_INLINE_STATIC', $rating);
                        }
                        if (is_object($value)) {
                            $value = $value->evaluate();
                        }
                    }
                }
                break;
            case 'VIEWS':
                if (isset($param[2])) {
                    $id_field = 'id';
                    // Not allowed for security reasons
                    if (preg_match('#^\\w*views\\w*$#', $param[1]) != 0) {
                        $test = $GLOBALS['SITE_DB']->query_value_null_ok($param[0], $param[1], array($id_field => $param[2]));
                        if (!is_null($test)) {
                            $value = integer_format($test);
                        }
                    }
                }
                break;
            default:
                global $EXTRA_SYMBOLS;
                if (is_null($EXTRA_SYMBOLS)) {
                    $EXTRA_SYMBOLS = array();
                    $hooks = find_all_hooks('systems', 'symbols');
                    foreach (array_keys($hooks) as $hook) {
                        $EXTRA_SYMBOLS[$hook] = array();
                    }
                }
                if (array_key_exists($name, $EXTRA_SYMBOLS)) {
                    if (!array_key_exists('ob', $EXTRA_SYMBOLS[$name])) {
                        require_code('hooks/systems/symbols/' . filter_naughty_harsh($name));
                        $EXTRA_SYMBOLS[$name]['ob'] = object_factory('Hook_symbol_' . filter_naughty_harsh($name));
                    }
                    $value = $EXTRA_SYMBOLS[$name]['ob']->run($param);
                    break;
                }
                if (defined($name)) {
                    $value = @strval(constant($name));
                    break;
                }
                $value = '';
                require_code('site');
                attach_message(do_lang_tempcode('MISSING_SYMBOL', escape_html($name)), 'warn');
        }
        if ($escaped != array()) {
            if (is_object($value)) {
                $value = $value->evaluate();
            }
            apply_tempcode_escaping($escaped, $value);
        }
        if ($cacheable) {
            $SYMBOL_CACHE[$escaped_codes] = $value;
        }
        return $value;
    }
    // Is it a directive?
    if ($type == TC_DIRECTIVE) {
        $value = '';
        if ($GLOBALS['XSS_DETECT']) {
            ocp_mark_as_escaped($value);
        }
        // In our param we should have a map of bubbled template parameters (under 'vars') and our numbered directive parameters
        if ($param === NULL) {
            $param = array();
        }
        // Closure-based Tempcode parser may send in strings, so we need to adapt...
        foreach ($param as $key => $val) {
            if (is_string($val)) {
                $param[$key] = make_string_tempcode($val);
            }
        }
        if (!isset($param['vars'])) {
            $param['vars'] = array();
        }
        switch ($name) {
            case 'SHIFT_ENCODE':
                break;
            case 'PARAM_INFO':
                $_value = do_template('PARAM_INFO', array('MAP' => $param['vars']));
                $value = $_value->evaluate();
                break;
            case 'CSS_INHERIT':
                // e.g. {+START,CSS_INHERIT,global,default,#886aa9}{+END}
                if (isset($param[0])) {
                    require_code('css_and_js');
                    $css_file = $param[0]->evaluate();
                    $theme = isset($param[1]) ? $param[1]->evaluate() : 'default';
                    $seed = isset($param[2]) ? $param[2]->evaluate() : NULL;
                    if ($seed == '') {
                        $seed = NULL;
                    }
                    $dark = isset($param[3]) ? $param[3]->evaluate() == '1' : false;
                    $algorithm = isset($param[4]) ? $param[4]->evaluate() : 'equations';
                    $value = css_inherit($css_file, $theme, $GLOBALS['FORUM_DRIVER']->get_theme(), $seed, $dark, $algorithm);
                }
                break;
            case 'FRACTIONAL_EDITABLE':
                foreach (array_keys($param) as $key) {
                    if (!is_numeric($key)) {
                        unset($param[$key]);
                    }
                }
                if (isset($param[3])) {
                    $edit_text = $param[0]->evaluate();
                    $edit_param_name = $param[1]->evaluate();
                    $edit_pagelink = $param[2]->evaluate();
                    $supports_comcode = (isset($param[4]) ? $param[3]->evaluate() : '0') == '1';
                    list($zone, $attributes, ) = page_link_decode($edit_pagelink);
                    if ($zone == '_SEARCH') {
                        $zone = get_module_zone($attributes['page']);
                    }
                    if (has_actual_page_access(get_member(), $attributes['page'], $zone) && has_zone_access(get_member(), 'adminzone')) {
                        $keep = symbol_tempcode('KEEP');
                        $url = find_script('fractional_edit') . '?edit_param_name=' . urlencode($edit_param_name) . '&supports_comcode=' . ($supports_comcode ? '1' : '0') . '&zone=' . urlencode($zone) . $keep->evaluate();
                        foreach ($attributes as $key => $val) {
                            $url .= '&' . $key . '=' . urlencode($val);
                        }
                        $_value = $param[count($param) - 1];
                        $_value = do_template('FRACTIONAL_EDIT', array('_GUID' => '075ac126c427d28b309004bc67b32b08', 'VALUE' => $_value, 'URL' => $url, 'EDIT_TEXT' => $edit_text, 'EDIT_PARAM_NAME' => $edit_param_name));
                        $value = $_value->evaluate();
                    } else {
                        $value = $param[count($param) - 1]->evaluate();
                    }
                }
                break;
            case 'SET':
                if (isset($param[1])) {
                    $var = $param[0]->evaluate();
                    $set_val = '';
                    $i = 1;
                    while (isset($param[$i])) {
                        if ($i != 1) {
                            $set_val .= ',';
                        }
                        $set_val .= $param[1]->evaluate();
                        $i++;
                    }
                    $TEMPCODE_SETGET[$var] = $set_val;
                }
                break;
            case 'IN_ARRAY':
                if (isset($param[1])) {
                    $key = $param[1]->evaluate();
                    $array = array_key_exists($key, $param['vars']) ? $param['vars'][$key] : array();
                    $value = in_array($param[0]->evaluate(), $array) ? '1' : '0';
                }
                break;
            case 'NOT_IN_ARRAY':
                if (isset($param[1])) {
                    $key = $param[1]->evaluate();
                    $array = array_key_exists($key, $param['vars']) ? $param['vars'][$key] : array();
                    $value = in_array($param[0]->evaluate(), $array) ? '0' : '1';
                }
                break;
            case 'IF_IN_ARRAY':
                if (isset($param[2])) {
                    $key = $param[1]->evaluate();
                    $array = array_key_exists($key, $param['vars']) ? $param['vars'][$key] : array();
                    $value = in_array($param[0]->evaluate(), $array) ? $param[2]->evaluate() : '';
                }
                break;
            case 'IF_NOT_IN_ARRAY':
                if (isset($param[2])) {
                    $key = $param[1]->evaluate();
                    $array = array_key_exists($key, $param['vars']) ? $param['vars'][$key] : array();
                    $value = in_array($param[0]->evaluate(), $array) ? '' : $param[2]->evaluate();
                }
                break;
            case 'IMPLODE':
                if (isset($param[1])) {
                    $key = $param[1]->evaluate();
                    $array = array_key_exists($key, $param['vars']) ? $param['vars'][$key] : array();
                    if (isset($param[2]) && $param[2]->evaluate() == '1') {
                        $delim = $param[0]->evaluate();
                        foreach ($array as $key => $val) {
                            if ($value != '') {
                                $value .= $delim;
                            }
                            $value .= (is_integer($key) ? integer_format($key) : $key) . ' = ' . $val;
                        }
                    } else {
                        $value = implode($param[0]->evaluate(), $array);
                    }
                }
                break;
            case 'COUNT':
                if (isset($param[0])) {
                    $key = $param[0]->evaluate();
                    $array = array_key_exists($key, $param['vars']) ? $param['vars'][$key] : array();
                    $value = strval(count($array));
                }
                break;
            case 'BOX':
                unset($param['vars']);
                $title = isset($param[1]) ? $param[0]->evaluate() : '';
                $dimensions = isset($param[2]) ? $param[1]->evaluate() : '100%';
                if ($dimensions == '') {
                    $dimensions = '100%';
                }
                $box_type = isset($param[3]) ? $param[2]->evaluate() : 'classic';
                $options = isset($param[4]) ? $param[3]->evaluate() : '';
                $meta = isset($param[5]) ? $param[4]->evaluate() : '';
                $links = isset($param[6]) ? $param[5]->evaluate() : '';
                $expand = isset($param[7]) ? $param[6]->evaluate() == '1' : false;
                $toplink = isset($param[8]) ? $param[7]->evaluate() : '';
                $tmp = put_in_standard_box(array_pop($param), $title, $dimensions, $box_type, $options, $meta, $links, $expand, $toplink);
                $value = $tmp->evaluate();
                break;
            case 'IF_NON_EMPTY':
                if (isset($param[1])) {
                    if (!$param[0]->is_really_empty()) {
                        $value = $param[1]->evaluate();
                    }
                }
                break;
            case 'IF_PASSED':
                if (isset($param[1])) {
                    $t = $param[0]->evaluate();
                    if (isset($param['vars'][$t])) {
                        $value = $param[1]->evaluate();
                    }
                }
                break;
            case 'IF_NON_PASSED':
                if (isset($param[1])) {
                    $t = $param[0]->evaluate();
                    if (!isset($param['vars'][$t])) {
                        $value = $param[1]->evaluate();
                    }
                }
                break;
            case 'IF_EMPTY':
                if (isset($param[1])) {
                    if ($param[0]->is_really_empty()) {
                        $value = $param[1]->evaluate();
                    }
                }
                break;
            case 'IF_ARRAY_EMPTY':
                if (isset($param[0])) {
                    $looking_at = $param[0]->evaluate();
                    if (array_key_exists($looking_at, $param['vars'])) {
                        if (count($param['vars'][$looking_at]) == 0) {
                            $value = $param[1]->evaluate();
                        }
                    }
                }
                break;
            case 'IF_ARRAY_NON_EMPTY':
                if (isset($param[0])) {
                    $looking_at = $param[0]->evaluate();
                    if (array_key_exists($looking_at, $param['vars'])) {
                        if (count($param['vars'][$looking_at]) != 0) {
                            $value = $param[1]->evaluate();
                        }
                    }
                }
                break;
            case 'OF':
                if (isset($param[1])) {
                    $key = $param[0]->evaluate();
                    $x = $param[1]->evaluate();
                    $array = array_key_exists($key, $param['vars']) ? $param['vars'][$key] : array();
                    $x2 = is_numeric($x) ? intval($x) : $x;
                    if (is_integer($x2)) {
                        if ($x2 < 0) {
                            $x2 = count($array) - 1;
                        } elseif ($x2 >= count($array)) {
                            $x2 -= count($array);
                        }
                    }
                    $value = array_key_exists($x2, $array) ? $array[$x2] : '';
                    if (is_object($value)) {
                        $value = $value->evaluate();
                    }
                }
                break;
            case 'INCLUDE':
                if (isset($param[1])) {
                    $tpl_params = $param['vars'];
                    $explode = explode(chr(10), $param[1]->evaluate());
                    foreach ($explode as $val) {
                        $bits = explode('=', $val, 2);
                        if (count($bits) == 2) {
                            $tpl_params[ltrim($bits[0])] = $bits[1];
                        }
                    }
                    $td = isset($param[3]) ? $param[2]->evaluate() : '';
                    if ($td == '') {
                        $td = 'templates';
                    }
                    $ex = isset($param[2]) ? $param[1]->evaluate() : '';
                    if ($ex == '') {
                        $ex = '.tpl';
                    }
                    $_value = do_template($param[0]->evaluate(), $tpl_params, NULL, false, NULL, $ex, $td);
                    $value = $_value->evaluate();
                }
                break;
            case 'WHILE':
                if (isset($param[1])) {
                    $_p = $param[0]->evaluate();
                    if ($_p == '1' || $_p == '1') {
                        $value = '';
                        $value .= $param[1]->evaluate();
                        $value .= ecv($lang, $escaped, $type, $name, $param);
                    }
                }
                break;
            case 'IF':
                if (isset($param[1])) {
                    $_p = $param[0]->evaluate();
                    if ($_p == '1' || $_p == '1') {
                        $value = $param[1]->evaluate();
                    }
                }
                break;
            case 'LOOP':
                if (isset($param[0])) {
                    if (!array_key_exists($param[0]->evaluate(), $param['vars'])) {
                        require_code('site');
                        attach_message(do_lang_tempcode('MISSING_TEMPLATE_PARAMETER', $param[0]->evaluate(), '???'), 'warn');
                        return '';
                    }
                    $array_key = $param[0]->evaluate();
                    if (is_numeric($array_key) || strpos($array_key, ',') !== false) {
                        $array = explode(',', $array_key);
                    } else {
                        $array = array_key_exists($array_key, $param['vars']) ? $param['vars'][$array_key] : array();
                        if (!is_array($array)) {
                            $array = array();
                        }
                    }
                    $value = '';
                    if (array_key_exists(1 + 1, $param)) {
                        $columns = $param[1]->evaluate();
                        $row_starter = array_key_exists(2 + 1, $param) ? $param[2]->evaluate() : '<tr>';
                        $row_terminator = array_key_exists(3 + 1, $param) ? $param[3]->evaluate() : '</tr>';
                        $value .= $row_starter;
                        // Sorting
                        if (array_key_exists(4 + 1, $param)) {
                            $sort_key = $param[4]->evaluate();
                            $rev = array_key_exists(5 + 1, $param) && $param[5]->evaluate() == 'DESC';
                            if ($sort_key != '') {
                                global $M_SORT_KEY;
                                $M_SORT_KEY = $sort_key;
                                uasort($array, 'multi_sort');
                            }
                            if ($rev) {
                                $array = array_reverse($array);
                            }
                        }
                    }
                    $last = count($param) - 2;
                    $col = 0;
                    $first = true;
                    foreach ($array as $go_key => $go) {
                        if (!is_array($go)) {
                            $go = array('_loop_key' => make_string_tempcode(is_integer($go_key) ? strval($go_key) : $go_key), '_loop_var' => make_string_tempcode($go));
                        }
                        // In case it's not a list of maps, but just a list
                        if (isset($param[2]) && $col % $columns == 0 && $col != 0) {
                            $value .= $row_starter;
                        }
                        $ps = $go + $param['vars'] + array('_loop_key' => make_string_tempcode(is_integer($go_key) ? strval($go_key) : $go_key), '_i' => strval($col), '_first' => $first, '_last' => $col == count($array) - 1);
                        $bound = $param[$last]->bind($ps, '');
                        $value .= $bound->evaluate();
                        ++$col;
                        if (isset($param[3]) && $col % $columns == 0) {
                            $value .= $row_terminator;
                        }
                        $first = false;
                    }
                    if (isset($param[2]) && $col % $columns != 0) {
                        $value .= $row_terminator;
                    }
                }
                break;
            default:
                require_code('site');
                attach_message(do_lang_tempcode('UNKNOWN_DIRECTIVE', escape_html($name)), 'warn');
        }
        if ($escaped != array()) {
            apply_tempcode_escaping($escaped, $value);
        }
        return $value;
    }
    // By elimination, it's language
    $a = isset($param[0]) ? is_object($param[0]) ? $param[0]->evaluate() : $param[0] : NULL;
    $b = isset($param[1]) ? is_object($param[1]) ? $param[1]->evaluate() : $param[1] : NULL;
    $c = isset($param[2]) ? array_splice($param, 2) : NULL;
    if ($c !== NULL) {
        foreach ($c as $i => $cc) {
            if (is_object($cc)) {
                $c[$i] = $cc->evaluate();
            }
        }
    }
    static $dle = false;
    if (!$dle) {
        $dle = function_exists('do_lang');
    }
    $ret = $dle ? do_lang($name, $a, $b, $c, $lang, false) : escape_html($name . ':' . (!is_null($a) ? $a : '') . ',' . (!is_null($b) ? $b : ''));
    if ($ret === NULL) {
        if ($type != TC_PARAMETER) {
            require_code('site');
            attach_message(do_lang_tempcode('MISSING_LANG_ENTRY', escape_html($name)), 'warn');
        }
        $value = '';
        if ($GLOBALS['XSS_DETECT']) {
            ocp_mark_as_escaped($value);
        }
        return $value;
    }
    if ($escaped != array() && $escaped != array(ENTITY_ESCAPED)) {
        apply_tempcode_escaping(array_diff($escaped, array(ENTITY_ESCAPED)), $ret);
    }
    // Escape but without ENTITY_ESCAPED because we don't do that on lang strings
    return $ret;
}
示例#14
0
 /**
  * The actualiser to charge a member points.
  *
  * @return tempcode		The UI
  */
 function points_charge()
 {
     $title = get_page_title('CHARGE_USER');
     $member = post_param_integer('user');
     $amount = post_param_integer('amount');
     $reason = post_param('reason');
     require_code('points2');
     charge_member($member, $amount, $reason);
     $left = available_points($member);
     $username = $GLOBALS['FORUM_DRIVER']->get_username($member);
     if (is_null($username)) {
         $username = do_lang('UNKNOWN');
     }
     $text = do_lang_tempcode('USER_HAS_BEEN_CHARGED', escape_html($username), escape_html(integer_format($amount)), escape_html(integer_format($left)));
     // Show it worked / Refresh
     $url = get_param('redirect', NULL);
     if (is_null($url)) {
         $_url = build_url(array('page' => 'points', 'type' => 'member', 'id' => $member), get_module_zone('points'));
         $url = $_url->evaluate();
     }
     return redirect_screen($title, $url, $text);
 }
示例#15
0
 /**
  * The actualiser for a gift point transaction.
  *
  * @return tempcode		The UI
  */
 function do_give()
 {
     $member_id_of = get_param_integer('id');
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('USER_POINT_FIND')), array('_SELF:_SELF:member:id=' . strval($member_id_of), do_lang_tempcode('_POINTS', escape_html($GLOBALS['FORUM_DRIVER']->get_username($member_id_of))))));
     $title = get_page_title('POINTS');
     $trans_type = post_param('trans_type', 'gift');
     $amount = post_param_integer('amount');
     $reason = post_param('reason');
     $worked = false;
     $member_id_viewing = get_member();
     if ($member_id_of == $member_id_viewing && !has_specific_permission($member_id_viewing, 'give_points_self')) {
         $message = do_lang_tempcode('PE_SELF');
     } elseif (is_guest($member_id_viewing)) {
         $message = do_lang_tempcode('MUST_LOGIN');
     } else {
         if ($trans_type == 'gift') {
             $anonymous = post_param_integer('anonymous', 0);
             $viewer_gift_points_available = get_gift_points_to_give($member_id_viewing);
             //$viewer_gift_points_used=get_gift_points_used($member_id_viewing);
             if ($viewer_gift_points_available < $amount && !has_specific_permission($member_id_viewing, 'have_negative_gift_points')) {
                 $message = do_lang_tempcode('PE_LACKING_GIFT_POINTS');
             } elseif ($amount < 0 && !has_specific_permission($member_id_viewing, 'give_negative_points')) {
                 $message = do_lang_tempcode('PE_NEGATIVE_GIFT');
             } elseif ($reason == '') {
                 $message = do_lang_tempcode('IMPROPERLY_FILLED_IN');
             } else {
                 // Write transfer
                 require_code('points2');
                 give_points($amount, $member_id_of, $member_id_viewing, $reason, $anonymous == 1);
                 // Randomised gifts
                 if (mt_rand(0, 4) == 1) {
                     $message = do_lang_tempcode('PR_LUCKY');
                     $_current_gift = point_info($member_id_viewing);
                     $current_gift = array_key_exists('points_gained_given', $_current_gift) ? $_current_gift['points_gained_given'] : 0;
                     $GLOBALS['FORUM_DRIVER']->set_custom_field($member_id_viewing, 'points_gained_given', $current_gift + 25);
                     // TODO: 25 should be a config option
                 } else {
                     $message = do_lang_tempcode('PR_NORMAL');
                 }
                 $worked = true;
             }
         }
         if ($trans_type == 'refund') {
             $trans_type = 'charge';
             $amount = -$amount;
         }
         if ($trans_type == 'charge') {
             if (has_actual_page_access($member_id_viewing, 'adminzone')) {
                 require_code('points2');
                 charge_member($member_id_of, $amount, $reason);
                 $left = available_points($member_id_of);
                 $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of);
                 if (is_null($username)) {
                     $username = do_lang('UNKNOWN');
                 }
                 $message = do_lang_tempcode('USER_HAS_BEEN_CHARGED', escape_html($username), escape_html(integer_format($amount)), escape_html(integer_format($left)));
                 $worked = true;
             } else {
                 access_denied('I_ERROR');
             }
         }
     }
     if ($worked) {
         // Show it worked / Refresh
         $url = build_url(array('page' => '_SELF', 'type' => 'member', 'id' => $member_id_of), '_SELF');
         return redirect_screen($title, $url, $message);
     } else {
         return warn_screen($title, $message);
     }
 }
示例#16
0
 /**
  * The UI to choose a section of the point-store.
  *
  * @return tempcode		The UI
  */
 function do_module_gui()
 {
     $title = get_page_title('POINT_STORE');
     $points_left = available_points(get_member());
     $items = new ocp_tempcode();
     $_hooks = find_all_hooks('modules', 'pointstore');
     foreach (array_keys($_hooks) as $hook) {
         require_code('hooks/modules/pointstore/' . filter_naughty_harsh($hook), true);
         $object = object_factory('Hook_pointstore_' . filter_naughty_harsh($hook), true);
         if (is_null($object)) {
             continue;
         }
         $object->init();
         $tpls = $object->info();
         foreach ($tpls as $tpl) {
             $item = do_template('POINTSTORE_ITEM', array('_GUID' => '1316f918b3c19331d5d8e55402a7ae45', 'ITEM' => $tpl));
             $items->attach($item);
         }
     }
     if (get_option('is_on_forw_buy') == '1') {
         $forwarding_url = build_url(array('page' => '_SELF', 'type' => 'newforwarding', 'id' => 'forwarding'), '_SELF');
         if ($GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'prices WHERE name LIKE \'' . db_encode_like('forw_%') . '\'') > 0) {
             $_pointstore_mail_forwarding_link = $forwarding_url;
         } else {
             $_pointstore_mail_forwarding_link = NULL;
         }
         $pointstore_mail_forwarding_link = do_template('POINTSTORE_MFORWARDING_LINK', array('_GUID' => 'e93666809dc3e47e3660245711f545ee', 'FORWARDING_URL' => $_pointstore_mail_forwarding_link));
     } else {
         $pointstore_mail_forwarding_link = new ocp_tempcode();
     }
     if (get_option('is_on_pop3_buy') == '1') {
         $pop3_url = build_url(array('page' => '_SELF', 'type' => 'pop3info', 'id' => 'pop3'), '_SELF');
         if ($GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'prices WHERE name LIKE \'' . db_encode_like('pop3_%') . '\'') > 0) {
             $_pointstore_mail_pop3_link = $pop3_url;
         } else {
             $_pointstore_mail_pop3_link = NULL;
         }
         $pointstore_mail_pop3_link = do_template('POINTSTORE_MPOP3_LINK', array('_GUID' => '42925a17262704450e451ad8502bce0d', 'POP3_URL' => $_pointstore_mail_pop3_link));
     } else {
         $pointstore_mail_pop3_link = new ocp_tempcode();
     }
     if (!$pointstore_mail_pop3_link->is_empty() || !$pointstore_mail_pop3_link->is_empty()) {
         $mail_tpl = do_template('POINTSTORE_MAIL', array('_GUID' => '4a024f39a4065197b2268ecd2923b8d6', 'POINTSTORE_MAIL_POP3_LINK' => $pointstore_mail_pop3_link, 'POINTSTORE_MAIL_FORWARDING_LINK' => $pointstore_mail_forwarding_link));
         $items->attach(do_template('POINTSTORE_ITEM', array('_GUID' => '815b00b651757d4052cb494ed6a8d926', 'ITEM' => $mail_tpl)));
     }
     $username = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
     return do_template('POINTSTORE_SCREEN', array('_GUID' => '1b66923dd1a3da6afb934a07909b8aa7', 'TITLE' => $title, 'ITEMS' => $items, 'POINTS_LEFT' => integer_format($points_left), 'USERNAME' => $username));
 }
示例#17
0
/**
 * Wrapper and actualiser to add a portal. Does not return.
 *
 * @param  MEMBER		The member performing the action (portal comes from where member currently is)
 * @param  string		Name of the portal
 * @param  string		Description of the portal
 * @param  AUTO_LINK	The realm the portal goes to
 * @param  integer	The X ordinate the portal goes to
 * @param  integer	The Y ordinate the portal goes to
 */
function add_portal_wrap($member_id, $name, $text, $end_location_realm, $end_location_x, $end_location_y)
{
    if ($end_location_realm == -1) {
        $end_location_realm = NULL;
    }
    // Get $realm,$x,$y from $member_id
    list($realm, $x, $y) = get_loc_details($member_id);
    if (is_null($end_location_realm)) {
        ocw_refresh_with_message(do_lang_tempcode('W_MISSING_DESTINATION_REALM'), 'warn');
    }
    if (is_null($end_location_x) || is_null($end_location_y)) {
        ocw_refresh_with_message(do_lang_tempcode('W_MISSING_DESTINATION'), 'warn');
    }
    if ($name == '') {
        ocw_refresh_with_message(do_lang_tempcode('W_MISSING_NAME'), 'warn');
    }
    // Check $end_location_realm exists
    $allow_portal = $GLOBALS['SITE_DB']->query_value_null_ok('w_rooms', 'allow_portal', array('location_x' => $end_location_x, 'location_y' => $end_location_y, 'location_realm' => $end_location_realm));
    if (is_null($allow_portal)) {
        ocw_refresh_with_message(do_lang_tempcode('W_NO_END'), 'warn');
    }
    if ($allow_portal == 0) {
        ocw_refresh_with_message(do_lang_tempcode('W_BAD_END'), 'warn');
    }
    // Check we don't have a portal to this realm here already
    $t = $GLOBALS['SITE_DB']->query_value_null_ok('w_portals', 'name', array('start_location_x' => $x, 'start_location_y' => $y, 'start_location_realm' => $realm, 'end_location_realm' => $end_location_realm));
    if (!is_null($t)) {
        ocw_refresh_with_message(do_lang_tempcode('W_DUPE_END'), 'warn');
    }
    if ($GLOBALS['SITE_DB']->query_value('w_rooms', 'allow_portal', array('location_x' => $x, 'location_y' => $y, 'location_realm' => $realm)) == 0) {
        ocw_refresh_with_message(do_lang_tempcode('W_BAD_START'), 'warn');
    }
    if (!has_specific_permission($member_id, 'administer_ocworld') && $GLOBALS['SITE_DB']->query_value('w_realms', 'owner', array('id' => $realm)) != $member_id && $GLOBALS['SITE_DB']->query_value('w_realms', 'r_private', array('id' => $realm)) == 1) {
        ocw_refresh_with_message(do_lang_tempcode('W_NO_EDIT_ACCESS_PRIVATE_REALM'), 'warn');
    }
    /*	if ((!has_specific_permission($member_id,'administer_ocworld')) && ($GLOBALS['SITE_DB']->query_value('w_realms','owner',array('id'=>$end_location_realm))!=$member_id) && ($GLOBALS['SITE_DB']->query_value('w_realms','r_private',array('id'=>$end_location_realm))==1))
    		ocw_refresh_with_message(do_lang_tempcode('W_NO_EDIT_ACCESS_PRIVATE_REALM'),'warn');*/
    // Charge them
    if (!has_specific_permission($member_id, 'administer_ocworld')) {
        require_code('points2');
        $price = get_price('mud_portal');
        if (available_points($member_id) < $price) {
            ocw_refresh_with_message(do_lang_tempcode('W_EXPENSIVE', integer_format($price)), 'warn');
        }
        charge_member($member_id, $price, do_lang('W_MADE_PORTAL_OCWORLD', $name));
    }
    add_portal($name, $text, $realm, $x, $y, $end_location_realm, $member_id, $end_location_x, $end_location_y);
    $destname = $GLOBALS['SITE_DB']->query_value('w_realms', 'name', array('id' => $end_location_realm));
    ocw_refresh_with_message(do_lang_tempcode('W_PORTAL_CREATED', escape_html($name), escape_html($destname)));
}
示例#18
0
 /**
  * Standard modular run function for CRON hooks. Searches for tasks to perform.
  */
 function run()
 {
     //if (!addon_installed('octhief')) return;
     require_code('ocf_topics_action2');
     require_code('points');
     require_lang('octhief');
     // ensure it is done once per week
     $time = time();
     $last_time = intval(get_value('last_thieving_time'));
     if ($last_time > time() - 24 * 60 * 60 * 7) {
         return;
     }
     set_value('last_thieving_time', strval($time));
     $octhief_type = get_option('octhief_type', true);
     $octhief_type = isset($octhief_type) && strlen($octhief_type) > 0 ? $octhief_type : 'Members that are inactive, but has lots points';
     $_octhief_number = get_option('octhief_number', true);
     $octhief_number = isset($_octhief_number) && is_numeric($_octhief_number) ? intval($_octhief_number) : 1;
     $_octhief_points = get_option('octhief_points', true);
     $octhief_points = isset($_octhief_points) && is_numeric($_octhief_points) ? intval($_octhief_points) : 10;
     $octhief_group = get_option('octhief_group', true);
     $octhief_group = isset($octhief_group) && strlen($octhief_group) > 0 ? $octhief_group : 'Member';
     // start determining the various cases
     if ($octhief_type == "Members that are inactive, but has lots points") {
         $all_members = $GLOBALS['FORUM_DRIVER']->get_top_posters(1000);
         $points = array();
         foreach ($all_members as $member) {
             $id = $GLOBALS['FORUM_DRIVER']->pname_id($member);
             $signin_time = $member['m_last_visit_time'];
             $points[$signin_time] = array('points' => available_points($id), 'id' => $id);
         }
         ksort($points);
         //print_r($points);
         $octhief_number = count($points) > $octhief_number ? $octhief_number : count($points);
         $theft_count = 0;
         foreach ($points as $member) {
             $theft_count++;
             if ($theft_count > $octhief_number) {
                 break;
             }
             // start stealing
             require_code('points2');
             require_lang('octhief');
             $total_points = $member['points'];
             $octhief_points = $octhief_points < $total_points ? $octhief_points : $total_points;
             $give_to_member = $GLOBALS['FORUM_DB']->query('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE  id <> ' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()) . ' AND id <> ' . strval($member['id']) . ' ORDER BY RAND( ) ', 1, NULL, true);
             $give_to_member = isset($give_to_member[0]['id']) && $give_to_member[0]['id'] > 0 ? $give_to_member[0]['id'] : 0;
             // get THIEF points
             charge_member($member['id'], $octhief_points, do_lang('THIEF_GET') . ' ' . strval($octhief_points) . ' point(-s) from you.');
             if ($give_to_member > 0) {
                 system_gift_transfer(do_lang('THIEF_GAVE_YOU') . ' ' . strval($octhief_points) . ' point(-s)', $octhief_points, $give_to_member);
                 require_code('ocf_topic_action');
                 require_code('ocf_posts_action');
                 $subject = do_lang('THIEF_PT_TOPIC', strval($octhief_points), $GLOBALS['FORUM_DRIVER']->get_username($member['id']), $GLOBALS['FORUM_DRIVER']->get_username($give_to_member));
                 $topic_id = ocf_make_topic(NULL, $subject, '', 1, 1, 0, 0, 0, $member['id'], $give_to_member, false, 0, NULL, '');
                 $post_id = ocf_make_post($topic_id, $subject, do_lang('THIEF_PT_TOPIC_POST'), 0, true, 1, 0, NULL, NULL, NULL, $give_to_member, NULL, NULL, NULL, false, true, NULL, true, $subject, 0, NULL, true, true, true);
                 send_pt_notification($post_id, $subject, $topic_id, $give_to_member, $GLOBALS['FORUM_DRIVER']->pname_id($member));
                 send_pt_notification($post_id, $subject, $topic_id, $GLOBALS['FORUM_DRIVER']->pname_id($member), $give_to_member);
             }
         }
     } elseif ($octhief_type == "Members that are rich") {
         $all_members = $GLOBALS['FORUM_DRIVER']->get_top_posters(100);
         $points = array();
         foreach ($all_members as $member) {
             $id = $GLOBALS['FORUM_DRIVER']->pname_id($member);
             $points[$id] = available_points($id);
         }
         arsort($points);
         $octhief_number = count($points) > $octhief_number ? $octhief_number : count($points);
         $theft_count = 0;
         foreach ($points as $member_id => $av_points) {
             $theft_count++;
             if ($theft_count > $octhief_number) {
                 break;
             }
             // start stealing
             require_code('points2');
             require_lang('octhief');
             $total_points = $av_points;
             $octhief_points = $octhief_points < $total_points ? $octhief_points : $total_points;
             $give_to_member = $GLOBALS['FORUM_DB']->query('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE  id <> ' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()) . ' AND id <> ' . strval($member_id) . ' ORDER BY RAND( ) ', 1, NULL, true);
             $give_to_member = isset($give_to_member[0]['id']) && $give_to_member[0]['id'] > 0 ? $give_to_member[0]['id'] : 0;
             // get THIEF points
             charge_member($member_id, $octhief_points, do_lang('THIEF_GET') . ' ' . strval($octhief_points) . ' point(-s) from you.');
             if ($give_to_member > 0) {
                 system_gift_transfer(do_lang('THIEF_GAVE_YOU') . ' ' . strval($octhief_points) . ' point(-s)', $octhief_points, $give_to_member);
                 require_code('ocf_topic_action');
                 require_code('ocf_posts_action');
                 $subject = do_lang('THIEF_PT_TOPIC', strval($octhief_points));
                 $topic_id = ocf_make_topic(NULL, $subject, '', 1, 1, 0, 0, 0, $member_id, $give_to_member, false, 0, NULL, '');
                 $post_id = ocf_make_post($topic_id, $subject, do_lang('THIEF_PT_TOPIC_POST'), 0, true, 1, 0, NULL, NULL, NULL, $give_to_member, NULL, NULL, NULL, false, true, NULL, true, $subject, 0, NULL, true, true, true);
                 send_pt_notification($post_id, $subject, $topic_id, $give_to_member, $member);
                 send_pt_notification($post_id, $subject, $topic_id, $member, $give_to_member);
             }
         }
     } elseif ($octhief_type == "Members that are random") {
         $random_members = $GLOBALS['FORUM_DB']->query('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE  id <> ' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()) . ' ORDER BY RAND( ) ', $octhief_number, NULL, true);
         $octhief_number = count($random_members) > $octhief_number ? $octhief_number : count($random_members);
         foreach ($random_members as $member) {
             // start stealing
             require_code('points2');
             require_lang('octhief');
             $total_points = available_points($member['id']);
             $octhief_points = $octhief_points < $total_points ? $octhief_points : $total_points;
             $give_to_member = $GLOBALS['FORUM_DB']->query('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE  id <> ' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()) . ' AND id <> ' . strval($member['id']) . ' ORDER BY RAND( ) ', 1, NULL, true);
             $give_to_member = isset($give_to_member[0]['id']) && $give_to_member[0]['id'] > 0 ? $give_to_member[0]['id'] : 0;
             // get THIEF points
             charge_member($member['id'], $octhief_points, do_lang('THIEF_GET') . ' ' . strval($octhief_points) . ' point(-s) from you.');
             if ($give_to_member != 0) {
                 system_gift_transfer(do_lang('THIEF_GAVE_YOU') . ' ' . strval($octhief_points) . ' point(-s)', $octhief_points, $give_to_member);
                 require_code('ocf_topic_action');
                 require_code('ocf_posts_action');
                 $subject = do_lang('THIEF_PT_TOPIC', strval($octhief_points));
                 $topic_id = ocf_make_topic(NULL, $subject, '', 1, 1, 0, 0, 0, $member['id'], $give_to_member, false, 0, NULL, '');
                 $post_id = ocf_make_post($topic_id, $subject, do_lang('THIEF_PT_TOPIC_POST'), 0, true, 1, 0, NULL, NULL, NULL, $give_to_member, NULL, NULL, NULL, false, true, NULL, true, $subject, 0, NULL, true, true, true);
                 send_pt_notification($post_id, $subject, $topic_id, $give_to_member, $member);
                 send_pt_notification($post_id, $subject, $topic_id, $member, $give_to_member);
             }
         }
     } elseif ($octhief_type == "Members that are in a certain usergroup") {
         $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list();
         $group_id = 0;
         foreach ($groups as $id => $group) {
             if ($octhief_group == $group) {
                 $group_id = $id;
             }
         }
         require_code('ocf_groups2');
         $members = ocf_get_group_members_raw($group_id);
         $octhief_number = count($members) > $octhief_number ? $octhief_number : count($members);
         $members_to_steal_ids = array_rand($members, $octhief_number);
         if ($octhief_number == 1) {
             $members_to_steal_ids = array('0' => $members_to_steal_ids);
         }
         foreach ($members_to_steal_ids as $member_rand_key) {
             // start stealing
             require_code('points2');
             require_lang('octhief');
             //echo $members[$member_rand_key];
             $total_points = available_points($members[$member_rand_key]);
             $octhief_points = $octhief_points < $total_points ? $octhief_points : $total_points;
             $give_to_member = $GLOBALS['FORUM_DB']->query('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE  id <> ' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()) . ' AND id <> ' . strval($members[$member_rand_key]) . ' ORDER BY RAND( ) ', 1, NULL, true);
             $give_to_member = isset($give_to_member[0]['id']) && $give_to_member[0]['id'] > 0 ? $give_to_member[0]['id'] : 0;
             // get THIEF points
             charge_member($members[$member_rand_key], $octhief_points, do_lang('THIEF_GET') . ' ' . strval($octhief_points) . ' point(-s) from you.');
             if ($give_to_member != 0) {
                 system_gift_transfer(do_lang('THIEF_GAVE_YOU') . ' ' . strval($octhief_points) . ' point(-s)', $octhief_points, $give_to_member);
                 require_code('ocf_topics_action');
                 $subject = do_lang('THIEF_PT_TOPIC', strval($octhief_points));
                 $topic_id = ocf_make_topic(NULL, $subject, '', 1, 1, 0, 0, 0, $members[$member_rand_key], $give_to_member, false, 0, NULL, '');
                 require_code('ocf_posts_action');
                 $post_id = ocf_make_post($topic_id, $subject, do_lang('THIEF_PT_TOPIC_POST'), 0, true, 1, 0, NULL, NULL, NULL, $give_to_member, NULL, NULL, NULL, false, true, NULL, true, $subject, 0, NULL, true, true, true);
                 require_code('ocf_topics_action2');
                 send_pt_notification($post_id, $subject, $topic_id, $give_to_member, $octhief_number);
                 send_pt_notification($post_id, $subject, $topic_id, $octhief_number, $give_to_member);
             }
         }
     }
 }
示例#19
0
/**
 * Farm out the files for downloads.
 */
function dload_script()
{
    // Closed site
    $site_closed = get_option('site_closed');
    if ($site_closed == '1' && !has_specific_permission(get_member(), 'access_closed_site') && !$GLOBALS['IS_ACTUALLY_ADMIN']) {
        header('Content-Type: text/plain');
        @exit(get_option('closed'));
    }
    global $SITE_INFO;
    if (!is_guest() || !isset($SITE_INFO['any_guest_cached_too']) || $SITE_INFO['any_guest_cached_too'] == '0') {
        if (get_param('for_session', '-1') != md5(strval(get_session_id())) && get_option('anti_leech') == '1' && ocp_srv('HTTP_REFERER') != '') {
            warn_exit(do_lang_tempcode('LEECH_BLOCK'));
        }
    }
    require_lang('downloads');
    $id = get_param_integer('id', 0);
    // Lookup
    $rows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('*'), array('id' => $id), '', 1);
    if (!array_key_exists(0, $rows)) {
        warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
    }
    $myrow = $rows[0];
    // Permission
    if (!has_category_access(get_member(), 'downloads', strval($myrow['category_id']))) {
        access_denied('CATEGORY_ACCESS');
    }
    // Cost?
    $got_before = $GLOBALS['SITE_DB']->query_value_null_ok('download_logging', 'the_user', array('the_user' => get_member(), 'id' => $id));
    if (addon_installed('points')) {
        if ($myrow['download_cost'] > 0) {
            require_code('points2');
            $member = get_member();
            if (is_guest($member)) {
                access_denied('NOT_AS_GUEST');
            }
            // Check they haven't downloaded this before (they only get charged once - maybe they are resuming)
            if (is_null($got_before)) {
                $cost = $myrow['download_cost'];
                $member = get_member();
                if (is_guest($member)) {
                    access_denied('NOT_AS_GUEST');
                }
                $dif = $cost - available_points($member);
                if ($dif > 0 && !has_specific_permission(get_member(), 'have_negative_gift_points')) {
                    warn_exit(do_lang_tempcode('LACKING_POINTS', integer_format($dif)));
                }
                require_code('points2');
                charge_member($member, $cost, do_lang('DOWNLOADED_THIS', get_translated_text($myrow['name'])));
                if ($myrow['download_submitter_gets_points'] == 1) {
                    system_gift_transfer(do_lang('THEY_DOWNLOADED_THIS', get_translated_text($myrow['name'])), $cost, $myrow['submitter']);
                }
            }
        }
    }
    // Filename
    $full = $myrow['url'];
    $breakdown = @pathinfo($full) or warn_exit(do_lang_tempcode('HTTP_DOWNLOAD_NO_SERVER', $full));
    //	$filename=$breakdown['basename'];
    if (!array_key_exists('extension', $breakdown)) {
        $extension = '';
    } else {
        $extension = strtolower($breakdown['extension']);
    }
    if (url_is_local($full)) {
        $_full = get_custom_file_base() . '/' . rawurldecode($full);
    } else {
        $_full = rawurldecode($full);
    }
    // Is it non-local? If so, redirect
    if (!url_is_local($full) || !file_exists(get_file_base() . '/' . rawurldecode(filter_naughty($full)))) {
        if (url_is_local($full)) {
            $full = get_custom_base_url() . '/' . $full;
        }
        if (strpos($full, chr(10)) !== false || strpos($full, chr(13)) !== false) {
            log_hack_attack_and_exit('HEADER_SPLIT_HACK');
        }
        header('Location: ' . $full);
        log_download($id, 0, !is_null($got_before));
        // Bandwidth used is 0 for an external download
        return;
    }
    // Some basic security: don't fopen php files
    if ($extension == 'php') {
        log_hack_attack_and_exit('PHP_DOWNLOAD_INNOCENT', integer_format($id));
    }
    // Size, bandwidth, logging
    $size = filesize($_full);
    if (is_null($got_before)) {
        $bandwidth = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT SUM(file_size) AS answer FROM ' . get_table_prefix() . 'download_logging l LEFT JOIN ' . get_table_prefix() . 'download_downloads d ON l.id=d.id WHERE date_and_time>' . strval(time() - 24 * 60 * 60 * 32));
        if ($bandwidth + floatval($size) > floatval(get_option('maximum_download')) * 1024 * 1024 * 1024 && !has_specific_permission(get_member(), 'bypass_bandwidth_restriction')) {
            warn_exit(do_lang_tempcode('TOO_MUCH_DOWNLOAD'));
        }
        require_code('files2');
        check_shared_bandwidth_usage($size);
    }
    log_download($id, $size, !is_null($got_before));
    // Send header
    if (strpos($myrow['original_filename'], chr(10)) !== false || strpos($myrow['original_filename'], chr(13)) !== false) {
        log_hack_attack_and_exit('HEADER_SPLIT_HACK');
    }
    header('Content-Type: application/octet-stream' . '; authoritative=true;');
    if (get_option('immediate_downloads') == '1') {
        require_code('mime_types');
        header('Content-Type: ' . get_mime_type(get_file_extension($myrow['original_filename'])) . '; authoritative=true;');
        header('Content-Disposition: filename="' . str_replace(chr(13), '', str_replace(chr(10), '', addslashes($myrow['original_filename']))) . '"');
    } else {
        if (strstr(ocp_srv('HTTP_USER_AGENT'), 'MSIE') !== false) {
            header('Content-Disposition: filename="' . str_replace(chr(13), '', str_replace(chr(10), '', addslashes($myrow['original_filename']))) . '"');
        } else {
            header('Content-Disposition: attachment; filename="' . str_replace(chr(13), '', str_replace(chr(10), '', addslashes($myrow['original_filename']))) . '"');
        }
    }
    header('Accept-Ranges: bytes');
    // Caching
    header("Pragma: private");
    header("Cache-Control: private");
    header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 60 * 60 * 24 * 365) . ' GMT');
    $time = is_null($myrow['edit_date']) ? $myrow['add_date'] : $myrow['edit_date'];
    $time = max($time, filemtime($_full));
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $time) . ' GMT');
    // Default to no resume
    $from = 0;
    $new_length = $size;
    @ini_set('zlib.output_compression', 'Off');
    // They're trying to resume (so update our range)
    $httprange = ocp_srv('HTTP_RANGE');
    if (strlen($httprange) > 0) {
        $_range = explode('=', ocp_srv('HTTP_RANGE'));
        if (count($_range) == 2) {
            if (strpos($_range[0], '-') === false) {
                $_range = array_reverse($_range);
            }
            $range = $_range[0];
            if (substr($range, 0, 1) == '-') {
                $range = strval($size - intval(substr($range, 1)) - 1) . $range;
            }
            if (substr($range, -1, 1) == '-') {
                $range .= strval($size - 1);
            }
            $bits = explode('-', $range);
            if (count($bits) == 2) {
                list($from, $to) = array_map('intval', $bits);
                if ($to - $from != 0 || $from == 0) {
                    $new_length = $to - $from + 1;
                    header('HTTP/1.1 206 Partial Content');
                    header('Content-Range: bytes ' . $range . '/' . strval($size));
                } else {
                    $from = 0;
                }
            }
        }
    }
    header('Content-Length: ' . strval($new_length));
    if (function_exists('set_time_limit')) {
        @set_time_limit(0);
    }
    error_reporting(0);
    // Send actual data
    $myfile = fopen($_full, 'rb');
    fseek($myfile, $from);
    $i = 0;
    flush();
    // Works around weird PHP bug that sends data before headers, on some PHP versions
    while ($i < $new_length) {
        $content = fread($myfile, min($new_length - $i, 1048576));
        echo $content;
        $len = strlen($content);
        if ($len == 0) {
            break;
        }
        $i += $len;
    }
    fclose($myfile);
    /*
    Security note... at the download adding/editing stage, we ensured that
    	only files accessible to the web server (in raw form) could end up in
    	our database.
    	Therefore we did not check here that our file was accessible in raw
    	form.
    */
}
示例#20
0
 /**
  * Standard stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function _buyquota()
 {
     if (get_option('is_on_pop3_buy') == '0') {
         return new ocp_tempcode();
     }
     $title = get_page_title('TITLE_QUOTA');
     $member_id = get_member();
     $pointsleft = available_points($member_id);
     $price = intval(get_option('quota'));
     $quota = post_param_integer('quota');
     $details = $GLOBALS['SITE_DB']->query_select('sales', array('details', 'details2'), array('memberid' => $member_id, 'purchasetype' => 'pop3'), '', 1);
     $prefix = $details[0]['details'];
     $suffix = $details[0]['details2'];
     // If we don't own a POP3 account, stop right here.
     if (!array_key_exists(0, $details)) {
         return warn_screen($title, do_lang_tempcode('NO_POP3'));
     }
     // Stop if we can't afford this much quota
     if ($quota * $price > $pointsleft && !has_specific_permission(get_member(), 'give_points_self')) {
         return warn_screen($title, do_lang_tempcode('CANT_AFFORD'));
     }
     // Mail off the order form
     $quota_url = get_option('quota_url');
     $_price = $quota * $price;
     $encoded_reason = do_lang('TITLE_QUOTA');
     $message_raw = do_template('POINTSTORE_QUOTA_MAIL', array('_GUID' => '5a4e0bb5e53e6ccf8e57581c377557f4', 'ENCODED_REASON' => $encoded_reason, 'QUOTA' => integer_format($quota), 'EMAIL' => $prefix . $suffix, 'QUOTA_URL' => $quota_url, 'PRICE' => integer_format($_price)));
     require_code('notifications');
     dispatch_notification('pointstore_request_quota', 'quota_' . uniqid('', true), do_lang('MAIL_REQUEST_QUOTA', NULL, NULL, NULL, get_site_default_lang()), $message_raw->evaluate(get_site_default_lang(), false), NULL, NULL, 3, true);
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('ORDER_QUOTA_DONE'));
 }
示例#21
0
/**
 * The UI for a points profile.
 *
 * @param  MEMBER			The ID of the member who is being viewed
 * @param  ?MEMBER		The ID of the member who is doing the viewing (NULL: current member)
 * @return tempcode		The UI
 */
function points_profile($member_id_of, $member_id_viewing)
{
    require_code('points');
    require_css('points');
    require_lang('points');
    require_javascript('javascript_validation');
    // Get info about viewing/giving user
    if (!is_guest($member_id_viewing)) {
        $viewer_gift_points_available = get_gift_points_to_give($member_id_viewing);
    }
    // Get info about viewed user
    $name = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of);
    if (is_null($name) || is_guest($member_id_of)) {
        warn_exit(do_lang_tempcode('USER_NO_EXIST'));
    }
    $title = get_page_title('_POINTS', true, array(escape_html($name)));
    $profile_link = $GLOBALS['FORUM_DRIVER']->member_profile_url($member_id_of, false, true);
    // Show stats about $member_id_of
    $post_count = $GLOBALS['FORUM_DRIVER']->get_post_count($member_id_of);
    $_point_info = point_info($member_id_of);
    $points_gained_given = array_key_exists('points_gained_given', $_point_info) ? $_point_info['points_gained_given'] : 0;
    $points_gained_rating = array_key_exists('points_gained_rating', $_point_info) ? $_point_info['points_gained_rating'] : 0;
    $points_gained_voting = array_key_exists('points_gained_voting', $_point_info) ? $_point_info['points_gained_voting'] : 0;
    $cedi_post_count = array_key_exists('points_gained_seedy', $_point_info) ? $_point_info['points_gained_seedy'] : 0;
    $chat_post_count = array_key_exists('points_gained_chat', $_point_info) ? $_point_info['points_gained_chat'] : 0;
    $points_used = points_used($member_id_of);
    $remaining = available_points($member_id_of);
    $gift_points_used = get_gift_points_used($member_id_of);
    //$_point_info['gift_points_used'];
    $gift_points_available = get_gift_points_to_give($member_id_of);
    $points_posting = intval(get_option('points_posting'));
    $points_rating = intval(get_option('points_rating'));
    $points_voting = intval(get_option('points_voting'));
    $points_joining = intval(get_option('points_joining'));
    $points_cedi_posting = intval(get_option('points_cedi', true));
    $points_chat_posting = intval(get_option('points_chat', true));
    $points_per_day = intval(get_option('points_per_day', true));
    $points_per_daily_visit = intval(get_option('points_per_daily_visit', true));
    $days_joined = intval(floor(floatval(time() - $GLOBALS['FORUM_DRIVER']->get_member_join_timestamp($member_id_of)) / (60.0 * 60.0 * 24.0)));
    $points_gained_auto = $points_per_day * $days_joined;
    $to = points_get_transactions('to', $member_id_of, $member_id_viewing);
    $from = points_get_transactions('from', $member_id_of, $member_id_viewing);
    // If we're staff, we can show the charge log too
    $chargelog_details = new ocp_tempcode();
    if (has_specific_permission($member_id_viewing, 'view_charge_log')) {
        global $NON_CANONICAL_PARAMS;
        $NON_CANONICAL_PARAMS[] = 'charge_start';
        $NON_CANONICAL_PARAMS[] = 'charge_sort';
        $start = get_param_integer('charge_start', 0);
        $max = get_param_integer('charge_max', 10);
        $sortables = array('date_and_time' => do_lang_tempcode('DATE'), 'amount' => do_lang_tempcode('AMOUNT'));
        $test = explode(' ', get_param('charge_sort', 'date_and_time DESC'), 2);
        if (count($test) == 1) {
            $test[1] = 'DESC';
        }
        list($sortable, $sort_order) = $test;
        if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) {
            log_hack_attack_and_exit('ORDERBY_HACK');
        }
        $max_rows = $GLOBALS['SITE_DB']->query_value('chargelog', 'COUNT(*)', array('user_id' => $member_id_of));
        $rows = $GLOBALS['SITE_DB']->query_select('chargelog c LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND t.id=c.reason', array('*'), array('user_id' => $member_id_of), 'ORDER BY ' . $sortable . ' ' . $sort_order, $max, $start);
        $charges = new ocp_tempcode();
        $fromname = get_site_name();
        $toname = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of);
        if (is_null($toname)) {
            $toname = do_lang('UNKNOWN');
        }
        require_code('templates_results_table');
        $fields_title = results_field_title(array(do_lang_tempcode('DATE'), do_lang_tempcode('AMOUNT'), do_lang_tempcode('FROM'), do_lang_tempcode('TO'), do_lang_tempcode('REASON')), $sortables, 'charge_sort', $sortable . ' ' . $sort_order);
        foreach ($rows as $myrow) {
            $date = get_timezoned_date($myrow['date_and_time']);
            $amount = $myrow['amount'];
            if (get_page_name() != 'search' && array_key_exists('text_parsed', $myrow) && !is_null($myrow['text_parsed']) && $myrow['text_parsed'] != '' && $myrow['reason'] != 0) {
                $reason = new ocp_tempcode();
                if (!$reason->from_assembly($myrow['text_parsed'], true)) {
                    $reason = get_translated_tempcode($myrow['reason']);
                }
            } else {
                $reason = get_translated_tempcode($myrow['reason']);
            }
            $charges->attach(results_entry(array(escape_html($date), escape_html(integer_format($amount)), escape_html($fromname), escape_html($toname), $reason)));
        }
        $chargelog_details = results_table(do_lang_tempcode('CHARGES'), $start, 'charge_start', $max, 'charge_max', $max_rows, $fields_title, $charges, $sortables, $sortable, $sort_order, 'charge_sort', NULL, NULL, NULL, 8, 'fgfdgfdgfdgfdger4gtrhg', false, 'tab__points');
        $chargelog_details->attach(do_template('POINTS_CHARGE', array('_GUID' => 'f1e2d45a7d920ab91553a5fd0728a5ad', 'URL' => build_url(array('page' => 'admin_points', 'type' => 'charge', 'redirect' => get_self_url(true)), get_module_zone('admin_points')), 'USER' => strval($member_id_of))));
    }
    // Show giving form
    if (is_guest($member_id_viewing)) {
        $give_template = do_lang_tempcode('POINTS_MUST_LOGIN');
    } else {
        $have_negative_gift_points = has_specific_permission($member_id_viewing, 'have_negative_gift_points');
        $enough_ok = $viewer_gift_points_available > 0 || $have_negative_gift_points;
        $give_ok = $member_id_viewing != $member_id_of || has_specific_permission($member_id_viewing, 'give_points_self');
        if ($enough_ok && $give_ok) {
            // Show how many points are available also
            $give_url = build_url(array('page' => 'points', 'type' => 'give', 'id' => $member_id_of), get_module_zone('points'));
            $give_template = do_template('POINTS_GIVE', array('_GUID' => 'fa1749d5a803d86b1efbcfde2ad81702', 'GIVE_URL' => $give_url, 'USER' => strval($member_id_of), 'VIEWER_GIFT_POINTS_AVAILABLE' => $have_negative_gift_points ? '' : integer_format($viewer_gift_points_available)));
        } else {
            $give_template = do_lang_tempcode('PE_LACKING_GIFT_POINTS');
        }
        if (!$give_ok) {
            $give_template = new ocp_tempcode();
        }
        if (!has_specific_permission($member_id_of, 'use_points')) {
            $give_template = new ocp_tempcode();
        }
    }
    return do_template('POINTS_PROFILE', array('_GUID' => 'f91208ef0f9a1e1a8633ce307a778a8d', 'TITLE' => $title, 'MEMBER' => strval($member_id_of), 'PROFILE_LINK' => $profile_link, 'NAME' => $name, 'POINTS_JOINING' => integer_format($points_joining), 'POST_COUNT' => integer_format($post_count), 'POINTS_POSTING' => integer_format($points_posting), 'MULT_POINTS_POSTING' => integer_format($points_posting * $post_count), 'POINTS_PER_DAY' => integer_format($points_per_day), 'DAYS_JOINED' => integer_format($days_joined), 'MULT_POINTS_PER_DAY' => integer_format($points_per_day * $days_joined), 'POINTS_GAINED_AUTO' => integer_format($points_gained_auto), 'CEDI_POST_COUNT' => integer_format($cedi_post_count), 'POINTS_CEDI_POSTING' => integer_format($points_cedi_posting), 'MULT_POINTS_CEDI_POSTING' => integer_format($cedi_post_count * $points_cedi_posting), 'CHAT_POST_COUNT' => integer_format($chat_post_count), 'POINTS_CHAT_POSTING' => integer_format($points_chat_posting), 'MULT_POINTS_CHAT_POSTING' => integer_format($chat_post_count * $points_chat_posting), 'POINTS_RATING' => integer_format($points_rating), 'POINTS_GAINED_RATING' => integer_format($points_gained_rating), 'MULT_POINTS_RATING' => integer_format($points_rating * $points_gained_rating), 'POINTS_VOTING' => integer_format($points_voting), 'POINTS_GAINED_VOTING' => integer_format($points_gained_voting), 'MULT_POINTS_VOTING' => integer_format($points_voting * $points_gained_voting), 'POINTS_PER_DAILY_VISIT' => integer_format($points_per_daily_visit), 'POINTS_GAINED_GIVEN' => integer_format($points_gained_given), 'POINTS_USED' => integer_format($points_used), 'REMAINING' => integer_format($remaining), 'GIFT_POINTS_USED' => integer_format($gift_points_used), 'GIFT_POINTS_AVAILABLE' => integer_format($gift_points_available), 'TO' => $to, 'FROM' => $from, 'CHARGELOG_DETAILS' => $chargelog_details, 'GIVE' => $give_template));
}
示例#22
0
 /**
  * Standard stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function __newforwarding()
 {
     if (get_option('is_on_forw_buy') == '0') {
         return new ocp_tempcode();
     }
     $title = get_page_title('TITLE_NEWFORWARDING');
     $member_id = get_member();
     $pointsleft = available_points($member_id);
     // the number of points this member has left
     $time = time();
     // So we don't need to call these big ugly names, again...
     $prefix = post_param('prefix');
     $_suffix = post_param('suffix');
     $email = post_param('email');
     $suffix = 'forw_' . $_suffix;
     $suffix_price = get_price($suffix);
     pointstore_handle_error_already_has('forwarding');
     // If the price is more than we can afford...
     if ($suffix_price > $pointsleft && !has_specific_permission(get_member(), 'give_points_self')) {
         return warn_screen($title, do_lang_tempcode('NOT_ENOUGH_POINTS', escape_html($_suffix)));
     }
     pointstore_handle_error_taken($prefix, $_suffix);
     // Add us to the database
     $sale_id = $GLOBALS['SITE_DB']->query_insert('sales', array('date_and_time' => $time, 'memberid' => get_member(), 'purchasetype' => 'forwarding', 'details' => $prefix, 'details2' => '@' . $_suffix), true);
     $forw_url = get_option('forw_url');
     // Mail off the order form
     $encoded_reason = do_lang('TITLE_NEWFORWARDING');
     $message_raw = do_template('POINTSTORE_FORWARDER_MAIL', array('_GUID' => 'a09dba8b440baa5cd48d462ebfafd15f', 'ENCODED_REASON' => $encoded_reason, 'EMAIL' => $email, 'PREFIX' => $prefix, 'SUFFIX' => $_suffix, 'FORW_URL' => $forw_url, 'SUFFIX_PRICE' => integer_format($suffix_price)));
     require_code('notifications');
     dispatch_notification('pointstore_request_forwarding', 'forw_' . strval($sale_id), do_lang('MAIL_REQUEST_FORWARDING', NULL, NULL, NULL, get_site_default_lang()), $message_raw->evaluate(get_site_default_lang(), false), NULL, NULL, 3, true);
     $text = do_lang_tempcode('ORDER_FORWARDER_DONE', $email, escape_html($prefix . '@' . $_suffix));
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, $text);
 }