本文整理汇总了PHP中t3lib_div::sysLog方法的典型用法代码示例。如果您正苦于以下问题:PHP t3lib_div::sysLog方法的具体用法?PHP t3lib_div::sysLog怎么用?PHP t3lib_div::sysLog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类t3lib_div
的用法示例。
在下文中一共展示了t3lib_div::sysLog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writeLogEntries
/**
* Writes exception to different logs
*
* @param Exception $exception The exception
* @param string the context where the exception was thrown, WEB or CLI
* @return void
* @see t3lib_div::sysLog(), t3lib_div::devLog()
*/
protected function writeLogEntries(Exception $exception, $context)
{
$filePathAndName = $exception->getFile();
$exceptionCodeNumber = $exception->getCode() > 0 ? '#' . $exception->getCode() . ': ' : '';
$logTitle = 'Core: Exception handler (' . $context . ')';
$logMessage = 'Uncaught TYPO3 Exception: ' . $exceptionCodeNumber . $exception->getMessage() . ' | ' . get_class($exception) . ' thrown in file ' . $filePathAndName . ' in line ' . $exception->getLine();
$backtrace = $exception->getTrace();
// write error message to the configured syslogs
t3lib_div::sysLog($logMessage, $logTitle, 4);
// When database credentials are wrong, the exception is probably
// caused by this. Therefor we cannot do any database operation,
// otherwise this will lead into recurring exceptions.
try {
// In case an error occurs before a database connection exists, try
// to connect to the DB to be able to write the devlog/sys_log entry
if (isset($GLOBALS['TYPO3_DB']) && is_object($GLOBALS['TYPO3_DB']) && empty($GLOBALS['TYPO3_DB']->link)) {
$GLOBALS['TYPO3_DB']->connectDB();
}
// write error message to devlog
// see: $TYPO3_CONF_VARS['SYS']['enable_exceptionDLOG']
if (TYPO3_EXCEPTION_DLOG) {
t3lib_div::devLog($logMessage, $logTitle, 3, array('TYPO3_MODE' => TYPO3_MODE, 'backtrace' => $backtrace));
}
// write error message to sys_log table
$this->writeLog($logTitle . ': ' . $logMessage);
} catch (Exception $exception) {
// Nothing happens here. It seems the database credentials are wrong
}
}
示例2: internalSanitizeLocalUrl
/**
* Checks if a given string is a valid frame URL to be loaded in the
* backend.
*
* @param string $url potential URL to check
*
* @return string either $url if $url is considered to be harmless, or an
* empty string otherwise
*/
private static function internalSanitizeLocalUrl($url = '')
{
$sanitizedUrl = '';
$decodedUrl = rawurldecode($url);
if ($decodedUrl !== t3lib_div::removeXSS($decodedUrl)) {
$decodedUrl = '';
}
if (!empty($url) && $decodedUrl !== '') {
$testAbsoluteUrl = t3lib_div::resolveBackPath($decodedUrl);
$testRelativeUrl = t3lib_div::resolveBackPath(t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')) . '/' . $decodedUrl);
// That's what's usually carried in TYPO3_SITE_PATH
$typo3_site_path = substr(t3lib_div::getIndpEnv('TYPO3_SITE_URL'), strlen(t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST')));
// Pass if URL is on the current host:
if (self::isValidUrl($decodedUrl)) {
if (self::isOnCurrentHost($decodedUrl) && strpos($decodedUrl, t3lib_div::getIndpEnv('TYPO3_SITE_URL')) === 0) {
$sanitizedUrl = $url;
}
// Pass if URL is an absolute file path:
} elseif (t3lib_div::isAbsPath($decodedUrl) && t3lib_div::isAllowedAbsPath($decodedUrl)) {
$sanitizedUrl = $url;
// Pass if URL is absolute and below TYPO3 base directory:
} elseif (strpos($testAbsoluteUrl, $typo3_site_path) === 0 && substr($decodedUrl, 0, 1) === '/') {
$sanitizedUrl = $url;
// Pass if URL is relative and below TYPO3 base directory:
} elseif (strpos($testRelativeUrl, $typo3_site_path) === 0 && substr($decodedUrl, 0, 1) !== '/') {
$sanitizedUrl = $url;
}
}
if (!empty($url) && empty($sanitizedUrl)) {
t3lib_div::sysLog('The URL "' . $url . '" is not considered to be local and was denied.', 'Core', t3lib_div::SYSLOG_SEVERITY_NOTICE);
}
return $sanitizedUrl;
}
示例3: main
/**
* Default action.
*
* @return array
* @throws RuntimeException
*/
public function main()
{
$this->init();
$allowedIps = t3lib_div::trimExplode(',', $this->config['allowedIps'], true);
if ($this->config['debug']) {
t3lib_div::sysLog('Connection from ' . t3lib_div::getIndpEnv('REMOTE_ADDR'), self::$extKey);
}
if ($this->config['mode'] !== 'M' || count($allowedIps) && !t3lib_div::inArray($allowedIps, t3lib_div::getIndpEnv('REMOTE_ADDR'))) {
$this->denyAccess();
}
$this->initTSFE();
if (!empty($this->config['synchronizeDeletedAccounts']) && $this->config['synchronizeDeletedAccounts']) {
$additionalFields = ', deleted';
$additionalWhere = '';
} else {
$additionalFields = '';
$additionalWhere = ' AND deleted=0';
}
$administrators = $this->getDatabaseConnection()->exec_SELECTgetRows('username, admin, disable, realName, email, TSconfig, starttime, endtime, lang, tx_openid_openid' . $additionalFields, 'be_users', 'admin=1 AND tx_openid_openid<>\'\'' . $additionalWhere);
if (count($administrators)) {
$key = $this->config['preSharedKey'];
$data = json_encode($administrators);
$encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $data, MCRYPT_MODE_CBC, md5(md5($key)));
$encrypted = base64_encode($encrypted);
return $encrypted;
} else {
throw new RuntimeException('No administrators found', 1327586994);
}
}
示例4: indexAction
/**
*
* @return string
*/
public function indexAction()
{
try {
$options = $this->widgetConfiguration['options'];
$apiKey = $this->widgetConfiguration['apiKey'];
if (!empty($this->widgetConfiguration['templatePathAndName'])) {
$this->view->setTemplatePathAndFilename(t3lib_div::getFileAbsFileName($this->widgetConfiguration['templatePathAndName']));
}
$flickr = new Tx_T3orgFlickrfeed_Utility_Flickr($apiKey);
if ($this->widgetConfiguration['type'] == 1 || $this->widgetConfiguration['type'] === 'tag') {
// tagSearch
$this->view->assign('result', $flickr->tagSearch($this->widgetConfiguration['tags'], $options));
if (is_array($this->widgetConfiguration['tags']) || $this->widgetConfiguration['tags'] instanceof Traversable) {
$tags = $this->widgetConfiguration['tags'];
} else {
$tags = t3lib_div::trimExplode(',', $this->widgetConfiguration['tags'], true);
}
$this->view->assign('tags', $tags);
} elseif ($this->widgetConfiguration['type'] == 2 || $this->widgetConfiguration['type'] === 'user') {
// people.getPublicPhotos
$this->view->assign('result', $flickr->userSearch($this->widgetConfiguration['user_id'], $options));
} else {
$this->view->assign('result', $flickr->groupPoolGetPhotos($this->widgetConfiguration['group_id'], $options));
}
} catch (Exception $e) {
t3lib_div::sysLog($e->getMessage(), $this->request->getControllerExtensionKey(), LOG_ERR);
$this->view->assign('error', $e->getMessage());
}
}
示例5: render
/**
* Renders Lorem Ipsum paragraphs. If $lipsum is provided it
* will be used as source text. If not provided as an argument
* or as inline argument, $lipsum is fetched from TypoScript settings.
*
* @param string $lipsum String of paragraphs file path or EXT:myext/path/to/file
* @return string
*/
public function render($lipsum = NULL)
{
if (strlen($lipsum) === 0) {
$this->getDefaultLoremIpsum();
}
if (strlen($lipsum) < 255 && !preg_match('/[^a-z0-9_\\./]/i', $lipsum)) {
// argument is most likely a file reference.
$sourceFile = t3lib_div::getFileAbsFileName($lipsum);
if (file_exists($sourceFile) === TRUE) {
$lipsum = file_get_contents($sourceFile);
} else {
t3lib_div::sysLog('Vhs LipsumViewHelper was asked to load Lorem Ipsum from a file which does not exist. ' . 'The file was: ' . $sourceFile, 'Vhs');
$lipsum = $this->getDefaultLoremIpsum();
}
}
$lipsum = preg_replace('/[\\r\\n]{1,}/i', "\n", $lipsum);
$paragraphs = explode("\n", $lipsum);
$paragraphs = array_slice($paragraphs, 0, intval($settings['paragraphs']));
foreach ($paragraphs as $index => $paragraph) {
$length = $settings['wordsPerParagraph'] + rand(0 - intval($settings['skew']), intval($settings['skew']));
$words = explode(' ', $paragraph);
$paragraphs[$index] = implode(' ', array_slice($words, 0, $length));
}
$lipsum = implode("\n", $paragraphs);
if ((bool) $settings['html'] === TRUE) {
$lipsum = $this->contentObject->parseFunc($lipsum, array(), '< ' . $settings['parseFuncTSPath']);
}
return $lipsum;
}
示例6: writeLogMessage
/**
* Writes log message.
* Destination log depends on the current system mode.
* For FE the function writes to the admin panel log. For BE messages are
* sent to the system log. If developer log is enabled, messages are also
* sent there.
*
* This function accepts variable number of arguments and can format
* parameters. The syntax is the same as for sprintf()
*
* @param string $message:
* to output
* @return void
* @see sprintf()
* @see t3lib::divLog()
* @see t3lib_div::sysLog()
* @see t3lib_timeTrack::setTSlogMessage()
*/
public static function writeLogMessage($message)
{
if (func_num_args() > 1) {
$params = func_get_args();
array_shift($params);
$message = vsprintf($message, $params);
}
if (TYPO3_MODE === 'BE') {
t3lib_div::sysLog($message, self::$extKey, 1);
}
if (TYPO3_DLOG) {
t3lib_div::devLog($message, self::$extKey, 1);
}
}
示例7: dispatchAction
/**
* the only action the extbase dispatcher knows of
*
* @return null
*/
public function dispatchAction()
{
if (!$this->controllerName) {
t3lib_div::sysLog(sprintf('There was no controller name set for class %s.', get_class($this)), 'cz_simple_cal', 2);
return '';
}
if (!isset($this->settings[$this->controllerName]) || !is_array($this->settings[$this->controllerName]) || !isset($this->settings[$this->controllerName]['allowedActions'])) {
t3lib_div::sysLog(sprintf('There were no allowedActions set on pageId %d, so there was nothing to display for the calendar.', $GLOBALS['TSFE']->id), 'cz_simple_cal', 2);
return '';
}
$actions = t3lib_div::trimExplode(',', $this->settings[$this->controllerName]['allowedActions'], true);
reset($actions);
$this->forward(current($actions));
}
示例8: mail
/**
* Proxy for the PHP mail() function. Adds possibility to hook in and send the mails in a different way.
* The hook can be used by adding function to the configuration array:
* $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery']
*
* @param string Email address to send to.
* @param string Subject line, non-encoded. (see PHP function mail())
* @param string Message content, non-encoded. (see PHP function mail())
* @param string Additional headers for the mail (see PHP function mail())
* @param string Additional flags for the sending mail tool (see PHP function mail())
* @return boolean Indicates whether the mail has been sent or not
* @see PHP function mail() []
* @link http://www.php.net/manual/en/function.mail.php
*/
public static function mail($to, $subject, $messageBody, $additionalHeaders = null, $additionalParameters = null)
{
$success = TRUE;
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery'])) {
$parameters = array('to' => $to, 'subject' => $subject, 'messageBody' => $messageBody, 'additionalHeaders' => $additionalHeaders, 'additionalParameters' => $additionalParameters);
$fakeThis = FALSE;
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery'] as $hookMethod) {
$success = $success && t3lib_div::callUserFunction($hookMethod, $parameters, $fakeThis);
}
} else {
$success = @mail($to, $subject, $messageBody, $additionalHeaders, $additionalParameters);
}
if (!$success) {
t3lib_div::sysLog('Mail to "' . $email . '" could not be sent (Subject: "' . $subject . '").', 'Core', 3);
}
return $success;
}
示例9: listAction
/**
* listAction
*
* @see http://www.flickr.com/services/api/flickr.photos.search.html
* @see http://www.flickr.com/services/api/flickr.groups.pools.getPhotos.html
* @see http://www.flickr.com/services/api/flickr.people.getPublicPhotos.html
*
*/
public function listAction()
{
try {
$options = $this->buildOptions();
$apiKey = $this->settings['apiKey'];
$flickr = new Tx_T3orgFlickrfeed_Utility_Flickr($apiKey);
if ($this->settings['type'] == 1) {
// tagSearch
$this->view->assign('result', $flickr->tagSearch($this->settings['tags'], $options));
$tags = t3lib_div::trimExplode(',', $this->settings['tags'], true);
$this->view->assign('tags', $tags);
} elseif ($this->settings['type'] == 2) {
// people.getPublicPhotos
$this->view->assign('result', $flickr->userSearch($this->settings['user_id'], $options));
} else {
$this->view->assign('result', $flickr->groupPoolGetPhotos($this->settings['group_id'], $options));
}
} catch (Exception $e) {
t3lib_div::sysLog($e->getMessage(), $this->request->getControllerExtensionKey(), LOG_ERR);
$this->view->assign('error', $e->getMessage());
}
}
示例10: execute
/**
* This is the main method that is called when a task is executed
* It MUST be implemented by all classes inheriting from this one
* Note that there is no error handling, errors and failures are expected
* to be handled and logged by the client implementations.
* Should return true on successful execution, false on error.
*
* @return boolean Returns true on successful execution, false on error
*/
public function execute()
{
$success = false;
$this->init();
$content = t3lib_div::getUrl($this->config['masterUrl']);
if ($content) {
$response = json_decode($content, true);
if ($response['success']) {
$key = $this->config['preSharedKey'];
$encrypted = $response['data'];
$data = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($encrypted), MCRYPT_MODE_CBC, md5(md5($key))), "");
$records = json_decode($data, true);
if (count($records)) {
$this->synchronizeUsers($records);
$success = true;
} else {
t3lib_div::sysLog('No users to be synchronized', self::$extKey, 3);
}
} else {
t3lib_div::sysLog($response['errors'][0], self::$extKey, 3);
}
}
return $success;
}
开发者ID:sruegg,项目名称:t3ext-causal_accounts,代码行数:33,代码来源:class.tx_causalaccounts_synchronizationtask.php
示例11: decryptPasswordForAutoLogin
/**
* Decrypts the password for auto-login on confirmation or invitation acceptation
*
* @param array $dataArray: table row containing the password to be decrypted
* @param array $row: incoming data containing the auto-login private key
* @return void
*/
public function decryptPasswordForAutoLogin(array &$dataArray, array $row)
{
if (isset($row['auto_login_key'])) {
$privateKey = $row['auto_login_key'];
if ($privateKey !== '') {
$password = $dataArray['tx_srfeuserregister_password'];
if ($password != '') {
$backend = tx_rsaauth_backendfactory::getBackend();
if (is_object($backend) && $backend->isAvailable()) {
$decryptedPassword = $backend->decrypt($privateKey, $password);
if ($decryptedPassword) {
$dataArray['password'] = $decryptedPassword;
} else {
// Failed to decrypt auto login password
$message = $GLOBALS['TSFE']->sL('LLL:EXT:' . $this->extKey . '/pi1/locallang.xml:internal_decrypt_auto_login_failed');
t3lib_div::sysLog($message, $this->extKey, t3lib_div::SYSLOG_SEVERITY_ERROR);
}
} else {
// Required RSA auth backend not available
// Should not happen: checked in tx_srfeuserregister_pi1_base::checkRequirements
}
}
}
}
}
示例12: handleError
/**
* Handles an error.
* If the error is registered as exceptionalError it will by converted into an exception, to be handled
* by the configured exceptionhandler. Additionall the error message is written to the configured logs.
* If TYPO3_MODE is 'BE' the error message is also added to the flashMessageQueue, in FE the error message
* is displayed in the admin panel (as TsLog message)
*
* @param integer The error level - one of the E_* constants
* @param string The error message
* @param string Name of the file the error occurred in
* @param integer Line number where the error occurred
* @return void
* @throws t3lib_error_Exception with the data passed to this method if the error is registered as exceptionalError
*/
public function handleError($errorLevel, $errorMessage, $errorFile, $errorLine)
{
// don't do anything if error_reporting is disabled by an @ sign
if (error_reporting() == 0) {
return TRUE;
}
$errorLevels = array(E_WARNING => 'Warning', E_NOTICE => 'Notice', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT => 'Runtime Notice', E_RECOVERABLE_ERROR => 'Catchable Fatal Error');
$message = 'PHP ' . $errorLevels[$errorLevel] . ': ' . $errorMessage . ' in ' . $errorFile . ' line ' . $errorLine;
if ($errorLevel & $this->exceptionalErrors) {
throw new t3lib_error_Exception($message, 1);
} else {
switch ($errorLevel) {
case E_USER_ERROR:
case E_RECOVERABLE_ERROR:
$severity = 2;
break;
case E_USER_WARNING:
case E_WARNING:
$severity = 1;
break;
default:
$severity = 0;
break;
}
$logTitle = 'Core: Error handler (' . TYPO3_MODE . ')';
// Write error message to the configured syslogs,
// see: $TYPO3_CONF_VARS['SYS']['systemLog']
if ($errorLevel & $GLOBALS['TYPO3_CONF_VARS']['SYS']['syslogErrorReporting']) {
t3lib_div::sysLog($message, $logTitle, $severity);
}
// In case an error occurs before a database connection exists, try
// to connect to the DB to be able to write an entry to devlog/sys_log
if (is_object($GLOBALS['TYPO3_DB']) && empty($GLOBALS['TYPO3_DB']->link)) {
try {
$GLOBALS['TYPO3_DB']->connectDB();
} catch (Exception $e) {
// There's nothing more we can do at this point if the
// database failed. It is up to the various log writers
// to check for themselves whether the have a DB connection
// available or not.
}
}
// Write error message to devlog extension(s),
// see: $TYPO3_CONF_VARS['SYS']['enable_errorDLOG']
if (TYPO3_ERROR_DLOG) {
t3lib_div::devLog($message, $logTitle, $severity + 1);
}
// Write error message to TSlog (admin panel)
if (is_object($GLOBALS['TT'])) {
$GLOBALS['TT']->setTSlogMessage($logTitle . ': ' . $message, $severity + 1);
}
// Write error message to sys_log table (ext: belog, Tools->Log)
if ($errorLevel & $GLOBALS['TYPO3_CONF_VARS']['SYS']['belogErrorReporting']) {
$this->writeLog($logTitle . ': ' . $message, $severity);
}
// Add error message to the flashmessageQueue
if (defined('TYPO3_ERRORHANDLER_MODE') && TYPO3_ERRORHANDLER_MODE == 'debug') {
$flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $message, 'PHP ' . $errorLevels[$errorLevel], $severity);
t3lib_FlashMessageQueue::addMessage($flashMessage);
}
}
// Don't execute PHP internal error handler
return TRUE;
}
示例13: IDtoPagePathThroughOverride
/**
* Checks if the page has a path to override.
*
* @param int $id
* @param string $mpvar
* @param int $lang
* @return array
*/
protected function IDtoPagePathThroughOverride($id, $mpvar, $lang)
{
$result = false;
$page = $this->getPage($id, $lang);
if ($page['tx_realurl_pathoverride']) {
if ($page['tx_realurl_pathsegment']) {
$result = array('pagepath' => trim($page['tx_realurl_pathsegment'], '/'), 'langID' => intval($lang), 'rootpage_id' => intval($this->conf['rootpage_id']));
} else {
$message = sprintf('Path override is set for page=%d (language=%d) but no segment defined!', $id, $lang);
t3lib_div::sysLog($message, 'realurl', 3);
$this->pObj->devLog($message, false, 2);
}
}
return $result;
}
示例14: authUser
/**
* Authenticate a user (Check various conditions for the user that might invalidate its authentication, eg. password match, domain, IP, etc.)
*
* @param array Data of user.
* @return boolean
*/
function authUser($user)
{
$OK = 100;
if ($this->login['uident'] && $this->login['uname']) {
// Checking password match for user:
$OK = $this->compareUident($user, $this->login);
if (!$OK) {
// Failed login attempt (wrong password) - write that to the log!
if ($this->writeAttemptLog) {
$this->writelog(255, 3, 3, 1, "Login-attempt from %s (%s), username '%s', password not accepted!", array($this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $this->login['uname']));
t3lib_div::sysLog(sprintf("Login-attempt from %s (%s), username '%s', password not accepted!", $this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $this->login['uname']), 'Core', 0);
}
if ($this->writeDevLog) {
t3lib_div::devLog('Password not accepted: ' . $this->login['uident'], 'tx_sv_auth', 2);
}
}
// Checking the domain (lockToDomain)
if ($OK && $user['lockToDomain'] && $user['lockToDomain'] != $this->authInfo['HTTP_HOST']) {
// Lock domain didn't match, so error:
if ($this->writeAttemptLog) {
$this->writelog(255, 3, 3, 1, "Login-attempt from %s (%s), username '%s', locked domain '%s' did not match '%s'!", array($this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $user[$this->db_user['username_column']], $user['lockToDomain'], $this->authInfo['HTTP_HOST']));
t3lib_div::sysLog(sprintf("Login-attempt from %s (%s), username '%s', locked domain '%s' did not match '%s'!", $this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $user[$this->db_user['username_column']], $user['lockToDomain'], $this->authInfo['HTTP_HOST']), 'Core', 0);
}
$OK = false;
}
}
return $OK;
}
示例15: sysLog
/**
* Adds a common log entry for this locking API using t3lib_div::sysLog().
* Example: 25-02-08 17:58 - cms: Locking [simple::0aeafd2a67a6bb8b9543fb9ea25ecbe2]: Acquired
*
* @param string $message: The message to be logged
* @param integer $severity: Severity - 0 is info (default), 1 is notice, 2 is warning, 3 is error, 4 is fatal error
* @return void
*/
public function sysLog($message, $severity = 0)
{
if ($this->isLoggingEnabled) {
t3lib_div::sysLog('Locking [' . $this->method . '::' . $this->id . ']: ' . trim($message), $this->syslogFacility, $severity);
}
}