function Pommo_Db($username = NULL, $password = NULL, $database = NULL, $hostname = NULL, $tablePrefix = NULL) { // turn off magic quotes runtime if (get_magic_quotes_runtime()) { if (!set_magic_quotes_runtime(0)) { Pommo::kill('Could not turn off PHP\'s magic_quotes_runtime'); } } $this->_prefix = $tablePrefix; $this->_database = $database; $this->table = array('config' => '`' . $tablePrefix . 'config`', 'fields' => '`' . $tablePrefix . 'fields`', 'group_rules' => '`' . $tablePrefix . 'group_rules`', 'groups' => '`' . $tablePrefix . 'groups`', 'mailing_notices' => '`' . $tablePrefix . 'mailing_notices`', 'mailing_current' => '`' . $tablePrefix . 'mailing_current`', 'mailings' => '`' . $tablePrefix . 'mailings`', 'scratch' => '`' . $tablePrefix . 'scratch`', 'subscriber_data' => '`' . $tablePrefix . 'subscriber_data`', 'subscriber_pending' => '`' . $tablePrefix . 'subscriber_pending`', 'subscriber_update' => '`' . $tablePrefix . 'subscriber_update`', 'subscribers' => '`' . $tablePrefix . 'subscribers`', 'templates' => '`' . $tablePrefix . 'templates`', 'queue' => '`' . $tablePrefix . 'queue`', 'updates' => '`' . $tablePrefix . 'updates`'); $this->_dieOnQuery = TRUE; $this->_debug = FALSE; $this->_results = array(); // connect to mysql database using config variables from poMMo class (set in setup/config.php). // supress errors to hide login information... $this->_link = mysql_connect($hostname, $username, $password); if (!$this->_link) { Pommo::kill(Pommo::_T('Could not establish database connection.') . ' ' . Pommo::_T('Verify your settings in config.php')); } if (!@mysql_select_db($database, $this->_link)) { Pommo::kill(sprintf(Pommo::_T('Connected to database server but could not select database (%s). Does it exist?'), $database) . ' ' . Pommo::_T('Verify your settings in config.php')); } // Make sure any results we retrieve or commands we send use the same charset and collation as the database: // code taken from Juliette Reinders Folmer; http://www.adviesenzo.nl/examples/php_mysql_charset_fix/ // TODO: Cache the charset? $db_charset = mysql_query("SHOW VARIABLES LIKE 'character_set_database'", $this->_link); $charset_row = mysql_fetch_assoc($db_charset); mysql_query("SET NAMES '" . $charset_row['Value'] . "'", $this->_link); unset($db_charset, $charset_row); // setup safeSQL class $this->_safeSQL = new SafeSQL_MySQL($this->_link); }
function parseSQL($ignoreerrors = false, $file = false) { $dbo = Pommo::$_dbo; $logger = Pommo::$_logger; if (!$file) { $file = Pommo::$_baseDir . 'sql/sql.schema.php'; } $file_content = @file($file); if (empty($file_content)) { Pommo::kill('Error installing. Could not read ' . $file); } $query = ''; foreach ($file_content as $sql_line) { $tsl = trim($sql_line); if ($sql_line != "" && substr($tsl, 0, 2) != "--" && substr($tsl, 0, 1) != "#") { $query .= $sql_line; if (preg_match("/;\\s*\$/", $sql_line)) { $matches = array(); preg_match('/:::(.+):::/', $query, $matches); if ($matches[1]) { $query = preg_replace('/:::(.+):::/', $dbo->table[$matches[1]], $query); } $query = trim($query); if (!$dbo->query($query) && !$ignoreerrors) { $logger->addErr(Pommo::_T('Database Error: ') . $dbo->getError()); return false; } $query = ''; } } } return true; }
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>')); } }
function validate(&$in) { global $pommo; $invalid = array(); if (empty($in['name'])) { $invalid[] = 'name'; } if (empty($in['body']) && empty($in['altbody'])) { $invalid[] = Pommo::_T('Both HTML and Text cannot be empty'); } if (!empty($invalid)) { Pommo::$_logger->addErr(implode(',', $invalid), 3); return false; } return true; }
function perform() { Pommo_Helper_Maintenance::memorizeBaseURL(); if (is_file(Pommo::$_workDir . '/import.csv')) { if (!unlink(Pommo::$_workDir . '/import.csv')) { Pommo::kill('Unable to remove import.csv'); } } // truncate error log if (filesize(Pommo::$_workDir . '/ERROR_LOG') > 25) { rename(Pommo::$_workDir . '/ERROR_LOG', Pommo::$_workDir . '/ERROR_LOG_OLD'); } if (!($handle = fopen(Pommo::$_workDir . '/ERROR_LOG', 'w'))) { Pommo::$_logger->addErr(Pommo::_T('Can write to ERROR_LOG. Check work directory permissions!')); return; } fwrite($handle, "<?php die(); ?>\n"); fclose($handle); return true; }
function PommoGroup($groupID = NULL, $status = 1, $filter = FALSE) { $this->_status = $status; if (!is_numeric($groupID)) { // exception if no group ID was passed -- group assumes "all subscribers". $GLOBALS['pommo']->requireOnce($GLOBALS['pommo']->_baseDir . 'inc/helpers/subscribers.php'); $this->_group = array('rules' => array(), 'id' => 0); $this->_id = 0; $this->_name = Pommo::_T('All Subscribers'); $this->_memberIDs = is_array($filter) ? PommoGroup::getMemberIDs($this->_group, $status, $filter) : null; $this->_tally = is_array($filter) ? count($this->_memberIDs) : PommoSubscriber::tally($status); return; } $this->_group = current(PommoGroup::get(array('id' => $groupID))); $this->_id = $groupID; $this->_name =& $this->_group['name']; $this->_memberIDs = PommoGroup::getMemberIDs($this->_group, $status, $filter); $this->_tally = count($this->_memberIDs); return; }
function __construct($groupID = NULL, $status = 1, $filter = FALSE) { $this->_status = $status; if (!is_numeric($groupID)) { // exception if no group ID was passed -- group assumes "all subscribers". require_once Pommo::$_baseDir . 'classes/Pommo_Subscribers.php'; $this->_group = array('rules' => array(), 'id' => 0); $this->_id = 0; $this->_name = Pommo::_T('All Subscribers'); $this->_memberIDs = is_array($filter) ? Pommo_Groups::getMemberIDs($this->_group, $status, $filter) : null; $this->_tally = is_array($filter) ? count($this->_memberIDs) : Pommo_Subscribers::tally($status); return; } $this->_group = current(Pommo_Groups::get(array('id' => $groupID))); $this->_id = $groupID; $this->_name =& $this->_group['name']; $this->_memberIDs = Pommo_Groups::getMemberIDs($this->_group, $status, $filter); $this->_tally = count($this->_memberIDs); return; }
function display($resource_name, $cache_id = null, $compile_id = null, $display = false) { global $pommo; // attempt to load the theme's requested template if (!is_file($this->template_dir . '/' . $resource_name)) { // template file not existant in theme, fallback to "default" theme if (!is_file($this->_themeDir . 'default/' . $resource_name)) { // requested template file does not exist in "default" theme, die. Pommo::kill(sprintf(Pommo::_T('Template file (%s) not found in default or current theme'), $resource_name)); } else { $resource_name = $this->_themeDir . 'default/' . $resource_name; $this->template_dir = $this->_themeDir . 'default'; } } if ($pommo->_logger->isMsg()) { $this->assign('messages', $pommo->_logger->getMsg()); } if ($pommo->_logger->isErr()) { $this->assign('errors', $pommo->_logger->getErr()); } return parent::display($resource_name, $cache_id = null, $compile_id = null, $display = false); }
function display($resource_name) { $resource_name .= '.php'; // attempt to load the theme's requested template if (!is_file($this->template_dir . '/' . $resource_name)) { // template file not existant in theme, fallback to "default" theme if (!is_file($this->_themeDir . 'default/' . $resource_name)) { // requested template file does not exist in "default" theme, die. Pommo::kill(sprintf(Pommo::_T('Template file (%s) not found in' . ' default or current theme'), $resource_name)); } else { $resource_name = $this->_themeDir . 'default/' . $resource_name; $this->template_dir = $this->_themeDir . 'default'; } } else { $resource_name = $this->template_dir . '/' . $resource_name; } if (Pommo::$_logger->isMsg()) { $this->assign('messages', Pommo::$_logger->getMsg()); } if (Pommo::$_logger->isErr()) { $this->assign('errors', Pommo::$_logger->getErr()); } include $resource_name; }
$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');
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; }
if (!PommoInstall::parseSQL(false, $file)) { $logger->addErr('Error Loading Default Mailing Templates.'); } // serialize the latest updates $GLOBALS['pommoFakeUpgrade'] = true; Pommo::requireOnce($pommo->_baseDir . 'install/helper.upgrade.php'); PommoUpgrade(); $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 $dbo->debug(FALSE); // drop existing poMMo tables foreach (array_keys($dbo->table) as $key) { $table = $dbo->table[$key]; $sql = 'DROP TABLE IF EXISTS ' . $table; $dbo->query($sql); } $logger->addErr('Installation failed! Enable debbuging to expose the problem.'); } } } else { // __ FORM NOT VALID $logger->addMsg(Pommo::_T('Please review and correct errors with your submission.')); } } $smarty->assign($_POST); $smarty->display('install.tpl'); Pommo::kill();
/********************************** 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')); $view->assign('t_saveTemplate', Pommo::_T('Save Template')); $view->display('admin/mailings/mailings_start');
$field = current(PommoField::get(array('id' => $_REQUEST['field_id']))); if ($field['id'] != $_REQUEST['field_id']) { die('bad field ID'); } $affected = PommoField::subscribersAffected($field['id'], $_REQUEST['options']); if (count($affected) > 0 && empty($_REQUEST['confirmed'])) { $msg = sprintf(Pommo::_T('Deleting option %1$s will affect %2$s subscribers who have selected this choice. They will be flagged as needing to update their records.'), '<b>' . $_REQUEST['options'] . '</b>', '<em>' . count($affected) . '</em>'); $msg .= "\n " . Pommo::_T('Are you sure?'); $json->add('callbackFunction', 'confirm'); $json->add('callbackParams', $msg); $json->serve(); } else { Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/subscribers.php'); $options = PommoField::optionDel($field, $_REQUEST['options']); if (!options) { $json->fail(Pommo::_T('Error with deletion.')); } // flag subscribers for update if (count($affected) > 0) { PommoSubscriber::flagByID($affected); } $json->add('callbackFunction', 'updateOptions'); $json->add('callbackParams', $options); $json->serve(); } break; default: die('invalid request passed to ' . __FILE__); break; } die;
*/ /********************************** INITIALIZATION METHODS *********************************/ require '../../bootstrap.php'; Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/groups.php'); Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/fields.php'); $pommo->init(); $logger =& $pommo->_logger; $dbo =& $pommo->_dbo; /********************************** SETUP TEMPLATE, PAGE *********************************/ Pommo::requireOnce($pommo->_baseDir . 'inc/classes/template.php'); $smarty = new PommoTemplate(); $smarty->assign('returnStr', Pommo::_T('Subscribers Page')); /** SET PAGE STATE * limit - The Maximum # of subscribers to show per page * sort - The subscriber field to sort by (email, ip, time_registered, time_touched, status, or field_id) * order - Order Type (ascending - ASC /descending - DESC) * info - (hide/show) Time Registered/Updated, IP address * * status - Filter by subscriber status (active, inactive, pending, all) * group - Filter by group members (groupID or 'all') */ // Initialize page state with default values overriden by those held in $_REQUEST $state =& PommoAPI::stateInit('subscribers_manage', array('limit' => 150, 'sort' => $pommo->_default_subscriber_sort, 'order' => 'asc', 'status' => 1, 'group' => 'all', 'page' => 1, 'search' => false), $_REQUEST); /********************************** VALIDATION ROUTINES *********************************/ if (!is_numeric($state['limit']) || $state['limit'] < 1 || $state['limit'] > 1000) {
$key = key($_POST['updateSmtpServer']); $server = array('host' => $_POST['host'][$key], 'port' => $_POST['port'][$key], 'auth' => $_POST['auth'][$key], 'user' => $_POST['user'][$key], 'pass' => $_POST['pass'][$key]); $input['smtp_' . $key] = serialize($server); PommoAPI::configUpdate($input, TRUE); $update = true; } elseif (!empty($_POST['deleteSmtpServer'])) { $input['smtp_' . key($_POST['deleteSmtpServer'])] = ''; PommoAPI::configUpdate($input, TRUE); $update = true; } elseif (!empty($_POST['throttle_SMTP'])) { $input['throttle_SMTP'] = $_POST['throttle_SMTP']; PommoAPI::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 = PommoAPI::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])) {
$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)); PommoAPI::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();
/********************************** STARTUP ROUTINES *********************************/ $config = PommoAPI::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')); $p = array('queueSize' => 100, 'maxRunTime' => $config['maxRuntime'], 'serial' => $serial); // 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; $p['spawn'] = $pommo->_session['spawn']; // initialize MTA $mailing = new PommoMTA($p); $logger->addMsg(sprintf(Pommo::_T('Started Mailing MTA. Spawn #%s.'), $p['spawn']), 3, TRUE); // poll mailing status $mailing->poll(); // check if message body or title contains personalizations // personalizations are cached in session Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/personalize.php'); // require once here so that mailer can use Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/personalizetitle.php'); // require once here so that mailer can use if (!isset($pommo->_session['personalization'])) { $pommo->_session['personalization'] = FALSE; $matches1 = array(); $matches2 = array(); $matches3 = array(); preg_match('/\\[\\[[^\\]]+]]/', $mailing->_mailing['body'], $matches1); preg_match('/\\[\\[[^\\]]+]]/', $mailing->_mailing['altbody'], $matches2);
$state['command'] = 'restart'; $state['charset'] = $state['list_charset']; $mailing = PommoHelper::arrayIntersect($state, $mailing); $code = PommoMailing::add($mailing); // populate queue $queue = array($key); if (!PommoMailCtl::queueMake($queue)) { $logger->addErr('Unable to Populate Queue'); } else { if (!PommoMailCtl::spawn($pommo->_baseUrl . 'admin/mailings/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); } } 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 . 'admin/setup/setup_configure.php#mailings">', '</a>')); } $smarty->assign('fields', PommoField::get()); $smarty->display('admin/mailings/mailing/ajax.mailingtest.tpl'); Pommo::kill();
// __ 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.')); } } $f_text = sprintf(Pommo::_T('%s - Any value will be accepted for text fields. They are useful for collecting names, addresses, etc.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Text') . ')</strong>'); $f_check = sprintf(Pommo::_T('%s - Checkboxes can be toggled ON or OFF. They are useful for opt-ins and agreements.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Checkbox') . ')</strong>'); $f_num = sprintf(Pommo::_T('%s - Only Numeric values will be accepted for number fields.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Number') . ')</strong>'); $f_date = sprintf(Pommo::_T('%s - Only calendar values will be accepted for this field. A date selector (calendar popup) will appear next to the field to aid the subscriber in selecting a date.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Date') . ')</strong>'); $f_mult = sprintf(Pommo::_T('%s - Subscribers will be able to select a value from the options you provide below. Multiple choice fields have reliable values for organizing, and are useful for collecting Country, Interests, etc.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Multiple Choice') . ')</strong>'); $f_comm = sprintf(Pommo::_T('%s -. If a subscriber enters a value for a comment field, it will be mailed to the admin notification email.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Comment') . ')</strong>'); switch ($field['type']) { case 'text': $view->assign('intro', $f_text); break; case 'checkbox': $view->assign('intro', $f_check); break; case 'number': $view->assign('intro', $f_num); break; case 'date': $view->assign('intro', $f_date); break; case 'multiple': $view->assign('intro', $f_mult);
$msg = Pommo::_T('subscription request'); $pending['type'] = 'confirm'; // normalize for Pommo_Helper_Messages::sendMessage break; case "change": $msg = Pommo::_T('record update request'); $pending['type'] = 'update'; // normalize for Pommo_Helper_Messages::sendMessage break; case "password": $msg = Pommo::_T('password change request'); break; default: Pommo::redirect('login.php?badPendingType=TRUE'); } // check if user wants to reconfirm or cancel their request if (!empty($_POST)) { if (isset($_POST['reconfirm'])) { require_once Pommo::$_baseDir . 'classes/Pommo_Helper_Messages.php'; Pommo_Helper_Messages::sendMessage(array('to' => $input['Email'], 'code' => $pending['code'], 'type' => $pending['type'])); } elseif (isset($_POST['cancel'])) { if (Pommo_Pending::cancel($pending)) { $logger->addMsg(sprintf(Pommo::_T('Your %s has been cancelled.'), $msg)); } } $smarty->assign('nodisplay', TRUE); } else { $logger->addMsg(sprintf(Pommo::_T('Your %s is still pending. To complete this request, please review the confirmation email sent to %s.'), $msg, $input['Email'])); } $smarty->display('user/pending.tpl'); Pommo::kill();
* (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 * */ /********************************** 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>')); } $view->display('admin/mailings/admin_mailings');
*********************************/ $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. if (Pommo_Helper_Messages::sendMessage(array('to' => $subscriber['email'], 'code' => $subscriber['pending_code'], 'type' => 'confirm'))) { $subscriber['registered'] = date("F j, Y, g:i a", $subscriber['registered']); if ($comments || isset($notices['pending']) && $notices['pending'] == 'on') { Pommo_Helper_Messages::notify($notices, $subscriber, 'pending', $comments); } if ($config['site_confirm']) { Pommo::redirect($config['site_confirm']); } } else { $smarty->assign('back', TRUE); // delete the subscriber Pommo_Subscribers::delete($id); } }
$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'])) { Pommo::redirect($config['site_success']); } break; case "change": if (isset($notices['update']) && $notices['update'] == 'on') { Pommo_Helper_Messages::notify($notices, $subscriber, 'update'); } $logger->addMsg(Pommo::_T('Your records have been updated.')); break; case "password": break; default: $logger->addMsg('Unknown Pending Type.'); break; } } $view->display('user/confirm');
Pommo::init(); $logger = Pommo::$_logger; $dbo = Pommo::$_dbo; /********************************** SETUP TEMPLATE, PAGE *********************************/ require_once Pommo::$_baseDir . 'classes/Pommo_Template.php'; $view = new Pommo_Template(); /********************************** JSON OUTPUT INITIALIZATION *********************************/ require_once Pommo::$_baseDir . 'classes/Pommo_Json.php'; $json = new Pommo_Json(); $success = false; if (isset($_POST['skip']) || isset($_POST['template']) && !is_numeric($_POST['template'])) { $success = true; } elseif (isset($_POST['load'])) { $template = current(Pommo_Mailing_Template::get(array('id' => $_POST['template']))); Pommo::$_session['state']['mailing']['body'] = $template['body']; Pommo::$_session['state']['mailing']['altbody'] = $template['altbody']; $success = true; } elseif (isset($_POST['delete'])) { $msg = Pommo_Mailing_Template::delete($_POST['template']) ? Pommo::_T('Template Deleted') : Pommo::_T('Error with deletion.'); $json->add('callbackFunction', 'deleteTemplate'); $json->add('callbackParams', array('id' => $_POST['template'], 'msg' => $msg)); } else { $view->assign('templates', Pommo_Mailing_Template::getNames()); $view->display('admin/mailings/mailing/templates'); Pommo::kill(); } $json->serve($success);
SETUP TEMPLATE, PAGE *********************************/ Pommo::requireOnce($pommo->_baseDir . 'inc/classes/template.php'); $smarty = new PommoTemplate(); // 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); PommoAPI::configUpdate($input, TRUE); $smarty->assign('output', Pommo::_T('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)) { PommoAPI::configUpdate($input, TRUE); $smarty->assign('output', Pommo::_T('Configuration Updated.')); } else { $smarty->assign('output', Pommo::_T('Please review and correct errors with your submission.')); } } $config = PommoAPI::configGet(array('throttle_MPS', 'throttle_BPS', 'throttle_DP', 'throttle_DBPP', 'throttle_DMPP')); $smarty->assign('mps', $config['throttle_MPS'] * 60); $smarty->assign('bps', $config['throttle_BPS'] / 1024); $smarty->assign('dp', $config['throttle_DP']); $smarty->assign('dmpp', $config['throttle_DMPP']); $smarty->assign('dbpp', $config['throttle_DBPP'] / 1024); $smarty->display('admin/setup/config/ajax.throttle.tpl'); Pommo::kill();
echo "<input type=\"text\" name=\"d[" . $field_id . "]\" id=\"field" . $field_id . "\" maxlength=\"60\" />\r\n"; } else { echo "<input type=\"text\" name=\"d[" . $field_id . "]\" maxlength=\"60\" value=\"" . htmlspecialchars($field['normally']) . "\" />\r\n"; } break; default: break; } echo "</div>\r\n\r\n"; } ?> </fieldset> <div id="buttons"> <!-- *** DO NOT CHANGE name="pommo_signup" ! *** If you'd like to change the button text change the "value=" text. --> <input type="hidden" name="pommo_signup" value="true" /> <input type="submit" value="<?php echo Pommo::_T('Subscribe'); ?> " /> </div> </form> </body> </html>
} // ====== CSV EXPORT ====== if ($_POST['type'] == 'csv') { if (!$ids) { $group = new PommoGroup($state['group'], $state['status']); $subscribers = $group->members(); } else { $subscribers = PommoSubscriber::get(array('id' => $ids)); } // supply headers $o = '"' . Pommo::_T('Email') . '"'; if (!empty($_POST['registered'])) { $o .= ',"' . Pommo::_T('Date Registered') . '"'; } if (!empty($_POST['ip'])) { $o .= ',"' . Pommo::_T('IP Address') . '"'; } foreach ($fields as $f) { $o .= ",\"{$f['name']}\""; } $o .= "\r\n"; function csvWrap(&$in) { $in = '"' . addslashes($in) . '"'; return; } foreach ($subscribers as $sub) { $d = array(); // normalize field order in export foreach (array_keys($fields) as $id) { if (array_key_exists($id, $sub['data'])) {
$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');
/********************************** SETUP TEMPLATE, PAGE *********************************/ require_once Pommo::$_baseDir . 'classes/Pommo_Template.php'; $view = new Pommo_Template(); $emails = Pommo::get('emails'); $dupes = Pommo::get('dupes'); $fields = Pommo_Fields::get(); $flag = FALSE; foreach ($fields as $field) { if ($field['required'] == 'on') { $flag = TRUE; } } if (isset($_GET['continue'])) { foreach ($emails as $email) { $subscriber = array('email' => $email, 'registered' => time(), 'ip' => $_SERVER['REMOTE_ADDR'], 'status' => 1, 'data' => array()); if ($flag) { $subscriber['flag'] = 9; } if (!Pommo_Subscribers::add($subscriber)) { die('Error importing subscriber'); } } sleep(1); die(Pommo::_T('Complete!') . ' <a href="subscribers_import.php">' . Pommo::_T('Return to') . ' ' . Pommo::_T('Import') . '</a>'); } $view->assign('flag', $flag); $view->assign('tally', count($emails)); $view->assign('dupes', $dupes); $view->display('admin/subscribers/import_txt');