$input['smtp_' . key($_POST['addSmtpServer'])] = serialize($server); PommoAPI::configUpdate($input, TRUE); $update = true; } elseif (!empty($_POST['updateSmtpServer'])) { $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
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();
$sql = 'DROP TABLE IF EXISTS ' . $table; $dbo->query($sql); } if (isset($_REQUEST['debugInstall'])) { $dbo->debug(TRUE); } $install = PommoInstall::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']); PommoAPI::configUpdate($_POST); // generate key to uniquely identify this installation $key = PommoHelper::makeCode(6); PommoAPI::configUpdate(array('key' => $key), TRUE); $pommo->reloadConfig(); // load configuration [depricated?], set message defaults, load templates Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/messages.php'); PommoHelperMessages::resetDefault('all'); // install templates $file = $pommo->_baseDir . "install/sql.templates.php"; 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');
*********************************/ require '../../../bootstrap.php'; $pommo->init(); $dbo =& $pommo->_dbo; /********************************** JSON OUTPUT INITIALIZATION *********************************/ Pommo::requireOnce($pommo->_baseDir . 'inc/classes/json.php'); $json = new PommoJSON(); // EXAMINE CALL switch ($_REQUEST['call']) { case 'wysiwyg': // update wysiwyg ++ state $wysiwyg = isset($_REQUEST['enable']) ? 'on' : 'off'; $pommo->_session['state']['mailing']['wysiwyg'] = $wysiwyg; PommoAPI::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': Pommo::requireOnce($pommo->_baseDir . 'inc/lib/lib.html2txt.php'); $h2t =& new html2text($_REQUEST['body']); $json->add('altbody', $h2t->get_text()); break; case 'getTemplateDescription': Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/templates.php'); $template = PommoMailingTemplate::getDescriptions(array('id' => $_REQUEST['id'])); $msg = empty($template[$_REQUEST['id']]) ? 'Aucune' : $template[$_REQUEST['id']]; die($msg);
$smarty->assign('vMsg', $vMsg); // populate _POST with info from database (fills in form values...) $dbVals = PommoAPI::configGet(array('admin_username')); $dbVals['admin_email'] = $pommo->_config['admin_email']; $smarty->assign($dbVals); } else { // ___ USER HAS SENT FORM ___ /********************************** JSON OUTPUT INITIALIZATION *********************************/ Pommo::requireOnce($pommo->_baseDir . 'inc/classes/json.php'); $json = new PommoJSON(); if (SmartyValidate::is_valid($_POST, 'users')) { // __ FORM IS VALID // convert password to MD5 if given... if (!empty($_POST['admin_password'])) { $_POST['admin_password'] = md5($_POST['admin_password']); } PommoAPI::configUpdate($_POST); unset($_POST['admin_password'], $_POST['admin_password2']); $pommo->reloadConfig(); $json->success(Pommo::_T('Configuration Updated.')); } else { // __ FORM NOT VALID $json->add('fieldErrors', $smarty->getInvalidFields('users')); $json->fail(Pommo::_T('Please review and correct errors with your submission.')); } } $smarty->assign($_POST); $smarty->display('admin/setup/config/users.tpl'); Pommo::kill();
function perform(&$in) { global $pommo; $dbo =& $pommo->_dbo; $logger =& $pommo->_logger; if (!is_numeric($in['id']) || !is_numeric($in['subscriber_id'])) { $logger->addErr('PommoPending::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('PommoPending::perform() -> Error updating subscriber.'); return false; } break; case 'change': // update $pommo->requireOnce($pommo->_baseDir . 'inc/helpers/subscribers.php'); $subscriber =& $in['array']; if (!PommoSubscriber::update($subscriber, 'REPLACE_ACTIVE')) { $logger->addErr('PommoPending::perform() -> Error updating subscriber.'); return false; } break; case 'password': // change (admin) password $pommo->requireOnce($pommo->_baseDir . 'inc/helpers/subscribers.php'); $password = PommoHelper::makePassword(); $config = PommoAPI::configGet(array('admin_username', 'admin_email')); if (!PommoAPI::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('PommoPending::perform() -> Error removing pending entry.'); return false; } return true; }
function PommoRevUpgrade($rev) { global $pommo; $logger =& $pommo->_logger; $dbo =& $pommo->_dbo; switch ($rev) { case 26: // Aardvark PR14 // manually add the serial column $query = "ALTER TABLE " . $dbo->table['updates'] . " ADD `serial` INT UNSIGNED NOT NULL"; if (!$dbo->query($query)) { Pommo::kill('Could not add serial column'); } if (!PommoInstall::incUpdate(1, "ALTER TABLE {$dbo->table['updates']} DROP `update_id` , DROP `update_serial`", "Dropping old Update columns")) { return false; } if (!PommoInstall::incUpdate(2, "ALTER TABLE {$dbo->table['updates']} ADD PRIMARY KEY ( `serial` )", "Adding Key to Updates Table")) { return false; } if (!PommoInstall::incUpdate(3, "CREATE TABLE {$dbo->table['mailing_notices']} (\n\t\t\t\t`mailing_id` int(10) unsigned NOT NULL,\n\t\t\t\t`notice` varchar(255) NOT NULL,\n\t\t\t\t`touched` timestamp NOT NULL,\n\t\t\t\tKEY `mailing_id` (`mailing_id`)\n\t\t\t)", "Adding Mailing Notice Table")) { return false; } if (!PommoInstall::incUpdate(4, "ALTER TABLE {$dbo->table['mailing_current']} DROP `notices`", "Dropping old Notice column")) { return false; } // bump revision if (!PommoAPI::configUpdate(array('revision' => 27), true)) { return false; } case 27: // Aardvark PR14.1 if (!PommoInstall::incUpdate(5, "CREATE TABLE {$dbo->table['subscriber_update']} (\n\t\t\t\t`email` varchar(60) NOT NULL,\n \t\t\t\t`code` char(32) NOT NULL ,\n \t\t\t\t`activated` datetime NULL default NULL ,\n \t\t\t\t`touched` timestamp(14) NOT NULL,\n\t\t\t\tPRIMARY KEY ( `email` )\n\t\t\t)", "Adding Update Activation Table")) { return false; } if (!PommoInstall::incUpdate(6, "INSERT INTO {$dbo->table['config']} VALUES ('public_history', 'off', 'Public Mailing History', 'off', 'on')", "Adding configuration of Public Mailings")) { return false; } Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/messages.php'); PommoHelperMessages::resetDefault(); // bump revision if (!PommoAPI::configUpdate(array('revision' => 28, 'version' => 'Aardvark PR14.2'), true)) { return false; } case 28: // Aardvark PR14.2 // bump revision if (!PommoAPI::configUpdate(array('revision' => 29, 'version' => 'Aardvark PR14.3'), true)) { return false; } case 29: // Aardvark PR14.3 // bump revision if (!PommoAPI::configUpdate(array('revision' => 30, 'version' => 'Aardvark PR14.3.1'), true)) { return false; } case 30: // Aardvark PR14.3.1 // bump revision if (!PommoAPI::configUpdate(array('revision' => 31, 'version' => 'Aardvark PR14.4'), true)) { return false; } break; case 31: // Aardvark PR14.4 // bump revision if (!PommoAPI::configUpdate(array('revision' => 32, 'version' => 'Aardvark PR14.4.1'), true)) { return false; } case 32: // Aardvark PR14.4.1 if (!PommoInstall::incUpdate(7, "RENAME TABLE {$dbo->table['group_criteria']} TO {$dbo->table['group_rules']}", "Renaming Group Rules Table")) { return false; } if (!PommoInstall::incUpdate(8, "ALTER TABLE {$dbo->table['group_rules']} CHANGE `criteria_id` `rule_id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT", "Renaming key column")) { return false; } if (!PommoAPI::configUpdate(array('revision' => 33, 'version' => 'Aardvark SVN'), true)) { return false; } case 33: // (svn development) -> Aardvark PR15 if (!PommoInstall::incUpdate(9, "ALTER TABLE {$dbo->table['group_rules']} ADD `type` TINYINT( 1 ) NOT NULL DEFAULT '0'", "Adding OR support to Group Rules")) { return false; } if (!PommoInstall::incUpdate(10, "INSERT INTO {$dbo->table['config']} (`config_name`, `config_value`, `config_description`, `autoload`, `user_change`) VALUES ('notices', '', '', 'off', 'off')", "Enabling Notification of Subscriber List Changes")) { return false; } if (!PommoInstall::incUpdate(11, "ALTER TABLE {$dbo->table['fields']} CHANGE `field_type` `field_type` ENUM( 'checkbox', 'multiple', 'text', 'date', 'number', 'comment' ) DEFAULT NULL", "Adding 'comments' field type")) { return false; } if (!PommoInstall::incUpdate(12, "ALTER TABLE {$dbo->table['mailing_notices']} ADD `id` SMALLINT UNSIGNED NULL", "Adding id to mailing notices")) { return false; } if (!PommoInstall::incUpdate(13, "ALTER TABLE {$dbo->table['mailing_current']} CHANGE `command` `command` ENUM( 'none', 'restart', 'stop', 'cancel' ) NOT NULL DEFAULT 'none'", "Adding cancel type to mailing commands")) { return false; } if (!PommoInstall::incUpdate(14, "INSERT INTO {$dbo->table['config']} (`config_name`, `config_value`, `config_description`, `autoload`, `user_change`) VALUES ('maxRuntime', '80', '', 'off', 'on')", "Enabling Mailing Runtime to be set in Config")) { return false; } if (!PommoInstall::incUpdate(15, "INSERT INTO {$dbo->table['config']} (`config_name`, `config_value`, `config_description`, `autoload`, `user_change`) VALUES ('list_wysiwyg', 'on', '', 'off', 'off')", "Persisting State of WYSIWYG Editor Toggle")) { return false; } if (!PommoInstall::incUpdate(16, "ALTER TABLE {$dbo->table['subscriber_data']} CHANGE `value` `value` CHAR( 60 ) NOT NULL", "Tuning Subscriber Data Table")) { return false; } if (!PommoInstall::incUpdate(17, "ALTER TABLE {$dbo->table['subscribers']} CHANGE `email` `email` CHAR( 60 ) NOT NULL", "Tuning Subscribers Table")) { return false; } if (!PommoInstall::incUpdate(18, "DROP TABLE {$dbo->table['subscriber_update']}", "Dropping previous activate routines")) { return false; } if (!PommoInstall::incUpdate(19, "CREATE TABLE {$dbo->table['templates']} (`template_id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, `name` VARCHAR( 60 ) NOT NULL DEFAULT 'name',`description` VARCHAR( 255 ) NULL ,`body` MEDIUMTEXT NULL ,`altbody` MEDIUMTEXT NULL, PRIMARY KEY(`template_id`))", "Adding mailing template support")) { return false; } // custom update 20, install default template $query = "\n\t\t\tSELECT serial FROM " . $dbo->table['updates'] . " \n\t\t\tWHERE serial=%i"; $query = $dbo->prepare($query, array('20')); if (!$dbo->records($query)) { $file = $pommo->_baseDir . "install/sql.templates.php"; if (PommoInstall::parseSQL(false, $file)) { $query = "INSERT INTO " . $dbo->table['updates'] . "(serial) VALUES(%i)"; $query = $dbo->prepare($query, array('20')); $dbo->query($query); } } // bump revision if (!PommoAPI::configUpdate(array('revision' => 34, 'version' => 'Aardvark PR15'), true)) { return false; } case 34: // Changes >= Aardvark PR15 $file = $pommo->_baseDir . "install/sql.templates.php"; if (!PommoInstall::parseSQL(false, $file)) { $logger->addErr('Error Loading Default Mailing Templates.'); } // bump revision if (!PommoAPI::configUpdate(array('revision' => 35, 'version' => 'Aardvark PR15.1'), true)) { return false; } case 35: // Aardvark PR15.1 // bump revision if (!PommoAPI::configUpdate(array('revision' => 36, 'version' => 'Aardvark SVN'), true)) { return false; } case 36: // SVN revision (applied to PR15.1, for next revision) if (!PommoInstall::incUpdate(21, "UPDATE {$dbo->table['config']} SET autoload='on' WHERE config_name='revision'", "Flagging Revision Autoloading")) { return false; } if (!PommoInstall::incUpdate(22, "DROP TABLE IF EXISTS {$dbo->table['subscriber_update']}", "Dropping previous activate routines")) { return false; } if (!PommoInstall::incUpdate(23, "CREATE TABLE {$dbo->table['scratch']} (\n\t\t\t\t`scratch_id` int(10) unsigned NOT NULL auto_increment,\n\t\t\t\t`time` TIMESTAMP NOT NULL,\n\t\t\t\t`type` SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Used to identify row type. 0 = undifined, 1 = ',\n\t\t\t\t`int` BIGINT NULL,\n\t\t\t\t`str` TEXT NULL,\n\t\t\t\tPRIMARY KEY (`scratch_id`),\n\t\t\t\tKEY `type`(`type`)\n\t\t\t\t) COMMENT = 'General Purpose Table for caches, counts, etc.'", "Adding Scratch Table")) { return false; } // bump revision if (!PommoAPI::configUpdate(array('revision' => 37, 'version' => 'Aardvark PR16rc1'), true)) { return false; } case 37: // bump revision if (!PommoAPI::configUpdate(array('revision' => 38, 'version' => 'Aardvark PR16rc2'), true)) { return false; } case 38: // bump revision if (!PommoAPI::configUpdate(array('revision' => 39, 'version' => 'Aardvark PR16rc3'), true)) { return false; } case 39: // bump revision if (!PommoAPI::configUpdate(array('revision' => 40, 'version' => 'Aardvark PR16rc4'), true)) { return false; } case 40: // bump revision if (!PommoAPI::configUpdate(array('revision' => 41, 'version' => 'Aardvark PR16'), true)) { return false; } case 41: $sql = 'Pommo::requireOnce($pommo->_baseDir . \'inc/helpers/messages.php\');PommoHelperMessages::resetDefault();'; if (!PommoInstall::incUpdate(24, $sql, "Resetting all Messages to Default", true)) { return false; } // bump revision if (!PommoAPI::configUpdate(array('revision' => 42, 'version' => 'Aardvark PR16.1'), true)) { return false; } case 42: // end of upgrade (break), no revision bump. break; default: return false; } return true; }
function resetDefault($section = 'all') { global $pommo; $dbo =& $pommo->_dbo; $messages = array(); if ($section != 'all') { $config = PommoAPI::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 . 'user/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)); PommoAPI::configUpdate($input, TRUE); return $messages; }