本文整理汇总了PHP中standardTime函数的典型用法代码示例。如果您正苦于以下问题:PHP standardTime函数的具体用法?PHP standardTime怎么用?PHP standardTime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了standardTime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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('~<span class="remove">(.+?)</span>~', '$1', $row['message']), array("\r" => '', '<br />' => "\n", '<' => '<', '>' => '>', '"' => '"')), 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;
}
示例2: 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>';
}
}
示例3: action_mailingsend
//.........这里部分代码省略.........
require_once SUBSDIR . '/PersonalMessage.subs.php';
}
// We are relying too much on writing to superglobals...
$base_subject = !empty($_POST['subject']) ? $_POST['subject'] : '';
$base_message = !empty($_POST['message']) ? $_POST['message'] : '';
// Save the message and its subject in $context
$context['subject'] = htmlspecialchars($base_subject, ENT_COMPAT, 'UTF-8');
$context['message'] = htmlspecialchars($base_message, ENT_COMPAT, 'UTF-8');
// Prepare the message for sending it as HTML
if (!$context['send_pm'] && !empty($_POST['send_html'])) {
// Prepare the message for HTML.
if (!empty($_POST['parse_html'])) {
$base_message = str_replace(array("\n", ' '), array('<br />' . "\n", ' '), $base_message);
}
// This is here to prevent spam filters from tagging this as spam.
if (preg_match('~\\<html~i', $base_message) == 0) {
if (preg_match('~\\<body~i', $base_message) == 0) {
$base_message = '<html><head><title>' . $base_subject . '</title></head>' . "\n" . '<body>' . $base_message . '</body></html>';
} else {
$base_message = '<html>' . $base_message . '</html>';
}
}
}
if (empty($base_message) || empty($base_subject)) {
$context['preview'] = true;
return $this->action_mailingcompose();
}
// Use the default time format.
$user_info['time_format'] = $modSettings['time_format'];
$variables = array('{$board_url}', '{$current_time}', '{$latest_member.link}', '{$latest_member.id}', '{$latest_member.name}');
// We might need this in a bit
$cleanLatestMember = empty($_POST['send_html']) || $context['send_pm'] ? un_htmlspecialchars($modSettings['latestRealName']) : $modSettings['latestRealName'];
// Replace in all the standard things.
$base_message = str_replace($variables, array(!empty($_POST['send_html']) ? '<a href="' . $scripturl . '">' . $scripturl . '</a>' : $scripturl, standardTime(forum_time(), false), !empty($_POST['send_html']) ? '<a href="' . $scripturl . '?action=profile;u=' . $modSettings['latestMember'] . '">' . $cleanLatestMember . '</a>' : ($context['send_pm'] ? '[url=' . $scripturl . '?action=profile;u=' . $modSettings['latestMember'] . ']' . $cleanLatestMember . '[/url]' : $cleanLatestMember), $modSettings['latestMember'], $cleanLatestMember), $base_message);
$base_subject = str_replace($variables, array($scripturl, standardTime(forum_time(), false), $modSettings['latestRealName'], $modSettings['latestMember'], $modSettings['latestRealName']), $base_subject);
$from_member = array('{$member.email}', '{$member.link}', '{$member.id}', '{$member.name}');
// If we still have emails, do them first!
$i = 0;
foreach ($context['recipients']['emails'] as $k => $email) {
// Done as many as we can?
if ($i >= $num_at_once) {
break;
}
// Don't sent it twice!
unset($context['recipients']['emails'][$k]);
// Dammit - can't PM emails!
if ($context['send_pm']) {
continue;
}
$to_member = array($email, !empty($_POST['send_html']) ? '<a href="mailto:' . $email . '">' . $email . '</a>' : $email, '??', $email);
sendmail($email, str_replace($from_member, $to_member, $base_subject), str_replace($from_member, $to_member, $base_message), null, null, !empty($_POST['send_html']), 5);
// Done another...
$i++;
}
// Got some more to send this batch?
$last_id_member = 0;
if ($i < $num_at_once) {
// Need to build quite a query!
$sendQuery = '(';
$sendParams = array();
if (!empty($context['recipients']['groups'])) {
// Take the long route...
$queryBuild = array();
foreach ($context['recipients']['groups'] as $group) {
$sendParams['group_' . $group] = $group;
$queryBuild[] = 'mem.id_group = {int:group_' . $group . '}';
示例4: get_file_listing
/**
* Generates a file listing for a given directory
*
* @param string $path
* @param string $relative
*/
function get_file_listing($path, $relative)
{
global $scripturl, $txt, $context;
// Only files with these extensions will be deemed editable
$editable = 'php|pl|css|js|vbs|xml|xslt|txt|xsl|html|htm|shtm|shtml|asp|aspx|cgi|py';
// Is it even a directory?
if (!is_dir($path)) {
fatal_lang_error('error_invalid_dir', 'critical');
}
// Read this directorys contents
$entries = array();
$dir = dir($path);
while ($entry = $dir->read()) {
$entries[] = $entry;
}
$dir->close();
// Sort it so it looks natural to the user
natcasesort($entries);
$listing1 = array();
$listing2 = array();
foreach ($entries as $entry) {
// Skip all dot files, including .htaccess.
if (substr($entry, 0, 1) === '.' || $entry === 'CVS') {
continue;
}
// A directory entry
if (is_dir($path . '/' . $entry)) {
$listing1[] = array('filename' => $entry, 'is_writable' => is_writable($path . '/' . $entry), 'is_directory' => true, 'is_template' => false, 'is_image' => false, 'is_editable' => false, 'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=browse;directory=' . $relative . $entry, 'size' => '');
} else {
$size = filesize($path . '/' . $entry);
if ($size > 2048 || $size == 1024) {
$size = comma_format($size / 1024) . ' ' . $txt['themeadmin_edit_kilobytes'];
} else {
$size = comma_format($size) . ' ' . $txt['themeadmin_edit_bytes'];
}
$writable = is_writable($path . '/' . $entry);
$listing2[] = array('filename' => $entry, 'is_writable' => $writable, 'is_directory' => false, 'is_template' => preg_match('~\\.template\\.php$~', $entry) != 0, 'is_image' => preg_match('~\\.(jpg|jpeg|gif|bmp|png|ico)$~', $entry) != 0, 'is_editable' => $writable && preg_match('~\\.(' . $editable . ')$~', $entry) != 0, 'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;filename=' . $relative . $entry, 'size' => $size, 'last_modified' => standardTime(filemtime($path . '/' . $entry)));
}
}
return array_merge($listing1, $listing2);
}
示例5: addSubscription
if ($found_duration !== 0) {
$notify = true;
addSubscription($subscription_id, $member_id, $found_duration);
}
} else {
$actual_cost = $cost['fixed'];
// It must be at least the right amount.
if ($total_cost != 0 && $total_cost >= $actual_cost) {
// Add the subscription.
$notify = true;
addSubscription($subscription_id, $member_id);
}
}
// Send a receipt?
if (!empty($modSettings['paid_email']) && $modSettings['paid_email'] == 2 && $notify) {
$replacements = array('NAME' => $subscription_info['name'], 'SUBNAME' => $member_info['member_name'], 'SUBUSER' => $member_info['real_name'], 'SUBEMAIL' => $member_info['email_address'], 'PRICE' => sprintf($modSettings['paid_currency_symbol'], $total_cost), 'PROFILELINK' => $scripturl . '?action=profile;u=' . $member_id, 'DATE' => standardTime(time(), false));
emailAdmins('paid_subscription_new', $replacements, $notify_users);
}
} elseif ($gatewayClass->isCancellation()) {
if (method_exists($gatewayClass, 'processCancelation')) {
$gatewayClass->processCancelation($subscription_id, $member_id, $subscription_info);
}
} else {
// Some other "valid" transaction such as:
//
// subscr_signup: This IPN response (txn_type) is sent only the first time the user signs up for a subscription.
// It then does not fire in any event later. This response is received somewhere before or after the first payment of
// subscription is received (txn_type=subscr_payment) which is what we do process
//
// Should we log any of these ...
}
示例6: ssi_recentAttachments
/**
* We want to show the recent attachments outside of the forum.
*
* @param int $num_attachments = 10
* @param string[] $attachment_ext = array()
* @param string $output_method = 'echo'
*/
function ssi_recentAttachments($num_attachments = 10, $attachment_ext = array(), $output_method = 'echo')
{
global $modSettings, $scripturl, $txt, $settings;
// We want to make sure that we only get attachments for boards that we can see *if* any.
$attachments_boards = boardsAllowedTo('view_attachments');
// No boards? Adios amigo.
if (empty($attachments_boards)) {
return array();
}
$db = database();
// Is it an array?
if (!is_array($attachment_ext)) {
$attachment_ext = array($attachment_ext);
}
// Lets build the query.
$request = $db->query('', '
SELECT
att.id_attach, att.id_msg, att.filename, IFNULL(att.size, 0) AS filesize, att.downloads, mem.id_member,
IFNULL(mem.real_name, m.poster_name) AS poster_name, m.id_topic, m.subject, t.id_board, m.poster_time,
att.width, att.height' . (empty($modSettings['attachmentShowImages']) || empty($modSettings['attachmentThumbnails']) ? '' : ', IFNULL(thumb.id_attach, 0) AS id_thumb, thumb.width AS thumb_width, thumb.height AS thumb_height') . '
FROM {db_prefix}attachments AS att
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = att.id_msg)
INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (empty($modSettings['attachmentShowImages']) || empty($modSettings['attachmentThumbnails']) ? '' : '
LEFT JOIN {db_prefix}attachments AS thumb ON (thumb.id_attach = att.id_thumb)') . '
WHERE att.attachment_type = 0' . ($attachments_boards === array(0) ? '' : '
AND m.id_board IN ({array_int:boards_can_see})') . (!empty($attachment_ext) ? '
AND att.fileext IN ({array_string:attachment_ext})' : '') . (!$modSettings['postmod_active'] || allowedTo('approve_posts') ? '' : '
AND t.approved = {int:is_approved}
AND m.approved = {int:is_approved}
AND att.approved = {int:is_approved}') . '
ORDER BY att.id_attach DESC
LIMIT {int:num_attachments}', array('boards_can_see' => $attachments_boards, 'attachment_ext' => $attachment_ext, 'num_attachments' => $num_attachments, 'is_approved' => 1));
// We have something.
$attachments = array();
while ($row = $db->fetch_assoc($request)) {
$filename = preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', htmlspecialchars($row['filename'], ENT_COMPAT, 'UTF-8'));
// Is it an image?
$attachments[$row['id_attach']] = array('member' => array('id' => $row['id_member'], 'name' => $row['poster_name'], 'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>'), 'file' => array('filename' => $filename, 'filesize' => round($row['filesize'] / 1024, 2) . $txt['kilobyte'], 'downloads' => $row['downloads'], 'href' => $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'], 'link' => '<img src="' . $settings['images_url'] . '/icons/clip.png" alt="" /> <a href="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'] . '">' . $filename . '</a>', 'is_image' => !empty($row['width']) && !empty($row['height']) && !empty($modSettings['attachmentShowImages'])), 'topic' => array('id' => $row['id_topic'], 'subject' => $row['subject'], 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'], 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>', 'time' => standardTime($row['poster_time']), 'html_time' => htmlTime($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time'])));
// Images.
if ($attachments[$row['id_attach']]['file']['is_image']) {
$id_thumb = empty($row['id_thumb']) ? $row['id_attach'] : $row['id_thumb'];
$attachments[$row['id_attach']]['file']['image'] = array('id' => $id_thumb, 'width' => $row['width'], 'height' => $row['height'], 'img' => '<img src="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'] . ';image" alt="' . $filename . '" />', 'thumb' => '<img src="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $id_thumb . ';image" alt="' . $filename . '" />', 'href' => $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $id_thumb . ';image', 'link' => '<a href="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'] . ';image"><img src="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $id_thumb . ';image" alt="' . $filename . '" /></a>');
}
}
$db->free_result($request);
// So you just want an array? Here you can have it.
if ($output_method == 'array' || empty($attachments)) {
return $attachments;
}
// Give them the default.
echo '
<table class="ssi_downloads" cellpadding="2">
<tr>
<th align="left">', $txt['file'], '</th>
<th align="left">', $txt['posted_by'], '</th>
<th align="left">', $txt['downloads'], '</th>
<th align="left">', $txt['filesize'], '</th>
</tr>';
foreach ($attachments as $attach) {
echo '
<tr>
<td>', $attach['file']['link'], '</td>
<td>', $attach['member']['link'], '</td>
<td align="center">', $attach['file']['downloads'], '</td>
<td>', $attach['file']['filesize'], '</td>
</tr>';
}
echo '
</table>';
}
示例7: loadPollContext
/**
* Loads in $context whatever is needed to show a poll
*
* @param int $poll_id simply a poll id...
*/
function loadPollContext($poll_id)
{
global $context, $user_info, $txt, $scripturl, $settings;
// Get the question and if it's locked.
$pollinfo = pollInfo($poll_id);
// Get all the options, and calculate the total votes.
$pollOptions = pollOptionsForMember($poll_id, $user_info['id']);
// Compute total votes.
$realtotal = 0;
$pollinfo['has_voted'] = false;
foreach ($pollOptions as $choice) {
$realtotal += $choice['votes'];
$pollinfo['has_voted'] |= $choice['voted_this'] != -1;
}
// If this is a guest we need to do our best to work out if they have voted, and what they voted for.
if ($user_info['is_guest'] && $pollinfo['guest_vote'] && allowedTo('poll_vote')) {
if (!empty($_COOKIE['guest_poll_vote']) && preg_match('~^[0-9,;]+$~', $_COOKIE['guest_poll_vote']) && strpos($_COOKIE['guest_poll_vote'], ';' . $poll_id . ',') !== false) {
// ;id,timestamp,[vote,vote...]; etc
$guestinfo = explode(';', $_COOKIE['guest_poll_vote']);
// Find the poll we're after.
foreach ($guestinfo as $i => $guestvoted) {
$guestvoted = explode(',', $guestvoted);
if ($guestvoted[0] == $poll_id) {
break;
}
}
// Has the poll been reset since guest voted?
if ($pollinfo['reset_poll'] > $guestvoted[1]) {
// Remove the poll info from the cookie to allow guest to vote again
unset($guestinfo[$i]);
if (!empty($guestinfo)) {
$_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo);
} else {
unset($_COOKIE['guest_poll_vote']);
}
} else {
// What did they vote for?
unset($guestvoted[0], $guestvoted[1]);
foreach ($pollOptions as $choice => $details) {
$pollOptions[$choice]['voted_this'] = in_array($choice, $guestvoted) ? 1 : -1;
$pollinfo['has_voted'] |= $pollOptions[$choice]['voted_this'] != -1;
}
unset($choice, $details, $guestvoted);
}
unset($guestinfo, $guestvoted, $i);
}
}
// Set up the basic poll information.
$context['poll'] = array('id' => $poll_id, 'image' => 'normal_' . (empty($pollinfo['voting_locked']) ? 'poll' : 'locked_poll'), 'question' => parse_bbc($pollinfo['question']), 'total_votes' => $pollinfo['total'], 'change_vote' => !empty($pollinfo['change_vote']), 'is_locked' => !empty($pollinfo['voting_locked']), 'options' => array(), 'lock' => allowedTo('poll_lock_any') || $context['user']['started'] && allowedTo('poll_lock_own'), 'edit' => allowedTo('poll_edit_any') || $context['user']['started'] && allowedTo('poll_edit_own'), 'allowed_warning' => $pollinfo['max_votes'] > 1 ? sprintf($txt['poll_options6'], min(count($pollOptions), $pollinfo['max_votes'])) : '', 'is_expired' => !empty($pollinfo['expire_time']) && $pollinfo['expire_time'] < time(), 'expire_time' => !empty($pollinfo['expire_time']) ? standardTime($pollinfo['expire_time']) : 0, 'has_voted' => !empty($pollinfo['has_voted']), 'starter' => array('id' => $pollinfo['id_member'], 'name' => $pollinfo['poster_name'], 'href' => $pollinfo['id_member'] == 0 ? '' : $scripturl . '?action=profile;u=' . $pollinfo['id_member'], 'link' => $pollinfo['id_member'] == 0 ? $pollinfo['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $pollinfo['id_member'] . '">' . $pollinfo['poster_name'] . '</a>'));
// Make the lock and edit permissions defined above more directly accessible.
$context['allow_lock_poll'] = $context['poll']['lock'];
$context['allow_edit_poll'] = $context['poll']['edit'];
// You're allowed to vote if:
// 1. the poll did not expire, and
// 2. you're either not a guest OR guest voting is enabled... and
// 3. you're not trying to view the results, and
// 4. the poll is not locked, and
// 5. you have the proper permissions, and
// 6. you haven't already voted before.
$context['allow_vote'] = !$context['poll']['is_expired'] && (!$user_info['is_guest'] || $pollinfo['guest_vote'] && allowedTo('poll_vote')) && empty($pollinfo['voting_locked']) && allowedTo('poll_vote') && !$context['poll']['has_voted'];
// You're allowed to view the results if:
// 1. you're just a super-nice-guy, or
// 2. anyone can see them (hide_results == 0), or
// 3. you can see them after you voted (hide_results == 1), or
// 4. you've waited long enough for the poll to expire. (whether hide_results is 1 or 2.)
$context['allow_poll_view'] = allowedTo('moderate_board') || $pollinfo['hide_results'] == 0 || $pollinfo['hide_results'] == 1 && $context['poll']['has_voted'] || $context['poll']['is_expired'];
$context['poll']['show_results'] = $context['allow_poll_view'] && (isset($_REQUEST['viewresults']) || isset($_REQUEST['viewResults']));
// You're allowed to change your vote if:
// 1. the poll did not expire, and
// 2. you're not a guest... and
// 3. the poll is not locked, and
// 4. you have the proper permissions, and
// 5. you have already voted, and
// 6. the poll creator has said you can!
$context['allow_change_vote'] = !$context['poll']['is_expired'] && !$user_info['is_guest'] && empty($pollinfo['voting_locked']) && allowedTo('poll_vote') && $context['poll']['has_voted'] && $context['poll']['change_vote'];
// You're allowed to return to voting options if:
// 1. you are (still) allowed to vote.
// 2. you are currently seeing the results.
$context['allow_return_vote'] = $context['allow_vote'] && $context['poll']['show_results'];
// Calculate the percentages and bar lengths...
$divisor = $realtotal == 0 ? 1 : $realtotal;
// Determine if a decimal point is needed in order for the options to add to 100%.
$precision = $realtotal == 100 ? 0 : 1;
// Now look through each option, and...
foreach ($pollOptions as $i => $option) {
// First calculate the percentage, and then the width of the bar...
$bar = round($option['votes'] * 100 / $divisor, $precision);
$barWide = $bar == 0 ? 1 : floor($bar * 8 / 3);
// Now add it to the poll's contextual theme data.
$context['poll']['options'][$i] = array('id' => 'options-' . $i, 'percent' => $bar, 'votes' => $option['votes'], 'voted_this' => $option['voted_this'] != -1, 'bar' => '<span style="white-space: nowrap;"><img src="' . $settings['images_url'] . '/poll_' . ($context['right_to_left'] ? 'right' : 'left') . '.png" alt="" /><img src="' . $settings['images_url'] . '/poll_middle.png" style="width:' . $barWide . 'px; height: 12px;" alt="-" /><img src="' . $settings['images_url'] . '/poll_' . ($context['right_to_left'] ? 'left' : 'right') . '.png" alt="" /></span>', 'bar_ndt' => $bar > 0 ? '<div class="bar" style="width: ' . $bar . '%;"><div style="width: ' . $bar . '%;"></div></div>' : '<div class="bar"></div>', 'bar_width' => $barWide, 'option' => parse_bbc($option['label']), 'vote_button' => '<input type="' . ($pollinfo['max_votes'] > 1 ? 'checkbox' : 'radio') . '" name="options[]" id="options-' . $i . '" value="' . $i . '" class="input_' . ($pollinfo['max_votes'] > 1 ? 'check' : 'radio') . '" />');
}
}
示例8: topicNotifications
/**
* Retrieve all topic notifications for the given user.
* (used by createList() callbacks)
*
* @param int $start
* @param int $items_per_page
* @param string $sort
* @param int $memID id_member
* @return array
*/
function topicNotifications($start, $items_per_page, $sort, $memID)
{
global $scripturl, $user_info, $modSettings;
$db = database();
// All the topics with notification on...
$request = $db->query('', '
SELECT
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from, b.id_board, b.name,
t.id_topic, ms.subject, ms.id_member, IFNULL(mem.real_name, ms.poster_name) AS real_name_col,
ml.id_msg_modified, ml.poster_time, ml.id_member AS id_member_updated,
IFNULL(mem2.real_name, ml.poster_name) AS last_real_name
FROM {db_prefix}log_notify AS ln
INNER JOIN {db_prefix}topics AS t ON (t.id_topic = ln.id_topic' . ($modSettings['postmod_active'] ? ' AND t.approved = {int:is_approved}' : '') . ')
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board AND {query_see_board})
INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg)
INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = ms.id_member)
LEFT JOIN {db_prefix}members AS mem2 ON (mem2.id_member = ml.id_member)
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member})
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = {int:current_member})
WHERE ln.id_member = {int:selected_member}
ORDER BY {raw:sort}
LIMIT {int:offset}, {int:items_per_page}', array('current_member' => $user_info['id'], 'is_approved' => 1, 'selected_member' => $memID, 'sort' => $sort, 'offset' => $start, 'items_per_page' => $items_per_page));
$notification_topics = array();
while ($row = $db->fetch_assoc($request)) {
censorText($row['subject']);
$notification_topics[] = array('id' => $row['id_topic'], 'poster_link' => empty($row['id_member']) ? $row['real_name_col'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name_col'] . '</a>', 'poster_updated_link' => empty($row['id_member_updated']) ? $row['last_real_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member_updated'] . '">' . $row['last_real_name'] . '</a>', 'subject' => $row['subject'], 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.0', 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>', 'new' => $row['new_from'] <= $row['id_msg_modified'], 'new_from' => $row['new_from'], 'updated' => standardTime($row['poster_time']), 'new_href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['new_from'] . '#new', 'new_link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['new_from'] . '#new">' . $row['subject'] . '</a>', 'board_link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>');
}
$db->free_result($request);
return $notification_topics;
}
示例9: action_who
/**
* Who's online, and what are they doing?
* This function prepares the who's online data for the Who template.
* It requires the who_view permission.
* It is enabled with the who_enabled setting.
* It is accessed via ?action=who.
*
* @uses Who template, main sub-template
* @uses Who language file.
*/
public function action_who()
{
global $context, $scripturl, $txt, $modSettings, $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');
loadLanguage('Who');
// Sort out... the column sorting.
$sort_methods = array('user' => 'mem.real_name', 'time' => 'lo.log_time');
$show_methods = array('members' => '(lo.id_member != 0)', 'guests' => '(lo.id_member = 0)', 'all' => '1=1');
// Store the sort methods and the show types for use in the template.
$context['sort_methods'] = array('user' => $txt['who_user'], 'time' => $txt['who_time']);
$context['show_methods'] = array('all' => $txt['who_show_all'], 'members' => $txt['who_show_members_only'], 'guests' => $txt['who_show_guests_only']);
// Can they see spiders too?
if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) {
$show_methods['spiders'] = '(lo.id_member = 0 AND lo.id_spider > 0)';
$show_methods['guests'] = '(lo.id_member = 0 AND lo.id_spider = 0)';
$context['show_methods']['spiders'] = $txt['who_show_spiders_only'];
} elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') {
unset($_SESSION['who_online_filter']);
}
// Does the user prefer a different sort direction?
if (isset($_REQUEST['sort']) && isset($sort_methods[$_REQUEST['sort']])) {
$context['sort_by'] = $_SESSION['who_online_sort_by'] = $_REQUEST['sort'];
$sort_method = $sort_methods[$_REQUEST['sort']];
} elseif (isset($_SESSION['who_online_sort_by'])) {
$context['sort_by'] = $_SESSION['who_online_sort_by'];
$sort_method = $sort_methods[$_SESSION['who_online_sort_by']];
} else {
$context['sort_by'] = $_SESSION['who_online_sort_by'] = 'time';
$sort_method = 'lo.log_time';
}
$context['sort_direction'] = isset($_REQUEST['asc']) || isset($_REQUEST['sort_dir']) && $_REQUEST['sort_dir'] == 'asc' ? 'up' : 'down';
$conditions = array();
if (!allowedTo('moderate_forum')) {
$conditions[] = '(IFNULL(mem.show_online, 1) = 1)';
}
// Fallback to top filter?
if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) {
$_REQUEST['show'] = $_REQUEST['show_top'];
}
// Does the user wish to apply a filter?
if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) {
$context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show'];
$conditions[] = $show_methods[$_REQUEST['show']];
} elseif (isset($_SESSION['who_online_filter'])) {
$context['show_by'] = $_SESSION['who_online_filter'];
$conditions[] = $show_methods[$_SESSION['who_online_filter']];
} else {
$context['show_by'] = $_SESSION['who_online_filter'] = 'all';
}
require_once SUBSDIR . '/Members.subs.php';
$totalMembers = countMembersOnline($conditions);
// Prepare some page index variables.
$context['page_index'] = constructPageIndex($scripturl . '?action=who;sort=' . $context['sort_by'] . ($context['sort_direction'] == 'up' ? ';asc' : '') . ';show=' . $context['show_by'], $_REQUEST['start'], $totalMembers, $modSettings['defaultMaxMembers']);
$context['start'] = $_REQUEST['start'];
$context['sub_template'] = 'whos_online';
Template_Layers::getInstance()->add('whos_selection');
// Look for people online, provided they don't mind if you see they are.
$members = onlineMembers($conditions, $sort_method, $context['sort_direction'], $context['start']);
$context['members'] = array();
$member_ids = array();
$url_data = array();
foreach ($members as $row) {
$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' => standardTime($row['log_time'], true), 'html_time' => htmlTime($row['log_time']), 'timestamp' => forum_time(true, $row['log_time']), 'query' => $actions, 'is_hidden' => $row['show_online'] == 0, 'id_spider' => $row['id_spider'], 'color' => empty($row['online_color']) ? '' : $row['online_color']);
$url_data[$row['session']] = array($row['url'], $row['id_member']);
$member_ids[] = $row['id_member'];
}
// Load the user data for these members.
loadMemberData($member_ids);
// Load up the guest user.
$memberContext[0] = array('id' => 0, 'name' => $txt['guest_title'], 'group' => $txt['guest_title'], 'href' => '', 'link' => $txt['guest_title'], 'email' => $txt['guest_title'], 'is_guest' => true);
// Are we showing spiders?
$spiderContext = array();
if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) {
foreach (unserialize($modSettings['spider_name_cache']) as $id => $name) {
$spiderContext[$id] = array('id' => 0, 'name' => $name, 'group' => $txt['spiders'], 'href' => '', 'link' => $name, 'email' => $name, 'is_guest' => true);
}
}
require_once SUBSDIR . '/Who.subs.php';
//.........这里部分代码省略.........
示例10: prepareMessageContext
/**
* Prepare context for a message.
*
* @param mixed[] $message the message array
*/
function prepareMessageContext($message)
{
global $context, $txt;
// Load up 'em attachments!
foreach ($message['attachment_stuff'] as $attachment) {
$context['attachments']['current'][] = array('name' => htmlspecialchars($attachment['filename'], ENT_COMPAT, 'UTF-8'), 'size' => $attachment['filesize'], 'id' => $attachment['id_attach'], 'approved' => $attachment['attachment_approved']);
}
// Allow moderators to change names....
if (allowedTo('moderate_forum') && empty($message['message']['id_member'])) {
$context['name'] = htmlspecialchars($message['message']['poster_name'], ENT_COMPAT, 'UTF-8');
$context['email'] = htmlspecialchars($message['message']['poster_email'], ENT_COMPAT, 'UTF-8');
}
// When was it last modified?
if (!empty($message['message']['modified_time'])) {
$context['last_modified'] = standardTime($message['message']['modified_time']);
$context['last_modified_text'] = sprintf($txt['last_edit_by'], $context['last_modified'], $message['message']['modified_name']);
}
// Show an "approve" box if the user can approve it, and the message isn't approved.
if (!$message['message']['approved'] && !$context['show_approval']) {
$context['show_approval'] = allowedTo('approve_posts');
}
}
示例11: getUnapprovedPosts
/**
* Make sure the "current user" (uses $user_info) cannot go outside of the limit for the day.
*
* @param string $approve_query additional condition for the query
* @param string $current_view defined whether return the topics (first
* messages) or the messages. If set to 'topics' it returns
* the topics, otherwise the messages
* @param mixed[] $boards_allowed array of arrays, it must contain three
* indexes:
* - delete_own_boards
* - delete_any_boards
* - delete_own_replies
* each of which must be an array of boards the user is allowed
* to perform a certain action (return of boardsAllowedTo)
* @param int $start start of the query LIMIT
* @param int $limit number of elements to return (default 10)
*/
function getUnapprovedPosts($approve_query, $current_view, $boards_allowed, $start, $limit = 10)
{
global $context, $scripturl, $user_info;
$db = database();
$request = $db->query('', '
SELECT m.id_msg, m.id_topic, m.id_board, m.subject, m.body, m.id_member,
IFNULL(mem.real_name, m.poster_name) AS poster_name, m.poster_time, m.smileys_enabled,
t.id_member_started, t.id_first_msg, b.name AS board_name, c.id_cat, c.name AS cat_name
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 = m.id_board)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)
WHERE m.approved = {int:not_approved}
AND t.id_first_msg ' . ($current_view == 'topics' ? '=' : '!=') . ' m.id_msg
AND {query_see_board}
' . $approve_query . '
LIMIT {int:start}, {int:limit}', array('start' => $start, 'limit' => $limit, 'not_approved' => 0));
$unapproved_items = array();
for ($i = 1; $row = $db->fetch_assoc($request); $i++) {
// Can delete is complicated, let's solve it first... is it their own post?
if ($row['id_member'] == $user_info['id'] && ($boards_allowed['delete_own_boards'] == array(0) || in_array($row['id_board'], $boards_allowed['delete_own_boards']))) {
$can_delete = true;
} elseif ($row['id_member'] == $row['id_member_started'] && $row['id_msg'] != $row['id_first_msg'] && ($boards_allowed['delete_own_replies'] == array(0) || in_array($row['id_board'], $boards_allowed['delete_own_replies']))) {
$can_delete = true;
} elseif ($row['id_member'] != $user_info['id'] && ($boards_allowed['delete_any_boards'] == array(0) || in_array($row['id_board'], $boards_allowed['delete_any_boards']))) {
$can_delete = true;
} else {
$can_delete = false;
}
$unapproved_items[] = array('id' => $row['id_msg'], 'alternate' => $i % 2, 'counter' => $context['start'] + $i, 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'], 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>', 'subject' => $row['subject'], 'body' => parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), 'time' => standardTime($row['poster_time']), 'html_time' => htmlTime($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time']), 'poster' => array('id' => $row['id_member'], 'name' => $row['poster_name'], 'link' => $row['id_member'] ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>' : $row['poster_name'], 'href' => $scripturl . '?action=profile;u=' . $row['id_member']), 'topic' => array('id' => $row['id_topic']), 'board' => array('id' => $row['id_board'], 'name' => $row['board_name'], 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['board_name'] . '</a>'), 'category' => array('id' => $row['id_cat'], 'name' => $row['cat_name'], 'link' => '<a href="' . $scripturl . '#c' . $row['id_cat'] . '">' . $row['cat_name'] . '</a>'), 'can_delete' => $can_delete);
}
$db->free_result($request);
return $unapproved_items;
}
示例12: action_printpage
/**
* Format a topic to be printer friendly.
* Must be called with a topic specified.
* Accessed via ?action=topic;sa=printpage.
*
* @uses Printpage template, main sub-template.
* @uses print_above/print_below later without the main layer.
*/
public function action_printpage()
{
global $topic, $scripturl, $context, $user_info, $board_info, $modSettings;
// Redirect to the boardindex if no valid topic id is provided.
if (empty($topic)) {
redirectexit();
}
$template_layers = Template_Layers::getInstance();
$template_layers->removeAll();
if (!empty($modSettings['disable_print_topic'])) {
unset($_REQUEST['action']);
$context['theme_loaded'] = false;
fatal_lang_error('feature_disabled', false);
}
require_once SUBSDIR . '/Topic.subs.php';
// Get the topic starter information.
$topicinfo = getTopicInfo($topic, 'starter');
$context['user']['started'] = $user_info['id'] == $topicinfo['id_member'] && !$user_info['is_guest'];
// Whatever happens don't index this.
$context['robot_no_index'] = true;
// Redirect to the boardindex if no valid topic id is provided.
if (empty($topicinfo)) {
redirectexit();
}
// @todo this code is almost the same as the one in Display.controller.php
if ($topicinfo['id_poll'] > 0 && !empty($modSettings['pollMode']) && allowedTo('poll_view')) {
loadLanguage('Post');
require_once SUBSDIR . '/Poll.subs.php';
loadPollContext($topicinfo['id_poll']);
$template_layers->addAfter('print_poll', 'print');
}
// Lets "output" all that info.
loadTemplate('Printpage');
$template_layers->add('print');
$context['sub_template'] = 'print_page';
$context['board_name'] = $board_info['name'];
$context['category_name'] = $board_info['cat']['name'];
$context['poster_name'] = $topicinfo['poster_name'];
$context['post_time'] = standardTime($topicinfo['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.
$context['posts'] = topicMessages($topic);
$posts_id = array_keys($context['posts']);
if (!isset($context['topic_subject'])) {
$context['topic_subject'] = $context['posts'][min($posts_id)]['subject'];
}
// Fetch attachments so we can print them if asked, enabled and allowed
if (isset($_REQUEST['images']) && !empty($modSettings['attachmentEnable']) && allowedTo('view_attachments')) {
require_once SUBSDIR . '/Topic.subs.php';
$context['printattach'] = messagesAttachments(array_keys($context['posts']));
$context['viewing_attach'] = true;
}
// Set a canonical URL for this page.
$context['canonical_url'] = $scripturl . '?topic=' . $topic . '.0';
$context['view_attach_mode'] = array('text' => $scripturl . '?action=topic;sa=printpage;topic=' . $topic . '.0', 'images' => $scripturl . '?action=topic;sa=printpage;topic=' . $topic . '.0;images');
}
示例13: showBusinessHours
function showBusinessHours($str)
{
$day_key = array(0 => "Sun", 1 => "Mon", 2 => "Tue", 3 => "Wed", 4 => "Thu", 5 => "Fri", 6 => "Sat");
$days = explode("|", $str);
$result = "<div class=\"hofo-container\">\r\n";
$result .= "<h5 class=\"medium black\" style=\"margin: 3px 0px;\"><u>Business Hours</u></h5>\r\n";
foreach ($days as $key => $hours) {
if ($hours != "00:00-00:00") {
$subresult .= "\t<div class=\"hofo-days small\">\r\n";
$subresult .= "\t" . $day_key[$key] . "</div>\r\n";
$subresult .= "\t<div class=\"hofo-hours small\">\r\n";
$time = null;
if ($hours == "CL") {
$time = "Closed";
} elseif ($hours == "BA") {
$time = "By Appointment";
} else {
$hour = explode("-", $hours);
$time = standardTime($hour[0]) . " - " . standardTime($hour[1]);
}
$subresult .= "\t" . $time . "</div>\r\n";
}
}
if ($subresult != "") {
$result .= $subresult . "</div>\r\n";
} else {
$result = "Hours not available. Contact company for hours of operation.";
}
return $result;
}
示例14: prepareSearchContext_callback
//.........这里部分代码省略.........
$charLimit = 50;
$message['body'] = strtr($message['body'], array("\n" => ' ', '<br />' => "\n"));
$message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']);
$message['body'] = strip_tags(strtr($message['body'], array('</div>' => '<br />', '</li>' => '<br />')), '<br>');
if (Util::strlen($message['body']) > $charLimit) {
if (empty($context['key_words'])) {
$message['body'] = Util::substr($message['body'], 0, $charLimit) . '<strong>...</strong>';
} else {
$matchString = '';
$force_partial_word = false;
foreach ($context['key_words'] as $keyword) {
$keyword = un_htmlspecialchars($keyword);
$keyword = preg_replace_callback('~(&#(\\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', strtr($keyword, array('\\\'' => '\'', '&' => '&')));
if (preg_match('~[\'\\.,/@%&;:(){}\\[\\]_\\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\\.,/@%&;:(){}\\[\\]_\\-+\\\\]~', $keyword) != 0) {
$force_partial_word = true;
}
$matchString .= strtr(preg_quote($keyword, '/'), array('\\*' => '.+?')) . '|';
}
$matchString = un_htmlspecialchars(substr($matchString, 0, -1));
$message['body'] = un_htmlspecialchars(strtr($message['body'], array(' ' => ' ', '<br />' => "\n", '[' => '[', ']' => ']', ':' => ':', '@' => '@')));
if (empty($modSettings['search_method']) || $force_partial_word) {
preg_match_all('/([^\\s\\W]{' . $charLimit . '}[\\s\\W]|[\\s\\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\\s\\W]|[^\\s\\W]{0,' . $charLimit . '})/isu', $message['body'], $matches);
} else {
preg_match_all('/([^\\s\\W]{' . $charLimit . '}[\\s\\W]|[\\s\\W].{0,' . $charLimit . '}?[\\s\\W]|^)(' . $matchString . ')([\\s\\W].{0,' . $charLimit . '}[\\s\\W]|[\\s\\W][^\\s\\W]{0,' . $charLimit . '})/isu', $message['body'], $matches);
}
$message['body'] = '';
foreach ($matches[0] as $index => $match) {
$match = strtr(htmlspecialchars($match, ENT_QUOTES, 'UTF-8'), array("\n" => ' '));
$message['body'] .= '<strong>......</strong> ' . $match . ' <strong>......</strong>';
}
}
// Re-fix the international characters.
$message['body'] = preg_replace_callback('~(&#(\\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', $message['body']);
}
} else {
// Run BBC interpreter on the message.
$message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']);
}
// Make sure we don't end up with a practically empty message body.
$message['body'] = preg_replace('~^(?: )+$~', '', $message['body']);
// Sadly, we need to check that the icon is not broken.
if (!empty($modSettings['messageIconChecks_enable'])) {
if (!isset($context['icon_sources'][$message['first_icon']])) {
$context['icon_sources'][$message['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
}
if (!isset($context['icon_sources'][$message['last_icon']])) {
$context['icon_sources'][$message['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
}
if (!isset($context['icon_sources'][$message['icon']])) {
$context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url';
}
} else {
if (!isset($context['icon_sources'][$message['first_icon']])) {
$context['icon_sources'][$message['first_icon']] = 'images_url';
}
if (!isset($context['icon_sources'][$message['last_icon']])) {
$context['icon_sources'][$message['last_icon']] = 'images_url';
}
if (!isset($context['icon_sources'][$message['icon']])) {
$context['icon_sources'][$message['icon']] = 'images_url';
}
}
// Do we have quote tag enabled?
$quote_enabled = empty($modSettings['disabledBBC']) || !in_array('quote', explode(',', $modSettings['disabledBBC']));
$output = array_merge($context['topics'][$message['id_msg']], array('id' => $message['id_topic'], 'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($message['is_sticky']), 'is_locked' => !empty($message['locked']), 'is_poll' => !empty($modSettings['pollMode']) && $message['id_poll'] > 0, 'is_hot' => !empty($modSettings['useLikesNotViews']) ? $message['num_likes'] >= $modSettings['hotTopicPosts'] : $message['num_replies'] >= $modSettings['hotTopicPosts'], 'is_very_hot' => !empty($modSettings['useLikesNotViews']) ? $message['num_likes'] >= $modSettings['hotTopicVeryPosts'] : $message['num_replies'] >= $modSettings['hotTopicVeryPosts'], 'posted_in' => !empty($participants[$message['id_topic']]), 'views' => $message['num_views'], 'replies' => $message['num_replies'], 'tests' => array('can_reply' => in_array($message['id_board'], $boards_can['post_reply_any']) || in_array(0, $boards_can['post_reply_any']), 'can_quote' => (in_array($message['id_board'], $boards_can['post_reply_any']) || in_array(0, $boards_can['post_reply_any'])) && $quote_enabled, 'can_mark_notify' => in_array($message['id_board'], $boards_can['mark_any_notify']) || in_array(0, $boards_can['mark_any_notify']) && !$context['user']['is_guest']), 'first_post' => array('id' => $message['first_msg'], 'time' => standardTime($message['first_poster_time']), 'html_time' => htmlTime($message['first_poster_time']), 'timestamp' => forum_time(true, $message['first_poster_time']), 'subject' => $message['first_subject'], 'href' => $scripturl . '?topic=' . $message['id_topic'] . '.0', 'link' => '<a href="' . $scripturl . '?topic=' . $message['id_topic'] . '.0">' . $message['first_subject'] . '</a>', 'icon' => $message['first_icon'], 'icon_url' => $settings[$context['icon_sources'][$message['first_icon']]] . '/post/' . $message['first_icon'] . '.png', 'member' => array('id' => $message['first_member_id'], 'name' => $message['first_member_name'], 'href' => !empty($message['first_member_id']) ? $scripturl . '?action=profile;u=' . $message['first_member_id'] : '', 'link' => !empty($message['first_member_id']) ? '<a href="' . $scripturl . '?action=profile;u=' . $message['first_member_id'] . '" title="' . $txt['profile_of'] . ' ' . $message['first_member_name'] . '">' . $message['first_member_name'] . '</a>' : $message['first_member_name'])), 'last_post' => array('id' => $message['last_msg'], 'time' => standardTime($message['last_poster_time']), 'html_time' => htmlTime($message['last_poster_time']), 'timestamp' => forum_time(true, $message['last_poster_time']), 'subject' => $message['last_subject'], 'href' => $scripturl . '?topic=' . $message['id_topic'] . ($message['num_replies'] == 0 ? '.0' : '.msg' . $message['last_msg']) . '#msg' . $message['last_msg'], 'link' => '<a href="' . $scripturl . '?topic=' . $message['id_topic'] . ($message['num_replies'] == 0 ? '.0' : '.msg' . $message['last_msg']) . '#msg' . $message['last_msg'] . '">' . $message['last_subject'] . '</a>', 'icon' => $message['last_icon'], 'icon_url' => $settings[$context['icon_sources'][$message['last_icon']]] . '/post/' . $message['last_icon'] . '.png', 'member' => array('id' => $message['last_member_id'], 'name' => $message['last_member_name'], 'href' => !empty($message['last_member_id']) ? $scripturl . '?action=profile;u=' . $message['last_member_id'] : '', 'link' => !empty($message['last_member_id']) ? '<a href="' . $scripturl . '?action=profile;u=' . $message['last_member_id'] . '" title="' . $txt['profile_of'] . ' ' . $message['last_member_name'] . '">' . $message['last_member_name'] . '</a>' : $message['last_member_name'])), 'board' => array('id' => $message['id_board'], 'name' => $message['board_name'], 'href' => $scripturl . '?board=' . $message['id_board'] . '.0', 'link' => '<a href="' . $scripturl . '?board=' . $message['id_board'] . '.0">' . $message['board_name'] . '</a>'), 'category' => array('id' => $message['id_cat'], 'name' => $message['cat_name'], 'href' => $scripturl . '#c' . $message['id_cat'], 'link' => '<a href="' . $scripturl . '#c' . $message['id_cat'] . '">' . $message['cat_name'] . '</a>')));
determineTopicClass($output);
if ($output['posted_in']) {
$output['class'] = 'my_' . $output['class'];
}
$body_highlighted = $message['body'];
$subject_highlighted = $message['subject'];
if (!empty($options['display_quick_mod'])) {
$started = $output['first_post']['member']['id'] == $user_info['id'];
$output['quick_mod'] = array('lock' => in_array(0, $boards_can['lock_any']) || in_array($output['board']['id'], $boards_can['lock_any']) || $started && (in_array(0, $boards_can['lock_own']) || in_array($output['board']['id'], $boards_can['lock_own'])), 'sticky' => (in_array(0, $boards_can['make_sticky']) || in_array($output['board']['id'], $boards_can['make_sticky'])) && !empty($modSettings['enableStickyTopics']), 'move' => in_array(0, $boards_can['move_any']) || in_array($output['board']['id'], $boards_can['move_any']) || $started && (in_array(0, $boards_can['move_own']) || in_array($output['board']['id'], $boards_can['move_own'])), 'remove' => in_array(0, $boards_can['remove_any']) || in_array($output['board']['id'], $boards_can['remove_any']) || $started && (in_array(0, $boards_can['remove_own']) || in_array($output['board']['id'], $boards_can['remove_own'])));
$context['can_lock'] |= $output['quick_mod']['lock'];
$context['can_sticky'] |= $output['quick_mod']['sticky'];
$context['can_move'] |= $output['quick_mod']['move'];
$context['can_remove'] |= $output['quick_mod']['remove'];
$context['can_merge'] |= in_array($output['board']['id'], $boards_can['merge_any']);
$context['can_markread'] = $context['user']['is_logged'];
$context['qmod_actions'] = array('remove', 'lock', 'sticky', 'move', 'markread');
call_integration_hook('integrate_quick_mod_actions_search');
}
foreach ($context['key_words'] as $query) {
// Fix the international characters in the keyword too.
$query = un_htmlspecialchars($query);
$query = trim($query, '\\*+');
$query = strtr(Util::htmlspecialchars($query), array('\\\'' => '\''));
$body_highlighted = preg_replace_callback('/((<[^>]*)|' . preg_quote(strtr($query, array('\'' => ''')), '/') . ')/iu', array($this, '_highlighted_callback'), $body_highlighted);
$subject_highlighted = preg_replace('/(' . preg_quote($query, '/') . ')/iu', '<strong class="highlight">$1</strong>', $subject_highlighted);
}
require_once SUBSDIR . '/Attachments.subs.php';
$output['matches'][] = array('id' => $message['id_msg'], 'attachment' => loadAttachmentContext($message['id_msg']), 'alternate' => $counter % 2, 'member' => &$memberContext[$message['id_member']], 'icon' => $message['icon'], 'icon_url' => $settings[$context['icon_sources'][$message['icon']]] . '/post/' . $message['icon'] . '.png', 'subject' => $message['subject'], 'subject_highlighted' => $subject_highlighted, 'time' => standardTime($message['poster_time']), 'html_time' => htmlTime($message['poster_time']), 'timestamp' => forum_time(true, $message['poster_time']), 'counter' => $counter, 'modified' => array('time' => standardTime($message['modified_time']), 'html_time' => htmlTime($message['modified_time']), 'timestamp' => forum_time(true, $message['modified_time']), 'name' => $message['modified_name']), 'body' => $message['body'], 'body_highlighted' => $body_highlighted, 'start' => 'msg' . $message['id_msg']);
$counter++;
if (!$context['compact']) {
$output['buttons'] = array('notify' => array('href' => $scripturl . '?action=notify;topic=' . $output['id'] . '.msg' . $message['id_msg'], 'text' => $txt['notify'], 'test' => 'can_mark_notify'), 'reply' => array('href' => $scripturl . '?action=post;topic=' . $output['id'] . '.msg' . $message['id_msg'], 'text' => $txt['reply'], 'test' => 'can_reply'), 'quote' => array('href' => $scripturl . '?action=post;topic=' . $output['id'] . '.msg' . $message['id_msg'] . ';quote=' . $message['id_msg'], 'text' => $txt['quote'], 'test' => 'can_quote'));
}
call_integration_hook('integrate_search_message_context', array($counter, &$output));
return $output;
}
示例15: sp_rssFeed
/**
* RSS Block, Displays rss feed in a block.
*
* @param mixed[] $parameters
* 'url' => url of the feed
* 'show_title' => Show the feed title
* 'show_content' => Show the content of the feed
* 'show_date' => Show the date of the feed item
* 'strip_preserve' => preserve tags
* 'count' => number of items to show
* 'limit' => number of characters of content to show
* @param int $id - not used in this block
* @param boolean $return_parameters if true returns the configuration options for the block
*/
function sp_rssFeed($parameters, $id, $return_parameters = false)
{
global $txt;
$block_parameters = array('url' => 'text', 'show_title' => 'check', 'show_content' => 'check', 'show_date' => 'check', 'strip_preserve' => 'text', 'count' => 'int', 'limit' => 'int');
if ($return_parameters) {
return $block_parameters;
}
$feed = !empty($parameters['url']) ? un_htmlspecialchars($parameters['url']) : '';
$show_title = !empty($parameters['show_title']);
$show_content = !empty($parameters['show_content']);
$show_date = !empty($parameters['show_date']);
$strip_preserve = !empty($parameters['strip_preserve']) ? $parameters['strip_preserve'] : 'br';
$strip_preserve = preg_match_all('~[A-Za-z0-9]+~', $strip_preserve, $match) ? $match[0] : array();
$count = !empty($parameters['count']) ? (int) $parameters['count'] : 5;
$limit = !empty($parameters['limit']) ? (int) $parameters['limit'] : 0;
// Need a feed name to load it
if (empty($feed)) {
echo '
', $txt['error_sp_invalid_feed'];
return;
}
$rss = array();
require_once SUBSDIR . '/Package.subs.php';
$data = fetch_web_data($feed);
$data_save = $data;
// Convert it to UTF8 if we can and its not already
preg_match('~encoding="([^"]*)"~', $data, $charset);
if (!empty($charset[1]) && $charset != 'UTF-8') {
// Use iconv if its available
if (function_exists('iconv')) {
$data = @iconv($charset[1], 'UTF-8' . '//TRANSLIT//IGNORE', $data);
}
// No iconv or a false response from it
if (!function_exists('iconv') || $data == false) {
// PHP (some 5.4 versions) mishandles //TRANSLIT//IGNORE and returns false: see https://bugs.php.net/bug.php?id=61484
if ($data == false) {
$data = $data_save;
}
if (function_exists('mb_convert_encoding')) {
// Replace unknown characters with a space
@ini_set('mbstring.substitute_character', '32');
$data = @mb_convert_encoding($data, 'UTF-8', $charset[1]);
} elseif (function_exists('recode_string')) {
$data = @recode_string($charset[1] . '..' . 'UTF-8', $data);
}
}
}
$data = str_replace(array("\n", "\r", "\t"), '', $data);
$data = preg_replace('~<\\!\\[CDATA\\[(.+?)\\]\\]>~eu', '\'#cdata_escape_encode#\' . Util::htmlspecialchars(\'$1\')', $data);
// Find all the feed items
preg_match_all('~<item>(.+?)</item>~', $data, $items);
foreach ($items[1] as $item_id => $item) {
if ($item_id === $count) {
break;
}
preg_match_all('~<([A-Za-z]+)>(.+?)</\\1>~', $item, $match);
foreach ($match[0] as $tag_id => $dummy) {
if (Util::strpos($match[2][$tag_id], '#cdata_escape_encode#') === 0) {
$match[2][$tag_id] = stripslashes(un_htmlspecialchars(Util::substr($match[2][$tag_id], 21)));
}
$rss[$item_id][strtolower($match[1][$tag_id])] = un_htmlspecialchars($match[2][$tag_id]);
}
}
// Nothing, say its invalid
if (empty($rss)) {
echo '
', $txt['error_sp_invalid_feed'];
return;
}
// Add all the items to an array
$items = array();
foreach ($rss as $item) {
$item['title'] = isset($item['title']) ? strip_tags($item['title']) : '';
$item['description'] = isset($item['description']) ? strip_tags($item['description'], empty($strip_preserve) ? '' : '<' . implode('><', $strip_preserve) . '>') : '';
$items[] = array('title' => $item['title'], 'href' => $item['link'], 'link' => $item['title'] == '' ? '' : ($item['link'] == '' ? $item['title'] : '<a href="' . $item['link'] . '" target="_blank" class="new_win">' . $item['title'] . '</a>'), 'content' => $limit > 0 ? Util::shorten_text($item['description'], $limit, true) : $item['description'], 'date' => !empty($item['pubdate']) ? standardTime(strtotime($item['pubdate']), '%d %B') : '');
}
// No items in the feed
if (empty($items)) {
echo '
', $txt['error_sp_invalid_feed'];
return;
} else {
$items[count($items) - 1]['is_last'] = true;
}
if ($show_content) {
echo '
//.........这里部分代码省略.........