本文整理汇总了PHP中log_hit函数的典型用法代码示例。如果您正苦于以下问题:PHP log_hit函数的具体用法?PHP log_hit怎么用?PHP log_hit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log_hit函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveComment
function saveComment()
{
global $siteurl, $comments_moderate, $comments_sendmail, $txpcfg, $comments_disallow_images, $prefs;
$ref = serverset('HTTP_REFERRER');
$in = getComment();
$evaluator =& get_comment_evaluator();
extract($in);
if (!checkCommentsAllowed($parentid)) {
txp_die(gTxt('comments_closed'), '403');
}
$ip = serverset('REMOTE_ADDR');
if (!checkBan($ip)) {
txp_die(gTxt('you_have_been_banned'), '403');
}
$blacklisted = is_blacklisted($ip);
if ($blacklisted) {
txp_die(gTxt('your_ip_is_blacklisted_by' . ' ' . $blacklisted), '403');
}
$web = clean_url($web);
$email = clean_url($email);
if ($remember == 1 || ps('checkbox_type') == 'forget' && ps('forget') != 1) {
setCookies($name, $email, $web);
} else {
destroyCookies();
}
$name = doSlash(strip_tags(deEntBrackets($name)));
$web = doSlash(strip_tags(deEntBrackets($web)));
$email = doSlash(strip_tags(deEntBrackets($email)));
$message = substr(trim($message), 0, 65535);
$message2db = doSlash(markup_comment($message));
$isdup = safe_row("message,name", "txp_discuss", "name='{$name}' and message='{$message2db}' and ip='" . doSlash($ip) . "'");
if ($prefs['comments_require_name'] && !trim($name) || $prefs['comments_require_email'] && !trim($email) || !trim($message)) {
$evaluator->add_estimate(RELOAD, 1);
// The error-messages are added in the preview-code
}
if ($isdup) {
$evaluator->add_estimate(RELOAD, 1);
}
// FIXME? Tell the user about dupe?
if ($evaluator->get_result() != RELOAD && checkNonce($nonce)) {
callback_event('comment.save');
$visible = $evaluator->get_result();
if ($visible != RELOAD) {
$parentid = assert_int($parentid);
$rs = safe_insert("txp_discuss", "parentid = {$parentid},\n\t\t\t\t\t name\t\t = '{$name}',\n\t\t\t\t\t email\t = '{$email}',\n\t\t\t\t\t web\t\t = '{$web}',\n\t\t\t\t\t ip\t\t = '" . doSlash($ip) . "',\n\t\t\t\t\t message = '{$message2db}',\n\t\t\t\t\t visible = " . intval($visible) . ",\n\t\t\t\t\t posted\t = now()");
if ($rs) {
safe_update("txp_discuss_nonce", "used = 1", "nonce='" . doSlash($nonce) . "'");
if ($prefs['comment_means_site_updated']) {
update_lastmod();
}
if ($comments_sendmail) {
mail_comment($message, $name, $email, $web, $parentid, $rs);
}
$updated = update_comments_count($parentid);
$backpage = substr($backpage, 0, $prefs['max_url_len']);
$backpage = preg_replace("/[\n\r#].*\$/s", '', $backpage);
$backpage = preg_replace("#(https?://[^/]+)/.*\$#", "\$1", hu) . $backpage;
if (defined('PARTLY_MESSY') and PARTLY_MESSY) {
$backpage = permlinkurl_id($parentid);
}
$backpage .= (strstr($backpage, '?') ? '&' : '?') . 'commented=' . ($visible == VISIBLE ? '1' : '0');
txp_status_header('302 Found');
if ($comments_moderate) {
header('Location: ' . $backpage . '#txpCommentInputForm');
} else {
header('Location: ' . $backpage . '#c' . sprintf("%06s", $rs));
}
log_hit('302');
$evaluator->write_trace();
exit;
}
}
}
// Force another Preview
$_POST['preview'] = RELOAD;
//$evaluator->write_trace();
}
示例2: handle_lastmod
function handle_lastmod($unix_ts = NULL, $exit = 1)
{
global $prefs;
extract($prefs);
if ($send_lastmod and $production_status == 'live') {
$unix_ts = get_lastmod($unix_ts);
# make sure lastmod isn't in the future
$unix_ts = min($unix_ts, time());
# or too far in the past (7 days)
$unix_ts = max($unix_ts, time() - 3600 * 24 * 7);
$last = safe_strftime('rfc822', $unix_ts, 1);
header("Last-Modified: {$last}");
header('Cache-Control: no-cache');
$hims = serverset('HTTP_IF_MODIFIED_SINCE');
if ($hims and @strtotime($hims) >= $unix_ts) {
log_hit('304');
if (!$exit) {
return array('304', $last);
}
txp_status_header('304 Not Modified');
# some mod_deflate versions have a bug that breaks subsequent
# requests when keepalive is used. dropping the connection
# is the only reliable way to fix this.
if (empty($lastmod_keepalive)) {
header('Connection: close');
}
header('Content-Length: 0');
# discard all output
while (@ob_end_clean()) {
}
exit;
}
if (!$exit) {
return array('200', $last);
}
}
}
示例3: output_file_download
function output_file_download($filename)
{
global $file_error, $file_base_path, $pretext;
callback_event('file_download');
if (!isset($file_error)) {
$filename = sanitizeForFile($filename);
$fullpath = build_file_path($file_base_path, $filename);
if (is_file($fullpath)) {
// Discard any error PHP messages.
ob_clean();
$filesize = filesize($fullpath);
$sent = 0;
header('Content-Description: File Download');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $filename . '"; size = "' . $filesize . '"');
// Fix for IE6 PDF bug on servers configured to send cache headers.
header('Cache-Control: private');
@ini_set("zlib.output_compression", "Off");
@set_time_limit(0);
@ignore_user_abort(true);
if ($file = fopen($fullpath, 'rb')) {
while (!feof($file) and connection_status() == 0) {
echo fread($file, 1024 * 64);
$sent += 1024 * 64;
ob_flush();
flush();
}
fclose($file);
// Record download.
if (connection_status() == 0 and !connection_aborted()) {
safe_update('txp_file', "downloads = downloads + 1", "id = " . intval($pretext['id']));
} else {
$pretext['request_uri'] .= $sent >= $filesize ? '#aborted' : "#aborted-at-" . floor($sent * 100 / $filesize) . "%";
}
log_hit('200');
}
} else {
$file_error = 404;
}
}
// Deal with error.
if (isset($file_error)) {
switch ($file_error) {
case 403:
txp_die(gTxt('403_forbidden'), '403');
break;
case 404:
txp_die(gTxt('404_not_found'), '404');
break;
default:
txp_die(gTxt('500_internal_server_error'), '500');
break;
}
}
}
示例4: txp_die
break;
case 404:
txp_die(gTxt('404_not_found'), '404');
break;
default:
txp_die(gTxt('500_internal_server_error'), '500');
break;
}
}
// download done
exit(0);
}
// send 304 Not Modified if appropriate
handle_lastmod();
// log the page view
log_hit($status);
// -------------------------------------------------------------
function preText($s, $prefs)
{
extract($prefs);
callback_event('pretext');
if (gps('rss')) {
include txpath . '/publish/rss.php';
exit(rss());
}
if (gps('atom')) {
include txpath . '/publish/atom.php';
exit(atom());
}
// set messy variables
$out = makeOut('id', 's', 'c', 'q', 'pg', 'p', 'month', 'author');
示例5: handle_lastmod
/**
* Sends and handles a lastmod header.
*
* @param int|null $unix_ts The last modification date as a UNIX timestamp
* @param bool $exit If TRUE, terminates the script
* @return array|null Array of sent HTTP status and the lastmod header, or NULL
* @package Pref
*/
function handle_lastmod($unix_ts = null, $exit = true)
{
if (get_pref('send_lastmod') && get_pref('production_status') == 'live') {
$unix_ts = get_lastmod($unix_ts);
// Make sure lastmod isn't in the future.
$unix_ts = min($unix_ts, time());
// Or too far in the past (7 days).
$unix_ts = max($unix_ts, time() - 3600 * 24 * 7);
$last = safe_strftime('rfc822', $unix_ts, 1);
header("Last-Modified: {$last}");
header('Cache-Control: no-cache');
$hims = serverSet('HTTP_IF_MODIFIED_SINCE');
if ($hims and @strtotime($hims) >= $unix_ts) {
log_hit('304');
if (!$exit) {
return array('304', $last);
}
txp_status_header('304 Not Modified');
// Some mod_deflate versions have a bug that breaks subsequent
// requests when keepalive is used. dropping the connection
// is the only reliable way to fix this.
if (!get_pref('lastmod_keepalive')) {
header('Connection: close');
}
header('Content-Length: 0');
// Discard all output.
while (@ob_end_clean()) {
}
exit;
}
if (!$exit) {
return array('200', $last);
}
}
}
示例6: _textpattern
//.........这里部分代码省略.........
$pretext_replacement['page'] = @$des_page ? $des_page : $section_settings['page'];
$pretext_replacement['css'] = $section_settings['css'];
$this->matched_permlink = $pretext_replacement;
global $permlink_mode;
if (in_array($prefs['permlink_mode'], array('id_title', 'section_id_title')) && @$pretext_replacement['pg'] && !@$pretext_replacement['id']) {
$pretext_replacement['id'] = '';
$pretext_replacement['is_article_list'] = true;
}
// Merge pretext_replacement with pretext
$pretext = array_merge($pretext, $pretext_replacement);
if (is_numeric(@$pretext['id'])) {
$a = safe_row('*, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod', 'textpattern', 'ID=' . intval($pretext['id']) . ' and Status >= 4');
populateArticleData($a);
}
// Export required values to the global namespace
foreach (array('id', 's', 'c', 'pg', 'is_article_list', 'prev_id', 'prev_title', 'next_id', 'next_title', 'css') as $key) {
if (array_key_exists($key, $pretext)) {
$GLOBALS[$key] = $pretext[$key];
}
}
if (count($this->matched_permlink) || @$mt_redirect) {
$pl_index = $pretext['permlink_id'];
if (!@$mt_redirect || !$this->pref('redirect_mt_style_links')) {
$pl = $this->get_permlink($pretext['permlink_id']);
$pl_index = @$pl['settings']['des_permlink'];
}
if (@$pretext['id'] && $pl_index) {
if (count($this->get_permlink($pl_index)) > 0) {
ob_clean();
global $siteurl;
$rs = safe_row('*, ID as thisid, unix_timestamp(Posted) as posted', 'textpattern', "ID = '{$pretext['id']}'");
$host = rtrim(str_replace(rtrim(doStrip($pretext['subpath']), '/'), '', hu), '/');
$this->redirect($host . $this->_permlinkurl($rs, PERMLINKURL, $pl_index), $this->pref('permlink_redirect_http_status'));
}
} else {
if ($url = @$pl['settings']['des_location']) {
ob_clean();
$this->redirect($url, $this->pref('url_redirect_http_status'));
}
}
}
if (@$pretext['rss']) {
if (@$pretext['s']) {
$_POST['section'] = $pretext['s'];
}
if (@$pretext['c']) {
$_POST['category'] = $pretext['c'];
}
ob_clean();
include txpath . '/publish/rss.php';
exit(rss());
}
if (@$pretext['atom']) {
if (@$pretext['s']) {
$_POST['section'] = $pretext['s'];
}
if (@$pretext['c']) {
$_POST['category'] = $pretext['c'];
}
ob_clean();
include txpath . '/publish/atom.php';
exit(atom());
}
$this->debug('Pretext ' . print_r($pretext, 1));
} else {
$this->debug('NO CHANGES MADE');
}
// Log this page hit
if (@$orginial_status == 404) {
log_hit($pretext['status']);
}
// Start output buffering and pseudo callback to textpattern_end
ob_start(array(&$this, '_textpattern_end_callback'));
// TxP 4.0.5 (r2436) introduced the textpattern_end callback making the following redundant
$version = array_sum(array_map(create_function('$line', 'if (preg_match(\'/^\\$' . 'LastChangedRevision: (\\w+) \\$/\', $line, $match)) return $match[1];'), @file(txpath . '/publish.php')));
if ($version >= '2436') {
return;
}
// Remove the plugin callbacks which have already been called
function filter_callbacks($c)
{
if ($c['event'] != 'textpattern') {
return true;
}
if (@$c['function'][0]->plugin_name == 'gbp_permanent_links' && @$c['function'][1] == '_textpattern') {
$GLOBALS['gbp_found_self'] = true;
return false;
}
return @$GLOBALS['gbp_found_self'];
}
$plugin_callback = array_filter($plugin_callback, 'filter_callbacks');
unset($GLOBALS['gbp_found_self']);
// Re-call textpattern
textpattern();
// Call custom textpattern_end callback
$this->_textpattern_end();
// textpattern() has run, kill the connection
die;
}
}
示例7: handle_lastmod
function handle_lastmod($unix_ts = NULL, $exit = 1)
{
global $prefs;
extract($prefs);
if ($send_lastmod and $production_status == 'live') {
$unix_ts = get_lastmod($unix_ts);
# make sure lastmod isn't in the future
$unix_ts = min($unix_ts, time());
# or too far in the past (7 days)
$unix_ts = max($unix_ts, time() - 3600 * 24 * 7);
$last = safe_strftime('rfc822', $unix_ts, 1);
header("Last-Modified: {$last}");
header('Cache-Control: no-cache');
$hims = serverset('HTTP_IF_MODIFIED_SINCE');
if ($hims and @strtotime($hims) >= $unix_ts) {
log_hit('304');
if (!$exit) {
return array('304', $last);
}
txp_status_header('304 Not Modified');
# header('Connection: close');
header('Content-Length: 0');
# discard all output
while (@ob_end_clean()) {
}
exit;
}
if (!$exit) {
return array('200', $last);
}
}
}