本文整理汇总了PHP中define_safe函数的典型用法代码示例。如果您正苦于以下问题:PHP define_safe函数的具体用法?PHP define_safe怎么用?PHP define_safe使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了define_safe函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Override the default Symphony constructor to initialise the Log, Config
* and Database objects for installation/update. This allows us to use the
* normal accessors.
*/
protected function __construct()
{
if (get_magic_quotes_gpc()) {
General::cleanArray($_SERVER);
General::cleanArray($_COOKIE);
General::cleanArray($_GET);
General::cleanArray($_POST);
}
// Include the default Config for installation.
include INSTALL . '/includes/config_default.php';
$this->initialiseConfiguration($settings);
// Initialize date/time
define_safe('__SYM_DATE_FORMAT__', self::Configuration()->get('date_format', 'region'));
define_safe('__SYM_TIME_FORMAT__', self::Configuration()->get('time_format', 'region'));
define_safe('__SYM_DATETIME_FORMAT__', __SYM_DATE_FORMAT__ . self::Configuration()->get('datetime_separator', 'region') . __SYM_TIME_FORMAT__);
DateTimeObj::setSettings(self::Configuration()->get('region'));
// Initialize language
$this->initialiseLang();
// Initialize logs
$this->initialiseLog(INSTALL_LOGS . '/install');
// Initialize database
$this->initialiseDatabase();
// Initialize error handlers
GenericExceptionHandler::initialise(Symphony::Log());
GenericErrorHandler::initialise(Symphony::Log());
}
示例2: initialiseCookie
public function initialiseCookie()
{
$cookie_path = @parse_url(URL, PHP_URL_PATH);
$cookie_path = '/' . trim($cookie_path, '/');
define_safe('__SYM_COOKIE_PATH__', $cookie_path);
define_safe('__SYM_COOKIE_PREFIX_', self::$Configuration->get('cookie_prefix', 'symphony'));
$this->Cookie = new Cookie(__SYM_COOKIE_PREFIX_, TWO_WEEKS, __SYM_COOKIE_PATH__);
}
示例3: modifyTextarea
public function modifyTextarea($context)
{
if ($context['field']->get('formatter') != 'tinymce') {
return;
}
if (!defined('__TINYMCE_SCRIPTS_IN_HEAD__') || !__TINYMCE_SCRIPTS_IN_HEAD__) {
define_safe('__TINYMCE_SCRIPTS_IN_HEAD__', true);
Administration::instance()->Page->addScriptToHead(URL . '/extensions/richtext_tinymce/lib/tiny_mce.js', 200);
Administration::instance()->Page->addScriptToHead(URL . '/extensions/richtext_tinymce/assets/applyMCE.js', 210);
}
$context['textarea']->setAttribute('id', trim($context['textarea']->getAttribute('id') . ' ' . $context['field']->get('element_name')));
}
示例4: __construct
protected function __construct()
{
$this->Profiler = new Profiler();
if (get_magic_quotes_gpc()) {
General::cleanArray($_SERVER);
General::cleanArray($_COOKIE);
General::cleanArray($_GET);
General::cleanArray($_POST);
}
include CONFIG;
$this->Configuration = new Configuration(true);
$this->Configuration->setArray($settings);
$cookie_path = parse_url(URL, PHP_URL_PATH);
$cookie_path = '/' . trim($cookie_path, '/');
define_safe('__SYM_COOKIE_PATH__', $cookie_path);
define_safe('__SYM_COOKIE_PREFIX_', $this->Configuration->get('cookie_prefix', 'symphony'));
define_safe('__LANG__', $this->Configuration->get('lang', 'symphony') ? $this->Configuration->get('lang', 'symphony') : 'en');
define_safe('__SYM_DATE_FORMAT__', $this->Configuration->get('date_format', 'region'));
define_safe('__SYM_TIME_FORMAT__', $this->Configuration->get('time_format', 'region'));
define_safe('__SYM_DATETIME_FORMAT__', __SYM_DATE_FORMAT__ . ' ' . __SYM_TIME_FORMAT__);
$this->initialiseLog();
error_reporting(E_ALL);
set_error_handler(array(&$this, '__errorHandler'));
$this->Cookie =& new Cookie(__SYM_COOKIE_PREFIX_, TWO_WEEKS, __SYM_COOKIE_PATH__);
try {
Lang::init(LANG . '/lang.%s.php', __LANG__);
} catch (Exception $e) {
trigger_error($e->getMessage(), E_USER_ERROR);
}
if (!$this->initialiseDatabase()) {
$error = $this->Database->getLastError();
$this->customError(E_USER_ERROR, 'Symphony Database Error', $error['num'] . ': ' . $error['msg'], true, true, 'database-error', array('error' => $error, 'message' => __('There was a problem whilst attempting to establish a database connection. Please check all connection information is correct. The following error was returned.')));
}
if (!$this->initialiseExtensionManager()) {
trigger_error('Error creating Symphony extension manager.', E_USER_ERROR);
}
DateTimeObj::setDefaultTimezone($this->Configuration->get('timezone', 'region'));
}
示例5: define_safe
}
}
/**
* Status when an extension is installed and enabled
* @var integer
*/
define_safe('EXTENSION_ENABLED', 10);
/**
* Status when an extension is disabled
* @var integer
*/
define_safe('EXTENSION_DISABLED', 11);
/**
* Status when an extension is in the file system, but has not been installed.
* @var integer
*/
define_safe('EXTENSION_NOT_INSTALLED', 12);
/**
* Status when an extension version in the file system is different to
* the version stored in the database for the extension
* @var integer
*/
define_safe('EXTENSION_REQUIRES_UPDATE', 13);
/**
* Status when the extension is not compatible with the current version of
* Symphony
* @since Symphony 2.3
* @var integer
*/
define_safe('EXTENSION_NOT_COMPATIBLE', 14);
示例6: define_safe
/**
* Returns the User Agent string of the browser that is viewing the current page
* @var string
*/
define_safe('HTTP_USER_AGENT', getenv('HTTP_USER_AGENT'));
/**
* If HTTPS is on, `__SECURE__` will be set to true, otherwise false. Use union of
* the `HTTPS` environmental variable and the X-Forwarded-Proto header to allow
* downstream proxies to inform the webserver of secured downstream connections
* @var string|boolean
*/
define_safe('__SECURE__', HTTPS == 'on' || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https');
/**
* The base URL of this Symphony install, minus the symphony path.
* @var string
*/
define_safe('URL', 'http' . (defined('__SECURE__') && __SECURE__ ? 's' : '') . '://' . DOMAIN);
/**
* Returns the URL + /symphony. This should be used whenever the a developer
* wants to link to the Symphony root
* @since Symphony 2.2
* @var string
*/
define_safe('SYMPHONY_URL', URL . '/symphony');
/**
* Returns the folder name for Symphony as an application
* @since Symphony 2.3.2
* @var string
*/
define_safe('APPLICATION_URL', URL . '/symphony');
示例7: is_null
Symphony::initialiseExtensionManager();
// Handle custom admin paths, #702
$adminPath = Symphony::Configuration()->get('admin-path', 'symphony');
$adminPath = is_null($adminPath) ? 'symphony' : $adminPath;
if (isset($_GET['symphony-page']) && strpos($_GET['symphony-page'], $adminPath, 0) === 0) {
$_GET['symphony-page'] = preg_replace('%^' . preg_quote($adminPath) . '\\/%', '', $_GET['symphony-page'], 1);
if ($_GET['symphony-page'] == '') {
unset($_GET['symphony-page']);
}
$_GET['mode'] = $_REQUEST['mode'] = 'administration';
}
/**
* Returns the URL + /symphony. This should be used whenever the a developer
* wants to link to the Symphony root
* @since Symphony 2.2
* @var string
*/
define_safe('SYMPHONY_URL', URL . '/' . $adminPath);
/**
* Overload the default Symphony launcher logic.
* @delegate ModifySymphonyLauncher
* @since Symphony 2.5.0
* @param string $context
* '/all/'
*/
Symphony::ExtensionManager()->notifyMembers('ModifySymphonyLauncher', '/all/');
// Use default launcher:
if (defined('SYMPHONY_LAUNCHER') === false) {
define('SYMPHONY_LAUNCHER', 'symphony_launcher');
}
}
示例8: detach
* @param integer $page_id
* The ID of the page.
*/
public static function detach($type, $r_handle, $page_id)
{
$col = self::getColumnFromType($type);
$pages = PageManager::fetch(false, array($col), array(sprintf('`id` = %d', $page_id)));
if (is_array($pages) && count($pages) == 1) {
$result = $pages[0][$col];
$values = explode(',', $result);
$idx = array_search($r_handle, $values, false);
if ($idx !== false) {
array_splice($values, $idx, 1);
$result = implode(',', $values);
return PageManager::edit($page_id, array($col => MySQL::cleanValue($result)));
}
}
return false;
}
}
/**
* The integer value for event-type resources.
* @var integer
*/
define_safe('RESOURCE_TYPE_EVENT', 20);
/**
* The integer value for datasource-type resources.
* @var integer
*/
define_safe('RESOURCE_TYPE_DS', 21);
示例9: define_safe
require_once DOCROOT . '/vendor/autoload.php';
require_once 'class.image.php';
require_once CONFIG;
Symphony::initialiseConfiguration($settings);
// Setup the environment
if (method_exists('DateTimeObj', 'setSettings')) {
DateTimeObj::setSettings($settings['region']);
} else {
DateTimeObj::setDefaultTimezone($settings['region']['timezone']);
}
define_safe('MODE_NONE', 0);
define_safe('MODE_RESIZE', 1);
define_safe('MODE_RESIZE_CROP', 2);
define_safe('MODE_CROP', 3);
define_safe('MODE_FIT', 4);
define_safe('CACHING', $settings['image']['cache'] == 1 ? true : false);
set_error_handler('__errorHandler');
function processParams($string, &$image_settings)
{
$param = (object) array('mode' => 0, 'width' => 0, 'height' => 0, 'position' => 0, 'background' => 0, 'file' => 0, 'external' => false);
// Check for matching recipes
if (file_exists(WORKSPACE . '/jit-image-manipulation/recipes.php')) {
include WORKSPACE . '/jit-image-manipulation/recipes.php';
}
// check to see if $recipes is even available before even checking if it is an array
if (!empty($recipes) && is_array($recipes)) {
foreach ($recipes as $recipe) {
// Is the mode regex? If so, bail early and let not JIT process it.
if ($recipe['mode'] === 'regex' && preg_match($recipe['url-parameter'], $string)) {
// change URL to a "normal" JIT URL
$string = preg_replace($recipe['url-parameter'], $recipe['jit-parameter'], $string);
示例10: __actionEdit
function __actionEdit()
{
$entry_id = intval($this->_context['entry_id']);
if (@array_key_exists('save', $_POST['action']) || @array_key_exists("done", $_POST['action'])) {
$entryManager = new EntryManager($this->_Parent);
if (!($ret = $entryManager->fetch($entry_id))) {
$this->_Parent->customError(E_USER_ERROR, __('Unknown Entry'), __('The entry you are looking for could not be found.'), false, true);
}
$entry = $ret[0];
$sectionManager = new SectionManager($this->_Parent);
$section = $sectionManager->fetch($entry->get('section_id'));
$post = General::getPostData();
$fields = $post['fields'];
if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($fields, $this->_errors)) {
$this->pageAlert(__('Some errors were encountered while attempting to save.'), Alert::ERROR);
} elseif (__ENTRY_OK__ != $entry->setDataFromPost($fields, $error)) {
$this->pageAlert($error['message'], Alert::ERROR);
} else {
###
# Delegate: EntryPreEdit
# Description: Just prior to editing of an Entry.
$this->_Parent->ExtensionManager->notifyMembers('EntryPreEdit', '/publish/edit/', array('section' => $section, 'entry' => &$entry, 'fields' => $fields));
if (!$entry->commit()) {
define_safe('__SYM_DB_INSERT_FAILED__', true);
$this->pageAlert(NULL, Alert::ERROR);
} else {
###
# Delegate: EntryPostEdit
# Description: Editing an entry. Entry object is provided.
$this->_Parent->ExtensionManager->notifyMembers('EntryPostEdit', '/publish/edit/', array('section' => $section, 'entry' => $entry, 'fields' => $fields));
$prepopulate_field_id = $prepopulate_value = NULL;
if (isset($_POST['prepopulate'])) {
$prepopulate_field_id = array_shift(array_keys($_POST['prepopulate']));
$prepopulate_value = stripslashes(rawurldecode(array_shift($_POST['prepopulate'])));
}
//redirect(URL . '/symphony/publish/' . $this->_context['section_handle'] . '/edit/' . $entry_id . '/saved/');
redirect(sprintf('%s/symphony/publish/%s/edit/%d/saved%s/', URL, $this->_context['section_handle'], $entry->get('id'), !is_null($prepopulate_field_id) ? ":{$prepopulate_field_id}:{$prepopulate_value}" : NULL));
}
}
} elseif (@array_key_exists('delete', $_POST['action']) && is_numeric($entry_id)) {
###
# Delegate: Delete
# Description: Prior to deleting an entry. Entry ID is provided, as an array to remain compatible with other Delete delegate call
Administration::instance()->ExtensionManager->notifyMembers('Delete', '/publish/', array('entry_id' => $entry_id));
$entryManager = new EntryManager($this->_Parent);
$entryManager->delete($entry_id);
redirect(URL . '/symphony/publish/' . $this->_context['section_handle'] . '/');
}
}
示例11: __actionDo
function __actionDo()
{
if (!isset($_POST['fields']['source']) or $_POST['fields']['source'] <= 0) {
$this->_errors[] = 'You didn\'t choose a source, perhaps you don\'t have any sections with an upload field in them?';
$this->_valid = false;
return;
}
if (!isset($_POST['fields']['sourcedir']) or !preg_match('/^\\/workspace\\/uploads\\/mui/i', $_POST['fields']['sourcedir'])) {
$this->_errors[] = 'Fail!';
$this->_valid = false;
return;
}
$this->_section_id = $_POST['fields']['source'];
// section id
$entryManager = new EntryManager($this->_Parent);
$sectionManager = new SectionManager($this->_Parent);
$section = $sectionManager->fetch($this->_section_id);
// get all the fields for the types we support, and get ready to put the filename in them
foreach ($this->_driver->getTypes() as $type) {
$f = $section->fetchFields($type);
if (count($f) > 0) {
foreach ($f as $field) {
$field_names[] = $field;
}
}
//array($field->get('element_name'), $field->get('destination'));
}
$files = General::listStructure(DOCROOT . $_POST['fields']['sourcedir']);
if (count($files['filelist']) == 0) {
$this->_errors[] = "There are no files in this directory: {$_POST['fields']['sourcedir']}.";
$this->_valid = false;
return;
}
// a list of all the entries so we can rollback
$entries = array();
foreach ($files['filelist'] as $k => $f) {
$continue = false;
$this->_files[] = $f;
$entry =& $entryManager->create();
$entry->set('section_id', $this->_section_id);
$entry->set('author_id', $this->_Parent->Author->get('id'));
$entry->set('creation_date', DateTimeObj::get('Y-m-d H:i:s'));
$entry->set('creation_date_gmt', DateTimeObj::getGMT('Y-m-d H:i:s'));
$chkfields = $fields = $_POST['fields'][$this->_section_id];
// loop over all the supported fields
foreach ($field_names as $field) {
$dest = $field->get('destination');
$name = $field->get('element_name');
$tmp_name = DOCROOT . $_POST['fields']['sourcedir'] . '/' . $f;
$new_name = DOCROOT . $dest . '/' . $f;
/* if you don't want to rollback implement this */
// if($field->get('validator') != NULL){
// $rule = $field->get('validator');
//
// // skip this file since it doesn't validate
// if(!General::validateString($tmp_name, $rule)) {
// ;
// // $continue = true;
// }
// }
$type = trim(shell_exec('file -b --mime ' . escapeshellarg($tmp_name)));
$size = filesize($tmp_name);
// setup fields to check the post
$chkfields[$name][name] = $f;
$chkfields[$name][type] = $type;
$chkfields[$name][tmp_name] = $tmp_name;
$chkfields[$name][error] = 0;
$chkfields[$name][size] = $size;
// an array to copy the files after
$copy[] = array($tmp_name, $new_name);
// setup upload fields as they should be as if they were processed
$fields[$name][file] = preg_replace("/^\\/workspace/", '', $dest) . '/' . $f;
$fields[$name][size] = $size;
$fields[$name][mimetype] = $type;
$fields[$name][meta] = serialize($this->getMetaInfo(DOCROOT . $fields[$name][file], $type));
}
// skip the file if it doesn't validate
// if ($continue == true) continue;
if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($chkfields, $this->_errors)) {
$this->_ignored_files[] = $f;
break;
}
// now we can copy the files to their new location since everything's validated
foreach ($copy as $c) {
if (@copy($c[0], $c[1])) {
@chmod($c[1], intval(0755, 8));
} else {
$this->_errors[] = "Couldn't copy the files to the {$dest} directory. ";
return;
}
}
// setup the data, process it
if (__ENTRY_OK__ != $this->setDataFromPost($entry, $fields, $this->_errors, false, false, $entries)) {
$this->_ignored_files[] = $f;
break;
}
// commit the entry if we made it
if (!$entry->commit()) {
define_safe('__SYM_DB_INSERT_FAILED__', true);
} else {
//.........这里部分代码省略.........
示例12: initialiseCookie
public function initialiseCookie()
{
try {
$cookie_path = parse_url(URL, PHP_URL_PATH);
$cookie_path = '/' . trim($cookie_path, '/');
} catch (Exception $e) {
$cookie_path = '/';
}
define_safe('__SYM_COOKIE_PATH__', $cookie_path);
define_safe('__SYM_COOKIE_PREFIX__', self::Configuration()->core()->symphony->{'cookie-prefix'});
$this->Cookie = new Cookie(__SYM_COOKIE_PREFIX__, TWO_WEEKS, __SYM_COOKIE_PATH__);
}
示例13: define_safe
* @var string
*/
define_safe('HTTP_HOST', getenv('HTTP_HOST'));
/**
* Returns the IP address of the machine that is viewing the current page.
* @var string
*/
define_safe('REMOTE_ADDR', getenv('REMOTE_ADDR'));
/**
* Returns the User Agent string of the browser that is viewing the current page
* @var string
*/
define_safe('HTTP_USER_AGENT', getenv('HTTP_USER_AGENT'));
/**
* If HTTPS is on, `__SECURE__` will be set to true, otherwise false
* @var string|boolean
*/
define_safe('__SECURE__', HTTPS == 'on');
/**
* The base URL of this Symphony install, minus the symphony path.
* @var string
*/
define_safe('URL', 'http' . (defined('__SECURE__') && __SECURE__ ? 's' : '') . '://' . DOMAIN);
/**
* Returns the URL + /symphony. This should be used whenever the a developer
* wants to link to the Symphony root
* @var string
* @since Symphony 2.2
*/
define_safe('SYMPHONY_URL', URL . '/symphony');
示例14: __actionEdit
function __actionEdit()
{
if (empty($_POST['fields']['title'])) {
$this->_errors = 'title';
$this->pageAlert(__('%1$s', array(__('Title must not be empty'))), Alert::ERROR);
return;
}
if (!$this->_driver->updateCat($_POST['fields'])) {
define_safe('__SYM_DB_INSERT_FAILED__', true);
$this->pageAlert(NULL, AdministrationPage::PAGE_ALERT_ERROR);
} else {
redirect(BASE_URL . '/edit/' . $this->_id . '/saved/');
}
}
示例15: define_safe
define_safe('SYMPHONY', DOCROOT . '/symphony');
define_safe('EXTENSIONS', DOCROOT . '/extensions');
define_safe('WORKSPACE', DOCROOT . '/workspace');
define_safe('LIBRARY', SYMPHONY . '/lib');
define_safe('ASSETS', SYMPHONY . '/assets');
define_safe('UTILITIES', WORKSPACE . '/utilities');
define_safe('DATASOURCES', WORKSPACE . '/data-sources');
define_safe('EVENTS', WORKSPACE . '/events');
define_safe('TEXTFORMATTERS', WORKSPACE . '/text-formatters');
define_safe('PAGES', WORKSPACE . '/pages');
define_safe('CACHE', MANIFEST . '/cache');
define_safe('TMP', MANIFEST . '/tmp');
define_safe('LOGS', MANIFEST . '/logs');
define_safe('CONFIG', MANIFEST . '/config.php');
define_safe('TOOLKIT', LIBRARY . '/toolkit');
define_safe('LANG', LIBRARY . '/lang');
define_safe('CORE', LIBRARY . '/core');
define_safe('BOOT', LIBRARY . '/boot');
define_safe('CONTENT', SYMPHONY . '/content');
define_safe('TEMPLATE', SYMPHONY . '/template');
define_safe('STARTTIME', precision_timer());
define_safe('TWO_WEEKS', 60 * 60 * 24 * 14);
define_safe('CACHE_LIFETIME', TWO_WEEKS);
define_safe('HTTPS', getenv('HTTPS'));
define_safe('HTTP_HOST', getenv('HTTP_HOST'));
define_safe('REMOTE_ADDR', getenv('REMOTE_ADDR'));
define_safe('HTTP_USER_AGENT', getenv('HTTP_USER_AGENT'));
define_safe('__SECURE__', HTTPS == 'on');
define_safe('URL', 'http' . (defined('__SECURE__') && __SECURE__ ? 's' : '') . '://' . DOMAIN);
define_safe('ACTIVITY_LOG', LOGS . '/main');