Welcome Guest, Not a member yet? Register   Sign In
Cron job returns "Undefined index: REQUEST_METHOD"
#4

CSRF protection is enabled. Windows machine is running PHP 7.1.17. Linux server is running PHP 7.1.27. My CPanel cronjob has the form:

Code:
/usr/bin/php -f /home/<directory>/<directory>/index.php cronjobs statistics

My relevant controller code:

Code:
class Cronjobs extends CI_Controller
{

   public function __construct()
   {
       parent::__construct();
       $this->load->model('accounts_model');
       $this->load->helper('url');
       $this->load->library('phpmailer_library');
       $objMail = $this->phpmailer_library->load();
       $params = array($objMail);
       $this->load->library('emailmanager', $params);
   }

   /**
    * This function can be run only via cron script.
    * It sends an email with statistics to administrator.
    */
   public function statistics()
   {
       if (is_cli() === TRUE)
       {
           $today = date('Y-m-d');          
           $statistics['total'] = $this->accounts_model->count_accounts();
           $this->emailmanager->SendStatisticsEmail('Statistics ' . $today, $statistics);            
       }
       else
       {
           $this->output->set_status_header(401); // Unauthorized        
       }
   }
}
Reply


Messages In This Thread
RE: Cron job returns &quot;Undefined index: REQUEST_METHOD&quot; - by anturom - 03-20-2019, 01:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB