コード例 #1
0
 /**
  * @brief getAllThemes 获取全部可用主题
  *
  * @return array
  */
 public static function getAllThemes()
 {
     $themes = LogX::readDir(LOGX_THEME);
     $reArray = array();
     foreach ($themes as $key => $theme) {
         $themeName = str_replace(LOGX_THEME, '', $theme);
         if ($themeName[0] != '.' && file_exists($theme . '/index.php') && file_exists($theme . '/post.php') && file_exists($theme . '/page.php')) {
             $reArray[] = $themeName;
         }
     }
     return $reArray;
 }
コード例 #2
0
 /**
  * @brief login 用户登录
  *
  * @return void
  */
 public function login()
 {
     $username = Request::P('username', 'string');
     $password = Request::P('password', 'string');
     $remember = Request::P('remember');
     if ($username == NULL || $password == NULL) {
         $r = array('success' => FALSE, 'message' => _t('Username or password missed.'));
         Response::ajaxReturn($r);
         return;
     }
     $user = new UserLibrary();
     $user->setName($username);
     if (!($u = $user->getUser())) {
         $r = array('success' => FALSE, 'message' => _t('Username not exists.'));
         Response::ajaxReturn($r);
     } else {
         if ($u['password'] != strtolower(md5($password))) {
             $r = array('success' => FALSE, 'message' => _t('Password wrong.'));
             Response::ajaxReturn($r);
             return;
         }
         $this->user['uid'] = $u['uid'];
         $this->user['username'] = $u['username'];
         $this->user['group'] = $u['group'];
         $this->user['email'] = $u['email'];
         $this->user['website'] = $u['website'];
         $expire = $remember ? time() + $remember : 0;
         if ($remember) {
             $u['auth'] = LogX::randomString(8);
             $user->updateSalt($u['auth']);
         }
         Response::setCookie('userid', $u['uid'], $expire);
         Response::setCookie('password', md5($u['auth'] . $u['password']), $expire);
         $r = array('success' => TRUE, 'message' => _t('Login success.'));
         Response::ajaxReturn($r);
     }
 }
コード例 #3
0
 /**
  * @brief deleteAll 删除整个缓存
  *
  * @return void
  */
 public function deleteAll()
 {
     $this->cache = array();
     $files = LogX::readFile(LOGX_CACHE, 'php');
     foreach ($files as $file) {
         if (substr($file, -10) == '.cache.php') {
             @unlink($file);
         }
     }
 }
コード例 #4
0
 /**
  * @brief getPlugins 获取所有可用的插件
  *
  * @return array
  */
 public static function getPlugins()
 {
     $plugins = LogX::readDir(LOGX_PLUGIN);
     $reArray = array();
     foreach ($plugins as $plugin) {
         $pluginName = str_replace(LOGX_PLUGIN, '', $plugin);
         if ($pluginName[0] != '.' && file_exists($plugin . '/' . $pluginName . '.php')) {
             $reArray[] = $pluginName;
         }
     }
     return $reArray;
 }
コード例 #5
0
	</script> 
</div>
<div class="box box-small">
	<div class="box-title">
		<h3><?php 
_e('Server Infomation');
?>
</h3>
		<span></span>
	</div>
	<div class="box-content">
		<?php 
_e('Used Disk Space');
?>
: <?php 
echo round(LogX::countDirSize(LOGX_ROOT) / (1024 * 1024), 2);
?>
MB
		<br /><?php 
_e('Run Time Limit');
?>
: <?php 
echo get_cfg_var('max_execution_time');
?>
s
		<br /><?php 
_e('Operating System');
?>
: <?php 
echo LogX::$_globalVars['SYSTEM']['OS'];
?>
コード例 #6
0
 /**
  * @brief showAttachment 防盗链显示、下载附件
  *
  * @param $params 参数
  *
  * @return void
  */
 public function showAttachment($params)
 {
     $meta = new MetaLibrary();
     $meta->setType(3);
     $meta->setMID($params['mid']);
     if (!($m = $meta->getMeta())) {
         Response::error(404);
         return;
     }
     $m = $m[0];
     // 判断 referer 防盗链
     $referer = Request::S('HTTP_REFERER', 'string');
     if ($referer) {
         $referer = parse_url($referer);
         $host = parse_url(OptionLibrary::get('domain'));
         if (LogX::getDomain($referer['host']) != LogX::getDomain($host['host'])) {
             Response::error(403);
             exit;
         }
     }
     $m['alias'] = LOGX_FILE . $m['alias'];
     // 通过判断getimagesize取出的图片信息是否存在类型标记和色彩位深来防止伪造。
     $isimage = false;
     if (stristr($m['description'], 'image')) {
         if (function_exists('getimagesize')) {
             $imginfo = @getimagesize($m['alias']);
             if (isset($imginfo[2]) && isset($imginfo['bits'])) {
                 $isimage = true;
             }
             unset($imginfo);
         } else {
             $isimage = true;
         }
     }
     // 附件读取形式,inline直接读取,attachment下载到本地
     $disposition = $isimage ? 'inline' : 'attachment';
     // 统计附件下载次数
     if ($disposition == 'attachment') {
         $meta->incReply($params['mid']);
     }
     $m['description'] = $m['description'] ? $m['description'] : 'application/octet-stream';
     if (is_readable($m['alias'])) {
         @ob_end_clean();
         if ($disposition == 'inline') {
             Response::setExpire(60 * 24 * 365);
         }
         header('content-Encoding: none');
         header('content-type: ' . $m['description']);
         header('content-Disposition: ' . $disposition . '; filename=' . urlencode($m['name']));
         header('content-Length: ' . abs(filesize($m['alias'])));
         $fp = @fopen($m['alias'], 'rb');
         @fpassthru($fp);
         @fclose($fp);
         exit;
     } else {
         Response::error(404);
     }
 }
コード例 #7
0
 /**
  * @brief postContent 输出文章内容
  *
  * @param $summary 摘要字数
  * @param $noHtml 是否过滤 HTML 标签
  * @param $e 是否输出
  *
  * @return mix
  */
 public function postContent($summary = 0, $noHtml = FALSE, $e = TRUE)
 {
     // 检查是否有文章
     if (!$this->postHave()) {
         return;
     }
     if (intval($summary)) {
         if ($noHtml) {
             $r = LogX::cutStr(str_replace(array("\r\r", "\r", "\n"), '', strip_tags($this->posts[$this->currentPost - 1]['content'])), intval($summary));
         } else {
             $r = LogX::cutHtmlStr($this->posts[$this->currentPost - 1]['content'], intval($summary));
         }
     } else {
         $r = $this->posts[$this->currentPost - 1]['content'];
     }
     if ($e) {
         echo $r;
     } else {
         return $r;
     }
 }
コード例 #8
0
 * @copyright	LogX Team (http://logx.org/)
 * @license	GNU General Public License V2.0
 * 
 */
// 检查安装
if (!@(include './config.php')) {
    file_exists('./install.php') ? header('Location: install.php') : (print 'Config file missing.');
    exit;
}
// LogX 根路径
define('LOGX_ROOT', str_replace('\\', '/', dirname(__FILE__)) . '/');
// LogX WEB 路径
define('LOGX_PATH', str_replace('index.php', '', $_SERVER['SCRIPT_NAME']));
// 载入 LogX 配置
if (!@(include LOGX_ROOT . 'LogX/Config.php')) {
    die('LogX Config file missing.');
}
// 载入系统文件
if (defined('LOGX_DEBUG') || !file_exists(LOGX_CACHE . '~core.php')) {
    foreach ($coreFiles as $file) {
        if (!@(include $file)) {
            die('Core files missing.');
        }
    }
} else {
    // 载入编译缓存
    include LOGX_CACHE . '~core.php';
}
// 启动 LogX
LogX::init();
コード例 #9
0
 /**
  * @brief init LogX 全局初始化方法
  *
  * @return void
  */
 public static function init()
 {
     // 输出 Logo
     if (isset($_GET['591E-D5FC-8065-CD36-D3E8-E45C-DB86-9197'])) {
         Response::logo();
     }
     // 非 DEBUG 模式下关闭错误输出
     if (defined('LOGX_DEBUG')) {
         error_reporting(E_ALL);
     } else {
         error_reporting(0);
     }
     // 设置自动载入函数
     function __autoLoad($className)
     {
         if (substr($className, -7) == 'Library' && is_file(LOGX_LIB . $className . '.php')) {
             @(require_once LOGX_LIB . $className . '.php');
         }
     }
     // 设置错误与异常处理函数
     set_error_handler(array(__CLASS__, 'error'));
     set_exception_handler(array(__CLASS__, 'exception'));
     // 运行环境检查
     if (!version_compare(PHP_VERSION, '5.0.0', '>=')) {
         throw new LogXException(sprintf(_t('LogX needs PHP 5.0.x or higher to run. You are currently running PHP %s.'), PHP_VERSION));
     }
     if (!version_compare(PHP_VERSION, '5.2.0', '>=')) {
         // 针对低版本 PHP 的兼容代码
         @(require_once LOGX_CORE . 'Compat.php');
     }
     // 设置语言
     if (defined('LOGX_LANGUAGE')) {
         Language::set(LOGX_LANGUAGE);
     } else {
         Language::set('zh-cn');
     }
     // 预编译核心文件
     global $coreFiles;
     if (!defined('LOGX_DEBUG') && !file_exists(LOGX_CACHE . '~core.php')) {
         Compile::build(LOGX_CACHE, $coreFiles, 'core');
     } elseif (!defined('LOGX_DEBUG')) {
         $file_time = filemtime(LOGX_CACHE . '~core.php');
         foreach ($coreFiles as $file) {
             if (filemtime($file) > $file_time) {
                 Compile::build(LOGX_CACHE, $coreFiles, 'core');
                 break;
             }
         }
     }
     self::$_globalVars = array('RUN' => array('TIME' => microtime(TRUE), 'MEM' => function_exists('memory_get_usage') ? memory_get_usage() : 0, 'LANG' => 'zh-cn'), 'SYSTEM' => array('OS' => PHP_OS, 'HTTP' => Request::S('SERVER_SOFTWARE', 'string'), 'PHP' => PHP_VERSION, 'MYSQL' => ''), 'SUPPORT' => array('MYSQL' => function_exists('mysql_connect'), 'GD' => function_exists('imagecreate'), 'MEMCACHE' => function_exists('memcache_connect'), 'SHMOP' => function_exists('shmop_open'), 'GZIP' => function_exists('ob_gzhandler'), 'TIMEZONE' => function_exists('date_default_timezone_set'), 'AUTOLOAD' => function_exists('spl_autoload_register')), 'INI' => array('ALLOW_CALL_TIME_PASS_REFERENCE' => ini_get('allow_call_time_pass_reference'), 'MAGIC_QUOTES_GPC' => ini_get('magic_quotes_gpc'), 'REGISTER_GLOBALS' => ini_get('register_globals'), 'ALLOW_URL_FOPEN' => ini_get('allow_url_fopen'), 'ALLOW_URL_INCLUDE' => ini_get('allow_url_include'), 'SAFE_MODE' => ini_get('safe_mode'), 'MAX_EXECUTION_TIME' => ini_get('max_execution_time'), 'MEMORY_LIMIT' => ini_get('memory_limit'), 'POST_MAX_SIZE' => ini_get('post_max_size'), 'FILE_UPLOADS' => ini_get('file_uploads'), 'UPLOAD_MAX_FILESIZE' => ini_get('upload_max_filesize'), 'MAX_FILE_UPLOADS' => ini_get('max_file_uploads')));
     // 清除不需要的变量,防止变量注入
     $defined_vars = get_defined_vars();
     foreach ($defined_vars as $key => $value) {
         if (!in_array($key, array('_POST', '_GET', '_COOKIE', '_SERVER', '_FILES'))) {
             ${$key} = '';
             unset(${$key});
         }
     }
     // 对用户输入进行转义处理
     if (!get_magic_quotes_gpc()) {
         $_GET = self::addSlashes($_GET);
         $_POST = self::addSlashes($_POST);
         $_COOKIE = self::addSlashes($_COOKIE);
     }
     // 开启输出缓存
     if (defined('LOGX_GZIP') && self::$_globalVars['SUPPORT']['GZIP']) {
         ob_start('ob_gzhandler');
     } else {
         ob_start();
     }
     // 连接到数据库
     Database::connect(DB_HOST, DB_USER, DB_PWD, DB_NAME, DB_PCONNECT);
     self::$_globalVars['SYSTEM']['MYSQL'] = Database::version();
     // 设定时区
     if (self::$_globalVars['SUPPORT']['TIMEZONE']) {
         date_default_timezone_set(OptionLibrary::get('timezone'));
     }
     // 连接到缓存
     Cache::connect(CACHE_TYPE);
     // 初始化路由表
     Router::init();
     // 初始化主题控制器
     Theme::init();
     // 初始化 Plugin
     Plugin::initPlugins();
     // 初始化全局组件
     Widget::initWidget('Global');
     Widget::initWidget('Widget');
     Widget::initWidget('Page');
     Widget::initWidget('User');
     // 尝试自动登录
     Widget::getWidget('User')->autoLogin();
     // 启动路由分发
     Router::dispatch();
 }