从 PHP 调用访客网络统计程序

发布于 2024-07-04 02:03:51 字数 543 浏览 5 评论 0原文

我一直在为我的网站研究不同的网络统计程序,其中一个很有前途的程序是访问者。 不幸的是,它是一个 C 程序,我不知道如何从网络服务器调用它。 我尝试过使用 PHP 的 shell_exec,但是我的网络主机(NFSN) 具有 PHP 的 安全模式 打开,它给了我一条错误消息。

有没有办法在安全模式下执行程序? 如果不能的话,它可以与CGI一起使用吗? 如果是这样,怎么办? (我以前从未使用过CGI)

I've been looking into different web statistics programs for my site, and one promising one is Visitors. Unfortunately, it's a C program and I don't know how to call it from the web server. I've tried using PHP's shell_exec, but my web host (NFSN) has PHP's safe mode on and it's giving me an error message.

Is there a way to execute the program within safe mode? If not, can it work with CGI? If so, how? (I've never used CGI before)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

空‖城人不在 2024-07-11 02:03:51

我自己设法解决了这个问题。 我将以下几行放入名为 users.cgi 的文件中:

#!/bin/sh

printf "Content-type: text/html\n\n"
exec visitors -A /home/logs/access_log

I managed to solve this problem on my own. I put the following lines in a file named visitors.cgi:

#!/bin/sh

printf "Content-type: text/html\n\n"
exec visitors -A /home/logs/access_log
ゞ记忆︶ㄣ 2024-07-11 02:03:51

幸运的是,我确实可以访问我的网站的日志文件。 我已经能够在服务器上手动生成 HTML 页面 - 我只是在寻找一种方法让它自动发生。 我所需要的只是执行 shell 命令并获取输出以显示为页面。

听起来对于实习生来说是一份不错的工作。

=)

致电您的主机,看看是否可以达成执行 shell 的协议。

As fortune would have it I do have access to the log file for my site. I've been able to generate the HTML page on the server manually - I've just been looking for a way to get it to happen automatically. All I need is to execute a shell command and get the output to display as the page.

Sounds like a good job for an intern.

=)

Call your host and see if you can work out a deal for doing a shell execute.

蓝色星空 2024-07-11 02:03:51

我赞同乔纳森的回答:这是一个日志分析器,这意味着您必须将网络服务器的日志文件作为输入提供给它,然后它会生成它的摘要。 鉴于您位于共享主机上,您不可能访问该文件,即使您可以访问它,它也可能包含该主机上托管的所有网站的条目给定的机器(使用 Apache 肯定可以为每个 VirtualHost 设置单独的日志记录,但我不知道这是否是一种常见的做法)。

一种可能的解决方法是从页面中写出日志文件。 然而,这是相当困难的,并且可能会对性能产生严重影响(如果您不想时不时地收到垃圾,则必须将写入序列化到日志文件中)。 总而言之,我建议使用在线分析服务,例如 Google Analytics。

I second the answer of Jonathan: this is a log analyzer, meaning that you must feed it as input the logfile of the webserver and it generates a summarization of it. Given that you are on a shared host, it is improbable that you can access to that file, and even if you would access it, it is probable that it contains then entries for all the websites hosted on the given machine (setting up separate logging for each VirtualHost is certainly possible with Apache, but I don't know if it is a common practice).

One possible workaround would be for you to write out a logfile from your pages. However this is rather difficult and can have a severe performance impact (you have to serialize the writes to the logfile for one, if you don't want to get garbage from time to time). All in all, I would suggest going with an online analytics service, like Google Analytics.

得不到的就毁灭 2024-07-11 02:03:51

有什么理由不只使用 Google Analytics 吗? 它是免费的,您不必自己编写。 我使用它,它为你提供了很多信息。

抱歉,我知道这不是“编程”答案;)

Is there any reason not to just use Google Analytics? It's free, and you don't have to write it yourself. I use it, and it gives you a lot of information.

Sorry, I know it's not a "programming" answer ;)

风铃鹿 2024-07-11 02:03:51

访问者看起来就像一个日志分析器和报告生成器。 最好将其设置为一项慢性作业,每天左右创建一次静态 HTML 页面。

如果您没有对托管帐户的 shell 访问权限,或者没有某种可以让您设置定时作业的控制面板,那么您就不走运了。

Visitors looks like a log analyzer and report generator. Its probably best setup as a chron job to create static HTML pages once a day or so.

If you don't have shell access to your hosting account, or some sort of control panel that lets you setup up chron jobs, you'll be out of luck.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文