Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX]CLONE - Email time zone concern #725

Open
wants to merge 1 commit into
base: V6.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions web_interface/astpp/application/controllers/crons.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,33 @@ function __construct() {
function index() {
$crons = $this->db->where('status', 0)->where("'".$this->CurrentDate."' >= next_execution_date OR next_execution_date IS NULL", '', false)->from('cron_settings')->get();
if($crons->num_rows > 0){
foreach ($crons->result() as $row) {
$this->db->set('next_execution_date', '"'.$this->calculateNextRun($row,$this->CurrentDate).'"', false)->where('id', $row->id)->update('cron_settings');
$row->file_path = str_replace("{BASE_URL}",base_url(),$row->file_path);
$output = shell_exec($row->file_path." > /dev/null 2>/dev/null &");
$this->db->set('last_execution_date', "'".gmdate("Y-m-d H:i:s")."'", false)->where('id', $row->id)->update('cron_settings');
}
foreach ($crons->result() as $row) {
$this->db->set('next_execution_date', '"'.$this->calculateNextRun($row,$this->CurrentDate).'"', false)->where('id', $row->id)->update('cron_settings');
// ASTPPENT-8702 Ashish start
$base_url_array= explode("{BASE_URL}",$row->file_path);
$url=explode('/',$base_url_array[1]);
$class_name = $url[0];
$function_name = $url[1];
$file_path = FCPATH ;
$ps_path = exec("which ps");
$command1 = trim($ps_path).' aux | grep "'.$class_name.'"'.' | grep "php"';
$output = shell_exec($command1);
if (strpos($output, 'index') !== false) {
echo $class_name;
}else{
$command = 'cd '.$file_path.' && '.'php index.php '.$class_name.' '.$function_name;
exec($command,$output1);
}
// ASTPPENT-8702 Ashish end
$this->db->set('last_execution_date', "'".gmdate("Y-m-d H:i:s")."'", false)->where('id', $row->id)->update('cron_settings');
}
}
exit;
}
private function calculateNextRun($obj,$CurrentDate)
{
return gmdate("Y-m-d H:i:s", strtotime($CurrentDate.' + '.$obj->exec_interval.' '.$obj->command));
// ASTPPENT-8702 Ashish start
return date("Y-m-d H:i:s", strtotime($CurrentDate.' + '.$obj->exec_interval.' '.$obj->command));
// ASTPPENT-8702 Ashish end
}
}