本文整理匯總了PHP中Pommo::kill方法的典型用法代碼示例。如果您正苦於以下問題:PHP Pommo::kill方法的具體用法?PHP Pommo::kill怎麽用?PHP Pommo::kill使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Pommo
的用法示例。
在下文中一共展示了Pommo::kill方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: init
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');
}
}
}
}
示例2: memorizeBaseURL
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);
}
示例3: __construct
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>'));
}
}
示例4: display
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);
}
示例5: display
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;
}
示例6: redirect
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;
}
示例7: Pommo_Template
*/
/**********************************
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'));
示例8: fclose
// 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');
示例9: mysql_query
/** 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;
}
示例10: Pommo_Template
$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'])) {
示例11: getActCode
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']);
}
示例12: configUpdate
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;
}
示例13: preInit
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);
}
}
}
示例14: elseif
$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();
示例15: incUpdate
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;
}