Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
en:modifications:cronjob_over_http [2014/11/02 16:47] swarnat |
en:modifications:cronjob_over_http [2014/11/02 17:28] (current) swarnat |
||
---|---|---|---|
Line 5: | Line 5: | ||
Sometimes you couldn't use system cronjobs to run the vtigerCRM Scheduler. But lot's of features need this to work properly. | Sometimes you couldn't use system cronjobs to run the vtigerCRM Scheduler. But lot's of features need this to work properly. | ||
So you could modify the Cron File to execute the Cronjob over HTTP. | So you could modify the Cron File to execute the Cronjob over HTTP. | ||
- | To not open this file for every one you need to add the application unique key as parameter and could limit the access to a single IP or IP range. | + | To not open this access point for every one, you need to add the application unique key as parameter and could limit the access to a single or multiple IPs. |
===== File: vtigercron.php ===== | ===== File: vtigercron.php ===== | ||
Line 17: | Line 17: | ||
<code php> | <code php> | ||
if(!empty($_REQUEST["unique_key"])) { | if(!empty($_REQUEST["unique_key"])) { | ||
- | $allowOnlyIP = ""; | + | $allowOnlyIP = array("84.189.115.145"); |
- | //To get the IP which you need to limit the access, uncomment the next line: | + | // To get the IP which you need to limit the access, uncomment the next line: |
//var_dump($_SERVER["REMOTE_ADDR"]); | //var_dump($_SERVER["REMOTE_ADDR"]); | ||
Line 25: | Line 25: | ||
$_SESSION["authenticated_user_id"] = 1; | $_SESSION["authenticated_user_id"] = 1; | ||
- | if(!empty($allowOnlyIP) && strpos($_SERVER["REMOTE_ADDR"], $allowOnlyIP) !== 0) { | + | |
+ | if(!empty($allowOnlyIP) && !in_array($_SERVER["REMOTE_ADDR"], $allowOnlyIP)) { | ||
unset($_SESSION["app_unique_key"]); | unset($_SESSION["app_unique_key"]); | ||
unset($_SESSION["authenticated_user_id"]); | unset($_SESSION["authenticated_user_id"]); | ||
Line 32: | Line 33: | ||
</code> | </code> | ||
- | Now you could call your workflow from a cronjob service like [[http://www.easycron.com?ref=22589|EasyCron]]. | + | Now you could call your workflow from a cronjob provider like [[http://www.easycron.com?ref=22589|EasyCron]]. |
+ | (If you use this provider over this link, you support my work in this wiki.) | ||
+ | But it will work absolutely every cronjob provider or function, which could call a URL. | ||
+ | |||
+ | Simple configure a cronjob for this URL: | ||
+ | <domain>/vtigercron.php?unique_key=<your_application_unique_key> | ||
+ | |||
+ | Your <your_application_unique_key> you found in your config.inc.php file in the variable **$application_unique_key** | ||
+ | |||
+ | === Limit access to static IP's === | ||
+ | |||
+ | I integrate an access limitation if you only want to grant the access to a single IP's | ||
+ | You see the line | ||
+ | $allowOnlyIP = array(); | ||
+ | |||
+ | You could use this Array to set the IP's which could be access this file. If this array is empty, every one, which have your unique key could execute your cronjob! | ||
+ | |||
+ | In the case of EasyCron you could set this variable to: | ||
+ | $allowOnlyIP = array('142.4.201.54', '198.27.81.134'); |