当前位置: 首页>>代码示例>>PHP>>正文


PHP trackStats函数代码示例

本文整理汇总了PHP中trackStats函数的典型用法代码示例。如果您正苦于以下问题:PHP trackStats函数的具体用法?PHP trackStats怎么用?PHP trackStats使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了trackStats函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createPost

function createPost(&$msgOptions, &$topicOptions, &$posterOptions)
{
    global $user_info, $txt, $modSettings, $smcFunc, $context;
    // Set optional parameters to the default value.
    $msgOptions['icon'] = empty($msgOptions['icon']) ? 'xx' : $msgOptions['icon'];
    $msgOptions['smileys_enabled'] = !empty($msgOptions['smileys_enabled']);
    $msgOptions['attachments'] = empty($msgOptions['attachments']) ? array() : $msgOptions['attachments'];
    $msgOptions['approved'] = isset($msgOptions['approved']) ? (int) $msgOptions['approved'] : 1;
    $topicOptions['id'] = empty($topicOptions['id']) ? 0 : (int) $topicOptions['id'];
    $topicOptions['poll'] = isset($topicOptions['poll']) ? (int) $topicOptions['poll'] : null;
    $topicOptions['lock_mode'] = isset($topicOptions['lock_mode']) ? $topicOptions['lock_mode'] : null;
    $topicOptions['sticky_mode'] = isset($topicOptions['sticky_mode']) ? $topicOptions['sticky_mode'] : null;
    $posterOptions['id'] = empty($posterOptions['id']) ? 0 : (int) $posterOptions['id'];
    $posterOptions['ip'] = empty($posterOptions['ip']) ? $user_info['ip'] : $posterOptions['ip'];
    // We need to know if the topic is approved. If we're told that's great - if not find out.
    if (!$modSettings['postmod_active']) {
        $topicOptions['is_approved'] = true;
    } elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved'])) {
        $request = $smcFunc['db_query']('', '
			SELECT approved
			FROM {db_prefix}topics
			WHERE id_topic = {int:id_topic}
			LIMIT 1', array('id_topic' => $topicOptions['id']));
        list($topicOptions['is_approved']) = $smcFunc['db_fetch_row']($request);
        $smcFunc['db_free_result']($request);
    }
    // If nothing was filled in as name/e-mail address, try the member table.
    if (!isset($posterOptions['name']) || $posterOptions['name'] == '' || empty($posterOptions['email']) && !empty($posterOptions['id'])) {
        if (empty($posterOptions['id'])) {
            $posterOptions['id'] = 0;
            $posterOptions['name'] = $txt['guest_title'];
            $posterOptions['email'] = '';
        } elseif ($posterOptions['id'] != $user_info['id']) {
            $request = $smcFunc['db_query']('', '
				SELECT member_name, email_address
				FROM {db_prefix}members
				WHERE id_member = {int:id_member}
				LIMIT 1', array('id_member' => $posterOptions['id']));
            // Couldn't find the current poster?
            if ($smcFunc['db_num_rows']($request) == 0) {
                trigger_error('createPost(): Invalid member id ' . $posterOptions['id'], E_USER_NOTICE);
                $posterOptions['id'] = 0;
                $posterOptions['name'] = $txt['guest_title'];
                $posterOptions['email'] = '';
            } else {
                list($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request);
            }
            $smcFunc['db_free_result']($request);
        } else {
            $posterOptions['name'] = $user_info['name'];
            $posterOptions['email'] = $user_info['email'];
        }
    }
    // It's do or die time: forget any user aborts!
    $previous_ignore_user_abort = ignore_user_abort(true);
    $new_topic = empty($topicOptions['id']);
    // Insert the post.
    $smcFunc['db_insert']('', '{db_prefix}messages', array('id_board' => 'int', 'id_topic' => 'int', 'id_member' => 'int', 'subject' => 'string-255', 'body' => !empty($modSettings['max_messageLength']) && $modSettings['max_messageLength'] > 65534 ? 'string-' . $modSettings['max_messageLength'] : 'string-65534', 'poster_name' => 'string-255', 'poster_email' => 'string-255', 'poster_time' => 'int', 'poster_ip' => 'string-255', 'smileys_enabled' => 'int', 'modified_name' => 'string', 'icon' => 'string-16', 'approved' => 'int'), array($topicOptions['board'], $topicOptions['id'], $posterOptions['id'], $msgOptions['subject'], $msgOptions['body'], $posterOptions['name'], $posterOptions['email'], time(), $posterOptions['ip'], $msgOptions['smileys_enabled'] ? 1 : 0, '', $msgOptions['icon'], $msgOptions['approved']), array('id_msg'));
    $msgOptions['id'] = $smcFunc['db_insert_id']('{db_prefix}messages', 'id_msg');
    // Something went wrong creating the message...
    if (empty($msgOptions['id'])) {
        return false;
    }
    // Fix the attachments.
    if (!empty($msgOptions['attachments'])) {
        $smcFunc['db_query']('', '
			UPDATE {db_prefix}attachments
			SET id_msg = {int:id_msg}
			WHERE id_attach IN ({array_int:attachment_list})', array('attachment_list' => $msgOptions['attachments'], 'id_msg' => $msgOptions['id']));
    }
    // Insert a new topic (if the topicID was left empty.)
    if ($new_topic) {
        $smcFunc['db_insert']('', '{db_prefix}topics', array('id_board' => 'int', 'id_member_started' => 'int', 'id_member_updated' => 'int', 'id_first_msg' => 'int', 'id_last_msg' => 'int', 'locked' => 'int', 'is_sticky' => 'int', 'num_views' => 'int', 'id_poll' => 'int', 'unapproved_posts' => 'int', 'approved' => 'int'), array($topicOptions['board'], $posterOptions['id'], $posterOptions['id'], $msgOptions['id'], $msgOptions['id'], $topicOptions['lock_mode'] === null ? 0 : $topicOptions['lock_mode'], $topicOptions['sticky_mode'] === null ? 0 : $topicOptions['sticky_mode'], 0, $topicOptions['poll'] === null ? 0 : $topicOptions['poll'], $msgOptions['approved'] ? 0 : 1, $msgOptions['approved']), array('id_topic'));
        $topicOptions['id'] = $smcFunc['db_insert_id']('{db_prefix}topics', 'id_topic');
        // The topic couldn't be created for some reason.
        if (empty($topicOptions['id'])) {
            // We should delete the post that did work, though...
            $smcFunc['db_query']('', '
				DELETE FROM {db_prefix}messages
				WHERE id_msg = {int:id_msg}', array('id_msg' => $msgOptions['id']));
            return false;
        }
        // Fix the message with the topic.
        $smcFunc['db_query']('', '
			UPDATE {db_prefix}messages
			SET id_topic = {int:id_topic}
			WHERE id_msg = {int:id_msg}', array('id_topic' => $topicOptions['id'], 'id_msg' => $msgOptions['id']));
        // There's been a new topic AND a new post today.
        trackStats(array('topics' => '+', 'posts' => '+'));
        updateStats('topic', true);
        updateStats('subject', $topicOptions['id'], $msgOptions['subject']);
        // What if we want to export new topics out to a CMS?
        call_integration_hook('integrate_create_topic', array($msgOptions, $topicOptions, $posterOptions));
    } else {
        $countChange = $msgOptions['approved'] ? 'num_replies = num_replies + 1' : 'unapproved_posts = unapproved_posts + 1';
        // Update the number of replies and the lock/sticky status.
        $smcFunc['db_query']('', '
			UPDATE {db_prefix}topics
			SET
				' . ($msgOptions['approved'] ? 'id_member_updated = {int:poster_id}, id_last_msg = {int:id_msg},' : '') . '
//.........这里部分代码省略.........
开发者ID:AhoyLemon,项目名称:ballpit,代码行数:101,代码来源:Subs-Post.php

示例2: elk_main

/**
 * The main dispatcher.
 * This delegates to each area.
 */
function elk_main()
{
    global $modSettings, $user_info, $topic, $board_info, $context;
    // Special case: session keep-alive, output a transparent pixel.
    if (isset($_GET['action']) && $_GET['action'] == 'keepalive') {
        header('Content-Type: image/gif');
        die("GIF89a€!ù,D;");
    }
    // We should set our security headers now.
    frameOptionsHeader();
    securityOptionsHeader();
    // Load the user's cookie (or set as guest) and load their settings.
    loadUserSettings();
    // Load the current board's information.
    loadBoard();
    // Load the current user's permissions.
    loadPermissions();
    // Load BadBehavior before we go much further
    loadBadBehavior();
    // Attachments don't require the entire theme to be loaded.
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach' && (!empty($modSettings['allow_guestAccess']) && $user_info['is_guest'])) {
        detectBrowser();
    } else {
        loadTheme();
    }
    // Check if the user should be disallowed access.
    is_not_banned();
    // If we are in a topic and don't have permission to approve it then duck out now.
    if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) {
        fatal_lang_error('not_a_topic', false);
    }
    $no_stat_actions = array('dlattach', 'findmember', 'jsoption', 'requestmembers', 'jslocale', 'xmlpreview', 'suggest', '.xml', 'xmlhttp', 'verificationcode', 'viewquery', 'viewadminfile');
    call_integration_hook('integrate_pre_log_stats', array(&$no_stat_actions));
    // Do some logging, unless this is an attachment, avatar, toggle of editor buttons, theme option, XML feed etc.
    if (empty($_REQUEST['action']) || !in_array($_REQUEST['action'], $no_stat_actions)) {
        // I see you!
        writeLog();
        // Track forum statistics and hits...?
        if (!empty($modSettings['hitStats'])) {
            trackStats(array('hits' => '+'));
        }
    }
    unset($no_stat_actions);
    // What shall we do?
    require_once SOURCEDIR . '/SiteDispatcher.class.php';
    $dispatcher = new Site_Dispatcher();
    // Show where we came from, and go
    $context['site_action'] = $dispatcher->site_action();
    $context['site_action'] = !empty($context['site_action']) ? $context['site_action'] : (isset($_REQUEST['action']) ? $_REQUEST['action'] : '');
    $dispatcher->dispatch();
}
开发者ID:Ralkage,项目名称:Elkarte,代码行数:55,代码来源:index.php

示例3: sendpm


//.........这里部分代码省略.........
                continue;
            }
            // Do they have any of the allowed groups?
            if (count(array_intersect($allowed_groups, $groups)) == 0 || count(array_intersect($disallowed_groups, $groups)) != 0) {
                $log['failed'][$row['id_member']] = sprintf($txt['pm_error_user_cannot_read'], $row['real_name']);
                unset($all_to[array_search($row['id_member'], $all_to)]);
                continue;
            }
        }
        // Note that PostgreSQL can return a lowercase t/f for FIND_IN_SET
        if (!empty($row['ignored']) && $row['ignored'] != 'f' && $row['id_member'] != $from['id']) {
            $log['failed'][$row['id_member']] = sprintf($txt['pm_error_ignored_by_user'], $row['real_name']);
            unset($all_to[array_search($row['id_member'], $all_to)]);
            continue;
        }
        // If the receiving account is banned (>=10) or pending deletion (4), refuse to send the PM.
        if ($row['is_activated'] >= 10 || $row['is_activated'] == 4 && !$user_info['is_admin']) {
            $log['failed'][$row['id_member']] = sprintf($txt['pm_error_user_cannot_read'], $row['real_name']);
            unset($all_to[array_search($row['id_member'], $all_to)]);
            continue;
        }
        // Send a notification, if enabled - taking the buddy list into account.
        if (!empty($row['email_address']) && ($row['pm_email_notify'] == 1 || $row['pm_email_notify'] > 1 && (!empty($modSettings['enable_buddylist']) && $row['is_buddy'])) && $row['is_activated'] == 1) {
            $notifications[empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']][] = $row['email_address'];
        }
        $log['sent'][$row['id_member']] = sprintf(isset($txt['pm_successfully_sent']) ? $txt['pm_successfully_sent'] : '', $row['real_name']);
    }
    $db->free_result($request);
    // Only 'send' the message if there are any recipients left.
    if (empty($all_to)) {
        return $log;
    }
    // Track the pm count for our stats
    if (!empty($modSettings['trackStats'])) {
        trackStats(array('pm' => '+'));
    }
    // Insert the message itself and then grab the last insert id.
    $db->insert('', '{db_prefix}personal_messages', array('id_pm_head' => 'int', 'id_member_from' => 'int', 'deleted_by_sender' => 'int', 'from_name' => 'string-255', 'msgtime' => 'int', 'subject' => 'string-255', 'body' => 'string-65534'), array($pm_head, $from['id'], $store_outbox ? 0 : 1, $from['username'], time(), $htmlsubject, $htmlmessage), array('id_pm'));
    $id_pm = $db->insert_id('{db_prefix}personal_messages', 'id_pm');
    // Add the recipients.
    if (!empty($id_pm)) {
        // If this is new we need to set it part of it's own conversation.
        if (empty($pm_head)) {
            $db->query('', '
				UPDATE {db_prefix}personal_messages
				SET id_pm_head = {int:id_pm_head}
				WHERE id_pm = {int:id_pm_head}', array('id_pm_head' => $id_pm));
        }
        // Some people think manually deleting personal_messages is fun... it's not. We protect against it though :)
        $db->query('', '
			DELETE FROM {db_prefix}pm_recipients
			WHERE id_pm = {int:id_pm}', array('id_pm' => $id_pm));
        $insertRows = array();
        $to_list = array();
        foreach ($all_to as $to) {
            $insertRows[] = array($id_pm, $to, in_array($to, $recipients['bcc']) ? 1 : 0, isset($deletes[$to]) ? 1 : 0, 1);
            if (!in_array($to, $recipients['bcc'])) {
                $to_list[] = $to;
            }
        }
        $db->insert('insert', '{db_prefix}pm_recipients', array('id_pm' => 'int', 'id_member' => 'int', 'bcc' => 'int', 'deleted' => 'int', 'is_new' => 'int'), $insertRows, array('id_pm', 'id_member'));
    }
    $maillist = !empty($modSettings['maillist_enabled']) && !empty($modSettings['pbe_pm_enabled']);
    // If they have post by email enabled, override disallow_sendBody
    if (!$maillist && !empty($modSettings['disallow_sendBody'])) {
        $message = '';
开发者ID:joshuaadickerson,项目名称:Elkarte,代码行数:67,代码来源:PersonalMessage.subs.php

示例4: reduceMailQueue


//.........这里部分代码省略.........
        list($mail_time, $mail_number) = isset($modSettings['mail_recent']) ? explode('|', $modSettings['mail_recent']) : array(0, 0);
        // Nothing worth noting...
        if (empty($mail_number) || $mail_time < time() - 60) {
            $mail_time = time();
            $mail_number = $batch_size;
        } elseif ($mail_number < $modSettings['mail_period_limit']) {
            // If this is likely one of the last cycles for this period, then send any remaining quota
            if ($mail_time - (time() - 60) < $delay * 2) {
                $batch_size = $modSettings['mail_period_limit'] - $mail_number;
            } elseif ($mail_number + $batch_size > $modSettings['mail_period_limit']) {
                $batch_size = $modSettings['mail_period_limit'] - $mail_number;
            }
            $mail_number += $batch_size;
        } else {
            return false;
        }
        // Reflect that we're about to send some, do it now to be safe.
        updateSettings(array('mail_recent' => $mail_time . '|' . $mail_number));
    }
    // Now we know how many we're sending, let's send them.
    list($ids, $emails) = emailsInfo($batch_size);
    // Delete, delete, delete!!!
    if (!empty($ids)) {
        deleteMailQueueItems($ids);
    }
    // Don't believe we have any left after this batch?
    if (count($ids) < $batch_size) {
        resetNextSendTime();
    }
    if (empty($ids)) {
        return false;
    }
    // We have some to send, lets send them!
    $sent = array();
    $failed_emails = array();
    // Use sendmail or SMTP
    $use_sendmail = empty($modSettings['mail_type']) || $modSettings['smtp_host'] == '';
    // Line breaks need to be \r\n only in windows or for SMTP.
    $line_break = !empty($context['server']['is_windows']) || !$use_sendmail ? "\r\n" : "\n";
    foreach ($emails as $key => $email) {
        // Use the right mail resource
        if ($use_sendmail) {
            $email['subject'] = strtr($email['subject'], array("\r" => '', "\n" => ''));
            if (!empty($modSettings['mail_strip_carriage'])) {
                $email['body'] = strtr($email['body'], array("\r" => ''));
                $email['headers'] = strtr($email['headers'], array("\r" => ''));
            }
            $need_break = substr($email['headers'], -1) === "\n" || substr($email['headers'], -1) === "\r" ? false : true;
            // Create our unique reply to email header if this message needs one
            $unq_id = '';
            $unq_head = '';
            if (!empty($modSettings['maillist_enabled']) && $email['message_id'] !== null && strpos($email['headers'], 'List-Id: <') !== false) {
                $unq_head = md5($scripturl . microtime() . rand()) . '-' . $email['message_id'];
                $encoded_unq_head = base64_encode($line_break . $line_break . '[' . $unq_head . ']' . $line_break);
                $unq_id = ($need_break ? $line_break : '') . 'Message-ID: <' . $unq_head . strstr(empty($modSettings['maillist_mail_from']) ? $webmaster_email : $modSettings['maillist_mail_from'], '@') . '>';
                $email['body_fail'] = $email['body'];
                $email['body'] = mail_insert_key($email['body'], $unq_head, $encoded_unq_head, $line_break);
            } elseif ($email['message_id'] !== null && empty($modSettings['mail_no_message_id'])) {
                $unq_id = ($need_break ? $line_break : '') . 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $email['message_id'] . strstr(empty($modSettings['maillist_mail_from']) ? $webmaster_email : $modSettings['maillist_mail_from'], '@') . '>';
            }
            // No point logging a specific error here, as we have no language. PHP error is helpful anyway...
            $result = mail(strtr($email['to'], array("\r" => '', "\n" => '')), $email['subject'], $email['body'], $email['headers'] . $unq_id);
            // If it sent, keep a record so we can save it in our allowed to reply log
            if (!empty($unq_head) && $result) {
                $sent[] = array($unq_head, time(), $email['to']);
            }
            // Track total emails sent
            if ($result && !empty($modSettings['trackStats'])) {
                trackStats(array('email' => '+'));
            }
            // Try to stop a timeout, this would be bad...
            @set_time_limit(300);
            if (function_exists('apache_reset_timeout')) {
                @apache_reset_timeout();
            }
        } else {
            $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['send_html'] ? $email['headers'] : 'Mime-Version: 1.0' . "\r\n" . $email['headers'], $email['priority'], $email['message_id']);
        }
        // Hopefully it sent?
        if (!$result) {
            $failed_emails[] = array(time(), $email['to'], $email['body_fail'], $email['subject'], $email['headers'], $email['send_html'], $email['priority'], $email['private'], $email['message_id']);
        }
    }
    // Clear out the stat cache.
    trackStats();
    // Log each of the sent emails.
    if (!empty($sent)) {
        log_email($sent);
    }
    // Any emails that didn't send?
    if (!empty($failed_emails)) {
        // If it failed, add it back to the queue
        updateFailedQueue($failed_emails);
        return false;
    } elseif (!empty($modSettings['mail_failed_attempts'])) {
        updateSuccessQueue();
    }
    // Had something to send...
    return true;
}
开发者ID:scripple,项目名称:Elkarte,代码行数:101,代码来源:Mail.subs.php

示例5: obExit

function obExit($header = null, $do_footer = null, $from_index = false, $from_fatal_error = false)
{
    global $context, $settings, $modSettings, $txt, $smcFunc;
    static $header_done = false, $footer_done = false, $level = 0, $has_fatal_error = false;
    // Attempt to prevent a recursive loop.
    ++$level;
    if ($level > 1 && !$from_fatal_error && !$has_fatal_error) {
        exit;
    }
    if ($from_fatal_error) {
        $has_fatal_error = true;
    }
    // Clear out the stat cache.
    trackStats();
    // If we have mail to send, send it.
    if (!empty($context['flush_mail'])) {
        AddMailQueue(true);
    }
    $do_header = $header === null ? !$header_done : $header;
    if ($do_footer === null) {
        $do_footer = $do_header;
    }
    // Has the template/header been done yet?
    if ($do_header) {
        // Was the page title set last minute? Also update the HTML safe one.
        if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) {
            $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title']));
        }
        // Start up the session URL fixer.
        ob_start('ob_sessrewrite');
        if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) {
            $buffers = explode(',', $settings['output_buffers']);
        } elseif (!empty($settings['output_buffers'])) {
            $buffers = $settings['output_buffers'];
        } else {
            $buffers = array();
        }
        if (isset($modSettings['integrate_buffer'])) {
            $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers);
        }
        if (!empty($buffers)) {
            foreach ($buffers as $function) {
                $function = trim($function);
                $call = strpos($function, '::') !== false ? explode('::', $function) : $function;
                // Is it valid?
                if (is_callable($call)) {
                    ob_start($call);
                }
            }
        }
        // Display the screen in the logical order.
        template_header();
        $header_done = true;
    }
    if ($do_footer) {
        if (WIRELESS && !isset($context['sub_template'])) {
            fatal_lang_error('wireless_error_notyet', false);
        }
        // Just show the footer, then.
        loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main');
        // Anything special to put out?
        if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) {
            echo $context['insert_after_template'];
        }
        // Just so we don't get caught in an endless loop of errors from the footer...
        if (!$footer_done) {
            $footer_done = true;
            template_footer();
            // (since this is just debugging... it's okay that it's after </html>.)
            if (!isset($_REQUEST['xml'])) {
                db_debug_junk();
            }
        }
    }
    // Remember this URL in case someone doesn't like sending HTTP_REFERER.
    if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) {
        $_SESSION['old_url'] = $_SERVER['REQUEST_URL'];
    }
    // For session check verfication.... don't switch browsers...
    $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT'];
    if (!empty($settings['strict_doctype'])) {
        // The theme author wants to use the STRICT doctype (only God knows why).
        $temp = ob_get_contents();
        if (function_exists('ob_clean')) {
            ob_clean();
        } else {
            ob_end_clean();
            ob_start('ob_sessrewrite');
        }
        echo strtr($temp, array('var smf_iso_case_folding' => 'var target_blank = \'_blank\'; var smf_iso_case_folding', 'target="_blank"' => 'onclick="this.target=target_blank"'));
    }
    // Hand off the output to the portal, etc. we're integrated with.
    call_integration_hook('integrate_exit', array($do_footer && !WIRELESS));
    // Don't exit if we're coming from index.php; that will pass through normally.
    if (!$from_index || WIRELESS) {
        exit;
    }
}
开发者ID:AhoyLemon,项目名称:ballpit,代码行数:98,代码来源:Subs.backup.2.php

示例6: method_create_topic


//.........这里部分代码省略.........
            AND ' . (!empty($id_topic) ? 't.ID_TOPIC' : 'b.ID_BOARD') . ' = {int:value}', array('value' => empty($id_topic) ? $id_board : $id_topic));
    if ($mobdb->num_rows() == 0) {
        createErrorResponse(4);
    }
    list($id_board) = $mobdb->fetch_row();
    $mobdb->free_result();
    // Can we actually post?
    if (!isset($id_topic)) {
        if (allowedTo('post_new', $id_board)) {
            $can_post = 1;
        } elseif ($modSettings['postmod_active'] && !allowedTo('post_new', $id_board) && allowedTo('post_unapproved_topics', $id_board)) {
            $can_post = 2;
        } else {
            createErrorResponse(25);
        }
    } else {
        $mobdb->query('
            SELECT locked, isSticky AS is_sticky, 1 AS approved, numReplies AS num_replies, ID_FIRST_MSG AS id_first_msg, ID_MEMBER_STARTED AS id_member_started, ID_BOARD AS id_board,
                ID_POLL AS id_poll
            FROM {db_prefix}topics
            WHERE id_topic = {int:current_topic}
            LIMIT 1', array('current_topic' => $id_topic));
        $topic_info = $mobdb->fetch_assoc();
        $mobdb->free_result();
        if ($topic_info['id_board'] != $id_board) {
            createErrorResponse(25);
        }
        // Locked?
        if ($topic_info['locked'] && !allowedTo('moderate_board', $id_board)) {
            createErrorResponse(25);
        }
        // Is this this guy's topic?
        if ($topic_info['id_member_started'] == $user_info['id']) {
            if (allowedTo('post_reply_own', $id_board)) {
                $can_post = 1;
            } elseif ($modSettings['postmod_active'] && !allowedTo('post_reply_own', $id_board) && allowedTo('post_unapproved_replies_own', $id_board)) {
                $can_post = 2;
            } else {
                createErrorResponse(25);
            }
        } else {
            if (allowedTo('post_reply_any', $id_board)) {
                $can_post = 1;
            } elseif ($modSettings['postmod_active'] && !allowedTo('post_reply_any', $id_board) && allowedTo('post_unapproved_replies_any', $id_board)) {
                $can_post = 2;
            } else {
                createErrorResponse(2);
            }
        }
    }
    // Alright, we passed the security tests, lets check the inputs
    //$subject = strtr(htmlspecialchars($subject), array("\r" => '', "\n" => '', "\t" => ''));
    //$body = htmlspecialchars($body);
    ######## Added by Sean to fix the issue can not post##############
    $subject = addslashes__recursive($subject);
    $body = addslashes__recursive($body);
    // Set up the inputs for the form.
    $body = $func['htmlspecialchars']($body, ENT_QUOTES);
    preparsecode($body);
    $subject = strtr($func['htmlspecialchars']($subject), array("\r" => '', "\n" => '', "\t" => ''));
    ##################################################################
    if (strlen($subject) > 100) {
        $subject = substr($subject, 0, 100);
    }
    // Are the attachments valid?
    if (isset($id_attach)) {
        // Does it even exist?
        $mobdb->query('
            SELECT a.ID_ATTACH, a.ID_THUMB
            FROM {db_prefix}attachments AS a
            WHERE a.ID_ATTACH = {int:attach}', array('attach' => $id_attach));
        // Not found?
        if ($mobdb->num_rows() == 0) {
            unset($id_attach);
        }
        list($id_attach, $id_thumb) = $mobdb->fetch_row();
        $mobdb->free_result();
    }
    // Get the parameters ready
    $msgOptions = array('id' => 0, 'subject' => $subject, 'body' => $body, 'icon' => isset($id_attach) ? 'clip' : 'xx', 'smileys_enabled' => true, 'attachments' => isset($id_attach) ? array($id_attach, $id_thumb) : null, 'approved' => $can_post == 2 ? false : true);
    $topicOptions = array('id' => isset($id_topic) ? $id_topic : 0, 'board' => $id_board, 'poll' => isset($topic_info) ? $topic_info['id_poll'] : null, 'lock_mode' => isset($topic_info) ? $topic_info['locked'] : null, 'sticky_mode' => isset($topic_info) ? $topic_info['is_sticky'] : null, 'mark_as_read' => true, 'is_approved' => $can_post == 2 ? false : true);
    $posterOptions = array('id' => $user_info['id'], 'name' => $user_info['name'], 'email' => $user_info['email'], 'update_post_count' => true);
    // Actually create the topic...
    createPost($msgOptions, $topicOptions, $posterOptions);
    if (empty($topicOptions['id'])) {
        createErrorResponse(8);
    }
    $id_topic = $topicOptions['id'];
    trackStats();
    // Notifications anyone?
    $notifyData = array('body' => $body, 'subject' => $subject, 'name' => $user_info['name'], 'poster' => $user_info['id'], 'msg' => $msgOptions['id'], 'board' => $id_board, 'topic' => $id_topic);
    //!!! Stupid fix for SMF 1.1
    $board = $id_board;
    $topic = $id_topic;
    if (!$is_post) {
        notifyMembersBoard($notifyData);
    }
    // Send out the response
    outputRPCNewTopic($is_post ? $msgOptions['id'] : $topicOptions['id'], $can_post, $is_post);
}
开发者ID:keweiliu6,项目名称:test_smf1,代码行数:101,代码来源:Mobiquo-Functions.php

示例7: obExit

function obExit($header = null, $do_footer = null, $from_index = false)
{
    global $context, $settings, $modSettings, $txt;
    static $header_done = false, $footer_done = false;
    // Clear out the stat cache.
    trackStats();
    $do_header = $header === null ? !$header_done : $header;
    if ($do_footer === null) {
        $do_footer = $do_header;
    }
    // Has the template/header been done yet?
    if ($do_header) {
        // Start up the session URL fixer.
        ob_start('ob_sessrewrite');
        // Just in case we have anything bad already in there...
        if ((isset($_REQUEST['debug']) || isset($_REQUEST['xml']) || WIRELESS && WIRELESS_PROTOCOL == 'wap') && in_array($txt['lang_locale'], array('UTF-8', 'ISO-8859-1'))) {
            ob_start('validate_unicode__recursive');
        }
        if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) {
            $buffers = explode(',', $settings['output_buffers']);
        } elseif (!empty($settings['output_buffers'])) {
            $buffers = $settings['output_buffers'];
        } else {
            $buffers = array();
        }
        if (isset($modSettings['integrate_buffer'])) {
            $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers);
        }
        if (!empty($buffers)) {
            foreach ($buffers as $buffer_function) {
                if (function_exists(trim($buffer_function))) {
                    ob_start(trim($buffer_function));
                }
            }
        }
        // Display the screen in the logical order.
        template_header();
        $header_done = true;
    }
    if ($do_footer) {
        if (WIRELESS && !isset($context['sub_template'])) {
            fatal_lang_error('wireless_error_notyet', false);
        }
        // Just show the footer, then.
        loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main');
        // Just so we don't get caught in an endless loop of errors from the footer...
        if (!$footer_done) {
            $footer_done = true;
            template_footer();
            // (since this is just debugging... it's okay that it's after </html>.)
            if (!isset($_REQUEST['xml'])) {
                db_debug_junk();
            }
        }
    }
    // Remember this URL in case someone doesn't like sending HTTP_REFERER.
    if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false) {
        $_SESSION['old_url'] = $_SERVER['REQUEST_URL'];
    }
    // For session check verfication.... don't switch browsers...
    $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT'];
    // Hand off the output to the portal, etc. we're integrated with.
    if (isset($modSettings['integrate_exit'], $context['template_layers']) && in_array('main', $context['template_layers']) && function_exists($modSettings['integrate_exit'])) {
        call_user_func($modSettings['integrate_exit'], $do_footer && !WIRELESS);
    }
    // Don't exit if we're coming from index.php; that will pass through normally.
    if (!$from_index || WIRELESS) {
        exit;
    }
}
开发者ID:bbon,项目名称:mjncms,代码行数:70,代码来源:Subs.php

示例8: createPost


//.........这里部分代码省略.........
    if (empty($msgOptions['id'])) {
        return false;
    }
    // Fix the attachments.
    if (!empty($msgOptions['attachments'])) {
        $db->query('', '
			UPDATE {db_prefix}attachments
			SET id_msg = {int:id_msg}
			WHERE id_attach IN ({array_int:attachment_list})', array('attachment_list' => $msgOptions['attachments'], 'id_msg' => $msgOptions['id']));
    }
    // What if we want to export new posts out to a CMS?
    call_integration_hook('integrate_create_post', array($msgOptions, $topicOptions, $posterOptions, $message_columns, $message_parameters));
    // Insert a new topic (if the topicID was left empty.)
    if ($new_topic) {
        $topic_columns = array('id_board' => 'int', 'id_member_started' => 'int', 'id_member_updated' => 'int', 'id_first_msg' => 'int', 'id_last_msg' => 'int', 'locked' => 'int', 'is_sticky' => 'int', 'num_views' => 'int', 'id_poll' => 'int', 'unapproved_posts' => 'int', 'approved' => 'int', 'redirect_expires' => 'int', 'id_redirect_topic' => 'int');
        $topic_parameters = array('id_board' => $topicOptions['board'], 'id_member_started' => $posterOptions['id'], 'id_member_updated' => $posterOptions['id'], 'id_first_msg' => $msgOptions['id'], 'id_last_msg' => $msgOptions['id'], 'locked' => $topicOptions['lock_mode'] === null ? 0 : $topicOptions['lock_mode'], 'is_sticky' => $topicOptions['sticky_mode'] === null ? 0 : $topicOptions['sticky_mode'], 'num_views' => 0, 'id_poll' => $topicOptions['poll'] === null ? 0 : $topicOptions['poll'], 'unapproved_posts' => $msgOptions['approved'] ? 0 : 1, 'approved' => $msgOptions['approved'], 'redirect_expires' => $topicOptions['redirect_expires'] === null ? 0 : $topicOptions['redirect_expires'], 'id_redirect_topic' => $topicOptions['redirect_topic'] === null ? 0 : $topicOptions['redirect_topic']);
        call_integration_hook('integrate_before_create_topic', array(&$msgOptions, &$topicOptions, &$posterOptions, &$topic_columns, &$topic_parameters));
        $db->insert('', '{db_prefix}topics', $topic_columns, $topic_parameters, array('id_topic'));
        $topicOptions['id'] = $db->insert_id('{db_prefix}topics', 'id_topic');
        // The topic couldn't be created for some reason.
        if (empty($topicOptions['id'])) {
            // We should delete the post that did work, though...
            $db->query('', '
				DELETE FROM {db_prefix}messages
				WHERE id_msg = {int:id_msg}', array('id_msg' => $msgOptions['id']));
            return false;
        }
        // Fix the message with the topic.
        $db->query('', '
			UPDATE {db_prefix}messages
			SET id_topic = {int:id_topic}
			WHERE id_msg = {int:id_msg}', array('id_topic' => $topicOptions['id'], 'id_msg' => $msgOptions['id']));
        // There's been a new topic AND a new post today.
        trackStats(array('topics' => '+', 'posts' => '+'));
        updateStats('topic', true);
        updateStats('subject', $topicOptions['id'], $msgOptions['subject']);
        // What if we want to export new topics out to a CMS?
        call_integration_hook('integrate_create_topic', array($msgOptions, $topicOptions, $posterOptions));
    } else {
        $update_parameters = array('poster_id' => $posterOptions['id'], 'id_msg' => $msgOptions['id'], 'locked' => $topicOptions['lock_mode'], 'is_sticky' => $topicOptions['sticky_mode'], 'id_topic' => $topicOptions['id'], 'counter_increment' => 1);
        if ($msgOptions['approved']) {
            $topics_columns = array('id_member_updated = {int:poster_id}', 'id_last_msg = {int:id_msg}', 'num_replies = num_replies + {int:counter_increment}');
        } else {
            $topics_columns = array('unapproved_posts = unapproved_posts + {int:counter_increment}');
        }
        if ($topicOptions['lock_mode'] !== null) {
            $topics_columns[] = 'locked = {int:locked}';
        }
        if ($topicOptions['sticky_mode'] !== null) {
            $topics_columns[] = 'is_sticky = {int:is_sticky}';
        }
        call_integration_hook('integrate_before_modify_topic', array(&$topics_columns, &$update_parameters, &$msgOptions, &$topicOptions, &$posterOptions));
        // Update the number of replies and the lock/sticky status.
        $db->query('', '
			UPDATE {db_prefix}topics
			SET
				' . implode(', ', $topics_columns) . '
			WHERE id_topic = {int:id_topic}', $update_parameters);
        // One new post has been added today.
        trackStats(array('posts' => '+'));
    }
    // Creating is modifying...in a way.
    // @todo id_msg_modified needs to be set when you create a post, now this query is
    // the only place it does get set for post creation.  Why not set it on the insert?
    $db->query('', '
		UPDATE {db_prefix}messages
开发者ID:KeiroD,项目名称:Elkarte,代码行数:67,代码来源:Post.subs.php

示例9: BoardIndex


//.........这里部分代码省略.........
    // Load the users online right now.
    $result = db_query("\n\t\tSELECT\n\t\t\tlo.ID_MEMBER, lo.logTime, mem.realName, mem.memberName, mem.showOnline,\n\t\t\tmg.onlineColor, mg.ID_GROUP, mg.groupName\n\t\tFROM {$db_prefix}log_online AS lo\n\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = lo.ID_MEMBER)\n\t\t\tLEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))", __FILE__, __LINE__);
    $context['users_online'] = array();
    $context['list_users_online'] = array();
    $context['online_groups'] = array();
    $context['num_guests'] = 0;
    $context['num_buddies'] = 0;
    $context['num_users_hidden'] = 0;
    $context['show_buddies'] = !empty($user_info['buddies']);
    while ($row = mysql_fetch_assoc($result)) {
        if (empty($row['realName'])) {
            $context['num_guests']++;
            continue;
        } elseif (empty($row['showOnline']) && !allowedTo('moderate_forum')) {
            $context['num_users_hidden']++;
            continue;
        }
        // Some basic color coding...
        if (!empty($row['onlineColor'])) {
            $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '" style="color: ' . $row['onlineColor'] . ';">' . $row['realName'] . '</a>';
        } else {
            $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a>';
        }
        $is_buddy = in_array($row['ID_MEMBER'], $user_info['buddies']);
        if ($is_buddy) {
            $context['num_buddies']++;
            $link = '<b>' . $link . '</b>';
        }
        $context['users_online'][$row['logTime'] . $row['memberName']] = array('id' => $row['ID_MEMBER'], 'username' => $row['memberName'], 'name' => $row['realName'], 'group' => $row['ID_GROUP'], 'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'], 'link' => $link, 'is_buddy' => $is_buddy, 'hidden' => empty($row['showOnline']));
        $context['list_users_online'][$row['logTime'] . $row['memberName']] = empty($row['showOnline']) ? '<i>' . $link . '</i>' : $link;
        if (!isset($context['online_groups'][$row['ID_GROUP']])) {
            $context['online_groups'][$row['ID_GROUP']] = array('id' => $row['ID_GROUP'], 'name' => $row['groupName'], 'color' => $row['onlineColor']);
        }
    }
    mysql_free_result($result);
    krsort($context['users_online']);
    krsort($context['list_users_online']);
    ksort($context['online_groups']);
    $context['num_users_online'] = count($context['users_online']) + $context['num_users_hidden'];
    // Track most online statistics?
    if (!empty($modSettings['trackStats'])) {
        // Determine the most users online - both all time and per day.
        $total_users = $context['num_guests'] + $context['num_users_online'];
        // More members on now than ever were?  Update it!
        if (!isset($modSettings['mostOnline']) || $total_users >= $modSettings['mostOnline']) {
            updateSettings(array('mostOnline' => $total_users, 'mostDate' => time()));
        }
        $date = strftime('%Y-%m-%d', forum_time(false));
        // One or more stats are not up-to-date?
        if (!isset($modSettings['mostOnlineUpdated']) || $modSettings['mostOnlineUpdated'] != $date) {
            $request = db_query("\n\t\t\t\tSELECT mostOn\n\t\t\t\tFROM {$db_prefix}log_activity\n\t\t\t\tWHERE date = '{$date}'\n\t\t\t\tLIMIT 1", __FILE__, __LINE__);
            // The log_activity hasn't got an entry for today?
            if (mysql_num_rows($request) == 0) {
                db_query("\n\t\t\t\t\tINSERT IGNORE INTO {$db_prefix}log_activity\n\t\t\t\t\t\t(date, mostOn)\n\t\t\t\t\tVALUES ('{$date}', {$total_users})", __FILE__, __LINE__);
            } else {
                list($modSettings['mostOnlineToday']) = mysql_fetch_row($request);
                if ($total_users > $modSettings['mostOnlineToday']) {
                    trackStats(array('mostOn' => $total_users));
                }
                $total_users = max($total_users, $modSettings['mostOnlineToday']);
            }
            mysql_free_result($request);
            updateSettings(array('mostOnlineUpdated' => $date, 'mostOnlineToday' => $total_users));
        } elseif ($total_users > $modSettings['mostOnlineToday']) {
            trackStats(array('mostOn' => $total_users));
            updateSettings(array('mostOnlineUpdated' => $date, 'mostOnlineToday' => $total_users));
        }
    }
    // Set the latest member.
    $context['latest_member'] =& $context['common_stats']['latest_member'];
    // Load the most recent post?
    if (!empty($settings['number_recent_posts']) && $settings['number_recent_posts'] == 1 || $settings['show_sp1_info']) {
        $context['latest_post'] = $most_recent_topic['ref'];
    }
    if (!empty($settings['number_recent_posts']) && $settings['number_recent_posts'] > 1) {
        require_once $sourcedir . '/Recent.php';
        if (($context['latest_posts'] = cache_get_data('boardindex-latest_posts:' . md5($user_info['query_see_board'] . $user_info['language']), 180)) == null) {
            $context['latest_posts'] = getLastPosts($settings['number_recent_posts']);
            cache_put_data('boardindex-latest_posts:' . md5($user_info['query_see_board'] . $user_info['language']), $context['latest_posts'], 180);
        }
        // We have to clean up the cached data a bit.
        foreach ($context['latest_posts'] as $k => $post) {
            $context['latest_posts'][$k]['time'] = timeformat($post['raw_timestamp']);
            $context['latest_posts'][$k]['timestamp'] = forum_time(true, $post['raw_timestamp']);
        }
    }
    $settings['display_recent_bar'] = !empty($settings['number_recent_posts']) ? $settings['number_recent_posts'] : 0;
    $settings['show_member_bar'] &= allowedTo('view_mlist');
    $context['show_stats'] = allowedTo('view_stats') && !empty($modSettings['trackStats']);
    $context['show_member_list'] = allowedTo('view_mlist');
    $context['show_who'] = allowedTo('who_view') && !empty($modSettings['who_enabled']);
    // Set some permission related settings.
    $context['show_login_bar'] = $user_info['is_guest'] && !empty($modSettings['enableVBStyleLogin']);
    $context['show_calendar'] = allowedTo('calendar_view') && !empty($modSettings['cal_enabled']);
    // Load the calendar?
    if ($context['show_calendar']) {
        $context['show_calendar'] = calendarDoIndex();
    }
    $context['page_title'] = $txt[18];
}
开发者ID:alencarmo,项目名称:OCF,代码行数:101,代码来源:BoardIndex.php

示例10: registerMember


//.........这里部分代码省略.........
    // Check if the email address is in use.
    $request = db_query("\n\t\tSELECT ID_MEMBER\n\t\tFROM {$db_prefix}members\n\t\tWHERE emailAddress = '{$regOptions['email']}'\n\t\t\tOR emailAddress = '{$regOptions['username']}'\n\t\tLIMIT 1", __FILE__, __LINE__);
    // !!! Separate the sprintf?
    if (mysql_num_rows($request) != 0) {
        fatal_error(sprintf($txt[730], htmlspecialchars($regOptions['email'])), false);
    }
    mysql_free_result($request);
    // Some of these might be overwritten. (the lower ones that are in the arrays below.)
    $regOptions['register_vars'] = array('memberName' => "'{$regOptions['username']}'", 'emailAddress' => "'{$regOptions['email']}'", 'passwd' => '\'' . sha1(strtolower($regOptions['username']) . $regOptions['password']) . '\'', 'passwordSalt' => '\'' . substr(md5(mt_rand()), 0, 4) . '\'', 'posts' => 0, 'dateRegistered' => time(), 'memberIP' => "'{$user_info['ip']}'", 'memberIP2' => "'{$_SERVER['BAN_CHECK_IP']}'", 'validation_code' => "'{$validation_code}'", 'realName' => "'{$regOptions['username']}'", 'personalText' => '\'' . addslashes($modSettings['default_personalText']) . '\'', 'pm_email_notify' => 1, 'ID_THEME' => 0, 'ID_POST_GROUP' => 4, 'lngfile' => "''", 'buddy_list' => "''", 'pm_ignore_list' => "''", 'messageLabels' => "''", 'personalText' => "''", 'websiteTitle' => "''", 'websiteUrl' => "''", 'location' => "''", 'ICQ' => "''", 'AIM' => "''", 'YIM' => "''", 'MSN' => "''", 'timeFormat' => "''", 'signature' => "''", 'avatar' => "''", 'usertitle' => "''", 'secretQuestion' => "''", 'secretAnswer' => "''", 'additionalGroups' => "''", 'smileySet' => "''");
    // Setup the activation status on this new account so it is correct - firstly is it an under age account?
    if ($regOptions['require'] == 'coppa') {
        $regOptions['register_vars']['is_activated'] = 5;
        // !!! This should be changed.  To what should be it be changed??
        $regOptions['register_vars']['validation_code'] = "''";
    } elseif ($regOptions['require'] == 'nothing') {
        $regOptions['register_vars']['is_activated'] = 1;
    } elseif ($regOptions['require'] == 'activation') {
        $regOptions['register_vars']['is_activated'] = 0;
    } else {
        $regOptions['register_vars']['is_activated'] = 3;
    }
    if (isset($regOptions['memberGroup'])) {
        // Make sure the ID_GROUP will be valid, if this is an administator.
        $regOptions['register_vars']['ID_GROUP'] = $regOptions['memberGroup'] == 1 && !allowedTo('admin_forum') ? 0 : $regOptions['memberGroup'];
        // Check if this group is assignable.
        $unassignableGroups = array(-1, 3);
        $request = db_query("\n\t\t\tSELECT ID_GROUP\n\t\t\tFROM {$db_prefix}membergroups\n\t\t\tWHERE minPosts != -1", __FILE__, __LINE__);
        while ($row = mysql_fetch_assoc($request)) {
            $unassignableGroups[] = $row['ID_GROUP'];
        }
        mysql_free_result($request);
        if (in_array($regOptions['register_vars']['ID_GROUP'], $unassignableGroups)) {
            $regOptions['register_vars']['ID_GROUP'] = 0;
        }
    }
    // Integrate optional member settings to be set.
    if (!empty($regOptions['extra_register_vars'])) {
        foreach ($regOptions['extra_register_vars'] as $var => $value) {
            $regOptions['register_vars'][$var] = $value;
        }
    }
    // Integrate optional user theme options to be set.
    $theme_vars = array();
    if (!empty($regOptions['theme_vars'])) {
        foreach ($regOptions['theme_vars'] as $var => $value) {
            $theme_vars[$var] = $value;
        }
    }
    // Call an optional function to validate the users' input.
    if (isset($modSettings['integrate_register']) && function_exists($modSettings['integrate_register'])) {
        $modSettings['integrate_register']($regOptions, $theme_vars);
    }
    // Register them into the database.
    db_query("\n\t\tINSERT INTO {$db_prefix}members\n\t\t\t(" . implode(', ', array_keys($regOptions['register_vars'])) . ")\n\t\tVALUES (" . implode(', ', $regOptions['register_vars']) . ')', __FILE__, __LINE__);
    $memberID = db_insert_id();
    // Grab their real name and send emails using it.
    $realName = substr($regOptions['register_vars']['realName'], 1, -1);
    // Update the number of members and latest member's info - and pass the name, but remove the 's.
    updateStats('member', $memberID, $realName);
    // Theme variables too?
    if (!empty($theme_vars)) {
        $setString = '';
        foreach ($theme_vars as $var => $val) {
            $setString .= "\n\t\t\t\t({$memberID}, SUBSTRING('{$var}', 1, 255), SUBSTRING('{$val}', 1, 65534)),";
        }
        db_query("\n\t\t\tINSERT INTO {$db_prefix}themes\n\t\t\t\t(ID_MEMBER, variable, value)\n\t\t\tVALUES " . substr($setString, 0, -1), __FILE__, __LINE__);
    }
    // If it's enabled, increase the registrations for today.
    trackStats(array('registers' => '+'));
    // Administrative registrations are a bit different...
    if ($regOptions['interface'] == 'admin') {
        if ($regOptions['require'] == 'activation') {
            $email_message = 'register_activate_message';
        } elseif (!empty($regOptions['send_welcome_email'])) {
            $email_message = 'register_immediate_message';
        }
        if (isset($email_message)) {
            sendmail($regOptions['email'], $txt['register_subject'], sprintf($txt[$email_message], $realName, $regOptions['username'], $regOptions['password'], $validation_code, $scripturl . '?action=activate;u=' . $memberID . ';code=' . $validation_code));
        }
        // All admins are finished here.
        return $memberID;
    }
    // Can post straight away - welcome them to your fantastic community...
    if ($regOptions['require'] == 'nothing') {
        if (!empty($regOptions['send_welcome_email'])) {
            sendmail($regOptions['email'], $txt['register_subject'], sprintf($txt['register_immediate_message'], $realName, $regOptions['username'], $regOptions['password']));
        }
        // Send admin their notification.
        adminNotify('standard', $memberID, $regOptions['username']);
    } elseif ($regOptions['require'] == 'activation' || $regOptions['require'] == 'coppa') {
        sendmail($regOptions['email'], $txt['register_subject'], sprintf($txt['register_activate_message'], $realName, $regOptions['username'], $regOptions['password'], $validation_code, $scripturl . '?action=activate;u=' . $memberID . ';code=' . $validation_code));
    } else {
        sendmail($regOptions['email'], $txt['register_subject'], sprintf($txt['register_pending_message'], $realName, $regOptions['username'], $regOptions['password']));
        // Admin gets informed here...
        adminNotify('approval', $memberID, $regOptions['username']);
    }
    // Okay, they're for sure registered... make sure the session is aware of this for security. (Just married :P!)
    $_SESSION['just_registered'] = 1;
    return $memberID;
}
开发者ID:alencarmo,项目名称:OCF,代码行数:101,代码来源:Subs-Members.php

示例11: obExit

 public static function obExit($header = null, $do_footer = null, $from_index = false, $from_fatal_error = false)
 {
     global $context, $modSettings;
     static $header_done = false, $footer_done = false, $level = 0, $has_fatal_error = false;
     // Attempt to prevent a recursive loop.
     ++$level;
     if ($level > 1 && !$from_fatal_error && !$has_fatal_error) {
         exit;
     }
     if ($from_fatal_error) {
         $has_fatal_error = true;
     }
     // Clear out the stat cache.
     trackStats();
     // If we have mail to send, send it.
     if (!empty($context['flush_mail'])) {
         AddMailQueue(true);
     }
     $do_header = $header === null ? !$header_done : $header;
     if ($do_footer === null) {
         $do_footer = $do_header;
     }
     // Has the template/header been done yet?
     if ($do_header) {
         // Was the page title set last minute? Also update the HTML safe one.
         if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) {
             $context['page_title_html_safe'] = $context['forum_name_html_safe'] . ' - ' . commonAPI::htmlspecialchars(un_htmlspecialchars($context['page_title']));
         }
         // Start up the session URL fixer.
         ob_start('ob_sessrewrite');
         HookAPI::integrateOB();
         //if(!empty($modSettings['simplesef_enable']))
         //	ob_start('SimpleSEF::ob_simplesef');
         // Display the screen in the logical order.
         self::template_header();
         $header_done = true;
     }
     if ($do_footer) {
         if (WIRELESS && !isset($context['sub_template'])) {
             fatal_lang_error('wireless_error_notyet', false);
         }
         self::Display();
         // Just so we don't get caught in an endless loop of errors from the footer...
         if (!$footer_done) {
             $footer_done = true;
             // (since this is just debugging... it's okay that it's after </html>.)
             if (!isset($_REQUEST['xml'])) {
                 db_debug_junk();
             }
         }
     }
     // Remember this URL in case someone doesn't like sending HTTP_REFERER.
     if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) {
         $_SESSION['old_url'] = $_SERVER['REQUEST_URL'];
     }
     // For session check verfication.... don't switch browsers...
     $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT'];
     // Hand off the output to the portal, etc. we're integrated with.
     HookAPI::callHook('integrate_exit', array($do_footer));
     if (!empty($modSettings['simplesef_enable'])) {
         SimpleSEF::fixXMLOutput($do_footer);
     }
     // Don't exit if we're coming from index.php; that will pass through normally.
     if (!$from_index) {
         exit;
     }
 }
开发者ID:norv,项目名称:EosAlpha,代码行数:67,代码来源:EosSmarty.php

示例12: smf_main

function smf_main()
{
    global $modSettings, $settings, $user_info, $board, $topic, $board_info, $maintenance, $sourcedir, $request_name, $txt, $user_settings, $mobiquo_config, $topic_per_page, $limit_num;
    // Load the user's cookie (or set as guest) and load their settings.
    loadUserSettings();
    // Load the current board's information.
    loadBoard();
    // Load the current user's permissions.
    loadPermissions();
    // Attachments don't require the entire theme to be loaded.
    loadTheme();
    header('Mobiquo_is_login:' . ($GLOBALS['context']['user']['is_logged'] ? 'true' : 'false'));
    // Check if the user should be disallowed access.
    if (!in_array($request_name, array('get_config', 'login'))) {
        is_not_banned();
    }
    // If we are in a topic and don't have permission to approve it then duck out now.
    if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) {
        //fatal_lang_error('not_a_topic', false);
        get_error('The topic is not approved');
    }
    // Do some logging, unless this is an attachment, avatar, toggle of editor buttons, theme option, XML feed etc.
    if (empty($_REQUEST['action']) || !in_array($_REQUEST['action'], array('dlattach', 'findmember', 'jseditor', 'jsoption', 'requestmembers', 'smstats', '.xml', 'xmlhttp', 'verificationcode', 'viewquery', 'viewsmfile'))) {
        // Log this user as online.
        writeLog();
        // Track forum statistics and hits...?
        if (!empty($modSettings['hitStats'])) {
            trackStats(array('hits' => '+'));
        }
    }
    // Is the forum in maintenance mode? (doesn't apply to administrators.)
    if (!empty($maintenance) && !allowedTo('admin_forum')) {
        if ($request_name != 'get_config' && $request_name != 'login') {
            get_error($txt['maintain_mode_on']);
        }
    } elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('push_content_check', 'user_subscription', 'set_api_key', 'reset_push_slug', 'prefetch_account', 'update_password', 'forget_password', 'sign_in', 'coppa', 'login', 'login2', 'register', 'register2', 'reminder', 'activate', 'help', 'smstats', 'mailq', 'verificationcode', 'openidreturn')))) {
        if ($request_name != 'get_config' && $request_name != 'prefetch_account') {
            loadLanguage('Login');
            get_error($txt['only_members_can_access']);
            //require_once($sourcedir . '/Subs-Auth.php');
            //return 'KickGuest';
        }
    }
    //-------------transform input data to local character set if needed
    utf8_to_local();
    //-------------change some setting for tapatalk display
    $settings['message_index_preview'] = 1;
    $modSettings['todayMod_bak'] = $modSettings['todayMod'];
    $modSettings['todayMod'] = 0;
    $user_settings['pm_prefs'] = 0;
    $user_info['user_time_format'] = $user_info['time_format'];
    $user_info['time_format'] = '%Y%m%dT%H:%M:%S+00:00';
    $modSettings['disableCustomPerPage'] = 1;
    $modSettings['disableCheckUA'] = 1;
    $modSettings['defaultMaxMessages'] = isset($limit_num) ? $limit_num : 20;
    $modSettings['defaultMaxMembers'] = 100;
    $modSettings['search_results_per_page'] = isset($topic_per_page) && $topic_per_page > 0 ? $topic_per_page : 20;
    $modSettings['defaultMaxTopics'] = isset($topic_per_page) && $topic_per_page > 0 ? $topic_per_page : 20;
    $modSettings['disable_pm_verification'] = $mobiquo_config['disable_pm_verification'];
    //-------------do something before action--------------
    if (function_exists('before_action_' . $request_name)) {
        call_user_func('before_action_' . $request_name);
    }
    if (empty($_REQUEST['action']) && !empty($board)) {
        if (empty($topic)) {
            require_once 'include/MessageIndex.php';
            return 'MessageIndex';
        } else {
            require_once 'include/Display.php';
            return 'Display';
        }
    }
    // Here's the monstrous $_REQUEST['action'] array - $_REQUEST['action'] => array($file, $function).
    $actionArray = array('activate' => array('Register.php', 'Activate'), 'admin' => array('Admin.php', 'AdminMain'), 'announce' => array('Post.php', 'AnnounceTopic'), 'attachapprove' => array('ManageAttachments.php', 'ApproveAttach'), 'buddy' => array('Subs-Members.php', 'BuddyListToggle'), 'calendar' => array('Calendar.php', 'CalendarMain'), 'clock' => array('Calendar.php', 'clock'), 'collapse' => array('BoardIndex.php', 'CollapseCategory'), 'coppa' => array('Register.php', 'CoppaForm'), 'credits' => array('Who.php', 'Credits'), 'deletemsg' => array('RemoveTopic.php', 'DeleteMessage'), 'display' => array('Display.php', 'Display'), 'dlattach' => array('Display.php', 'Download'), 'editpoll' => array('Poll.php', 'EditPoll'), 'editpoll2' => array('Poll.php', 'EditPoll2'), 'emailuser' => array('SendTopic.php', 'EmailUser'), 'findmember' => array('Subs-Auth.php', 'JSMembers'), 'groups' => array('Groups.php', 'Groups'), 'help' => array('Help.php', 'ShowHelp'), 'helpadmin' => array('Help.php', 'ShowAdminHelp'), 'im' => array('PersonalMessage.php', 'MessageMain'), 'jseditor' => array('Subs-Editor.php', 'EditorMain'), 'jsmodify' => array('Post.php', 'JavaScriptModify'), 'jsoption' => array('Themes.php', 'SetJavaScript'), 'lock' => array('LockTopic.php', 'LockTopic'), 'lockvoting' => array('Poll.php', 'LockVoting'), 'login' => array('LogInOut.php', 'Login'), 'login2' => array('LogInOut.php', 'Login2'), 'logout' => array('LogInOut.php', 'Logout'), 'markasread' => array('Subs-Boards.php', 'MarkRead'), 'mergetopics' => array('SplitTopics.php', 'MergeTopics'), 'mlist' => array('Memberlist.php', 'Memberlist'), 'moderate' => array('ModerationCenter.php', 'ModerationMain'), 'modifycat' => array('ManageBoards.php', 'ModifyCat'), 'modifykarma' => array('Karma.php', 'ModifyKarma'), 'movetopic' => array('MoveTopic.php', 'MoveTopic'), 'movetopic2' => array('MoveTopic.php', 'MoveTopic2'), 'notify' => array('Notify.php', 'Notify'), 'notifyboard' => array('Notify.php', 'BoardNotify'), 'openidreturn' => array('Subs-OpenID.php', 'smf_openID_return'), 'pm' => array('PersonalMessage.php', 'MessageMain'), 'post' => array('Post.php', 'Post'), 'post2' => array('Post.php', 'Post2'), 'printpage' => array('Printpage.php', 'PrintTopic'), 'profile' => array('Profile.php', 'ModifyProfile'), 'quotefast' => array('Post.php', 'QuoteFast'), 'quickmod' => array('MessageIndex.php', 'QuickModeration'), 'quickmod2' => array('Display.php', 'QuickInTopicModeration'), 'recent' => array('Recent.php', 'RecentPosts'), 'register' => array('Register.php', 'Register'), 'register2' => array('Register.php', 'Register2'), 'reminder' => array('Reminder.php', 'RemindMe'), 'removepoll' => array('Poll.php', 'RemovePoll'), 'removetopic2' => array('RemoveTopic.php', 'RemoveTopic2'), 'reporttm' => array('SendTopic.php', 'ReportToModerator'), 'requestmembers' => array('Subs-Auth.php', 'RequestMembers'), 'restoretopic' => array('RemoveTopic.php', 'RestoreTopic'), 'search' => array('Search.php', 'PlushSearch1'), 'search2' => array('Search.php', 'PlushSearch2'), 'sendtopic' => array('SendTopic.php', 'EmailUser'), 'smstats' => array('Stats.php', 'SMStats'), 'suggest' => array('Subs-Editor.php', 'AutoSuggestHandler'), 'spellcheck' => array('Subs-Post.php', 'SpellCheck'), 'splittopics' => array('SplitTopics.php', 'SplitTopics'), 'stats' => array('Stats.php', 'DisplayStats'), 'sticky' => array('LockTopic.php', 'Sticky'), 'theme' => array('Themes.php', 'ThemesMain'), 'trackip' => array('Profile-View.php', 'trackIP'), 'about:mozilla' => array('Karma.php', 'BookOfUnknown'), 'about:unknown' => array('Karma.php', 'BookOfUnknown'), 'unread' => array('Recent.php', 'UnreadTopics'), 'unreadreplies' => array('Recent.php', 'UnreadTopics'), 'verificationcode' => array('Register.php', 'VerificationCode'), 'viewprofile' => array('Profile.php', 'ModifyProfile'), 'vote' => array('Poll.php', 'Vote'), 'viewquery' => array('ViewQuery.php', 'ViewQuery'), 'viewsmfile' => array('Admin.php', 'DisplayAdminFile'), 'who' => array('Who.php', 'Who'), '.xml' => array('News.php', 'ShowXmlFeed'), 'xmlhttp' => array('Xml.php', 'XMLhttpMain'));
    // Allow modifying $actionArray easily.
    call_integration_hook('integrate_actions', array(&$actionArray));
    //error_log($request_name.'-'.$_REQUEST['action']);   //for debugging
    // Get the function and file to include - if it's not there, do the board index.
    if (!isset($_REQUEST['action']) || !isset($actionArray[$_REQUEST['action']])) {
        if (function_exists('action_' . $request_name)) {
            return 'action_' . $request_name;
        } else {
            get_error('Invalid action');
        }
    }
    $local_action = array('login2', 'post', 'post2', 'who', 'profile', 'notify', 'notifyboard', 'markasread', 'unread', 'search2', 'pm', 'logout');
    // Otherwise, it was set - so let's go to that action.
    if (in_array($_REQUEST['action'], $local_action)) {
        if (file_exists(TT_ROOT . 'include/' . $actionArray[$_REQUEST['action']][0])) {
            require_once TT_ROOT . 'include/' . $actionArray[$_REQUEST['action']][0];
        } else {
            if (file_exists($sourcedir . '/' . $actionArray[$_REQUEST['action']][0])) {
                require_once $sourcedir . '/' . $actionArray[$_REQUEST['action']][0];
            }
        }
    } else {
        if (file_exists($sourcedir . '/' . $actionArray[$_REQUEST['action']][0])) {
            require_once $sourcedir . '/' . $actionArray[$_REQUEST['action']][0];
        }
    }
//.........这里部分代码省略.........
开发者ID:keweiliu6,项目名称:test-smf2,代码行数:101,代码来源:smf_entry.php

示例13: registerMember


//.........这里部分代码省略.........
        }
    }
    // Integrate optional member settings to be set.
    if (!empty($regOptions['extra_register_vars'])) {
        foreach ($regOptions['extra_register_vars'] as $var => $value) {
            $regOptions['register_vars'][$var] = $value;
        }
    }
    // Integrate optional user theme options to be set.
    $theme_vars = array();
    if (!empty($regOptions['theme_vars'])) {
        foreach ($regOptions['theme_vars'] as $var => $value) {
            $theme_vars[$var] = $value;
        }
    }
    // Right, now let's prepare for insertion.
    $knownInts = array('date_registered', 'posts', 'id_group', 'last_login', 'personal_messages', 'unread_messages', 'notifications', 'new_pm', 'pm_prefs', 'gender', 'hide_email', 'show_online', 'pm_email_notify', 'karma_good', 'karma_bad', 'notify_announcements', 'notify_send_body', 'notify_regularity', 'notify_types', 'id_theme', 'is_activated', 'id_msg_last_visit', 'id_post_group', 'total_time_logged_in', 'warning');
    $knownFloats = array('time_offset');
    // Call an optional function to validate the users' input.
    call_integration_hook('integrate_register', array(&$regOptions, &$theme_vars, &$knownInts, &$knownFloats));
    $column_names = array();
    $values = array();
    foreach ($regOptions['register_vars'] as $var => $val) {
        $type = 'string';
        if (in_array($var, $knownInts)) {
            $type = 'int';
        } elseif (in_array($var, $knownFloats)) {
            $type = 'float';
        } elseif ($var == 'birthdate') {
            $type = 'date';
        }
        $column_names[$var] = $type;
        $values[$var] = $val;
    }
    // Register them into the database.
    $db->insert('', '{db_prefix}members', $column_names, $values, array('id_member'));
    $memberID = $db->insert_id('{db_prefix}members', 'id_member');
    // Update the number of members and latest member's info - and pass the name, but remove the 's.
    if ($regOptions['register_vars']['is_activated'] == 1) {
        updateMemberStats($memberID, $regOptions['register_vars']['real_name']);
    } else {
        updateMemberStats();
    }
    // Theme variables too?
    if (!empty($theme_vars)) {
        $inserts = array();
        foreach ($theme_vars as $var => $val) {
            $inserts[] = array($memberID, $var, $val);
        }
        $db->insert('insert', '{db_prefix}themes', array('id_member' => 'int', 'variable' => 'string-255', 'value' => 'string-65534'), $inserts, array('id_member', 'variable'));
    }
    // If it's enabled, increase the registrations for today.
    trackStats(array('registers' => '+'));
    // Administrative registrations are a bit different...
    if ($regOptions['interface'] == 'admin') {
        if ($regOptions['require'] == 'activation') {
            $email_message = 'admin_register_activate';
        } elseif (!empty($regOptions['send_welcome_email'])) {
            $email_message = 'admin_register_immediate';
        }
        if (isset($email_message)) {
            $replacements = array('REALNAME' => $regOptions['register_vars']['real_name'], 'USERNAME' => $regOptions['username'], 'PASSWORD' => $regOptions['password'], 'FORGOTPASSWORDLINK' => $scripturl . '?action=reminder', 'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $memberID . ';code=' . $validation_code, 'ACTIVATIONLINKWITHOUTCODE' => $scripturl . '?action=activate;u=' . $memberID, 'ACTIVATIONCODE' => $validation_code);
            $emaildata = loadEmailTemplate($email_message, $replacements);
            sendmail($regOptions['email'], $emaildata['subject'], $emaildata['body'], null, null, false, 0);
        }
    } else {
        // Can post straight away - welcome them to your fantastic community...
        if ($regOptions['require'] == 'nothing') {
            if (!empty($regOptions['send_welcome_email'])) {
                $replacements = array('REALNAME' => $regOptions['register_vars']['real_name'], 'USERNAME' => $regOptions['username'], 'PASSWORD' => $regOptions['password'], 'FORGOTPASSWORDLINK' => $scripturl . '?action=reminder', 'OPENID' => !empty($regOptions['openid']) ? $regOptions['openid'] : '');
                $emaildata = loadEmailTemplate('register_' . ($regOptions['auth_method'] == 'openid' ? 'openid_' : '') . 'immediate', $replacements);
                sendmail($regOptions['email'], $emaildata['subject'], $emaildata['body'], null, null, false, 0);
            }
            // Send admin their notification.
            require_once SUBSDIR . '/Notification.subs.php';
            sendAdminNotifications('standard', $memberID, $regOptions['username']);
        } elseif ($regOptions['require'] == 'activation' || $regOptions['require'] == 'coppa') {
            $replacements = array('REALNAME' => $regOptions['register_vars']['real_name'], 'USERNAME' => $regOptions['username'], 'PASSWORD' => $regOptions['password'], 'FORGOTPASSWORDLINK' => $scripturl . '?action=reminder', 'OPENID' => !empty($regOptions['openid']) ? $regOptions['openid'] : '');
            if ($regOptions['require'] == 'activation') {
                $replacements += array('ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $memberID . ';code=' . $validation_code, 'ACTIVATIONLINKWITHOUTCODE' => $scripturl . '?action=activate;u=' . $memberID, 'ACTIVATIONCODE' => $validation_code);
            } else {
                $replacements += array('COPPALINK' => $scripturl . '?action=coppa;u=' . $memberID);
            }
            $emaildata = loadEmailTemplate('register_' . ($regOptions['auth_method'] == 'openid' ? 'openid_' : '') . ($regOptions['require'] == 'activation' ? 'activate' : 'coppa'), $replacements);
            sendmail($regOptions['email'], $emaildata['subject'], $emaildata['body'], null, null, false, 0);
        } else {
            $replacements = array('REALNAME' => $regOptions['register_vars']['real_name'], 'USERNAME' => $regOptions['username'], 'PASSWORD' => $regOptions['password'], 'FORGOTPASSWORDLINK' => $scripturl . '?action=reminder', 'OPENID' => !empty($regOptions['openid']) ? $regOptions['openid'] : '');
            $emaildata = loadEmailTemplate('register_' . ($regOptions['auth_method'] == 'openid' ? 'openid_' : '') . 'pending', $replacements);
            sendmail($regOptions['email'], $emaildata['subject'], $emaildata['body'], null, null, false, 0);
            // Admin gets informed here...
            require_once SUBSDIR . '/Notification.subs.php';
            sendAdminNotifications('approval', $memberID, $regOptions['username']);
        }
        // Okay, they're for sure registered... make sure the session is aware of this for security. (Just married :P!)
        $_SESSION['just_registered'] = 1;
    }
    // If they are for sure registered, let other people to know about it
    call_integration_hook('integrate_register_after', array($regOptions, $memberID));
    return $memberID;
}
开发者ID:Ralkage,项目名称:Elkarte,代码行数:101,代码来源:Members.subs.php

示例14: createPost


//.........这里部分代码省略.........
            smf_db_query('
				UPDATE {db_prefix}attachments
				SET id_msg = {int:id_msg}
				WHERE id_attach IN ({array_int:attachment_list})', array('attachment_list' => $attachments, 'id_msg' => $msg_to_update));
        } else {
            return false;
        }
        // that should NOT happen...
    }
    // Insert a new topic (if the topicID was left empty.)
    if ($new_topic) {
        if (!isset($topicOptions['topic_prefix'])) {
            $topicOptions['topic_prefix'] = 0;
        }
        if (!isset($topicOptions['topic_layout'])) {
            $topicOptions['topic_layout'] = 0;
        }
        smf_db_insert('', '{db_prefix}topics', array('id_board' => 'int', 'id_member_started' => 'int', 'id_member_updated' => 'int', 'id_first_msg' => 'int', 'id_last_msg' => 'int', 'locked' => 'int', 'is_sticky' => 'int', 'num_views' => 'int', 'id_poll' => 'int', 'unapproved_posts' => 'int', 'approved' => 'int', 'id_prefix' => 'int', 'id_layout' => 'int'), array($topicOptions['board'], $posterOptions['id'], $posterOptions['id'], $msgOptions['id'], $msgOptions['id'], $topicOptions['lock_mode'] === null ? 0 : $topicOptions['lock_mode'], $topicOptions['sticky_mode'] === null ? 0 : $topicOptions['sticky_mode'], 0, $topicOptions['poll'] === null ? 0 : $topicOptions['poll'], $msgOptions['approved'] ? 0 : 1, $msgOptions['approved'], $topicOptions['topic_prefix'], $topicOptions['topic_layout']), array('id_topic'));
        $topicOptions['id'] = smf_db_insert_id('{db_prefix}topics', 'id_topic');
        // The topic couldn't be created for some reason.
        if (empty($topicOptions['id'])) {
            // We should delete the post that did work, though...
            smf_db_query('
				DELETE FROM {db_prefix}messages
				WHERE id_msg = {int:id_msg}', array('id_msg' => $msgOptions['id']));
            return false;
        }
        // Fix the message with the topic.
        smf_db_query('
			UPDATE {db_prefix}messages
			SET id_topic = {int:id_topic}
			WHERE id_msg = {int:id_msg}', array('id_topic' => $topicOptions['id'], 'id_msg' => $msgOptions['id']));
        // There's been a new topic AND a new post today.
        trackStats(array('topics' => '+', 'posts' => '+'));
        updateStats('topic', true);
        updateStats('subject', $topicOptions['id'], $msgOptions['subject']);
        // todo supporting code for related topics mod (should go away - the mod is not included)
        if (isset($modSettings['have_related_topics']) && $modSettings['have_related_topics']) {
            require_once $sourcedir . '/lib/Subs-Related.php';
            relatedUpdateTopics($topicOptions['id']);
        }
        // What if we want to export new topics out to a CMS?
        HookAPI::callHook('create_topic', array(&$msgOptions, &$topicOptions, &$posterOptions));
        // record the activity
        if ($modSettings['astream_active'] && !$context['no_astream']) {
            require_once $sourcedir . '/lib/Subs-Activities.php';
            aStreamAdd($posterOptions['id'], ACT_NEWTOPIC, array('member_name' => $posterOptions['real_name'], 'topic_title' => $msgOptions['subject']), $topicOptions['board'], $topicOptions['id'], $msgOptions['id'], $posterOptions['id']);
        }
    } else {
        if (false === $automerge_posts) {
            $countChange = $msgOptions['approved'] ? 'num_replies = num_replies + 1' : 'unapproved_posts = unapproved_posts + 1';
        } else {
            // the # of replies and unapproved posts does not increase if we merge
            $countChange = $msgOptions['approved'] ? 'num_replies = num_replies' : 'unapproved_posts = unapproved_posts';
        }
        // Update the number of replies and the lock/sticky status.
        smf_db_query('
			UPDATE {db_prefix}topics
			SET
				' . ($msgOptions['approved'] ? 'id_member_updated = {int:poster_id}, id_last_msg = {int:id_msg},' : '') . '
				' . $countChange . ($topicOptions['lock_mode'] === null ? '' : ',
				locked = {int:locked}') . ($topicOptions['sticky_mode'] === null ? '' : ',
				is_sticky = {int:is_sticky}') . '
			WHERE id_topic = {int:id_topic}', array('poster_id' => $posterOptions['id'], 'id_msg' => $msg_to_update, 'locked' => $topicOptions['lock_mode'], 'is_sticky' => $topicOptions['sticky_mode'], 'id_topic' => $topicOptions['id']));
        // One new post has been added today.
        if (false === $automerge_posts) {
开发者ID:norv,项目名称:EosAlpha,代码行数:67,代码来源:Subs-Post.php

示例15: trackStatsUsersOnline

/**
 * Check if the number of users online is a record and store it.
 * @param int $total_users_online
 */
function trackStatsUsersOnline($total_users_online)
{
    global $modSettings, $smcFunc;
    $settingsToUpdate = array();
    // More members on now than ever were?  Update it!
    if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) {
        $settingsToUpdate = array('mostOnline' => $total_users_online, 'mostDate' => time());
    }
    $date = strftime('%Y-%m-%d', forum_time(false));
    // No entry exists for today yet?
    if (!isset($modSettings['mostOnlineUpdated']) || $modSettings['mostOnlineUpdated'] != $date) {
        $request = $smcFunc['db_query']('', '
			SELECT most_on
			FROM {db_prefix}log_activity
			WHERE date = {date:date}
			LIMIT 1', array('date' => $date));
        // The log_activity hasn't got an entry for today?
        if ($smcFunc['db_num_rows']($request) === 0) {
            $smcFunc['db_insert']('ignore', '{db_prefix}log_activity', array('date' => 'date', 'most_on' => 'int'), array($date, $total_users_online), array('date'));
        } else {
            list($modSettings['mostOnlineToday']) = $smcFunc['db_fetch_row']($request);
            if ($total_users_online > $modSettings['mostOnlineToday']) {
                trackStats(array('most_on' => $total_users_online));
            }
            $total_users_online = max($total_users_online, $modSettings['mostOnlineToday']);
        }
        $smcFunc['db_free_result']($request);
        $settingsToUpdate['mostOnlineUpdated'] = $date;
        $settingsToUpdate['mostOnlineToday'] = $total_users_online;
    } elseif ($total_users_online > $modSettings['mostOnlineToday']) {
        trackStats(array('most_on' => $total_users_online));
        $settingsToUpdate['mostOnlineToday'] = $total_users_online;
    }
    if (!empty($settingsToUpdate)) {
        updateSettings($settingsToUpdate);
    }
}
开发者ID:Glyph13,项目名称:SMF2.1,代码行数:41,代码来源:Subs-MembersOnline.php


注:本文中的trackStats函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。