0

I am using Zend framework. I want to create an easy script for sending me an email with statistics every day. That is the easy part.

The cron script execution with my provider can be only set up by an URL link.

How can I make sure this URL can be only accessed by the machine, and not by any user or robot that tries the URL by accident or something.

I want to avoid executing the cron script by anyone else than the machine that is supposed to access it.

4

2 回答 2

2

使 cron 脚本检索:

http://yourdomain.com/path/to/script.php?token=743cc5a35d28aa7d22d4e93

然后在脚本中:

if( ! ( isset($_GET['token']) && $_GET['token'] === '743cc5a35d28aa7d22d4e93' ) ) {
    exit;
}

它不能保证请求是真实的,但可以防止意外调用您的脚本。

于 2013-09-23T23:02:17.577 回答
1

如果提供程序来自静态 IP,它应该像检查$_SERVER['REMOTE_ADDR']预定义 IP 一样简单。

于 2013-09-23T22:59:14.323 回答