Opencart管理员Cron工作 [英] Opencart Admin Cron Jobs

查看:100
本文介绍了Opencart管理员Cron工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解CRON以及如何创建/管理它.但是这个问题不一样.

I know about CRON and how to create/manage it. But this issue was different.

我想开发一个模块来删除超过给定时间范围的任何(未付款)订单. 例如:我想删除下达订单后两天仍未付款的所有未付款订单.

I want to develop a module to delete any (unpaid) order that exceeds the time frame given. Ex: I want to delete any unpaid order that has not been paid for 2 days after the order was placed.

我想在opencart中使用现有模型(而不要使用新模型).假设模块URL为: http://www. yourstore.com/admin/index.php?route=module/modulename/function 并且会从CRON调用,然后所有未付的订单都将消失.

I want to use existed model in opencart (and not use a new one). Let's say the module URL would be: http://www.yourstore.com/admin/index.php?route=module/modulename/function And will be called from CRON, and then all any unpaid order will be disappeared.

但是主要问题是:当CRON要访问该URL时,它需要一个安全令牌,否则它将永远不会执行.

But the main problem is: when CRON wants to access that URL, it needs a security token or it will never be executed.

我的问题是:如何在没有安全令牌的情况下从CRON执行该模块(如果仅针对该模块)?

My question is: how to execute that module from CRON without security token (in case just for that module)?

请帮助我,如果您有更好的主意或更简洁的方法,我会非常感谢您.

Please help me, if you have a better idea or a more clean way, I would say many thanks to you.

推荐答案

在2.3.0.2中,我发现一种非常简单的方法是将控制器功能路径添加到忽略的路径设置中,以进行登录和权限限制.然后只需在该控制器功能中添加网址密码或其他检查功能即可将其锁定.

In 2.3.0.2 a very simple way I found was to add your controller function path into the ignored paths settings for login and permission restrictions. Then just add a url password or other check in that controller function to lock it down.

因此,首先在admin/controller/startup/login.php中将您的控制器功能路径添加到两个$ ignore数组中,例如'common/cron/action'

So first in admin/controller/startup/login.php add your controller function path to both $ignore arrays, eg 'common/cron/action'

然后在admin/controller/startup/permissions.php中,您只需要控制器路径,例如'common/cron'

And then in admin/controller/startup/permissions.php you want just the controller path, eg 'common/cron'

然后最后在您的action()函数开始时执行以下操作:

And then finally at start of your action() function do like:

if(!isset($_GET['pass']) || $_GET['pass'] != 'secretpassword')return;

然后我刚刚将其添加到了我的cron中:

Then i just added this to my cron:

php-cli -r 'echo file_get_contents("https://www.website.com/admin/index.php?route=common/cron/action&pass=secretpassword");'

这篇关于Opencart管理员Cron工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆