示例#1
0
 /**
  * 验证帐号是否被锁定
  *
  * @author          mrmsl <*****@*****.**>
  * @date            2012-07-12 09:02:21
  * @lastmodify      2013-01-22 11:47:43 by mrmsl
  *
  * @param array $admin_info 管理员信息
  *
  * @return mixed true未被锁定,否则返回错误信息
  */
 private function _checkLock($admin_info)
 {
     if ($admin_info['lock_start_time'] && $admin_info['lock_start_time'] < APP_NOW_TIME && $admin_info['lock_end_time'] && $admin_info['lock_end_time'] > APP_NOW_TIME) {
         $info = L('ACCOUNT_IS_LOCKED,TO') . new_date(sys_config('sys_timezone_datetime_format'), $admin_info['lock_end_time']);
         $this->addLog("{$admin_info['username']}[{$admin_info['realname']}] {$info}", LOG_TYPE_ADMIN_LOGIN_INFO);
         return $info;
     }
     return true;
 }
示例#2
0
 /**
  * 创建运行时文件
  *
  * @author          mrmsl <*****@*****.**>
  * @date            2013-01-22 15:45:33
  * @lastmodify      2013-02-18 17:03:00 by mrmsl
  *
  * @return void 无返回值
  */
 private function _buildRuntimeFile()
 {
     $filesize = 0;
     //加载文件大小
     $compile = "<?php\n!defined('YAB_PATH') && exit('Access Denied');";
     //编译内容
     //加载核心文件
     foreach ($this->_require_files as $file) {
         require $file;
         if (defined('APP_DEBUG') && !APP_DEBUG) {
             $filesize += filesize($file);
             $compile .= compile_file($file);
         }
     }
     $require_files = array(CORE_PATH . 'Bootstrap.' . APP_EXT, CORE_PATH . 'Template.' . APP_EXT, CORE_PATH . 'Model.' . APP_EXT, CORE_PATH . 'Logger.' . APP_EXT, CORE_PATH . 'Filter.' . APP_EXT, CORE_PATH . 'Db.' . APP_EXT, CORE_PATH . 'drivers/db/Db' . ucfirst(DB_TYPE) . '.' . APP_EXT);
     if (is_file($filename = LIB_PATH . 'BaseController.' . APP_EXT)) {
         //底层控制器类
         $require_files[] = $filename;
     }
     if (is_file($filename = APP_PATH . 'controllers/Common.' . APP_EXT)) {
         //项目底层通用控制器类
         $require_files[] = $filename;
     }
     if (is_file($filename = LIB_PATH . 'BaseModel.' . APP_EXT)) {
         //底层模型类
         $require_files[] = $filename;
     }
     if (is_file($filename = APP_PATH . 'models/Common.' . APP_EXT)) {
         //项目底层通用模型类
         $require_files[] = $filename;
     }
     //加载核心文件,用空间换时间
     if (APP_DEBUG) {
         //调试
         foreach ($require_files as $file) {
             require $file;
         }
     } else {
         foreach ($require_files as $file) {
             require $file;
             $filesize += filesize($file);
             $compile .= compile_file($file);
         }
         file_put_contents(RUNTIME_FILE, $compile);
         $size = filesize(RUNTIME_FILE);
         //编译后大小
         file_put_contents(LOG_PATH . 'compile_runtime_file.log', new_date() . '(' . format_size($filesize) . ' => ' . format_size($size) . ')' . EOL_LF, FILE_APPEND);
     }
 }
示例#3
0
 /**
  * 循环获取评论
  *
  * @author          mrmsl <*****@*****.**>
  * @date            2013-04-28 12:47:13
  *
  * @param array $comments 评论数组
  * @param bool  $is_reply true为回复。默认false
  *
  * @return string 评论html
  */
 protected function _getRecurrsiveComments($comments, $is_reply = false)
 {
     if (!$comments) {
         return '';
     }
     $html = '';
     foreach ($comments as $item) {
         $html .= '
         <div class="panel-list media comment-detail panel-comment' . ($is_reply ? ' panel-comment-reply' : '') . '" id="comment-' . $item['comment_id'] . '">
             <img class="media-object pull-left avatar avatar-level-' . $item['level'] . '" alt="" src="';
         if ($item['user_pic']) {
             $html .= $item['user_pic'];
         } else {
             $html .= $item['email'] ? 'http://www.gravatar.com/avatar/' . md5($item['email']) . '?d=http%3A%2F%2Fwww.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536' : COMMON_IMGCACHE . 'images/guest.png';
         }
         $html .= '" />
             <div class="media-body">
                 <p class="muted">
                     <a href="#base-' . $item['comment_id'] . '" rel="nofollow" class="muted pull-right hide reply"><span class="icon-share-alt icon-gray"></span>' . L('REPLY') . '</a>
                     <span class="name-' . $item['comment_id'] . '">';
         if ($item['user_homepage']) {
             $html .= '  <a href="' . $item['user_homepage'] . '" rel="nofollow">' . $item['username'] . '</a>';
         } else {
             $html .= $item['username'];
         }
         if ($item['city']) {
             $html .= "      [{$item['province']}{$item['city']}]";
         } elseif ($ip = long2ip($item['user_ip'])) {
             $arr = explode('.', $ip);
             $arr[2] = $arr[3] = '*';
             $ip = join('.', $arr);
             $html .= "      [{$ip}]";
         }
         $html .= '  </span><span class="time-axis pull-right" data-time="' . $item['add_time'] . '">' . new_date(null, $item['add_time']) . '</span>';
         $html .= '</p>';
         $html .= $item['content'];
         $html .= '<span id="base-' . $item['comment_id'] . '"></span>';
         if (!empty($item['data'])) {
             $html .= $this->_getRecurrsiveComments($item['data'], true);
         } elseif ($item['last_reply_time'] > $item['add_time'] && $item['level'] < 5 && !$is_reply) {
             $html .= $this->_getReplyComments($item['comment_id']);
         }
         $html .= '
             </div>
         </div>';
     }
     return $html;
 }
示例#4
0
 /**
  * 验证其它,包括提交频率,禁止ip等
  *
  * @author      mrmsl <*****@*****.**>
  * @date        2013-05-24 09:15:07
  *
  * @return string|bool true验证成功,否则错误信息
  */
 private function _checkOther()
 {
     $module = C('T_VERIFYCODE_MODULE');
     $last_time = session($module);
     if ($last_time > time() && $this->_module->getGuestbookCommentsSetting($module, 'alternation')) {
         //提交过于频繁
         $error = sprintf(L('YOUR_SUBMIT_HIGH_FREQUENCY'), L(C('T_MODULE')));
         $log = $module . $error . ',' . new_date(null, $last_time) . ' => ' . new_date();
         $error = $error . ',' . str_replace('{0}', new_date(null, $last_time), L('TRY_IT_UNTIL'));
     }
     if ($disabled_ip = $this->_module->getGuestbookCommentsSetting($module, 'disabled_ip')) {
         if (in_array($ip = get_client_ip(), explode(EOL_LF, $disabled_ip))) {
             $log = $error = L('FORBID,' . C('T_MODULE')) . 'ip:' . $ip;
         }
     }
     if (empty($log)) {
         return true;
     }
     $this->_module->triggerError(__METHOD__ . ': ' . __LINE__ . ',' . $log);
     C('T_REDIRECT', true);
     return $error;
 }
示例#5
0
 /**
  * 创建运行时文件
  *
  * @author          mrmsl <*****@*****.**>
  * @date            2013-09-26 10:37:40
  *
  * @return void 无返回值
  */
 private function _buildRuntimeFile()
 {
     $filesize = 0;
     //加载文件大小
     $compile = '<?php' . PHP_EOL . "!defined('YAB_PATH') && exit('Access Denied');";
     //编译内容
     //加载核心文件,用空间换时间
     if (APP_DEBUG) {
         //调试
         foreach ($this->_require_files as $file) {
             require $file;
         }
     } else {
         foreach ($this->_require_files as $file) {
             require $file;
             $filesize += filesize($file);
             $compile .= compile_file($file);
         }
     }
     $require_files = array(CORE_PATH . 'Template' . PHP_EXT, CORE_PATH . 'Controller' . PHP_EXT, CORE_PATH . 'Model' . PHP_EXT, CORE_PATH . 'Logger' . PHP_EXT, CORE_PATH . 'Filter' . PHP_EXT, CORE_PATH . 'Db' . PHP_EXT, CORE_PATH . 'drivers/db/Db' . ucfirst(DB_TYPE) . PHP_EXT, LIB_PATH . 'BaseModel' . PHP_EXT, LIB_PATH . 'SVNDiff' . PHP_EXT, APP_PATH . '/controllers/CommonController' . PHP_EXT, APP_PATH . '/models/CommonModel' . PHP_EXT, LIB_PATH . 'LogModel' . PHP_EXT);
     //加载核心文件,用空间换时间
     if (APP_DEBUG) {
         //调试
         foreach ($require_files as $file) {
             require $file;
         }
     } else {
         foreach ($require_files as $file) {
             require $file;
             $filesize += filesize($file);
             $compile .= compile_file($file);
         }
         file_put_contents(RUNTIME_FILE, $compile);
         $size = filesize(RUNTIME_FILE);
         //编译后大小
         file_put_contents(LOG_PATH . 'compile_runtime_file.log', new_date() . '(' . format_size($filesize) . ' => ' . format_size($size) . ')' . PHP_EOL, FILE_APPEND);
     }
 }
示例#6
0
 /**
  * 获取文件列表
  *
  * @author          mrmsl <*****@*****.**>
  * @date            2012-07-17 12:46:02
  *
  * @param string $node 节点路径
  *
  * @return array 文件列表
  */
 private function _getFile($node)
 {
     $node = trim($node, '/');
     $this->_denyDirectory($node);
     $file_arr = array();
     $directory = PACKER_JS_PATH . $node . '/';
     $k = 0;
     if (is_dir($directory)) {
         $date_format = sys_config('sys_timezone_datetime_format');
         $d = dir($directory);
         while ($f = $d->read()) {
             if ($f == '.' || $f == '..' || substr($f, 0, 1) == '.') {
                 continue;
             }
             $filename = $directory . '/' . $f;
             if (is_dir($filename)) {
                 $file_arr[$k] = array('text' => $f, 'checked' => $f == 'pack' ? null : false, 'id' => $node . '/' . $f);
                 $file_arr[$k]['data'] = $this->_getFile($f);
                 $k++;
             } elseif (substr($f, -3) == '.js' && !in_array($f, array('app.js'))) {
                 $desc = '';
                 //js文件说明
                 $file = new SplFileObject($filename);
                 if (!strpos($filename, '.min.')) {
                     $file->fgets();
                     $desc = trim(str_replace('*', '', $file->fgets()));
                     //第二行为文件说明
                 }
                 $file_arr[] = array('text' => $f, 'id' => $node . '/' . $f, 'leaf' => true, 'checked' => $node == 'pack' ? null : false, 'filesize' => format_size($file->getSize()), 'filemtime' => new_date($date_format, $file->getMTime()), 'desc' => $desc);
             }
         }
         //end while
         $d->close();
     }
     //end if
     return $file_arr;
 }
示例#7
0
 /**
  * {@inheritDoc}
  */
 protected function _infoCallback(&$cate_info)
 {
     $cate_info['add_time'] = new_date(sys_config('sys_timezone_datetime_format'), $cate_info['add_time']);
     $cate_info['cate_name'] = $this->_getCache($cate_info['cate_id'] . '.cate_name', 'Category');
 }
示例#8
0
 /**
  * 最新评论
  *
  * @author          mrmsl <*****@*****.**>
  * @date            2013-05-10 10:38:39
  *
  * @param array $info ssi信息
  *
  * @return void 无返回值
  */
 private function _ssi_new_comments($info)
 {
     $data = $this->_model->table(TB_COMMENTS)->where('status=' . COMMENT_STATUS_PASS)->order('comment_id DESC')->limit(10)->select();
     $selected = array(COMMENT_TYPE_BLOG => array(), COMMENT_TYPE_MINIBLOG => array());
     foreach ($data as $k => $v) {
         $type = $v['type'];
         $blog_id = $v['blog_id'];
         if (COMMENT_TYPE_BLOG == $type) {
             if (isset($selected[COMMENT_TYPE_BLOG][$blog_id])) {
                 $blog_info = $selected[COMMENT_TYPE_BLOG][$blog_id];
             } else {
                 $blog_info = $this->_model->table(TB_BLOG)->where('blog_id=' . $blog_id)->field('title,link_url')->find();
                 $selected[COMMENT_TYPE_BLOG][$blog_id] = $blog_info;
             }
             $data[$k]['title'] = $blog_info['title'];
             $data[$k]['link_url'] = $blog_info['link_url'];
         } elseif (COMMENT_TYPE_MINIBLOG == $type) {
             if (isset($selected[COMMENT_TYPE_MINIBLOG][$blog_id])) {
                 $blog_info = $selected[COMMENT_TYPE_MINIBLOG][$blog_id];
             } else {
                 $blog_info = $this->_model->table(TB_MINIBLOG)->where('blog_id=' . $v['blog_id'])->field('add_time,link_url')->find();
                 $selected[COMMENT_TYPE_MINIBLOG][$blog_id] = $blog_info;
             }
             $data[$k]['title'] = new_date('Y-m-d', $blog_info['add_time']) . ' ' . L('MINIBLOG');
             $data[$k]['link_url'] = $blog_info['link_url'];
         }
     }
     //end foreach
     $this->getViewTemplate('build_html')->assign('comments', $data);
     $this->_buildHtml(WWWROOT . $info['html_name'] . C('HTML_SUFFIX'), $this->_fetch($info['_controller'], $info['_action']));
 }
示例#9
0
 /**
  * {@inheritDoc}
  */
 protected function _infoCallback(&$admin_info)
 {
     unset($admin_info['password']);
     $admin_info['lock_start_time'] = $admin_info['lock_start_time'] ? new_date(sys_config('sys_timezone_datetime_format'), $admin_info['lock_start_time']) : '';
     $admin_info['lock_end_time'] = $admin_info['lock_end_time'] ? new_date(sys_config('sys_timezone_datetime_format'), $admin_info['lock_end_time']) : '';
 }
示例#10
0
 /**
  * 获取文件列表
  *
  * @author          mrmsl <*****@*****.**>
  * @date            2013-06-27 15:14:17
  *
  * @param string $node 节点路径
  *
  * @return array 文件列表
  */
 public function listAction()
 {
     $path = Filter::string('path', 'get');
     //路径
     if ($path) {
         $this->_denyDirectory($path);
         $path = trim($path, '/');
     } else {
         $path = new_date('Y/md/');
     }
     $log_path = LOG_PATH . $path;
     if (!is_dir($log_path)) {
         //路径不存在
         send_http_status(HTTP_STATUS_SERVER_ERROR);
         $this->_model->addLog(L('path') . LOG_PATH . $path . L('NOT_EXIST'), LOG_TYPE_INVALID_PARAM);
         $this->_ajaxReturn(false, L('path') . $path . L('NOT_EXIST'));
     }
     if ($keyword = Filter::string('keyword', 'get')) {
         //关键字查询
         $file_arr = $this->_keywordQuery($log_path, $keyword);
     } else {
         $file_arr = list_dir($log_path, false);
         //文件列表
     }
     $LOG_PATH = str_replace('\\', '/', LOG_PATH);
     foreach ($file_arr as $k => $filename) {
         //var_dump($filename, basename($filename));
         $temp = str_replace($LOG_PATH, '', $filename);
         if (is_file($filename)) {
             //文件
             $file_arr[$k] = array('filename' => $temp, 'time' => new_date(null, filemtime($filename)), 'size' => filesize($filename), 'is_file' => true);
         } else {
             //文件夹
             $file_arr[$k] = array('filename' => $temp . '/', 'time' => '--', 'size' => '--');
         }
     }
     usort($file_arr, array($this, '_cmp'));
     //按时间倒序
     $this->_ajaxReturn(true, '', $file_arr, count($file_arr));
 }
示例#11
0
/**
 * 自定义错误处理
 *
 * @author          mrmsl <*****@*****.**>
 * @date            2012-09-12 13:31:07
 * @lastmodify      2013-01-22 17:12:01 by mrmsl
 *
 * @param int    $errno   错误号
 * @param string $errstr  错误信息
 * @param string $errfile 错误文件
 * @param int    $errline 错误文件行号
 * @param mixed  $vars    用户变量。默认''
 *
 * @return void 无返回值
 */
function error_handler($errno, $errstr, $errfile, $errline, $vars = '')
{
    if (0 === error_reporting()) {
        //@抑制错误
        return false;
    }
    $log_filename = C('LOG_FILENAME');
    C('LOG_FILENAME', false);
    if ($log_level = C('LOG_LEVEL')) {
        //通过trigger_error触发
        C('LOG_LEVEL', false);
        if (strpos(sys_config('sys_log_level'), $log_level) === false) {
            return;
        }
        $errno = $log_level;
    }
    $quit_arr = array(E_ERROR => 'PHP Error', E_PARSE => 'PHP Parsing Error', E_CORE_ERROR => 'PHP Core Error', E_CORE_WARNING => 'PHP Core Warning', E_COMPILE_ERROR => 'PHP Compile Error', E_RECOVERABLE_ERROR => 'PHP Catchable Fatal Error', E_APP_EXCEPTION => 'PHP Uncaught Exception');
    $error_arr = $quit_arr + array(E_NOTICE => 'PHP Notice', E_WARNING => 'PHP Warning', E_COMPILE_WARNING => 'PHP Compile Warning', E_STRICT => 'PHP Strict standards', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_APP_DEBUG => 'User Debug', E_APP_INFO => 'User Info', E_APP_SQL => 'User SQL', E_APP_ROLLBACK_SQL => 'User ROLLBACK SQL');
    defined('E_USER_DEPRECATED') ? $error_arr[E_USER_DEPRECATED] = 'PHP E_USER_DEPRECATED' : '';
    defined('E_DEPRECATED') ? $error_arr[E_DEPRECATED] = 'PHP E_DEPRECATED' : '';
    $user_errors = array(E_USER_WARNING, E_USER_NOTICE, E_USER_ERROR);
    list($usec, $sec) = explode(' ', microtime());
    $error = '[' . new_date(null, time(false)) . substr($usec, 1, 5) . '] [Client: ' . get_client_ip() . ']' . ' ';
    $error .= defined('REQUEST_METHOD') ? REQUEST_METHOD : $_SERVER['REQUEST_METHOD'];
    $error .= ' ';
    $error .= defined('REQUEST_URI') ? REQUEST_URI : (empty($_SERVER['REQUEST_URI']) ? '' : urldecode($_SERVER['REQUEST_URI']));
    if (isset($quit_arr[$errno]) || E_USER_ERROR == $errno) {
        //错误,记录来源
        if ($referer = defined('REFERER_PAGER') ? REFERER_PAGER : (empty($_SERVER['HTTP_REFERER']) ? '' : HTTP_REFERER)) {
            $error .= '(' . $referer . ')';
        }
    }
    $error .= PHP_EOL;
    $error .= "in {$errfile} on line {$errline}" . PHP_EOL;
    $error .= "{$error_arr[$errno]}[{$errno}]: ";
    $error .= $errstr . PHP_EOL;
    //if (in_array($errno, $user_errors)) {
    //$error .= PHP_EOL . var_export($vars, true);
    //}
    Logger::record($error, $log_filename);
    if (isset($quit_arr[$errno])) {
        Logger::save();
        $trace = $vars && is_string($vars) && 0 === strpos($vars, '__') ? substr($vars, 2) : '';
        halt($errstr, $errfile, $errline, $trace);
    }
}
示例#12
0
 /**
  * 写日志
  *
  * @author          liu21st <*****@*****.**>
  * @lastmodify      2013-01-17 09:26:44 by mrmsl
  *
  * @param string $message       日志信息。默认'',取已保存日志
  * @param string $destination   写入目标。默认'',日志路径+Y/md/+文件名
  * @param int    $type          日志记录方式。默认'',取C('LOG_TYPE')
  * @param string $extra         额外信息。默认''
  *
  * @return void 无返回值
  */
 public static function write($message = '', $destination = '', $type = '', $extra = '')
 {
     $log = $message ? $message : join(PHP_EOL, self::$log);
     if (!$log) {
         return;
     }
     $log .= PHP_EOL;
     $now = new_date(self::$date_format);
     $type = $type ? $type : C('LOG_TYPE');
     if (!$type || self::FILE == $type) {
         //文件方式记录日志
         if (defined('TODAY_LOG_PATH')) {
             $log_path = TODAY_LOG_PATH;
         } else {
             new_mkdir($log_path = LOG_PATH . new_date('Y/md/'));
             define('TODAY_LOG_PATH', $log_path);
         }
         if ('' === $destination) {
             $filename = 'php' . C('LOG_FILE_SUFFIX');
         } elseif ($destination) {
             if (false === strpos($destination, C('LOG_FILE_SUFFIX'))) {
                 //sql.log, slowquery.log, errorsql.log...
                 $filename = $destination . C('LOG_FILE_SUFFIX');
             }
         }
         $destination = empty($filename) ? $destination : $log_path . $filename;
         //检测日志文件大小,超过配置大小则备份日志文件重新生成
         if (is_file($destination) && ($filesize = sys_config('sys_log_filesize')) && $filesize * 1024 <= filesize($destination)) {
             rename($destination, $log_path . basename($filename, C('LOG_FILE_SUFFIX')) . new_date('_His') . C('LOG_FILE_SUFFIX'));
         }
     } else {
         $destination = $destination ? $destination : C('LOG_DEST');
         $extra = $extra ? $extra : C('LOG_EXTRA');
     }
     if (APP_DEBUG && strpos($log, 'PHP ')) {
         //调试模式,输出php错误
         send_http_status(HTTP_STATUS_SERVER_ERROR);
         if (!IS_AJAX) {
             echo nl2br($log);
         }
     }
     error_log($log, $type, $destination, $extra);
 }
示例#13
0
 /**
  * 比较两个数据之间的差异,适用于修改数据时,记录变化
  *
  * @param array  $old_data 老数据
  * @param array  $new_data 新数据。默认array()
  * @param string $key      比较字段。默认''
  *
  * @return string 差异
  */
 protected function _dataDiff($old_data, $new_data = array(), $key = '')
 {
     $diff = empty($new_data) ? $old_data : array_udiff_uassoc($old_data, $new_data, create_function('$a, $b', 'return $a == $b ? 0 : 1;'), create_function('$a, $b', 'return $a === $b ? 0 : 1;'));
     $key = $key ? explode(',', $key) : array_keys($diff);
     foreach ($old_data as $k => $v) {
         if (in_array($k, $key) && isset($diff[$k])) {
             if (in_array($k, array('lock_start_time', 'lock_end_time'))) {
                 //时间戳转化为时间格式 by mrmsl on 2012-09-11 08:30:02
                 $diff[$k] = empty($diff[$k]) ? '' : new_date(null, $diff[$k]);
                 $diff[$k] .= '[to]' . (empty($new_data[$k]) ? 'NULL' : new_date(null, $new_data[$k]));
             } else {
                 $diff[$k] .= '[to]' . (isset($new_data[$k]) ? $k == 'password' ? '******' : $new_data[$k] : 'NULL');
             }
         } else {
             unset($diff[$k]);
         }
     }
     return $diff ? preg_replace('/ +/', ' ', stripslashes(str_replace(PHP_EOL, '', var_export($diff, true)))) : '';
 }
示例#14
0
 /**
  * {@inheritDoc}
  */
 protected function _infoCallback(&$cate_info)
 {
     $cate_info['add_time'] = new_date(sys_config('sys_timezone_datetime_format'), $cate_info['add_time']);
 }
示例#15
0
 /**
  * 生成系统常量
  *
  * @author          mrmsl <*****@*****.**>
  * @date            2013-05-03 15:15:19
  *
  * @param array $sys_config 系统信息。默认array(),取sys_config()
  *
  * @return void 无返回值
  */
 public function publicDefineSystemConstantsAction($sys_config = array())
 {
     $filename = INCLUDE_PATH . 'app_config.tpl.php';
     //常量模板
     $tpl = file_get_contents($filename);
     $sys_config = $sys_config ? $sys_config : sys_config();
     $content = preg_replace("#sys_config\\('(\\w+)'\\)#e", '"\'" . addslashes($sys_config["\\1"]) . "\'"', $tpl);
     $find = array('@@lastmodify', '@WEB_COOKIE_DOMAIN', '@WEB_SESSION_COOKIE_DOMAIN', '@WEB_ADMIN_ENTRY', '@AUTO_CREATE_COMMENT');
     $replace = array(new_date(), '@domain' == ($cookie_domain = $sys_config['sys_cookie_domain']) ? 'WEB_DOMAIN_SCOPE' : "'{$cookie_domain}'", '@domain' == ($session_cookie_domain = $sys_config['sys_session_cookie_domain']) ? 'WEB_DOMAIN_SCOPE' : "'{$session_cookie_domain}'", 0 === strpos('http://', $v = $sys_config['sys_base_admin_entry']) ? "'{$v}'" : "BASE_SITE_URL . '{$v}'", '后台自动生成,请毋修改。最后更新时间: ' . new_date());
     $content = str_replace($find, $replace, $content);
     file_put_contents(INCLUDE_PATH . 'app_config.php', $content);
     //写文件
     if (!APP_DEBUG && is_file(RUNTIME_FILE)) {
         //constants.php已经包含进运行时文件。干掉
         unlink(RUNTIME_FILE);
     }
 }
示例#16
0
 /**
  * 重命名
  *
  * @return string 新文件名
  */
 private function _resetName()
 {
     $rename_rule = $this->_rename_rule;
     if (-1 === $rename_rule) {
         //保持文件名不变
         return $this->_uploaded_file['name'];
     } elseif (0 === $rename_rule) {
         //以时间戳+4位随机数
         $filename = function_exists('new_date') ? new_date('YmdHis') : new_date('YmdHis') . mt_rand(1000, 9999);
     } else {
         $filename = basename($this->_uploaded_file['name'], '.' . $this->_uploaded_file['extension']);
         $filename = $rename_rule($filename);
     }
     return $filename . '.' . $this->_uploaded_file['extension'];
 }
示例#17
0
 /**
  * 管理员列表
  *
  * @author          mrmsl <*****@*****.**>
  * @date            2012-12-26 14:22:09
  * @lastmodify      2013-03-31 19:03:13 by mrmsl
  *
  * @return void 无返回值
  */
 public function listAction()
 {
     $db_fields = $this->_getDbFields();
     //表字段
     $sort = Filter::string('sort', 'get', $this->_pk_field);
     //排序字段
     $sort = in_array($sort, $db_fields) ? $sort : $this->_pk_field;
     $sort = 'c.' . $sort;
     $order = empty($_GET['dir']) ? Filter::string('order', 'get') : Filter::string('dir', 'get');
     //排序
     $order = toggle_order($order);
     $keyword = Filter::string('keyword', 'get');
     //关键字
     $date_start = Filter::string('date_start', 'get');
     //添加开始时间
     $date_end = Filter::string('date_end', 'get');
     //添加结束时间
     $column = Filter::string('column', 'get');
     //搜索字段
     $type = Filter::int('type', 'get');
     //类型
     $status = Filter::int('auditing', 'get');
     //状态
     $reply_type = Filter::int('admin_reply_type', 'get');
     //回复状态
     $where = array();
     $column_arr = array('username' => 'c.username', 'email' => 'c.email', 'content' => 'c.content', 'blog_id' => 'c.blog_id', 'miniblog_id' => 'c.blog_id', 'blog_content' => 'b.content', 'blog_title' => 'b.title');
     if ($keyword !== '' && isset($column_arr[$column])) {
         $where[$column_arr[$column]] = $this->_buildMatchQuery($column_arr[$column], $keyword, Filter::string('match_mode', 'get'));
         if ('blog_content' == $column || 'blog_title' == $column) {
             $table = ' JOIN ' . TB_BLOG . ' AS b ON b.blog_id=c.blog_id';
         }
     }
     if ($date_start && ($date_start = strtotime($date_start))) {
         $where['c.add_time'][] = array('EGT', $date_start);
     }
     if ($date_end && ($date_end = strtotime($date_end))) {
         $where['c.add_time'][] = array('ELT', $date_end);
     }
     if (isset($where['c.add_time']) && count($where['c.add_time']) == 1) {
         $where['c.add_time'] = $where['c.add_time'][0];
     }
     if (-1 != $type) {
         //类型
         $where['c.type'] = $type;
     }
     if (-1 != $status) {
         //状态
         $where['c.status'] = $status;
     }
     if (-1 != $reply_type) {
         //回复状态
         $where['c.admin_reply_type'] = $reply_type;
     }
     isset($table) && $this->_model->join($table);
     $total = $this->_model->alias('c')->where($where)->count('c.blog_id');
     if ($total === false) {
         //查询出错
         $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME') . L('TOTAL_NUM,ERROR'));
     } elseif ($total == 0) {
         //无记录
         $this->_ajaxReturn(true, '', null, $total);
     }
     $page_info = Filter::page($total);
     isset($table) && $this->_model->join($table);
     $data = $this->_model->alias('c')->field('c.*,INET_NTOA(user_ip) AS user_ip')->where($where)->limit($page_info['limit'])->order('' . $sort . ' ' . $order)->select();
     $data === false && $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME') . L('LIST,ERROR'));
     //出错
     $selected = array(COMMENT_TYPE_BLOG => array(), COMMENT_TYPE_MINIBLOG => array());
     foreach ($data as $k => $v) {
         $type = $v['type'];
         $blog_id = $v['blog_id'];
         if (COMMENT_TYPE_BLOG == $type) {
             if (isset($selected[COMMENT_TYPE_BLOG][$blog_id])) {
                 $info = $selected[COMMENT_TYPE_BLOG][$blog_id];
             } else {
                 $info = $this->_model->table(TB_BLOG)->where('blog_id=' . $blog_id)->field('title,link_url')->find();
                 $selected[COMMENT_TYPE_BLOG][$blog_id] = $info;
             }
             $data[$k]['title'] = $info['title'];
             $data[$k]['link_url'] = $info['link_url'];
         } elseif (COMMENT_TYPE_MINIBLOG == $type) {
             if (isset($selected[COMMENT_TYPE_MINIBLOG][$blog_id])) {
                 $info = $selected[COMMENT_TYPE_MINIBLOG][$blog_id];
             } else {
                 $info = $this->_model->table(TB_MINIBLOG)->where('blog_id=' . $v['blog_id'])->field('add_time,link_url')->find();
                 $selected[COMMENT_TYPE_MINIBLOG][$blog_id] = $info;
             }
             $data[$k]['title'] = new_date('Y-m-d', $info['add_time']) . ' ' . L('MINIBLOG');
             $data[$k]['link_url'] = $info['link_url'];
         }
     }
     //end foreach
     $this->_ajaxReturn(true, '', $data, $total);
 }