/** * Main class entry point * * @access public * @param object ipsRegistry reference * @return void [Outputs to screen] */ public function doExecute(ipsRegistry $registry) { @set_time_limit(1200); //----------------------------------------- // Require and run //----------------------------------------- require_once IPS_ROOT_PATH . 'sources/classes/class_taskmanager.php'; $functions = new class_taskmanager($registry); //----------------------------------------- // Check shutdown functions //----------------------------------------- if (IPS_USE_SHUTDOWN) { define('IS_SHUTDOWN', 1); register_shutdown_function(array($functions, 'runTask')); } else { $functions->runTask(); } if ($functions->type != 'cron' && !$_SERVER['SHELL']) { //----------------------------------------- // Print out the 'blank' gif //----------------------------------------- @header("Content-Type: image/gif"); print base64_decode("R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="); } }
/** * Complete bulk mail processing * * @access private * @return void */ private function _mailSendComplete() { $pergo = intval($this->request['pergo']); $id = intval($this->request['id']); if (!$id) { $this->registry->output->global_message = $this->lang->words['b_norecord']; $this->_mailStart(); return; } //----------------------------------------- // Get it from the db //----------------------------------------- $mail = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'bulk_mail', 'where' => 'mail_id=' . $id)); if (!$mail['mail_subject'] and !$mail['mail_content']) { $this->registry->output->global_message = $this->lang->words['b_nosend']; $this->_mailStart(); return; } //----------------------------------------- // Update mail //----------------------------------------- if (!$pergo or $pergo > 1000) { $pergo = 50; } $this->DB->update('bulk_mail', array('mail_active' => 1, 'mail_pergo' => $pergo, 'mail_sentto' => 0, 'mail_start' => time()), 'mail_id=' . $id); $this->DB->update('bulk_mail', array('mail_active' => 0), 'mail_id <> ' . $id); //----------------------------------------- // Wake up task manager //----------------------------------------- require_once IPS_ROOT_PATH . 'sources/classes/class_taskmanager.php'; $task = new class_taskmanager($this->registry); $this->DB->update('task_manager', array('task_enabled' => 1), "task_key='bulkmail'"); $this_task = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'task_manager', 'where' => "task_key='bulkmail'")); $newdate = $task->generateNextRun($this_task); $this->DB->update('task_manager', array('task_next_run' => $newdate), "task_id=" . $this_task['task_id']); $task->saveNextRunStamp(); //----------------------------------------- // Sit back and watch the show //----------------------------------------- $this->registry->output->global_message = $this->lang->words['b_initiated']; $this->_mailStart(); }