==Additional Columns for Current Mailing== current_id (int) ID of current mailing (from mailing_id) command (enum) 'none' (default), 'restart', 'stop' serial (int) Serial of this mailing securityCode (char[32]) Security Code of Mailing current_status (enum) 'started', 'stopped' (default)
Пример #1
0
 function Pommo_Mta($args = array())
 {
     $defaults = array('queueSize' => 100, 'maxRunTime' => 80, 'skipSecurity' => false, 'start' => time(), 'serial' => false, 'spawn' => 1);
     $p = Pommo_Api::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(Pommo_Mailing::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 (!Pommo_Mail_Ctl::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;
 }
Пример #2
0
        $mailing = current(Pommo_Mailing::get(array('id' => $_REQUEST['mailings'])));
        // change group name to ID
        $groups = Pommo_Groups::getNames();
        $gid = 'all';
        foreach ($groups as $group) {
            if ($group['name'] == $mailing['group']) {
                $gid = $group['id'];
            }
        }
        Pommo_Api::stateReset(array('mailing'));
        // if this is a plain text mailing, switch body + altbody.
        if ($mailing['ishtml'] == 'off') {
            $mailing['altbody'] = $mailing['body'];
            $mailing['body'] = null;
        }
        // Initialize page state with default values overriden by those held in $_REQUEST
        $state =& Pommo_Api::stateInit('mailing', array('fromname' => $mailing['fromname'], 'fromemail' => $mailing['fromemail'], 'frombounce' => $mailing['frombounce'], 'list_charset' => $mailing['charset'], 'mailgroup' => $gid, 'subject' => $mailing['subject'], 'body' => $mailing['body'], 'altbody' => $mailing['altbody']));
        Pommo::redirect(Pommo::$_baseUrl . 'mailings_start.php');
        break;
    case 'delete':
        $deleted = Pommo_Mailing::delete($mailingIDS);
        $logger->addMsg(Pommo::_T('Please Wait') . '...');
        $params = $json->encode(array('ids' => $mailingIDS));
        $view->assign('callbackFunction', 'deleteMailing');
        $view->assign('callbackParams', $params);
        break;
    default:
        $logger->AddErr('invalid call');
        break;
}
$view->display('admin/rpc');
Пример #3
0
 *
 */
/**********************************
	INITIALIZATION METHODS
 *********************************/
require 'bootstrap.php';
require_once Pommo::$_baseDir . 'classes/Pommo_Mailing.php';
Pommo::init();
$logger = Pommo::$_logger;
$dbo = Pommo::$_dbo;
/**********************************
	SETUP TEMPLATE, PAGE
 *********************************/
require_once Pommo::$_baseDir . 'classes/Pommo_Template.php';
$view = new Pommo_Template();
if (Pommo_Mailing::isCurrent()) {
    Pommo::kill(sprintf(Pommo::_T('A Mailing is currently processing. Visit the' . ' %sStatus%s page to check its progress.'), '<a href="mailing_status.php">', '</a>'));
}
if (Pommo::$_config['demo_mode'] == 'on') {
    $logger->addMsg(sprintf(Pommo::_T('%sDemonstration Mode%s is on -- no Emails' . ' will actually be sent. This is good for testing settings.'), '<a href="' . Pommo::$_baseUrl . 'setup_configure.php#mailings">', '</a>'));
}
require_once Pommo::$_baseDir . 'themes/wysiwyg/editors.php';
$editors = new PommoWYSIWYG();
$editor = $editors->loadEditor();
if (!$editor) {
    die('Could not find requested WYSIWYG editor (' . $editor . ') in editors.php');
}
$view->assign('wysiwygJS', $editor);
// translation assignments for dialg titles...
$view->assign('t_personalization', Pommo::_T('Personalization'));
$view->assign('t_testMailing', Pommo::_T('Test Mailing'));
Пример #4
0
 *  (at your option) 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 Pommo.  If not, see <http://www.gnu.org/licenses/>.
 * 
 *  This fork is from https://github.com/soonick/poMMo
 *  Please see docs/contribs for Contributors
 *
 */
// Progress bar modified from the works of Juha Suni <*****@*****.**>
/**********************************
	INITIALIZATION METHODS
 *********************************/
require 'bootstrap.php';
require_once Pommo::$_baseDir . 'classes/Pommo_Mailing.php';
Pommo::init();
$logger = Pommo::$_logger;
$dbo = Pommo::$_dbo;
/**********************************
	SETUP TEMPLATE, PAGE
 *********************************/
require_once Pommo::$_baseDir . 'classes/Pommo_Template.php';
$view = new Pommo_Template();
$mailing = current(Pommo_Mailing::get(array('active' => TRUE)));
$view->assign('mailing', $mailing);
$view->display('admin/mailings/mailing_status');
Пример #5
0
 * 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.
 */
/**********************************
	INITIALIZATION METHODS
 *********************************/
require '../bootstrap.php';
require_once Pommo::$_baseDir . 'classes/Pommo_Mailing.php';
Pommo::init();
$logger =& Pommo::$_logger;
$dbo =& Pommo::$_dbo;
if (isset($_REQUEST['mailings'])) {
    if (is_array($_REQUEST['mailings'])) {
        $_REQUEST['mailings'] = $_REQUEST['mailings'][0];
    }
    $mailing = current(Pommo_Mailing::get(array('id' => $_REQUEST['mailings'])));
} else {
    $mailing = Pommo::$_session['state']['mailing'];
}
/**********************************
	SETUP TEMPLATE, PAGE
 *********************************/
require_once Pommo::$_baseDir . 'classes/Pommo_Template.php';
$smarty = new Pommo_Template();
$smarty->assign($mailing);
$smarty->display('inc/mailing.tpl');
Pommo::kill();
Пример #6
0
<?php

/**
 * Copyright (C) 2010  Adrian Ancona Novelo <*****@*****.**>
 * 
 * This file is part of poMMo (https://github.com/soonick/pommo)
 * 
 * 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.
 */
/**********************************
	INITIALIZATION METHODS
 *********************************/
require 'bootstrap.php';
require_once "classes/Pommo_Mailing.php";
Pommo_Mailing::saveHit($_GET['mailing'], $_GET['subscriber']);
header('Content-type: image/png');
echo gzinflate(base64_decode('6wzwc+flkuJiYGDg9fRwCQLSjCDMwQQkJ5QH3wNSb' . 'CVBfsEMYJC3jH0ikOLxdHEMqZiTnJCQAOSxMDB+E7cIBcl7uvq5rHNKaAIA'));
Пример #7
0
/**********************************
	OUTPUT FORMATTING
*********************************/
$records = array();
foreach ($mailings as $o) {
    //	If the mailing is not beeing tracked show "not tracked" instead of 0
    if (0 == $o['track']) {
        $o['hits'] = Pommo::_T('Not tracked');
    }
    $row = array('id' => $o['id'], 'subject' => $o['subject'], 'group' => $o['group'] . ' (' . $o['tally'] . ')', 'sent' => $o['sent'], 'start' => $o['start'], 'end' => $o['end'], 'hits' => $o['hits']);
    if ($o['status'] == 0) {
        $o['status'] = Pommo::_T('Complete');
    } elseif ($o['status'] == 1) {
        $o['status'] = Pommo::_T('Processing');
    } else {
        $o['status'] = Pommo::_T('Cancelled');
    }
    $row['status'] = $o['status'];
    // calculate mails per hour
    if (!empty($o['end']) && !empty($o['sent'])) {
        $runtime = strtotime($o['end']) - strtotime($o['start']);
        $mph = $runtime == 0 ? $o['sent'] * 3600 : round($o['sent'] / $runtime * 3600);
    } else {
        $mph = 0;
    }
    $row['end'] .= '<br />' . $mph . ' ' . Pommo::_T('Mails/Hour');
    array_push($records, $row);
}
// format for JSON output to jqGrid
$json->add(array('page' => $state['page'], 'total' => $state['pages'], 'records' => Pommo_Mailing::tally(), 'rows' => $records));
$json->serve();
Пример #8
0
$view = new Pommo_Template();
$view->assign('returnStr', Pommo::_T('Mailings Page'));
/** SET PAGE STATE
 * limit	- # of mailings per page
 * sort		- Sorting of Mailings [subject, mailgroup, subscriberCount, started, etc.]
 * order	- Order Type (ascending - ASC /descending - DESC)
 */
// Initialize page state with default values overriden by those held in $_REQUEST
$state =& Pommo_Api::stateInit('mailings_history', array('limit' => 10, 'sort' => 'end', 'order' => 'desc', 'page' => 1), $_REQUEST);
/**********************************
	VALIDATION ROUTINES
*********************************/
if (!is_numeric($state['limit']) || $state['limit'] < 1 || $state['limit'] > 1000) {
    $state['limit'] = 10;
}
if ($state['order'] != 'asc' && $state['order'] != 'desc') {
    $state['order'] = 'asc';
}
if ($state['sort'] != 'start' && $state['sort'] != 'end' && $state['sort'] != 'subject' && $state['sort'] != 'sent' && $state['sort'] != 'status' && $state['sort'] != 'group') {
    $state['sort'] = 'end';
}
/**********************************
	DISPLAY METHODS
*********************************/
// Calculate and Remember number of pages
$tally = Pommo_Mailing::tally();
$state['pages'] = is_numeric($tally) && $tally > 0 ? ceil($tally / $state['limit']) : 0;
$view->assign('state', $state);
$view->assign('tally', $tally);
$view->assign('mailings', $mailings);
$view->display('admin/mailings/mailings_history');
Пример #9
0
     } else {
         // temp subscriber created
         $state['tally'] = 1;
         $state['group'] = Pommo::_T('Test Mailing');
         if ($state['ishtml'] == 'off') {
             $state['body'] = $state['altbody'];
             $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);
Пример #10
0
$output['statusText'] = $statusText[$output['status']];
// get last 50 unique notices
$mailingNotices = Pommo_Mailing::getNotices($mailing['id'], 50, true);
$newNotices = array();
foreach ($mailingNotices as $time => $arr) {
    if (!isset($state['notices'][$time])) {
        $newNotices = array_merge($newNotices, $arr);
        continue;
    }
    foreach ($arr as $notice) {
        if (array_search($notice, $arr) === false) {
            $newNotices[] = $notice;
        }
    }
}
$state['notices'] = $mailingNotices;
$output['notices'] = array_reverse($newNotices);
// calculate sent
if ($output['status'] == 4) {
    $output['sent'] = Pommo_Mailing::getSent($mailing['id']);
} else {
    $query = "SELECT count(subscriber_id) FROM {$dbo->table['queue']} WHERE status > 0";
    $output['sent'] = $dbo->query($query, 0);
}
// cleanup session if frozen or finished.
if ($output['status'] > 2) {
    Pommo_Api::stateInit('subscribers_manage');
}
$output['percent'] = $output['status'] == 4 ? 100 : round($output['sent'] * (100 / $mailing['tally']));
$json->add($output);
$json->serve();
Пример #11
0
 function add(&$in)
 {
     $dbo = Pommo::$_dbo;
     // set the start time if not provided
     if (empty($in['start'])) {
         $in['start'] = time();
     }
     if (empty($in['sent'])) {
         $in['sent'] = 0;
     }
     if (!Pommo_Mailing::validate($in)) {
         return false;
     }
     //	Add image to track views
     if (1 == $in['track']) {
         $in['body'] .= '<img src="http://' . $_SERVER['SERVER_NAME'] . Pommo::$_baseUrl . 'track-[[!mailing_id]]-[[!subscriber_id]]' . '.png">';
     }
     $query = "INSERT INTO " . $dbo->table['mailings'] . "\n                SET\n                [fromname='%S',]\n                [fromemail='%S',]\n                [frombounce='%S',]\n                [subject='%S',]\n                [body='%S',]\n                [altbody='%S',]\n                [ishtml='%S',]\n                [mailgroup='%S',]\n                [subscriberCount=%I,]\n                [finished=FROM_UNIXTIME(%I),]\n                [sent=%I,]\n                [charset='%S',]\n                [status=%I,]\n                [track=%I,]\n                started=FROM_UNIXTIME(%i)";
     $query = $dbo->prepare($query, @array($in['fromname'], $in['fromemail'], $in['frombounce'], $in['subject'], $in['body'], $in['altbody'], $in['ishtml'], $in['group'], $in['tally'], $in['end'], $in['sent'], $in['charset'], $in['status'], $in['track'], $in['start']));
     // fetch new mailing_id
     $id = $dbo->lastId($query);
     if (!$id) {
         return false;
     }
     // Save the attachments
     if ($in['attachments']) {
         $attach = explode(',', $in['attachments']);
         foreach ($attach as $key => $attachment) {
             $query = "INSERT INTO " . $dbo->table['mailings_attachments'] . "\n                        SET\n                        [mailing_id='%I',]\n                        [file_id='%I']";
             $query = $dbo->prepare($query, @array($id, $attachment));
             $dbo->query($query);
         }
     }
     // insert current if applicable
     if (!empty($in['status']) && $in['status'] == 1) {
         if (empty($in['code'])) {
             $in['code'] = Pommo_Helper::makeCode();
         }
         $query = "INSERT INTO " . $dbo->table['mailing_current'] . "\n            SET\n            [command='%S',]\n            [serial=%I,]\n            [securityCode='%S',]\n            [current_status='%S',]\n            current_id=%i";
         $query = $dbo->prepare($query, @array($in['command'], $in['serial'], $in['code'], $in['current_status'], $id));
         if (!$dbo->query($query)) {
             return false;
         }
         return $in['code'];
     }
     return $id;
 }
Пример #12
0
 function add(&$in)
 {
     $dbo =& Pommo::$_dbo;
     // set the start time if not provided
     if (empty($in['start'])) {
         $in['start'] = time();
     }
     if (empty($in['sent'])) {
         $in['sent'] = 0;
     }
     if (!Pommo_Mailing::validate($in)) {
         return false;
     }
     $query = "\n\t\t\tINSERT INTO " . $dbo->table['mailings'] . "\n\t\t\tSET\n\t\t\t[fromname='%S',]\n\t\t\t[fromemail='%S',]\n\t\t\t[frombounce='%S',]\n\t\t\t[subject='%S',]\n\t\t\t[body='%S',]\n\t\t\t[altbody='%S',]\n\t\t\t[ishtml='%S',]\n\t\t\t[mailgroup='%S',]\n\t\t\t[subscriberCount=%I,]\n\t\t\t[finished=FROM_UNIXTIME(%I),]\n\t\t\t[sent=%I,]\n\t\t\t[charset='%S',]\n\t\t\t[status=%I,]\n\t\t\tstarted=FROM_UNIXTIME(%i)";
     $query = $dbo->prepare($query, @array($in['fromname'], $in['fromemail'], $in['frombounce'], $in['subject'], $in['body'], $in['altbody'], $in['ishtml'], $in['group'], $in['tally'], $in['end'], $in['sent'], $in['charset'], $in['status'], $in['start']));
     // fetch new subscriber's ID
     $id = $dbo->lastId($query);
     if (!$id) {
         return false;
     }
     // insert current if applicable
     if (!empty($in['status']) && $in['status'] == 1) {
         if (empty($in['code'])) {
             $in['code'] = Pommo_Helper::makeCode();
         }
         $query = "\n\t\t\tINSERT INTO " . $dbo->table['mailing_current'] . "\n\t\t\tSET\n\t\t\t[command='%S',]\n\t\t\t[serial=%I,]\n\t\t\t[securityCode='%S',]\n\t\t\t[current_status='%S',]\n\t\t\tcurrent_id=%i";
         $query = $dbo->prepare($query, @array($in['command'], $in['serial'], $in['code'], $in['current_status'], $id));
         if (!$dbo->query($query)) {
             return false;
         }
         return $in['code'];
     }
     return $id;
 }