javascript - PHP 计数器消失/重新出现

标签 javascript counter hit

我下载了一个脚本来在我网站的两个页面上运行一个非常基本的计数器。自 2009 年 4 月以来运行良好,但在过去的三周内它会突然消失,然后偶尔会重新出现。这周是每一天。起初计数器只是消失了,现在除了横幅之外,带有计数器的页面不会加载。该页面最终会加载,有时最多需要五分钟。但是没有柜台显示。那是很久以后的事了。然后它可以再次消失!

[ http://www.thepenvro.com/][1]是主页 然后,如果您单击“新闻”,则单击“社会事件新闻”,这是另一个有计数器的页面。 (我们正在尝试查看谁对重聚信息感兴趣)。页面不稳定。它们要么没问题,要么它们在那里但缺少两页左下角的计数器,或者页面将只显示没有页面内容或计数器的标题。排名不分先后。

我已经进入我网站的服务器端并重置脚本(Streamline.net tekkie 告诉我这样做)。它似乎没有帮助,但时不时地想知道这是否只是巧合。

它会影响另一个脚本。我有一个很好用的电子邮件表单,但是当此计数器消失时,它会降低 联系人 页面上的表单电子邮件功能。我在表单底部放了一条注释,供访问者在收到错误消息时发送电子邮件。当您设法获取 SUBMIT 以更改屏幕时,完整的错误消息是:

FastCGI Error
The FastCGI Handler was unable to process the request. 
Error Details:
The FastCGI pool queue is full 
Error Number: 4 (0x80070004). 
Error Description: The system cannot open the file. 
HTTP Error 500 - Server Error.
Internet Information Services (IIS)

Streamline asks me to replicate the error...I can't! I can only give them what I am posting here and screenshots. So I don't have a clue if it's my script or them. The script for the counter is below. It was something I purchased as well. I first thought maybe it was IE8 that was causing the trouble, but the same problem shows in Firefox.

One last note....It's not the form to email that's a problem as I have that also running in one of the sub-domain's of the site and there is NO trouble there. But I do not have the counter running anywhere on the sub-domain either. I have all the same features for the main and sub-domain.

Thank you for any help...I am a complete novice so any solutions will be gratefully received. We are doing the publicity for our reunion in May and I have a big email campaign after Christmas to get out and I don't want the site all buggered up. If there is an alternative counter or if the version's php I have is too old, I am happy to purchase a better one from a reputable source.

<?php
/*******************************************************************************
*  Title: PHP hit counter (PHPcount)
*  Version: 1.2 @ October 26, 2007
*  Author: Klemen Stirn
*  Website: http://www.phpjunkyard.com
********************************************************************************
*  COPYRIGHT NOTICE
*  Copyright 2004-2007 Klemen Stirn. All Rights Reserved.

*******************************************************************************/

// SETUP YOUR COUNTER
// Detailed information found in the readme.htm file

// Count UNIQUE visitors ONLY? 1 = YES, 0 = NO
$count_unique = 1;
// Number of hours a visitor is considered as "unique"
$unique_hours = 1;
// Minimum number of digits shown (zero-padding). Set to 0 to disable.
$min_digits = 0;

#############################
#     DO NOT EDIT BELOW     #
#############################

/* Turn error notices off */
error_reporting(E_ALL ^ E_NOTICE);

/* Get page and log file names */
$page = input($_GET['page']) or die('ERROR: Missing page ID');
$logfile = 'logs/' . $page . '.txt';

   /* Does the log exist? */
   if (file_exists($logfile)) {

    /* Get current count */
    $count = trim(file_get_contents($logfile)) or $count = 0;

    if ($count_unique==0 || $_COOKIE['counter_unique']!=$page) {
    /* Increase the count by 1 */
    $count = $count + 1;
    $fp = @fopen($logfile,'w+') or die('ERROR: Can\'t write to the log file 
   ('.$logfile.'), please make sure this file exists and is CHMOD to 666 (rw-rw-rw-)!');
    flock($fp, LOCK_EX);
    fputs($fp, $count);
    flock($fp, LOCK_UN);
    fclose($fp);

    /* Print the Cookie and P3P compact privacy policy */
    header('P3P: CP="NOI NID"');
    setcookie('counter_unique', $page, time()+60*60*$unique_hours);
}

/* Is zero-padding enabled? */
if ($min_digits > 0) {
    $count = sprintf('%0'.$min_digits.'s',$count);
}

/* Print out Javascript code and exit */
echo 'document.write(\''.$count.'\');';
exit();

} else {
die('ERROR: Invalid log file!');
}

/* This functin handles input parameters making sure nothing dangerous is passed in */
function input($in) {
$out = htmlentities(stripslashes($in));
$out = str_replace(array('/','\\'), '', $out);
return $out;
}
?>

最佳答案

这与PHP代码无关,与web服务器的配置有关。它可能每秒被击中太多次而无法处理所有请求。

尝试从 IIS 查看以下设置:

  • instanceMaxRequests
  • 最大实例数
  • 队列长度

关于javascript - PHP 计数器消失/重新出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1896377/

相关文章:

javascript - jQuery - 在函数之间共享变量

javascript - 当我尝试通过 google API、JS React 获取日历事件时出错

javascript - 如何在 React Native 中点击移动图片

c - 得到一个太少的除数

javascript - 使用 JavaScript 识别独特的命中

javascript - Angularjs 和 Socket.io,在我看来不可能编辑值

python - 在 Python 中按每个键具有不同值的键过滤字典列表

r - 在 R 中按组向数据帧添加索引(或计数器)

testing - jMeter 报告中服务器命中率和吞吐量之间的差异

algorithm - 如何在 Canvas 中仅绘制具有自定义颜色的 > 0% alpha 的可见像素?