kill() public static method

* kill Used to terminate a script
public static kill ( $msg = NULL, $backtrace = FALSE )
$backtrace
Example #1
0
 function init($language, $baseDir)
 {
     if (!is_file($baseDir . 'language/' . $language . '/LC_MESSAGES/pommo.mo')) {
         Pommo::kill('Unknown Language (' . $language . ')');
     }
     // if LC_MESSAGES is not available.. make it (helpful for win32)
     if (!defined('LC_MESSAGES')) {
         define('LC_MESSAGES', 6);
     }
     // load gettext emulation layer if PHP is not compiled w/ gettext support
     if (!function_exists('gettext')) {
         require_once $baseDir . 'lib/gettext/gettext.php';
         require_once $baseDir . 'lib/gettext/gettext.inc';
     }
     // set the locale
     if (!Pommo_Helper_L10n::_setLocale(LC_MESSAGES, $language, $baseDir)) {
         // *** SYSTEM LOCALE COULD NOT BE USED, USE EMULTATION ****
         require_once $baseDir . 'lib/gettext/gettext.php';
         require_once $baseDir . 'lib/gettext/gettext.inc';
         if (!Pommo_Helper_L10n::_setLocaleEmu(LC_MESSAGES, $language, $baseDir)) {
             Pommo::kill('Error setting up language translation!');
         }
     } else {
         // *** SYSTEM LOCALE WAS USED ***
         if (!defined('_poMMo_gettext')) {
             // set gettext environment
             $domain = 'pommo';
             bindtextdomain($domain, $baseDir . 'language');
             textdomain($domain);
             if (function_exists('bind_textdomain_codeset')) {
                 bind_textdomain_codeset($domain, 'UTF-8');
             }
         }
     }
 }
 function memorizeBaseURL()
 {
     if (!($handle = fopen(Pommo::$_workDir . '/maintenance.php', 'w'))) {
         Pommo::kill('Unable to prepare maintenance.php for writing');
     }
     $fileContent = "<?php die(); ?>\n[baseURL] = \"Pommo::{$_baseUrl}\"\n";
     if (!fwrite($handle, $fileContent)) {
         Pommo::kill('Unable to perform maintenance');
     }
     fclose($handle);
 }
Example #3
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 #4
0
 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);
 }
Example #5
0
 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;
 }
Example #6
0
 public static function redirect($url, $msg = NULL, $kill = true)
 {
     // adds http & baseURL if they aren't already provided...
     //	allows code shortcuts ;)
     //  if url DOES NOT start with '/', the section will automatically be
     //	appended
     if (!preg_match('@^https?://@i', $url)) {
         if (strpos($url, Pommo::$_baseUrl) === false) {
             if (substr($url, 0, 1) != '/') {
                 if (Pommo::$_section != 'user' && Pommo::$_section != 'admin') {
                     $url = Pommo::$_http . Pommo::$_baseUrl . $url;
                 } else {
                     $url = Pommo::$_http . Pommo::$_baseUrl . Pommo::$_section . '/' . $url;
                 }
             } else {
                 $url = Pommo::$_http . Pommo::$_baseUrl . str_replace(Pommo::$_baseUrl, '', substr($url, 1));
             }
         } else {
             $url = Pommo::$_http . $url;
         }
     }
     header('Location: ' . $url);
     if ($kill) {
         if ($msg) {
             Pommo::kill($msg);
         } else {
             Pommo::kill(Pommo::_T('Redirecting, please wait...'));
         }
     }
     return;
 }
Example #7
0
 */
/**********************************
	INITIALIZATION METHODS
 *********************************/
require 'bootstrap.php';
require_once Pommo::$_baseDir . 'classes/Pommo_Mailing.php';
Pommo::init();
$logger = Pommo::$_logger;
$dbo = Pommo::$_dbo;
/**********************************
	SETUP TEMPLATE, PAGE
 *********************************/
require_once Pommo::$_baseDir . 'classes/Pommo_Template.php';
$view = new Pommo_Template();
if (Pommo_Mailing::isCurrent()) {
    Pommo::kill(sprintf(Pommo::_T('A Mailing is currently processing. Visit the' . ' %sStatus%s page to check its progress.'), '<a href="mailing_status.php">', '</a>'));
}
if (Pommo::$_config['demo_mode'] == 'on') {
    $logger->addMsg(sprintf(Pommo::_T('%sDemonstration Mode%s is on -- no Emails' . ' will actually be sent. This is good for testing settings.'), '<a href="' . Pommo::$_baseUrl . 'setup_configure.php#mailings">', '</a>'));
}
require_once Pommo::$_baseDir . 'themes/wysiwyg/editors.php';
$editors = new PommoWYSIWYG();
$editor = $editors->loadEditor();
if (!$editor) {
    die('Could not find requested WYSIWYG editor (' . $editor . ') in editors.php');
}
$view->assign('wysiwygJS', $editor);
// translation assignments for dialg titles...
$view->assign('t_personalization', Pommo::_T('Personalization'));
$view->assign('t_testMailing', Pommo::_T('Test Mailing'));
$view->assign('t_saveTemplate', Pommo::_T('Save Template'));
Example #8
0
    // make sure we can write to the file
    if (!($handle = fopen(Pommo::$_workDir . '/mailing.test.php', 'w'))) {
        Pommo::kill('Unable to write to test file!');
    }
    fclose($handle);
    unlink(Pommo::$_workDir . '/mailing.test.php');
    Pommo::kill('Initial Spawn Failed (test file not written to)! Test the mail processor.');
}
$die = false;
$time = 0;
while (!$die) {
    sleep(10);
    $o = Pommo_Helper::parseConfig(Pommo::$_workDir . '/mailing.test.php');
    if (!isset($o['code']) || $o['code'] != $code) {
        unlink(Pommo::$_workDir . '/mailing.test.php');
        Pommo::kill('Spawning Failed. Codes did not match.');
    }
    if (!isset($o['time']) || $time >= $o['time'] || $o['time'] == 90) {
        $die = true;
    }
    $time = $o['time'];
    echo "{$time} seconds <br />";
    ob_flush();
    flush();
}
unlink(Pommo::$_workDir . '/mailing.test.php');
if ($time == 90) {
    Pommo::kill('SUCCESS');
}
Pommo::kill('FAILED -- Your webserver or a 3rd party tool is force terminating PHP. Mailings may freeze. If you are having problems with frozen mailings, try setting the Mailing Runtime Value to ' . ($time - 10) . ' or below');
Example #9
0
 /** query function. 
  * 
  * Returns true if the query was successful, or false if not*. 
  *    * If $this->_dieOnQuery is set, a die() will be issued and the script halted. If _debug is set,
  *       the mysql_error will be appended to the die() call. _dieOnQuery is enabled by default.
  * 
  * If query is called with numeric arguments, a specific field is returned. This is useful for
  * SQL statements that return a single row, or multiple rows of a single column. 
  *   ex. 
  *      A] query($sql,3) -> returns 4th column of a resultset
  *      B] query($sql,0,2) -> returns the second column of the first row of a resultset.
  *   
  *     A is useful for a result set containing a single column, ie. "SELECT name FROM people";
  * 
  * Example invocations from partent script:
  * 
  *   $dbo = & Pommo::$_dbo;
  *   $dbo->dieOnQuery(TRUE);
  *   $dbo->debug(TRUE);
  * 
  *   $sql = "SOME SQL QUERY";
  *   if ($DB->query($sql)) {
  *   while ($row = mysql_fetch_assoc($dbo->_result)) { echo $row[fieldname]; }
  *   }
  *   
  *  $dbo->dieOnQuery(FALSE);
  * 
  *   $firstname = $dbo->query(SELECT phone,name FROM users,0,2);
  *   if (!$firstname) { echo "INVALID QUERY"; }
  *  
  *   $numRowsInSet = $dbo->records()
  *   $numRecordsChanged = $dbo->affected()
  * 
  *  :: EXAMPLE OF ITERATING THROUGH A RESULT SET (ROWS) ::
  * 
  * $sql = "SELECT name FROM users WHERE group='X'";
  * 	while ($row = $dbo->getRows($sql)) {
  *   	$sql = "UPDATE name SET group='Y' WHERE config_name='".$row['name']."'";
  * 			if (!$dbo->query($sql))
  * 				die('Error updating group for '.$row['name']);	
  * 		}
  * 	}
  */
 function &query(&$query, $row = NULL, $col = NULL)
 {
     global $pommo;
     $logger =& Pommo::$_logger;
     // execute query
     $this->_result = mysql_query($query, $this->_link);
     // output debugging info if enabled
     if ($this->_debug) {
         $numRecords = 0;
         // get # of records if a non bool was returned..
         if (!is_bool($this->_result)) {
             $numRecords = $this->records();
         }
         $logger->addMsg('[DB] Received query affecting ' . $this->affected() . ' rows and returning ' . $numRecords . ' results. Query: ' . $query);
     }
     // check if query was unsuccessful
     if (!$this->_result) {
         if ($this->_debug) {
             $logger->addMsg('Query failed with error --> ' . mysql_error());
         }
         if ($this->_dieOnQuery) {
             Pommo::kill('MySQL Query Failed.' . $query);
         }
     }
     if (is_numeric($row)) {
         $this->_result = $this->records() === 0 ? false : mysql_result($this->_result, $row, $col);
     }
     // return the result
     return $this->_result;
 }
Example #10
0
$logger =& Pommo::$_logger;
$dbo =& Pommo::$_dbo;
/**********************************
	SETUP TEMPLATE, PAGE
 *********************************/
require_once Pommo::$_baseDir . 'classes/Pommo_Template.php';
$view = new Pommo_Template();
// Prepare for subscriber form -- load in fields + POST/Saved Subscribe Form
$view->prepareForSubscribeForm();
// fetch the subscriber, validate code
$subscriber = current(Pommo_Subscribers::get(array('email' => empty($_REQUEST['email']) ? '0' : $_REQUEST['email'], 'status' => 1)));
if (empty($subscriber)) {
    Pommo::redirect('login.php');
}
if ($_REQUEST['code'] != Pommo_Subscribers::getActCode($subscriber)) {
    Pommo::kill(Pommo::_T('Invalid activation code.'));
}
// check if we have pending request
if (Pommo_Pending::isPending($subscriber['id'])) {
    $input = urlencode(serialize(array('Email' => $_POST['Email'])));
    Pommo::redirect('pending.php?input=' . $input);
}
$config = Pommo_Api::configGet(array('notices'));
$notices = unserialize($config['notices']);
if (!isset($_POST['d'])) {
    $view->assign('d', $subscriber['data']);
}
// check for an update + validate new subscriber info (also converts dates to ints)
if (!empty($_POST['update']) && Pommo_Validate::subscriberData($_POST['d'])) {
    $newsub = array('id' => $subscriber['id'], 'email' => $subscriber['email'], 'data' => $_POST['d']);
    if (!empty($_POST['newemail'])) {
Example #11
0
 public static function getActCode($subscriber)
 {
     if (empty($subscriber['id']) || empty($subscriber['registered'])) {
         Pommo::kill('Invalid Subscriber passed to getActCode!');
     }
     return md5($subscriber['id'] . $subscriber['registered']);
 }
Example #12
0
 static function configUpdate($input, $force = FALSE)
 {
     $dbo = Pommo::$_dbo;
     if (!is_array($input)) {
         Pommo::kill('Bad input passed to updateConfig', TRUE);
     }
     // if this is password, skip if empty
     if (isset($input['admin_password']) && empty($input['admin_password'])) {
         unset($input['admin_password']);
     }
     // get eligible config rows/options to change
     $force = $force ? null : 'on';
     $query = "\n            SELECT config_name\n            FROM " . $dbo->table['config'] . "\n            WHERE config_name IN(%q)\n            [AND user_change='%S']";
     $query = $dbo->prepare($query, array(array_keys($input), $force));
     // update rows/options
     $when = '';
     // multi-row update in a single query syntax
     while ($row = $dbo->getRows($query)) {
         $when .= $dbo->prepare("WHEN '%s' THEN '%s'", array($row['config_name'], $input[$row['config_name']])) . ' ';
         // limits multi-row update query to specific rows
         // (vs updating entire table)
         $where[] = $row['config_name'];
     }
     $query = "\n            UPDATE " . $dbo->table['config'] . "\n            SET config_value =\n                CASE config_name " . $when . " ELSE config_value END\n            [WHERE config_name IN(%Q)]";
     $query = $dbo->prepare($query, array($where));
     if (!$dbo->query($query)) {
         Pommo::kill('Error updating config');
     }
     return true;
 }
Example #13
0
 function preInit()
 {
     Pommo::requireOnce($this->_baseDir . 'inc/classes/log.php');
     Pommo::requireOnce($this->_baseDir . 'inc/lib/safesql/SafeSQL.class.php');
     Pommo::requireOnce($this->_baseDir . 'inc/classes/db.php');
     Pommo::requireOnce($this->_baseDir . 'inc/classes/auth.php');
     // initialize logger
     $this->_logger = new PommoLog();
     // NOTE -> this clears messages that may have been retained (not outputted) from logger.
     // read in config.php (configured by user)
     // TODO -> write a web-based frontend to config.php creation
     $config = PommoHelper::parseConfig($this->_baseDir . 'config.php');
     // check to see if config.php was "properly" loaded
     if (count($config) < 5) {
         Pommo::kill('Could not read config.php');
     }
     $this->_workDir = empty($config['workDir']) ? $this->_baseDir . 'cache' : $config['workDir'];
     $this->_debug = strtolower($config['debug']) != 'on' ? false : true;
     $this->_default_subscriber_sort = empty($config['default_subscriber_sort']) ? 'email' : $config['default_subscriber_sort'];
     $this->_verbosity = empty($config['verbosity']) ? 3 : $config['verbosity'];
     $this->_logger->_verbosity = $this->_verbosity;
     $this->_dateformat = $config['date_format'] >= 1 && $cofig['date_format'] <= 3 ? intval($config['date_format']) : 1;
     // the regex strips port info from hostname
     $this->_hostname = empty($config['hostname']) ? preg_replace('/:\\d+$/i', '', $_SERVER['HTTP_HOST']) : $config['hostname'];
     $this->_hostport = empty($config['hostport']) ? $_SERVER['SERVER_PORT'] : $config['hostport'];
     $this->_ssl = !isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) != 'on' ? false : true;
     $this->_http = ($this->_ssl ? 'https://' : 'http://') . $this->_hostname;
     if ($this->_hostport != 80 && $this->_hostport != 443) {
         $this->_http .= ':' . $this->_hostport;
     }
     $this->_language = empty($config['lang']) ? 'en' : strtolower($config['lang']);
     $this->_slanguage = defined('_poMMo_lang') ? _poMMo_lang : false;
     // include translation (l10n) methods if language is not English
     $this->_l10n = FALSE;
     if ($this->_language != 'en') {
         $this->_l10n = TRUE;
         Pommo::requireOnce($this->_baseDir . 'inc/helpers/l10n.php');
         PommoHelperL10n::init($this->_language, $this->_baseDir);
     }
     // set base URL (e.g. http://mysite.com/news/pommo => 'news/pommo/')
     // TODO -> provide validation of baseURL ?
     if (isset($config['baseURL'])) {
         $this->_baseUrl = $config['baseURL'];
     } else {
         // If we're called from an outside (embedded) script, read baseURL from "last known good".
         // Else, set it based off of REQUEST
         if (defined('_poMMo_embed')) {
             Pommo::requireOnce($this->_baseDir . 'inc/helpers/maintenance.php');
             $this->_baseUrl = PommoHelperMaintenance::rememberBaseURL();
         } else {
             $baseUrl = preg_replace('@/(inc|setup|user|install|support(/tests)?|admin(/subscribers|/user|/mailings|/setup)?(/ajax|/mailing|/config)?)$@i', '', dirname($_SERVER['PHP_SELF']));
             $this->_baseUrl = $baseUrl == '/' ? $baseUrl : $baseUrl . '/';
         }
     }
     // make sure workDir is writable
     if (!is_dir($this->_workDir . '/pommo/smarty')) {
         $wd = $this->_workDir;
         $this->_workDir = null;
         if (!is_dir($wd)) {
             Pommo::kill(sprintf(Pommo::_T('Work Directory (%s) not found! Make sure it exists and the webserver can write to it. You can change its location from the config.php file.'), $wd));
         }
         if (!is_writable($wd)) {
             Pommo::kill(sprintf(Pommo::_T('Cannot write to Work Directory (%s). Make sure it has the proper permissions.'), $wd));
         }
         if (ini_get('safe_mode') == "1") {
             Pommo::kill(sprintf(Pommo::_T('Working Directory (%s) cannot be created under PHP SAFE MODE. See Documentation, or disable SAFE MODE.'), $wd));
         }
         if (!is_dir($wd . '/pommo')) {
             if (!mkdir($wd . '/pommo')) {
                 Pommo::kill(Pommo::_T('Could not create directory') . ' ' . $wd . '/pommo');
             }
         }
         if (!mkdir($wd . '/pommo/smarty')) {
             Pommo::kill(Pommo::_T('Could not create directory') . ' ' . $wd . '/pommo/smarty');
         }
         $this->_workdir = $wd;
     }
     // set the current "section" -- should be "user" for /user/* files, "mailings" for /admin/mailings/* files, etc. etc.
     $this->_section = preg_replace('@^admin/?@i', '', str_replace($this->_baseUrl, '', dirname($_SERVER['PHP_SELF'])));
     // initialize database link
     $this->_dbo = @new PommoDB($config['db_username'], $config['db_password'], $config['db_database'], $config['db_hostname'], $config['db_prefix']);
     // turn off debugging if in user area
     if ($this->_section == 'user') {
         $this->_debug = false;
         $this->_dbo->debug(FALSE);
     }
     // if debugging is set in config.php, enable debugging on the database.
     if ($this->_debug) {
         // don't enable debugging in ajax requests unless verbosity is < 3
         if (PommoHelper::isAjax() && $this->_verbosity > 2) {
             $this->_debug = false;
         } else {
             $this->_dbo->debug(TRUE);
         }
     }
 }
    $state['order'] = 'asc';
}
if (!is_numeric($state['sort']) && $state['sort'] != 'email' && $state['sort'] != 'ip' && $state['sort'] != 'time_registered' && $state['sort'] != 'time_touched') {
    $state['sort'] = 'email';
}
if (!is_numeric($state['status'])) {
    $state['status'] = 1;
}
if (!is_numeric($state['group']) && $state['group'] != 'all') {
    $state['group'] = 'all';
}
if (isset($_REQUEST['searchClear'])) {
    $state['search'] = false;
} elseif (isset($_REQUEST['searchField']) && (is_numeric($_REQUEST['searchField']) || $_REQUEST['searchField'] == 'email' || $_REQUEST['searchField'] == 'ip' || $_REQUEST['searchField'] == 'time_registered' || $_REQUEST['searchField'] == 'time_touched')) {
    $_REQUEST['searchString'] = trim($_REQUEST['searchString']);
    $state['search'] = empty($_REQUEST['searchString']) ? false : array('field' => $_REQUEST['searchField'], 'string' => trim($_REQUEST['searchString']));
}
/**********************************
	DISPLAY METHODS
*********************************/
// Get the *empty* group [no member IDs. 3rd arg is set TRUE]
$group = new PommoGroup($state['group'], $state['status'], $state['search']);
// Calculate and Remember number of pages for this group/status combo
$state['pages'] = is_numeric($group->_tally) && $group->_tally > 0 ? ceil($group->_tally / $state['limit']) : 0;
$smarty->assign('state', $state);
$smarty->assign('tally', $group->_tally);
$smarty->assign('groups', PommoGroup::get());
$smarty->assign('fields', PommoField::get());
$smarty->display('admin/subscribers/subscribers_manage.tpl');
Pommo::kill();
Example #15
0
 function incUpdate($serial, $sql, $msg = "Performing Update", $eval = false)
 {
     global $pommo;
     $dbo =& Pommo::$_dbo;
     $logger =& Pommo::$_logger;
     if (!is_numeric($serial)) {
         Pommo::kill('Invalid serial passed; ' . $serial);
     }
     $msg = $serial . ". {$msg} ...";
     $query = "\n\t\t\tSELECT serial FROM " . $dbo->table['updates'] . " \n\t\t\tWHERE serial=%i";
     $query = $dbo->prepare($query, array($serial));
     if ($dbo->records($query)) {
         $msg .= "skipped.";
         $logger->addMsg($msg);
         return true;
     }
     if (!isset($GLOBALS['pommoFakeUpgrade'])) {
         // run the update
         if ($eval) {
             eval($sql);
         } else {
             $query = $dbo->prepare($sql);
             if (!$dbo->query($query)) {
                 // query failed...
                 $msg .= $GLOBALS['pommoLooseUpgrade'] ? 'IGNORED.' : 'FAILED';
                 $logger->addErr($msg);
                 return $GLOBALS['pommoLooseUpgrade'];
             }
         }
         $msg .= "done.";
         $logger->addMsg($msg);
     } else {
         $msg .= "skipped.";
         $logger->addMsg($msg, 2);
     }
     $query = "\n\t\t\tINSERT INTO " . $dbo->table['updates'] . " \n\t\t\t(serial) VALUES(%i)";
     $query = $dbo->prepare($query, array($serial));
     if (!$dbo->query($query)) {
         Pommo::kill('Unable to serialize');
     }
     return true;
 }
    // make sure we can write to the file
    if (!($handle = fopen($pommo->_workDir . '/mailing.test.php', 'w'))) {
        Pommo::kill('Impossible d\'&eacute;crire dans le fichier de test.');
    }
    fclose($handle);
    unlink($pommo->_workDir . '/mailing.test.php');
    Pommo::kill('Echec du d&eacute;clenchement du m&eacute;canisme (probl&egrave;me d\'&eacute;criture au niveau du fichier de test). Merci de tester le processeur d\'envoi d\'e-mails.');
}
$die = false;
$time = 0;
while (!$die) {
    sleep(10);
    $o = PommoHelper::parseConfig($pommo->_workDir . '/mailing.test.php');
    if (!isset($o['code']) || $o['code'] != $code) {
        unlink($pommo->_workDir . '/mailing.test.php');
        Pommo::kill('Le test a &eacute;chou&eacute;. Certains codes ne correspondent pas.');
    }
    if (!isset($o['time']) || $time >= $o['time'] || $o['time'] == 90) {
        $die = true;
    }
    $time = $o['time'];
    echo "{$time} secondes <br />";
    ob_flush();
    flush();
}
unlink($pommo->_workDir . '/mailing.test.php');
if ($time == 90) {
    Pommo::kill('TEST REUSSI');
}
Pommo::kill('ECHEC -- Votre serveur (ou une application tierce) refuse l\'ex&eacute;cution de ce test PHP. Il se peut que les envois soient suspendus. Si vous rencontrez des probl&egrave;mes li&eacute;s &agrave; la suspension des envois, essayez de renseigner le d&eacute;lai d\'ex&eacute;cution du script avec une valeur inf&eacute;rieure ou &eacute;gale &agrave; ' . ($time - 10) . '');
// Your webserver or a 3rd party tool is force terminating PHP. Mailings may freeze. If you are having problems with frozen mailings, try setting the Mailing Runtime Value to...
Example #17
0
         }
         $i++;
     }
     // save file for access after assignments
     if ($box) {
         // when PHP5 is widespread, switch to file_put_contents()  && use the $fp stream
         if (!($handle = fopen(Pommo::$_workDir . '/import.csv', 'w'))) {
             Pommo::kill('Could not write to temp CSV file (' . Pommo::$_workDir . '/import.csv)');
         }
         if (fwrite($handle, $_POST['box']) === FALSE) {
             Pommo::kill('Could not write to temp CSV file (' . Pommo::$_workDir . '/import.csv)');
         }
         fclose($handle);
     } else {
         if (!move_uploaded_file($_FILES[$fname]['tmp_name'], Pommo::$_workDir . '/import.csv')) {
             Pommo::kill('Could not write to temp CSV file (' . Pommo::$_workDir . '/import.csv)');
         }
     }
     Pommo::set(array('preview' => $a));
     Pommo::redirect('import_csv.php' . (isset($_REQUEST['excludeUnsubscribed']) ? '?excludeUnsubscribed=true' : ''));
 } else {
     //	Saves all parsed E-mails in an array
     $a = array();
     while (($data = fgetcsv($fp, 2048, ',', '"')) !== false) {
         foreach ($data as $email) {
             if (Pommo_Helper::isEmail($email)) {
                 $email = strtolower($email);
                 $a[$email] = $email;
             }
         }
     }
Example #18
0
 function timeFromStr($str)
 {
     global $pommo;
     if (!defined('ADODB_DATE_VERSION')) {
         // safely load ADODB date library
         Pommo::requireOnce($pommo->_baseDir . 'inc/lib/adodb/adodb-time.inc.php');
     }
     // normalize delimiter
     str_replace('-', '/', $str);
     // Extract Year, Month, and Day from a string like "2007/08/03"
     $a = explode("/", $str);
     // Validate the string
     if (count($a) != 3 || !is_numeric($a[0]) || !is_numeric($a[1]) || !is_numeric($a[2])) {
         return false;
     }
     switch ($pommo->_dateformat) {
         case 1:
             $year = substr($a[0], 0, 4);
             $month = substr($a[1], 0, 2);
             $day = substr($a[2], 0, 2);
             break;
         case 2:
             $year = substr($a[2], 0, 4);
             $month = substr($a[0], 0, 2);
             $day = substr($a[1], 0, 2);
             break;
         case 3:
             $year = substr($a[2], 0, 4);
             $month = substr($a[1], 0, 2);
             $day = substr($a[0], 0, 2);
             break;
         default:
             Pommo::kill('Unknown date_format', TRUE);
     }
     // Y-M-D validation
     if ($month < 1 || $month > 12) {
         return false;
     }
     if ($day < 1 || $day > 31) {
         return false;
     }
     // correction heuristic for short year @ end of century...
     if (strlen($year) == 2) {
         $year = $year < 50 ? '20' . $year : '19' . $year;
     }
     return adodb_mktime(0, 0, 0, $month, $day, $year);
 }
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 #20
0
Pommo::requireOnce($pommo->_baseDir . 'inc/classes/mailctl.php');
echo 'Merci de patienter quelques secondes...';
ob_flush();
flush();
$code = PommoHelper::makeCode();
if (!PommoMailCtl::spawn($pommo->_baseUrl . 'support/tests/mailing.test2.php?code=' . $code, true)) {
    Pommo::kill('Echec du d&eacute;clenchement du m&eacute;canisme. Vous devez corriger ce probl&egrave;me pour que poMMo puisse envoyer des e-mails.');
}
sleep(6);
if (!is_file($pommo->_workDir . '/mailing.test.php')) {
    // make sure we can write to the file
    if (!($handle = fopen($pommo->_workDir . '/mailing.test.php', 'w'))) {
        die('Impossible d\'&eacute;crire dans le fichier de test.');
    }
    fclose($handle);
    unlink($pommo->_workDir . '/mailing.test.php');
    Pommo::kill('Echec du d&eacute;clenchement du m&eacute;canisme (probl&egrave;me d\'&eacute;criture au niveau du fichier de test). Vous devez corriger ce probl&egrave;me pour que poMMo puisse envoyer des e-mails.');
}
$o = PommoHelper::parseConfig($pommo->_workDir . '/mailing.test.php');
unlink($pommo->_workDir . '/mailing.test.php') or die('impossible de supprimer mailing.test.php');
if (isset($o['error'])) {
    Pommo::kill('UNE ERREUR A ETE TROUVEE. MERCI DE VERIFIER LE RESULTAT DE \'MAILING_TEST\' DANS LE REPERTOIRE DE TRAVAIL');
}
if (!isset($o['code']) || $o['code'] != $code) {
    Pommo::kill('Le test a &eacute;chou&eacute;. Certains codes ne correspondent pas.');
}
if (!isset($o['spawn']) || $o['spawn'] == 0) {
    Pommo::kill('D&eacute;clenchement r&eacute;ussi mais &eacute;chec des envois &agrave; r&eacute;p&eacute;tition.');
}
Pommo::kill('D&eacute;clenchement r&eacute;ussi. Envois &agrave; r&eacute;p&eacute;tition r&eacute;ussis. La fonction d\'envoi massif est op&eacute;rationnelle.');
Example #21
0
Pommo::requireOnce($pommo->_baseDir . 'inc/classes/mailctl.php');
echo 'Please Wait...';
ob_flush();
flush();
$code = PommoHelper::makeCode();
if (!PommoMailCtl::spawn($pommo->_baseUrl . 'support/tests/mailing.test2.php?code=' . $code, true)) {
    Pommo::kill('Initial Spawn Failed! You must correct this before poMMo can send mailings.');
}
sleep(6);
if (!is_file($pommo->_workDir . '/mailing.test.php')) {
    // make sure we can write to the file
    if (!($handle = fopen($pommo->_workDir . '/mailing.test.php', 'w'))) {
        die('Unable to write to test file!');
    }
    fclose($handle);
    unlink($pommo->_workDir . '/mailing.test.php');
    Pommo::kill('Initial Spawn Failed (test file not written)! You must correct this before poMMo can send mailings.');
}
$o = PommoHelper::parseConfig($pommo->_workDir . '/mailing.test.php');
unlink($pommo->_workDir . '/mailing.test.php') or die('could not remove mailing.test.php');
if (isset($o['error'])) {
    Pommo::kill('ERROR WITH RESAWN. SEE THE OUTPUT OF \'MAILING_TEST\' IN THE WORK DIRECTORY');
}
if (!isset($o['code']) || $o['code'] != $code) {
    Pommo::kill('Spawning Failed. Codes did not match.');
}
if (!isset($o['spawn']) || $o['spawn'] == 0) {
    Pommo::kill('Inital spawn success. Respawn failed!');
}
Pommo::kill('Initial spawn success. Respawn success. Spawning Works!');