Exemple #1
0
 function PommoMTA($args = array())
 {
     $defaults = array('queueSize' => 100, 'maxRunTime' => 80, 'skipSecurity' => false, 'start' => time(), 'serial' => false, 'spawn' => 1);
     $p = PommoAPI::getParams($defaults, $args);
     foreach ($p as $k => $v) {
         $this->{'_' . $k} = $v;
     }
     // protect against safe mode timeouts
     if (ini_get('safe_mode')) {
         $this->_maxRunTime = ini_get('max_execution_time') - 10;
     } else {
         set_time_limit(0);
     }
     // protect against user (client) abort
     ignore_user_abort(true);
     // register shutdown method
     register_shutdown_function(array(&$this, "shutdown"));
     // set parameters from URL
     $this->_code = empty($_GET['code']) ? 'invalid' : $_GET['code'];
     $this->_test = isset($_GET['test']);
     $this->_id = isset($_GET['id']) && is_numeric($_GET['id']) ? $_GET['id'] : false;
     // verify and initialize the current mailing
     $p = array('active' => true, 'code' => $this->_skipSecurity ? null : $this->_code, 'id' => $this->_id ? $this->_id : null);
     $this->_mailing = current(PommoMailing::get($p));
     if (!is_numeric($this->_mailing['id'])) {
         $this->shutdown('Unable to initialize mailing.');
     }
     $this->_id = $this->_mailing['id'];
     // make sure the $_GET global holds the mailing id (used in personalizations, etc.)
     $_GET['id'] = $this->_id;
     // security routines
     if ($this->_mailing['end'] > 0) {
         $this->shutdown(Pommo::_T('Mailing Complete.'));
     }
     if (empty($this->_mailing['serial'])) {
         if (!PommoMailCtl::mark($this->_serial, $this->_id)) {
             $this->shutdown('Unable to serialize mailing (ID: ' . $this->_id . ' SERIAL: ' . $this->_serial . ')');
         }
     }
     if ($this->_maxRunTime < 15) {
         $this->shutdown('Max Runtime must be at least 15 seconds!');
     }
     $this->_queue = $this->_sent = $this->_failed = array();
     return;
 }
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 */
/**********************************
	INITIALIZATION METHODS
 *********************************/
require '../../bootstrap.php';
Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/mailings.php');
$config = PommoAPI::configGet('public_history');
if ($config['public_history'] == 'on') {
    $pommo->init(array('authLevel' => 0));
} else {
    Pommo::redirect('login.php');
}
$logger =& $pommo->_logger;
$dbo =& $pommo->_dbo;
if (isset($_REQUEST['mailings'])) {
    if (is_array($_REQUEST['mailings'])) {
        $_REQUEST['mailings'] = $_REQUEST['mailings'][0];
    }
    $mailing = current(PommoMailing::get(array('id' => $_REQUEST['mailings'])));
} else {
    die;
}
/**********************************
	SETUP TEMPLATE, PAGE
 *********************************/
Pommo::requireOnce($pommo->_baseDir . 'inc/classes/template.php');
$smarty = new PommoTemplate();
$smarty->assign($mailing);
$smarty->display('inc/mailing.tpl');
Pommo::kill();
if (!empty($_REQUEST['sord']) && ($_REQUEST['sord'] == 'asc' || $_REQUEST['sord'] == 'desc')) {
    $state['order'] = $_REQUEST['sord'];
}
// Calculate the offset
$start = $state['limit'] * $state['page'] - $state['limit'];
if ($start < 0) {
    $start = 0;
}
/**********************************
	RECORD RETREVIAL
*********************************/
// normalize sort to database column
if ($state['sort'] == 'start') {
    $state['sort'] = 'started';
}
// Fetch Mailings for this Page
$mailings = PommoMailing::get(array('noBody' => TRUE, 'sort' => $state['sort'], 'order' => $state['order'], 'limit' => $state['limit'], 'offset' => $start));
/**********************************
	OUTPUT FORMATTING
*********************************/
$records = array();
foreach ($mailings as $o) {
    $row = array('id' => $o['id'], 'subject' => $o['subject'], 'start' => $o['start']);
    if ($o['status'] == 0) {
        // only return "complete" mailings
        array_push($records, $row);
    }
}
// format for JSON output to jqGrid
$json->add(array('page' => $state['page'], 'total' => $state['pages'], 'records' => PommoMailing::tally(), 'rows' => $records));
$json->serve();
 * touched - remember last time the mailing was touched
 * timestamp - updated whenever the mailing touched time changes
 */
// Initialize page state with default values overriden by those held in $_REQUEST
$state =& PommoAPI::stateInit('subscribers_manage', array('touched' => null, 'timestamp' => time(), 'notices' => array()));
if (!empty($_GET['resetNotices'])) {
    $state['notices'] = array();
}
/**********************************
	JSON OUTPUT INITIALIZATION
 *********************************/
Pommo::requireOnce($pommo->_baseDir . 'inc/classes/json.php');
$json = new PommoJSON();
$output = array('percent' => null, 'status' => null, 'statusText' => null, 'sent' => null, 'notices' => FALSE);
$statusText = array(1 => Pommo::_T('Processing'), 2 => Pommo::_T('Stopped'), 3 => Pommo::_T('Frozen'), 4 => Pommo::_T('Finished'));
$mailing = isset($_GET['id']) ? current(PommoMailing::get(array('id' => $_GET['id']))) : current(PommoMailing::get(array('active' => TRUE)));
// status >> 1: Processing  2: Stopped  3: Frozen  4: Finished
if ($mailing['status'] != 1) {
    $output['status'] = 4;
} elseif ($mailing['current_status'] == 'stopped') {
    $output['status'] = 2;
} else {
    $output['status'] = 1;
}
// check for frozen mailing
if ($output['status'] != 4) {
    if ($state['touched'] != $mailing['touched']) {
        $state['touched'] = $mailing['touched'];
        $state['timestamp'] = time();
    } else {
        if (time() - $state['timestamp'] > 25) {
/**********************************
	SETUP TEMPLATE, PAGE
 *********************************/
Pommo::requireOnce($pommo->_baseDir . 'inc/classes/template.php');
$smarty = new PommoTemplate();
$smarty->assign('title', $pommo->_config['site_name'] . ' - ' . Pommo::_T('Mailing History'));
/** SET PAGE STATE
 * limit	- # of mailings per page
 * sort		- Sorting of Mailings [subject, started]
 * order	- Order Type (ascending - ASC /descending - DESC)
 */
// Initialize page state with default values overriden by those held in $_REQUEST
$state =& PommoAPI::stateInit('mailings_history', array('limit' => 100, 'sort' => 'finished', 'order' => 'asc', 'page' => 1), $_REQUEST);
// if mail_id is passed, display the mailing.
if (isset($_GET['mail_id']) && is_numeric($_GET['mail_id'])) {
    $input = current(PommoMailing::get(array('id' => $_GET['mail_id'])));
    // attempt personalizations of body/subject
    if (isset($_GET['email']) && isset($_GET['code'])) {
        $subscriber = current(PommoSubscriber::get(array('email' => $_GET['email'], 'status' => 1)));
        if ($_GET['code'] == PommoSubscriber::getActCode($subscriber)) {
            Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/personalize.php');
            // require once here so that mailer can use
            Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/personalizetitle.php');
            // title personalization
            $matches1 = array();
            preg_match('/\\[\\[[^\\]]+]]/', $input['body'], $matches1);
            if (!empty($matches1)) {
                $pBody = PommoHelperPersonalize::search($input['body']);
                $input['body'] = PommoHelperPersonalize::replace($input['body'], $subscriber, $pBody);
            }
            $matches2 = array();
 * poMMo is free software; you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published 
 * by the Free Software Foundation; either version 2, or any later version.
 * 
 * poMMo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
 * 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.
 */
// Progress bar modified from the works of Juha Suni <*****@*****.**>
/**********************************
	INITIALIZATION METHODS
 *********************************/
require '../../bootstrap.php';
Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/mailings.php');
$pommo->init();
$logger =& $pommo->_logger;
$dbo =& $pommo->_dbo;
/**********************************
	SETUP TEMPLATE, PAGE
 *********************************/
Pommo::requireOnce($pommo->_baseDir . 'inc/classes/template.php');
$smarty = new PommoTemplate();
$mailing = current(PommoMailing::get(array('active' => TRUE)));
$smarty->assign('mailing', $mailing);
$smarty->display('admin/mailings/mailing_status.tpl');
Pommo::kill();