/** * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX. * * @return tempcode The snippet */ function run() { $type = get_param('type'); if (!has_zone_access(get_member(), 'adminzone')) { return new ocp_tempcode(); } decache('main_staff_checklist'); require_lang('staff_checklist'); switch ($type) { case 'add': $recurinterval = get_param_integer('recurinterval', 0); $task_title = get_param('tasktitle', false, true); $id = $GLOBALS['SITE_DB']->query_insert('customtasks', array('tasktitle' => $task_title, 'datetimeadded' => time(), 'recurinterval' => $recurinterval, 'recurevery' => get_param('recurevery'), 'taskisdone' => NULL), true); require_code('notifications'); $subject = do_lang('CT_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $task_title); $mail = do_lang('CT_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($task_title)); dispatch_notification('checklist_task', NULL, $subject, $mail); return do_template('BLOCK_MAIN_STAFF_CHECKLIST_CUSTOM_TASK', array('TASKTITLE' => comcode_to_tempcode(get_param('tasktitle', false, true)), 'DATETIMEADDED' => display_time_period(time()), 'RECURINTERVAL' => $recurinterval == 0 ? '' : integer_format($recurinterval), 'RECUREVERY' => get_param('recurevery'), 'TASKDONE' => 'not_completed', 'ID' => strval($id))); case 'delete': $GLOBALS['SITE_DB']->query_delete('customtasks', array('id' => get_param_integer('id')), '', 1); break; case 'mark_done': $GLOBALS['SITE_DB']->query_update('customtasks', array('taskisdone' => time()), array('id' => get_param_integer('id')), '', 1); break; case 'mark_undone': $GLOBALS['SITE_DB']->query_update('customtasks', array('taskisdone' => NULL), array('id' => get_param_integer('id')), '', 1); break; } return new ocp_tempcode(); }
/** * Standard modular run function for CRON hooks. Searches for tasks to perform. */ function run() { if (get_forum_type() != 'ocf') { return; } $time = time(); $last_time = intval(get_value('last_confirm_reminder_time')); if ($last_time > time() - 24 * 60 * 60 * 2) { return; } set_value('last_confirm_reminder_time', strval($time)); require_code('mail'); require_lang('ocf'); $GLOBALS['NO_DB_SCOPE_CHECK'] = true; $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'f_members WHERE ' . db_string_not_equal_to('m_validated_email_confirm_code', '') . ' AND m_join_time>' . strval($last_time)); $GLOBALS['NO_DB_SCOPE_CHECK'] = false; foreach ($rows as $row) { $coppa = get_option('is_on_coppa') == '1' && utctime_to_usertime(time() - mktime(0, 0, 0, $row['m_dob_month'], $row['m_dob_day'], $row['m_dob_year'])) / 31536000.0 < 13.0; if (!$coppa) { $zone = get_module_zone('join'); if ($zone != '') { $zone .= '/'; } $url = get_base_url() . '/' . $zone . 'index.php?page=join&type=step4&email=' . rawurlencode($row['m_email_address']) . '&code=' . $row['m_validated_email_confirm_code']; $url_simple = get_base_url() . '/' . $zone . 'index.php?page=join&type=step4'; $message = do_lang('OCF_SIGNUP_TEXT', comcode_escape(get_site_name()), comcode_escape($url), array($url_simple, $row['m_email_address'], strval($row['m_validated_email_confirm_code'])), $row['m_language']); mail_wrap(do_lang('CONFIRM_EMAIL_SUBJECT', get_site_name(), NULL, NULL, $row['m_language']), $message, array($row['m_email_address']), $row['m_username']); } } }
/** * Send a "your content has been validated" notification out to the submitter of some content. Only call if this is true ;). * * @param ID_TEXT Content type * @param ID_TEXT Content ID */ function send_content_validated_notification($content_type, $content_id) { require_code('content'); list($content_title, $submitter_id, , , , $content_url_safe) = content_get_details($content_type, $content_id); if (!is_null($content_url_safe)) { require_code('notifications'); require_lang('unvalidated'); $subject = do_lang('CONTENT_VALIDATED_NOTIFICATION_MAIL_SUBJECT', $content_title, get_site_name()); $mail = do_lang('CONTENT_VALIDATED_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($content_title), array($content_url_safe->evaluate())); dispatch_notification('content_validated', NULL, $subject, $mail, array($submitter_id)); } }
/** * Standard modular run function for CRON hooks. Searches for tasks to perform. */ function run() { if (!addon_installed('catalogues')) { return; } $last = get_value('last_classified_refresh'); $time = time(); if (!is_null($last) && intval($last) > $time - 60 * 60) { return; } // Don't do more than once per hour if (function_exists('set_time_limit')) { @set_time_limit(0); } $start = 0; do { $entries = $GLOBALS['SITE_DB']->query_select('catalogue_entries e JOIN ' . get_table_prefix() . 'classifieds_prices p ON p.c_catalogue_name=e.c_name', array('e.*'), array('ce_validated' => 1), '', 1000, $start); foreach ($entries as $entry) { if ($entry['ce_last_moved'] == $entry['ce_add_date']) { require_code('classifieds'); initialise_classified_listing($entry); } // Expiring if ($entry['ce_last_moved'] < $time) { $GLOBALS['SITE_DB']->query_update('catalogue_entries', array('ce_validated' => 0), array('id' => $entry['id']), '', 1); decache('main_cc_embed'); decache('main_recent_cc_entries'); require_code('catalogues2'); calculate_category_child_count_cache($entry['cc_id']); } elseif ($entry['ce_last_moved'] < $time + 60 * 60 * 24 && $entry['ce_last_moved'] > $time + 60 * 60 * 23) { // Expiring in 24 hours require_code('notifications'); require_lang('classifieds'); $member_id = $entry['ce_submitter']; $renew_url = build_url(array('page' => 'classifieds', 'type' => 'adverts', 'id' => $member_id), get_module_zone('classifieds')); require_code('catalogues'); $data_map = get_catalogue_entry_map($entry, NULL, 'CATEGORY', 'DEFAULT', NULL, NULL, array(0)); $ad_title = $data_map['FIELD_0_PLAIN']; if (is_object($ad_title)) { $ad_title = $ad_title->evaluate(); } $subject_tag = do_lang('SUBJECT_CLASSIFIED_ADVERT_EXPIRING', $ad_title, get_site_name(), NULL, get_lang($member_id), false); $mail = do_lang('MAIL_CLASSIFIED_ADVERT_EXPIRING', $ad_title, comcode_escape(get_site_name()), comcode_escape($renew_url->evaluate()), get_lang($member_id), false); // Send actual notification dispatch_notification('classifieds__' . $entry['c_name'], '', $subject_tag, $mail, array($member_id), A_FROM_SYSTEM_PRIVILEGED); } } } while (count($entries) == 1000); set_value('last_classified_refresh', strval($time)); }
/** * @license http://opensource.org/licenses/cpal_1.0 Common Public Attribution License * @copyright ocProducts Ltd * @package activity_feed */ function activities_addon_syndicate_described_activity($a_language_string_code = '', $a_label_1 = '', $a_label_2 = '', $a_label_3 = '', $a_pagelink_1 = '', $a_pagelink_2 = '', $a_pagelink_3 = '', $a_addon = '', $a_is_public = 1, $a_member_id = NULL, $sitewide_too = false, $a_also_involving = NULL) { require_code('activities'); require_lang('activities'); if (get_db_type() == 'xml' && get_param_integer('keep_testing_logging', 0) != 1) { return NULL; } $stored_id = 0; if (is_null($a_member_id)) { $a_member_id = get_member(); } if (is_guest($a_member_id)) { return NULL; } $go = array('a_language_string_code' => $a_language_string_code, 'a_label_1' => $a_label_1, 'a_label_2' => $a_label_2, 'a_label_3' => $a_label_3, 'a_is_public' => $a_is_public); $stored_id = mixed(); // Check if this has been posted previously (within the last 10 minutes) to // stop spamming but allow generalised repeat status messages. $test = $GLOBALS['SITE_DB']->query_select('activities', array('a_language_string_code', 'a_label_1', 'a_label_2', 'a_label_3', 'a_is_public'), NULL, 'WHERE a_time>' . strval(time() - 600), 1); if (!array_key_exists(0, $test) || $test[0] != $go || running_script('execute_temp')) { // Log the activity $row = $go + array('a_member_id' => $a_member_id, 'a_also_involving' => $a_also_involving, 'a_pagelink_1' => $a_pagelink_1, 'a_pagelink_2' => $a_pagelink_2, 'a_pagelink_3' => $a_pagelink_3, 'a_time' => time(), 'a_addon' => $a_addon, 'a_is_public' => $a_is_public); $stored_id = $GLOBALS['SITE_DB']->query_insert('activities', $row, true); // Update the latest activity file log_newest_activity($stored_id, 1000); // External places if ($a_is_public == 1 && !$GLOBALS['IS_ACTUALLY_ADMIN']) { $dests = find_all_hooks('systems', 'syndication'); foreach (array_keys($dests) as $hook) { require_code('hooks/systems/syndication/' . $hook); $ob = object_factory('Hook_Syndication_' . $hook); if ($ob->is_available()) { $ob->syndicate_user_activity($a_member_id, $row); if ($sitewide_too && has_specific_permission(get_member(), 'syndicate_site_activity') && post_param_integer('syndicate_this', 0) == 1) { $ob->syndicate_site_activity($row); } } } } list($message) = render_activity($row, false); require_code('notifications'); $username = $GLOBALS['FORUM_DRIVER']->get_username($a_member_id); $subject = do_lang('ACTIVITY_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $username, html_entity_decode(strip_tags($message->evaluate()), ENT_QUOTES, get_charset())); $mail = do_lang('ACTIVITY_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($username), array('[semihtml]' . $message->evaluate() . '[/semihtml]')); dispatch_notification('activity', strval($a_member_id), $subject, $mail); } return $stored_id; }
/** * Standard modular run function for CRON hooks. Searches for tasks to perform. */ function run() { if (!defined('MAXIMUM_DIGEST_LENGTH')) { define('MAXIMUM_DIGEST_LENGTH', 1024 * 100); // 100KB } require_code('notifications'); foreach (array(A_DAILY_EMAIL_DIGEST => 60 * 60 * 24, A_WEEKLY_EMAIL_DIGEST => 60 * 60 * 24 * 7, A_MONTHLY_EMAIL_DIGEST => 60 * 60 * 24 * 31) as $frequency => $timespan) { $start = 0; do { // Find where not tint-in-tin $members = $GLOBALS['SITE_DB']->query('SELECT DISTINCT d_to_member_id FROM ' . get_table_prefix() . 'digestives_consumed c JOIN ' . get_table_prefix() . 'digestives_tin t ON c.c_member_id=t.d_to_member_id AND c.c_frequency=' . strval($frequency) . ' WHERE c_time<' . strval(time() - $timespan) . ' AND c_frequency=' . strval($frequency), 100, $start); foreach ($members as $member) { require_lang('notifications'); $to_member_id = $member['d_to_member_id']; $to_name = $GLOBALS['FORUM_DRIVER']->get_username($to_member_id); $to_email = $GLOBALS['FORUM_DRIVER']->get_member_email_address($to_member_id); $messages = $GLOBALS['SITE_DB']->query_select('digestives_tin', array('d_subject', 'd_message', 'd_date_and_time'), array('d_to_member_id' => $to_member_id, 'd_frequency' => $frequency), 'ORDER BY d_date_and_time'); $GLOBALS['SITE_DB']->query_delete('digestives_tin', array('d_to_member_id' => $to_member_id, 'd_frequency' => $frequency)); $_message = ''; foreach ($messages as $message) { if ($_message != '') { $_message .= chr(10); } if (strlen($_message) + strlen($message['d_message']) < MAXIMUM_DIGEST_LENGTH) { $_message .= do_lang('DIGEST_EMAIL_INDIVIDUAL_MESSAGE_WRAP', comcode_escape($message['d_subject']), $message['d_message'], array(comcode_escape(get_site_name()), get_timezoned_date($message['d_date_and_time']))); } else { $_message .= do_lang('DIGEST_ITEM_OMITTED', comcode_escape($message['d_subject']), get_timezoned_date($message['d_date_and_time']), array(comcode_escape(get_site_name()))); } } if ($_message != '') { $wrapped_subject = do_lang('DIGEST_EMAIL_SUBJECT_' . strval($frequency), comcode_escape(get_site_name())); $wrapped_message = do_lang('DIGEST_EMAIL_MESSAGE_WRAP', $_message, comcode_escape(get_site_name())); require_code('mail'); mail_wrap($wrapped_subject, $wrapped_message, array($to_email), $to_name, get_option('staff_address'), get_site_name(), 3, NULL, true, A_FROM_SYSTEM_UNPRIVILEGED, false); $GLOBALS['SITE_DB']->query_update('digestives_consumed', array('c_time' => time()), array('c_member_id' => $to_member_id, 'c_frequency' => $frequency), '', 1); } } $start += 100; } while (count($members) == 100); } }
/** * Add to the newsletter, in the simplest way. * * @param EMAIL The email address of the subscriber * @param integer The interest level * @range 1 4 * @param ?LANGUAGE_NAME The language (NULL: users) * @param boolean Whether to require a confirmation mail * @param ?AUTO_LINK The newsletter to join (NULL: the first) * @param string Subscribers forename * @param string Subscribers surname * @return string Newsletter password */ function basic_newsletter_join($email, $interest_level = 4, $lang = NULL, $get_confirm_mail = false, $newsletter_id = NULL, $forename = '', $surname = '') { if (is_null($lang)) { $lang = user_lang(); } if (is_null($newsletter_id)) { $newsletter_id = db_get_first_id(); } $password = get_rand_password(); $code_confirm = $get_confirm_mail ? mt_rand(1, 9999999) : 0; $test = $GLOBALS['SITE_DB']->query_value_null_ok('newsletter_subscribe', 'the_level', array('newsletter_id' => $newsletter_id, 'email' => $email)); if ($test === 0) { $GLOBALS['SITE_DB']->query_delete('newsletter_subscribe', array('newsletter_id' => $newsletter_id, 'email' => $email), '', 1); $test = NULL; } if (is_null($test)) { require_lang('newsletter'); $test = $GLOBALS['SITE_DB']->query_value_null_ok('newsletter', 'email', array('email' => $email)); if (is_null($test)) { $salt = produce_salt(); $GLOBALS['SITE_DB']->query_insert('newsletter', array('n_forename' => $forename, 'n_surname' => $surname, 'join_time' => time(), 'email' => $email, 'code_confirm' => $code_confirm, 'pass_salt' => $salt, 'the_password' => md5($password . $salt), 'language' => $lang), false, true); // race condition if ($get_confirm_mail) { $_url = build_url(array('page' => 'newsletter', 'type' => 'confirm', 'email' => $email, 'confirm' => $code_confirm), get_module_zone('newsletter')); $url = $_url->evaluate(); $message = do_lang('NEWSLETTER_SIGNUP_TEXT', comcode_escape($url), comcode_escape($password), array($forename, $surname, $email, get_site_name()), $lang); require_code('mail'); mail_wrap(do_lang('NEWSLETTER_SIGNUP', NULL, NULL, NULL, $lang), $message, array($email)); } } else { $GLOBALS['SITE_DB']->query_update('newsletter', array('join_time' => time()), array('email' => $email), '', 1); $password = ''; } $GLOBALS['SITE_DB']->query_insert('newsletter_subscribe', array('newsletter_id' => $newsletter_id, 'the_level' => $interest_level, 'email' => $email), false, true); // race condition return $password; } return do_lang('NA'); }
/** * Add a buddy. * * @param MEMBER The member befriending * @param MEMBER The member being befriended * @param ?TIME The logged time of the friendship (NULL: now) */ function buddy_add($likes, $liked, $time = NULL) { if (is_null($time)) { $time = time(); } $GLOBALS['SITE_DB']->query_delete('chat_buddies', array('member_likes' => $likes, 'member_liked' => $liked), '', 1); // Just in case page refreshed $GLOBALS['SITE_DB']->query_insert('chat_buddies', array('member_likes' => $likes, 'member_liked' => $liked, 'date_and_time' => $time)); // Send a notification if (is_null($GLOBALS['SITE_DB']->query_value_null_ok('chat_buddies', 'date_and_time', array('member_likes' => $liked, 'member_liked' => $likes)))) { require_lang('chat'); require_code('notifications'); $to_name = $GLOBALS['FORUM_DRIVER']->get_username($liked); $from_name = $GLOBALS['FORUM_DRIVER']->get_username($likes); $subject_tag = do_lang('YOURE_MY_BUDDY_SUBJECT', $from_name, get_site_name(), NULL, get_lang($liked)); $befriend_url = build_url(array('page' => 'chat', 'type' => 'buddy_add', 'member_id' => $likes), get_module_zone('chat'), NULL, false, false, true); $message_raw = do_lang('YOURE_MY_BUDDY_BODY', comcode_escape($to_name), comcode_escape(get_site_name()), array($befriend_url->evaluate(), comcode_escape($from_name)), get_lang($liked)); dispatch_notification('new_buddy', NULL, $subject_tag, $message_raw, array($liked), $likes); // Log the action log_it('MAKE_BUDDY', strval($likes), strval($liked)); syndicate_described_activity('chat:PEOPLE_NOW_FRIENDS', $to_name, '', '', '_SEARCH:members:view:' . strval($liked), '_SEARCH:members:view:' . strval($likes), '', 'chat', 1, $likes); syndicate_described_activity('chat:PEOPLE_NOW_FRIENDS', $to_name, '', '', '_SEARCH:members:view:' . strval($liked), '_SEARCH:members:view:' . strval($likes), '', 'chat', 1, $liked); } }
/** * Standard modular run function for CRON hooks. Searches for tasks to perform. */ function run() { $this_birthday_day = date('d/m/Y'); if (get_long_value('last_birthday_day') !== $this_birthday_day) { set_long_value('last_birthday_day', $this_birthday_day); require_lang('ocf'); require_code('ocf_general'); $_birthdays = ocf_find_birthdays(); $birthdays = new ocp_tempcode(); foreach ($_birthdays as $_birthday) { $member_url = $GLOBALS['OCF_DRIVER']->member_profile_url($_birthday['id'], false, true); $username = $_birthday['username']; $birthday_url = build_url(array('page' => 'topics', 'type' => 'birthday', 'id' => $_birthday['username']), get_module_zone('topics')); require_code('notifications'); $subject = do_lang('BIRTHDAY_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $username); $mail = do_lang('BIRTHDAY_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($username), array($member_url->evaluate(), $birthday_url->evaluate())); if (addon_installed('chat')) { $friends = $GLOBALS['SITE_DB']->query_select('chat_buddies', array('member_likes'), array('member_liked' => $_birthday['id'])); dispatch_notification('ocf_friend_birthday', NULL, $subject, $mail, collapse_1d_complexity('member_likes', $friends)); } dispatch_notification('ocf_birthday', NULL, $subject, $mail); } } }
/** * Add a post. * * @param AUTO_LINK The ID of the topic to add the post to. * @param SHORT_TEXT The title of the post (may be blank). * @param LONG_TEXT The post. * @param BINARY Whether to skip showing the posters signature in the post. * @param boolean Whether the post is the first in the topic. * @param ?BINARY Whether the post is validated (NULL: unknown, find whether it needs to be marked unvalidated initially). * @param BINARY Whether the post is marked emphasised. * @param ?string The name of the person making the post (NULL: username of current member). * @param ?IP The IP address the post is to be made under (NULL: IP of current user). * @param ?TIME The time of the post (NULL: now). * @param ?MEMBER The poster (NULL: current member). * @param ?MEMBER The member that this post is intended solely for (NULL: public). * @param ?TIME The last edit time of the post (NULL: never edited). * @param ?MEMBER The member that was last to edit the post (NULL: never edited). * @param boolean Whether to check permissions for whether the post may be made as it is given. * @param boolean Whether to update the caches after making the post. * @param ?AUTO_LINK The forum the post will be in (NULL: find out from the DB). * @param boolean Whether to allow attachments in this post. * @param ?string The title of the topic (NULL: find from the DB). * @param BINARY Whether the topic is a sunk topic. * @param ?AUTO_LINK Force an ID (NULL: don't force an ID) * @param boolean Whether to make the post anonymous * @param boolean Whether to skip post checks * @param boolean Whether this is for a new Private Topic * @param boolean Whether to explicitly insert the Comcode with admin privileges * @param ?AUTO_LINK Parent post ID (NULL: none-threaded/root-of-thread) * @return AUTO_LINK The ID of the new post. */ function ocf_make_post($topic_id, $title, $post, $skip_sig = 0, $is_starter = false, $validated = NULL, $is_emphasised = 0, $poster_name_if_guest = NULL, $ip_address = NULL, $time = NULL, $poster = NULL, $intended_solely_for = NULL, $last_edit_time = NULL, $last_edit_by = NULL, $check_permissions = true, $update_cacheing = true, $forum_id = NULL, $support_attachments = true, $topic_title = '', $sunk = 0, $id = NULL, $anonymous = false, $skip_post_checks = false, $is_pt = false, $insert_comcode_as_admin = false, $parent_id = NULL) { if (is_null($poster)) { $poster = get_member(); } if ($check_permissions) { if (strlen($title) > 120) { warn_exit(do_lang_tempcode('TITLE_TOO_LONG')); } if (get_option('prevent_shouting') == '1') { if (strtoupper($title) == $title) { $title = ucwords($title); } } if (is_null($intended_solely_for) && !$skip_post_checks) { ocf_check_post($post, $topic_id, $poster); } } if (is_null($ip_address)) { $ip_address = get_ip_address(); } if (is_null($time)) { $time = time(); $send_notification = true; } else { $send_notification = false; } if (is_null($poster_name_if_guest)) { if ($poster == $GLOBALS['OCF_DRIVER']->get_guest_id() || $anonymous) { $poster_name_if_guest = do_lang('GUEST'); } else { $poster_name_if_guest = $GLOBALS['OCF_DRIVER']->get_username($poster); if (is_null($poster_name_if_guest)) { $poster_name_if_guest = do_lang('UNKNOWN'); } } } if (is_null($forum_id) || $topic_title == '' && !$is_starter) { $info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('t_is_open', 't_pt_from', 't_pt_to', 't_forum_id', 't_cache_last_member_id', 't_cache_first_title'), array('id' => $topic_id), '', 1); if (!array_key_exists(0, $info)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $forum_id = $info[0]['t_forum_id']; $topic_title = $info[0]['t_cache_first_title']; if ($topic_title == '') { $topic_title = $title; } if ($check_permissions) { if ($info[0]['t_pt_from'] != get_member() && $info[0]['t_pt_to'] != get_member() && !ocf_has_special_pt_access($topic_id) && !has_specific_permission(get_member(), 'view_other_pt') && is_null($forum_id)) { access_denied('I_ERROR'); } } } if (is_null($forum_id)) { if ($check_permissions && $poster == $GLOBALS['OCF_DRIVER']->get_guest_id()) { access_denied('I_ERROR'); } $validated = 1; // Personal posts always validated } else { if ($check_permissions) { if ($info[0]['t_is_open'] == 0 && !ocf_may_moderate_forum($forum_id)) { access_denied('I_ERROR'); } $last_member_id = $info[0]['t_cache_last_member_id']; if (!ocf_may_post_in_topic($forum_id, $topic_id, $last_member_id) && !$is_starter) { access_denied('I_ERROR'); } } } // Ensure parent post is from the same topic if (!is_null($parent_id)) { $test_topic_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_posts', 'p_topic_id', array('id' => $parent_id), ' AND ' . ocf_get_topic_where($topic_id, $poster)); if (is_null($test_topic_id)) { $parent_id = NULL; } } if (is_null($validated) || $validated == 1 && $check_permissions) { if (!is_null($forum_id) && !has_specific_permission(get_member(), 'bypass_validation_lowrange_content', 'topics', array('forums', $forum_id))) { $validated = 0; } else { $validated = 1; } } if (!$support_attachments) { $lang_id = insert_lang_comcode($post, 4, $GLOBALS['FORUM_DB'], $insert_comcode_as_admin); } else { $lang_id = 0; } if (!addon_installed('unvalidated')) { $validated = 1; } $map = array('p_title' => substr($title, 0, 255), 'p_post' => $lang_id, 'p_ip_address' => $ip_address, 'p_time' => $time, 'p_poster' => $anonymous ? db_get_first_id() : $poster, 'p_poster_name_if_guest' => substr($poster_name_if_guest, 0, 80), 'p_validated' => $validated, 'p_topic_id' => $topic_id, 'p_is_emphasised' => $is_emphasised, 'p_cache_forum_id' => $forum_id, 'p_last_edit_time' => $last_edit_time, 'p_last_edit_by' => $last_edit_by, 'p_intended_solely_for' => $intended_solely_for, 'p_skip_sig' => $skip_sig, 'p_parent_id' => $parent_id); if (!is_null($id)) { $map['id'] = $id; } $post_id = $GLOBALS['FORUM_DB']->query_insert('f_posts', $map, true); if ($support_attachments) { require_code('attachments2'); $lang_id = insert_lang_comcode_attachments(4, $post, 'ocf_post', strval($post_id), $GLOBALS['FORUM_DB']); $GLOBALS['FORUM_DB']->query_update('f_posts', array('p_post' => $lang_id), array('id' => $post_id), '', 1); } $_url = build_url(array('page' => 'topicview', 'type' => 'findpost', 'id' => $post_id), 'forum', NULL, false, false, true, 'post_' . strval($post_id)); $url = $_url->evaluate(); if ($validated == 0) { if ($check_permissions) { // send_validation_mail is used for other content - but forum is special $subject = do_lang('POST_REQUIRING_VALIDATION_MAIL_SUBJECT', $topic_title, NULL, NULL, get_site_default_lang()); $post_text = get_translated_text($lang_id, $GLOBALS['FORUM_DB'], get_site_default_lang()); $mail = do_lang('POST_REQUIRING_VALIDATION_MAIL', comcode_escape($url), comcode_escape($poster_name_if_guest), $post_text); require_code('notifications'); dispatch_notification('needs_validation', NULL, $subject, $mail); } } else { if ($check_permissions) { if ($send_notification) { $post_comcode = get_translated_text($lang_id, $GLOBALS['FORUM_DB']); require_code('ocf_posts_action2'); ocf_send_topic_notification($url, $topic_id, $forum_id, $anonymous ? db_get_first_id() : $poster, $is_starter, $post_comcode, $topic_title, $intended_solely_for, $is_pt); // Send a notification for the inline PP if (!is_null($intended_solely_for)) { require_code('notifications'); $msubject = do_lang('NEW_PERSONAL_POST_SUBJECT', $topic_title, NULL, NULL, get_lang($intended_solely_for)); $mmessage = do_lang('NEW_PERSONAL_POST_MESSAGE', comcode_escape($GLOBALS['FORUM_DRIVER']->get_username($anonymous ? db_get_first_id() : $poster)), comcode_escape($topic_title), array(comcode_escape($url), $post_comcode), get_lang($intended_solely_for)); dispatch_notification('ocf_new_pt', NULL, $msubject, $mmessage, array($intended_solely_for), $anonymous ? db_get_first_id() : $poster); } } } } if ($check_permissions) { // Is the user gonna automatically enable notifications for this? $auto_monitor_contrib_content = $GLOBALS['OCF_DRIVER']->get_member_row_field($poster, 'm_auto_monitor_contrib_content'); if ($auto_monitor_contrib_content == 1) { require_code('notifications'); enable_notifications('ocf_topic', strval($topic_id), $poster); } } if ($update_cacheing) { if (function_exists('get_member')) { if (function_exists('ocf_ping_topic_read')) { ocf_ping_topic_read($topic_id); } if (is_null($forum_id)) { $with = $info[0]['t_pt_from']; if ($with == get_member()) { $with = $info[0]['t_pt_to']; } decache('side_ocf_personal_topics', array($with)); decache('_new_pp', array($with)); } if (get_option('show_post_validation') == '1') { decache('main_staff_checklist'); } } if (is_null($intended_solely_for)) { if ($validated == 1) { require_code('ocf_posts_action2'); ocf_force_update_topic_cacheing($topic_id, 1, true, $is_starter, $post_id, $time, $title, $lang_id, $poster_name_if_guest, $poster); } if ($validated == 1) { if (!is_null($forum_id)) { require_code('ocf_posts_action2'); // Find if the topic is validated. This can be approximate, if we don't get 1 then ocf_force_update_forum_cacheing will do a search, making the code very slightly slower if (!$check_permissions || is_null($forum_id)) { $topic_validated = 1; } else { if ($is_starter) { $topic_validated = has_specific_permission($poster, 'bypass_validation_midrange_content', 'topics', array('forums', $forum_id)) ? 1 : 0; } else { $topic_validated = $GLOBALS['FORUM_DB']->query_value('f_topics', 't_validated', array('id' => $topic_id)); } } ocf_force_update_forum_cacheing($forum_id, $is_starter ? 1 : 0, 1, $topic_validated == 0 ? NULL : $topic_id, $topic_validated == 0 ? NULL : $topic_title, $topic_validated == 0 ? NULL : $time, $topic_validated == 0 ? NULL : $poster_name_if_guest, $topic_validated == 0 ? NULL : $poster, $topic_validated == 0 ? NULL : $forum_id); } } } // Update post count if (!is_null($forum_id)) { $post_counts = is_null($forum_id) ? 1 : $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'f_post_count_increment', array('id' => $forum_id)); if ($post_counts === 1 && !$anonymous && $validated == 1) { ocf_force_update_member_post_count($poster, 1); } if ($check_permissions) { ocf_decache_ocp_blocks($forum_id, NULL, $intended_solely_for); } // i.e. we don't run this if in installer } if ($poster != $GLOBALS['OCF_DRIVER']->get_guest_id()) { require_code('ocf_posts_action2'); ocf_member_handle_promotion($poster); } } return $post_id; }
/** * UI to add note to an order * * @return tempcode The interface. */ function add_note() { require_code('form_templates'); $id = get_param_integer('id'); $redirect_url = get_param('redirect', NULL); $last_action = get_param('last_act', NULL); breadcrumb_set_parents(array(array('_SEARCH:admin_ecommerce:ecom_usage', do_lang_tempcode('ECOMMERCE')), array('_SELF:_SELF:misc', do_lang_tempcode('ORDERS')), array('_SELF:_SELF:show_orders', do_lang_tempcode('ORDER_LIST')))); $update_url = build_url(array('page' => '_SELF', 'type' => '_add_note', 'redirect' => $redirect_url), '_SELF'); $fields = new ocp_tempcode(); $note = $GLOBALS['SITE_DB']->query_value('shopping_order', 'notes', array('id' => $id)); if (!is_null($last_action)) { $note .= do_lang('ADD_NOTE_UPPEND_TEXT', get_timezoned_date(time(), true, false, true, true), do_lang('ORDER_STATUS_' . $last_action)); } $fields->attach(form_input_text(do_lang_tempcode('NOTE'), do_lang_tempcode('NOTE_DESCRIPTION'), 'note', $note, true)); $fields->attach(form_input_hidden('order_id', strval($id))); $title = get_page_title('ADD_NOTE_TITLE', true, array(strval($id))); if ($last_action == 'dispatched') { //Display dispatch mail preview $res = $GLOBALS['SITE_DB']->query_select('shopping_order', array('*'), array('id' => $id), '', 1); $order_det = $res[0]; $member_name = $GLOBALS['FORUM_DRIVER']->get_username($order_det['c_member']); $message = do_lang('ORDER_DISPATCHED_MAIL_MESSAGE', comcode_escape(get_site_name()), comcode_escape($member_name), array(strval($id)), get_lang($order_det['c_member'])); $fields->attach(form_input_text(do_lang_tempcode('DISPATCH_MAIL_PREVIEW'), do_lang_tempcode('DISPATCH_MAIL_PREVIEW_DESCRIPTION'), 'dispatch_mail_content', $message, true)); } return do_template('FORM_SCREEN', array('TITLE' => $title, 'TEXT' => do_lang_tempcode('NOTE_DESCRIPTION'), 'HIDDEN' => '', 'FIELDS' => $fields, 'URL' => $update_url, 'SUBMIT_NAME' => do_lang_tempcode('ADD_NOTE'))); }
/** * Edit a video in a specified gallery. * * @param AUTO_LINK The ID of the entry to edit * @param SHORT_TEXT Video title * @param ID_TEXT The gallery name * @param LONG_TEXT The video comments * @param URLPATH The URL to the actual video * @param URLPATH The URL to the thumbnail of the actual video * @param BINARY Whether the video has been validated for display on the site * @param BINARY Whether the video may be rated * @param BINARY Whether the video may be commented upon * @param BINARY Whether the video may be trackbacked * @param LONG_TEXT Hidden notes associated with the video * @param integer The length of the video * @param integer The width of the video * @param integer The height of the video * @param SHORT_TEXT Meta keywords * @param LONG_TEXT Meta description */ function edit_video($id, $title, $cat, $comments, $url, $thumb_url, $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes, $video_length, $video_width, $video_height, $meta_keywords, $meta_description) { require_code('urls2'); suggest_new_idmoniker_for('galleries', 'video', strval($id), $title == '' ? $comments : $title); $_title = $GLOBALS['SITE_DB']->query_value('videos', 'title', array('id' => $id)); $_comments = $GLOBALS['SITE_DB']->query_value('videos', 'comments', array('id' => $id)); require_code('files2'); delete_upload('uploads/galleries', 'videos', 'url', 'id', $id, $url); delete_upload('uploads/galleries_thumbs', 'videos', 'thumb_url', 'id', $id, $thumb_url); require_code('transcoding'); $url = transcode_video($url, 'videos', 'url', NULL, 'video_width', 'video_height'); if (!addon_installed('unvalidated')) { $validated = 1; } require_code('submit'); $just_validated = !content_validated('video', strval($id)) && $validated == 1; if ($just_validated) { send_content_validated_notification('video', strval($id)); } $GLOBALS['SITE_DB']->query_update('videos', array('title' => lang_remap_comcode($_title, $title), 'edit_date' => time(), 'allow_rating' => $allow_rating, 'allow_comments' => $allow_comments, 'allow_trackbacks' => $allow_trackbacks, 'notes' => $notes, 'validated' => $validated, 'cat' => $cat, 'comments' => lang_remap_comcode($_comments, $comments), 'url' => $url, 'thumb_url' => $thumb_url, 'video_length' => $video_length, 'video_width' => $video_width, 'video_height' => $video_height), array('id' => $id), '', 1); $self_url = build_url(array('page' => 'galleries', 'type' => 'video', 'id' => $id), get_module_zone('galleries'), NULL, false, false, true); if ($just_validated) { require_lang('galleries'); require_code('notifications'); $subject = do_lang('VIDEO_NOTIFICATION_MAIL_SUBJECT', get_site_name(), strip_comcode($title)); $mail = do_lang('VIDEO_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($title), array(comcode_escape($self_url->evaluate()))); dispatch_notification('gallery_entry', $cat, $subject, $mail); } log_it('EDIT_VIDEO', strval($id), $title); require_code('seo2'); seo_meta_set_for_explicit('video', strval($id), $meta_keywords, $meta_description); decache('main_gallery_embed'); require_lang('galleries'); require_code('feedback'); update_spacer_post($allow_comments != 0, 'videos', strval($id), $self_url, do_lang('VIEW_VIDEO', '', '', '', get_site_default_lang()), get_value('comment_forum__videos')); }
/** * The actualiser for uploading a file. * * @return tempcode The UI. */ function module_do_upload() { if (!has_specific_permission(get_member(), 'upload_filedump')) { access_denied('I_ERROR'); } $title = get_page_title('FILEDUMP_UPLOAD'); if (function_exists('set_time_limit')) { @set_time_limit(0); } // Slowly uploading a file can trigger time limit, on some servers $place = filter_naughty(post_param('place')); require_code('uploads'); if (!is_swf_upload(true) && (!array_key_exists('file', $_FILES) || !is_uploaded_file($_FILES['file']['tmp_name']))) { $attach_name = 'file'; $max_size = get_max_file_size(); if (isset($_FILES[$attach_name]) && ($_FILES[$attach_name]['error'] == 1 || $_FILES[$attach_name]['error'] == 2)) { warn_exit(do_lang_tempcode('FILE_TOO_BIG', integer_format($max_size))); } elseif (isset($_FILES[$attach_name]) && ($_FILES[$attach_name]['error'] == 3 || $_FILES[$attach_name]['error'] == 6 || $_FILES[$attach_name]['error'] == 7)) { warn_exit(do_lang_tempcode('ERROR_UPLOADING_' . strval($_FILES[$attach_name]['error']))); } else { warn_exit(do_lang_tempcode('ERROR_UPLOADING')); } } $file = $_FILES['file']['name']; if (get_magic_quotes_gpc()) { $file = stripslashes($file); } if (!has_specific_permission(get_member(), 'upload_anything_filedump') || get_file_base() != get_custom_file_base()) { check_extension($file); } $file = str_replace('.', '-', basename($file, '.' . get_file_extension($file))) . '.' . get_file_extension($file); if (!file_exists(get_custom_file_base() . '/uploads/filedump' . $place . $file)) { $max_size = get_max_file_size(); if ($_FILES['file']['size'] > $max_size) { warn_exit(do_lang_tempcode('FILE_TOO_BIG', integer_format(intval($max_size)))); } $full = get_custom_file_base() . '/uploads/filedump' . $place . $file; if (is_swf_upload(true)) { @rename($_FILES['file']['tmp_name'], $full) or warn_exit(do_lang_tempcode('FILE_MOVE_ERROR', escape_html($file), escape_html('uploads/filedump' . $place))); } else { @move_uploaded_file($_FILES['file']['tmp_name'], $full) or warn_exit(do_lang_tempcode('FILE_MOVE_ERROR', escape_html($file), escape_html('uploads/filedump' . $place))); } fix_permissions($full); sync_file($full); $return_url = build_url(array('page' => '_SELF', 'place' => $place), '_SELF'); $test = $GLOBALS['SITE_DB']->query_value_null_ok('filedump', 'description', array('name' => $file, 'path' => $place)); if (!is_null($test)) { delete_lang($test); } $GLOBALS['SITE_DB']->query_delete('filedump', array('name' => $file, 'path' => $place), '', 1); $description = post_param('description'); $GLOBALS['SITE_DB']->query_insert('filedump', array('name' => $file, 'path' => $place, 'the_member' => get_member(), 'description' => insert_lang_comcode($description, 3))); require_code('notifications'); $subject = do_lang('FILEDUMP_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $file, $place); $mail = do_lang('FILEDUMP_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($file), array(comcode_escape($place), comcode_escape($description))); dispatch_notification('filedump', $place, $subject, $mail); log_it('FILEDUMP_UPLOAD', $file, $place); if (has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), get_page_name(), get_zone_name())) { syndicate_described_activity('filedump:ACTIVITY_FILEDUMP_UPLOAD', $place . '/' . $file, '', '', '', '', '', 'filedump'); } return redirect_screen($title, $return_url, do_lang_tempcode('SUCCESS')); } else { warn_exit(do_lang_tempcode('OVERWRITE_ERROR')); } return new ocp_tempcode(); }
/** * Find if the given member id and password is valid. If username is NULL, then the member id is used instead. * All authorisation, cookies, and form-logins, are passed through this function. * Some forums do cookie logins differently, so a Boolean is passed in to indicate whether it is a cookie login. * * @param ?SHORT_TEXT The member username (NULL: don't use this in the authentication - but look it up using the ID if needed) * @param ?MEMBER The member id (NULL: use member name) * @param MD5 The md5-hashed password * @param string The raw password * @param boolean Whether this is a cookie login, determines how the hashed password is treated for the value passed in * @return array A map of 'id' and 'error'. If 'id' is NULL, an error occurred and 'error' is set */ function forum_authorise_login($username, $userid, $password_hashed, $password_raw, $cookie_login = false) { $out = array(); $out['id'] = NULL; require_code('ocf_members'); require_code('ocf_groups'); if (!function_exists('require_lang')) { require_code('lang'); } if (!function_exists('do_lang_tempcode')) { require_code('tempcode'); } if (!function_exists('require_lang')) { return $out; } require_lang('ocf'); require_code('mail'); $skip_auth = false; if ($userid === NULL) { $rows = $this->connection->query('SELECT * FROM ' . $this->connection->get_table_prefix() . 'f_members WHERE ' . db_string_equal_to('m_username', $username), 1); if (!array_key_exists(0, $rows) && get_option('one_per_email_address') == '1') { $rows = $this->connection->query('SELECT * FROM ' . $this->connection->get_table_prefix() . 'f_members WHERE ' . db_string_equal_to('m_email_address', $username) . ' ORDER BY id ASC', 1); } if (array_key_exists(0, $rows)) { $this->MEMBER_ROWS_CACHED[$rows[0]['id']] = $rows[0]; $userid = $rows[0]['id']; } } else { $rows[0] = $this->get_member_row($userid); } // LDAP to the rescue if we couldn't get a row global $LDAP_CONNECTION; if (!array_key_exists(0, $rows) && $LDAP_CONNECTION !== NULL && $userid === NULL) { // See if LDAP has it -- if so, we can add $test = ocf_is_on_ldap($username); if (!$test) { $out['error'] = is_null($username) ? do_lang_tempcode('USER_NO_EXIST') : do_lang_tempcode('_USER_NO_EXIST', escape_html($username)); return $out; } $test_auth = ocf_ldap_authorise_login($username, $password_raw); if ($test_auth['m_pass_hash_salted'] == '!!!') { $out['error'] = do_lang_tempcode('USER_BAD_PASSWORD'); return $out; } if ($test) { require_code('ocf_members_action'); require_code('ocf_members_action2'); $completion_form_submitted = trim(post_param('email_address', '')) != ''; if (!$completion_form_submitted && get_value('no_finish_profile') !== '1') { @ob_end_clean(); if (!function_exists('do_header')) { require_code('site'); } $middle = ocf_member_external_linker_ask($username, 'ldap', ocf_ldap_guess_email($username)); $tpl = globalise($middle, NULL, '', true); $tpl->evaluate_echo(); exit; } else { $userid = ocf_member_external_linker($username, uniqid('', true), 'ldap'); $row = $this->get_member_row($userid); } } } if (!array_key_exists(0, $rows) || $rows[0] === NULL) { $out['error'] = is_null($username) ? do_lang_tempcode('USER_NO_EXIST') : do_lang_tempcode('_USER_NO_EXIST', escape_html($username)); return $out; } $row = $rows[0]; // Now LDAP can kick in and get the correct hash if (ocf_is_ldap_member($userid)) { //$rows[0]['m_pass_hash_salted']=ocf_get_ldap_hash($userid); // Doesn't exist any more? This is a special case - the 'LDAP member' exists in our DB, but not LDAP. It has been deleted from LDAP or LDAP server has jumped /*if (is_null($rows[0]['m_pass_hash_salted'])) { $out['error']=(do_lang_tempcode('_USER_NO_EXIST',$username)); return $out; } No longer appropriate with new authentication mode - instead we just have to give an invalid password message */ $row = array_merge($row, ocf_ldap_authorise_login($username, $password_hashed)); } if (addon_installed('unvalidated')) { if ($row['m_validated'] == 0) { $out['error'] = do_lang_tempcode('USER_NOT_VALIDATED_STAFF'); return $out; } } if ($row['m_validated_email_confirm_code'] != '') { $out['error'] = do_lang_tempcode('USER_NOT_VALIDATED_EMAIL'); return $out; } if ($this->is_banned($row['id'])) { $out['error'] = do_lang_tempcode('USER_BANNED'); return $out; } // Check password if (!$skip_auth) { // Choose a compatibility screen. // Note that almost all cookie logins are the same. This is because the cookie logins use OCF cookies, regardless of compatibility scheme. $password_compatibility_scheme = $row['m_password_compat_scheme']; switch ($password_compatibility_scheme) { case 'remote': // This will work too - we're logging in with the username of a remote profile, so no resynching will happen // This will work too - we're logging in with the username of a remote profile, so no resynching will happen case '': // ocPortal style salted MD5 algorithm if ($cookie_login) { if ($password_hashed !== $row['m_pass_hash_salted']) { require_code('tempcode'); // This can be incidental even in fast AJAX scripts, if an old invalid cookie is present, so we need tempcode for do_lang_tempcode $out['error'] = do_lang_tempcode('USER_BAD_PASSWORD'); return $out; } } else { if (md5($row['m_pass_salt'] . $password_hashed) !== $row['m_pass_hash_salted']) { $out['error'] = do_lang_tempcode('USER_BAD_PASSWORD'); return $out; } } break; case 'plain': if ($password_hashed !== md5($row['m_pass_hash_salted'])) { $out['error'] = do_lang_tempcode('USER_BAD_PASSWORD'); return $out; } break; case 'md5': // Old style plain md5 (also works if both are unhashed: used for LDAP) if ($password_hashed !== $row['m_pass_hash_salted'] && $password_hashed != '!!!') { $out['error'] = do_lang_tempcode('USER_BAD_PASSWORD'); return $out; } break; /* case 'httpauth': // This is handled in get_member() */ break; case 'ldap': if ($password_hashed !== $row['m_pass_hash_salted']) { $out['error'] = do_lang_tempcode('USER_BAD_PASSWORD'); return $out; } break; default: $path = get_file_base() . '/sources_custom/hooks/systems/ocf_auth/' . $password_compatibility_scheme . '.php'; if (!file_exists($path)) { $path = get_file_base() . '/sources/hooks/systems/ocf_auth/' . $password_compatibility_scheme . '.php'; } if (!file_exists($path)) { $out['error'] = do_lang_tempcode('UNKNOWN_AUTH_SCHEME_IN_DB'); return $out; } require_code('hooks/systems/ocf_auth/' . $password_compatibility_scheme); $ob = object_factory('Hook_ocf_auth_' . $password_compatibility_scheme); $error = $ob->auth($username, $userid, $password_hashed, $password_raw, $cookie_login, $row); if (!is_null($error)) { $out['error'] = $error; return $out; } break; } } // Ok, authorised basically, but we need to see if this is a valid login IP if (ocf_get_best_group_property($this->get_members_groups($row['id']), 'enquire_on_new_ips') == 1) { global $SENT_OUT_VALIDATE_NOTICE; $ip = get_ip_address(3); $test2 = $this->connection->query_value_null_ok('f_member_known_login_ips', 'i_val_code', array('i_member_id' => $row['id'], 'i_ip' => $ip)); if ((is_null($test2) || $test2 != '') && !compare_ip_address($ip, $row['m_ip_address'])) { if (!$SENT_OUT_VALIDATE_NOTICE) { if (!is_null($test2)) { $this->connection->query_delete('f_member_known_login_ips', array('i_member_id' => $row['id'], 'i_ip' => $ip), '', 1); } $code = !is_null($test2) ? $test2 : uniqid('', true); $this->connection->query_insert('f_member_known_login_ips', array('i_val_code' => $code, 'i_member_id' => $row['id'], 'i_ip' => $ip)); $url = find_script('validateip') . '?code=' . $code; $url_simple = find_script('validateip'); require_code('comcode'); $mail = do_lang('IP_VERIFY_MAIL', comcode_escape($url), comcode_escape(get_ip_address()), array($url_simple, $code), get_lang($row['id'])); $email_address = $row['m_email_address']; if ($email_address == '') { $email_address = get_option('staff_address'); } if (running_script('index')) { mail_wrap(do_lang('IP_VERIFY_MAIL_SUBJECT', NULL, NULL, NULL, get_lang($row['id'])), $mail, array($email_address), $row['m_username'], '', '', 1); } $SENT_OUT_VALIDATE_NOTICE = true; } $out['error'] = do_lang_tempcode('REQUIRES_IP_VALIDATION'); return $out; } } $this->ocf_flood_control($row['id']); $out['id'] = $row['id']; return $out; }
/** * Send out a notification of some new news. * * @param AUTO_LINK The ID of the news * @param SHORT_TEXT The title * @param AUTO_LINK The main news category */ function dispatch_news_notification($id, $title, $main_news_category) { $self_url = build_url(array('page' => 'news', 'type' => 'view', 'id' => $id), get_module_zone('news'), NULL, false, false, true); $is_blog = !is_null($GLOBALS['SITE_DB']->query_value('news_categories', 'nc_owner', array('id' => $main_news_category))); require_code('notifications'); require_lang('news'); if ($is_blog) { $subject = do_lang('BLOG_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $title); $mail = do_lang('BLOG_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($title), array($self_url->evaluate())); dispatch_notification('news_entry', strval($main_news_category), $subject, $mail); } else { $subject = do_lang('NEWS_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $title); $mail = do_lang('NEWS_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($title), array($self_url->evaluate())); dispatch_notification('news_entry', strval($main_news_category), $subject, $mail); } }
/** * Send out a notification, as a topic just got a new post. * * @param URLPATH The URL to view the new post. * @param AUTO_LINK The ID of the topic that got posted in. * @param ?AUTO_LINK The forum that the topic is in (NULL: find out from the DB). * @param MEMBER The member that made the post triggering this tracking notification. * @param boolean Whether the post started a new topic. * @param LONG_TEXT The post, in Comcode format. * @param SHORT_TEXT The topic title (blank: look it up from the $topic_id). If non-blank we must use it as it is implying the database might not have the correct value yet. * @param ?MEMBER Only send the notification to this member (NULL: no such limit). * @param boolean Whether this is for a Private Topic. * @param ?ID_TEXT DO NOT send notifications to: The notification code (NULL: no restriction) * @param ?SHORT_TEXT DO NOT send notifications to: The category within the notification code (NULL: none / no restriction) */ function ocf_send_topic_notification($url, $topic_id, $forum_id, $sender_member_id, $is_starter, $post, $topic_title, $_limit_to = NULL, $is_pt = false, $no_notify_for__notification_code = NULL, $no_notify_for__code_category = NULL) { if (is_null($forum_id) && $is_starter) { return; } if ($topic_title == '') { $topic_info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('t_pt_to', 't_pt_from', 't_cache_first_title'), array('id' => $topic_id), '', 1); if (!array_key_exists(0, $topic_info)) { return; } // Topic's gone missing somehow (e.g. race condition) $topic_title = $topic_info[0]['t_cache_first_title']; } $sender_username = $GLOBALS['FORUM_DRIVER']->get_username($sender_member_id); $subject = do_lang($is_starter ? 'TOPIC_NOTIFICATION_MAIL_SUBJECT' : 'POST_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $topic_title); $mail = do_lang($is_starter ? 'TOPIC_NOTIFICATION_MAIL' : 'POST_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($url), array(comcode_escape($sender_username), $post, $topic_title)); $limit_to = is_null($_limit_to) ? array() : array($_limit_to); if ($is_pt) { $topic_info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('t_pt_to', 't_pt_from', 't_cache_first_title'), array('id' => $topic_id), '', 1); if (!array_key_exists(0, $topic_info)) { return; } // Topic's gone missing somehow (e.g. race condition) $limit_to[] = $topic_info[0]['t_pt_to']; $limit_to[] = $topic_info[0]['t_pt_from']; $limit_to = array_merge($limit_to, collapse_1d_complexity('s_member_id', $GLOBALS['FORUM_DB']->query_select('f_special_pt_access', array('s_member_id'), array('s_topic_id' => $topic_id)))); } require_code('notifications'); dispatch_notification('ocf_topic', strval($topic_id), $subject, $mail, count($limit_to) == 0 ? NULL : $limit_to, $sender_member_id, 3, false, false, $no_notify_for__notification_code, $no_notify_for__code_category); }
/** * Send a new-PT notification. * * @param AUTO_LINK The ID of the post made * @param SHORT_TEXT PT title * @param AUTO_LINK ID of the topic * @param MEMBER Member getting the PT * @param ?MEMBER Member posting the PT (NULL: current member) * @param ?mixed Post language ID or post text (NULL: unknown, lookup from $post_id) * @param boolean Whether to also mark the topic as unread */ function send_pt_notification($post_id, $subject, $topic_id, $to_id, $from_id = NULL, $post = NULL, $mark_unread = false) { if (is_null($from_id)) { $from_id = get_member(); } $post_lang_id = is_integer($post) ? $post : $GLOBALS['FORUM_DB']->query_value('f_posts', 'p_post', array('id' => $post_id)); $post_comcode = get_translated_text((int) $post_lang_id, $GLOBALS['FORUM_DB']); require_code('notifications'); $msubject = do_lang('NEW_PERSONAL_TOPIC_SUBJECT', $subject, NULL, NULL, get_lang($to_id)); $mmessage = do_lang('NEW_PERSONAL_TOPIC_MESSAGE', comcode_escape($GLOBALS['FORUM_DRIVER']->get_username($from_id)), comcode_escape($subject), array(comcode_escape($GLOBALS['FORUM_DRIVER']->topic_url($topic_id)), $post_comcode), get_lang($to_id)); dispatch_notification('ocf_new_pt', NULL, $msubject, $mmessage, array($to_id), $from_id); if ($mark_unread) { $GLOBALS['FORUM_DB']->query_delete('f_read_logs', array('l_topic_id' => $topic_id, 'l_member_id' => $to_id), '', 1); } }
/** * Dispatch a notification about a CEDI page * * @param AUTO_LINK The page ID * @param ID_TEXT The action type * @set ADD EDIT */ function dispatch_cedi_page_notification($page_id, $type) { $page_name = get_translated_text($GLOBALS['SITE_DB']->query_value('seedy_pages', 'title', array('id' => $page_id))); $_the_message = get_translated_text($GLOBALS['SITE_DB']->query_value('seedy_pages', 'description', array('id' => $page_id))); $_view_url = build_url(array('page' => 'cedi', 'type' => 'misc', 'id' => $page_id == db_get_first_id() ? NULL : $page_id), get_page_zone('cedi'), NULL, false, false, true); $view_url = $_view_url->evaluate(); $their_username = $GLOBALS['FORUM_DRIVER']->get_username(get_member()); $subject = do_lang($type . '_CEDI_PAGE_SUBJECT', $page_name, NULL, NULL, get_site_default_lang()); $message_raw = do_lang($type . '_CEDI_PAGE_BODY', comcode_escape($their_username), comcode_escape($page_name), array(comcode_escape($view_url), $_the_message), get_site_default_lang()); require_code('notifications'); dispatch_notification('cedi', strval($page_id), $subject, $message_raw); }
/** * Set the poll. * * @param AUTO_LINK The poll ID to set */ function set_poll($id) { persistant_cache_delete('POLL'); $rows = $GLOBALS['SITE_DB']->query_select('poll', array('question', 'submitter'), array('id' => $id)); $question = $rows[0]['question']; $submitter = $rows[0]['submitter']; log_it('CHOOSE_POLL', strval($id), get_translated_text($question)); if (has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'polls')) { syndicate_described_activity('polls:ACTIVITY_CHOOSE_POLL', get_translated_text($question), '', '', '_SEARCH:polls:view:' . strval($id), '', '', 'polls'); } if (!is_guest($submitter) && addon_installed('points')) { require_code('points2'); $_points_chosen = get_option('points_CHOOSE_POLL'); if (is_null($_points_chosen)) { $points_chosen = 35; } else { $points_chosen = intval($_points_chosen); } if ($points_chosen != 0) { system_gift_transfer(do_lang('POLL'), $points_chosen, $submitter); } } $GLOBALS['SITE_DB']->query_update('poll', array('is_current' => 0), array('is_current' => 1)); $GLOBALS['SITE_DB']->query_update('poll', array('is_current' => 1, 'date_and_time' => time()), array('id' => $id), '', 1); decache('main_poll'); require_lang('polls'); require_code('notifications'); $subject = do_lang('POLL_CHOSEN_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $question); $poll_url = build_url(array('page' => 'polls', 'type' => 'view', 'id' => $id), get_module_zone('polls'), NULL, false, false, true); $mail = do_lang('POLL_CHOSEN_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape(get_translated_text($question)), $poll_url->evaluate()); dispatch_notification('poll_chosen', NULL, $subject, $mail); }
/** * Log an action * * @param ID_TEXT The type of activity just carried out (a lang string) * @param ?SHORT_TEXT The most important parameter of the activity (e.g. id) (NULL: none) * @param ?SHORT_TEXT A secondary (perhaps, human readable) parameter of the activity (e.g. caption) (NULL: none) */ function _log_it($type, $a = NULL, $b = NULL) { if (!function_exists('get_member')) { return; } // If this is during installation if (get_option('site_closed') == '1' && get_option('no_stats_when_closed', true) === '1') { return; } // Run hooks, if any exist $hooks = find_all_hooks('systems', 'upon_action_logging'); foreach (array_keys($hooks) as $hook) { require_code('hooks/systems/upon_action_logging/' . filter_naughty($hook)); $ob = object_factory('upon_action_logging' . filter_naughty($hook), true); if (is_null($ob)) { continue; } $ob->run($type, $a, $b); } $ip = get_ip_address(); $GLOBALS['SITE_DB']->query_insert('adminlogs', array('the_type' => $type, 'param_a' => is_null($a) ? '' : substr($a, 0, 80), 'param_b' => is_null($b) ? '' : substr($b, 0, 80), 'date_and_time' => time(), 'the_user' => get_member(), 'ip' => $ip)); decache('side_tag_cloud'); decache('main_staff_actions'); decache('main_staff_checklist'); decache('main_awards'); decache('main_multi_content'); decache('side_stored_menu'); // Due to the content counts in the CMS/Admin Zones if (get_page_name() != 'admin_themewizard' && get_page_name() != 'admin_import') { require_all_lang(); static $logged = 0; $logged++; if ($logged < 10) { require_all_lang(); if (is_null($a)) { $a = do_lang('NA'); } if (is_null($a)) { $a = do_lang('NA'); } require_code('notifications'); $subject = do_lang('ACTIONLOG_NOTIFICATION_MAIL_SUBJECT', get_site_name(), do_lang($type), array($a, $b)); $mail = do_lang('ACTIONLOG_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape(do_lang($type)), array(is_null($a) ? '' : comcode_escape($a), is_null($b) ? '' : comcode_escape($b))); if (addon_installed('actionlog')) { dispatch_notification('actionlog', $type, $subject, $mail); } } } }
/** * Display a catalogue entry * * @param AUTO_LINK Entry ID * @param boolean Whether to skip rendering a title * @return tempcode Tempcode interface to display an entry */ function render_catalogue_entry_screen($id, $no_title = false) { require_code('feedback'); if (addon_installed('ecommerce')) { require_code('ecommerce'); } require_code('images'); require_css('catalogues'); require_lang('catalogues'); $entries = $GLOBALS['SITE_DB']->query_select('catalogue_entries', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $entries)) { return warn_screen(get_page_title('CATALOGUES'), do_lang_tempcode('MISSING_RESOURCE')); } $entry = $entries[0]; $categories = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('*'), array('id' => $entry['cc_id']), '', 1); if (!array_key_exists(0, $categories)) { warn_exit(do_lang_tempcode('CAT_NOT_FOUND', strval($entry['cc_id']))); } $category = $categories[0]; $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=catalogues&filter=' . strval($entry['cc_id']); $catalogue_name = $category['c_name']; $catalogues = $GLOBALS['SITE_DB']->query_select('catalogues', array('*'), array('c_name' => $catalogue_name), '', 1); if (!array_key_exists(0, $catalogues)) { warn_exit(do_lang_tempcode('CATALOGUE_NOT_FOUND', $catalogue_name)); } $catalogue = $catalogues[0]; // Permission for here? if (!has_category_access(get_member(), 'catalogues_catalogue', $catalogue_name)) { access_denied('CATALOGUE_ACCESS'); } if (get_value('disable_cat_cat_perms') !== '1' && !has_category_access(get_member(), 'catalogues_category', strval($entry['cc_id']))) { access_denied('CATEGORY_ACCESS'); } $ecommerce = is_ecommerce_catalogue($catalogue_name); if ($ecommerce) { $tpl_set = 'products'; } else { $tpl_set = $catalogue_name; } $root = get_param_integer('root', NULL); $map = get_catalogue_entry_map($entry, $catalogue, 'PAGE', $tpl_set, $root, NULL, NULL, true, true); if (get_db_type() != 'xml') { $entry['ce_views']++; $GLOBALS['SITE_DB']->query_update('catalogue_entries', array('ce_views' => $entry['ce_views']), array('id' => $id), '', 1, NULL, false, true); } // Validation if ($entry['ce_validated'] == 0) { if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) { access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated'); } $map['WARNINGS'] = do_template('WARNING_TABLE', array('_GUID' => 'bf604859a572ca53e969bec3d91f9cfb', 'WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT'))); } else { $map['WARNINGS'] = ''; } //Finding any hook exists for this product-------------------- if (addon_installed('ecommerce')) { $object = find_product(strval($id)); if (is_object($object) && method_exists($object, 'get_custom_product_map_fields')) { $object->get_custom_product_map_fields($id, $map); } } //------------------------------------------------------------ $map['ENTRY'] = do_template('CATALOGUE_' . $tpl_set . '_ENTRY', $map, NULL, false, 'CATALOGUE_DEFAULT_ENTRY'); $map['ADD_DATE'] = get_timezoned_date($entry['ce_add_date']); $map['ADD_DATE_RAW'] = strval($entry['ce_add_date']); $map['EDIT_DATE'] = is_null($entry['ce_edit_date']) ? '' : get_timezoned_date($entry['ce_edit_date']); $map['EDIT_DATE_RAW'] = is_null($entry['ce_edit_date']) ? '' : strval($entry['ce_edit_date']); $map['VIEWS'] = integer_format($entry['ce_views']); $title_to_use = do_lang_tempcode($catalogue_name . '__CATALOGUE_ENTRY', $map['FIELD_0']); $title_to_use_2 = do_lang($catalogue_name . '__CATALOGUE_ENTRY', $map['FIELD_0_PLAIN'], NULL, NULL, NULL, false); if (is_null($title_to_use_2)) { $title_to_use = do_lang_tempcode('DEFAULT__CATALOGUE_ENTRY', $map['FIELD_0']); $title_to_use_2 = do_lang('DEFAULT__CATALOGUE_ENTRY', $map['FIELD_0_PLAIN']); } if ($no_title) { $map['TITLE'] = new ocp_tempcode(); } else { if (addon_installed('awards')) { require_code('awards'); $awards = find_awards_for('catalogue_entry', strval($id)); } else { $awards = array(); } $map['TITLE'] = get_page_title($title_to_use, false, NULL, NULL, $awards); } $map['SUBMITTER'] = strval($entry['ce_submitter']); require_code('seo2'); if (is_object($title_to_use_2)) { $title_to_use_2 = $title_to_use_2->evaluate(); } seo_meta_load_for('catalogue_entry', strval($id), strip_tags($title_to_use_2)); if ($map['TREE'] === '') { $map['TREE'] = new ocp_tempcode(); $url = build_url(array('page' => '_SELF', 'type' => 'index', 'id' => $catalogue_name), '_SELF'); $map['TREE']->attach(hyperlink($url, escape_html(get_translated_text($catalogue['c_title'])), false, false, do_lang('INDEX'))); $map['TREE']->attach(do_template('BREADCRUMB_ESCAPED')); $url = build_url(array('page' => '_SELF', 'type' => 'category', 'id' => $category['id']), '_SELF'); $map['TREE']->attach(hyperlink($url, escape_html(get_translated_text($category['cc_title'])), false, false, do_lang('GO_BACKWARDS_TO', get_translated_text($category['cc_title'])), NULL, NULL, 'up')); } $map['CATEGORY_TITLE'] = get_translated_text($category['cc_title']); $map['CAT'] = strval($entry['cc_id']); $map['TAGS'] = get_loaded_tags('catalogue_entries'); breadcrumb_add_segment($map['TREE'], $title_to_use); if (is_null($root)) { breadcrumb_set_parents(array(array('_SELF:_SELF:misc' . ($ecommerce ? ':ecommerce=1' : ''), do_lang('CATALOGUES')))); } $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $entry['ce_add_date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($entry['ce_submitter']), 'publisher' => '', 'modified' => is_null($entry['ce_edit_date']) ? '' : date('Y-m-d', $entry['ce_edit_date']), 'type' => get_translated_text($catalogue['c_title']) . ' entry', 'title' => comcode_escape($title_to_use_2), 'identifier' => '_SEARCH:catalogues:entry:' . strval($id), 'description' => ''); return do_template('CATALOGUE_' . $tpl_set . '_ENTRY_SCREEN', $map, NULL, false, 'CATALOGUE_DEFAULT_ENTRY_SCREEN'); }
/** * Send out a notification to a member. * * @param MEMBER Member to send to * @param integer Listening setting * @param ID_TEXT The notification code to use * @param ?SHORT_TEXT The category within the notification code (NULL: none) * @param SHORT_TEXT Message subject (in Comcode) * @param LONG_TEXT Message body (in Comcode) * @param integer The member ID doing the sending. Either a USER or a negative number (e.g. A_FROM_SYSTEM_UNPRIVILEGED) * @param integer The message priority (1=urgent, 3=normal, 5=low) * @range 1 5 * @param boolean Whether to NOT CC to the CC address * @return boolean New $no_cc setting */ function _dispatch_notification_to_member($to_member_id, $setting, $notification_code, $code_category, $subject, $message, $from_member_id, $priority, $no_cc) { // Fish out some general details of the sender $to_name = $GLOBALS['FORUM_DRIVER']->get_username($to_member_id); $from_email = ''; $from_name = ''; if (!is_null($from_member_id) && $from_member_id >= 0) { /*$from_email=$GLOBALS['FORUM_DRIVER']->get_member_email_address($from_member_id); No; we can't disclose email addresses, so notifications will all be emailed from system if ($from_email=='') $from_email=''; $from_name=$GLOBALS['FORUM_DRIVER']->get_username($from_member_id);*/ } $db = substr($notification_code, 0, 4) == 'ocf_' ? $GLOBALS['FORUM_DB'] : $GLOBALS['SITE_DB']; // If none-specified, we'll need to be clever now if ($setting == A__STATISTICAL) { $setting = _find_member_statistical_notification_type($to_member_id); } $needs_manual_cc = true; $message_to_send = $message; // May get tweaked, if we have some kind of error to explain, etc // Send according to the listen setting... if (_notification_setting_available(A_INSTANT_SMS, $to_member_id)) { if (($setting & A_INSTANT_SMS) != 0) { $wrapped_message = do_lang('NOTIFICATION_SMS_COMPLETE_WRAP', $subject, $message_to_send); // Lang string may be modified to include {2}, but would cost more. Default just has {1}. require_code('sms'); $successes = sms_wrap($wrapped_message, array($to_member_id)); if ($successes == 0) { $setting = $setting | A_INSTANT_EMAIL; // Make sure it also goes to email then $message_to_send = do_lang('INSTEAD_OF_SMS', $message); } } } if (_notification_setting_available(A_INSTANT_EMAIL, $to_member_id)) { if (($setting & A_INSTANT_EMAIL) != 0) { $to_email = $GLOBALS['FORUM_DRIVER']->get_member_email_address($to_member_id); if ($to_email != '') { $wrapped_subject = do_lang('NOTIFICATION_EMAIL_SUBJECT_WRAP', $subject, comcode_escape(get_site_name())); $wrapped_message = do_lang('NOTIFICATION_EMAIL_MESSAGE_WRAP', $message_to_send, comcode_escape(get_site_name())); mail_wrap($wrapped_subject, $wrapped_message, array($to_email), $to_name, $from_email, $from_name, $priority, NULL, $no_cc, $from_member_id < 0 ? $GLOBALS['FORUM_DRIVER']->get_guest_id() : $from_member_id, $from_member_id == A_FROM_SYSTEM_PRIVILEGED, false); $needs_manual_cc = false; $no_cc = true; // Don't CC again } } } if (_notification_setting_available(A_DAILY_EMAIL_DIGEST, $to_member_id)) { if (($setting & A_DAILY_EMAIL_DIGEST) != 0 || ($setting & A_WEEKLY_EMAIL_DIGEST) != 0 || ($setting & A_MONTHLY_EMAIL_DIGEST) != 0) { foreach (array(A_DAILY_EMAIL_DIGEST, A_WEEKLY_EMAIL_DIGEST, A_MONTHLY_EMAIL_DIGEST) as $frequency) { if (($setting & $frequency) != 0) { $GLOBALS['SITE_DB']->query_insert('digestives_tin', array('d_subject' => $subject, 'd_message' => $message, 'd_from_member_id' => $from_member_id, 'd_to_member_id' => $to_member_id, 'd_priority' => $priority, 'd_no_cc' => $no_cc ? 1 : 0, 'd_date_and_time' => time(), 'd_notification_code' => substr($notification_code, 0, 80), 'd_code_category' => is_null($code_category) ? '' : $code_category, 'd_frequency' => $frequency)); $GLOBALS['SITE_DB']->query_insert('digestives_consumed', array('c_member_id' => $to_member_id, 'c_frequency' => $frequency, 'c_time' => time()), false, true); } } $needs_manual_cc = false; } } if (_notification_setting_available(A_INSTANT_PT, $to_member_id)) { if (($setting & A_INSTANT_PT) != 0) { require_code('ocf_topics_action'); require_code('ocf_posts_action'); $wrapped_subject = do_lang('NOTIFICATION_PT_SUBJECT_WRAP', $subject); $wrapped_message = do_lang('NOTIFICATION_PT_MESSAGE_WRAP', $message_to_send); // NB: These are posted by Guest (system) although the display name is set to the member triggering. This is intentional to stop said member getting unexpected replies. $topic_id = ocf_make_topic(NULL, $wrapped_subject, 'ocf_topic_modifiers/announcement', 1, 1, 0, 0, 0, db_get_first_id(), $to_member_id, false, 0, NULL, ''); ocf_make_post($topic_id, $wrapped_subject, $wrapped_message, 0, true, 1, 0, $from_member_id < 0 ? do_lang('SYSTEM') : $from_name, NULL, NULL, db_get_first_id(), NULL, NULL, NULL, false, true, NULL, true, $wrapped_subject, 0, NULL, true, true, true, $from_member_id == A_FROM_SYSTEM_PRIVILEGED); } } // Send to staff CC address regardless if (!$no_cc && $needs_manual_cc) { $no_cc = true; // Don't CC again $to_email = get_option('cc_address'); if ($to_email != '') { mail_wrap($subject, $message, array($to_email), $to_name, $from_email, $from_name, $priority, NULL, true, $from_member_id < 0 ? NULL : $from_member_id, $from_member_id == A_FROM_SYSTEM_PRIVILEGED, false); } } return $no_cc; }
/** * Arrange posts underneath a post in the thread (not including the post itself). * * @param ?AUTO_LINK Reference post in thread (NULL: root) * @param array Posts we will be rendering and have not arranged yet (only some of which will be underneath $post_id) * @param array Posts we won't be rendering * @param integer Maximum depth to render to * @param integer Current depth in recursion * @return array Array structure of rendered posts */ function _arrange_posts_in_tree($post_id, &$posts, $queue, $max_thread_depth, $depth = 0) { $rendered = array(); $non_rendered = array(); $posts_copy = $posts; // So the foreach's array iteration pointer is not corrupted by the iterations in our recursive calls (issue on some PHP versions) foreach ($posts_copy as $i => $p) { if ($p['parent_id'] === $post_id) { unset($posts[$i]); $children = $this->_arrange_posts_in_tree($p['id'], $posts, $queue, $max_thread_depth, $depth + 1); if ($depth + 1 >= $max_thread_depth) { foreach ($children[0] as $j => $c) { if (strpos($c['message_comcode'], '[quote') === false) { $c['message_comcode'] = '[quote="' . comcode_escape($p['username']) . '"]' . $p['message_comcode'] . '[/quote]' . "\n\n" . $c['message_comcode']; $new = do_template('COMCODE_QUOTE_BY', array('SAIDLESS' => false, 'BY' => $p['username'], 'CONTENT' => $p['message'])); $new->attach($c['message']); $c['message'] = $new; } $c['parent_id'] = $p['parent_id']; $children[0][$j] = $c; } $p['children'] = array(array(), array()); $rendered[] = $p; $rendered = array_merge($rendered, $children[0]); $non_rendered = array_merge($non_rendered, $children[1]); } else { $p['children'] = $children; $rendered[] = $p; } } } $non_rendered = array_merge($non_rendered, $this->_grab_at_and_underneath($post_id, $queue)); return array($rendered, $non_rendered); }
/** * Add comments to the specified resource. * * @param boolean Whether this resource allows comments (if not, this function does nothing - but it's nice to move out this common logic into the shared function) * @param ID_TEXT The type (download, etc) that this commenting is for * @param ID_TEXT The ID of the type that this commenting is for * @param mixed The URL to where the commenting will pass back to (to put into the comment topic header) (URLPATH or Tempcode) * @param ?string The title to where the commenting will pass back to (to put into the comment topic header) (NULL: don't know, but not first post so not important) * @param ?string The name of the forum to use (NULL: default comment forum) * @param boolean Whether to not require a captcha * @param ?BINARY Whether the post is validated (NULL: unknown, find whether it needs to be marked unvalidated initially). This only works with the OCF driver (hence is the last parameter). * @param boolean Whether to force allowance * @param boolean Whether to skip a success message * @param boolean Whether posts made should not be shared * @return boolean Whether a hidden post has been made */ function actualise_post_comment($allow_comments, $content_type, $content_id, $content_url, $content_title, $forum = NULL, $avoid_captcha = false, $validated = NULL, $explicit_allow = false, $no_success_message = false, $private = false) { if (!$explicit_allow) { if (get_option('is_on_comments') == '0' || !$allow_comments) { return false; } if (!has_specific_permission(get_member(), 'comment', get_page_name())) { return false; } } if (running_script('preview')) { return false; } $forum_tie = get_option('is_on_strong_forum_tie') == '1'; if (addon_installed('captcha')) { if (array_key_exists('post', $_POST) && $_POST['post'] != '' && !$avoid_captcha) { require_code('captcha'); enforce_captcha(); } } $post_title = post_param('title', NULL); if (is_null($post_title) && !$forum_tie) { return false; } $post = post_param('post', NULL); if ($post == do_lang('POST_WARNING')) { $post = ''; } if ($post == do_lang('THREADED_REPLY_NOTICE', do_lang('POST_WARNING'))) { $post = ''; } if ($post == '' && $post_title !== '') { $post = $post_title; $post_title = ''; } if ($post === '') { warn_exit(do_lang_tempcode('NO_PARAMETER_SENT', 'post')); } if (is_null($post)) { $post = ''; } $email = trim(post_param('email', '')); if ($email != '') { $body = '> ' . str_replace(chr(10), chr(10) . '> ', $post); if (substr($body, -2) == '> ') { $body = substr($body, 0, strlen($body) - 2); } if (get_page_name() != 'tickets') { $post .= '[staff_note]'; } $post .= "\n\n" . '[email subject="Re: ' . comcode_escape($post_title) . ' [' . get_site_name() . ']" body="' . comcode_escape($body) . '"]' . $email . '[/email]' . "\n\n"; if (get_page_name() != 'tickets') { $post .= '[/staff_note]'; } } $content_title = strip_comcode($content_title); if (is_null($forum)) { $forum = get_option('comments_forum_name'); } $content_url_flat = is_object($content_url) ? $content_url->evaluate() : $content_url; $_parent_id = post_param('parent_id', ''); $parent_id = $_parent_id == '' ? NULL : intval($_parent_id); $poster_name_if_guest = post_param('poster_name_if_guest', ''); list($topic_id, $is_hidden) = $GLOBALS['FORUM_DRIVER']->make_post_forum_topic($forum, $content_type . '_' . $content_id, get_member(), $post_title, $post, $content_title, do_lang('COMMENT'), $content_url_flat, NULL, NULL, $validated, $explicit_allow ? 1 : NULL, $explicit_allow, $poster_name_if_guest, $parent_id, false, !$private && $post != '' ? 'comment_posted' : NULL, !$private && $post != '' ? $content_type . '_' . $content_id : NULL); if (!is_null($topic_id)) { if (!is_integer($forum)) { $forum_id = $GLOBALS['FORUM_DRIVER']->forum_id_from_name($forum); } else { $forum_id = (int) $forum; } if (get_forum_type() == 'ocf' && !is_null($GLOBALS['LAST_POST_ID'])) { $extra_review_ratings = array(); global $REVIEWS_STRUCTURE; if (array_key_exists($content_type, $REVIEWS_STRUCTURE)) { $reviews_rating_criteria = $REVIEWS_STRUCTURE[$content_type]; } else { $reviews_rating_criteria[] = ''; } foreach ($reviews_rating_criteria as $rating_type) { // Has there actually been any rating? $rating = post_param_integer('review_rating__' . fix_id($rating_type), NULL); if (!is_null($rating)) { if ($rating > 10 || $rating < 1) { log_hack_attack_and_exit('VOTE_CHEAT'); } $GLOBALS['SITE_DB']->query_insert('review_supplement', array('r_topic_id' => $GLOBALS['LAST_TOPIC_ID'], 'r_post_id' => $GLOBALS['LAST_POST_ID'], 'r_rating_type' => $rating_type, 'r_rating_for_type' => $content_type, 'r_rating_for_id' => $content_id, 'r_rating' => $rating)); } } } } if (!$private && $post != '') { list(, $submitter, , $safe_content_url, $cma_info) = get_details_behind_feedback_code($content_type, $content_id); $content_type_title = $content_type; if (!is_null($cma_info) && isset($cma_info['content_type_label'])) { $content_type_title = do_lang($cma_info['content_type_label']); } // Notification require_code('notifications'); $username = $GLOBALS['FORUM_DRIVER']->get_username(get_member()); $subject = do_lang('NEW_COMMENT_SUBJECT', get_site_name(), $content_title == '' ? ocp_mb_strtolower($content_type_title) : $content_title, array($post_title, $username), get_site_default_lang()); $username = $GLOBALS['FORUM_DRIVER']->get_username(get_member()); $message_raw = do_lang('NEW_COMMENT_BODY', comcode_escape(get_site_name()), comcode_escape($content_title == '' ? ocp_mb_strtolower($content_type_title) : $content_title), array($post_title == '' ? do_lang('NO_SUBJECT') : $post_title, post_param('post'), comcode_escape($content_url_flat), comcode_escape($username)), get_site_default_lang()); dispatch_notification('comment_posted', $content_type . '_' . $content_id, $subject, $message_raw); // Is the user gonna automatically enable notifications for this? if (get_forum_type() == 'ocf') { $auto_monitor_contrib_content = $GLOBALS['OCF_DRIVER']->get_member_row_field(get_member(), 'm_auto_monitor_contrib_content'); if ($auto_monitor_contrib_content == 1) { enable_notifications('comment_posted', $content_type . '_' . $content_id); } } // Activity $real_content_type = convert_ocportal_type_codes('feedback_type_code', $content_type, 'cma_hook'); if (may_view_content_behind_feedback_code($GLOBALS['FORUM_DRIVER']->get_guest_id(), $real_content_type, $content_id)) { if (is_null($submitter)) { $submitter = $GLOBALS['FORUM_DRIVER']->get_guest_id(); } $activity_type = is_null($submitter) || is_guest($submitter) ? '_ADDED_COMMENT_ON' : 'ADDED_COMMENT_ON'; if ($content_title == '') { syndicate_described_activity($activity_type . '_UNTITLED', ocp_mb_strtolower($content_type_title), $content_type_title, '', url_to_pagelink(is_object($safe_content_url) ? $safe_content_url->evaluate() : $safe_content_url), '', '', convert_ocportal_type_codes('feedback_type_code', $content_type, 'addon_name'), 1, NULL, false, $submitter); } else { syndicate_described_activity($activity_type, $content_title, ocp_mb_strtolower($content_type_title), $content_type_title, url_to_pagelink(is_object($safe_content_url) ? $safe_content_url->evaluate() : $safe_content_url), '', '', convert_ocportal_type_codes('feedback_type_code', $content_type, 'addon_name'), 1, NULL, false, $submitter); } } } if ($post != '' && $forum_tie && !$no_success_message) { require_code('site2'); assign_refresh($GLOBALS['FORUM_DRIVER']->topic_url($GLOBALS['FORUM_DRIVER']->find_topic_id_for_topic_identifier($forum, $content_type . '_' . $content_id), $forum), 0.0); } if ($post != '' && !$no_success_message) { attach_message(do_lang_tempcode('SUCCESS')); } return $is_hidden; }
/** * 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')); }
/** * The UI for recommending the site. * * @return tempcode The UI. */ function gui() { require_code('form_templates'); global $EXTRA_HEAD; $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />'); // XHTMLXHTML global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'page_title'; $NON_CANONICAL_PARAMS[] = 'subject'; $NON_CANONICAL_PARAMS[] = 's_message'; $NON_CANONICAL_PARAMS[] = 'from'; $NON_CANONICAL_PARAMS[] = 'title'; $NON_CANONICAL_PARAMS[] = 'ocp'; $page_title = get_param('page_title', NULL, true); $submit_name = !is_null($page_title) ? make_string_tempcode($page_title) : do_lang_tempcode('SEND'); $post_url = build_url(array('page' => '_SELF', 'type' => 'actual'), '_SELF', NULL, true); $hidden = new ocp_tempcode(); $name = post_param('name', is_guest() ? '' : $GLOBALS['FORUM_DRIVER']->get_username(get_member())); $recommender_email_address = post_param('recommender_email_address', $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member())); $fields = new ocp_tempcode(); $fields->attach(form_input_line(do_lang_tempcode('YOUR_NAME'), '', 'name', $name, true)); $fields->attach(form_input_email(do_lang_tempcode('YOUR_EMAIL_ADDRESS'), '', 'recommender_email_address', $recommender_email_address, true)); $already = array(); foreach ($_POST as $key => $email_address) { if (substr($key, 0, 14) != 'email_address_') { continue; } if (get_magic_quotes_gpc()) { $email_address = stripslashes($email_address); } $already[] = $email_address; } if (is_guest()) { $fields->attach(form_input_email(do_lang_tempcode('FRIEND_EMAIL_ADDRESS'), '', 'email_address_0', array_key_exists(0, $already) ? $already[0] : '', true)); } else { $fields->attach(form_input_line_multi(do_lang_tempcode('FRIEND_EMAIL_ADDRESS'), do_lang_tempcode('THEIR_ADDRESS'), 'email_address_', $already, 1, NULL, 'email')); } if (may_use_invites() && get_forum_type() == 'ocf' && !is_guest()) { $invites = get_num_invites(get_member()); if ($invites > 0) { require_lang('ocf'); $invite = count($_POST) == 0 ? true : post_param_integer('invite', 0) == 1; $fields->attach(form_input_tick(do_lang_tempcode('USE_INVITE'), do_lang_tempcode('USE_INVITE_DESCRIPTION', $GLOBALS['FORUM_DRIVER']->is_super_admin(get_member()) ? do_lang('NA_EM') : integer_format($invites)), 'invite', $invite)); } } $message = post_param('message', NULL); $subject = get_param('subject', do_lang('RECOMMEND_MEMBER_SUBJECT', get_site_name()), true); if (is_null($message)) { $message = get_param('s_message', '', true); if ($message == '') { $from = get_param('from', NULL, true); if (!is_null($from)) { $resource_title = get_param('title', '', true); if ($resource_title == '') { $downloaded_at_link = http_download_file($from, 3000, false); if (is_string($downloaded_at_link)) { $matches = array(); if (preg_match('#\\s*<title[^>]*\\s*>\\s*(.*)\\s*\\s*<\\s*/title\\s*>#mi', $downloaded_at_link, $matches) != 0) { $resource_title = trim(str_replace('–', '-', str_replace('—', '-', @html_entity_decode($matches[1], ENT_QUOTES, get_charset())))); $resource_title = preg_replace('#^' . str_replace('#', '\\#', preg_quote(get_site_name())) . ' - #', '', $resource_title); $resource_title = preg_replace('#\\s+[^\\d\\s][^\\d\\s]?[^\\d\\s]?\\s+' . str_replace('#', '\\#', preg_quote(get_site_name())) . '$#i', '', $resource_title); } } } if ($resource_title == '') { $resource_title = do_lang('THIS'); // Could not find at all, so say 'this' } else { $subject = get_param('subject', do_lang('RECOMMEND_MEMBER_SUBJECT_SPECIFIC', get_site_name(), $resource_title), true); } $message = do_lang('FOUND_THIS_ON', get_site_name(), comcode_escape($from), comcode_escape($resource_title)); } } if (get_param_integer('ocp', 0) == 1) { $message = do_lang('RECOMMEND_OCPORTAL'); } } $text = is_null($page_title) ? do_lang_tempcode('RECOMMEND_SITE_TEXT') : new ocp_tempcode(); if (!is_null(get_param('from', NULL, true))) { if (is_null($page_title)) { $title = get_page_title('RECOMMEND_LINK'); } else { $title = get_page_title($page_title, false); } $submit_name = do_lang_tempcode('SEND'); $text = do_lang_tempcode('RECOMMEND_AUTO_TEXT', get_site_name()); $need_message = true; } else { if (is_null($page_title)) { $title = get_page_title('_RECOMMEND_SITE', true, array(escape_html(get_site_name()))); } else { $title = get_page_title($page_title, false); } $hidden->attach(form_input_hidden('wrap_message', '1')); $need_message = false; } //add an upload CSV contacts file field $_help_url = build_url(array('page' => 'recommend_help'), get_page_zone('recommend_help')); $help_url = $_help_url->evaluate(); if (get_value('disable_csv_recommend') !== '1' && !is_guest()) { $fields->attach(form_input_upload(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('UPLOAD')), do_lang_tempcode('DESCRIPTION_UPLOAD_CSV_FILE', escape_html($help_url)), 'upload', false, NULL, NULL, false)); } handle_max_file_size($hidden); $fields->attach(form_input_line(do_lang_tempcode('SUBJECT'), '', 'subject', $subject, true)); $fields->attach(form_input_text_comcode(do_lang_tempcode('MESSAGE'), do_lang_tempcode('RECOMMEND_SUP_MESSAGE'), 'message', $message, $need_message)); if (addon_installed('captcha')) { require_code('captcha'); if (use_captcha()) { $fields->attach(form_input_captcha()); $text->attach(' '); $text->attach(do_lang_tempcode('FORM_TIME_SECURITY')); } } $hidden->attach(form_input_hidden('comcode__message', '1')); if (get_value('disable_csv_recommend') !== '1' && !is_guest()) { $javascript = 'standardAlternateFields(\'upload\',\'email_address_0\');'; } else { $javascript = ''; } $javascript .= function_exists('captcha_ajax_check') ? captcha_ajax_check() : ''; return do_template('FORM_SCREEN', array('_GUID' => '08a538ca8d78597b0417f464758a59fd', 'JAVASCRIPT' => $javascript, 'SKIP_VALIDATION' => true, 'TITLE' => $title, 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'URL' => $post_url, 'SUBMIT_NAME' => $submit_name, 'TEXT' => $text)); }
/** * Give a member some points, from another member. * * @param integer The amount being given * @param MEMBER The member receiving the points * @param MEMBER The member sending the points * @param SHORT_TEXT The reason for the gift * @param boolean Does the sender want to remain anonymous? * @param boolean Whether to send out an email about it */ function give_points($amount, $recipient_id, $sender_id, $reason, $anonymous = false, $send_email = true) { require_lang('points'); require_code('points'); $your_username = $GLOBALS['FORUM_DRIVER']->get_username($sender_id); $GLOBALS['SITE_DB']->query_insert('gifts', array('date_and_time' => time(), 'amount' => $amount, 'gift_from' => $sender_id, 'gift_to' => $recipient_id, 'reason' => insert_lang_comcode($reason, 4), 'anonymous' => $anonymous ? 1 : 0)); $sender_gift_points_used = point_info($sender_id); $sender_gift_points_used = array_key_exists('gift_points_used', $sender_gift_points_used) ? $sender_gift_points_used['gift_points_used'] : 0; $GLOBALS['FORUM_DRIVER']->set_custom_field($sender_id, 'gift_points_used', strval($sender_gift_points_used + $amount)); $temp_points = point_info($recipient_id); $GLOBALS['FORUM_DRIVER']->set_custom_field($recipient_id, 'points_gained_given', strval((array_key_exists('points_gained_given', $temp_points) ? $temp_points['points_gained_given'] : 0) + $amount)); $their_username = $GLOBALS['FORUM_DRIVER']->get_username($recipient_id); if (is_null($their_username)) { warn_exit(do_lang_tempcode('_USER_NO_EXIST', $recipient_id)); } $yes = $GLOBALS['FORUM_DRIVER']->get_member_email_allowed($recipient_id); if ($yes && $send_email) { $_url = build_url(array('page' => 'points', 'type' => 'member', 'id' => $recipient_id), get_module_zone('points'), NULL, false, false, true); $url = $_url->evaluate(); require_code('notifications'); if ($anonymous) { $message_raw = do_lang('GIVEN_POINTS_FOR_ANON', comcode_escape(get_site_name()), comcode_escape(integer_format($amount)), array(comcode_escape($reason), comcode_escape($url)), get_lang($recipient_id)); dispatch_notification('received_points', NULL, do_lang('YOU_GIVEN_POINTS', integer_format($amount), NULL, NULL, get_lang($recipient_id)), $message_raw, array($recipient_id), A_FROM_SYSTEM_UNPRIVILEGED); } else { $message_raw = do_lang('GIVEN_POINTS_FOR', comcode_escape(get_site_name()), comcode_escape(integer_format($amount)), array(comcode_escape($reason), comcode_escape($url), comcode_escape($your_username)), get_lang($recipient_id)); dispatch_notification('received_points', NULL, do_lang('YOU_GIVEN_POINTS', integer_format($amount), NULL, NULL, get_lang($recipient_id)), $message_raw, array($recipient_id), $sender_id); } $message_raw = do_lang('USER_GIVEN_POINTS_FOR', comcode_escape($their_username), comcode_escape(integer_format($amount)), array(comcode_escape($reason), comcode_escape($url), comcode_escape($your_username)), get_site_default_lang()); dispatch_notification('receive_points_staff', NULL, do_lang('USER_GIVEN_POINTS', integer_format($amount), NULL, NULL, get_site_default_lang()), $message_raw, NULL, $sender_id); } global $TOTAL_POINTS_CACHE, $POINT_INFO_CACHE; if (array_key_exists($recipient_id, $TOTAL_POINTS_CACHE)) { $TOTAL_POINTS_CACHE[$recipient_id] += $amount; } if (array_key_exists($recipient_id, $POINT_INFO_CACHE) && array_key_exists('points_gained_given', $POINT_INFO_CACHE[$recipient_id])) { $POINT_INFO_CACHE[$recipient_id]['points_gained_given'] += $amount; } if (array_key_exists($sender_id, $POINT_INFO_CACHE) && array_key_exists('gift_points_used', $POINT_INFO_CACHE[$sender_id])) { $POINT_INFO_CACHE[$sender_id]['gift_points_used'] += $amount; } if (get_forum_type() == 'ocf') { require_code('ocf_posts_action'); require_code('ocf_posts_action2'); ocf_member_handle_promotion($recipient_id); } if (!$anonymous) { if (has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'points')) { syndicate_described_activity(is_null($recipient_id) || is_guest($recipient_id) ? 'points:_ACTIVITY_GIVE_POINTS' : 'points:ACTIVITY_GIVE_POINTS', $reason, integer_format($amount), '', '_SEARCH:points:member:' . strval($recipient_id), '', '', 'points', 1, NULL, false, $recipient_id); } } }
/** * Stock maintain warning mail * * @param SHORT_TEXT product name * @param AUTO_LINK Product id */ function stock_maintain_warn_mail($product_name, $product_id) { $product_info_url = build_url(array('page' => 'catalogues', 'type' => 'entry', 'id' => $product_id), get_module_zone('catalogues')); $subject = do_lang('STOCK_LEVEL_MAIL_SUBJECT', get_site_name(), $product_name, NULL, get_site_default_lang()); $message = do_lang('STOCK_MAINTENANCE_WARN_MAIL', comcode_escape(get_site_name()), comcode_escape($product_name), array($product_info_url->evaluate()), get_site_default_lang()); require_code('notifications'); dispatch_notification('low_stock', NULL, $subject, $message, NULL, NULL, A_FROM_SYSTEM_PRIVILEGED); }
/** * Edit a download. * * @param AUTO_LINK The ID of the download to edit * @param AUTO_LINK The ID of the category the download is to be in * @param SHORT_TEXT The name of the download * @param URLPATH The URL to the download * @param LONG_TEXT The description of the download * @param ID_TEXT The author of the download (not necessarily same as the submitter) * @param LONG_TEXT The comments for the download * @param AUTO_LINK The out-mode-id (the ID of a download that this download is an old version of). Often people wonder why this is specified with the old version, and not the opposite with the new version - it is because statistically, we perceive more chance of downloads merging than splitting * @param integer The ordered number of the gallery image to use as the download representative image * @param BINARY Whether the download has been validated * @param BINARY Whether the download may be rated * @param SHORT_INTEGER Whether comments are allowed (0=no, 1=yes, 2=review style) * @param BINARY Whether the download may be trackbacked * @param LONG_TEXT Hidden notes pertaining to the download * @param SHORT_TEXT The downloads original filename (the URL may be obfuscated) * @param integer The file size of the download (we can't really detect this in real-time for remote URLs) * @param integer The cost of the download that members will have to pay to get it * @param BINARY Whether the submitter gets the points for the download (they are selling it) (otherwise they are just thrown out, which is an alternative model - one of enforcing community point building) * @param ?AUTO_LINK The licence to use (NULL: none) * @param SHORT_TEXT Meta keywords * @param LONG_TEXT Meta description */ function edit_download($id, $category_id, $name, $url, $description, $author, $comments, $out_mode_id, $default_pic, $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes, $original_filename, $file_size, $cost, $submitter_gets_points, $licence, $meta_keywords, $meta_description) { require_code('urls2'); suggest_new_idmoniker_for('downloads', 'view', strval($id), $name); if ($file_size == 0 || url_is_local($url)) { if (url_is_local($url)) { $file_size = filesize(get_custom_file_base() . '/' . rawurldecode($url)); } else { $file_size = @filesize($url) or $file_size = NULL; } } $myrows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('name', 'description', 'comments'), array('id' => $id), '', 1); if (!array_key_exists(0, $myrows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $myrows[0]; require_code('seo2'); seo_meta_set_for_explicit('downloads_download', strval($id), $meta_keywords, $meta_description); require_code('files2'); delete_upload('uploads/downloads', 'download_downloads', 'url', 'id', $id, $url); $met = @ini_get('max_execution_time'); $data_mash = create_data_mash($url, NULL, get_file_extension($original_filename)); if (function_exists('set_time_limit')) { @set_time_limit($met); } if (!addon_installed('unvalidated')) { $validated = 1; } require_code('submit'); $just_validated = !content_validated('download', strval($id)) && $validated == 1; if ($just_validated) { send_content_validated_notification('download', strval($id)); } $map = array('download_data_mash' => $data_mash, 'download_licence' => $licence, 'original_filename' => $original_filename, 'download_submitter_gets_points' => $submitter_gets_points, 'download_cost' => $cost, 'edit_date' => time(), 'file_size' => $file_size, 'allow_rating' => $allow_rating, 'allow_comments' => $allow_comments, 'allow_trackbacks' => $allow_trackbacks, 'notes' => $notes, 'name' => lang_remap($myrow['name'], $name), 'description' => lang_remap_comcode($myrow['description'], $description), 'comments' => lang_remap_comcode($myrow['comments'], $comments), 'validated' => $validated, 'category_id' => $category_id, 'url' => $url, 'author' => $author, 'default_pic' => $default_pic, 'out_mode_id' => $out_mode_id); $GLOBALS['SITE_DB']->query_update('download_downloads', $map, array('id' => $id), '', 1); $self_url = build_url(array('page' => 'downloads', 'type' => 'entry', 'id' => $id), get_module_zone('downloads'), NULL, false, false, true); if ($just_validated) { require_lang('downloads'); require_code('notifications'); $subject = do_lang('DOWNLOAD_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $name); $mail = do_lang('DOWNLOAD_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($name), array(comcode_escape($self_url->evaluate()))); dispatch_notification('download', strval($category_id), $subject, $mail); } log_it('EDIT_DOWNLOAD', strval($id), get_translated_text($myrow['name'])); if (addon_installed('galleries')) { // Change its gallery require_code('galleries2'); $download_gallery_root = get_option('download_gallery_root'); if (is_null($download_gallery_root)) { $download_gallery_root = 'root'; } $test = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'parent_id', array('name' => 'download_' . strval($id))); if (!is_null($test)) { edit_gallery('download_' . strval($id), 'download_' . strval($id), do_lang('GALLERY_FOR_DOWNLOAD', $name), '', '', '', $download_gallery_root); } } decache('main_recent_downloads'); decache('main_top_downloads'); decache('main_download_category'); decache('main_download_tease'); require_code('feedback'); update_spacer_post($allow_comments != 0, 'downloads', strval($id), $self_url, $name, get_value('comment_forum__downloads')); }
/** * Actualise ticket creation/reply, then show the ticket again. * * @return tempcode The UI */ function do_update_ticket() { $title = get_page_title('SUPPORT_TICKETS'); $id = get_param('id'); $_title = post_param('title'); $post = post_param('post'); if ($post == '') { warn_exit(do_lang_tempcode('NO_PARAMETER_SENT', 'post')); } $ticket_type = post_param_integer('ticket_type', -1); $this->check_id($id); $staff_only = post_param_integer('staff_only', 0) == 1; // Update $_home_url = build_url(array('page' => '_SELF', 'type' => 'ticket', 'id' => $id, 'redirect' => NULL), '_SELF', NULL, false, true, true); $home_url = $_home_url->evaluate(); $email = ''; if ($ticket_type != -1) { $type_string = get_translated_text($ticket_type); $ticket_type_details = get_ticket_type($ticket_type); //$_title=$type_string.' ('.$_title.')'; if (!has_category_access(get_member(), 'tickets', $type_string)) { access_denied('I_ERROR'); } // Check FAQ search results first if ($ticket_type_details['search_faq'] && post_param_integer('faq_searched', 0) == 0) { $results = $this->do_search($title, $id, $post); if (!is_null($results)) { return $results; } } $new_post = new ocp_tempcode(); $new_post->attach(do_lang('THIS_WITH_COMCODE', do_lang('TICKET_TYPE'), $type_string) . "\n\n"); $email = trim(post_param('email', '')); if ($email != '') { $body = '> ' . str_replace(chr(10), chr(10) . '> ', $post); if (substr($body, -2) == '> ') { $body = substr($body, 0, strlen($body) - 2); } $new_post->attach('[email subject="Re: ' . comcode_escape(post_param('title')) . ' [' . get_site_name() . ']" body="' . comcode_escape($body) . '"]' . $email . '[/email]' . "\n\n"); } elseif (is_guest() && $ticket_type_details['guest_emails_mandatory']) { // Error if the e-mail address is required for this ticket type warn_exit(do_lang_tempcode('ERROR_GUEST_EMAILS_MANDATORY')); } $new_post->attach($post); $post = $new_post->evaluate(); } if (addon_installed('captcha')) { if (get_option('captcha_on_feedback') == '1') { require_code('captcha'); enforce_captcha(); } } ticket_add_post(get_member(), $id, $ticket_type, $_title, $post, $home_url, $staff_only); // Find true ticket title $_forum = 1; $_topic_id = 1; $_ticket_type = 1; // These will be returned by reference $posts = get_ticket_posts($id, $_forum, $_topic_id, $_ticket_type); if (!is_array($posts)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $__title = $_title; foreach ($posts as $ticket_post) { $__title = $ticket_post['title']; if ($__title != '') { break; } } // Send email if (!$staff_only) { if ($email == '') { $email = $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member()); } send_ticket_email($id, $__title, $post, $home_url, $email, $ticket_type); } $url = build_url(array('page' => '_SELF', 'type' => 'ticket', 'id' => $id), '_SELF'); if (is_guest()) { $url = build_url(array('page' => '_SELF'), '_SELF'); } if (get_param('redirect', '') != '') { $url = make_string_tempcode(get_param('redirect')); } return redirect_screen($title, $url, do_lang_tempcode('TICKET_STARTED')); }