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


PHP forum_time函数代码示例

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


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

示例1: PrintTopic

function PrintTopic()
{
    global $db_prefix, $topic, $txt, $scripturl, $context;
    global $board_info;
    if (empty($topic)) {
        fatal_lang_error(472, false);
    }
    // Get the topic starter information.
    $request = db_query("\n\t\tSELECT m.posterTime, IFNULL(mem.realName, m.posterName) AS posterName\n\t\tFROM {$db_prefix}messages AS m\n\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)\n\t\tWHERE m.ID_TOPIC = {$topic}\n\t\tORDER BY ID_MSG\n\t\tLIMIT 1", __FILE__, __LINE__);
    if (mysql_num_rows($request) == 0) {
        fatal_lang_error('smf232');
    }
    $row = mysql_fetch_assoc($request);
    mysql_free_result($request);
    // Lets "output" all that info.
    loadTemplate('Printpage');
    $context['template_layers'] = array('print');
    $context['board_name'] = $board_info['name'];
    $context['category_name'] = $board_info['cat']['name'];
    $context['poster_name'] = $row['posterName'];
    $context['post_time'] = timeformat($row['posterTime'], false);
    // Split the topics up so we can print them.
    $request = db_query("\n\t\tSELECT subject, posterTime, body, IFNULL(mem.realName, posterName) AS posterName\n\t\tFROM {$db_prefix}messages AS m\n\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)\n\t\tWHERE ID_TOPIC = {$topic}\n\t\tORDER BY ID_MSG", __FILE__, __LINE__);
    $context['posts'] = array();
    while ($row = mysql_fetch_assoc($request)) {
        // Censor the subject and message.
        censorText($row['subject']);
        censorText($row['body']);
        $context['posts'][] = array('subject' => $row['subject'], 'member' => $row['posterName'], 'time' => timeformat($row['posterTime'], false), 'timestamp' => forum_time(true, $row['posterTime']), 'body' => parse_bbc($row['body'], 'print'));
        if (!isset($context['topic_subject'])) {
            $context['topic_subject'] = $row['subject'];
        }
    }
    mysql_free_result($request);
}
开发者ID:VBGAMER45,项目名称:SMFMods,代码行数:35,代码来源:Printpage.php

示例2: getMemberNotices

    public function getMemberNotices($id_member, $groups)
    {
        $request = $this->_db->query('', '
			SELECT n.id_notice, n.body, n.class, n.expire, n.show_to, n.positioning
			FROM {db_prefix}notices AS n
				LEFT JOIN {db_prefix}log_notices AS ln ON (ln.id_notice = n.id_notice AND ln.id_member = {int:current_member})
			WHERE ln.dismissed IS NULL
				AND (n.expire = 0 OR n.expire > {int:time})', array('current_member' => $id_member, 'time' => forum_time(false)));
        $notices = array();
        while ($row = $this->_db->fetch_assoc($request)) {
            $show = (array) json_decode($row['show_to']);
            foreach ($groups as $group) {
                if (in_array($group, $show)) {
                    if (empty($id_member) && !empty($_SESSION['dismissible_notices'][$row['id_notice']])) {
                        continue;
                    }
                    $row['positioning'] = (array) json_decode($row['positioning']);
                    if (empty($row['positioning']['element'])) {
                        $row['positioning']['element'] = 'global';
                    }
                    if (empty($row['positioning']['position'])) {
                        $row['positioning']['position'] = 0;
                    }
                    if (empty($row['positioning']['element_name'])) {
                        $row['positioning']['element_name'] = '';
                    }
                    $row['body'] = parse_bbc($row['body']);
                    $notices[] = $row;
                    break;
                }
            }
        }
        $this->_db->free_result($request);
        return $notices;
    }
开发者ID:emanuele45,项目名称:DismissibleNotices,代码行数:35,代码来源:DismissibleNotices.class.php

示例3: getErrorLogData

/**
 * Gets data from the error log
 *
 * @param int $start
 * @param string $sort_direction
 * @param mixed[]|null $filter
 */
function getErrorLogData($start, $sort_direction = 'DESC', $filter = null)
{
    global $modSettings, $scripturl, $txt;
    $db = database();
    // Find and sort out the errors.
    $request = $db->query('', '
		SELECT id_error, id_member, ip, url, log_time, message, session, error_type, file, line
		FROM {db_prefix}log_errors' . (isset($filter) ? '
		WHERE ' . $filter['variable'] . ' LIKE {string:filter}' : '') . '
		ORDER BY id_error ' . ($sort_direction == 'down' ? 'DESC' : '') . '
		LIMIT ' . $start . ', ' . $modSettings['defaultMaxMessages'], array('filter' => isset($filter) ? $filter['value']['sql'] : ''));
    $log = array();
    for ($i = 0; $row = $db->fetch_assoc($request); $i++) {
        $search_message = preg_replace('~<span class="remove">(.+?)</span>~', '%', $db->escape_wildcard_string($row['message']));
        if ($search_message == $filter['value']['sql']) {
            $search_message = $db->escape_wildcard_string($row['message']);
        }
        $show_message = strtr(strtr(preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '$1', $row['message']), array("\r" => '', '<br />' => "\n", '<' => '&lt;', '>' => '&gt;', '"' => '&quot;')), array("\n" => '<br />'));
        $log['errors'][$row['id_error']] = array('alternate' => $i % 2 == 0, 'member' => array('id' => $row['id_member'], 'ip' => $row['ip'], 'session' => $row['session']), 'time' => standardTime($row['log_time']), 'html_time' => htmlTime($row['log_time']), 'timestamp' => forum_time(true, $row['log_time']), 'url' => array('html' => htmlspecialchars((substr($row['url'], 0, 1) == '?' ? $scripturl : '') . $row['url'], ENT_COMPAT, 'UTF-8'), 'href' => base64_encode($db->escape_wildcard_string($row['url']))), 'message' => array('html' => $show_message, 'href' => base64_encode($search_message)), 'id' => $row['id_error'], 'error_type' => array('type' => $row['error_type'], 'name' => isset($txt['errortype_' . $row['error_type']]) ? $txt['errortype_' . $row['error_type']] : $row['error_type']), 'file' => array());
        if (!empty($row['file']) && !empty($row['line'])) {
            // Eval'd files rarely point to the right location and cause havoc for linking, so don't link them.
            $linkfile = strpos($row['file'], 'eval') === false || strpos($row['file'], '?') === false;
            // De Morgan's Law.  Want this true unless both are present.
            $log['errors'][$row['id_error']]['file'] = array('file' => $row['file'], 'line' => $row['line'], 'href' => $scripturl . '?action=admin;area=logs;sa=errorlog;activity=file;file=' . base64_encode($row['file']) . ';line=' . $row['line'], 'link' => $linkfile ? '<a href="' . $scripturl . '?action=admin;area=logs;sa=errorlog;activity=file;file=' . base64_encode($row['file']) . ';line=' . $row['line'] . '" onclick="return reqWin(this.href, 600, 480, false);">' . $row['file'] . '</a>' : $row['file'], 'search' => base64_encode($row['file']));
        }
        // Make a list of members to load later.
        $log['members'][$row['id_member']] = $row['id_member'];
    }
    $db->free_result($request);
    return $log;
}
开发者ID:KeiroD,项目名称:Elkarte,代码行数:38,代码来源:Error.subs.php

示例4: PrintTopic

function PrintTopic()
{
    global $topic, $txt, $scripturl, $context, $user_info;
    global $board_info, $smcFunc, $modSettings;
    // Redirect to the boardindex if no valid topic id is provided.
    if (empty($topic)) {
        redirectexit();
    }
    // Whatever happens don't index this.
    $context['robot_no_index'] = true;
    // Get the topic starter information.
    $request = $smcFunc['db_query']('', '
		SELECT m.poster_time, IFNULL(mem.real_name, m.poster_name) AS poster_name
		FROM {db_prefix}messages AS m
			LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
		WHERE m.id_topic = {int:current_topic}
		ORDER BY m.id_msg
		LIMIT 1', array('current_topic' => $topic));
    // Redirect to the boardindex if no valid topic id is provided.
    if ($smcFunc['db_num_rows']($request) == 0) {
        redirectexit();
    }
    $row = $smcFunc['db_fetch_assoc']($request);
    $smcFunc['db_free_result']($request);
    // Lets "output" all that info.
    loadTemplate('Printpage');
    $context['template_layers'] = array('print');
    $context['board_name'] = $board_info['name'];
    $context['category_name'] = $board_info['cat']['name'];
    $context['poster_name'] = $row['poster_name'];
    $context['post_time'] = timeformat($row['poster_time'], false);
    $context['parent_boards'] = array();
    foreach ($board_info['parent_boards'] as $parent) {
        $context['parent_boards'][] = $parent['name'];
    }
    // Split the topics up so we can print them.
    $request = $smcFunc['db_query']('', '
		SELECT subject, poster_time, body, IFNULL(mem.real_name, poster_name) AS poster_name
		FROM {db_prefix}messages AS m
			LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
		WHERE m.id_topic = {int:current_topic}' . ($modSettings['postmod_active'] && !allowedTo('approve_posts') ? '
			AND (m.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR m.id_member = {int:current_member}') . ')' : '') . '
		ORDER BY m.id_msg', array('current_topic' => $topic, 'is_approved' => 1, 'current_member' => $user_info['id']));
    $context['posts'] = array();
    while ($row = $smcFunc['db_fetch_assoc']($request)) {
        // Censor the subject and message.
        censorText($row['subject']);
        censorText($row['body']);
        $context['posts'][] = array('subject' => $row['subject'], 'member' => $row['poster_name'], 'time' => timeformat($row['poster_time'], false), 'timestamp' => forum_time(true, $row['poster_time']), 'body' => parse_bbc($row['body'], 'print'));
        if (!isset($context['topic_subject'])) {
            $context['topic_subject'] = $row['subject'];
        }
    }
    $smcFunc['db_free_result']($request);
    // Set a canonical URL for this page.
    $context['canonical_url'] = $scripturl . '?topic=' . $topic . '.0';
}
开发者ID:abdulhadikaryana,项目名称:kebudayaan,代码行数:57,代码来源:Printpage.php

示例5: formatExpireCol

 public static function formatExpireCol($time)
 {
     if ($time == 0) {
         return '<i class="fa fa-check success"></i>';
     } elseif ($time > forum_time(false)) {
         return standardTime($time) . ' <i class="fa fa-clock-o success"></i>';
     } else {
         return '<i class="fa fa-times-circle-o  error"></i>';
     }
 }
开发者ID:emanuele45,项目名称:DismissibleNotices,代码行数:10,代码来源:DismissibleNotices.integrate.php

示例6: getLastPosts

function getLastPosts($latestPostOptions)
{
    global $scripturl, $txt, $user_info, $modSettings, $smcFunc, $context;
    // Find all the posts.  Newer ones will have higher IDs.  (assuming the last 20 * number are accessable...)
    // !!!SLOW This query is now slow, NEEDS to be fixed.  Maybe break into two?
    $request = $smcFunc['db_query']('substring', '
		SELECT
			m.poster_time, m.subject, m.id_topic, m.id_member, m.id_msg,
			IFNULL(mem.real_name, m.poster_name) AS poster_name, t.id_board, b.name AS board_name,
			SUBSTRING(m.body, 1, 385) AS body, m.smileys_enabled
		FROM {db_prefix}messages AS m
			INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
			INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
			LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
		WHERE m.id_msg >= {int:likely_max_msg}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
			AND b.id_board != {int:recycle_board}' : '') . '
			AND {query_wanna_see_board}' . ($modSettings['postmod_active'] ? '
			AND t.approved = {int:is_approved}
			AND m.approved = {int:is_approved}' : '') . '
		ORDER BY m.id_msg DESC
		LIMIT ' . $latestPostOptions['number_posts'], array('likely_max_msg' => max(0, $modSettings['maxMsgID'] - 50 * $latestPostOptions['number_posts']), 'recycle_board' => $modSettings['recycle_board'], 'is_approved' => 1));
    $posts = array();
    $context['MemberColor_ID_MEMBER'] = array();
    while ($row = $smcFunc['db_fetch_assoc']($request)) {
        // Censor the subject and post for the preview ;).
        censorText($row['subject']);
        censorText($row['body']);
        $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br />' => '&#10;')));
        if ($smcFunc['strlen']($row['body']) > 128) {
            $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
        }
        // Build the array.
        $posts[] = array('board' => array('id' => $row['id_board'], 'name' => $row['board_name'], 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['board_name'] . '</a>'), 'topic' => $row['id_topic'], 'poster' => array('id' => $row['id_member'], 'name' => $row['poster_name'], 'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'], 'link' => empty($row['id_member']) ? (!empty($modSettings['MemberColorGuests']) ? '<span style="color:' . $modSettings['MemberColorGuests'] . ';">' : '') . $row['poster_name'] . (!empty($modSettings['MemberColorGuests']) ? '</span>' : '') : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" title="' . $txt['profile_of'] . ' ' . $row['poster_name'] . '">' . $row['poster_name'] . '</a>'), 'subject' => $row['subject'], 'short_subject' => shorten_subject($row['subject'], 24), 'preview' => $row['body'], 'time' => timeformat($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time']), 'raw_timestamp' => $row['poster_time'], 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#msg' . $row['id_msg'], 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#msg' . $row['id_msg'] . '" rel="nofollow">' . $row['subject'] . '</a>');
        //The Last Posters id for the MemberColor.
        if (!empty($modSettings['MemberColorRecentLastPost']) && !empty($row['id_member'])) {
            $context['MemberColor_ID_MEMBER'][$row['id_member']] = $row['id_member'];
        }
    }
    $smcFunc['db_free_result']($request);
    // Know set the colors for the Recent posts...
    if (!empty($context['MemberColor_ID_MEMBER'])) {
        $colorDatas = load_onlineColors($context['MemberColor_ID_MEMBER']);
        //So Let's Color The Recent Posts ;)
        if (!empty($modSettings['MemberColorRecentLastPost']) && is_array($posts)) {
            foreach ($posts as $postkey => $postid_memcolor) {
                if (!empty($colorDatas[$postid_memcolor['poster']['id']]['colored_link'])) {
                    $posts[$postkey]['poster']['link'] = $colorDatas[$postid_memcolor['poster']['id']]['colored_link'];
                }
            }
        }
    }
    return $posts;
}
开发者ID:Kheros,项目名称:MMOver,代码行数:53,代码来源:Subs-Recent.php

示例7: getLastPosts

function getLastPosts($latestPostOptions)
{
    global $scripturl, $txt, $user_info, $modSettings, $smcFunc, $context;
    // Find all the posts.  Newer ones will have higher IDs.  (assuming the last 20 * number are accessable...)
    // !!!SLOW This query is now slow, NEEDS to be fixed.  Maybe break into two?
    $request = smf_db_query('
		SELECT
			m.poster_time, m.subject, m.id_topic, m.id_member, m.id_msg, b.name, m1.subject AS first_subject,
			IFNULL(mem.real_name, m.poster_name) AS poster_name, t.id_board, b.name AS board_name,
			SUBSTRING(m.body, 1, 385) AS body, m.smileys_enabled
		FROM {db_prefix}messages AS m
			INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
			INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
			INNER JOIN {db_prefix}messages AS m1 ON (m1.id_msg = t.id_first_msg)
			LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
		WHERE m.id_msg >= {int:likely_max_msg}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
			AND b.id_board != {int:recycle_board}' : '') . '
			AND {query_wanna_see_board}' . ($modSettings['postmod_active'] ? '
			AND t.approved = {int:is_approved}
			AND m.approved = {int:is_approved}' : '') . '
		ORDER BY m.id_msg DESC
		LIMIT ' . $latestPostOptions['number_posts'], array('likely_max_msg' => max(0, $modSettings['maxMsgID'] - 50 * $latestPostOptions['number_posts']), 'recycle_board' => $modSettings['recycle_board'], 'is_approved' => 1));
    $posts = array();
    while ($row = mysql_fetch_assoc($request)) {
        // Censor the subject and post for the preview ;).
        censorText($row['subject']);
        censorText($row['body']);
        $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br />' => '&#10;')));
        if (commonAPI::strlen($row['body']) > 128) {
            $row['body'] = commonAPI::substr($row['body'], 0, 128) . '...';
        }
        $bhref = URL::board($row['id_board'], $row['board_name'], 0, true);
        $mhref = URL::user($row['id_member'], $row['poster_name']);
        $thref = URL::topic($row['id_topic'], $row['first_subject'], 0, false, '.msg' . $row['id_msg'], ';topicseen#msg' . $row['id_msg']);
        // Build the array.
        $posts[] = array('board' => array('id' => $row['id_board'], 'name' => $row['board_name'], 'href' => $bhref, 'link' => '<a href="' . $bhref . '">' . $row['board_name'] . '</a>'), 'topic' => $row['id_topic'], 'poster' => array('id' => $row['id_member'], 'name' => $row['poster_name'], 'href' => empty($row['id_member']) ? '' : $mhref, 'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $mhref . '">' . $row['poster_name'] . '</a>'), 'subject' => $row['subject'], 'short_subject' => shorten_subject($row['subject'], 35), 'preview' => $row['body'], 'time' => timeformat($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time']), 'raw_timestamp' => $row['poster_time'], 'href' => $thref, 'link' => '<a href="' . $thref . '" rel="nofollow">' . $row['first_subject'] . '</a>');
    }
    mysql_free_result($request);
    return $posts;
}
开发者ID:norv,项目名称:EosAlpha,代码行数:40,代码来源:Subs-Recent.php

示例8: CalendarMain

function CalendarMain()
{
    global $txt, $context, $modSettings, $scripturl, $options;
    // If we are posting a new event defect to the posting function.
    if (isset($_GET['sa']) && $_GET['sa'] == 'post') {
        return CalendarPost();
    }
    // This is gonna be needed...
    loadTemplate('Calendar');
    // Permissions, permissions, permissions.
    isAllowedTo('calendar_view');
    // You can't do anything if the calendar is off.
    if (empty($modSettings['cal_enabled'])) {
        fatal_lang_error('calendar_off', false);
    }
    // Set the page title to mention the calendar ;).
    $context['page_title'] = $context['forum_name'] . ': ' . $txt['calendar24'];
    // Get the current day of month...
    $today = array('day' => (int) strftime('%d', forum_time()), 'month' => (int) strftime('%m', forum_time()), 'year' => (int) strftime('%Y', forum_time()));
    $today['date'] = sprintf('%04d-%02d-%02d', $today['year'], $today['month'], $today['day']);
    // If the month and year are not passed in, use today's date as a starting point.
    $curPage = array('month' => isset($_REQUEST['month']) ? (int) $_REQUEST['month'] : $today['month'], 'year' => isset($_REQUEST['year']) ? (int) $_REQUEST['year'] : $today['year']);
    // Make sure the year and month are in valid ranges.
    if ($curPage['month'] < 1 || $curPage['month'] > 12) {
        fatal_lang_error('calendar1', false);
    }
    if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) {
        fatal_lang_error('calendar2', false);
    }
    // Get information about the first day of this month.
    $firstDayOfMonth = array('dayOfWeek' => (int) strftime('%w', mktime(0, 0, 0, $curPage['month'], 1, $curPage['year'])), 'weekNum' => (int) strftime('%U', mktime(0, 0, 0, $curPage['month'], 1, $curPage['year'])));
    // Find the last day of the month.
    $nLastDay = (int) strftime('%d', mktime(0, 0, 0, $curPage['month'] == 12 ? 1 : $curPage['month'] + 1, 0, $curPage['month'] == 12 ? $curPage['year'] + 1 : $curPage['year']));
    // The number of days the first row is shifted to the right for the starting day.
    $nShift = $firstDayOfMonth['dayOfWeek'];
    // Calendar start day- default Sunday.
    $nStartDay = !empty($options['calendar_start_day']) ? $options['calendar_start_day'] : 0;
    // Starting any day other than Sunday means a shift...
    if ($nStartDay) {
        $nShift -= $nStartDay;
        if ($nShift < 0) {
            $nShift = 7 + $nShift;
        }
    }
    // Number of rows required to fit the month.
    $nRows = floor(($nLastDay + $nShift) / 7);
    if (($nLastDay + $nShift) % 7) {
        $nRows++;
    }
    // Get the lowest and highest days of this month, in YYYY-MM-DD format. ($nLastDay is always 2 digits.)
    $low = $curPage['year'] . '-' . sprintf('%02d', $curPage['month']) . '-01';
    $high = $curPage['year'] . '-' . sprintf('%02d', $curPage['month']) . '-' . $nLastDay;
    // Fetch the arrays for birthdays, posted events, and holidays.
    $bday = !empty($modSettings['cal_showbdaysoncalendar']) ? calendarBirthdayArray($low, $high) : array();
    $events = !empty($modSettings['cal_showeventsoncalendar']) ? calendarEventArray($low, $high) : array();
    $holidays = !empty($modSettings['cal_showholidaysoncalendar']) ? calendarHolidayArray($low, $high) : array();
    // Days of the week taking into consideration that they may want it to start on any day.
    $context['week_days'] = array();
    $count = $nStartDay;
    for ($i = 0; $i < 7; $i++) {
        $context['week_days'][] = $count;
        $count++;
        if ($count == 7) {
            $count = 0;
        }
    }
    // An adjustment value to apply to all calculated week numbers.
    if (!empty($modSettings['cal_showweeknum'])) {
        // Need to know what day the first of the year was on.
        $foy = (int) strftime('%w', mktime(0, 0, 0, 1, 1, $curPage['year']));
        // If the first day of the year is a Sunday, then there is no adjustment
        // to be made. However, if the first day of the year is not a Sunday, then there is a partial
        // week at the start of the year that needs to be accounted for.
        if ($nStartDay == 0) {
            $nWeekAdjust = $foy == 0 ? 0 : 1;
        } else {
            $nWeekAdjust = $nStartDay > $foy && $foy != 0 ? 2 : 1;
        }
        // If our week starts on a day greater than the day the month starts on, then our week numbers will be one too high.
        // So we need to reduce it by one - all these thoughts of offsets makes my head hurt...
        if ($firstDayOfMonth['dayOfWeek'] < $nStartDay) {
            $nWeekAdjust--;
        }
    } else {
        $nWeekAdjust = 0;
    }
    // Basic template stuff.
    $context['can_post'] = allowedTo('calendar_post');
    $context['last_day'] = $nLastDay;
    $context['current_month'] = $curPage['month'];
    $context['current_year'] = $curPage['year'];
    // Load up the linktree!
    $context['linktree'][] = array('url' => $scripturl . '?action=calendar;year=' . $context['current_year'] . ';month=' . $context['current_month'], 'name' => $txt['months'][$context['current_month']] . ' ' . $context['current_year']);
    // Iterate through each week.
    $context['weeks'] = array();
    for ($nRow = 0; $nRow < $nRows; $nRow++) {
        // Start off the week - and don't let it go above 52, since that's the number of weeks in a year.
        $context['weeks'][$nRow] = array('days' => array(), 'number' => $firstDayOfMonth['weekNum'] + $nRow + $nWeekAdjust);
        // Handle the dreaded "week 53", it can happen, but only once in a blue moon ;)
        if ($context['weeks'][$nRow]['number'] == 53 && $nShift != 4) {
//.........这里部分代码省略.........
开发者ID:VBGAMER45,项目名称:SMFMods,代码行数:101,代码来源:Calendar.php

示例9: messagePostError

/**
 * An error in the message...
 *
 * @param $error_types
 * @param $named_recipients
 * @param $recipient_ids
 */
function messagePostError($error_types, $named_recipients, $recipient_ids = array())
{
    global $txt, $context, $scripturl, $modSettings;
    global $smcFunc, $user_info, $sourcedir;
    if (!isset($_REQUEST['xml'])) {
        $context['menu_data_' . $context['pm_menu_id']]['current_area'] = 'send';
    }
    if (!WIRELESS && !isset($_REQUEST['xml'])) {
        $context['sub_template'] = 'send';
    } elseif (isset($_REQUEST['xml'])) {
        $context['sub_template'] = 'pm';
    }
    $context['page_title'] = $txt['send_message'];
    // Got some known members?
    $context['recipients'] = array('to' => array(), 'bcc' => array());
    if (!empty($recipient_ids['to']) || !empty($recipient_ids['bcc'])) {
        $allRecipients = array_merge($recipient_ids['to'], $recipient_ids['bcc']);
        $request = $smcFunc['db_query']('', '
			SELECT id_member, real_name
			FROM {db_prefix}members
			WHERE id_member IN ({array_int:member_list})', array('member_list' => $allRecipients));
        while ($row = $smcFunc['db_fetch_assoc']($request)) {
            $recipientType = in_array($row['id_member'], $recipient_ids['bcc']) ? 'bcc' : 'to';
            $context['recipients'][$recipientType][] = array('id' => $row['id_member'], 'name' => $row['real_name']);
        }
        $smcFunc['db_free_result']($request);
    }
    // Set everything up like before....
    $context['subject'] = isset($_REQUEST['subject']) ? $smcFunc['htmlspecialchars']($_REQUEST['subject']) : '';
    $context['message'] = isset($_REQUEST['message']) ? str_replace(array('  '), array('&nbsp; '), $smcFunc['htmlspecialchars']($_REQUEST['message'])) : '';
    $context['copy_to_outbox'] = !empty($_REQUEST['outbox']);
    $context['reply'] = !empty($_REQUEST['replied_to']);
    if ($context['reply']) {
        $_REQUEST['replied_to'] = (int) $_REQUEST['replied_to'];
        $request = $smcFunc['db_query']('', '
			SELECT
				pm.id_pm, CASE WHEN pm.id_pm_head = {int:no_id_pm_head} THEN pm.id_pm ELSE pm.id_pm_head END AS pm_head,
				pm.body, pm.subject, pm.msgtime, mem.member_name, IFNULL(mem.id_member, 0) AS id_member,
				IFNULL(mem.real_name, pm.from_name) AS real_name
			FROM {db_prefix}personal_messages AS pm' . ($context['folder'] == 'sent' ? '' : '
				INNER JOIN {db_prefix}pm_recipients AS pmr ON (pmr.id_pm = {int:replied_to})') . '
				LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = pm.id_member_from)
			WHERE pm.id_pm = {int:replied_to}' . ($context['folder'] == 'sent' ? '
				AND pm.id_member_from = {int:current_member}' : '
				AND pmr.id_member = {int:current_member}') . '
			LIMIT 1', array('current_member' => $user_info['id'], 'no_id_pm_head' => 0, 'replied_to' => $_REQUEST['replied_to']));
        if ($smcFunc['db_num_rows']($request) == 0) {
            if (!isset($_REQUEST['xml'])) {
                fatal_lang_error('pm_not_yours', false);
            } else {
                $error_types[] = 'pm_not_yours';
            }
        }
        $row_quoted = $smcFunc['db_fetch_assoc']($request);
        $smcFunc['db_free_result']($request);
        censorText($row_quoted['subject']);
        censorText($row_quoted['body']);
        $context['quoted_message'] = array('id' => $row_quoted['id_pm'], 'pm_head' => $row_quoted['pm_head'], 'member' => array('name' => $row_quoted['real_name'], 'username' => $row_quoted['member_name'], 'id' => $row_quoted['id_member'], 'href' => !empty($row_quoted['id_member']) ? $scripturl . '?action=profile;u=' . $row_quoted['id_member'] : '', 'link' => !empty($row_quoted['id_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row_quoted['id_member'] . '">' . $row_quoted['real_name'] . '</a>' : $row_quoted['real_name']), 'subject' => $row_quoted['subject'], 'time' => timeformat($row_quoted['msgtime']), 'timestamp' => forum_time(true, $row_quoted['msgtime']), 'body' => parse_bbc($row_quoted['body'], true, 'pm' . $row_quoted['id_pm']));
    }
    // Build the link tree....
    $context['linktree'][] = array('url' => $scripturl . '?action=pm;sa=send', 'name' => $txt['new_message']);
    // Set each of the errors for the template.
    loadLanguage('Errors');
    $context['error_type'] = 'minor';
    $context['post_error'] = array('messages' => array(), 'error_type' => '');
    foreach ($error_types as $error_type) {
        $context['post_error'][$error_type] = true;
        if (isset($txt['error_' . $error_type])) {
            if ($error_type == 'long_message') {
                $txt['error_' . $error_type] = sprintf($txt['error_' . $error_type], $modSettings['max_messageLength']);
            }
            $context['post_error']['messages'][] = $txt['error_' . $error_type];
        }
        // If it's not a minor error flag it as such.
        if (!in_array($error_type, array('new_reply', 'not_approved', 'new_replies', 'old_topic', 'need_qr_verification', 'no_subject'))) {
            $context['error_type'] = 'serious';
        }
    }
    // Need to reset draft capability once again
    $context['drafts_pm_save'] = !empty($modSettings['drafts_pm_enabled']) && allowedTo('pm_draft');
    $context['drafts_autosave'] = !empty($context['drafts_pm_save']) && !empty($modSettings['drafts_autosave_enabled']) && allowedTo('pm_autosave_draft');
    // We need to load the editor once more.
    require_once $sourcedir . '/Subs-Editor.php';
    // Create it...
    $editorOptions = array('id' => 'message', 'value' => $context['message'], 'width' => '90%', 'labels' => array('post_button' => $txt['send_message']), 'preview_type' => 2);
    create_control_richedit($editorOptions);
    // ... and store the ID again...
    $context['post_box_name'] = $editorOptions['id'];
    // Check whether we need to show the code again.
    $context['require_verification'] = !$user_info['is_admin'] && !empty($modSettings['pm_posts_verification']) && $user_info['posts'] < $modSettings['pm_posts_verification'];
    if ($context['require_verification'] && !isset($_REQUEST['xml'])) {
        require_once $sourcedir . '/Subs-Editor.php';
        $verificationOptions = array('id' => 'pm');
//.........这里部分代码省略.........
开发者ID:Glyph13,项目名称:SMF2.1,代码行数:101,代码来源:PersonalMessage.php

示例10: Who

function Who()
{
    global $db_prefix, $context, $scripturl, $user_info, $txt, $modSettings, $ID_MEMBER, $memberContext;
    // Permissions, permissions, permissions.
    isAllowedTo('who_view');
    // You can't do anything if this is off.
    if (empty($modSettings['who_enabled'])) {
        fatal_lang_error('who_off', false);
    }
    // Load the 'Who' template.
    loadTemplate('Who');
    // Sort out... the column sorting.
    $sort_methods = array('user' => 'mem.realName', 'time' => 'lo.logTime');
    // By default order by last time online.
    if (!isset($_REQUEST['sort']) || !isset($sort_methods[$_REQUEST['sort']])) {
        $context['sort_by'] = 'time';
        $_REQUEST['sort'] = 'lo.logTime';
    } else {
        $context['sort_by'] = $_REQUEST['sort'];
        $_REQUEST['sort'] = $sort_methods[$_REQUEST['sort']];
    }
    $context['sort_direction'] = isset($_REQUEST['asc']) ? 'up' : 'down';
    // Get the total amount of members online.
    $request = db_query("\n\t\tSELECT COUNT(*)\n\t\tFROM {$db_prefix}log_online AS lo\n\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (lo.ID_MEMBER = mem.ID_MEMBER)" . (!allowedTo('moderate_forum') ? "\n\t\tWHERE IFNULL(mem.showOnline, 1) = 1" : ''), __FILE__, __LINE__);
    list($totalMembers) = mysql_fetch_row($request);
    mysql_free_result($request);
    // Prepare some page index variables.
    $context['page_index'] = constructPageIndex($scripturl . '?action=who;sort=' . $context['sort_by'] . (isset($_REQUEST['asc']) ? ';asc' : ''), $_REQUEST['start'], $totalMembers, $modSettings['defaultMaxMembers']);
    $context['start'] = $_REQUEST['start'];
    // Look for people online, provided they don't mind if you see they are.
    $request = db_query("\n\t\tSELECT\n\t\t\t(UNIX_TIMESTAMP(lo.logTime) - UNIX_TIMESTAMP() + " . time() . ") AS logTime,\n\t\t\tlo.ID_MEMBER, lo.url, INET_NTOA(lo.ip) AS ip, mem.realName, lo.session,\n\t\t\tmg.onlineColor, IFNULL(mem.showOnline, 1) AS showOnline\n\t\tFROM {$db_prefix}log_online AS lo\n\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (lo.ID_MEMBER = mem.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))" . (!allowedTo('moderate_forum') ? "\n\t\tWHERE IFNULL(mem.showOnline, 1) = 1" : '') . "\n\t\tORDER BY {$_REQUEST['sort']} " . (isset($_REQUEST['asc']) ? 'ASC' : 'DESC') . "\n\t\tLIMIT {$context['start']}, {$modSettings['defaultMaxMembers']}", __FILE__, __LINE__);
    $context['members'] = array();
    $member_ids = array();
    $url_data = array();
    while ($row = mysql_fetch_assoc($request)) {
        $actions = @unserialize($row['url']);
        if ($actions === false) {
            continue;
        }
        // Send the information to the template.
        $context['members'][$row['session']] = array('id' => $row['ID_MEMBER'], 'ip' => allowedTo('moderate_forum') ? $row['ip'] : '', 'time' => strtr(timeformat($row['logTime']), array($txt['smf10'] => '', $txt['smf10b'] => '')), 'timestamp' => forum_time(true, $row['logTime']), 'query' => $actions, 'is_hidden' => $row['showOnline'] == 0, 'color' => empty($row['onlineColor']) ? '' : $row['onlineColor']);
        $url_data[$row['session']] = array($row['url'], $row['ID_MEMBER']);
        $member_ids[] = $row['ID_MEMBER'];
    }
    mysql_free_result($request);
    // Load the user data for these members.
    loadMemberData($member_ids);
    // Load up the guest user.
    $memberContext[0] = array('id' => 0, 'name' => $txt[28], 'group' => $txt[28], 'href' => '', 'link' => $txt[28], 'email' => $txt[28], 'is_guest' => true);
    $url_data = determineActions($url_data);
    // Setup the linktree and page title (do it down here because the language files are now loaded..)
    $context['page_title'] = $txt['who_title'];
    $context['linktree'][] = array('url' => $scripturl . '?action=who', 'name' => $txt['who_title']);
    // Put it in the context variables.
    foreach ($context['members'] as $i => $member) {
        if ($member['id'] != 0) {
            $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0;
        }
        // Keep the IP that came from the database.
        $memberContext[$member['id']]['ip'] = $member['ip'];
        $context['members'][$i]['action'] = isset($url_data[$i]) ? $url_data[$i] : $txt['who_hidden'];
        $context['members'][$i] += $memberContext[$member['id']];
    }
    // Some people can't send personal messages...
    $context['can_send_pm'] = allowedTo('pm_send');
}
开发者ID:VBGAMER45,项目名称:SMFMods,代码行数:66,代码来源:Who.php

示例11: pmxc_InitContent

 /**
  * InitContent.
  * Checks the cache status and create the content.
  */
 function pmxc_InitContent()
 {
     global $sourcedir, $pmxCacheFunc, $options;
     // if visible init the content
     if ($this->visible) {
         $this->today = array('day' => (int) strftime('%d', forum_time()), 'month' => (int) strftime('%m', forum_time()), 'year' => (int) strftime('%Y', forum_time()), 'date' => strftime('%Y-%m-%d', forum_time()));
         $this->cal_startday = isset($options['calendar_start_day']) ? $options['calendar_start_day'] : $this->cfg['config']['settings']['firstday'];
         $this->cache_key .= '-' . $this->cal_startday;
         $cachedata = null;
         if (!empty($this->cfg['cache'])) {
             if (($cachedata = $pmxCacheFunc['get']($this->cache_key, $this->cache_mode)) !== null) {
                 list($curday, $this->calgrid, $this->calbirthdays, $this->calholidays, $this->calevents) = $cachedata;
                 if ($curday != $this->today['date']) {
                     $pmxCacheFunc['clear']($this->cache_key, $this->cache_mode);
                     $cachedata = null;
                 }
             }
         }
         if (empty($cachedata)) {
             include_once $sourcedir . '/Subs-Calendar.php';
             $calendarOptions = array('start_day' => $this->cal_startday, 'show_birthdays' => false, 'show_events' => false, 'show_holidays' => false, 'show_week_num' => false, 'short_day_titles' => true, 'show_next_prev' => false, 'show_week_links' => false, 'size' => 'small');
             $this->calgrid = getCalendarGrid($this->today['month'], $this->today['year'], $calendarOptions);
             $this->calbirthdays = array();
             if (!empty($this->cfg['config']['settings']['birthdays']['show'])) {
                 $start_data = isset($this->cfg['config']['settings']['birthdays']['before']) ? date('Y-m-d', time() - 86400 * intval($this->cfg['config']['settings']['birthdays']['after'])) : date('Y-m-d');
                 $end_data = isset($this->cfg['config']['settings']['birthdays']['after']) ? date('Y-m-d', time() + 86400 * intval($this->cfg['config']['settings']['birthdays']['before'])) : date('Y-m-d');
                 $temp = getBirthdayRange($start_data, $end_data);
                 foreach ($temp as $key => $val) {
                     $mnt = intval(substr($key, 5, 2));
                     if (in_array($mnt, array(11, 12)) && in_array($this->today['month'], array(1, 12))) {
                         $nkey = strval($this->today['year'] - 1) . substr($key, 4);
                     } else {
                         $nkey = strval($this->today['year']) . substr($key, 4);
                     }
                     $this->calbirthdays[$nkey] = $val;
                 }
                 ksort($this->calbirthdays);
             }
             $this->calholidays = array();
             if (!empty($this->cfg['config']['settings']['holidays']['show'])) {
                 $start_data = isset($this->cfg['config']['settings']['holidays']['before']) ? date('Y-m-d', time() - 86400 * intval($this->cfg['config']['settings']['holidays']['after'])) : date('Y-m-d');
                 $end_data = isset($this->cfg['config']['settings']['holidays']['after']) ? date('Y-m-d', time() + 86400 * intval($this->cfg['config']['settings']['holidays']['before'])) : date('Y-m-d');
                 $this->calholidays = getHolidayRange($start_data, $end_data);
                 ksort($this->calholidays);
             }
             $this->calevents = array();
             if (!empty($this->cfg['config']['settings']['events']['show'])) {
                 $start_data = isset($this->cfg['config']['settings']['events']['before']) ? date('Y-m-d', time() - 86400 * intval($this->cfg['config']['settings']['events']['after'])) : date('Y-m-d');
                 $end_data = isset($this->cfg['config']['settings']['events']['after']) ? date('Y-m-d', time() + 86400 * intval($this->cfg['config']['settings']['events']['before'])) : date('Y-m-d');
                 $events = getEventRange($start_data, $end_data);
                 ksort($events);
                 foreach ($events as $event) {
                     foreach ($event as $data) {
                         if (!array_key_exists($data['id'], $this->calevents)) {
                             $this->calevents[$data['id']] = $data;
                         }
                     }
                 }
             }
             if (!empty($this->cfg['cache'])) {
                 $cachedata = array($this->today['date'], $this->calgrid, $this->calbirthdays, $this->calholidays, $this->calevents);
                 $pmxCacheFunc['put']($this->cache_key, $cachedata, $this->cache_time, $this->cache_mode);
                 unset($cachedata);
             }
         }
     }
     return $this->visible;
 }
开发者ID:thunderamur,项目名称:PortaMx-Virgo-2.0-Beta-2,代码行数:72,代码来源:mini_calendar.php

示例12: list_getModLogEntries


//.........这里部分代码省略.........
        }
        if (isset($row['extra']['board_from'])) {
            $boards[(int) $row['extra']['board_from']][] = $row['id_action'];
        }
        if (isset($row['extra']['board'])) {
            $boards[(int) $row['extra']['board']][] = $row['id_action'];
        }
        // A message?
        if (isset($row['extra']['message'])) {
            $messages[(int) $row['extra']['message']][] = $row['id_action'];
        }
        // IP Info?
        if (isset($row['extra']['ip_range'])) {
            if ($seeIP) {
                $row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>';
            } else {
                $row['extra']['ip_range'] = $txt['logged'];
            }
        }
        // Email?
        if (isset($row['extra']['email'])) {
            $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>';
        }
        // Bans are complex.
        if ($row['action'] == 'ban') {
            $row['action_text'] = $txt['modlog_ac_ban'];
            foreach (array('member', 'email', 'ip_range', 'hostname') as $type) {
                if (isset($row['extra'][$type])) {
                    $row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type];
                }
            }
        }
        // The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details.
        $entries[$row['id_action']] = array('id' => $row['id_action'], 'ip' => $seeIP ? $row['ip'] : $txt['logged'], 'position' => empty($row['real_name']) && empty($row['group_name']) ? $txt['guest'] : $row['group_name'], 'moderator_link' => $row['id_member'] ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>' : (empty($row['real_name']) ? $txt['guest'] . (!empty($row['extra']['member_acted']) ? ' (' . $row['extra']['member_acted'] . ')' : '') : $row['real_name']), 'time' => timeformat($row['log_time']), 'timestamp' => forum_time(true, $row['log_time']), 'editable' => time() > $row['log_time'] + $context['hoursdisable'] * 3600, 'extra' => $row['extra'], 'action' => $row['action'], 'action_text' => isset($row['action_text']) ? $row['action_text'] : '');
    }
    $smcFunc['db_free_result']($result);
    if (!empty($boards)) {
        $request = $smcFunc['db_query']('', '
			SELECT id_board, name
			FROM {db_prefix}boards
			WHERE id_board IN ({array_int:board_list})
			LIMIT ' . count(array_keys($boards)), array('board_list' => array_keys($boards)));
        while ($row = $smcFunc['db_fetch_assoc']($request)) {
            foreach ($boards[$row['id_board']] as $action) {
                // Make the board number into a link - dealing with moving too.
                if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) {
                    $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
                } elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) {
                    $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
                } elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) {
                    $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
                }
            }
        }
        $smcFunc['db_free_result']($request);
    }
    if (!empty($topics)) {
        $request = $smcFunc['db_query']('', '
			SELECT ms.subject, t.id_topic
			FROM {db_prefix}topics AS t
				INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg)
			WHERE t.id_topic IN ({array_int:topic_list})
			LIMIT ' . count(array_keys($topics)), array('topic_list' => array_keys($topics)));
        while ($row = $smcFunc['db_fetch_assoc']($request)) {
            foreach ($topics[$row['id_topic']] as $action) {
                $this_action =& $entries[$action];
开发者ID:valek0972,项目名称:hackits,代码行数:67,代码来源:Modlog.php

示例13: PortaMx_AdminArticles


//.........这里部分代码省略.........
                        // load the article for edit/clone
                        $request = $smcFunc['db_query']('', '
							SELECT *
							FROM {db_prefix}portamx_articles
							WHERE id = {int:id}', array('id' => $id));
                        $row = $smcFunc['db_fetch_assoc']($request);
                        $article = array('id' => $row['id'], 'name' => $row['name'], 'catid' => $row['catid'], 'acsgrp' => $row['acsgrp'], 'ctype' => $row['ctype'], 'config' => $row['config'], 'content' => $row['content'], 'active' => $row['active'], 'owner' => $row['owner'], 'created' => $row['created'], 'approved' => $row['approved'], 'approvedby' => $row['approvedby'], 'updated' => $row['updated'], 'updatedby' => $row['updatedby']);
                        $smcFunc['db_free_result']($request);
                        if (!empty($_POST['clone_article'])) {
                            $article['id'] = 0;
                            $article['active'] = 0;
                            $article['approved'] = 0;
                            $article['owner'] = $user_info['id'];
                            $article['created'] = 0;
                            $article['updated'] = 0;
                            $article['updatedby'] = 0;
                            $context['pmx']['subaction'] = 'editnew';
                        } else {
                            $context['pmx']['subaction'] = 'edit';
                        }
                    } elseif (!empty($_POST['delete_article'])) {
                        $delid = $_POST['delete_article'];
                        // get the current page
                        $context['pmx']['articlestart'] = getCurrentPage($delid, $context['pmx']['settings']['manager']['artpage'], true);
                        $smcFunc['db_query']('', '
							DELETE FROM {db_prefix}portamx_articles
							WHERE id = {int:id}', array('id' => $delid));
                        // clear cached blocks
                        $pmxCacheFunc['clean']();
                    } elseif (!empty($_POST['chg_approved'])) {
                        $smcFunc['db_query']('', '
							UPDATE {db_prefix}portamx_articles
							SET approved = CASE WHEN approved = 0 THEN {int:apptime} ELSE 0 END, approvedby = {int:appmember}
							WHERE id = {int:id}', array('id' => $_POST['chg_approved'], 'apptime' => forum_time(), 'appmember' => $user_info['id']));
                        // clear cached blocks
                        $pmxCacheFunc['clean']();
                    } elseif (!empty($_POST['chg_active'])) {
                        $smcFunc['db_query']('', '
							UPDATE {db_prefix}portamx_articles
							SET active = CASE WHEN active = 0 THEN {int:apptime} ELSE 0 END
							WHERE id = {int:id}', array('id' => $_POST['chg_active'], 'apptime' => forum_time()));
                        // clear cached blocks
                        $pmxCacheFunc['clean']();
                    }
                    if (isset($_POST['xml']) && (!empty($_POST['chg_active']) || !empty($_POST['chg_approved']))) {
                        $id = !empty($_POST['chg_active']) ? $_POST['chg_active'] : $_POST['chg_approved'];
                        $request = $smcFunc['db_query']('', '
							SELECT active, approved
							FROM {db_prefix}portamx_articles
							WHERE id = {int:id}', array('id' => $id));
                        list($active, $approved) = $smcFunc['db_fetch_row']($request);
                        $smcFunc['db_free_result']($request);
                        // return update result
                        ob_start();
                        echo $id . ',' . (!empty($_POST['chg_active']) ? intval(!empty($active)) : intval(!empty($approved)));
                        ob_end_flush();
                        exit;
                    }
                } elseif (!empty($_POST['cancel_edit']) || !empty($_POST['cancel_overview'])) {
                    // called fron blocks move/clone ?
                    if (!empty($_POST['fromblock'])) {
                        // on cancel after saved remove the article
                        if ($_POST['sa'] == 'edit' && !empty($_POST['id'])) {
                            $smcFunc['db_query']('', '
								DELETE FROM {db_prefix}portamx_articles
								WHERE id = {int:id}', array('id' => $_POST['id']));
开发者ID:thunderamur,项目名称:PortaMx-Virgo-2.0-Beta-2,代码行数:67,代码来源:AdminArticles.php

示例14: loadMemberContext

function loadMemberContext($user, $display_custom_fields = false)
{
    global $memberContext, $user_profile, $txt, $scripturl, $user_info;
    global $context, $modSettings, $board_info, $settings;
    global $smcFunc;
    static $dataLoaded = array();
    // If this person's data is already loaded, skip it.
    if (isset($dataLoaded[$user])) {
        return true;
    }
    // We can't load guests or members not loaded by loadMemberData()!
    if ($user == 0) {
        return false;
    }
    if (!isset($user_profile[$user])) {
        trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING);
        return false;
    }
    // Well, it's loaded now anyhow.
    $dataLoaded[$user] = true;
    $profile = $user_profile[$user];
    // Censor everything.
    censorText($profile['signature']);
    censorText($profile['personal_text']);
    censorText($profile['location']);
    // Set things up to be used before hand.
    $gendertxt = $profile['gender'] == 2 ? $txt['female'] : ($profile['gender'] == 1 ? $txt['male'] : '');
    $profile['signature'] = str_replace(array("\n", "\r"), array('<br />', ''), $profile['signature']);
    $profile['signature'] = parse_bbc($profile['signature'], true, 'sig' . $profile['id_member']);
    $profile['is_online'] = (!empty($profile['show_online']) || allowedTo('moderate_forum')) && $profile['is_online'] > 0;
    $profile['stars'] = empty($profile['stars']) ? array('', '') : explode('#', $profile['stars']);
    // Setup the buddy status here (One whole in_array call saved :P)
    $profile['buddy'] = in_array($profile['id_member'], $user_info['buddies']);
    $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array();
    // If we're always html resizing, assume it's too large.
    if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize') {
        $avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : '';
        $avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : '';
    } else {
        $avatar_width = '';
        $avatar_height = '';
    }
    // What a monstrous array...
    $memberContext[$user] = array('username' => $profile['member_name'], 'name' => $profile['real_name'], 'id' => $profile['id_member'], 'is_buddy' => $profile['buddy'], 'is_reverse_buddy' => in_array($user_info['id'], $buddy_list), 'buddies' => $buddy_list, 'title' => !empty($modSettings['titlesEnable']) ? $profile['usertitle'] : '', 'href' => $scripturl . '?action=profile;u=' . $profile['id_member'], 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $profile['id_member'] . '" title="' . $txt['profile_of'] . ' ' . $profile['real_name'] . '">' . $profile['real_name'] . '</a>', 'email' => $profile['email_address'], 'show_email' => showEmailAddress(!empty($profile['hide_email']), $profile['id_member']), 'registered' => empty($profile['date_registered']) ? $txt['not_applicable'] : timeformat($profile['date_registered']), 'registered_timestamp' => empty($profile['date_registered']) ? 0 : forum_time(true, $profile['date_registered']), 'blurb' => $profile['personal_text'], 'gender' => array('name' => $gendertxt, 'image' => !empty($profile['gender']) ? '<img class="gender" src="' . $settings['images_url'] . '/' . ($profile['gender'] == 1 ? 'Male' : 'Female') . '.gif" alt="' . $gendertxt . '" />' : ''), 'website' => array('title' => $profile['website_title'], 'url' => $profile['website_url']), 'birth_date' => empty($profile['birthdate']) || $profile['birthdate'] === '0001-01-01' ? '0000-00-00' : (substr($profile['birthdate'], 0, 4) === '0004' ? '0000' . substr($profile['birthdate'], 4) : $profile['birthdate']), 'signature' => $profile['signature'], 'location' => $profile['location'], 'icq' => $profile['icq'] != '' && (empty($modSettings['guest_hideContacts']) || !$user_info['is_guest']) ? array('name' => $profile['icq'], 'href' => 'http://www.icq.com/whitepages/about_me.php?uin=' . $profile['icq'], 'link' => '<a class="icq new_win" href="http://www.icq.com/whitepages/about_me.php?uin=' . $profile['icq'] . '" target="_blank" title="' . $txt['icq_title'] . ' - ' . $profile['icq'] . '"><img src="http://status.icq.com/online.gif?img=5&amp;icq=' . $profile['icq'] . '" alt="' . $txt['icq_title'] . ' - ' . $profile['icq'] . '" width="18" height="18" /></a>', 'link_text' => '<a class="icq extern" href="http://www.icq.com/whitepages/about_me.php?uin=' . $profile['icq'] . '" title="' . $txt['icq_title'] . ' - ' . $profile['icq'] . '">' . $profile['icq'] . '</a>') : array('name' => '', 'add' => '', 'href' => '', 'link' => '', 'link_text' => ''), 'aim' => $profile['aim'] != '' && (empty($modSettings['guest_hideContacts']) || !$user_info['is_guest']) ? array('name' => $profile['aim'], 'href' => 'aim:goim?screenname=' . urlencode(strtr($profile['aim'], array(' ' => '%20'))) . '&amp;message=' . $txt['aim_default_message'], 'link' => '<a class="aim" href="aim:goim?screenname=' . urlencode(strtr($profile['aim'], array(' ' => '%20'))) . '&amp;message=' . $txt['aim_default_message'] . '" title="' . $txt['aim_title'] . ' - ' . $profile['aim'] . '"><img src="' . $settings['images_url'] . '/aim.gif" alt="' . $txt['aim_title'] . ' - ' . $profile['aim'] . '" /></a>', 'link_text' => '<a class="aim" href="aim:goim?screenname=' . urlencode(strtr($profile['aim'], array(' ' => '%20'))) . '&amp;message=' . $txt['aim_default_message'] . '" title="' . $txt['aim_title'] . ' - ' . $profile['aim'] . '">' . $profile['aim'] . '</a>') : array('name' => '', 'href' => '', 'link' => '', 'link_text' => ''), 'yim' => $profile['yim'] != '' && (empty($modSettings['guest_hideContacts']) || !$user_info['is_guest']) ? array('name' => $profile['yim'], 'href' => 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($profile['yim']), 'link' => '<a class="yim" href="http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($profile['yim']) . '" title="' . $txt['yim_title'] . ' - ' . $profile['yim'] . '"><img src="http://opi.yahoo.com/online?u=' . urlencode($profile['yim']) . '&amp;m=g&amp;t=0" alt="' . $txt['yim_title'] . ' - ' . $profile['yim'] . '" /></a>', 'link_text' => '<a class="yim" href="http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($profile['yim']) . '" title="' . $txt['yim_title'] . ' - ' . $profile['yim'] . '">' . $profile['yim'] . '</a>') : array('name' => '', 'href' => '', 'link' => '', 'link_text' => ''), 'msn' => $profile['msn'] != '' && (empty($modSettings['guest_hideContacts']) || !$user_info['is_guest']) ? array('name' => $profile['msn'], 'href' => 'http://members.msn.com/' . $profile['msn'], 'link' => '<a class="msn new_win" href="http://members.msn.com/' . $profile['msn'] . '" title="' . $txt['msn_title'] . ' - ' . $profile['msn'] . '"><img src="' . $settings['images_url'] . '/msntalk.gif" alt="' . $txt['msn_title'] . ' - ' . $profile['msn'] . '" /></a>', 'link_text' => '<a class="msn new_win" href="http://members.msn.com/' . $profile['msn'] . '" title="' . $txt['msn_title'] . ' - ' . $profile['msn'] . '">' . $profile['msn'] . '</a>') : array('name' => '', 'href' => '', 'link' => '', 'link_text' => ''), 'real_posts' => $profile['posts'], 'posts' => $profile['posts'] > 500000 ? $txt['geek'] : comma_format($profile['posts']), 'avatar' => array('name' => $profile['avatar'], 'image' => $profile['avatar'] == '' ? $profile['id_attach'] > 0 ? '<img class="avatar" src="' . (empty($profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename']) . '" alt="" />' : '' : (stristr($profile['avatar'], 'http://') ? '<img class="avatar" src="' . $profile['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" />' : '<img class="avatar" src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($profile['avatar']) . '" alt="" />'), 'href' => $profile['avatar'] == '' ? $profile['id_attach'] > 0 ? empty($profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename'] : '' : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']), 'url' => $profile['avatar'] == '' ? '' : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar'])), 'last_login' => empty($profile['last_login']) ? $txt['never'] : timeformat($profile['last_login']), 'last_login_timestamp' => empty($profile['last_login']) ? 0 : forum_time(0, $profile['last_login']), 'karma' => array('good' => $profile['karma_good'], 'bad' => $profile['karma_bad'], 'allow' => !$user_info['is_guest'] && !empty($modSettings['karmaMode']) && $user_info['id'] != $user && allowedTo('karma_edit') && ($user_info['posts'] >= $modSettings['karmaMinPosts'] || $user_info['is_admin'])), 'ip' => htmlspecialchars($profile['member_ip']), 'ip2' => htmlspecialchars($profile['member_ip2']), 'online' => array('is_online' => $profile['is_online'], 'text' => $txt[$profile['is_online'] ? 'online' : 'offline'], 'href' => $scripturl . '?action=pm;sa=send;u=' . $profile['id_member'], 'link' => '<a href="' . $scripturl . '?action=pm;sa=send;u=' . $profile['id_member'] . '">' . $txt[$profile['is_online'] ? 'online' : 'offline'] . '</a>', 'image_href' => $settings['images_url'] . '/' . ($profile['buddy'] ? 'buddy_' : '') . ($profile['is_online'] ? 'useron' : 'useroff') . '.gif', 'label' => $txt[$profile['is_online'] ? 'online' : 'offline']), 'language' => $smcFunc['ucwords'](strtr($profile['lngfile'], array('_' => ' ', '-utf8' => ''))), 'is_activated' => isset($profile['is_activated']) ? $profile['is_activated'] : 1, 'is_banned' => isset($profile['is_activated']) ? $profile['is_activated'] >= 10 : 0, 'options' => $profile['options'], 'is_guest' => false, 'group' => $profile['member_group'], 'group_color' => $profile['member_group_color'], 'group_id' => $profile['id_group'], 'post_group' => $profile['post_group'], 'post_group_color' => $profile['post_group_color'], 'group_stars' => str_repeat('<img src="' . str_replace('$language', $context['user']['language'], isset($profile['stars'][1]) ? $settings['images_url'] . '/' . $profile['stars'][1] : '') . '" alt="*" />', empty($profile['stars'][0]) || empty($profile['stars'][1]) ? 0 : $profile['stars'][0]), 'warning' => $profile['warning'], 'warning_status' => !empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $profile['warning'] ? 'mute' : (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $profile['warning'] ? 'moderate' : (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $profile['warning'] ? 'watch' : '')), 'local_time' => timeformat(time() + ($profile['time_offset'] - $user_info['time_offset']) * 3600, false));
    // First do a quick run through to make sure there is something to be shown.
    $memberContext[$user]['has_messenger'] = false;
    foreach (array('icq', 'msn', 'aim', 'yim') as $messenger) {
        if (!isset($context['disabled_fields'][$messenger]) && !empty($memberContext[$user][$messenger]['link'])) {
            $memberContext[$user]['has_messenger'] = true;
            break;
        }
    }
    // Are we also loading the members custom fields into context?
    if ($display_custom_fields && !empty($modSettings['displayFields'])) {
        $memberContext[$user]['custom_fields'] = array();
        if (!isset($context['display_fields'])) {
            $context['display_fields'] = unserialize($modSettings['displayFields']);
        }
        foreach ($context['display_fields'] as $custom) {
            if (empty($custom['title']) || empty($profile['options'][$custom['colname']])) {
                continue;
            }
            $value = $profile['options'][$custom['colname']];
            // BBC?
            if ($custom['bbc']) {
                $value = parse_bbc($value);
            } elseif (isset($custom['type']) && $custom['type'] == 'check') {
                $value = $value ? $txt['yes'] : $txt['no'];
            }
            // Enclosing the user input within some other text?
            if (!empty($custom['enclose'])) {
                $value = strtr($custom['enclose'], array('{SCRIPTURL}' => $scripturl, '{IMAGES_URL}' => $settings['images_url'], '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], '{INPUT}' => $value));
            }
            $memberContext[$user]['custom_fields'][] = array('title' => $custom['title'], 'colname' => $custom['colname'], 'value' => $value, 'placement' => !empty($custom['placement']) ? $custom['placement'] : 0);
        }
    }
    return true;
}
开发者ID:valek0972,项目名称:hackits,代码行数:78,代码来源:Load.php

示例15: getXmlProfile

function getXmlProfile($xml_format)
{
    global $scripturl, $memberContext, $user_profile, $modSettings, $user_info;
    // You must input a valid user....
    if (empty($_GET['u']) || loadMemberData((int) $_GET['u']) === false) {
        return array();
    }
    // Make sure the id is a number and not "I like trying to hack the database".
    $_GET['u'] = (int) $_GET['u'];
    // Load the member's contextual information!
    if (!loadMemberContext($_GET['u']) || !allowedTo('profile_view_any')) {
        return array();
    }
    // Okay, I admit it, I'm lazy.  Stupid $_GET['u'] is long and hard to type.
    $profile =& $memberContext[$_GET['u']];
    if ($xml_format == 'rss' || $xml_format == 'rss2') {
        $data = array(array('title' => cdata_parse($profile['name']), 'link' => $scripturl . '?action=profile;u=' . $profile['id'], 'description' => cdata_parse(isset($profile['group']) ? $profile['group'] : $profile['post_group']), 'comments' => $scripturl . '?action=pm;sa=send;u=' . $profile['id'], 'pubDate' => gmdate('D, d M Y H:i:s \\G\\M\\T', $user_profile[$profile['id']]['dateRegistered']), 'guid' => $scripturl . '?action=profile;u=' . $profile['id']));
    } elseif ($xml_format == 'rdf') {
        $data = array(array('title' => cdata_parse($profile['name']), 'link' => $scripturl . '?action=profile;u=' . $profile['id'], 'description' => cdata_parse(isset($profile['group']) ? $profile['group'] : $profile['post_group'])));
    } elseif ($xml_format == 'atom') {
        $data[] = array('title' => cdata_parse($profile['name']), 'link' => $scripturl . '?action=profile;u=' . $profile['id'], 'summary' => cdata_parse(isset($profile['group']) ? $profile['group'] : $profile['post_group']), 'created' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $user_profile[$profile['id']]['dateRegistered']), 'issued' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $user_profile[$profile['id']]['dateRegistered']), 'modified' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $user_profile[$profile['id']]['lastLogin']), 'id' => $scripturl . '?action=profile;u=' . $profile['id']);
    } else {
        $data = array('username' => cdata_parse($profile['username']), 'name' => cdata_parse($profile['name']), 'link' => $scripturl . '?action=profile;u=' . $profile['id'], 'posts' => $profile['posts'], 'post-group' => cdata_parse($profile['post_group']), 'language' => cdata_parse($profile['language']), 'last-login' => gmdate('D, d M Y H:i:s \\G\\M\\T', $user_profile[$profile['id']]['lastLogin']), 'registered' => gmdate('D, d M Y H:i:s \\G\\M\\T', $user_profile[$profile['id']]['dateRegistered']));
        // Everything below here might not be set, and thus maybe shouldn't be displayed.
        if ($profile['gender']['name'] != '') {
            $data['gender'] = cdata_parse($profile['gender']['name']);
        }
        if ($profile['avatar']['name'] != '') {
            $data['avatar'] = $profile['avatar']['url'];
        }
        // If they are online, show an empty tag... no reason to put anything inside it.
        if ($profile['online']['is_online']) {
            $data['online'] = '';
        }
        if ($profile['signature'] != '') {
            $data['signature'] = cdata_parse($profile['signature']);
        }
        if ($profile['blurb'] != '') {
            $data['blurb'] = cdata_parse($profile['blurb']);
        }
        if ($profile['location'] != '') {
            $data['location'] = cdata_parse($profile['location']);
        }
        if ($profile['title'] != '') {
            $data['title'] = cdata_parse($profile['title']);
        }
        if (!empty($profile['icq']['name']) && !(!empty($modSettings['guest_hideContacts']) && $user_info['is_guest'])) {
            $data['icq'] = $profile['icq']['name'];
        }
        if ($profile['aim']['name'] != '' && !(!empty($modSettings['guest_hideContacts']) && $user_info['is_guest'])) {
            $data['aim'] = $profile['aim']['name'];
        }
        if ($profile['msn']['name'] != '' && !(!empty($modSettings['guest_hideContacts']) && $user_info['is_guest'])) {
            $data['msn'] = $profile['msn']['name'];
        }
        if ($profile['yim']['name'] != '' && !(!empty($modSettings['guest_hideContacts']) && $user_info['is_guest'])) {
            $data['yim'] = $profile['yim']['name'];
        }
        if ($profile['website']['title'] != '') {
            $data['website'] = array('title' => cdata_parse($profile['website']['title']), 'link' => $profile['website']['url']);
        }
        if ($profile['group'] != '') {
            $data['postition'] = cdata_parse($profile['group']);
        }
        if (!empty($modSettings['karmaMode'])) {
            $data['karma'] = array('good' => $profile['karma']['good'], 'bad' => $profile['karma']['bad']);
        }
        if ((empty($profile['hide_email']) || empty($modSettings['allow_hideEmail'])) && !(!empty($modSettings['guest_hideContacts']) && $user_info['is_guest'])) {
            $data['email'] = $profile['email'];
        }
        if (!empty($profile['birth_date']) && substr($profile['birth_date'], 0, 4) != '0000') {
            list($birth_year, $birth_month, $birth_day) = sscanf($profile['birth_date'], '%d-%d-%d');
            $datearray = getdate(forum_time());
            $data['age'] = $datearray['year'] - $birth_year - ($datearray['mon'] > $birth_month || $datearray['mon'] == $birth_month && $datearray['mday'] >= $birth_day ? 0 : 1);
        }
    }
    // Save some memory.
    unset($profile);
    unset($memberContext[$_GET['u']]);
    return $data;
}
开发者ID:VBGAMER45,项目名称:SMFMods,代码行数:81,代码来源:News.php


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