本文整理汇总了PHP中Symphony::Log方法的典型用法代码示例。如果您正苦于以下问题:PHP Symphony::Log方法的具体用法?PHP Symphony::Log怎么用?PHP Symphony::Log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symphony
的用法示例。
在下文中一共展示了Symphony::Log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __trigger
protected function __trigger()
{
$result = null;
$actionName = $this->getActionName();
$requestMethod = $this->getRequestMethod();
$requestArray = $this->getRequestArray();
if ($_SERVER['REQUEST_METHOD'] == $requestMethod && isset($requestArray[$actionName])) {
$result = new XMLElement($actionName);
$r = new XMLElement('result');
$id = intval($_POST['id']);
try {
$this->validate();
$entry = $this->createEntryFromPost($id);
$this->visitEntry($entry);
$r->setAttribute('success', 'yes');
$r->setAttribute('id', $entry->get('id'));
} catch (Exception $ex) {
$xmlEx = new XMLElement('error');
$showMsg = $ex instanceof InsertSectionException || Symphony::Engine()->isLoggedIn();
$errorMessage = $showMsg ? $ex->getMessage() : __('A Fatal error occured');
$xmlEx->setValue($errorMessage);
$result->appendChild($xmlEx);
$r->setAttribute('success', 'no');
Symphony::Log()->pushExceptionToLog($ex, true);
}
$result->appendChild($r);
} else {
throw new FrontendPageNotFoundException();
}
return $result;
}
示例2: __prepareRun
public function __prepareRun($context)
{
$importManager = new XmlImporterManager();
$html_errors = ini_get('html_errors');
$source = null;
if (isset($_GET['source'])) {
$source = $_GET['source'];
}
array_shift($context);
ini_set('html_errors', false);
foreach ($context as $handle) {
$importer = $importManager->create($handle);
if ($importer === false) {
Symphony::Log()->writeToLog(__('The XMLImporter %s could not be found.', array($handle)), E_USER_ERROR, true);
continue;
} else {
$status = $importer->validate($source);
}
if ($status == XMLImporter::__OK__) {
$importer->commit();
}
$this->_runs[] = array('importer' => $importer, 'status' => $status);
}
ini_set('html_errors', $html_errors);
}
示例3: __construct
/**
* Creates a new exception, and logs the error.
*
* @param string $message
* @param int $code
* @param Exception $previous
* The previous exception, if nested. See
* http://www.php.net/manual/en/language.exceptions.extending.php
* @return void
*/
public function __construct($message, $code = 0, $previous = null)
{
$trace = parent::getTrace();
// Best-guess to retrieve classname of email-gateway.
// Might fail in non-standard uses, will then return an
// empty string.
$gateway_class = $trace[1]['class'] ? ' (' . $trace[1]['class'] . ')' : '';
Symphony::Log()->pushToLog(__('Email Gateway Error') . $gateway_class . ': ' . $message, $code, true);
parent::__construct('<![CDATA[' . trim($message) . ']]>');
}
示例4: __construct
/**
* Creates a new exception, and logs the error.
*
* @param string $message
* @param int $code
* @param Exception $previous
* The previous exception, if nested. See
* http://www.php.net/manual/en/language.exceptions.extending.php
* @return void
*/
public function __construct($message, $code = 0, $previous = null)
{
$trace = parent::getTrace();
// Best-guess to retrieve classname of email-gateway.
// Might fail in non-standard uses, will then return an
// empty string.
$gateway_class = $trace[1]['class'] ? ' (' . $trace[1]['class'] . ')' : '';
Symphony::Log()->pushToLog(__('Email Gateway Error') . $gateway_class . ': ' . $message, $code, true);
// CDATA the $message: Do not trust input from others
$message = General::wrapInCDATA(trim($message));
parent::__construct($message);
}
示例5: run
static function run($function, $existing_version = null)
{
self::$existing_version = $existing_version;
try {
$canProceed = self::$function();
return $canProceed === false ? false : true;
} catch (DatabaseException $e) {
Symphony::Log()->writeToLog('Could not complete upgrading. MySQL returned: ' . $e->getDatabaseErrorCode() . ': ' . $e->getMessage(), E_ERROR, true);
return false;
} catch (Exception $e) {
Symphony::Log()->writeToLog('Could not complete upgrading because of the following error: ' . $e->getMessage(), E_ERROR, true);
return false;
}
}
示例6: install
public static function install() {
try {
self::uninstall();
Symphony::Database()->query("CREATE TABLE IF NOT EXISTS `tbl_cdi_log` (
`date` DATETIME NOT NULL,
`order` int(4),
`author` VARCHAR(255) NOT NULL,
`url` VARCHAR(255) NOT NULL,
`query_hash` VARCHAR(255) NOT NULL)");
if (!file_exists(CDIROOT)) { mkdir(CDIROOT); }
Symphony::Configuration()->set('api_key', CdiUtil::generateKey(), 'cdi');
return true;
} catch(Exception $e) {
Administration::instance()->Page->pageAlert(_('An error occurred while installing CDI: ') . $e->getMessage());
Symphony::Log()->pushToLog('[CDI] ' . $e->getMessage(), E_ERROR, true);
return false;
}
}
示例7: viewFailure
protected function viewFailure()
{
$h2 = new XMLElement('h2', __('Updating Failure'));
$p = new XMLElement('p', __('An error occurred while updating Symphony.'));
// Attempt to get update information from the log file
try {
$log = file_get_contents(INSTALL_LOGS . '/update');
} catch (Exception $ex) {
$log_entry = Symphony::Log()->popFromLog();
if (isset($log_entry['message'])) {
$log = $log_entry['message'];
} else {
$log = 'Unknown error occurred when reading the update log';
}
}
$code = new XMLElement('code', $log);
$this->Form->appendChild($h2);
$this->Form->appendChild($p);
$this->Form->appendChild(new XMLElement('pre', $code));
}
示例8: flushCache
public function flushCache($context)
{
$this->__fetchSectionsFromContext($context);
$cacheDir = CACHE . '/cacheabledatasource/';
try {
foreach (DatasourceManager::listAll() as $ds) {
if (!in_array($ds['source'], $this->_sectionsToFlush)) {
continue;
}
$cache = glob($cacheDir . $ds['handle'] . '_*.xml');
if (empty($cache)) {
continue;
}
foreach ($cache as $file) {
unlink($file);
}
}
} catch (Exception $e) {
Symphony::Log()->writeToLog(date('d.m.y H:i:s') . ' > CacheableDatasource: ' . $e->getMessage(), true);
}
}
示例9: __trigger
protected function __trigger()
{
$r = new XMLElement($this->getRootElement());
try {
if ($this->isValid()) {
if ($this->__sendEmail()) {
$r->setAttribute('success', 'yes');
} else {
throw new EmailEventException('Error sending email');
}
} else {
throw new EmailEventException('Form is invalid');
}
} catch (Exception $ex) {
$xmlEx = new XMLElement('error');
$showMsg = $ex instanceof EmailEventException || Symphony::Engine()->isLoggedIn();
$errorMessage = $showMsg ? $ex->getMessage() : __('A Fatal error occured');
$xmlEx->setValue($errorMessage);
$r->appendChild($xmlEx);
$r->setAttribute('success', 'no');
Symphony::Log()->pushExceptionToLog($ex, true);
}
return $r;
}
示例10: if
$result["status"] = "error";
$result["message"] = $e->getMessage();
Symphony::Log()->pushToLog('[CDI] ' . $e->getMessage(), E_ERROR, true);
}
}
// CDI Restore
else if(isset($_POST["action"]["cdi_restore"])) {
try {
CdiDumpDB::restore();
$result["status"] = 'success';
} catch(Exception $e) {
$result["status"] = "error";
$result["message"] = $e->getMessage();
Symphony::Log()->pushToLog('[CDI] ' . $e->getMessage(), E_NOTICE, true);
}
}
// No action? Error!
else {
$result["status"] = "error";
$result["message"] = "You can only execute actions if you actually post one!";
Symphony::Log()->pushToLog('[CDI] You can only execute actions if you actually post one!', E_NOTICE, true);
}
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');
echo json_encode($result);
die();
?>
示例11: upgrade
static function upgrade()
{
// 2.3dev
if (version_compare(self::$existing_version, '2.3dev', '<=')) {
Symphony::Configuration()->set('version', '2.3dev', 'symphony');
Symphony::Configuration()->set('useragent', 'Symphony/2.3dev', 'general');
// Add Publish Label to `tbl_fields`
if (!Symphony::Database()->tableContainsField('tbl_fields', 'publish_label')) {
Symphony::Database()->query('ALTER TABLE `tbl_fields` ADD `publish_label` VARCHAR(255) DEFAULT NULL');
}
// Migrate any Checkbox's Long Description to Publish Label
try {
$checkboxes = Symphony::Database()->fetch("SELECT `field_id`, `description` FROM `tbl_fields_checkbox`");
foreach ($checkboxes as $field) {
if (!isset($field['description'])) {
continue;
}
Symphony::Database()->query(sprintf("\n\t\t\t\t\t\t\tUPDATE `tbl_fields`\n\t\t\t\t\t\t\tSET `publish_label` = '%s'\n\t\t\t\t\t\t\tWHERE `id` = %d\n\t\t\t\t\t\t\tLIMIT 1;\n\t\t\t\t\t\t\t", $field['description'], $field['field_id']));
}
Symphony::Database()->query("ALTER TABLE `tbl_fields_checkbox` DROP `description`");
} catch (Exception $ex) {
}
// Removing unused settings
Symphony::Configuration()->remove('allow_page_subscription', 'symphony');
Symphony::Configuration()->remove('strict_error_handling', 'symphony');
Symphony::Configuration()->remove('character_set', 'database');
Symphony::Configuration()->remove('character_encoding', 'database');
Symphony::Configuration()->remove('runtime_character_set_alter', 'database');
if (Symphony::Configuration()->get('pagination_maximum_rows', 'symphony') == '17') {
Symphony::Configuration()->set('pagination_maximum_rows', '20', 'symphony');
}
Symphony::Configuration()->write();
}
// 2.3 Beta 1
if (version_compare(self::$existing_version, '2.3beta1', '<=')) {
Symphony::Configuration()->set('version', '2.3beta1', 'symphony');
Symphony::Configuration()->set('useragent', 'Symphony/2.3 Beta 1', 'general');
Symphony::Configuration()->write();
}
// 2.3 Beta 2
if (version_compare(self::$existing_version, '2.3beta2', '<=')) {
// Migrate Publish Labels (if created) to the Label field
// Then drop Publish Label, we're going to use element_name and label
// to take care of the same functionality!
try {
if (Symphony::Database()->tableContainsField('tbl_fields', 'publish_label')) {
$fields = Symphony::Database()->fetch('SELECT `publish_label`, `label`, `id` FROM `tbl_fields`');
foreach ($fields as $field) {
if (!$field['publish_label']) {
continue;
}
Symphony::Database()->query(sprintf("\n\t\t\t\t\t\t\t\tUPDATE `tbl_fields`\n\t\t\t\t\t\t\t\tSET `label` = '%s'\n\t\t\t\t\t\t\t\tWHERE `id` = %d\n\t\t\t\t\t\t\t\tLIMIT 1;\n\t\t\t\t\t\t\t\t", $field['publish_label'], $field['id']));
}
Symphony::Database()->query("ALTER TABLE `tbl_fields` DROP `publish_label`");
}
} catch (Exception $ex) {
Symphony::Log()->pushToLog($ex->getMessage(), E_NOTICE, true);
}
// Add uniqueness constraint for the Authors table. #937
try {
Symphony::Database()->query("ALTER TABLE `tbl_authors` ADD UNIQUE KEY `email` (`email`)");
} catch (DatabaseException $ex) {
// 1061 will be 'duplicate key', which is fine (means key was added earlier)
// 1062 means the key failed to apply, which is bad.
// @see http://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html
if ($ex->getDatabaseErrorCode() === 1062) {
Symphony::Log()->pushToLog(__("You have multiple Authors with the same email address, which can cause issues with password retrieval. Please ensure all Authors have unique email addresses before updating. " . $ex->getMessage()), E_USER_ERROR, true);
return false;
}
}
// Update the version information
Symphony::Configuration()->set('version', '2.3beta2', 'symphony');
Symphony::Configuration()->set('useragent', 'Symphony/2.3 Beta 2', 'general');
Symphony::Configuration()->write();
}
// 2.3 Beta 3
if (version_compare(self::$existing_version, '2.3beta3', '<=')) {
// Refresh indexes on existing Author field tables
$author_fields = Symphony::Database()->fetchCol("field_id", "SELECT `field_id` FROM `tbl_fields_author`");
foreach ($author_fields as $id) {
$table = 'tbl_entries_data_' . $id;
// MySQL doesn't support DROP IF EXISTS, so we'll try and catch.
try {
Symphony::Database()->query("ALTER TABLE `" . $table . "` DROP INDEX `entry_id`");
} catch (Exception $ex) {
}
try {
Symphony::Database()->query("CREATE UNIQUE INDEX `author` ON `" . $table . "` (`entry_id`, `author_id`)");
Symphony::Database()->query("OPTIMIZE TABLE " . $table);
} catch (Exception $ex) {
}
}
// Move section sorting data from the database to the filesystem. #977
$sections = Symphony::Database()->fetch("SELECT `handle`, `entry_order`, `entry_order_direction` FROM `tbl_sections`");
foreach ($sections as $s) {
Symphony::Configuration()->set('section_' . $s['handle'] . '_sortby', $s['entry_order'], 'sorting');
Symphony::Configuration()->set('section_' . $s['handle'] . '_order', $s['entry_order_direction'], 'sorting');
}
// Drop `local`/`gmt` from Date fields, add `date` column. #693
$date_fields = Symphony::Database()->fetchCol("field_id", "SELECT `field_id` FROM `tbl_fields_date`");
//.........这里部分代码省略.........
示例12: view
public function view()
{
if ($_REQUEST['error'] && Symphony::Log()) {
Symphony::Log()->pushToLog(sprintf('%s - %s%s%s', 'Javascript', $_REQUEST['error'], $_REQUEST['url'] ? " in file " . $_REQUEST['url'] : null, $_REQUEST['line'] ? " on line " . $_REQUEST['line'] : null), E_ERROR, true);
}
}
示例13: action
public function action()
{
if (isset($_POST['action'])) {
$actionParts = array_keys($_POST['action']);
$action = end($actionParts);
// Login Attempted
if ($action == 'login') {
if (empty($_POST['username']) || empty($_POST['password']) || !Administration::instance()->login($_POST['username'], $_POST['password'])) {
/**
* A failed login attempt into the Symphony backend
*
* @delegate AuthorLoginFailure
* @since Symphony 2.2
* @param string $context
* '/login/'
* @param string $username
* The username of the Author who attempted to login.
*/
Symphony::ExtensionManager()->notifyMembers('AuthorLoginFailure', '/login/', array('username' => Symphony::Database()->cleanValue($_POST['username'])));
$this->failedLoginAttempt = true;
} else {
/**
* A successful login attempt into the Symphony backend
*
* @delegate AuthorLoginSuccess
* @since Symphony 2.2
* @param string $context
* '/login/'
* @param string $username
* The username of the Author who logged in.
*/
Symphony::ExtensionManager()->notifyMembers('AuthorLoginSuccess', '/login/', array('username' => Symphony::Database()->cleanValue($_POST['username'])));
isset($_POST['redirect']) ? redirect($_POST['redirect']) : redirect(SYMPHONY_URL . '/');
}
// Reset of password requested
} elseif ($action == 'reset') {
$author = Symphony::Database()->fetchRow(0, sprintf("\n SELECT `id`, `email`, `first_name`\n FROM `tbl_authors`\n WHERE `email` = '%1\$s' OR `username` = '%1\$s'\n ", Symphony::Database()->cleanValue($_POST['email'])));
if (!empty($author)) {
Symphony::Database()->delete('tbl_forgotpass', sprintf("\n `expiry` < %d", DateTimeObj::getGMT('c')));
if (!($token = Symphony::Database()->fetchVar('token', 0, "SELECT `token` FROM `tbl_forgotpass` WHERE `expiry` > '" . DateTimeObj::getGMT('c') . "' AND `author_id` = " . $author['id']))) {
// More secure password token generation
if (function_exists('openssl_random_pseudo_bytes')) {
$seed = openssl_random_pseudo_bytes(16);
} else {
$seed = mt_rand();
}
$token = substr(SHA1::hash($seed), 0, 16);
Symphony::Database()->insert(array('author_id' => $author['id'], 'token' => $token, 'expiry' => DateTimeObj::getGMT('c', time() + 120 * 60)), 'tbl_forgotpass');
}
try {
$email = Email::create();
$email->recipients = $author['email'];
$email->subject = __('New Symphony Account Password');
$email->text_plain = __('Hi %s,', array($author['first_name'])) . PHP_EOL . __('A new password has been requested for your account. Login using the following link, and change your password via the Authors area:') . PHP_EOL . PHP_EOL . ' ' . SYMPHONY_URL . "/login/{$token}/" . PHP_EOL . PHP_EOL . __('It will expire in 2 hours. If you did not ask for a new password, please disregard this email.') . PHP_EOL . PHP_EOL . __('Best Regards,') . PHP_EOL . __('The Symphony Team');
$email->send();
$this->_email_sent = true;
$this->_email_sent_to = $author['email'];
// Set this so we can display a customised message
} catch (Exception $e) {
$this->_email_error = General::unwrapCDATA($e->getMessage());
Symphony::Log()->pushExceptionToLog($e, true);
}
/**
* When a password reset has occurred and after the Password
* Reset email has been sent.
*
* @delegate AuthorPostPasswordResetSuccess
* @since Symphony 2.2
* @param string $context
* '/login/'
* @param integer $author_id
* The ID of the Author who requested the password reset
*/
Symphony::ExtensionManager()->notifyMembers('AuthorPostPasswordResetSuccess', '/login/', array('author_id' => $author['id']));
} else {
/**
* When a password reset has been attempted, but Symphony doesn't
* recognise the credentials the user has given.
*
* @delegate AuthorPostPasswordResetFailure
* @since Symphony 2.2
* @param string $context
* '/login/'
* @param string $email
* The sanitised Email of the Author who tried to request the password reset
*/
Symphony::ExtensionManager()->notifyMembers('AuthorPostPasswordResetFailure', '/login/', array('email' => Symphony::Database()->cleanValue($_POST['email'])));
$this->_email_sent = false;
}
}
}
}
示例14: __errorHandler
function __errorHandler($errno = null, $errstr, $errfile = null, $errline = null, $errcontext = null)
{
global $param;
if (error_reporting() != 0 && in_array($errno, array(E_WARNING, E_USER_WARNING, E_ERROR, E_USER_ERROR))) {
Symphony::initialiseLog();
Symphony::Log()->pushToLog("{$errno} - " . strip_tags(is_object($errstr) ? $errstr->generate() : $errstr) . ($errfile ? " in file {$errfile}" : '') . ($errline ? " on line {$errline}" : ''), $errno, true);
Symphony::Log()->pushToLog(sprintf('Image class param dump - mode: %d, width: %d, height: %d, position: %d, background: %d, file: %s, external: %d, raw input: %s', $param->mode, $param->width, $param->height, $param->position, $param->background, $param->file, (bool) $param->external, $_GET['param']), E_NOTICE, true);
}
}
示例15: save
public static function save() {
try {
// cdi-mode
if(isset($_POST['settings']['cdi']['cdi-mode'])) {
Symphony::Configuration()->set('cdi-mode', $_POST['settings']['cdi']['cdi-mode'], 'cdi');
} else {
return false;
}
// mode (based on is-slave)
if(isset($_POST['settings']['cdi']['is-slave'])) {
if(CdiUtil::isCdi()) {
Symphony::Configuration()->set('mode', 'CdiSlave', 'cdi');
} else {
Symphony::Configuration()->set('mode', 'CdiDBSyncSlave', 'cdi');
}
} else {
if(CdiUtil::isCdi()) {
Symphony::Configuration()->set('mode', 'CdiMaster', 'cdi');
} else {
Symphony::Configuration()->set('mode', 'CdiDBSyncMaster', 'cdi');
}
}
// disable_blueprints
if(isset($_POST['settings']['cdi']['disable_blueprints'])) {
Symphony::Configuration()->set('disable_blueprints', 'yes', 'cdi');
} else {
Symphony::Configuration()->set('disable_blueprints', 'no', 'cdi');
}
// backup-enabled
if(isset($_POST['settings']['cdi']['backup-enabled'])) {
Symphony::Configuration()->set('backup-enabled', 'yes', 'cdi');
} else {
Symphony::Configuration()->set('backup-enabled', 'no', 'cdi');
}
// backup-overwrite
if(isset($_POST['settings']['cdi']['backup-overwrite'])) {
Symphony::Configuration()->set('backup-overwrite', 'yes', 'cdi');
} else {
Symphony::Configuration()->set('backup-overwrite', 'no', 'cdi');
}
// manual-backup-overwrite
if(isset($_POST['settings']['cdi']['manual-backup-overwrite'])) {
Symphony::Configuration()->set('manual-backup-overwrite', 'yes', 'cdi');
} else {
Symphony::Configuration()->set('manual-backup-overwrite', 'no', 'cdi');
}
// restore-enabled
if(isset($_POST['settings']['cdi']['restore-enabled'])) {
Symphony::Configuration()->set('restore-enabled', 'yes', 'cdi');
} else {
Symphony::Configuration()->set('restore-enabled', 'no', 'cdi');
}
// maintenance-enabled
if(isset($_POST['settings']['cdi']['maintenance-enabled'])) {
Symphony::Configuration()->set('maintenance-enabled', 'yes', 'cdi');
} else {
Symphony::Configuration()->set('maintenance-enabled', 'no', 'cdi');
}
// save configuration
return Symphony::Configuration()->write();
} catch(Exception $e) {
Administration::instance()->Page->pageAlert(_('An error occurred while saving preferences for CDI: ') . $e->getMessage());
Symphony::Log()->pushToLog('[CDI] ' . $e->getMessage(), E_ERROR, true);
return false;
}
}