예제 #1
1
 /**
  * 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();
 }
예제 #2
0
 /**
  * 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));
 }
예제 #3
0
/**
 * @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;
}
예제 #4
0
 /**
  * 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);
         }
     }
 }
예제 #5
0
/**
 * 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);
    }
}
예제 #6
0
/**
 * 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;
}
예제 #7
0
/**
 * 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);
}
예제 #8
0
 /**
  * Finish step.
  *
  * @param  tempcode	The page title.
  * @return tempcode	The result of execution.
  */
 function finish($title)
 {
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('PURCHASING'))));
     $message = get_param('message', NULL, true);
     if (get_param_integer('cancel', 0) == 0) {
         if (perform_local_payment()) {
             $trans_id = post_param('trans_id');
             $transaction_rows = $GLOBALS['SITE_DB']->query_select('trans_expecting', array('*'), array('id' => $trans_id), '', 1);
             if (!array_key_exists(0, $transaction_rows)) {
                 warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
             }
             $transaction_row = $transaction_rows[0];
             $amount = $transaction_row['e_amount'];
             $length = $transaction_row['e_length'];
             $length_units = $transaction_row['e_length_units'];
             $via = get_option('payment_gateway');
             require_code('hooks/systems/ecommerce_via/' . filter_naughty_harsh($via));
             $object = object_factory('Hook_' . $via);
             $name = post_param('name');
             $card_number = post_param('card_number');
             $expiry_date = str_replace('/', '', post_param('expiry_date'));
             $issue_number = post_param_integer('issue_number', NULL);
             $start_date = str_replace('/', '', post_param('start_date'));
             $card_type = post_param('card_type');
             $cv2 = post_param('cv2');
             list($success, , $message, $message_raw) = $object->do_transaction($trans_id, $name, $card_number, $amount, $expiry_date, $issue_number, $start_date, $card_type, $cv2, $length, $length_units);
             if ($success || !is_null($length)) {
                 $status = !is_null($length) && !$success ? 'SCancelled' : 'Completed';
                 handle_confirmed_transaction($transaction_row['e_purchase_id'], $transaction_row['e_item_name'], $status, $message_raw, '', '', $amount, get_option('currency'), $trans_id, '', $via, is_null($length) ? '' : strtolower(strval($length) . ' ' . $length_units));
             }
             if ($success) {
                 $member_id = $transaction_row['e_member_id'];
                 require_code('notifications');
                 dispatch_notification('payment_received', NULL, do_lang('PAYMENT_RECEIVED_SUBJECT', $trans_id), do_lang('PAYMENT_RECEIVED_BODY', float_format(floatval($amount)), get_option('currency'), get_site_name()), array($member_id), A_FROM_SYSTEM_PRIVILEGED);
             }
         }
         $product = get_param('product', '');
         if ($product != '') {
             if (count($_POST) != 0) {
                 handle_transaction_script();
             }
             attach_message(do_lang_tempcode('SUCCESS'), 'inform');
             $object = find_product($product);
             if (method_exists($object, 'get_finish_url')) {
                 return redirect_screen($title, $object->get_finish_url($product), $message);
             }
         }
         return $this->wrap(do_template('PURCHASE_WIZARD_STAGE_FINISH', array('_GUID' => '43f706793719ea893c280604efffacfe', 'TITLE' => $title, 'MESSAGE' => $message)), $title, NULL);
     }
     if (!is_null($message)) {
         return $this->wrap(do_template('PURCHASE_WIZARD_STAGE_FINISH', array('_GUID' => '859c31e8f0f02a2a46951be698dd22cf', 'TITLE' => $title, 'MESSAGE' => $message)), $title, NULL);
     }
     inform_exit(do_lang_tempcode('PRODUCT_PURCHASE_CANCEL'));
     return new ocp_tempcode();
     // Will never get here
 }
예제 #9
0
파일: ocf.php 프로젝트: erico-deh/ocPortal
 /**
  * Handle flood control for members.
  *
  * @param  MEMBER			The member ID that just got detected
  */
 function ocf_flood_control($id)
 {
     global $NON_PAGE_SCRIPT;
     if ($NON_PAGE_SCRIPT == 1) {
         return;
     }
     global $FLOOD_CONTROL_ONCE;
     if ($FLOOD_CONTROL_ONCE) {
         return;
     }
     $FLOOD_CONTROL_ONCE = true;
     if (get_page_name() == 'join') {
         return;
     }
     if (!running_script('index') && !running_script('iframe')) {
         return;
     }
     require_code('ocf_groups');
     // Set last visit time session cookie if it doesn't exist
     if (!array_key_exists('last_visit', $_COOKIE) && $GLOBALS['FORUM_DRIVER']->get_guest_id() != $id) {
         require_code('users_active_actions');
         $lvt = $this->get_member_row_field($id, 'm_last_visit_time');
         ocp_setcookie('last_visit', is_null($lvt) ? strval(time()) : strval($lvt), true);
         $new_visit = true;
     } else {
         $new_visit = false;
     }
     // Do some flood control
     $submitting = count($_POST) > 0 && get_param('type', NULL) !== 'ed' && get_param('type', NULL) !== 'ec' && !running_script('preview');
     $restrict = $submitting ? 'flood_control_submit_secs' : 'flood_control_access_secs';
     $restrict_setting = $submitting ? 'm_last_submit_time' : 'm_last_visit_time';
     $restrict_answer = ocf_get_best_group_property($this->get_members_groups($id), $restrict);
     if (!$submitting && array_key_exists('redirect', $_GET)) {
         $restrict_answer = 0;
     }
     if ($restrict_answer < 0) {
         $restrict_answer = 0;
     }
     $last = $this->get_member_row_field($id, $restrict_setting);
     if ($last > time()) {
         $last = time() - $restrict_answer;
     }
     // Weird clock problem
     $wait_time = $restrict_answer - time() + $last;
     if ($wait_time > 0 && addon_installed('stats')) {
         require_code('site');
         log_stats('/flood', 0);
         $time_threshold = 30;
         $count_threshold = 50;
         $query = 'SELECT COUNT(*) FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'stats WHERE date_and_time>' . strval(time() - $time_threshold) . ' AND date_and_time<' . strval(time()) . ' AND ' . db_string_equal_to('ip', get_ip_address());
         $count = $GLOBALS['SITE_DB']->query_value_null_ok_full($query);
         if ($count >= $count_threshold && addon_installed('securitylogging')) {
             $ip = get_ip_address();
             require_code('failure');
             add_ip_ban($ip);
             require_code('notifications');
             dispatch_notification('auto_ban', NULL, do_lang('AUTO_BAN_SUBJECT', $ip, NULL, NULL, get_site_default_lang()), do_lang('AUTO_BAN_DOS_MESSAGE', $ip, integer_format($count_threshold), integer_format($time_threshold), get_site_default_lang()), NULL, A_FROM_SYSTEM_PRIVILEGED);
         }
         if (!function_exists('require_lang')) {
             require_code('lang');
         }
         if (!function_exists('do_lang_tempcode')) {
             require_code('tempcode');
         }
         require_lang('ocf');
         warn_exit(do_lang_tempcode('FLOOD_CONTROL_RESTRICT', integer_format($wait_time)));
     }
     $extra = $submitting ? array('m_last_submit_time' => time()) : array();
     $dif = time() - $this->get_member_row_field($id, 'm_last_visit_time');
     if ($dif < 0) {
         $dif = 0;
     }
     // can happen if system clock changes
     if (is_guest($id)) {
         if (get_value('session_prudence') !== '1') {
             global $SESSION_CACHE;
             $num_guests = 0;
             foreach ($SESSION_CACHE as $c) {
                 if (!array_key_exists('the_user', $c)) {
                     continue;
                 }
                 // Workaround to HipHop PHP weird bug
                 if ($c['last_activity'] > time() - 60 * 4 && is_guest($c['the_user'])) {
                     $num_guests++;
                 }
             }
             $dif *= $num_guests;
         } else {
             $restrict_answer = 0;
         }
     }
     if ($submitting || count($_POST) == 0 && $dif > $wait_time) {
         if ($restrict_answer != 0 || $dif > 180 || $new_visit) {
             $old_ip = $this->get_member_row_field($id, 'm_ip_address');
             $change_map = array('m_last_visit_time' => time());
             if (get_ip_address() != $old_ip) {
                 $change_map['m_ip_address'] = get_ip_address();
             }
             if (get_db_type() != 'xml') {
                 $this->connection->query_update('f_members', $change_map + $extra, array('id' => $id), '', 1, NULL, false, true);
             }
         }
     }
 }
예제 #10
0
/**
 * 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);
    }
}
예제 #11
0
 /**
  * Function to dispatch an order
  *
  * @param	AUTO_LINK	Order Id
  */
 function send_dispatch_notification($order_id)
 {
     //Mail dispatch notification to customer
     $message = post_param('dispatch_mail_content', NULL);
     if (is_null($message)) {
         return;
     }
     $res = $GLOBALS['SITE_DB']->query_select('shopping_order', array('*'), array('id' => $order_id), '', 1);
     $order_det = $res[0];
     //$message	=do_lang('ORDER_DISPATCHED_MAIL_MESSAGE',comcode_escape(get_site_name()),comcode_escape($member_name),array(strval($order_id)));
     require_code('notifications');
     dispatch_notification('order_dispatched', NULL, do_lang('ORDER_DISPATCHED_MAIL_SUBJECT', get_site_name(), strval($order_id), NULL, get_lang($order_det['c_member'])), $message, array($order_det['c_member']), A_FROM_SYSTEM_PRIVILEGED);
 }
예제 #12
0
 /**
  * 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();
 }
예제 #13
0
파일: news.php 프로젝트: erico-deh/ocPortal
/**
 * 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);
    }
}
예제 #14
0
파일: quiz.php 프로젝트: erico-deh/ocPortal
 /**
  * Actualiser: process quiz results.
  *
  * @return tempcode	The result of execution.
  */
 function _do_quiz()
 {
     $id = get_param_integer('id');
     $quizzes = $GLOBALS['SITE_DB']->query_select('quizzes', array('*'), array('id' => $id), '', 1);
     if (!array_key_exists(0, $quizzes)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $quiz = $quizzes[0];
     $this->enforcement_checks($quiz);
     $last_visit_time = $GLOBALS['SITE_DB']->query_value_null_ok('quiz_member_last_visit', 'v_time', array('v_quiz_id' => $id, 'v_member_id' => get_member()), 'ORDER BY v_time DESC');
     if (is_null($last_visit_time)) {
         warn_exit(do_lang_tempcode('QUIZ_TWICE'));
     }
     if (!is_null($quiz['q_timeout'])) {
         if (time() - $last_visit_time > $quiz['q_timeout'] * 60 + 10) {
             warn_exit(do_lang_tempcode('TOO_LONG_ON_SCREEN'));
         }
         // +10 is for page load time, worst case scenario to be fair
     }
     // Our entry
     $entry_id = $GLOBALS['SITE_DB']->query_insert('quiz_entries', array('q_time' => time(), 'q_member' => get_member(), 'q_quiz' => $id, 'q_results' => 0), true);
     $GLOBALS['SITE_DB']->query_update('quiz_member_last_visit', array('v_time' => time() - (is_null($quiz['q_timeout']) ? 0 : $quiz['q_timeout']) * 60), array('v_member_id' => get_member(), 'v_quiz_id' => $id), '', 1);
     // Calculate results and store
     $questions = $GLOBALS['SITE_DB']->query_select('quiz_questions', array('*'), array('q_quiz' => $id));
     foreach ($questions as $i => $question) {
         $answers = $GLOBALS['SITE_DB']->query_select('quiz_question_answers', array('*'), array('q_question' => $question['id']));
         $questions[$i]['answers'] = $answers;
     }
     $marks = 0.0;
     $potential_extra_marks = 0;
     $out_of = count($questions);
     if ($out_of == 0) {
         $out_of = 1;
     }
     $results = array();
     $corrections = array();
     $unknowns = array();
     foreach ($questions as $i => $question) {
         $name = 'q_' . strval($question['id']);
         if ($question['q_num_choosable_answers'] == 0) {
             if (count($question['answers']) == 0) {
                 $potential_extra_marks++;
                 $unknowns[] = array(get_translated_text($question['q_question_text']), post_param($name));
             } else {
                 $was_right = false;
                 $correct_answer = new ocp_tempcode();
                 $correct_explanation = NULL;
                 foreach ($question['answers'] as $a) {
                     if ($a['q_is_correct'] == 1) {
                         $correct_answer = make_string_tempcode(escape_html(get_translated_text($a['q_answer_text'])));
                     }
                     if ($a['q_is_correct'] == 1 && get_translated_text($a['q_answer_text']) == post_param($name)) {
                         $marks++;
                         $was_right = true;
                         break;
                     }
                     if (get_translated_text($a['q_answer_text']) == post_param($name)) {
                         $correct_explanation = $a['q_explanation'];
                     }
                 }
                 if (!$was_right) {
                     $correction = array($question['id'], get_translated_text($question['q_question_text']), $correct_answer, post_param($name));
                     if (!is_null($correct_explanation)) {
                         $explanation = get_translated_text($correct_explanation);
                         if ($explanation != '') {
                             $correction[] = $explanation;
                         }
                     }
                     $corrections[] = $correction;
                 }
             }
             $results[$i] = post_param($name);
             $GLOBALS['SITE_DB']->query_insert('quiz_entry_answer', array('q_entry' => $entry_id, 'q_question' => $question['id'], 'q_answer' => $results[$i]));
         } elseif ($question['q_num_choosable_answers'] > 1) {
             // Vector distance
             $wrongness = 0.0;
             $accum = new ocp_tempcode();
             $correct_answer = new ocp_tempcode();
             $correct_explanation = NULL;
             foreach ($question['answers'] as $a) {
                 $for_this = post_param_integer($name . '_' . strval($a['id']), 0);
                 $should_be_this = $a['q_is_correct'];
                 $dist = $for_this - $should_be_this;
                 $wrongness += $dist * $dist;
                 if ($should_be_this == 1) {
                     if (!$correct_answer->is_empty()) {
                         $correct_answer->attach(do_lang_tempcode('LIST_SEP'));
                     }
                     $correct_answer->attach(escape_html(get_translated_text($a['q_answer_text'])));
                     $correct_explanation = $a['q_explanation'];
                 }
                 if ($for_this == 1) {
                     if (!$accum->is_empty()) {
                         $accum->attach(do_lang_tempcode('LIST_SEP'));
                     }
                     $accum->attach(escape_html(get_translated_text($a['q_answer_text'])));
                     $GLOBALS['SITE_DB']->query_insert('quiz_entry_answer', array('q_entry' => $entry_id, 'q_question' => $question['id'], 'q_answer' => strval($a['id'])));
                 }
             }
             $wrongness = sqrt($wrongness);
             // Normalise it
             $wrongness /= count($question['answers']);
             // And get our complement
             $correctness = 1.0 - $wrongness;
             $marks += $correctness;
             if ($correctness != 1.0) {
                 $correction = array($question['id'], get_translated_text($question['q_question_text']), $correct_answer, $accum);
                 if (!is_null($correct_explanation)) {
                     $explanation = get_translated_text($correct_explanation);
                     if ($explanation != '') {
                         $correction[] = $explanation;
                     }
                 }
                 $corrections[] = $correction;
             }
             $results[$i] = $accum->evaluate();
         } else {
             $was_right = false;
             $correct_answer = new ocp_tempcode();
             $correct_explanation = NULL;
             foreach ($question['answers'] as $a) {
                 if ($a['q_is_correct'] == 1) {
                     $correct_answer = make_string_tempcode(escape_html(get_translated_text($a['q_answer_text'])));
                 }
                 if (post_param_integer($name, -1) == $a['id']) {
                     $results[$i] = get_translated_text($a['q_answer_text']);
                     if ($a['q_is_correct'] == 1) {
                         $was_right = true;
                         $marks++;
                         break;
                     }
                     $correct_explanation = $a['q_explanation'];
                 }
             }
             $GLOBALS['SITE_DB']->query_insert('quiz_entry_answer', array('q_entry' => $entry_id, 'q_question' => $question['id'], 'q_answer' => post_param($name, '')));
             if (!array_key_exists($i, $results)) {
                 $results[$i] = '/';
             }
             if (!$was_right) {
                 $correction = array($question['id'], get_translated_text($question['q_question_text']), $correct_answer, $results[$i]);
                 if (!is_null($correct_explanation)) {
                     $explanation = get_translated_text($correct_explanation);
                     if ($explanation != '') {
                         $correction[] = $explanation;
                     }
                 }
                 $corrections[] = $correction;
             }
         }
     }
     $mail_title = do_lang('EMAIL_TITLE', do_lang($quiz['q_type']), $GLOBALS['FORUM_DRIVER']->get_username(get_member()), strval($entry_id), get_site_default_lang());
     $_corrections = new ocp_tempcode();
     $_corrections_to_show = new ocp_tempcode();
     foreach ($corrections as $correction) {
         $this_correction = new ocp_tempcode();
         $this_correction->attach(do_lang('QUIZ_MISTAKE', is_object($correction[1]) ? $correction[1]->evaluate() : $correction[1], is_object($correction[3]) ? $correction[3]->evaluate() : $correction[3], array(is_object($correction[2]) ? $correction[2]->evaluate() : $correction[2], array_key_exists(4, $correction) ? $correction[4] : '')));
         if (array_key_exists(4, $correction)) {
             $_corrections_to_show->attach($this_correction);
         }
         $_corrections->attach($this_correction);
     }
     $_answers = new ocp_tempcode();
     foreach ($results as $i => $result) {
         $_answers->attach(do_lang('QUIZ_RESULT', get_translated_text($questions[$i]['q_question_text']), is_null($result) ? '' : $result));
     }
     $_unknowns = new ocp_tempcode();
     foreach ($unknowns as $unknown) {
         $_unknowns->attach(do_lang('QUIZ_UNKNOWN', $unknown[0], $unknown[1]));
     }
     require_code('notifications');
     // Award points?
     if ($out_of == 0) {
         $out_of = 1;
     }
     $minimum_percentage = intval(round(100.0 * $marks / $out_of));
     $maximum_percentage = intval(round(100.0 * ($marks + $potential_extra_marks) / $out_of));
     if (addon_installed('points') && $quiz['q_points_for_passing'] != 0 && ($quiz['q_type'] != 'TEST' || $minimum_percentage >= $quiz['q_percentage'])) {
         require_code('points2');
         $points_difference = $quiz['q_points_for_passing'];
         system_gift_transfer(do_lang('POINTS_COMPLETED_QUIZ', get_translated_text($quiz['q_name'])), $points_difference, get_member());
     } else {
         $points_difference = 0;
     }
     // Give them their result if it is a test.
     if ($quiz['q_type'] == 'TEST') {
         $result = new ocp_tempcode();
         $result->attach(paragraph(do_lang_tempcode('MARKS_OUT_OF', float_format($marks) . ($potential_extra_marks == 0 ? '' : '-' . float_format($marks + $potential_extra_marks)), integer_format($out_of), strval($minimum_percentage) . ($potential_extra_marks == 0 ? '' : '-' . strval($maximum_percentage))), 'trete9r0itre'));
         $result2 = do_lang_tempcode('MAIL_MARKS_OUT_OF', float_format($marks) . ($potential_extra_marks == 0 ? '' : '-' . float_format($marks + $potential_extra_marks)), integer_format($out_of), strval($minimum_percentage) . ($potential_extra_marks == 0 ? '' : '-' . strval($maximum_percentage)));
         if ($minimum_percentage >= $quiz['q_percentage']) {
             $result->attach(paragraph(do_lang_tempcode('TEST_PASS'), '4tfdhdhghh'));
             $result2->attach(do_lang_tempcode('MAIL_TEST_PASS'));
             syndicate_described_activity('quiz:ACTIVITY_PASSED_TEST', get_translated_text($quiz['q_name']), '', '', '_SEARCH:quiz:do:' . strval($id), '', '', 'quizzes');
         } elseif ($maximum_percentage < $quiz['q_percentage']) {
             $result->attach(paragraph(do_lang_tempcode('TEST_FAIL'), '5yrgdgsdg'));
             $result2->attach(do_lang_tempcode('MAIL_TEST_FAIL'));
         } else {
             $result->attach(paragraph(do_lang_tempcode('TEST_UNKNOWN'), 'yteyrthrt'));
             $result2->attach(do_lang_tempcode('MAIL_TEST_UNKNOWN'));
         }
         // Send mail about the result to the staff: include result and corrections, and unknowns
         $mail = do_template('QUIZ_TEST_ANSWERS_MAIL', array('_GUID' => 'a0f8f47cdc1ef83b59c93135ebb5c114', 'UNKNOWNS' => $_unknowns, 'CORRECTIONS' => $_corrections, 'RESULT' => $result2, 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username(get_member())));
         dispatch_notification('quiz_results', strval($id), $mail_title, $mail->evaluate(get_site_default_lang()));
     } elseif ($quiz['q_type'] == 'COMPETITION') {
         $result = comcode_to_tempcode($_corrections->evaluate());
         syndicate_described_activity('quiz:ACTIVITY_ENTERED_COMPETITION', get_translated_text($quiz['q_name']), '', '', '_SEARCH:quiz:do:' . strval($id), '', '', 'quizzes');
     } else {
         $result = paragraph(do_lang_tempcode('SURVEY_THANKYOU'), '4rtyrthgf');
         $_answers = do_template('QUIZ_ANSWERS_MAIL', array('_GUID' => '381f392c8e491b6e078bcae34adc45e8', 'ANSWERS' => $_answers, 'MEMBER_PROFILE_URL' => is_guest() ? '' : $GLOBALS['FORUM_DRIVER']->member_profile_url(get_member(), false, true), 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username(get_member())));
         // Send mail of answers to the staff
         dispatch_notification('quiz_results', strval($id), $mail_title, $_answers->evaluate(get_site_default_lang()));
         syndicate_described_activity('quiz:ACTIVITY_FILLED_SURVEY', get_translated_text($quiz['q_name']), '', '', '_SEARCH:quiz:do:' . strval($id), '', '', 'quizzes');
     }
     // Store results for entry
     $GLOBALS['SITE_DB']->query_update('quiz_entries', array('q_results' => intval(round($marks))), array('id' => $entry_id), '', 1);
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', make_string_tempcode(escape_html(get_translated_text($quiz['q_name']))))));
     // Show end text
     $title = get_page_title(do_lang_tempcode('THIS_WITH', do_lang_tempcode($quiz['q_type']), make_string_tempcode(escape_html(get_translated_text($quiz['q_name'])))), false);
     $fail_text = get_translated_tempcode($quiz['q_end_text_fail']);
     $message = $quiz['q_type'] != 'TEST' || $minimum_percentage >= $quiz['q_percentage'] || $fail_text->is_empty() ? get_translated_tempcode($quiz['q_end_text']) : get_translated_tempcode($quiz['q_end_text_fail']);
     return do_template('QUIZ_DONE_SCREEN', array('_GUID' => 'fa783f087eca7f8f577b134ec0bdc4ce', 'CORRECTIONS_TO_SHOW' => comcode_to_tempcode($_corrections_to_show->evaluate()), 'POINTS_DIFFERENCE' => strval($points_difference), 'RESULT' => $result, 'TITLE' => $title, 'TYPE' => $quiz['q_type'], 'MESSAGE' => $message));
 }
예제 #15
0
/**
 * 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);
}
예제 #16
0
 /**
  * Finish step.
  *
  * @return tempcode	The result of execution.
  */
 function finish()
 {
     $title = get_page_title('_PURCHASE_FINISHED');
     breadcrumb_set_parents(array(array('_SELF:catalogues:misc:ecommerce=1', do_lang_tempcode('CATALOGUES')), array('_SELF:_SELF:misc', do_lang_tempcode('SHOPPING'))));
     $message = get_param('message', NULL, true);
     // TODO: Assumption, needs to really go through the payment gateway API
     if (get_param_integer('cancel', 0) == 0) {
         //Empty cart.
         $where = array();
         if (is_guest()) {
             $where['session_id'] = get_session_id();
         } else {
             $where['ordered_by'] = get_member();
         }
         $GLOBALS['SITE_DB']->query_delete('shopping_cart', $where);
         log_cart_actions('Completed payment');
         if (perform_local_payment()) {
             $trans_id = post_param('trans_id');
             $transaction_rows = $GLOBALS['SITE_DB']->query_select('trans_expecting', array('*'), array('id' => $trans_id), '', 1);
             if (!array_key_exists(0, $transaction_rows)) {
                 warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
             }
             $transaction_row = $transaction_rows[0];
             $amount = $transaction_row['e_amount'];
             $length = $transaction_row['e_length'];
             $length_units = $transaction_row['e_length_units'];
             $via = get_option('payment_gateway');
             require_code('hooks/systems/ecommerce_via/' . filter_naughty_harsh($via));
             $object = object_factory('Hook_' . $via);
             $name = post_param('name');
             $card_number = post_param('card_number');
             $expiry_date = str_replace('/', '', post_param('expiry_date'));
             $issue_number = post_param_integer('issue_number', NULL);
             $start_date = str_replace('/', '', post_param('start_date'));
             $card_type = post_param('card_type');
             $cv2 = post_param('cv2');
             list($success, , $message, $message_raw) = $object->do_transaction($trans_id, $name, $card_number, $amount, $expiry_date, $issue_number, $start_date, $card_type, $cv2, $length, $length_units);
             if ($success || !is_null($length)) {
                 $status = !is_null($length) && !$success ? 'SCancelled' : 'Completed';
                 handle_confirmed_transaction($transaction_row['e_purchase_id'], $transaction_row['e_item_name'], $status, $message_raw, '', '', $amount, get_option('currency'), $trans_id, '', $via, is_null($length) ? '' : strtolower(strval($length) . ' ' . $length_units));
             }
             if ($success) {
                 $member_id = $transaction_row['e_member_id'];
                 require_code('notifications');
                 dispatch_notification('payment_received', NULL, do_lang('PAYMENT_RECEIVED_SUBJECT', $trans_id), do_lang('PAYMENT_RECEIVED_BODY', float_format(floatval($amount)), get_option('currency'), get_site_name()), array($member_id), A_FROM_SYSTEM_PRIVILEGED);
             }
         }
         attach_message(do_lang_tempcode('SUCCESS'), 'inform');
         if (count($_POST) != 0) {
             $order_id = handle_transaction_script();
             $object = find_product(do_lang('CART-ORDER', $order_id));
             if (method_exists($object, 'get_finish_url')) {
                 return redirect_screen($title, $object->get_finish_url(), $message);
             }
         }
         return $this->wrap(do_template('PURCHASE_WIZARD_STAGE_FINISH', array('TITLE' => $title, 'MESSAGE' => $message)), $title, NULL);
     }
     if (!is_null($message)) {
         return $this->wrap(do_template('PURCHASE_WIZARD_STAGE_FINISH', array('TITLE' => $title, 'MESSAGE' => $message)), $title, NULL);
     }
     warn_exit(do_lang_tempcode('PRODUCT_PURCHASE_CANCEL'));
     return new ocp_tempcode();
     // Will never get here
 }
예제 #17
0
 /**
  * Cancel a subscription.
  *
  * @return tempcode	The interface.
  */
 function cancel()
 {
     $title = get_page_title('SUBSCRIPTION_CANCEL');
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MY_SUBSCRIPTIONS'))));
     $id = get_param_integer('id');
     $via = $GLOBALS['SITE_DB']->query_value('subscriptions', 's_via', array('id' => $id));
     if ($via != 'manual' && $via != '') {
         require_code('hooks/systems/ecommerce_via/' . filter_naughty($via));
         $hook = object_factory($via);
         if ($hook->auto_cancel($id) !== true) {
             require_code('notifications');
             $trans_id = $GLOBALS['SITE_DB']->query_value('transactions', 'id', array('purchase_id' => strval($id)));
             $username = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
             dispatch_notification('subscription_cancelled_staff', NULL, do_lang('SUBSCRIPTION_CANCELLED_SUBJECT', NULL, NULL, NULL, get_site_default_lang()), do_lang('SUBSCRIPTION_CANCELLED_BODY', $trans_id, $username, NULL, get_site_default_lang()));
         }
     }
     $GLOBALS['SITE_DB']->query_delete('subscriptions', array('id' => $id, 's_member_id' => get_member()), '', 1);
     $url = build_url(array('page' => '_SELF'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
예제 #18
0
 /**
  * Handle IPN's. The function may produce output, which would be returned to the Payment Gateway. The function may do transaction verification.
  *
  * @return array	A long tuple of collected data.
  */
 function handle_transaction()
 {
     //$myfile=fopen(get_file_base().'/data_custom/ecommerce.log','wt');
     //fwrite($myfile,serialize($_POST)."\n".serialize($_GET));
     //fclose($myfile);
     //$_POST=unserialize('a:36:{s:8:"testMode";s:3:"100";s:8:"authCost";s:4:"15.0";s:8:"currency";s:3:"GBP";s:7:"address";s:1:"a";s:13:"countryString";s:11:"South Korea";s:10:"callbackPW";s:10:"s35645dxr4";s:12:"installation";s:5:"84259";s:3:"fax";s:1:"a";s:12:"countryMatch";s:1:"B";s:7:"transId";s:9:"222873126";s:3:"AVS";s:4:"0000";s:12:"amountString";s:11:"&#163;15.00";s:8:"postcode";s:1:"a";s:7:"msgType";s:10:"authResult";s:4:"name";s:1:"a";s:3:"tel";s:1:"a";s:11:"transStatus";s:1:"Y";s:4:"desc";s:15:"Property Advert";s:8:"cardType";s:10:"Mastercard";s:4:"lang";s:2:"en";s:9:"transTime";s:13:"1171243476007";s:16:"authAmountString";s:11:"&#163;15.00";s:10:"authAmount";s:4:"15.0";s:9:"ipAddress";s:12:"84.9.162.135";s:4:"cost";s:4:"15.0";s:6:"instId";s:5:"84259";s:6:"amount";s:4:"15.0";s:8:"compName";s:32:"The Accessible Property Register";s:7:"country";s:2:"KR";s:11:"MC_callback";s:63:"www.kivi.co.uk/ClientFiles/APR/data/ecommerce.php?from=worldpay";s:14:"rawAuthMessage";s:22:"cardbe.msg.testSuccess";s:5:"email";s:16:"*****@*****.**";s:12:"authCurrency";s:3:"GBP";s:11:"rawAuthCode";s:1:"A";s:6:"cartId";s:32:"3ecd645f632f0304067fb565e71b4dcd";s:8:"authMode";s:1:"A";}');
     //$_GET=unserialize('a:3:{s:4:"from";s:8:"worldpay";s:7:"msgType";s:10:"authResult";s:12:"installation";s:5:"84259";}');
     $code = post_param('transStatus');
     if ($code == 'C') {
         exit;
     }
     // Cancellation signal, won't process
     $txn_id = post_param('transId');
     $cart_id = post_param('cartId');
     if (post_param('futurePayType', '') == 'regular') {
         $subscription = true;
     } else {
         $subscription = false;
     }
     $transaction_rows = $GLOBALS['SITE_DB']->query_select('trans_expecting', array('*'), array('id' => $cart_id), '', 1);
     if (!array_key_exists(0, $transaction_rows)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $transaction_row = $transaction_rows[0];
     $member_id = $transaction_row['e_member_id'];
     $item_name = $subscription ? '' : $transaction_row['e_item_name'];
     $purchase_id = $transaction_row['e_purchase_id'];
     $success = $code == 'Y';
     $message = post_param('rawAuthMessage');
     $payment_status = $success ? 'Completed' : 'Failed';
     $reason_code = '';
     $pending_reason = '';
     $memo = '';
     $mc_gross = post_param('authAmount');
     $mc_currency = post_param('authCurrency');
     $email = $GLOBALS['FORUM_DRIVER']->get_member_email_address($member_id);
     if (post_param('callbackPW') != get_option('callback_password')) {
         my_exit(do_lang('IPN_UNVERIFIED'));
     }
     if ($success) {
         require_code('notifications');
         dispatch_notification('payment_received', NULL, do_lang('PAYMENT_RECEIVED_SUBJECT', $txn_id, NULL, NULL, get_lang($member_id)), do_lang('PAYMENT_RECEIVED_BODY', float_format(floatval($mc_gross)), $mc_currency, get_site_name(), get_lang($member_id)), array($member_id), A_FROM_SYSTEM_PRIVILEGED);
     }
     if ($success) {
         $_url = build_url(array('page' => 'purchase', 'type' => 'finish', 'product' => get_param('product', NULL), 'message' => '<WPDISPLAY ITEM=banner>'), get_module_zone('purchase'));
     } else {
         $_url = build_url(array('page' => 'purchase', 'type' => 'finish', 'cancel' => 1, 'message' => do_lang_tempcode('DECLINED_MESSAGE', $message)), get_module_zone('purchase'));
     }
     $url = $_url->evaluate();
     echo http_download_file($url);
     if (addon_installed('shopping')) {
         $this->store_shipping_address($purchase_id);
     }
     return array($purchase_id, $item_name, $payment_status, $reason_code, $pending_reason, $memo, $mc_gross, $mc_currency, $txn_id, '');
 }
예제 #19
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_code('feedback');
     require_javascript('javascript_validation');
     $is_occle_talking = ocp_srv('HTTP_USER_AGENT') == 'ocPortal' && ocp_srv('HTTP_HOST') == 'ocportal.com';
     $self_url = get_self_url();
     $self_title = get_page_name();
     $type = 'block_main_feedback';
     $id = array_key_exists('param', $map) ? $map['param'] : '';
     $out = new ocp_tempcode();
     if (post_param_integer('_comment_form_post', 0) == 1) {
         if (!has_no_forum()) {
             $hidden = actualise_post_comment(true, $type, $id, $self_url, $self_title, array_key_exists('forum', $map) ? $map['forum'] : NULL, $is_occle_talking || get_option('captcha_on_feedback') == '0', 1, false, true, true);
             if (array_key_exists('title', $_POST)) {
                 $redirect = get_param('redirect', NULL);
                 if (!is_null($redirect)) {
                     $redirect_screen = redirect_screen(get_page_title('_FEEDBACK'), $redirect, do_lang_tempcode('FEEDBACK_THANKYOU'));
                     @ob_end_clean();
                     $echo = globalise($redirect_screen, NULL, '', true);
                     $echo->evaluate_echo();
                     exit;
                 } else {
                     attach_message(do_lang_tempcode('SUCCESS'), 'inform');
                 }
             }
         } else {
             $post = post_param('post', '');
             $title = post_param('title', '');
             if ($post != '') {
                 require_code('notifications');
                 dispatch_notification('new_feedback', $type, do_lang('NEW_FEEDBACK_SUBJECT', $title, NULL, NULL, get_site_default_lang()), do_lang('NEW_FEEDBACK_MESSAGE', $post, NULL, NULL, get_site_default_lang()));
                 $email_from = trim(post_param('email', $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member())));
                 if ($email_from != '') {
                     require_code('mail');
                     mail_wrap(do_lang('YOUR_MESSAGE_WAS_SENT_SUBJECT', $title), do_lang('YOUR_MESSAGE_WAS_SENT_BODY', $post), array($email_from), NULL, '', '', 3, NULL, false, get_member());
                 }
             }
         }
     }
     // Comment posts
     $forum = get_option('comments_forum_name');
     $count = 0;
     $_comments = $GLOBALS['FORUM_DRIVER']->get_forum_topic_posts($GLOBALS['FORUM_DRIVER']->find_topic_id_for_topic_identifier($forum, $type . '_' . $id), $count);
     if ($_comments !== -1) {
         $em = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser();
         require_javascript('javascript_editing');
         $comcode_help = build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode', false));
         require_javascript('javascript_validation');
         $comment_url = get_self_url();
         if (addon_installed('captcha')) {
             require_code('captcha');
             $use_captcha = !$is_occle_talking && get_option('captcha_on_feedback') == '1' && use_captcha();
             if ($use_captcha) {
                 generate_captcha();
             }
         } else {
             $use_captcha = false;
         }
         $comment_details = do_template('COMMENTS_POSTING_FORM', array('_GUID' => '4ca32620f3eb68d9cc820b18265792d7', 'JOIN_BITS' => '', 'FIRST_POST_URL' => '', 'FIRST_POST' => '', 'USE_CAPTCHA' => $use_captcha, 'POST_WARNING' => get_param('post_warning', ''), 'COMMENT_TEXT' => '', 'GET_EMAIL' => false, 'EMAIL_OPTIONAL' => true, 'GET_TITLE' => true, 'EM' => $em, 'DISPLAY' => 'block', 'COMMENT_URL' => $comment_url, 'TITLE' => do_lang_tempcode('FEEDBACK')));
     } else {
         $comment_details = new ocp_tempcode();
     }
     $out->attach($comment_details);
     return $out;
 }
예제 #20
0
/**
 * 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);
}
예제 #21
0
/**
 * 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'));
}
예제 #22
0
 /**
  * Standard actualisation stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function action_done2()
 {
     $class = str_replace('hook_pointstore_', '', strtolower(get_class($this)));
     $title = get_page_title('OCGIFTS_TITLE');
     $gift_id = get_param_integer('gift');
     $member_id = get_member();
     $to_member = post_param('username', '');
     $gift_message = post_param('gift_message', '');
     $member_row = $GLOBALS['FORUM_DB']->query_select('f_members', array('*'), array('m_username' => $to_member), '', 1);
     if (isset($member_row[0]['id']) && $member_row[0]['id'] > 0) {
         $to_member_id = $member_row[0]['id'];
         $anonymous = post_param_integer('anonymous', 0);
         $gift_row = $GLOBALS['SITE_DB']->query_select('ocgifts', array('*'), array('id' => $gift_id));
         if (isset($gift_row[0]['id']) && $gift_row[0]['id'] > 0) {
             //check available points and charge
             $available_points = available_points($member_id);
             if ($gift_row[0]['price'] > $available_points) {
                 warn_exit(do_lang_tempcode('CANT_AFFORD'));
             }
             require_code('points2');
             //get gift points
             charge_member($member_id, $gift_row[0]['price'], do_lang('GIFT_PURCHASING') . ' - ' . strval($gift_row[0]['price']) . ' point(-s).');
             $gift_row_id = $GLOBALS['SITE_DB']->query_insert('members_gifts', array('to_user_id' => $to_member_id, 'from_user_id' => $member_id, 'gift_id' => $gift_id, 'add_time' => time(), 'is_anonymous' => $anonymous, 'topic_id' => NULL, 'gift_message' => $gift_message), true);
         }
         if (isset($gift_row[0]['id']) && $gift_row[0]['id'] > 0) {
             require_code('notifications');
             if ($anonymous == 0) {
                 $subject = do_lang('GOT_GIFT');
                 $message = '[html]' . do_lang('GIFT_EXPLANATION1', $GLOBALS['FORUM_DRIVER']->get_username($member_id), $gift_row[0]['name']) . '[/html].' . "\n\n" . '[img]' . get_custom_base_url() . '/' . $gift_row[0]['image'] . '[/img]' . "\n\n" . $gift_message;
                 dispatch_notification('gift', NULL, $subject, $message, array($to_member_id));
             } else {
                 $subject = do_lang('GOT_GIFT', NULL, NULL, NULL, get_lang($to_member_id));
                 $message = '[html]' . do_lang('GIFT_EXPLANATION2', $gift_row[0]['name'], NULL, NULL, get_lang($to_member_id)) . '[/html].' . "\n\n" . '[img]' . get_custom_base_url() . '/' . $gift_row[0]['image'] . '[/img]' . "\n\n" . $gift_message;
                 dispatch_notification('gift', NULL, $subject, $message, array($to_member_id), A_FROM_SYSTEM_UNPRIVILEGED);
             }
         }
     } else {
         warn_exit(do_lang_tempcode('NO_MEMBER_SELECTED'));
     }
     // Show message
     $result = do_lang_tempcode('GIFT_CONGRATULATIONS');
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, $result);
 }
예제 #23
0
/**
 * Send out booking mails.
 *
 * @param  array		Booking details structure.
 */
function send_booking_emails($request)
{
    require_code('notifications');
    // Send receipt to customer
    $customer_email = $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member());
    $customer_name = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
    $receipt = do_template('BOOKING_CONFIRM_FCOMCODE', array('EMAIL_ADDRESS' => $customer_email, 'MEMBER_ID' => strval(get_member()), 'USERNAME' => $customer_name, 'PRICE' => float_format(find_booking_price($request)), 'DETAILS' => make_booking_request_printable($request)));
    dispatch_notification('booking_customer', NULL, do_lang('SUBJECT_BOOKING_CONFIRM', get_site_name()), static_evaluate_tempcode($receipt), array(get_member()), A_FROM_SYSTEM_PRIVILEGED);
    // Send notice to staff
    $notice = do_template('BOOKING_NOTICE_FCOMCODE', array('EMAIL_ADDRESS' => $customer_email, 'MEMBER_ID' => strval(get_member()), 'USERNAME' => $customer_name, 'PRICE' => float_format(find_booking_price($request)), 'DETAILS' => make_booking_request_printable($request)), get_site_default_lang());
    dispatch_notification('booking_inform_staff', NULL, do_lang('SUBJECT_BOOKING_NOTICE', $GLOBALS['FORUM_DRIVER']->get_username(get_member()), get_site_name()), static_evaluate_tempcode($notice), NULL, NULL, 2);
}
예제 #24
0
 /**
  * Handle IPN's. The function may produce output, which would be returned to the Payment Gateway. The function may do transaction verification.
  *
  * @return array	A long tuple of collected data.
  */
 function handle_transaction()
 {
     /*$myfile=fopen(get_file_base().'/data_custom/ecommerce.log','at');
     		fwrite($myfile,serialize($_POST));
     		fclose($myfile);*/
     $txn_id = post_param('trans_id');
     if (substr($txn_id, 0, 7) == 'subscr_') {
         $subscription = true;
         $txn_id = substr($txn_id, 7);
     } else {
         $subscription = false;
     }
     $transaction_rows = $GLOBALS['SITE_DB']->query_select('trans_expecting', array('*'), array('id' => $txn_id), '', 1);
     if (!array_key_exists(0, $transaction_rows)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $transaction_row = $transaction_rows[0];
     $member_id = $transaction_row['e_member_id'];
     $item_name = $subscription ? '' : $transaction_row['e_item_name'];
     $purchase_id = $transaction_row['e_purchase_id'];
     $code = post_param('code');
     $success = $code == 'A';
     $message = post_param('message');
     if ($message == '') {
         switch ($code) {
             case 'P:A':
                 $message = do_lang('PGE_A');
                 break;
             case 'P:X':
                 $message = do_lang('PGE_X');
                 break;
             case 'P:P':
                 $message = do_lang('PGE_P');
                 break;
             case 'P:S':
                 $message = do_lang('PGE_S');
                 break;
             case 'P:E':
                 $message = do_lang('PGE_E');
                 break;
             case 'P:I':
                 $message = do_lang('PGE_I');
                 break;
             case 'P:C':
                 $message = do_lang('PGE_C');
                 break;
             case 'P:T':
                 $message = do_lang('PGE_T');
                 break;
             case 'P:N':
                 $message = do_lang('PGE_N');
                 break;
             case 'P:M':
                 $message = do_lang('PGE_M');
                 break;
             case 'P:B':
                 $message = do_lang('PGE_B');
                 break;
             case 'P:D':
                 $message = do_lang('PGE_D');
                 break;
             case 'P:V':
                 $message = do_lang('PGE_V');
                 break;
             case 'P:R':
                 $message = do_lang('PGE_R');
                 break;
             case 'P:#':
                 $message = do_lang('PGE_HASH');
                 break;
             case 'C':
                 $message = do_lang('PGE_COMM');
                 break;
             default:
                 $message = do_lang('UNKNOWN');
         }
     }
     $payment_status = $success ? 'Completed' : 'Failed';
     $reason_code = '';
     $pending_reason = '';
     $memo = '';
     $mc_gross = post_param('amount');
     $mc_currency = post_param('currency', '');
     // May be blank for subscription
     $email = $GLOBALS['FORUM_DRIVER']->get_member_email_address($member_id);
     // Validate
     $hash = post_param('hash');
     if ($subscription) {
         $my_hash = md5('trans_id=' . $txn_id . '&' . 'req_cv2=true' . '&' . get_option('ipn_digest'));
     } else {
         $repeat = $this->_translate_subscription_details($transaction_row['e_length'], $transaction_row['e_length_units']);
         $my_hash = md5('trans_id=' . $txn_id . '&' . 'req_cv2=true' . '&' . 'repeat=' . $repeat . '&' . get_option('ipn_digest'));
     }
     if ($hash != $my_hash) {
         my_exit(do_lang('IPN_UNVERIFIED'));
     }
     if ($success) {
         require_code('notifications');
         dispatch_notification('payment_received', NULL, do_lang('PAYMENT_RECEIVED_SUBJECT', $txn_id, NULL, NULL, get_lang($member_id)), do_lang('PAYMENT_RECEIVED_BODY', float_format(floatval($mc_gross)), $mc_currency, get_site_name(), get_lang($member_id)), array($member_id), A_FROM_SYSTEM_PRIVILEGED);
     }
     // Subscription stuff
     if (get_param_integer('subc', 0) == 1) {
         if (!$success) {
             $payment_status = 'SCancelled';
         }
     }
     if ($success) {
         $_url = build_url(array('page' => 'purchase', 'type' => 'finish', 'product' => get_param('product', NULL)), get_module_zone('purchase'));
     } else {
         $_url = build_url(array('page' => 'purchase', 'type' => 'finish', 'cancel' => 1, 'message' => do_lang_tempcode('DECLINED_MESSAGE', $message)), get_module_zone('purchase'));
     }
     $url = $_url->evaluate();
     echo http_download_file($url);
     if (addon_installed('shopping')) {
         $this->store_shipping_address($purchase_id);
     }
     return array($purchase_id, $item_name, $payment_status, $reason_code, $pending_reason, $memo, $mc_gross, $mc_currency, $txn_id, '');
 }
예제 #25
0
 /**
  * Standard stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function ___text()
 {
     if (get_option('is_on_flagrant_buy') == '0') {
         return new ocp_tempcode();
     }
     $title = get_page_title('TITLE_NEWTEXT');
     // Define variables
     $member_id = get_member();
     $message = post_param('message');
     $days = post_param_integer('days');
     $points_left = available_points($member_id);
     // First we need to know the price of the number of days we ordered. After that, compare that price with our users current number of points.
     $dayprice = intval(get_option('text'));
     $total = $dayprice * $days;
     if ($points_left < $total && !has_specific_permission(get_member(), 'give_points_self')) {
         return warn_screen($title, do_lang_tempcode('FLAGRANT_LACK_POINTS', integer_format($days), integer_format($total), integer_format($points_left)));
     }
     // Add this to the database
     $GLOBALS['SITE_DB']->query_insert('text', array('notes' => '', 'activation_time' => NULL, 'active_now' => 0, 'user_id' => $member_id, 'the_message' => insert_lang_comcode($message, 2), 'days' => $days, 'order_time' => time()));
     // Mail off the notice
     require_code('notifications');
     $_url = build_url(array('page' => 'admin_flagrant'), 'adminzone', NULL, false, false, true);
     $manage_url = $_url->evaluate();
     dispatch_notification('pointstore_request_flagrant', NULL, do_lang('TITLE_NEWTEXT', NULL, NULL, NULL, get_site_default_lang()), do_lang('MAIL_FLAGRANT_TEXT', $message, comcode_escape($manage_url), NULL, get_site_default_lang()));
     // Now, deduct the points from our user's account
     require_code('points2');
     charge_member($member_id, $total, do_lang('PURCHASED_FLAGRANT'));
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('ORDER_FLAGRANT_DONE'));
 }
예제 #26
0
파일: cedi.php 프로젝트: erico-deh/ocPortal
/**
 * 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);
}
예제 #27
0
/**
 * 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);
        }
    }
}
예제 #28
0
/**
 * 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'));
}
예제 #29
0
/**
 * 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);
            }
        }
    }
}
예제 #30
0
/**
 * 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;
}