Example #1
0
 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');
     $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) {
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;
}
Example #3
0
 /** 
  * init -> called by page to load page state, populate config, and track authentication. 
  *	valid args [ passed as Pommo::init(array('arg' => val, 'arg2' => val)) ] ->
  *		authLevel	:	check that authenticated permission level is at least authLevel (non authenticated == 0). exit if not high enough. [default: 1]
  *		keep		:	keep data stored in session. [default: false]
  *		session		:	explicity set session name. [default: null]
  * 		install		:	bypass loading of config/version checking [default: false]
  */
 function init($args = array())
 {
     $defaults = array('authLevel' => 1, 'keep' => FALSE, 'noSession' => FALSE, 'sessionID' => NULL, 'install' => FALSE);
     // merge submitted parameters
     $p = PommoAPI::getParams($defaults, $args);
     // Bypass Reading of Config, SESSION creation, and authentication checks and return
     //  if 'install' passed
     if ($p['install']) {
         return;
     }
     // load configuration data
     // note; cannot save in session, as session needs unique key -- this is simplest method.
     $this->_config = PommoAPI::configGetBase();
     // check current ("file") revision against database ("last") revision
     $revision = isset($this->_config['revision']) ? $this->_config['revision'] : false;
     if (!defined('_poMMo_support')) {
         if (!$revision) {
             $this->kill(sprintf(Pommo::_T('Error loading configuration. Has poMMo been installed? %sClick Here%s to install.'), '<a href="' . $this->_baseUrl . 'install/install.php">', '</a>'));
         } elseif ($this->_revision != $revision) {
             $this->kill(sprintf(Pommo::_T('Version Mismatch. %sClick Here%s to upgrade.'), '<a href="' . $this->_baseUrl . 'install/upgrade.php">', '</a>'));
         }
     }
     // toggle DB debugging
     if ($this->_debug) {
         $this->_dbo->debug(TRUE);
     }
     // Bypass SESSION creation, reading of config, authentication checks and return
     //  if 'noSession' passed
     if ($p['noSession']) {
         return;
     }
     // start the session
     if (!empty($p['sessionID'])) {
         session_id($p['sessionID']);
     }
     $this->startSession();
     // check for "session" language -- user defined language on the fly.
     if ($this->_slanguage) {
         $this->_session['slanguage'] = $this->_slanguage;
     }
     if (isset($this->_session['slanguage'])) {
         if ($this->_session['slanguage'] == 'en') {
             $this->_l10n = FALSE;
         } else {
             $this->_l10n = TRUE;
             Pommo::requireOnce($this->_baseDir . 'inc/helpers/l10n.php');
             PommoHelperL10n::init($this->_session['slanguage'], $this->_baseDir);
         }
         $this->_slanguage = $this->_session['slanguage'];
     }
     // if authLevel == '*' || _poMMo_support (0 if poMMo not installed, 1 if installed)
     if (defined('_poMMo_support')) {
         Pommo::requireOnce($this->_baseDir . 'inc/classes/install.php');
         $p['authLevel'] = PommoInstall::verify() ? 1 : 0;
     }
     // check authentication levels
     $this->_auth = new PommoAuth(array('requiredLevel' => $p['authLevel']));
     // clear SESSION 'data' unless keep is passed.
     // TODO --> phase this out in favor of page state system?
     // -- add "persistent" flag & complicate state initilization...
     if (!$p['keep']) {
         $this->_session['data'] = array();
     }
 }
Example #4
0
*********************************/
require '../bootstrap.php';
Pommo::requireOnce($pommo->_baseDir . 'inc/classes/install.php');
$pommo->init(array('authLevel' => 0, 'install' => TRUE));
$pommo->reloadConfig();
$logger =& $pommo->_logger;
$dbo =& $pommo->_dbo;
$dbo->dieOnQuery(FALSE);
/**********************************
	SETUP TEMPLATE, PAGE
 *********************************/
Pommo::requireOnce($pommo->_baseDir . 'inc/classes/template.php');
$smarty = new PommoTemplate();
$smarty->prepareForForm();
// Check to make sure poMMo is installed
if (!PommoInstall::verify()) {
    $logger->addErr(sprintf(Pommo::_T('poMMo does not appear to be installed! Please %s INSTALL %s before attempting an upgrade.'), '<a href="' . $pommo->_baseUrl . 'install/install.php">', '</a>'));
    $smarty->display('upgrade.tpl');
    Pommo::kill();
}
// Check to make sure poMMo is PR14 or higher.
if ($pommo->_config['revision'] < 26) {
    $logger->addErr('Upgrade path unavailable. Cannot upgrade from Aardvark PR13.2 or below!');
    $smarty->display('upgrade.tpl');
    Pommo::kill();
}
// Check to make sure poMMo is not already up to date.
if ($pommo->_config['revision'] == $pommo->_revision && !isset($_REQUEST['forceUpgrade']) && !isset($_REQUEST['continue'])) {
    $logger->addErr(sprintf(Pommo::_T('poMMo appears to be up to date. If you want to force an upgrade, %s click here %s'), '<a href="' . $_SERVER['PHP_SELF'] . '?forceUpgrade=TRUE">', '</a>'));
    $smarty->display('upgrade.tpl');
    Pommo::kill();