简体   繁体   English

有关某人将运行仅用于cron作业的php脚本

[英]Concerned someone will run a php script only intended for a cron job

I have a PHP script on my server, this PHP script gets specified emails from my mySQL database, it then pulls a whole bunch of data from the database which it uses to compose an email which it sends to each email address it pulled from the database. 我的服务器上有一个PHP脚本,该PHP脚本从mySQL数据库中获取指定的电子邮件,然后从数据库中提取一大堆数据,用它来编写电子邮件,并将其发送到从数据库中提取的每个电子邮件地址。

In order to run this script once a day I have set up a cron job on my server which does so. 为了每天运行一次此脚本,我在服务器上设置了cron作业。

When I receive an email sent from this script, in the source of the email, it has the following line: X-PHP-Script: (exact address to PHP script) 当我收到从此脚本发送的电子邮件时,在电子邮件的来源中,该行包含以下内容: X-PHP-Script: (exact address to PHP script)

My concern is that anyone, at anytime can go to that address and run this script over and over again, not only will it make everyone on the email list very irritated, but it will also clog up my server. 我担心的是,任何人都可以随时访问该地址并一遍又一遍地运行此脚本,这不仅会使电子邮件列表中的每个人都非常恼火,而且还会阻塞我的服务器。

I would like to know if there is anything I can do, to disable someone from being able to run this script themselves, or if there is a better way I should be doing this which would also solve my problem. 我想知道我是否可以做些什么,或者禁止某人自己运行此脚本,或者是否有更好的方法可以解决我的问题。

Thank you in advance :) 先感谢您 :)

您可以将PHP脚本放置在公共网站之外(例如,在Plesk中,公共URL以httpdocs开头,因此您可以将其直接放置在此文件夹之前的文件夹中)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM