Example #1
0
 function bmDebug()
 {
     global $pommo;
     echo "\n\n<br><br><b>BASIC DEBUG</b><hr><br>\n\n";
     echo "\n\nPHP: " . phpversion() . "<br><br>\n\n";
     echo "\n\nMYSQL CLIENT: " . mysql_get_client_info() . "<br><br>\n\n";
     echo "\n\nMYSQL HOST: " . mysql_get_host_info() . "<br><br>\n\n";
     echo "\n\nMYSQL SERVER: " . mysql_get_server_info() . "<br><br>\n\n";
     echo "\n\nBACKTRACE: " . $this->bmBacktrace() . "<br><br>\n\n";
     echo "\nBaseURL:" . Pommo::$_baseUrl . "<br>\n";
     echo "\n HTTP:" . Pommo::$_http . "<br>\n";
     echo "\nBaseDir: " . Pommo::$_baseDir . "<br>\n";
     echo "\nWorkDir:" . Pommo::$_workDir . "<br>\n";
     echo "\nLang:" . Pommo::$_lang . "<br>\n";
     echo "\nVerbosity:" . Pommo::$_verbosity . "<br>\n";
     echo "\nRevision: " . Pommo::$_revision . "<br>\n";
     echo "\nSection: " . Pommo::$_section . "<br>\n";
     echo "\n\n<br><br><b>CONFIG DEBUG</b><hr><br>\n\n";
     $config = Pommo_Api::configGet('all');
     if (!empty($config)) {
         echo "\n\n<br>CONFIG:<br>\n\n";
         foreach ($config as $name => $value) {
             if ($name == 'admin_username' || $name == 'admin_password') {
                 $value = '**CENSOR** - ' . strlen($value);
             } elseif ($name == 'messages') {
                 continue;
             }
             echo "\n{$name}: {$value} <br>\n";
         }
     } else {
         echo "\n\n<br>CONFIG: could not load\n\n";
     }
 }
Example #2
0
 function __construct($args = array())
 {
     $defaults = array('username' => null, 'requiredLevel' => 0);
     $p = Pommo_Api::getParams($defaults, $args);
     if (empty(Pommo::$_session['username'])) {
         Pommo::$_session['username'] = $p['username'];
     }
     $this->_username =& Pommo::$_session['username'];
     $this->_permissionLevel = $this->getPermissionLevel($this->_username);
     if ($p['requiredLevel'] > $this->_permissionLevel) {
         Pommo::kill(sprintf(Pommo::_T('Denied access. You must %slogin%s to' . ' access this page...'), '<a href="' . Pommo::$_baseUrl . 'index.php?referer=' . $_SERVER['PHP_SELF'] . '">', '</a>'));
     }
 }
Example #3
0
 /**
  * Register function that will be called when the script terminates abruptly.
  * Get code, test and id from URL.
  * Retrieve mailing (subject, body, attachments, etc) that will be sent.
  *
  * @param array $args.- Configuration overwrites
  */
 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.) TODO: Find another way to do this
     $_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();
 }
Example #4
0
/**********************************
	SETUP TEMPLATE, PAGE
 *********************************/
require_once Pommo::$_baseDir . 'classes/Pommo_Template.php';
$view = new Pommo_Template();
// Read user requested changes
if (!empty($_POST['throttle_restore'])) {
    $input = array('throttle_MPS' => 3, 'throttle_BPS' => 0, 'throttle_DP' => 10, 'throttle_DBPP' => 0, 'throttle_DMPP' => 0);
    Pommo_Api::configUpdate($input, TRUE);
    $view->assign('output', _('Configuration Updated.'));
} elseif (!empty($_POST['throttle-submit'])) {
    $input = array();
    $input['throttle_MPS'] = is_numeric($_POST['mps']) && $_POST['mps'] >= 0 && $_POST['mps'] <= 5 ? $_POST['mps'] : 3;
    $input['throttle_BPS'] = is_numeric($_POST['bps']) && $_POST['bps'] >= 0 && $_POST['bps'] <= 400 ? $_POST['bps'] * 1024 : 0;
    $input['throttle_DP'] = is_numeric($_POST['dp']) && $_POST['dp'] >= 5 && $_POST['dp'] <= 20 ? $_POST['dp'] : 10;
    $input['throttle_DMPP'] = is_numeric($_POST['dmpp']) && $_POST['dmpp'] >= 0 && $_POST['dmpp'] <= 5 ? $_POST['dmpp'] : 0;
    $input['throttle_DBPP'] = is_numeric($_POST['dbpp']) && $_POST['dbpp'] >= 0 && $_POST['dbpp'] <= 200 ? $_POST['dbpp'] * 1024 : 0;
    if (!empty($input)) {
        Pommo_Api::configUpdate($input, TRUE);
        $view->assign('output', _('Configuration Updated.'));
    } else {
        $view->assign('output', _('Please review and correct errors with your submission.'));
    }
}
$config = Pommo_Api::configGet(array('throttle_MPS', 'throttle_BPS', 'throttle_DP', 'throttle_DBPP', 'throttle_DMPP'));
$view->assign('mps', $config['throttle_MPS'] * 60);
$view->assign('bps', $config['throttle_BPS'] / 1024);
$view->assign('dp', $config['throttle_DP']);
$view->assign('dmpp', $config['throttle_DMPP']);
$view->assign('dbpp', $config['throttle_DBPP'] / 1024);
$view->display('admin/setup/config/ajax.throttle');
Example #5
0
     $sql = 'DROP TABLE IF EXISTS ' . $table;
     $dbo->query($sql);
 }
 if (isset($_REQUEST['debugInstall'])) {
     $dbo->debug(TRUE);
 }
 $install = Pommo_Install::parseSQL();
 if ($install) {
     // installation of DB went OK, set configuration values to user supplied ones
     $pass = $_POST['admin_password'];
     // install configuration
     $_POST['admin_password'] = md5($_POST['admin_password']);
     Pommo_Api::configUpdate($_POST);
     // generate key to uniquely identify this installation
     $key = Pommo_Helper::makeCode(6);
     Pommo_Api::configUpdate(array('key' => $key), TRUE);
     Pommo::reloadConfig();
     // load configuration [depricated?], set message defaults, load templates
     require_once Pommo::$_baseDir . 'classes/Pommo_Helper_Messages.php';
     Pommo_Helper_Messages::resetDefault('all');
     // install templates
     $file = Pommo::$_baseDir . 'sql/sql.templates.php';
     if (!Pommo_Install::parseSQL(false, $file)) {
         $logger->addErr('Error Loading Default Mailing Templates.');
     }
     $logger->addMsg(Pommo::_T('Installation Complete! You may now login and setup poMMo.'));
     $logger->addMsg(Pommo::_T('Login Username: '******'admin');
     $logger->addMsg(Pommo::_T('Login Password: '******'installed', TRUE);
 } else {
     // INSTALL FAILED
Example #6
0
require_once Pommo::$_baseDir . 'classes/Pommo_Template.php';
$view = new Pommo_Template();
if (empty($_GET['code'])) {
    $logger->addMsg(Pommo::_T('No code given.'));
    $view->display('user/confirm');
    Pommo::kill();
}
// lookup code
$pending = Pommo_Pending::get($_GET['code']);
if (!$pending) {
    $logger->addMsg(Pommo::_T('Invalid code! Make sure you copied it correctly from the email.'));
    $view->display('user/confirm');
    Pommo::kill();
}
// Load success messages and redirection URL from config
$config = Pommo_Api::configGet(array('site_success', 'messages', 'notices'));
$messages = unserialize($config['messages']);
$notices = unserialize($config['notices']);
if (Pommo_Pending::perform($pending)) {
    require_once Pommo::$_baseDir . 'classes/Pommo_Helper_Messages.php';
    // get subscriber info
    require_once Pommo::$_baseDir . 'classes/Pommo_Subscribers.php';
    $subscriber = current(Pommo_Subscribers::get(array('id' => $pending['subscriber_id'])));
    switch ($pending['type']) {
        case "add":
            // send/print welcome message
            Pommo_Helper_Messages::sendMessage(array('to' => $subscriber['email'], 'type' => 'subscribe'));
            if (isset($notices['subscribe']) && $notices['subscribe'] == 'on') {
                Pommo_Helper_Messages::notify($notices, $subscriber, 'subscribe');
            }
            if (!empty($config['site_success'])) {
Example #7
0
 * 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_Groups.php';
Pommo::init();
$logger = Pommo::$_logger;
$dbo = Pommo::$_dbo;
// Remember the Page State
$state = Pommo_Api::stateInit('subscribers_manage');
// Fetch group + member IDs
$group = new Pommo_Groups($state['group'], $state['status'], $state['search']);
/**********************************
	JSON OUTPUT INITIALIZATION
 *********************************/
require_once Pommo::$_baseDir . 'classes/Pommo_Json.php';
$json = new Pommo_Json();
/**********************************
	PAGINATION AND ORDERING
*********************************/
// Get and Remember the requested number of rows
if (!empty($_REQUEST['page']) && (is_numeric($_REQUEST['rows']) && ($_REQUEST['rows'] > 0 && $_REQUEST['rows'] <= 1000))) {
    $state['limit'] = $_REQUEST['rows'];
}
// Get and Remember the requested page
Example #8
0
// ** check if email already exists in DB ("duplicates are bad..")
if (Pommo_Helper::isDupe($subscriber['email'])) {
    $logger->addErr(Pommo::_T('Email address already exists. Duplicates are not allowed.'));
    $smarty->assign('dupe', TRUE);
}
// check if errors exist with data, if so print results and die.
if ($logger->isErr() || !Pommo_Validate::subscriberData($subscriber['data'], array('active' => FALSE))) {
    $smarty->assign('back', TRUE);
    $smarty->display('user/process.tpl');
    Pommo::kill();
}
$comments = isset($_POST['comments']) ? substr($_POST['comments'], 0, 255) : false;
/**********************************
	ADD SUBSCRIBER
 *********************************/
$config = Pommo_Api::configGet(array('site_success', 'site_confirm', 'list_confirm', 'notices'));
$notices = unserialize($config['notices']);
require_once Pommo::$_baseDir . 'classes/Pommo_Helper_Messages.php';
if ($config['list_confirm'] == 'on') {
    // email confirmation required.
    // add user as "pending"
    $subscriber['pending_code'] = Pommo_Helper::makeCode();
    $subscriber['pending_type'] = 'add';
    $subscriber['status'] = 2;
    $id = Pommo_Subscribers::add($subscriber);
    if (!$id) {
        $logger->addErr('Error adding subscriber! Please contact the administrator.');
        $smarty->assign('back', TRUE);
    } else {
        $logger->addMsg(Pommo::_T('Subscription request received.'));
        // send confirmation message.
Example #9
0
 function subscriberData(&$in, $p = array())
 {
     $defaults = array('prune' => true, 'active' => true, 'log' => true, 'ignore' => false, 'ignoreInactive' => true, 'skipReq' => false);
     $p = Pommo_Api::getParams($defaults, $p);
     require_once Pommo::$_baseDir . 'classes/Pommo_Fields.php';
     $logger = Pommo::$_logger;
     $fields = Pommo_Fields::get(array('active' => $p['active']));
     $valid = true;
     foreach ($fields as $id => $field) {
         $inactive = $field['active'] == 'on' ? false : true;
         if (!isset($in[$id]) && $p['skipReq']) {
             continue;
         }
         $in[$id] = @trim($in[$id]);
         if (empty($in[$id])) {
             unset($in[$id]);
             // don't include blank values
             if ($field['required'] == 'on') {
                 if ($p['log']) {
                     $logger->addErr(sprintf(Pommo::_T('%s is a required field.'), $field['prompt']));
                 }
                 $valid = false;
             }
             continue;
         }
         // shorten
         $in[$id] = substr($in[$id], 0, 255);
         switch ($field['type']) {
             case "checkbox":
                 if (strtolower($in[$id]) == 'true') {
                     $in[$id] = 'on';
                 }
                 if (strtolower($in[$id]) == 'false') {
                     $in[$id] = '';
                 }
                 if ($in[$id] != 'on' && $in[$id] != '') {
                     if ($p['ignore'] || $inactive && $p['ignoreInactive']) {
                         unset($in[$id]);
                         break;
                     }
                     if ($p['log']) {
                         $logger->addErr(sprintf(Pommo::_T('Illegal input for field %s.'), $field['prompt']));
                     }
                     $valid = false;
                 }
                 break;
             case "multiple":
                 if (is_array($in[$id])) {
                     foreach ($in[$id] as $key => $val) {
                         if (!in_array($val, $field['array'])) {
                             if ($p['ignore'] || $inactive && $p['ignoreInactive']) {
                                 unset($in[$id]);
                                 break;
                             }
                             if ($p['log']) {
                                 $logger->addErr(sprintf(Pommo::_T('Illegal input for field %s.'), $field['prompt']));
                             }
                             $valid = false;
                         }
                     }
                 } elseif (!in_array($in[$id], $field['array'])) {
                     if ($p['ignore'] || $inactive && $p['ignoreInactive']) {
                         unset($in[$id]);
                         break;
                     }
                     if ($p['log']) {
                         $logger->addErr(sprintf(Pommo::_T('Illegal input for field %s.'), $field['prompt']));
                     }
                     $valid = false;
                 }
                 break;
             case "date":
                 // convert date to timestamp [float; using adodb time library]
                 if (is_numeric($in[$id])) {
                     $in[$id] = Pommo_Helper::timeToStr($in[$id]);
                 }
                 $in[$id] = Pommo_Helper::timeFromStr($in[$id]);
                 if (!$in[$id]) {
                     if ($p['ignore'] || $inactive && $p['ignoreInactive']) {
                         unset($in[$id]);
                         break;
                     }
                     if ($p['log']) {
                         $logger->addErr(sprintf(Pommo::_T('Field (%s) must be a date (' . Pommo_Helper::timeGetFormat() . ').'), $field['prompt']));
                     }
                     $valid = false;
                 }
                 break;
             case "number":
                 if (!is_numeric($in[$id])) {
                     if ($p['ignore'] || $inactive && $p['ignoreInactive']) {
                         unset($in[$id]);
                         break;
                     }
                     if ($p['log']) {
                         $logger->addErr(sprintf(Pommo::_T('Field (%s) must be a number.'), $field['prompt']));
                     }
                     $valid = false;
                 }
                 break;
         }
     }
     // prune
     if ($p['prune']) {
         $in = Pommo_Helper::arrayIntersect($in, $fields);
     }
     return $valid;
 }
Example #10
0
require 'bootstrap.php';
require_once Pommo::$_baseDir . 'classes/Pommo_Sql.php';
require_once Pommo::$_baseDir . 'classes/Pommo_Groups.php';
require_once Pommo::$_baseDir . 'classes/Pommo_Fields.php';
require_once Pommo::$_baseDir . 'classes/Pommo_Rules.php';
Pommo::init();
$logger = Pommo::$_logger;
$dbo = Pommo::$_dbo;
/**********************************
	SETUP TEMPLATE, PAGE
 *********************************/
require_once Pommo::$_baseDir . 'classes/Pommo_Template.php';
$view = new Pommo_Template();
$view->assign('returnStr', _('Groups Page'));
// Initialize page state with default values overriden by those held in $_REQUEST
$state =& Pommo_Api::stateInit('groups_edit', array('group' => 0), $_REQUEST);
$groups = Pommo_Groups::get();
$fields = Pommo_Fields::get();
$group =& $groups[$state['group']];
if (empty($group)) {
    Pommo::redirect('subscribers_groups.php');
}
$rules = Pommo_Sql::sortRules($group['rules']);
$rules['and'] = Pommo_Sql::sortLogic($rules['and']);
$rules['or'] = Pommo_Sql::sortLogic($rules['or']);
foreach ($rules as $key => $a) {
    if ($key == 'include' || $key == 'exclude') {
        foreach ($a as $k => $gid) {
            $rules[$key][$k] = $groups[$gid]['name'];
        }
    }
Example #11
0
 function prepareMail($subject = NULL, $body = NULL, $HTML = FALSE, $altbody = NULL, $attachments = NULL)
 {
     $this->_subject = $subject;
     $this->_body = $body;
     $this->_altbody = $altbody;
     $this->_attachments = $attachments;
     // ** Set PHPMailer class parameters
     if ($this->_validated == FALSE) {
         // Validate mail parameters
         if (!$this->validate()) {
             return false;
         }
         // TODO -> should I just set PHPMailer parameters in the 1st place & skip $this->_paramName ?
         // TODO -> pass these by reference ??
         // set the character set
         $this->CharSet = $this->_charset;
         $this->FromName = $this->_fromname;
         $this->From = $this->_fromemail;
         $this->Subject = $this->_subject;
         // set Sender (bounce address)
         $this->Sender = $this->_frombounce;
         // if safe mode is on && using sendmail, force php mail() as excahnger [sendmail will not send w/ safe mode on]
         if (ini_get('safe_mode') && $this->_exchanger == 'sendmail') {
             $this->_exchanger = 'mail';
         }
         // make sure exchanger is valid, DEFAULT to PHP Mail
         if ($this->_exchanger != "mail" && $this->_exchanger != "sendmail" && $this->_exchanger != "smtp") {
             $this->_exchanger = "mail";
         }
         $this->Mailer = $this->_exchanger;
         if ($this->Mailer == 'smtp') {
             // loads the default relay (#1) -- use setRelay() to change.
             $config = Pommo_Api::configGet('smtp_1');
             $smtp = unserialize($config['smtp_1']);
             if (!empty($smtp['host'])) {
                 $this->Host = $smtp['host'];
             }
             if (!empty($smtp['port'])) {
                 $this->Port = $smtp['port'];
             }
             if (!empty($smtp['auth']) && $smtp['auth'] == 'on') {
                 $this->SMTPAuth = TRUE;
                 $this->SMTPSecure = $smtp['security'];
                 if (!empty($smtp['user'])) {
                     $this->Username = $smtp['user'];
                 }
                 if (!empty($smtp['pass'])) {
                     $this->Password = $smtp['pass'];
                 }
             }
         }
         // if altbody exists, set message type to HTML + add alt body
         if ($HTML) {
             $this->IsHTML(TRUE);
             if (!empty($this->_altbody)) {
                 $this->AltBody = $this->_altbody;
             }
         }
         $this->Body = $this->_body;
         // passed all sanity checks...
         $this->_validated = TRUE;
     }
     return TRUE;
 }
 function resetDefault($section = 'all')
 {
     global $pommo;
     $dbo =& Pommo::$_dbo;
     $messages = array();
     if ($section != 'all') {
         $config = Pommo_Api::configGet(array('messages'));
         $messages = unserialize($config['messages']);
     }
     if ($section == 'all' || $section == 'subscribe') {
         $messages['subscribe'] = array();
         $messages['subscribe']['msg'] = sprintf(Pommo::_T('Welcome to our mailing list. You can always login to update your records or unsubscribe by visiting: %s'), "\n  " . Pommo::$_http . Pommo::$_baseUrl . 'login.php');
         $messages['subscribe']['sub'] = sprintf(Pommo::_T('Welcome to %s'), Pommo::$_config['list_name']);
         $messages['subscribe']['web'] = Pommo::_T('Welcome to our mailing list. Enjoy your stay.');
         $messages['subscribe']['email'] = false;
     }
     if ($section == 'all' || $section == 'unsubscribe') {
         $messages['unsubscribe'] = array();
         $messages['unsubscribe']['sub'] = sprintf(Pommo::_T('Farewell from %s'), Pommo::$_config['list_name']);
         $messages['unsubscribe']['msg'] = Pommo::_T('You have been unsubscribed and will not receive any more mailings from us. Feel free to come back anytime!');
         $messages['unsubscribe']['web'] = Pommo::_T('You have successfully unsubscribed. Enjoy your travels.');
         $messages['unsubscribe']['email'] = false;
     }
     if ($section == 'all' || $section == 'confirm') {
         $messages['confirm'] = array();
         $messages['confirm']['msg'] = sprintf(Pommo::_T('You have requested to subscribe to %s. We would like to validate your email address before adding you as a subscriber. Please click the link below to be added ->'), Pommo::$_config['list_name']) . "\r\n\t[[url]]\r\n\r\n" . Pommo::_T('If you have received this message in error, please ignore it.');
         $messages['confirm']['sub'] = Pommo::_T('Subscription request');
     }
     if ($section == 'all' || $section == 'activate') {
         $messages['activate'] = array();
         $messages['activate']['msg'] = sprintf(Pommo::_T('Someone has requested to access to your records for %s.'), Pommo::$_config['list_name']) . ' ' . Pommo::_T('You may edit your information or unsubscribe by visiting the link below ->') . "\r\n\t[[url]]\r\n\r\n" . Pommo::_T('If you have received this message in error, please ignore it.');
         $messages['activate']['sub'] = sprintf(Pommo::_T('%s: Account Access.'), Pommo::$_config['list_name']);
     }
     if ($section == 'all' || $section == 'password') {
         $messages['password'] = array();
         $messages['password']['msg'] = sprintf(Pommo::_T('You have requested to change your password for %s.'), Pommo::$_config['list_name']) . ' ' . Pommo::_T('Please validate this request by clicking the link below ->') . "\r\n\t[[url]]\r\n\r\n" . Pommo::_T('If you have received this message in error, please ignore it.');
         $messages['password']['sub'] = Pommo::_T('Change Password request');
     }
     if ($section == 'all' || $section == 'update') {
         $messages['update'] = array();
         $messages['update']['msg'] = sprintf(Pommo::_T('You have requested to update your records for %s.'), Pommo::$_config['list_name']) . ' ' . Pommo::_T('Please validate this request by clicking the link below ->') . "\n\n\t[[url]]\n\n" . Pommo::_T('If you have received this message in error, please ignore it.');
         $messages['update']['sub'] = Pommo::_T('Update Records request');
     }
     $input = array('messages' => serialize($messages));
     Pommo_Api::configUpdate($input, TRUE);
     return $messages;
 }
Example #13
0
Pommo::init();
$logger = Pommo::$_logger;
$dbo = Pommo::$_dbo;
/**********************************
	SETUP TEMPLATE, PAGE
 *********************************/
require_once Pommo::$_baseDir . 'classes/Pommo_Template.php';
$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
*********************************/
Example #14
0
 *********************************/
require '../bootstrap.php';
Pommo::init();
$dbo =& Pommo::$_dbo;
/**********************************
	JSON OUTPUT INITIALIZATION
 *********************************/
require_once Pommo::$_baseDir . 'classes/Pommo_Json.php';
$json = new Pommo_Json();
// EXAMINE CALL
switch ($_REQUEST['call']) {
    case 'wysiwyg':
        // update wysiwyg ++ state
        $wysiwyg = isset($_REQUEST['enable']) ? 'on' : 'off';
        Pommo::$_session['state']['mailing']['wysiwyg'] = $wysiwyg;
        Pommo_Api::configUpdate(array('list_wysiwyg' => $wysiwyg), true);
        break;
    case 'savebody':
        Pommo::$_session['state']['mailing']['body'] = $_REQUEST['body'];
        Pommo::$_session['state']['mailing']['altbody'] = $_REQUEST['altbody'];
        break;
    case 'altbody':
        require_once Pommo::$_baseDir . 'lib/lib.html2txt.php';
        $h2t =& new html2text($_REQUEST['body']);
        $json->add('altbody', $h2t->get_text());
        break;
    case 'getTemplateDescription':
        require_once Pommo::$_baseDir . 'classes/Pommo_Mailing_Template.php';
        $template = Pommo_Mailing_Template::getDescriptions(array('id' => $_REQUEST['id']));
        $msg = empty($template[$_REQUEST['id']]) ? 'Unknown' : $template[$_REQUEST['id']];
        die($msg);
 function &getDescriptions($p = array())
 {
     $defaults = array('id' => null, 'name' => null);
     $p = Pommo_Api::getParams($defaults, $p);
     global $pommo;
     $dbo =& Pommo::$_dbo;
     $o = array();
     $query = "\n\t\t\tSELECT template_id, description\n\t\t\tFROM " . $dbo->table['templates'] . "\n\t\t\tWHERE\n\t\t\t\t1\n\t\t\t\t[AND name='%S']\n\t\t\t\t[AND template_id IN(%C)]\n\t\t\tORDER BY name";
     $query = $dbo->prepare($query, array($p['name'], $p['id']));
     while ($row = $dbo->getRows($query)) {
         $o[$row['template_id']] = $row['description'];
     }
     return $o;
 }
Example #16
0
    	 *********************************/
    require_once Pommo::$_baseDir . 'classes/Pommo_Json.php';
    $json = new Pommo_Json();
    if ($state['tally'] > 0) {
        if ($state['ishtml'] == 'off') {
            $state['body'] = $state['altbody'];
            $state['altbody'] = '';
        }
        $mailing = Pommo_Mailing::make(array(), TRUE);
        $state['status'] = 1;
        $state['current_status'] = 'stopped';
        $state['command'] = 'restart';
        $mailing = Pommo_Helper::arrayIntersect($state, $mailing);
        $code = Pommo_Mailing::add($mailing);
        if (!Pommo_Mail_Ctl::queueMake($memberIDs)) {
            $json->fail('Unable to populate queue');
        }
        if (!Pommo_Mail_Ctl::spawn(Pommo::$_baseUrl . 'ajax/mailings_send4.php?code=' . $code)) {
            $json->fail('Unable to spawn background mailer');
        }
        // clear mailing composistion data from session
        Pommo_Api::stateReset(array('mailing'));
        $json->add('callbackFunction', 'redirect');
        $json->add('callbackParams', Pommo::$_baseUrl . 'mailing_status.php');
    } else {
        $json->fail(Pommo::_T('Cannot send a mailing to 0 subscribers!'));
    }
    $json->serve();
}
$smarty->assign($state);
$smarty->display('admin/mailings/mailing/preview.tpl');
Example #17
0
Pommo::init(array('sessionID' => $serial, 'keep' => TRUE, 'authLevel' => 0));
$logger = Pommo::$_logger;
$dbo = Pommo::$_dbo;
// don't die on query so we can capture logs'
// NOTE: Be extra careful to check the success of queries/methods!
$dbo->dieOnQuery(FALSE);
// turn logging off unless verbosity is 1
if (Pommo::$_verbosity > 1) {
    $dbo->debug(FALSE);
}
// start error logging
Pommo::logErrors();
/**********************************
    STARTUP ROUTINES
 *********************************/
$config = Pommo_Api::configGet(array('list_exchanger', 'maxRuntime', 'smtp_1', 'smtp_2', 'smtp_3', 'smtp_4', 'throttle_SMTP', 'throttle_MPS', 'throttle_BPS', 'throttle_DP', 'throttle_DMPP', 'throttle_DBPP'));
// NOTE: PR15 removed multimode (simultaneous SMTP relays) variables + functionality!
//	we will be migrating to swiftmailer, and its multi-SMTP support/balancing in PR16-ish.
/**********************************
 * MAILING INITIALIZATION
 *********************************/
// calculate spawn # (number of times this MTA has spawned under this serial)
Pommo::$_session['spawn'] = isset(Pommo::$_session['spawn']) ? Pommo::$_session['spawn'] + 1 : 1;
// initialize MTA
$pommoMtaConfig = array('queueSize' => 100, 'maxRunTime' => $config['maxRuntime'], 'serial' => $serial, 'spawn' => Pommo::$_session['spawn']);
$mailing = new Pommo_Mta($pommoMtaConfig);
$logger->addMsg(sprintf(Pommo::_T('Started Mailing MTA. Spawn #%s.'), $pommoMtaConfig['spawn']), 3, TRUE);
// poll mailing status
$mailing->poll();
// check if message body contains personalizations
// personalizations are cached in session
Example #18
0
 static function reloadConfig()
 {
     return self::$_config = Pommo_Api::configGetBase(TRUE);
 }
Example #19
0
 static function &get($p = array())
 {
     $defaults = array('id' => null);
     $p = Pommo_Api::getParams($defaults, $p);
     $dbo =& Pommo::$_dbo;
     $o = array();
     $query = "\n            SELECT g.group_id, g.group_name, c.rule_id, c.field_id, c.logic, c.value, c.type\n            FROM " . $dbo->table['groups'] . " g\n            LEFT JOIN " . $dbo->table['group_rules'] . " c\n                ON (g.group_id = c.group_id)\n            WHERE\n                1\n                [AND g.group_id IN(%C)]\n            ORDER BY g.group_name";
     $query = $dbo->prepare($query, array($p['id']));
     while ($row = $dbo->getRows($query)) {
         if (empty($o[$row['group_id']])) {
             $o[$row['group_id']] = Pommo_Groups::makeDB($row);
         }
         if (!empty($row['rule_id'])) {
             $c = array('field_id' => $row['field_id'], 'logic' => $row['logic'], 'value' => $row['value'], 'or' => $row['type'] == 0 ? false : true);
             $o[$row['group_id']]['rules'][$row['rule_id']] = $c;
         }
     }
     return $o;
 }
Example #20
0
 * 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;
// Remember the Page State
$state =& Pommo_Api::stateInit('mailings_history');
/**********************************
	JSON OUTPUT INITIALIZATION
 *********************************/
require_once Pommo::$_baseDir . 'classes/Pommo_Json.php';
$json = new Pommo_Json();
/**********************************
	PAGINATION AND ORDERING
*********************************/
// Get and Remember the requested number of rows
if (!empty($_REQUEST['page']) && (is_numeric($_REQUEST['rows']) && ($_REQUEST['rows'] > 0 && $_REQUEST['rows'] <= 1000))) {
    $state['limit'] = $_REQUEST['rows'];
}
// Get and Remember the requested page
if (!empty($_REQUEST['page']) && (is_numeric($_REQUEST['page']) && $_REQUEST['page'] <= $state['pages'])) {
    $state['page'] = $_REQUEST['page'];
Example #21
0
        $messages['confirm']['sub'] = $_POST['confirm_sub'];
        $messages['confirm']['msg'] = $_POST['confirm_msg'];
        $messages['activate'] = array();
        $messages['activate']['sub'] = $_POST['activate_sub'];
        $messages['activate']['msg'] = $_POST['activate_msg'];
        $messages['update'] = array();
        $messages['update']['sub'] = $_POST['update_sub'];
        $messages['update']['msg'] = $_POST['update_msg'];
        $notices = array();
        $notices['email'] = $_POST['notify_email'];
        $notices['subject'] = $_POST['notify_subject'];
        $notices['subscribe'] = $_POST['notify_subscribe'];
        $notices['unsubscribe'] = $_POST['notify_unsubscribe'];
        $notices['update'] = $_POST['notify_update'];
        $notices['pending'] = $_POST['notify_pending'];
        $input = array('messages' => serialize($messages), 'notices' => serialize($notices));
        Pommo_Api::configUpdate($input, TRUE);
        $json->success(Pommo::_T('Configuration Updated.'));
    } else {
        // __ FORM NOT VALID
        $json->add('fieldErrors', $smarty->getInvalidFields('messages'));
        $json->fail(Pommo::_T('Please review and correct errors with your submission.'));
    }
}
$smarty->assign('t_subscribe', Pommo::_T('Subscription'));
$smarty->assign('t_unsubscribe', Pommo::_T('Unsubscription'));
$smarty->assign('t_pending', Pommo::_T('Pending'));
$smarty->assign('t_update', Pommo::_T('Update'));
$smarty->assign($_POST);
$smarty->display('admin/setup/config/messages.tpl');
Pommo::kill();
Example #22
0
/**********************************
	SETUP TEMPLATE, PAGE
 *********************************/
require_once Pommo::$_baseDir . 'classes/Pommo_Template.php';
$smarty = new Pommo_Template();
//	log the user out if requested
if (isset($_GET['logout'])) {
    Pommo::$_auth->logout();
    header('Location: ' . Pommo::$_http . Pommo::$_baseUrl . 'index.php');
}
// 	check if user is already logged in
if (Pommo::$_hasConfigFile && Pommo::$_auth->isAuthenticated()) {
    // If user is authenticated (has logged in), redirect to admin.php
    Pommo::redirect(Pommo::$_http . Pommo::$_baseUrl . 'admin.php');
} elseif (isset($_POST['submit']) && !empty($_POST['username']) && !empty($_POST['password'])) {
    $auth = Pommo_Api::configGet(array('admin_username', 'admin_password'));
    if ($_POST['username'] == $auth['admin_username'] && md5($_POST['password']) == $auth['admin_password']) {
        // don't perform maintenance if accessing support area
        if (!isset($_GET['referer']) || !basename($_GET['referer']) == 'support.php') {
            // login success. Perform maintenance, set auth, redirect to referer
            require_once Pommo::$_baseDir . 'classes/Pommo_Helper_Maintenance.php';
            Pommo_Helper_Maintenance::perform();
        }
        Pommo::$_auth->login($_POST['username']);
        Pommo::redirect(Pommo::$_http . $_POST['referer']);
    } else {
        $logger->addMsg(Pommo::_T('Failed login attempt. Try again.'));
    }
} elseif (!empty($_POST['resetPassword'])) {
    // TODO -- visit this function later
    // Check if a reset password request has been received
Example #23
0
Pommo::init();
$logger =& Pommo::$_logger;
$dbo =& Pommo::$_dbo;
/**********************************
	SETUP TEMPLATE, PAGE
 *********************************/
require_once Pommo::$_baseDir . 'classes/Pommo_Template.php';
$smarty = new Pommo_Template();
$smarty->prepareForForm();
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>'));
}
$dbvalues = Pommo_Api::configGet(array('list_fromname', 'list_fromemail', 'list_frombounce', 'list_charset', 'list_wysiwyg'));
// Initialize page state with default values overriden by those held in $_REQUEST
$state = Pommo_Api::stateInit('mailing', array('fromname' => $dbvalues['list_fromname'], 'fromemail' => $dbvalues['list_fromemail'], 'frombounce' => $dbvalues['list_frombounce'], 'list_charset' => $dbvalues['list_charset'], 'wysiwyg' => $dbvalues['list_wysiwyg'], 'mailgroup' => 'all', 'subject' => '', 'body' => '', 'altbody' => ''), $_POST);
// SmartyValidate Custom Validation Function
function check_charset($value, $empty, &$params, &$formvars)
{
    $validCharsets = array('UTF-8', 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-7', 'ISO-8859-15', 'cp1251', 'KOI8-R', 'GB2312', 'EUC-JP', 'ISO-2022-JP');
    return in_array($value, $validCharsets);
}
if (!SmartyValidate::is_registered_form() || empty($_POST)) {
    // ___ USER HAS NOT SENT FORM ___
    SmartyValidate::connect($smarty, true);
    // register custom criteria
    SmartyValidate::register_criteria('isCharSet', 'check_charset');
    SmartyValidate::register_validator('fromname', 'fromname', 'notEmpty', false, false, 'trim');
    SmartyValidate::register_validator('subject', 'subject', 'notEmpty', false, false, 'trim');
    SmartyValidate::register_validator('fromemail', 'fromemail', 'isEmail', false, false, 'trim');
    SmartyValidate::register_validator('frombounce', 'frombounce', 'isEmail', false, false, 'trim');
Example #24
0
 function perform(&$in)
 {
     global $pommo;
     $dbo =& Pommo::$_dbo;
     $logger =& Pommo::$_logger;
     if (!is_numeric($in['id']) || !is_numeric($in['subscriber_id'])) {
         $logger->addErr('Pommo_Pending::perform() -> invalid pending object sent.');
         return false;
     }
     switch ($in['type']) {
         case 'add':
             // subscribe
             $query = "\n\t\t\t\t\tUPDATE " . $dbo->table['subscribers'] . "\n\t\t\t\t\tSET status=1\n\t\t\t\t\tWHERE subscriber_id=%i";
             $query = $dbo->prepare($query, array($in['subscriber_id']));
             if (!$dbo->query($query)) {
                 $logger->addErr('Pommo_Pending::perform() -> Error updating subscriber.');
                 return false;
             }
             break;
         case 'change':
             // update
             require_once Pommo::$_baseDir . 'classes/Pommo_Subscribers.php';
             $subscriber =& $in['array'];
             if (!Pommo_Subscribers::update($subscriber, 'REPLACE_ACTIVE')) {
                 $logger->addErr('Pommo_Pending::perform() -> Error updating subscriber.');
                 return false;
             }
             break;
         case 'password':
             // change (admin) password
             require_once Pommo::$_baseDir . 'classes/Pommo_Subscribers.php';
             $password = Pommo_Helper::makePassword();
             $config = Pommo_Api::configGet(array('admin_username', 'admin_email'));
             if (!Pommo_Api::configUpdate(array('admin_password' => md5($password)), TRUE)) {
                 $logger->addMsg('Error updating password.');
                 return false;
             }
             $logger->addErr(sprintf(Pommo::_T('You may now %1$s login %2$s with username: %3$s and password: %4$s '), '<a href="' . Pommo::$_baseUrl . 'index.php">', '</a>', '<span style="font-size: 130%">' . $config['admin_username'] . '</span>', '<span style="font-size: 130%">' . $password . '</span>'));
             break;
     }
     $query = "\n\t\t\tDELETE FROM " . $dbo->table['subscriber_pending'] . "\n\t\t\tWHERE pending_id=%i";
     $query = $dbo->prepare($query, array($in['id']));
     if (!$dbo->query($query)) {
         $logger->addErr('Pommo_Pending::perform() -> Error removing pending entry.');
         return false;
     }
     return true;
 }
Example #25
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');
Example #26
0
 public static function get($p = array())
 {
     $defaults = array('active' => false, 'noBody' => false, 'id' => null, 'code' => null, 'sort' => null, 'order' => null, 'limit' => null, 'offset' => null);
     if ($p['forHistory']) {
         $forHistory = 1;
         unset($p['forHistory']);
     }
     $p = Pommo_Api::getParams($defaults, $p);
     $dbo =& Pommo::$_dbo;
     $p['active'] = $p['active'] ? 1 : null;
     if (is_numeric($p['limit']) && !is_numeric($p['offset'])) {
         $p['offset'] = 0;
     }
     $o = array();
     //	We modify the query if the mailings are for the history section
     if (1 == $forHistory) {
         $field = "COUNT(h.subscriber_id) AS hits";
         $join = "LEFT JOIN " . $dbo->table['mailings_hits'] . " h ON (h.mailing_id = m.mailing_id)";
     } else {
         $field = "GROUP_CONCAT(a.file_name) AS file_name";
         $join = "LEFT JOIN " . $dbo->table['mailings_attachments'] . " ma ON (m.mailing_id = ma.mailing_id)\n            LEFT JOIN " . $dbo->table['attachment_files'] . " a ON (ma.file_id = a.file_id)";
     }
     $select = "m.mailing_id,\n                c.command,\n                c.serial,\n                c.securityCode,\n                c.current_status,\n                c.touched,\n                fromname,\n                fromemail,\n                frombounce,\n                subject,\n                ishtml,\n                mailgroup,\n                subscriberCount,\n                started,\n                finished,\n                sent,\n                charset,\n                status,\n                track,\n                " . $field;
     if (!$p['noBody']) {
         $select .= ", body, altbody";
     }
     $query = "SELECT {$select}\n            FROM " . $dbo->table['mailings'] . " m\n            LEFT JOIN " . $dbo->table['mailing_current'] . " c ON (m.mailing_id = c.current_id) " . $join . " WHERE\n                1\n                [AND m.status=%I]\n                [AND m.mailing_id IN(%C)]\n                [AND c.securityCode='%S']\n                GROUP BY mailing_id\n                [ORDER BY %S] [%S]\n                [LIMIT %I, %I]";
     $query = $dbo->prepare($query, array($p['active'], $p['id'], $p['code'], $p['sort'], $p['order'], $p['offset'], $p['limit']));
     while ($row = $dbo->getRows($query)) {
         $o[$row['mailing_id']] = Pommo_Mailing::makeDB($row);
     }
     return $o;
 }
Example #27
0
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 */
/**********************************
	INITIALIZATION METHODS
*********************************/
require '../bootstrap.php';
Pommo::init();
$logger =& Pommo::$_logger;
$dbo =& Pommo::$_dbo;
/**********************************
	SETUP TEMPLATE, PAGE
 *********************************/
require_once Pommo::$_baseDir . 'classes/Pommo_Template.php';
$smarty = new Pommo_Template();
$smarty->prepareForForm();
$exchanger = current(Pommo_Api::configGet(array('list_exchanger')));
SmartyValidate::connect($smarty);
if (!SmartyValidate::is_registered_form('exchanger') || empty($_POST)) {
    // ___ USER HAS NOT SENT FORM ___
    SmartyValidate::register_form('exchanger', true);
    SmartyValidate::register_validator('email', 'email', 'isEmail', false, false, false, 'exchanger');
    $vMsg = array();
    $vMsg['email'] = Pommo::_T('Invalid email address');
    $smarty->assign('vMsg', $vMsg);
    $dbvals = array('exchanger' => $exchanger, 'email' => Pommo::$_config['admin_email']);
    $smarty->assign($dbvals);
} else {
    // ___ USER HAS SENT FORM ___
    /**********************************
    		JSON OUTPUT INITIALIZATION
    	 *********************************/
Example #28
0
 static function get($p = array())
 {
     $defaults = array('active' => false, 'id' => null, 'byName' => false);
     $p = Pommo_Api::getParams($defaults, $p);
     $dbo = Pommo::$_dbo;
     $p['active'] = $p['active'] ? 'on' : null;
     $p['byName'] = $p['byName'] ? 'field_name' : 'field_ordering';
     $o = array();
     $query = "\n            SELECT *\n            FROM " . $dbo->table['fields'] . "\n            WHERE\n                1\n                [AND field_active='%S']\n                [AND field_id IN(%C)]\n            ORDER BY " . $p['byName'];
     $query = $dbo->prepare($query, array($p['active'], $p['id']));
     while ($row = $dbo->getRows($query)) {
         $o[$row['field_id']] = Pommo_Fields::makeDB($row);
     }
     return $o;
 }
Example #29
0
    $validator->setPost($_POST);
    $validator->addData('list_name', 'Other', false);
    $validator->addData('site_name', 'Other', false);
    $validator->addData('site_url', 'Url', false);
    $validator->addData('site_success', 'Url', true);
    $validator->addData('site_confirm', 'Url', true);
    $validator->addData('list_confirm', 'matchRegex', false, '!^(on|off)$!');
    $validator->addData('list_exchanger', 'matchRegex', false, '!^(sendmail|mail|smtp)$!');
    /**********************************
    		JSON OUTPUT INITIALIZATION
    	 *********************************/
    require_once Pommo::$_baseDir . 'classes/Pommo_Json.php';
    $json = new Pommo_Json();
    if ($result = $validator->checkData()) {
        // __ FORM IS VALID
        Pommo_Api::configUpdate($_POST);
        Pommo::reloadConfig();
        $json->success(Pommo::_T('Configuration Updated.'));
    } else {
        // __ FORM NOT VALID
        $fieldErrors = array();
        $errors = $validator->getErrors();
        foreach ($errors as $key => $val) {
            $fieldErrors[] = array('field' => $key, 'message' => $val);
        }
        $json->add('fieldErrors', $fieldErrors);
        $json->fail(Pommo::_T('Please review and correct errors with your submission.'));
    }
}
$view->assign($_POST);
$view->display('admin/setup/config/general');
Example #30
0
    Pommo_Api::configUpdate($input, TRUE);
    $update = true;
} elseif (!empty($_POST['deleteSmtpServer'])) {
    $input['smtp_' . key($_POST['deleteSmtpServer'])] = '';
    Pommo_Api::configUpdate($input, TRUE);
    $update = true;
} elseif (!empty($_POST['throttle_SMTP'])) {
    $input['throttle_SMTP'] = $_POST['throttle_SMTP'];
    Pommo_Api::configUpdate($input);
    $update = true;
}
if (isset($update)) {
    $smarty->assign('output', $update ? Pommo::_T('Configuration Updated.') : Pommo::_T('Please review and correct errors with your submission.'));
}
// Get the SMTP settings from DB
$smtpConfig = Pommo_Api::configGet(array('smtp_1', 'smtp_2', 'smtp_3', 'smtp_4', 'throttle_SMTP'));
$smtp[1] = unserialize($smtpConfig['smtp_1']);
$smtp[2] = unserialize($smtpConfig['smtp_2']);
$smtp[3] = unserialize($smtpConfig['smtp_3']);
$smtp[4] = unserialize($smtpConfig['smtp_4']);
if (empty($smtp[1])) {
    $smtp[1] = array('host' => 'mail.localhost', 'port' => '25', 'auth' => 'off', 'user' => '', 'pass' => '');
}
// Test the servers
$addServer = FALSE;
$smtpStatus = array();
for ($i = 1; $i < 5; $i++) {
    if (empty($smtp[$i])) {
        if (!$addServer) {
            $addServer = $i;
        }