本文整理汇总了PHP中obExit函数的典型用法代码示例。如果您正苦于以下问题:PHP obExit函数的具体用法?PHP obExit怎么用?PHP obExit使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了obExit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ArcadeSilverScore
function ArcadeSilverScore()
{
global $scripturl, $txt, $db_prefix, $context, $sourcedir, $modSettings, $smcFunc;
file_put_contents('./debug/' . sha1(serialize($_REQUEST)) . '.txt', print_r(array($_REQUEST, $_SESSION['arcade']['v2_play']), true));
ArcadeXMLOutput(array('test' => 'ok'));
obExit(false);
}
示例2: ArcadeVbPermRequest
function ArcadeVbPermRequest()
{
global $scripturl, $context, $modSettings, $smcFunc;
if (!($game = getGameInfo($_SESSION['arcade_play_vb3g'][$_POST['id']]))) {
return false;
}
$session =& $_SESSION['arcade_play_' . $game['id']];
$noteid = $_POST['note'] / ($_POST['fakekey'] * ceil($_POST['score']));
if ($_POST['id'] != $session['last_id'] || $noteid != $_POST['id'] || $_POST['gametime'] != $session['start_time']) {
ob_end_clean();
if (!empty($modSettings['enableCompressedOutput'])) {
@ob_start('ob_gzhandler');
} else {
ob_start();
}
echo '&validate=0';
obExit(false);
}
$session['end_time'] = microtime_float();
$session['score'] = $_POST['score'];
ob_end_clean();
if (!empty($modSettings['enableCompressedOutput'])) {
@ob_start('ob_gzhandler');
} else {
ob_start();
}
echo '&validate=1µone=', microtime_float(), '&result=OK';
obExit(false);
}
示例3: action_stats
/**
* Display some useful/interesting board statistics.
*
* What it does:
* - Gets all the statistics in order and puts them in.
* - Uses the Stats template and language file. (and main sub template.)
* - Requires the view_stats permission.
* - Accessed from ?action=stats.
*
* @uses Stats language file
* @uses Stats template, statistics sub template
*/
public function action_stats()
{
global $txt, $scripturl, $modSettings, $context;
// You have to be able to see these
isAllowedTo('view_stats');
// Page disabled - redirect them out
if (empty($modSettings['trackStats'])) {
fatal_lang_error('feature_disabled', true);
}
if (!empty($_REQUEST['expand'])) {
$context['robot_no_index'] = true;
$month = (int) substr($_REQUEST['expand'], 4);
$year = (int) substr($_REQUEST['expand'], 0, 4);
if ($year > 1900 && $year < 2200 && $month >= 1 && $month <= 12) {
$_SESSION['expanded_stats'][$year][] = $month;
}
} elseif (!empty($_REQUEST['collapse'])) {
$context['robot_no_index'] = true;
$month = (int) substr($_REQUEST['collapse'], 4);
$year = (int) substr($_REQUEST['collapse'], 0, 4);
if (!empty($_SESSION['expanded_stats'][$year])) {
$_SESSION['expanded_stats'][$year] = array_diff($_SESSION['expanded_stats'][$year], array($month));
}
}
// Just a lil' help from our friend :P
require_once SUBSDIR . '/Stats.subs.php';
// Handle the XMLHttpRequest.
if (isset($_REQUEST['xml'])) {
// Collapsing stats only needs adjustments of the session variables.
if (!empty($_REQUEST['collapse'])) {
obExit(false);
}
$context['sub_template'] = 'stats';
getDailyStats('YEAR(date) = {int:year} AND MONTH(date) = {int:month}', array('year' => $year, 'month' => $month));
$context['yearly'][$year]['months'][$month]['date'] = array('month' => sprintf('%02d', $month), 'year' => $year);
return;
}
// Stats it is
loadLanguage('Stats');
loadTemplate('Stats');
loadJavascriptFile('stats.js');
// Build the link tree......
$context['linktree'][] = array('url' => $scripturl . '?action=stats', 'name' => $txt['stats_center']);
// Prepare some things for the template page
$context['page_title'] = $context['forum_name'] . ' - ' . $txt['stats_center'];
$context['sub_template'] = 'statistics';
// These are the templates that will be used to render the statistics
$context['statistics_callbacks'] = array('general_statistics', 'top_statistics');
// Call each area of statics to load our friend $context
$this->loadGeneralStatistics();
$this->loadTopStatistics();
$this->loadMontlyActivity();
// Custom stats (just add a template_layer or another callback to add it to the page!)
call_integration_hook('integrate_forum_stats');
}
示例4: draftXmlReturn
/**
* Output a block of XML that contains the details of our draft.
*
* @param int $draft
*/
function draftXmlReturn($draft)
{
if (empty($draft)) {
return;
}
global $txt, $context;
header('Content-Type: text/xml; charset=UTF-8');
echo '<', '?xml version="1.0" encoding="UTF-8"?', '>
<response>
<lastsave id="', $draft, '"><![CDATA[', $txt['last_saved_on'], ': ', timeformat(time()), ']', ']></lastsave>
</response>';
obExit(false);
}
示例5: RelatedTopicsAdminBuildIndex
/**
* Related Topics
*
* @package RelatedTopics
* @author Niko Pahajoki http://madjoki.com/
* @version 1.5
* @license http://madjoki.com/smf-mods/license/ New-BSD
*/
function RelatedTopicsAdminBuildIndex()
{
global $smcFunc, $scripturl, $modSettings, $context, $txt;
loadTemplate('Admin');
loadLanguage('Admin');
if (!isset($context['relatedClass']) && !initRelated()) {
fatal_lang_error('no_methods_selected');
}
$context['step'] = empty($_REQUEST['step']) ? 0 : (int) $_REQUEST['step'];
if ($context['step'] == 0) {
// Clear caches
foreach ($context['relatedClass'] as $class) {
$class->recreateIndexTables();
}
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}related_topics');
}
$request = $smcFunc['db_query']('', '
SELECT MAX(id_topic)
FROM {db_prefix}topics');
list($max_topics) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
// How many topics to do per page load?
$perStep = 150;
$last = $context['step'] + $perStep;
// Search for topic ids between first and last which are not in ignored boards
$request = $smcFunc['db_query']('', '
SELECT t.id_topic
FROM {db_prefix}topics AS t
WHERE t.id_topic > {int:start}
AND t.id_topic <= {int:last}' . (!empty($context['rt_ignore']) ? '
AND t.id_board NOT IN({array_int:ignored})' : ''), array('start' => $context['step'], 'last' => $last, 'ignored' => $context['rt_ignore']));
$topics = array();
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$topics[] = $row['id_topic'];
}
$smcFunc['db_free_result']($request);
// Update topics
relatedUpdateTopics($topics, true);
if ($last >= $max_topics) {
redirectexit('action=admin;area=relatedtopics;sa=methods');
}
$context['sub_template'] = 'not_done';
$context['continue_get_data'] = '?action=admin;area=relatedtopics;sa=buildIndex;step=' . $last;
$context['continue_percent'] = round(100 * ($last / $max_topics));
$context['continue_post_data'] = '';
$context['continue_countdown'] = '2';
obExit();
}
示例6: GroupRequests
function GroupRequests()
{
global $txt, $context, $scripturl, $user_info, $sourcedir, $smcFunc, $modSettings, $language;
// Set up the template stuff...
$context['page_title'] = $txt['mc_group_requests'];
$context['sub_template'] = 'show_list';
// Verify we can be here.
if ($user_info['mod_cache']['gq'] == '0=1') {
isAllowedTo('manage_membergroups');
}
// Normally, we act normally...
$where = $user_info['mod_cache']['gq'] == '1=1' || $user_info['mod_cache']['gq'] == '0=1' ? $user_info['mod_cache']['gq'] : 'lgr.' . $user_info['mod_cache']['gq'];
$where_parameters = array();
// We've submitted?
if (isset($_POST[$context['session_var']]) && !empty($_POST['groupr']) && !empty($_POST['req_action'])) {
checkSession('post');
// Clean the values.
foreach ($_POST['groupr'] as $k => $request) {
$_POST['groupr'][$k] = (int) $request;
}
// If we are giving a reason (And why shouldn't we?), then we don't actually do much.
if ($_POST['req_action'] == 'reason') {
// Different sub template...
$context['sub_template'] = 'group_request_reason';
// And a limitation. We don't care that the page number bit makes no sense, as we don't need it!
$where .= ' AND lgr.id_request IN ({array_int:request_ids})';
$where_parameters['request_ids'] = $_POST['groupr'];
$context['group_requests'] = list_getGroupRequests(0, $modSettings['defaultMaxMessages'], 'lgr.id_request', $where, $where_parameters);
// Let obExit etc sort things out.
obExit();
} else {
// Get the details of all the members concerned...
$request = $smcFunc['db_query']('', '
SELECT lgr.id_request, lgr.id_member, lgr.id_group, mem.email_address, mem.id_group AS primary_group,
mem.additional_groups AS additional_groups, mem.lngfile, mem.member_name, mem.notify_types,
mg.hidden, mg.group_name
FROM {db_prefix}log_group_requests AS lgr
INNER JOIN {db_prefix}members AS mem ON (mem.id_member = lgr.id_member)
INNER JOIN {db_prefix}membergroups AS mg ON (mg.id_group = lgr.id_group)
WHERE ' . $where . '
AND lgr.id_request IN ({array_int:request_list})
ORDER BY mem.lngfile', array('request_list' => $_POST['groupr']));
$email_details = array();
$group_changes = array();
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$row['lngfile'] = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile'];
// If we are approving work out what their new group is.
if ($_POST['req_action'] == 'approve') {
// For people with more than one request at once.
if (isset($group_changes[$row['id_member']])) {
$row['additional_groups'] = $group_changes[$row['id_member']]['add'];
$row['primary_group'] = $group_changes[$row['id_member']]['primary'];
} else {
$row['additional_groups'] = explode(',', $row['additional_groups']);
}
// Don't have it already?
if ($row['primary_group'] == $row['id_group'] || in_array($row['id_group'], $row['additional_groups'])) {
continue;
}
// Should it become their primary?
if ($row['primary_group'] == 0 && $row['hidden'] == 0) {
$row['primary_group'] = $row['id_group'];
} else {
$row['additional_groups'][] = $row['id_group'];
}
// Add them to the group master list.
$group_changes[$row['id_member']] = array('primary' => $row['primary_group'], 'add' => $row['additional_groups']);
}
// Add required information to email them.
if ($row['notify_types'] != 4) {
$email_details[] = array('rid' => $row['id_request'], 'member_id' => $row['id_member'], 'member_name' => $row['member_name'], 'group_id' => $row['id_group'], 'group_name' => $row['group_name'], 'email' => $row['email_address'], 'language' => $row['lngfile']);
}
}
$smcFunc['db_free_result']($request);
// Remove the evidence...
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}log_group_requests
WHERE id_request IN ({array_int:request_list})', array('request_list' => $_POST['groupr']));
// Ensure everyone who is online gets their changes right away.
updateSettings(array('settings_updated' => time()));
if (!empty($email_details)) {
require_once $sourcedir . '/Subs-Post.php';
// They are being approved?
if ($_POST['req_action'] == 'approve') {
// Make the group changes.
foreach ($group_changes as $id => $groups) {
// Sanity check!
foreach ($groups['add'] as $key => $value) {
if ($value == 0 || trim($value) == '') {
unset($groups['add'][$key]);
}
}
$smcFunc['db_query']('', '
UPDATE {db_prefix}members
SET id_group = {int:primary_group}, additional_groups = {string:additional_groups}
WHERE id_member = {int:selected_member}', array('primary_group' => $groups['primary'], 'selected_member' => $id, 'additional_groups' => implode(',', $groups['add'])));
}
$lastLng = $user_info['language'];
foreach ($email_details as $email) {
$replacements = array('USERNAME' => $email['member_name'], 'GROUPNAME' => $email['group_name']);
//.........这里部分代码省略.........
示例7: BookOfUnknown
function BookOfUnknown()
{
global $context;
if (strpos($_GET['action'], 'mozilla') !== false && !$context['browser']['is_gecko']) {
redirectexit('http://www.getfirefox.com/');
} elseif (strpos($_GET['action'], 'mozilla') !== false) {
redirectexit('about:mozilla');
}
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '>
<head>
<title>The Book of Unknown, ', @$_GET['verse'] == '2:18' ? '2:18' : '4:16', '</title>
<style type="text/css">
em
{
font-size: 1.3em;
line-height: 0;
}
</style>
</head>
<body style="background-color: #444455; color: white; font-style: italic; font-family: serif;">
<div style="margin-top: 12%; font-size: 1.1em; line-height: 1.4; text-align: center;">';
if (@$_GET['verse'] == '2:18') {
echo '
Woe, it was that his name wasn\'t <em>known</em>, that he came in mystery, and was recognized by none. And it became to be in those days <em>something</em>. Something not yet <em id="unknown" name="[Unknown]">unknown</em> to mankind. And thus what was to be known the <em>secret project</em> began into its existence. Henceforth the opposition was only <em>weary</em> and <em>fearful</em>, for now their match was at arms against them.';
} else {
echo '
And it came to pass that the <em>unbelievers</em> dwindled in number and saw rise of many <em>proselytizers</em>, and the opposition found fear in the face of the <em>x</em> and the <em>j</em> while those who stood with the <em>something</em> grew stronger and came together. Still, this was only the <em>beginning</em>, and what lay in the future was <em id="unknown" name="[Unknown]">unknown</em> to all, even those on the right side.';
}
echo '
</div>
<div style="margin-top: 2ex; font-size: 2em; text-align: right;">';
if (@$_GET['verse'] == '2:18') {
echo '
from <span style="font-family: Georgia, serif;"><strong><a href="http://www.unknownbrackets.com/about:unknown" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 2:18</span>';
} else {
echo '
from <span style="font-family: Georgia, serif;"><strong><a href="http://www.unknownbrackets.com/about:unknown" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 4:16</span>';
}
echo '
</div>
</body>
</html>';
obExit(false);
}
示例8: redirectexit
function redirectexit($setLocation = '', $refresh = false)
{
global $scripturl, $context, $modSettings, $db_show_debug, $db_cache;
// In case we have mail to send, better do that - as obExit doesn't always quite make it...
if (!empty($context['flush_mail'])) {
AddMailQueue(true);
}
$add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:';
if (WIRELESS) {
// Add the scripturl on if needed.
if ($add) {
$setLocation = $scripturl . '?' . $setLocation;
}
$char = strpos($setLocation, '?') === false ? '?' : ';';
if (strpos($setLocation, '#') !== false) {
$setLocation = strtr($setLocation, array('#' => $char . WIRELESS_PROTOCOL . '#'));
} else {
$setLocation .= $char . WIRELESS_PROTOCOL;
}
} elseif ($add) {
$setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : '');
}
// Put the session ID in.
if (defined('SID') && SID != '') {
$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation);
} elseif (isset($_GET['debug'])) {
$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation);
}
if (!empty($modSettings['queryless_urls']) && (empty($context['server']['is_cgi']) || @ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && (!empty($context['server']['is_apache']) || !empty($context['server']['is_lighttpd']))) {
if (defined('SID') && SID != '') {
$setLocation = preg_replace_callback('~"' . preg_quote($scripturl, '/') . '\\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', 'fix_redirect_sid__preg_callback', $setLocation);
} else {
$setLocation = preg_replace_callback('~"' . preg_quote($scripturl, '/') . '\\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', 'fix_redirect_path__preg_callback', $setLocation);
}
}
// Maybe integrations want to change where we are heading?
call_integration_hook('integrate_redirect', array(&$setLocation, &$refresh));
// We send a Refresh header only in special cases because Location looks better. (and is quicker...)
if ($refresh && !WIRELESS) {
header('Refresh: 0; URL=' . strtr($setLocation, array(' ' => '%20')));
} else {
header('Location: ' . str_replace(' ', '%20', $setLocation));
}
// Debugging.
if (isset($db_show_debug) && $db_show_debug === true) {
$_SESSION['debug_redirect'] = $db_cache;
}
obExit(false);
}
示例9: packageRequireFTP
//.........这里部分代码省略.........
// This looks odd, but it's an attempt to work around PHP suExec.
if (!file_exists($file)) {
mktree(dirname($file), 0755);
@touch($file);
@chmod($file, 0755);
}
if (!@is_writable($file)) {
@chmod($file, 0777);
}
if (!@is_writable(dirname($file))) {
@chmod(dirname($file), 0777);
}
if (@is_writable($file)) {
unset($files[$k]);
}
}
return $files;
} elseif (isset($_SESSION['pack_ftp'])) {
// Load the file containing the ftp_connection class.
loadClassFile('Class-Package.php');
$package_ftp = new ftp_connection($_SESSION['pack_ftp']['server'], $_SESSION['pack_ftp']['port'], $_SESSION['pack_ftp']['username'], package_crypt($_SESSION['pack_ftp']['password']));
if ($files === null) {
return array();
}
foreach ($files as $k => $file) {
$ftp_file = strtr($file, array($_SESSION['pack_ftp']['root'] => ''));
// This looks odd, but it's an attempt to work around PHP suExec.
if (!file_exists($file)) {
mktree(dirname($file), 0755);
$package_ftp->create_file($ftp_file);
$package_ftp->chmod($ftp_file, 0755);
}
if (!@is_writable($file)) {
$package_ftp->chmod($ftp_file, 0777);
}
if (!@is_writable(dirname($file))) {
$package_ftp->chmod(dirname($ftp_file), 0777);
}
if (@is_writable($file)) {
unset($files[$k]);
}
}
return $files;
}
if (isset($_POST['ftp_none'])) {
$_SESSION['pack_ftp'] = false;
$files = packageRequireFTP($destination_url, $files, $return);
return $files;
} elseif (isset($_POST['ftp_username'])) {
loadClassFile('Class-Package.php');
$ftp = new ftp_connection($_POST['ftp_server'], $_POST['ftp_port'], $_POST['ftp_username'], $_POST['ftp_password']);
if ($ftp->error === false) {
// Common mistake, so let's try to remedy it...
if (!$ftp->chdir($_POST['ftp_path'])) {
$ftp_error = $ftp->last_message;
$ftp->chdir(preg_replace('~^/home[2]?/[^/]+?~', '', $_POST['ftp_path']));
}
}
}
if (!isset($ftp) || $ftp->error !== false) {
if (!isset($ftp)) {
loadClassFile('Class-Package.php');
$ftp = new ftp_connection(null);
} elseif ($ftp->error !== false && !isset($ftp_error)) {
$ftp_error = $ftp->last_message === null ? '' : $ftp->last_message;
}
list($username, $detect_path, $found_path) = $ftp->detect_path($boarddir);
if ($found_path) {
$_POST['ftp_path'] = $detect_path;
} elseif (!isset($_POST['ftp_path'])) {
$_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path;
}
if (!isset($_POST['ftp_username'])) {
$_POST['ftp_username'] = $username;
}
$context['package_ftp'] = array('server' => isset($_POST['ftp_server']) ? $_POST['ftp_server'] : (isset($modSettings['package_server']) ? $modSettings['package_server'] : 'localhost'), 'port' => isset($_POST['ftp_port']) ? $_POST['ftp_port'] : (isset($modSettings['package_port']) ? $modSettings['package_port'] : '21'), 'username' => isset($_POST['ftp_username']) ? $_POST['ftp_username'] : (isset($modSettings['package_username']) ? $modSettings['package_username'] : ''), 'path' => $_POST['ftp_path'], 'error' => empty($ftp_error) ? null : $ftp_error, 'destination' => $destination_url);
// If we're returning dump out here.
if ($return) {
return $files;
}
$context['page_title'] = $txt['package_ftp_necessary'];
$context['sub_template'] = 'ftp_required';
obExit();
} else {
if (!in_array($_POST['ftp_path'], array('', '/'))) {
$ftp_root = strtr($boarddir, array($_POST['ftp_path'] => ''));
if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || substr($_POST['ftp_path'], 0, 1) == '/')) {
$ftp_root = substr($ftp_root, 0, -1);
}
} else {
$ftp_root = $boarddir;
}
$_SESSION['pack_ftp'] = array('server' => $_POST['ftp_server'], 'port' => $_POST['ftp_port'], 'username' => $_POST['ftp_username'], 'password' => package_crypt($_POST['ftp_password']), 'path' => $_POST['ftp_path'], 'root' => $ftp_root);
if (!isset($modSettings['package_path']) || $modSettings['package_path'] != $_POST['ftp_path']) {
updateSettings(array('package_path' => $_POST['ftp_path']));
}
$files = packageRequireFTP($destination_url, $files, $return);
}
return $files;
}
示例10: pauseSignatureApplySettings
/**
* Just pause the signature applying thing.
*
* @todo Move to subs file
* @todo Merge with other pause functions?
* pausePermsSave(), pausAttachmentMaintenance(), pauseRepairProcess()
*
* @param int $applied_sigs
*/
function pauseSignatureApplySettings($applied_sigs)
{
global $context, $txt, $sig_start;
// Try get more time...
@set_time_limit(600);
if (function_exists('apache_reset_timeout')) {
@apache_reset_timeout();
}
// Have we exhausted all the time we allowed?
if (time() - array_sum(explode(' ', $sig_start)) < 3) {
return;
}
$context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $applied_sigs . ';' . $context['session_var'] . '=' . $context['session_id'];
$context['page_title'] = $txt['not_done_title'];
$context['continue_post_data'] = '';
$context['continue_countdown'] = '2';
$context['sub_template'] = 'not_done';
// Specific stuff to not break this template!
$context[$context['admin_menu_name']]['current_subsection'] = 'sig';
// Get the right percent.
$context['continue_percent'] = round($applied_sigs / $context['max_member'] * 100);
// Never more than 100%!
$context['continue_percent'] = min($context['continue_percent'], 100);
obExit();
}
示例11: RequestMembers
/**
* Outputs each member name on its own line.
* - used by javascript to find members matching the request.
*/
function RequestMembers()
{
global $user_info, $txt, $smcFunc;
checkSession('get');
$_REQUEST['search'] = $smcFunc['htmlspecialchars']($_REQUEST['search']) . '*';
$_REQUEST['search'] = trim($smcFunc['strtolower']($_REQUEST['search']));
$_REQUEST['search'] = strtr($_REQUEST['search'], array('%' => '\\%', '_' => '\\_', '*' => '%', '?' => '_', '&' => '&'));
if (function_exists('iconv')) {
header('Content-Type: text/plain; charset=UTF-8');
}
$request = $smcFunc['db_query']('', '
SELECT real_name
FROM {db_prefix}members
WHERE real_name LIKE {string:search}' . (isset($_REQUEST['buddies']) ? '
AND id_member IN ({array_int:buddy_list})' : '') . '
AND is_activated IN (1, 11)
LIMIT ' . ($smcFunc['strlen']($_REQUEST['search']) <= 2 ? '100' : '800'), array('buddy_list' => $user_info['buddies'], 'search' => $_REQUEST['search']));
while ($row = $smcFunc['db_fetch_assoc']($request)) {
if (function_exists('iconv')) {
$utf8 = iconv($txt['lang_character_set'], 'UTF-8', $row['real_name']);
if ($utf8) {
$row['real_name'] = $utf8;
}
}
$row['real_name'] = strtr($row['real_name'], array('&' => '&', '<' => '<', '>' => '>', '"' => '"'));
if (preg_match('~&#\\d+;~', $row['real_name']) != 0) {
$fixchar = create_function('$n', '
if ($n < 128)
return chr($n);
elseif ($n < 2048)
return chr(192 | $n >> 6) . chr(128 | $n & 63);
elseif ($n < 65536)
return chr(224 | $n >> 12) . chr(128 | $n >> 6 & 63) . chr(128 | $n & 63);
else
return chr(240 | $n >> 18) . chr(128 | $n >> 12 & 63) . chr(128 | $n >> 6 & 63) . chr(128 | $n & 63);');
$row['real_name'] = preg_replace('~&#(\\d+);~e', '$fixchar(\'$1\')', $row['real_name']);
}
echo $row['real_name'], "\n";
}
$smcFunc['db_free_result']($request);
obExit(false);
}
示例12: TPdownloadme
//.........这里部分代码省略.........
// can we actually download?
if ($show == 1 || allowedTo('tp_dlmanager')) {
$now = time();
$year = (int) date("Y", $now);
$week = (int) date("W", $now);
// update weekly views
$req = $smcFunc['db_query']('', '
SELECT id FROM {db_prefix}tp_dldata
WHERE year = {int:year}
AND week = {int:week}
AND item = {int:item}', array('year' => $year, 'week' => $week, 'item' => $item));
if ($smcFunc['db_num_rows']($req) > 0) {
$row = $smcFunc['db_fetch_assoc']($req);
$smcFunc['db_query']('', '
UPDATE {db_prefix}tp_dldata
SET downloads = downloads + 1
WHERE id = {int:dlitem}', array('dlitem' => $row['id']));
} else {
$smcFunc['db_insert']('INSERT', '{db_prefix}tp_dldata', array('week' => 'int', 'year' => 'int', 'downloads' => 'int', 'item' => 'int'), array($week, $year, 1, $item), array('id'));
}
$smcFunc['db_query']('', '
UPDATE LOW_PRIORITY {db_prefix}tp_dlmanager
SET downloads = downloads + 1
WHERE id = {int:item} LIMIT 1', array('item' => $item));
ob_end_clean();
if (!empty($modSettings['enableCompressedOutput']) && @version_compare(PHP_VERSION, '4.2.0') >= 0 && @filesize($filename) <= 4194304) {
@ob_start('ob_gzhandler');
} else {
ob_start();
header('Content-Encoding: none');
}
if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime(array_shift(explode(';', $_SERVER['HTTP_IF_MODIFIED_SINCE']))) >= filemtime($filename)) {
ob_end_clean();
header('HTTP/1.1 304 Not Modified');
exit;
}
// Send the attachment headers.
header('Pragma: no-cache');
header('Cache-Control: max-age=' . 10 . ', private');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', FALSE);
if (!$context['browser']['is_gecko']) {
header('Content-Transfer-Encoding: binary');
}
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($filename)) . ' GMT');
header('Accept-Ranges: bytes');
header('Set-Cookie:');
header('Connection: close');
header('Content-Disposition: attachment; filename="' . $newname . '"');
header('Content-Type: application/octet-stream');
if (filesize($filename) != 0) {
$size = @getimagesize($filename);
if (!empty($size) && $size[2] > 0 && $size[2] < 4) {
header('Content-Type: image/' . ($size[2] != 1 ? $size[2] != 2 ? 'png' : 'jpeg' : 'gif'));
}
}
if (empty($modSettings['enableCompressedOutput']) || filesize($filename) > 4194304) {
header('Content-Length: ' . filesize($filename));
}
@set_time_limit(0);
if (in_array(substr($real_filename, -4), array('.txt', '.css', '.htm', '.php', '.xml'))) {
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) {
$callback = create_function('$buffer', 'return preg_replace(\'~[\\r]?\\n~\', "\\r\\n", $buffer);');
} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
$callback = create_function('$buffer', 'return preg_replace(\'~[\\r]?\\n~\', "\\r", $buffer);');
} else {
$callback = create_function('$buffer', 'return preg_replace(\'~\\r~\', "\\r\\n", $buffer);');
}
}
// Since we don't do output compression for files this large...
if (filesize($filename) > 4194304) {
// Forcibly end any output buffering going on.
if (function_exists('ob_get_level')) {
while (@ob_get_level() > 0) {
@ob_end_clean();
}
} else {
@ob_end_clean();
@ob_end_clean();
@ob_end_clean();
}
$fp = fopen($filename, 'rb');
while (!feof($fp)) {
if (isset($callback)) {
echo $callback(fread($fp, 8192));
} else {
echo fread($fp, 8192);
}
flush();
}
fclose($fp);
} elseif (isset($callback) || @readfile($filename) == null) {
echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename);
}
obExit(false);
} else {
redirectexit('action=tpmod;dl');
}
}
示例13: iCalDownload
function iCalDownload()
{
global $smcFunc, $sourcedir, $forum_version, $context, $modSettings;
// Goes without saying that this is required.
if (!isset($_REQUEST['eventid'])) {
fatal_lang_error('no_access', false);
}
// This is kinda wanted.
require_once $sourcedir . '/Subs-Calendar.php';
// Load up the event in question and check it exists.
$event = getEventProperties($_REQUEST['eventid']);
if ($event === false) {
fatal_lang_error('no_access', false);
}
// Check the title isn't too long - iCal requires some formatting if so.
$title = str_split($event['title'], 30);
foreach ($title as $id => $line) {
if ($id != 0) {
$title[$id] = ' ' . $title[$id];
}
$title[$id] .= "\n";
}
// Format the date.
$date = $event['year'] . '-' . ($event['month'] < 10 ? '0' . $event['month'] : $event['month']) . '-' . ($event['day'] < 10 ? '0' . $event['day'] : $event['day']) . 'T';
$date .= '1200:00:00Z';
// This is what we will be sending later.
$filecontents = '';
$filecontents .= 'BEGIN:VCALENDAR' . "\n";
$filecontents .= 'VERSION:2.0' . "\n";
$filecontents .= 'PRODID:-//SimpleMachines//SMF ' . (empty($forum_version) ? 1.0 : strtr($forum_version, array('SMF ' => ''))) . '//EN' . "\n";
$filecontents .= 'BEGIN:VEVENT' . "\n";
$filecontents .= 'DTSTART:' . $date . "\n";
$filecontents .= 'DTEND:' . $date . "\n";
$filecontents .= 'SUMMARY:' . implode('', $title);
$filecontents .= 'END:VEVENT' . "\n";
$filecontents .= 'END:VCALENDAR';
// Send some standard headers.
ob_end_clean();
if (!empty($modSettings['enableCompressedOutput'])) {
@ob_start('ob_gzhandler');
} else {
ob_start();
}
// Send the file headers
header('Pragma: ');
header('Cache-Control: no-cache');
if (!$context['browser']['is_gecko']) {
header('Content-Transfer-Encoding: binary');
}
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . 'GMT');
header('Accept-Ranges: bytes');
header('Connection: close');
header('Content-Disposition: attachment; filename=' . $event['title'] . '.ics');
// How big is it?
if (empty($modSettings['enableCompressedOutput'])) {
header('Content-Length: ' . $smcFunc['strlen']($filecontents));
}
// This is a calendar item!
header('Content-Type: text/calendar');
// Chuck out the card.
echo $filecontents;
// Off we pop - lovely!
obExit(false);
}
示例14: action_verificationcode
/**
* Show the verification code or let it hear.
* Accessed by ?action=verificationcode
*/
public function action_verificationcode()
{
global $context, $scripturl;
$verification_id = isset($_GET['vid']) ? $_GET['vid'] : '';
$code = $verification_id && isset($_SESSION[$verification_id . '_vv']) ? $_SESSION[$verification_id . '_vv']['code'] : (isset($_SESSION['visual_verification_code']) ? $_SESSION['visual_verification_code'] : '');
// Somehow no code was generated or the session was lost.
if (empty($code)) {
header('Content-Type: image/gif');
die("GIF89a€!ù,D;");
} elseif (isset($_REQUEST['sound'])) {
loadLanguage('Login');
loadTemplate('Register');
$context['verification_sound_href'] = $scripturl . '?action=verificationcode;rand=' . md5(mt_rand()) . ($verification_id ? ';vid=' . $verification_id : '') . ';format=.wav';
$context['sub_template'] = 'verification_sound';
Template_Layers::getInstance()->removeAll();
obExit();
} elseif (empty($_REQUEST['format'])) {
require_once SUBSDIR . '/Graphics.subs.php';
if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code)) {
header('HTTP/1.1 400 Bad Request');
} elseif (isset($_REQUEST['letter'])) {
$_REQUEST['letter'] = (int) $_REQUEST['letter'];
if ($_REQUEST['letter'] > 0 && $_REQUEST['letter'] <= strlen($code) && !showLetterImage(strtolower($code[$_REQUEST['letter'] - 1]))) {
header('Content-Type: image/gif');
die("GIF89a€!ù,D;");
}
} else {
header('Content-Type: image/gif');
die("GIF89a€!ù,D;");
}
} elseif ($_REQUEST['format'] === '.wav') {
require_once SUBSDIR . '/Sound.subs.php';
if (!createWaveFile($code)) {
header('HTTP/1.1 400 Bad Request');
}
}
// We all die one day...
die;
}
示例15: DisplayAdminFile
/**
* Get one of the admin information files from Simple Machines.
*/
function DisplayAdminFile()
{
global $context, $modSettings, $smcFunc;
setMemoryLimit('32M');
if (empty($_REQUEST['filename']) || !is_string($_REQUEST['filename'])) {
fatal_lang_error('no_access', false);
}
$request = $smcFunc['db_query']('', '
SELECT data, filetype
FROM {db_prefix}admin_info_files
WHERE filename = {string:current_filename}
LIMIT 1', array('current_filename' => $_REQUEST['filename']));
if ($smcFunc['db_num_rows']($request) == 0) {
fatal_lang_error('admin_file_not_found', true, array($_REQUEST['filename']));
}
list($file_data, $filetype) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
// @todo Temp
// Figure out if sesc is still being used.
if (strpos($file_data, ';sesc=') !== false) {
$file_data = '
if (!(\'smfForum_sessionvar\' in window))
window.smfForum_sessionvar = \'sesc\';
' . strtr($file_data, array(';sesc=' => ';\' + window.smfForum_sessionvar + \'='));
}
$context['template_layers'] = array();
// Lets make sure we aren't going to output anything nasty.
@ob_end_clean();
if (!empty($modSettings['enableCompressedOutput'])) {
@ob_start('ob_gzhandler');
} else {
@ob_start();
}
// Make sure they know what type of file we are.
header('Content-Type: ' . $filetype);
echo $file_data;
obExit(false);
}