/** * 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')); }
/** * Standard modular run function for preview hooks. * * @return array A pair: The preview, the updated post Comcode */ function run() { require_code('uploads'); $urls = get_url('', 'file', 'uploads/iotds', 0, OCP_UPLOAD_IMAGE, true, '', 'file2'); if ($urls[0] == '') { if (!is_null(post_param_integer('id', NULL))) { $rows = $GLOBALS['SITE_DB']->query_select('iotds', array('url', 'thumb_url'), array('id' => post_param_integer('id')), '', 1); $urls = $rows[0]; $url = $urls['url']; $thumb_url = $urls['thumb_url']; } else { warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD')); } } else { $url = $urls[0]; $thumb_url = $urls[1]; } $caption = comcode_to_tempcode(post_param('caption', '')); $title = comcode_to_tempcode(post_param('title', '')); require_code('images'); $thumb = do_image_thumb(url_is_local($thumb_url) ? get_custom_base_url() . '/' . $thumb_url : $thumb_url, $caption, true); $url = url_is_local($url) ? get_custom_base_url() . '/' . $url : $url; $preview = do_template('IOTD', array('ID' => '', 'IMAGE_URL' => $url, 'SUBMITTER' => strval(get_member()), 'VIEW_URL' => $url, 'IMAGE' => $thumb, 'CAPTION' => $title)); return array($preview, NULL); }
/** * 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')); }
/** * Handle cloud registrations. */ function backend_cloud_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')); } $path = post_param('path', ''); $procedure = post_param('registerProcedure', ''); $protocol = post_param('protocol', ''); if ($protocol == 'soap') { exit('false'); } if ($protocol == 'http-post') { exit('false'); } if ($protocol == 'xml-rpc' && !function_exists('xmlrpc_encode')) { exit('false'); } $port = post_param_integer('port', '80'); // $watching_channel=$_POST['channels']; $status = register_them($path, $procedure, $protocol, $port, get_param('type', '')); if (!$status) { exit('false'); } exit('true'); }
/** * Standard modular run function for preview hooks. * * @return array A pair: The preview, the updated post Comcode */ function run() { if (!has_specific_permission(get_member(), 'comcode_dangerous')) { exit; } require_code('zones2'); require_code('zones3'); $bparameters = ''; $bparameters_xml = ''; $block = post_param('block'); $parameters = get_block_parameters($block); $parameters[] = 'failsafe'; $parameters[] = 'cache'; $parameters[] = 'quick_cache'; foreach ($parameters as $parameter) { $value = post_param($parameter, NULL); if (is_null($value)) { if (post_param_integer('tick_on_form__' . $parameter, NULL) === NULL) { continue; } // If not on form, continue, otherwise must be 0 $value = '0'; } if ($value != '' && ($parameter != 'failsafe' || $value == '1') && ($parameter != 'cache' || $value != block_cache_default($block)) && ($parameter != 'quick_cache' || $value == '1')) { $bparameters .= ' ' . $parameter . '="' . str_replace('"', '\\"', $value) . '"'; $bparameters_xml = '<blockParam key="' . escape_html($parameter) . '" val="' . escape_html($value) . '" />'; } } $comcode = '[block' . $bparameters . ']' . $block . '[/block]'; $preview = comcode_to_tempcode($comcode); return array($preview, NULL); }
/** * Get what we need to get attachments in a form-field interface. * * @param ID_TEXT The name of the field attachments are for * @return array A pair: the attachments UI (tempcode), the hidden attachment field */ function get_attachments($posting_field_name) { $image_types = str_replace(',', ', ', get_option('valid_images')); require_lang('javascript'); require_javascript('javascript_swfupload'); require_css('swfupload'); require_code('files2'); $max_attach_size = get_max_file_size(get_member(), $GLOBALS['SITE_DB']); $attach_size_field = form_input_hidden('MAX_FILE_SIZE', strval($max_attach_size)); $num_attachments = post_param_integer('num_attachments', has_js() ? 1 : 3); $attachments = new ocp_tempcode(); for ($i = 1; $i <= $num_attachments; $i++) { $attachments->attach(do_template('ATTACHMENT', array('_GUID' => 'c3b38ca70cbd1c5f9cf91bcae9ed1134', 'POSTING_FIELD_NAME' => $posting_field_name, 'I' => strval($i)))); } if (get_forum_type() == 'ocf') { require_code('ocf_groups'); require_lang('ocf'); $max_attachments = ocf_get_member_best_group_property(get_member(), 'max_attachments_per_post'); } else { $max_attachments = 100; } $attachment_template = do_template('ATTACHMENT', array('_GUID' => 'c3b38ca70cbd1c5f9cf91bcae9ed11dsds', 'POSTING_FIELD_NAME' => $posting_field_name, 'I' => '__num_attachments__')); $attachments = do_template('ATTACHMENTS', array('_GUID' => '054921e7c09412be479676759accf222', 'POSTING_FIELD_NAME' => $posting_field_name, 'ATTACHMENT_TEMPLATE' => $attachment_template, 'IMAGE_TYPES' => $image_types, 'ATTACHMENTS' => $attachments, 'MAX_ATTACHMENTS' => strval($max_attachments), 'NUM_ATTACHMENTS' => strval($num_attachments))); return array($attachments, $attach_size_field); }
/** * Update cart * * @param array Product details */ function update_cart($product_det) { if (!is_array($product_det) || count($product_det) == 0) { return; } foreach ($product_det as $product) { $where = array('product_id' => $product['product_id'], 'is_deleted' => 0); if (is_guest()) { $where['session_id'] = get_session_id(); } else { $where['ordered_by'] = get_member(); } if ($product['Quantity'] > 0) { $GLOBALS['SITE_DB']->query_update('shopping_cart', array('quantity' => $product['Quantity']), $where); } else { $GLOBALS['SITE_DB']->query_delete('shopping_cart', $where); } } //Update tax opt out status to the current order $tax_opted_out = post_param_integer('tax_opted_out', 0); $order_id = get_current_order_id(); if (get_option('allow_opting_out_of_tax') == '1') { $GLOBALS['SITE_DB']->query_update('shopping_order', array('tax_opted_out' => $tax_opted_out), array('id' => $order_id), '', 1); } }
/** * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX. * * @return tempcode The snippet */ function run() { if (get_option('is_on_rating') == '0') { return do_lang_tempcode('INTERNAL_ERROR'); } // Has there actually been any rating? if (strtoupper(ocp_srv('REQUEST_METHOD')) == 'POST' || ocp_srv('HTTP_REFERER') == '') { $rating = either_param_integer('rating', NULL); } else { $rating = post_param_integer('rating'); // Will fail } $content_type = get_param('content_type'); $type = get_param('type', ''); $content_id = get_param('id'); $content_url = get_param('content_url', '', true); $content_title = get_param('content_title', '', true); require_code('feedback'); actualise_specific_rating($rating, get_page_name(), get_member(), $content_type, $type, $content_id, $content_url, $content_title); actualise_give_rating_points(); $template = get_param('template', NULL); if ($template !== '') { if (is_null($template)) { $template = 'RATING_BOX'; } return display_rating($content_url, $content_title, $content_type, $content_id, $template); } return do_lang_tempcode('THANKYOU_FOR_RATING_SHORT'); }
/** * Standard modular render function for profile tabs edit hooks. * * @param MEMBER The ID of the member who is being viewed * @param MEMBER The ID of the member who is doing the viewing * @param boolean Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later * @return ?array A tuple: The tab title, the tab body text (may be blank), the tab fields, extra Javascript (may be blank) the suggested tab order, hidden fields (optional) (NULL: if $leave_to_ajax_if_possible was set) */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { $title = do_lang_tempcode('DELETE_MEMBER'); $order = 200; // Actualiser $delete_account = post_param_integer('delete', 0); if ($delete_account == 1) { if (is_guest($member_id_of)) { warn_exit(do_lang_tempcode('INTERNAL_ERROR')); } ocf_delete_member($member_id_of); inform_exit(do_lang_tempcode('SUCCESS')); } if ($leave_to_ajax_if_possible) { return NULL; } // UI fields $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of); $text = do_lang_tempcode('_DELETE_MEMBER' . ($member_id_of == get_member() ? '_SUICIDAL' : ''), escape_html($username)); $fields = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false)); $javascript = ''; return array($title, $fields, $text, $javascript, $order); }
/** * Standard modular run function for setting features from the setup wizard. */ function set_fields() { if (!addon_installed('banners')) { return; } $usergroups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(); if (post_param_integer('have_default_banners_donation', 0) == 0) { $test = $GLOBALS['SITE_DB']->query_value_null_ok('banners', 'name', array('name' => 'donate')); if (!is_null($test)) { require_code('banners2'); delete_banner('donate'); foreach (array_keys($usergroups) as $id) { $GLOBALS['SITE_DB']->query_insert('group_page_access', array('page_name' => 'donate', 'zone_name' => 'site', 'group_id' => $id), false, true); } } } if (post_param_integer('have_default_banners_advertising', 0) == 0) { $test = $GLOBALS['SITE_DB']->query_value_null_ok('banners', 'name', array('name' => 'advertise_here')); if (!is_null($test)) { require_code('banners2'); delete_banner('advertise_here'); foreach (array_keys($usergroups) as $id) { $GLOBALS['SITE_DB']->query_insert('group_page_access', array('page_name' => 'advertise', 'zone_name' => 'site', 'group_id' => $id), false, true); } } } $test = $GLOBALS['SITE_DB']->query_value('banners', 'COUNT(*)'); if ($test == 0) { set_option('is_on_banners', '0'); } }
/** * Standard modular run function for setting features from the setup wizard. */ function set_fields() { if (!addon_installed('news')) { return; } $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups(); $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true); $GLOBALS['SITE_DB']->query_delete('gsp', array('specific_permission' => 'have_personal_category', 'the_page' => 'cms_news')); if (post_param_integer('keep_blogs', 0) == 1) { foreach (array_keys($groups) as $group_id) { if (!in_array($group_id, $admin_groups)) { $GLOBALS['SITE_DB']->query_insert('gsp', array('specific_permission' => 'have_personal_category', 'group_id' => $group_id, 'module_the_name' => '', 'category_name' => '', 'the_page' => 'cms_news', 'the_value' => 1)); } } } if (post_param_integer('keep_news_categories', 0) == 0) { $news_cats = $GLOBALS['SITE_DB']->query_select('news_categories', array('id'), array('nc_owner' => NULL)); foreach ($news_cats as $news_cat) { if ($news_cat['id'] > db_get_first_id() && $news_cat['id'] < db_get_first_id() + 7) { require_code('news'); delete_news_category($news_cat['id']); } } } }
/** * 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); }
/** * Check a POST inputted date for validity, and get the Unix timestamp for the inputted date. * * @param ID_TEXT The stub of the parameter name (stub_year, stub_month, stub_day, stub_hour, stub_minute) * @param boolean Whether to allow over get parameters also * @return ?TIME The timestamp of the date (NULL: no input date was chosen) */ function _get_input_date($stub, $get_also = false) { $timezone = post_param('timezone', get_users_timezone()); if ($get_also) { // if (either_param_integer($stub,0)==0) return NULL; // NULL was chosen Doesn't work like this now $year = either_param_integer($stub . '_year', NULL); if (is_null($year)) { return NULL; } $month = either_param_integer($stub . '_month', NULL); if (is_null($month)) { return NULL; } $day = either_param_integer($stub . '_day', NULL); if (is_null($day)) { return NULL; } $hour = either_param_integer($stub . '_hour', NULL); $minute = either_param_integer($stub . '_minute', NULL); } else { // if (post_param_integer($stub,0)==0) return NULL; // NULL was chosen Doesn't work like this now $year = post_param_integer($stub . '_year', NULL); if (is_null($year)) { return NULL; } $month = post_param_integer($stub . '_month', NULL); if (is_null($month)) { return NULL; } $day = post_param_integer($stub . '_day', NULL); if (is_null($day)) { return NULL; } $hour = post_param_integer($stub . '_hour', NULL); $minute = post_param_integer($stub . '_minute', NULL); } if (!checkdate($month, $day, $year)) { warn_exit(do_lang_tempcode('INVALID_DATE_GIVEN')); } if (is_null($hour)) { if (strpos($stub, 'end') !== false) { $hour = 23; $minute = 59; } else { $hour = 0; $minute = 0; } } $time = mktime($hour, $minute, 0, $month, $day, $year); if ($year >= 1970 || @strftime('%Y', @mktime(0, 0, 0, 1, 1, 1963)) == '1963') { $amount_forward = tz_time($time, $timezone) - $time; $time = $time - $amount_forward; } return $time; }
/** * Standard modular run function for preview hooks. * * @return array A pair: The preview, the updated post Comcode */ function run() { require_lang('ocf'); require_css('ocf'); $original_comcode = post_param('post'); $posting_ref_id = post_param_integer('posting_ref_id', mt_rand(0, 100000)); $post_bits = do_comcode_attachments($original_comcode, 'seedy_post', strval(-$posting_ref_id), true, $GLOBALS['SITE_DB']); $post_comcode = $post_bits['comcode']; $post_html = $post_bits['tempcode']; return array($post_html, $post_comcode); }
/** * Update an e-mail address from what was chosen in an interface; update or delete each price/cost/item */ function _do_price_mail() { $i = 0; while (array_key_exists('forw_' . strval($i), $_POST)) { $price = post_param_integer('forw_' . strval($i)); $name = 'forw_' . post_param('dforw_' . strval($i)); $name2 = 'forw_' . post_param('ndforw_' . strval($i)); if (post_param_integer('delete_forw_' . strval($i), 0) == 1) { $GLOBALS['SITE_DB']->query_delete('prices', array('name' => $name), '', 1); } else { $GLOBALS['SITE_DB']->query_update('prices', array('price' => $price, 'name' => $name2), array('name' => $name), '', 1); } $i++; } }
/** * Standard modular run function for setting features from the setup wizard. */ function set_fields() { if (!addon_installed('galleries')) { return; } $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups(); $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true); $GLOBALS['SITE_DB']->query_delete('gsp', array('specific_permission' => 'have_personal_category', 'the_page' => 'cms_galleries')); if (post_param_integer('keep_personal_galleries', 0) == 1) { foreach (array_keys($groups) as $group_id) { if (!in_array($group_id, $admin_groups)) { $GLOBALS['SITE_DB']->query_insert('gsp', array('specific_permission' => 'have_personal_category', 'group_id' => $group_id, 'module_the_name' => '', 'category_name' => '', 'the_page' => 'cms_galleries', 'the_value' => 1)); } } } }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_lang('messaging'); require_code('feedback'); $to = array_key_exists('param', $map) ? $map['param'] : get_option('staff_address'); $post = post_param('post', ''); if (post_param_integer('_comment_form_post', 0) == 1 && $post != '') { if (addon_installed('captcha')) { if (get_option('captcha_on_feedback') == '1') { require_code('captcha'); enforce_captcha(); } } $message = new ocp_tempcode(); /*Used to be written out here*/ attach_message(do_lang_tempcode('MESSAGE_SENT'), 'inform'); require_code('mail'); $email_from = trim(post_param('email', $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member()))); mail_wrap(post_param('title'), $post, array($to), NULL, $email_from, $GLOBALS['FORUM_DRIVER']->get_username(get_member()), 3, NULL, false, get_member()); if ($email_from != '') { mail_wrap(do_lang('YOUR_MESSAGE_WAS_SENT_SUBJECT', post_param('title')), do_lang('YOUR_MESSAGE_WAS_SENT_BODY', $post), array($email_from), NULL, '', '', 3, NULL, false, get_member()); } } else { $message = new ocp_tempcode(); } $box_title = array_key_exists('title', $map) ? $map['title'] : do_lang('CONTACT_US'); $private = array_key_exists('private', $map) && $map['private'] == '1'; $em = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser(); require_javascript('javascript_editing'); $comcode_help = build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode', false)); require_javascript('javascript_validation'); $comment_url = get_self_url(); $email_optional = array_key_exists('email_optional', $map) ? intval($map['email_optional']) == 1 : true; if (addon_installed('captcha')) { require_code('captcha'); $use_captcha = get_option('captcha_on_feedback') == '1' && use_captcha(); if ($use_captcha) { generate_captcha(); } } else { $use_captcha = false; } $comment_details = do_template('COMMENTS_POSTING_FORM', array('JOIN_BITS' => '', 'FIRST_POST_URL' => '', 'FIRST_POST' => '', 'USE_CAPTCHA' => $use_captcha, 'EMAIL_OPTIONAL' => $email_optional, 'POST_WARNING' => '', 'COMMENT_TEXT' => '', 'GET_EMAIL' => !$private, 'GET_TITLE' => !$private, 'EM' => $em, 'DISPLAY' => 'block', 'TITLE' => $box_title, 'COMMENT_URL' => $comment_url)); $out = do_template('BLOCK_MAIN_CONTACT_SIMPLE', array('_GUID' => '298a357f442f440c6b42e58d6717e57c', 'EMAIL_OPTIONAL' => true, 'COMMENT_DETAILS' => $comment_details, 'MESSAGE' => $message)); return $out; }
/** * Standard modular run function for preview hooks. * * @return array A pair: The preview, the updated post Comcode */ function run() { $original_comcode = post_param('post'); $posting_ref_id = post_param_integer('posting_ref_id', mt_rand(0, 100000)); $post_bits = do_comcode_attachments($original_comcode, 'news', strval(-$posting_ref_id), true, $GLOBALS['SITE_DB']); $post_comcode = $post_bits['comcode']; $post_html = $post_bits['tempcode']; $view_space_map = array(); $view_space_map[post_param('label_for__title')] = escape_html(post_param('title')); $view_space_map[post_param('label_for__post')] = $post_html; $view_space_map[post_param('label_for__news')] = comcode_to_tempcode(post_param('news', '')); require_code('templates_view_space'); $view_space_fields = new ocp_tempcode(); foreach ($view_space_map as $key => $val) { $view_space_fields->attach(view_space_field($key, $val, true)); } $output = do_template('VIEW_SPACE', array('WIDTH' => '170', 'FIELDS' => $view_space_fields)); return array($output, $post_comcode); }
/** * Standard modular run function for preview hooks. * * @return array A pair: The preview, the updated post Comcode */ function run() { require_code('setupwizard'); $collapse_zones = post_param_integer('collapse_user_zones', 0) == 1; $installprofile = post_param('installprofile', ''); if ($installprofile != '') { require_code('hooks/modules/admin_setupwizard_installprofiles/' . $installprofile); $object = object_factory('Hook_admin_setupwizard_installprofiles_' . $installprofile); $installprofileblocks = $object->default_blocks(); $block_options = $object->block_options(); } else { $installprofileblocks = array(); $block_options = array(); } $page_structure = _get_zone_pages($installprofileblocks, $block_options, $collapse_zones, $installprofile); $zone_structure = array_pop($page_structure); $preview = do_template('SETUPWIZARD_BLOCK_PREVIEW', array('LEFT' => $zone_structure['left'], 'RIGHT' => $zone_structure['right'], 'START' => $zone_structure['start'])); return array($preview, NULL); }
/** * Standard modular run function for setting features from the setup wizard. */ function set_fields() { if (get_forum_type() != 'ocf') { return; } $dbs_back = $GLOBALS['NO_DB_SCOPE_CHECK']; $GLOBALS['NO_DB_SCOPE_CHECK'] = true; require_lang('ocf'); if (post_param_integer('have_default_rank_set', 0) == 0) { $test = $GLOBALS['SITE_DB']->query_value_null_ok('f_groups', 'id', array('id' => db_get_first_id() + 8)); if (!is_null($test)) { $promotion_target = ocf_get_group_property(db_get_first_id() + 8, 'promotion_target'); if (!is_null($promotion_target)) { $GLOBALS['SITE_DB']->query_update('f_groups', array('g_promotion_target' => NULL, 'g_promotion_threshold' => NULL, 'g_rank_image' => ''), array('id' => db_get_first_id() + 8), '', 1); for ($i = db_get_first_id() + 4; $i < db_get_first_id() + 8; $i++) { require_code('ocf_groups_action'); require_code('ocf_groups_action2'); ocf_delete_group($i); } } $_name = ocf_get_group_property(db_get_first_id() + 8, 'name'); if (is_integer($_name)) { lang_remap($_name, do_lang('MEMBER')); } } } if (post_param_integer('have_default_full_emoticon_set', 0) == 0) { $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'f_emoticons WHERE e_code<>\':P\' AND e_code<>\';)\' AND e_code<>\':)\' AND e_code<>\':)\' AND e_code<>\':\\\'(\''); } if (post_param_integer('have_default_cpf_set', 0) == 0) { $fields = array('im_aim', 'im_msn', 'im_yahoo', 'im_skype', 'interests', 'location', 'occupation'); foreach ($fields as $field) { $test = $GLOBALS['SITE_DB']->query_value_null_ok('f_custom_fields f LEFT JOIN ' . get_table_prefix() . 'translate t ON t.id=f.cf_name', 'f.id', array('text_original' => do_lang('DEFAULT_CPF_' . $field . '_NAME'))); if (!is_null($test)) { require_code('ocf_members_action'); require_code('ocf_members_action2'); ocf_delete_custom_field($test); } } } $GLOBALS['NO_DB_SCOPE_CHECK'] = $dbs_back; }
/** * Standard modular render function for profile tabs edit hooks. * * @param MEMBER The ID of the member who is being viewed * @param MEMBER The ID of the member who is doing the viewing * @param boolean Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later * @return ?array A tuple: The tab title, the tab body text (may be blank), the tab fields, extra Javascript (may be blank) the suggested tab order, hidden fields (optional) (NULL: if $leave_to_ajax_if_possible was set) */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { $title = do_lang_tempcode('PHOTO'); $order = 30; // Actualiser if (post_param_integer('submitting_photo_tab', 0) == 1) { require_code('ocf_members_action'); require_code('ocf_members_action2'); ocf_member_choose_photo('photo_url', 'photo_file', $member_id_of); attach_message(do_lang_tempcode('SUCCESS_SAVE'), 'inform'); } if ($leave_to_ajax_if_possible) { return NULL; } $photo_url = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_photo_url'); $thumb_url = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_photo_thumb_url'); // UI fields $fields = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'photo_file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('URL')), do_lang_tempcode('DESCRIPTION_ALTERNATE_URL'), 'photo_url', $photo_url, false)); if (get_option('is_on_gd') == '0' || !function_exists('imagetypes')) { $thumb_width = get_option('thumb_width'); $fields->attach(form_input_upload(do_lang_tempcode('THUMBNAIL'), do_lang_tempcode('DESCRIPTION_THUMBNAIL', escape_html($thumb_width)), 'photo_file2', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('URL')), do_lang_tempcode('DESCRIPTION_ALTERNATE_URL'), 'photo_thumb_url', $thumb_url, false)); } $hidden = new ocp_tempcode(); handle_max_file_size($hidden, 'image'); $hidden->attach(form_input_hidden('submitting_photo_tab', '1')); $text = new ocp_tempcode(); require_code('images'); $max = floatval(get_max_image_size()) / floatval(1024 * 1024); if ($max < 3.0) { require_code('files2'); $config_url = get_upload_limit_config_url(); $text->attach(paragraph(do_lang_tempcode(is_null($config_url) ? 'MAXIMUM_UPLOAD' : 'MAXIMUM_UPLOAD_STAFF', escape_html($max > 10.0 ? integer_format(intval($max)) : float_format($max)), is_null($config_url) ? '' : escape_html($config_url)))); } $text = do_template('OCF_EDIT_PHOTO_TAB', array('TEXT' => $text, 'MEMBER_ID' => strval($member_id_of), 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($member_id_of), 'PHOTO' => $GLOBALS['FORUM_DRIVER']->get_member_photo_url($member_id_of))); $javascript = ''; return array($title, $fields, $text, $javascript, $order, $hidden); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { if (!array_key_exists('param', $map)) { $map['param'] = 'main'; } if (!array_key_exists('page', $map)) { $map['page'] = str_replace('-', '_', get_page_name()); } if (array_key_exists('extra_param_from', $map)) { $extra = '_' . $map['extra_param_from']; } else { $extra = ''; } require_code('feedback'); $submitted = post_param_integer('_comment_form_post', 0) == 1; $self_url = build_url(array('page' => '_SELF'), '_SELF', NULL, true, false, true); $self_title = $map['page']; $test_changed = post_param('title', NULL); if (!is_null($test_changed)) { decache('main_comments'); } $hidden = $submitted ? actualise_post_comment(true, 'block_main_comments', $map['page'] . '_' . $map['param'] . $extra, $self_url, $self_title, array_key_exists('forum', $map) ? $map['forum'] : NULL, false, NULL, get_page_name() == 'guestbook') : false; $out = new ocp_tempcode(); if (array_key_exists('title', $_POST) && $hidden && $submitted) { $out->attach(paragraph(do_lang_tempcode('MESSAGE_POSTED'), 'dsgdgdfl;gkd09')); if (get_forum_type() == 'ocf') { if (addon_installed('unvalidated')) { require_code('submit'); $validate_url = get_self_url(true, false, array('keep_session' => NULL)); $_validate_url = build_url(array('page' => 'topics', 'type' => 'validate_post', 'id' => $GLOBALS['LAST_POST_ID'], 'redirect' => $validate_url), get_module_zone('topics'), NULL, false, false, true); $validate_url = $_validate_url->evaluate(); send_validation_request('MAKE_POST', 'f_posts', false, $GLOBALS['LAST_POST_ID'], $validate_url); } } } $invisible_if_no_comments = array_key_exists('invisible_if_no_comments', $map) && $map['invisible_if_no_comments'] == '1'; $reverse = array_key_exists('reverse', $map) && $map['reverse'] == '1'; $allow_reviews = !array_key_exists('reviews', $map) || $map['reviews'] == '1'; $out->attach(get_comments('block_main_comments', true, $map['page'] . '_' . $map['param'] . $extra, $invisible_if_no_comments, array_key_exists('forum', $map) ? $map['forum'] : NULL, NULL, NULL, get_page_name() == 'guestbook', $reverse, NULL, $allow_reviews)); return $out; }
/** * Standard modular run function for preview hooks. * * @return array A pair: The preview, the updated post Comcode */ function run() { require_code('uploads'); $urls = get_url('', 'file', 'safe_mode_temp', 0, OCP_UPLOAD_IMAGE, false); if ($urls[0] == '') { if (!is_null(post_param_integer('id', NULL))) { $rows = $GLOBALS['SITE_DB']->query_select('calendar_types', array('t_logo'), array('id' => post_param_integer('id')), '', 1); $urls = $rows[0]; $url = find_theme_image($urls['t_logo']); } elseif (!is_null(post_param('theme_img_code', NULL))) { $url = find_theme_image(post_param('theme_img_code')); } else { warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD')); } } else { $url = $urls[0]; } require_code('images'); $preview = do_image_thumb(url_is_local($url) ? get_custom_base_url() . '/' . $url : $url, post_param('title'), true); return array($preview, NULL); }
/** * Move a menu branch. */ function menu_management_script() { $id = get_param_integer('id'); $to_menu = get_param('menu'); $changes = array('i_menu' => $to_menu); $rows = $GLOBALS['SITE_DB']->query_select('menu_items', array('*'), array('id' => $id), '', 1); if (array_key_exists(0, $rows)) { $row = $rows[0]; } else { $row = NULL; } $test = false; foreach (array_keys($test ? $_GET : $_POST) as $key) { $val = $test ? get_param($key) : post_param($key); $key = preg_replace('#\\_\\d+$#', '', $key); if ($key == 'caption' || $key == 'caption_long') { if (is_null($row)) { $changes['i_' . $key] = insert_lang($val, 2); } else { lang_remap($row['i_' . $key], $val); } } elseif ($key == 'url' || $key == 'theme_img_code') { $changes['i_' . $key] = $val; } elseif ($key == 'match_tags') { $changes['i_page_only'] = $val; } } $changes['i_order'] = post_param_integer('order_' . strval($id), 0); $changes['i_new_window'] = post_param_integer('new_window_' . strval($id), 0); $changes['i_check_permissions'] = post_param_integer('check_perms_' . strval($id), 0); $changes['i_expanded'] = 0; $changes['i_parent'] = NULL; if (is_null($row)) { $GLOBALS['SITE_DB']->query_insert('menu_items', $changes); } else { $GLOBALS['SITE_DB']->query_update('menu_items', $changes, array('id' => $id), '', 1); } }
/** * Standard modular run function for preview hooks. * * @return array A pair: The preview, the updated post Comcode */ function run() { require_code('uploads'); $cat = post_param('cat'); $urls = get_url('url', 'file', 'uploads/galleries' . (get_value('use_gallery_subdirs') == '1' ? '/' . $cat : ''), 0, OCP_UPLOAD_IMAGE, true, '', 'file2'); if ($urls[0] == '') { if (!is_null(post_param_integer('id', NULL))) { $rows = $GLOBALS['SITE_DB']->query_select('images', array('url', 'thumb_url'), array('id' => post_param_integer('id')), '', 1); $urls = $rows[0]; $url = $urls['url']; $thumb_url = $urls['thumb_url']; } else { warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD')); } } else { $url = $urls[0]; $thumb_url = $urls[1]; } require_code('images'); $thumb = do_image_thumb(url_is_local($thumb_url) ? get_custom_base_url() . '/' . $thumb_url : $thumb_url, post_param('comments'), true); $preview = hyperlink(url_is_local($url) ? get_custom_base_url() . '/' . $url : $url, $thumb); return array($preview, NULL); }
/** * Standard modular render function for profile tabs edit hooks. * * @param MEMBER The ID of the member who is being viewed * @param MEMBER The ID of the member who is doing the viewing * @param boolean Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later * @return ?array A tuple: The tab title, the tab body text (may be blank), the tab fields, extra Javascript (may be blank) the suggested tab order, hidden fields (optional) (NULL: if $leave_to_ajax_if_possible was set) */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { require_lang('notifications'); $title = do_lang_tempcode('NOTIFICATIONS'); $order = 100; if (strtoupper(ocp_srv('REQUEST_METHOD')) == 'POST') { $auto_monitor_contrib_content = post_param_integer('auto_monitor_contrib_content', 0); $GLOBALS['FORUM_DB']->query_update('f_members', array('m_auto_monitor_contrib_content' => $auto_monitor_contrib_content), array('id' => $member_id_of), '', 1); // Decache from run-time cache unset($GLOBALS['FORUM_DRIVER']->MEMBER_ROWS_CACHED[$member_id_of]); unset($GLOBALS['MEMBER_CACHE_FIELD_MAPPINGS'][$member_id_of]); } if ($leave_to_ajax_if_possible && strtoupper(ocp_srv('REQUEST_METHOD')) != 'POST') { return NULL; } require_code('notifications2'); $text = notifications_ui($member_id_of); if ($text->is_empty()) { return NULL; } $javascript = ''; return array($title, new ocp_tempcode(), $text, $javascript, $order); }
/** * 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); }
/** * The actualiser to delete all chat rooms. * * @return tempcode The UI */ function _delete_all() { $delete = post_param_integer('continue_delete', 0); if ($delete != 1) { return $this->misc(); } else { $title = get_page_title('DELETE_ALL_ROOMS'); delete_all_chatrooms(); return $this->do_next_manager($title, do_lang_tempcode('SUCCESS'), NULL); } }
/** * Standard modular render function for profile tabs edit hooks. * * @param MEMBER The ID of the member who is being viewed * @param MEMBER The ID of the member who is doing the viewing * @param boolean Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later * @return ?array A tuple: The tab title, the tab body text (may be blank), the tab fields, extra Javascript (may be blank) the suggested tab order, hidden fields (optional) (NULL: if $leave_to_ajax_if_possible was set) */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { $title = do_lang_tempcode('AVATAR'); $order = 20; // Actualiser if (post_param_integer('submitting_avatar_tab', 0) == 1) { require_code('uploads'); if (has_specific_permission($member_id_viewing, 'own_avatars')) { if (!(is_swf_upload(true) && array_key_exists('avatar_file', $_FILES) || array_key_exists('avatar_file', $_FILES) && is_uploaded_file($_FILES['avatar_file']['tmp_name']))) { $urls = array(); $stock = post_param('avatar_alt_url', ''); if ($stock == '') { $stock = post_param('avatar_stock', NULL); if (!is_null($stock)) { $urls[0] = $stock == '' ? '' : find_theme_image($stock, false, true); } else { $urls[0] = ''; } // None } else { if (url_is_local($stock) && !$GLOBALS['FORUM_DRIVER']->is_super_admin($member_id_viewing)) { $old = $GLOBALS['FORUM_DB']->query_value('f_members', 'm_avatar_url', array('id' => $member_id_of)); if ($old != $stock) { access_denied('ASSOCIATE_EXISTING_FILE'); } } $urls[0] = $stock; // URL } } else { // We have chosen an upload. Note that we will not be looking at alt_url at this point, even though it is specified below for canonical reasons $urls = get_url('avatar_alt_url', 'avatar_file', file_exists(get_custom_file_base() . '/uploads/avatars') ? 'uploads/avatars' : 'uploads/ocf_avatars', 0, OCP_UPLOAD_IMAGE, false, '', '', false, true); if ((get_base_url() != get_forum_base_url() || array_key_exists('on_msn', $GLOBALS['SITE_INFO']) && $GLOBALS['SITE_INFO']['on_msn'] == '1') && $urls[0] != '' && url_is_local($urls[0])) { $urls[0] = get_custom_base_url() . '/' . $urls[0]; } } $avatar_url = $urls[0]; } else { $stock = post_param('avatar_stock'); $avatar_url = $stock == '' ? '' : find_theme_image($stock, false, true); } require_code('ocf_members_action'); require_code('ocf_members_action2'); ocf_member_choose_avatar($avatar_url, $member_id_of); attach_message(do_lang_tempcode('SUCCESS_SAVE'), 'inform'); } if ($leave_to_ajax_if_possible) { return NULL; } // UI fields $avatar_url = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_avatar_url'); require_javascript('javascript_multi'); $fields = new ocp_tempcode(); require_code('form_templates'); require_code('themes2'); $ids = get_all_image_ids_type('ocf_default_avatars', true); $found_it = false; foreach ($ids as $id) { $pos = strpos($avatar_url, '/' . $id); $selected = $pos !== false; if ($selected) { $found_it = true; } } $hidden = new ocp_tempcode(); if (has_specific_permission($member_id_viewing, 'own_avatars')) { $javascript = 'standardAlternateFields(\'avatar_file\',\'avatar_alt_url\',\'avatar_stock*\',true);'; $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'avatar_file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); handle_max_file_size($hidden, 'image'); $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('URL')), do_lang_tempcode('DESCRIPTION_ALTERNATE_URL'), 'avatar_alt_url', $found_it ? '' : $avatar_url, false)); $fields->attach(form_input_picture_choose_specific(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('STOCK')), do_lang_tempcode('DESCRIPTION_ALTERNATE_STOCK'), 'avatar_stock', $ids, $avatar_url, NULL, NULL, true)); } else { $javascript = ''; $fields->attach(form_input_picture_choose_specific(do_lang_tempcode('STOCK'), '', 'avatar_stock', $ids, $avatar_url, NULL, NULL, true)); } if ($avatar_url != '') { if (url_is_local($avatar_url)) { $avatar_url = get_complex_base_url($avatar_url) . '/' . $avatar_url; } $avatar = do_template('OCF_TOPIC_POST_AVATAR', array('_GUID' => '50a5902f3ab7e384d9cf99577b222cc8', 'AVATAR' => $avatar_url)); } else { $avatar = do_lang_tempcode('NONE_EM'); } $width = ocf_get_member_best_group_property($member_id_of, 'max_avatar_width'); $height = ocf_get_member_best_group_property($member_id_of, 'max_avatar_height'); $text = do_template('OCF_EDIT_AVATAR_TAB', array('_GUID' => 'dbdac6ca3bc752b54d2a24a4c6e69c7c', 'MEMBER_ID' => strval($member_id_of), 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($member_id_of), 'AVATAR' => $avatar, 'WIDTH' => integer_format($width), 'HEIGHT' => integer_format($height))); $hidden = new ocp_tempcode(); $hidden->attach(form_input_hidden('submitting_avatar_tab', '1')); return array($title, $fields, $text, $javascript, $order, $hidden); }
/** * The actualiser to resign from a usergroup. * * @return tempcode The UI */ function resign() { $title = get_page_title('RESIGN_FROM_GROUP'); $id = post_param_integer('id', NULL); if (is_null($id)) { $id = get_param_integer('id'); $post_url = build_url(array('page' => '_SELF', 'type' => get_param('type')), '_SELF', NULL, true); $hidden = form_input_hidden('id', strval($id)); return do_template('YESNO_SCREEN', array('_GUID' => 'd9524899fbc243247a9d253cf93c8aa2', 'TITLE' => $title, 'TEXT' => do_lang_tempcode('Q_SURE'), 'URL' => $post_url, 'HIDDEN' => $hidden)); } ocf_member_leave_group($id, get_member()); $url = build_url(array('page' => '_SELF', 'type' => 'view', 'id' => $id), '_SELF'); return redirect_screen($title, $url, do_lang_tempcode('SUCCESS')); }