* the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with program; see the file docs/LICENSE. If not, write to the * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ /********************************** INITIALIZATION METHODS *********************************/ define('_poMMo_support', TRUE); require 'bootstrap.php'; Pommo::init(); require_once Pommo::$_baseDir . 'classes/Pommo_Mail_Ctl.php'; set_time_limit(0); $code = Pommo_Helper::makeCode(); if (!Pommo_Mail_Ctl::spawn(Pommo::$_baseUrl . 'mailing.runtime2.php?code=' . $code)) { Pommo::kill('Initial Spawn Failed! You must correct this before poMMo can send mailings.'); } echo 'Initial Run Time: ' . ini_get('max_execution_time') . ' seconds <br>'; echo '<br/> This test takes at least 90 seconds. Upon completetion "SUCCESS" will be printed. If you do not see "SUCCESS", the max runtime should be set near the second highest "reported working" value.'; echo '<hr>'; echo '<b>Reported working value(s)</b><br />'; ob_flush(); flush(); sleep(5); if (!is_file(Pommo::$_workDir . '/mailing.test.php')) { // make sure we can write to the file if (!($handle = fopen(Pommo::$_workDir . '/mailing.test.php', 'w'))) { Pommo::kill('Unable to write to test file!'); } fclose($handle);
// ignore user abort ignore_user_abort(true); require_once Pommo::$_baseDir . 'classes/Pommo_Mail_Ctl.php'; $code = empty($_GET['code']) ? null : $_GET['code']; $spawn = !isset($_GET['spawn']) ? 0 : $_GET['spawn'] + 1; trigger_error('Testing Log, Spawn #' . $spawn); $fileContent = "<?php die(); ?>\n[code] = {$code}\n[spawn] = {$spawn}\n"; if (!($handle = fopen(Pommo::$_workDir . '/mailing.test.php', 'w'))) { die('Unable to write to test file'); } if (fwrite($handle, $fileContent) === FALSE) { die('Unable to write to test file'); } fclose($handle); if ($spawn > 0) { die; } sleep(1); // respawn test if (!Pommo_Mail_Ctl::spawn(Pommo::$_baseUrl . 'mailing.test2.php?' . 'code=' . $code . '&spawn=' . $spawn, true)) { $fileContent .= '[error] = true'; $handle = fopen(Pommo::$_workDir . '/mailing.test.php', 'w'); fwrite($handle, $fileContent); fclose($handle); $errors = $logger->getAll(); $fileContent = print_r($errors, true); $handle = fopen(Pommo::$_workDir . '/MAILING_TEST', 'w'); fwrite($handle, $fileContent); fclose($handle); } die;
require_once Pommo::$_baseDir . 'classes/Pommo_Mail_Ctl.php'; require_once Pommo::$_baseDir . 'classes/Pommo_Mailing.php'; Pommo::init(); $logger =& Pommo::$_logger; $dbo =& Pommo::$_dbo; /********************************** JSON OUTPUT INITIALIZATION *********************************/ require_once Pommo::$_baseDir . 'classes/Pommo_Json.php'; $json = new Pommo_Json(); $mailing = current(Pommo_Mailing::get(array('active' => TRUE))); switch ($_GET['cmd']) { case 'cancel': // cancel a mailing // cancel a mailing case 'restart': // restart mailing // restart mailing case 'stop': // pause mailing $query = "\n\t\t\tUPDATE " . $dbo->table['mailing_current'] . "\n\t\t\tSET command='" . $_GET['cmd'] . "'\n\t\t\tWHERE current_id=%i"; $query = $dbo->prepare($query, array($mailing['id'])); if (!$dbo->query($query)) { $json->fail(); } if ($_GET['cmd'] == 'restart' || $_GET['cmd'] == 'cancel') { Pommo_Mail_Ctl::spawn(Pommo::$_baseUrl . 'ajax/mailings_send4.php?id=' . $mailing['id'] . '&code=' . $mailing['code']); } break; } $json->success();
$state['altbody'] = ''; } // create mailing $mailing = Pommo_Mailing::make(array(), TRUE); $state['status'] = 1; $state['current_status'] = 'stopped'; $state['command'] = 'restart'; $state['charset'] = $state['list_charset']; $mailing = Pommo_Helper::arrayIntersect($state, $mailing); $code = Pommo_Mailing::add($mailing); // populate queue $queue = array($key); if (!Pommo_Mail_Ctl::queueMake($queue)) { $logger->addErr('Unable to Populate Queue'); } else { if (!Pommo_Mail_Ctl::spawn(Pommo::$_baseUrl . 'ajax/mailings_send4.php?test=TRUE&code=' . $code)) { $logger->addErr('Unable to spawn background mailer'); } else { $smarty->assign('sent', $_POST['email']); } } } } elseif ($current) { $logger->addMsg(Pommo::_T('A mailing is currently taking place. Please try again later.')); $smarty->assign($_POST); } else { // __ FORM NOT VALID $logger->addMsg(Pommo::_T('Please review and correct errors with your submission.')); $smarty->assign($_POST); } }
function stop($finish = false) { $this->_mailer->SmtpClose(); if ($this->_test) { // don't respawn if this is a test mailing Pommo_Mail_Ctl::finish($this->_id, TRUE, TRUE); Pommo_Subscribers::delete(current($this->_hash)); session_destroy(); exit; } if ($finish) { Pommo_Mail_Ctl::finish($this->_id); $this->shutdown(Pommo::_T('Mailing Complete.')); } // respwn if (!Pommo_Mail_Ctl::spawn(Pommo::$_baseUrl . 'ajax/mailings_send4.php?' . 'code=' . $this->_code . '&serial=' . $this->_serial . '&id=' . $this->_id)) { $this->shutdown('*** RESPAWN FAILED! ***'); } $this->shutdown(sprintf(Pommo::_T('Runtime (%s seconds) reached, respawning.'), $this->_maxRunTime), false); }
* You should have received a copy of the GNU General Public License * along with program; see the file docs/LICENSE. If not, write to the * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ /********************************** INITIALIZATION METHODS *********************************/ define('_poMMo_support', TRUE); require 'bootstrap.php'; Pommo::init(); require_once Pommo::$_baseDir . 'classes/Pommo_Mail_Ctl.php'; echo 'Please Wait...'; ob_flush(); flush(); $code = Pommo_Helper::makeCode(); if (!Pommo_Mail_Ctl::spawn(Pommo::$_baseUrl . 'mailing.test2.php?code=' . $code, true)) { Pommo::kill('Initial Spawn Failed! You must correct this before poMMo can send mailings.'); } sleep(6); if (!is_file(Pommo::$_workDir . '/mailing.test.php')) { // make sure we can write to the file if (!($handle = fopen(Pommo::$_workDir . '/mailing.test.php', 'w'))) { die('Unable to write to test file!'); } fclose($handle); unlink(Pommo::$_workDir . '/mailing.test.php'); Pommo::kill('Initial Spawn Failed (test file not written)! You must correct this before poMMo can send mailings.'); } $o = Pommo_Helper::parseConfig(Pommo::$_workDir . '/mailing.test.php'); unlink(Pommo::$_workDir . '/mailing.test.php') or die('could not remove mailing.test.php'); if (isset($o['error'])) {