當前位置: 首頁>>代碼示例>>PHP>>正文


PHP rcube::get_user_id方法代碼示例

本文整理匯總了PHP中rcube::get_user_id方法的典型用法代碼示例。如果您正苦於以下問題:PHP rcube::get_user_id方法的具體用法?PHP rcube::get_user_id怎麽用?PHP rcube::get_user_id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rcube的用法示例。


在下文中一共展示了rcube::get_user_id方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: write_log

 /**
  * Append a line to a logfile in the logs directory.
  * Date will be added automatically to the line.
  *
  * @param $name name of log file
  * @param line Line to append
  */
 public static function write_log($name, $line)
 {
     if (!is_string($line)) {
         $line = var_export($line, true);
     }
     $date_format = self::$instance ? self::$instance->config->get('log_date_format') : null;
     $log_driver = self::$instance ? self::$instance->config->get('log_driver') : null;
     if (empty($date_format)) {
         $date_format = 'd-M-Y H:i:s O';
     }
     $date = date($date_format);
     // trigger logging hook
     if (is_object(self::$instance) && is_object(self::$instance->plugins)) {
         $log = self::$instance->plugins->exec_hook('write_log', array('name' => $name, 'date' => $date, 'line' => $line));
         $name = $log['name'];
         $line = $log['line'];
         $date = $log['date'];
         if ($log['abort']) {
             return true;
         }
     }
     if ($log_driver == 'syslog') {
         $prio = $name == 'errors' ? LOG_ERR : LOG_INFO;
         syslog($prio, $line);
         return true;
     }
     // log_driver == 'file' is assumed here
     $line = sprintf("[%s]: %s\n", $date, $line);
     $log_dir = null;
     // per-user logging is activated
     if (self::$instance && self::$instance->config->get('per_user_logging', false) && self::$instance->get_user_id()) {
         $log_dir = self::$instance->get_user_log_dir();
         if (empty($log_dir)) {
             return false;
         }
     } else {
         if (!empty($log['dir'])) {
             $log_dir = $log['dir'];
         } else {
             if (self::$instance) {
                 $log_dir = self::$instance->config->get('log_dir');
             }
         }
     }
     if (empty($log_dir)) {
         $log_dir = RCUBE_INSTALL_PATH . 'logs';
     }
     // try to open specific log file for writing
     $logfile = $log_dir . '/' . $name;
     if ($fp = @fopen($logfile, 'a')) {
         fwrite($fp, $line);
         fflush($fp);
         fclose($fp);
         return true;
     }
     trigger_error("Error writing to log file {$logfile}; Please check permissions", E_USER_WARNING);
     return false;
 }
開發者ID:zamentur,項目名稱:roundcube_ynh,代碼行數:65,代碼來源:rcube.php

示例2: write_log

 /**
  * Append a line to a logfile in the logs directory.
  * Date will be added automatically to the line.
  *
  * @param string $name Name of the log file
  * @param mixed  $line Line to append
  *
  * @return bool True on success, False on failure
  */
 public static function write_log($name, $line)
 {
     if (!is_string($line)) {
         $line = var_export($line, true);
     }
     $date_format = $log_driver = $session_key = null;
     if (self::$instance) {
         $date_format = self::$instance->config->get('log_date_format');
         $log_driver = self::$instance->config->get('log_driver');
         $session_key = intval(self::$instance->config->get('log_session_id', 8));
     }
     $date = rcube_utils::date_format($date_format);
     // trigger logging hook
     if (is_object(self::$instance) && is_object(self::$instance->plugins)) {
         $log = self::$instance->plugins->exec_hook('write_log', array('name' => $name, 'date' => $date, 'line' => $line));
         $name = $log['name'];
         $line = $log['line'];
         $date = $log['date'];
         if ($log['abort']) {
             return true;
         }
     }
     // add session ID to the log
     if ($session_key > 0 && ($sess = session_id())) {
         $line = '<' . substr($sess, 0, $session_key) . '> ' . $line;
     }
     if ($log_driver == 'syslog') {
         $prio = $name == 'errors' ? LOG_ERR : LOG_INFO;
         return syslog($prio, $line);
     }
     // log_driver == 'file' is assumed here
     $line = sprintf("[%s]: %s\n", $date, $line);
     // per-user logging is activated
     if (self::$instance && self::$instance->config->get('per_user_logging', false) && self::$instance->get_user_id()) {
         $log_dir = self::$instance->get_user_log_dir();
         if (empty($log_dir) && $name != 'errors') {
             return false;
         }
     }
     if (empty($log_dir)) {
         if (!empty($log['dir'])) {
             $log_dir = $log['dir'];
         } else {
             if (self::$instance) {
                 $log_dir = self::$instance->config->get('log_dir');
             }
         }
     }
     if (empty($log_dir)) {
         $log_dir = RCUBE_INSTALL_PATH . 'logs';
     }
     return file_put_contents("{$log_dir}/{$name}", $line, FILE_APPEND) !== false;
 }
開發者ID:jimjag,項目名稱:roundcubemail,代碼行數:62,代碼來源:rcube.php


注:本文中的rcube::get_user_id方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。