Beispiel #1
0
 /**
  * 入口函数(继承)
  */
 public static function main($framework_enable = null, $framework_require = null, $framework_module = null, $framework_action = null, $framework_parameter = null)
 {
     // 防止运行多次
     static $static_repeat = false;
     if ($static_repeat) {
         return parent::main(false);
     }
     $static_repeat = true;
     define('IN_WAP', check_wap());
     // 载入配置参数
     list($front_action, $front_online) = self::init(array('front_action', 'front_online'));
     list($front_action2, $front_online2) = parent::init(array('front_action', 'front_online'));
     $front_action === '' and $front_action = $front_action2;
     $front_action === '' and $front_action = parent::init('framework_action');
     $front_online === '' and $front_online = $front_online2;
     // 执行前端模块
     $online = parent::main('final,return', null, __CLASS__, $front_action);
     // 执行后续模块
     if ($online) {
         // 视图全局变量
         if ($front_online) {
             front::view2(array($front_online => $online, 'get' => $_GET));
         }
         return parent::main($framework_enable, $framework_require, $framework_module, $framework_action, $framework_parameter);
     } else {
         return false;
     }
 }
Beispiel #2
0
 /**
  * 应用程序初始化
  * @access public
  * @return void
  */
 public static function init()
 {
     // 页面压缩输出支持
     if (C('OUTPUT_ENCODE')) {
         $zlib = ini_get('zlib.output_compression');
         if (empty($zlib)) {
             ob_start('ob_gzhandler');
         }
     }
     // 设置系统时区
     date_default_timezone_set(C('DEFAULT_TIMEZONE'));
     // 加载动态项目公共文件和配置
     load_ext_file();
     // URL调度
     Dispatcher::dispatch();
     // 定义当前请求的系统常量
     define('NOW_TIME', $_SERVER['REQUEST_TIME']);
     define('REQUEST_METHOD', $_SERVER['REQUEST_METHOD']);
     define('IS_GET', REQUEST_METHOD == 'GET' ? true : false);
     define('IS_POST', REQUEST_METHOD == 'POST' ? true : false);
     define('IS_PUT', REQUEST_METHOD == 'PUT' ? true : false);
     define('IS_DELETE', REQUEST_METHOD == 'DELETE' ? true : false);
     define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' || !empty($_POST[C('VAR_AJAX_SUBMIT')]) || !empty($_GET[C('VAR_AJAX_SUBMIT')]) ? true : false);
     // URL调度结束标签
     tag('url_dispatch');
     // 系统变量安全过滤
     if (C('VAR_FILTERS')) {
         $filters = explode(',', C('VAR_FILTERS'));
         foreach ($filters as $filter) {
             // 全局参数过滤
             array_walk_recursive($_POST, $filter);
             array_walk_recursive($_GET, $filter);
         }
     }
     if (C('REQUEST_VARS_FILTER')) {
         // 全局安全过滤
         array_walk_recursive($_GET, 'think_filter');
         array_walk_recursive($_POST, 'think_filter');
         array_walk_recursive($_REQUEST, 'think_filter');
     }
     if (cookie('think_template') == '' && check_wap()) {
         cookie('think_template', 'w3g');
     }
     C('LOG_PATH', realpath(LOG_PATH) . '/');
     //动态配置 TMPL_EXCEPTION_FILE,改为绝对地址
     C('TMPL_EXCEPTION_FILE', realpath(C('TMPL_EXCEPTION_FILE')));
     return;
 }
 protected function _initialize()
 {
     parent::_initialize();
     /*加入用户模块时打开*/
     define('UID', is_login());
     D('Content')->publishDueContents();
     //定时发布
     $wap = check_wap();
     //访问首页的时候如果是手机用户访问跳转到mobile显示
     if ($wap && C('OPEN_WAP_TPL')) {
         $this->iswap = true;
         layout('layout_wap');
     } else {
         $this->iswap = false;
     }
     $this->login_user = session('user_auth');
     // set visit
     $visit = array('ip' => get_remote_ip(), 'http_user_agent' => htmlspecialchars($_SERVER['HTTP_USER_AGENT']), 'http_referer' => htmlspecialchars($_SERVER['HTTP_REFERER']), 'uri' => htmlspecialchars($_SERVER['REQUEST_URI']), 'module' => strtolower(CONTROLLER_NAME), 'module_id' => I('id'), 'request' => serialize($_REQUEST), 'first_get' => array_shift(I('get.')));
     D("Visit")->add($visit);
 }
Beispiel #4
0
<?php

/**
 * 入口文件 	参考 block,参考老师
 * 
 */
include 'config';
//加载配置文件
require PATH_COMMON . "functions";
//加载方法库
require PATH_MVC_C . "_Main" . CONTROL_INC;
//加载 control 基础类
require PATH_MVC_M . "_Model" . MODEL_M;
//加载 model 基础类
if (check_wap()) {
    //wap访问,	抄的block,没搞明白,先跳过
    echo "wap访问";
} else {
    //等待优化
    //$get_path	= str_replace('/', '', $get_path);
    preg_match_all("/\\/(\\w*)/", $_SERVER["REQUEST_URI"], $get_path);
    //print_r($get_path);
    if (file_exists(PATH_MVC_V . PATH_CURRENT_VIEW . $get_path[1][0] . WAP_VIEW_HTML)) {
        include PATH_MVC_V . PATH_CURRENT_VIEW . $get_path[1][0] . WAP_VIEW_HTML;
    } else {
        $get_control = !empty(trim($get_path[1][0])) ? trim($get_path[1][0]) : "index";
        $get_action = !empty(trim($get_path[1][1])) ? trim($get_path[1][1]) : "init";
        //echo PATH_MVC_C.$get_control;
        if (file_exists(PATH_MVC_C . $get_control . CONTROL_INC)) {
            require PATH_MVC_C . $get_control . CONTROL_INC;
            $class_name = $get_control . CLASS_SERVICE;
 function tougao()
 {
     self::is_login();
     if ($_POST) {
         if (empty($_POST['verify']) && !check_wap()) {
             $this->error('验证码必须!');
         }
         if (md5($_POST['verify']) != $_SESSION['verify'] && !check_wap()) {
             $this->error('验证码错误!');
         }
         $data = array_map('strval', $_POST);
         $data = array_map('remove_xss', $data);
         //过滤下标题
         $data['title'] = htmlspecialchars($_POST['title']);
         $data['content'] = htmlspecialchars($_POST['content']);
         $data['status'] = 0;
         $data['dami_uid'] = $_SESSION['dami_uid'];
         $arc = M('article');
         if (C('TOKEN_ON') && !$arc->autoCheckToken($_POST)) {
             $this->error(L('_TOKEN_ERROR_'));
         }
         //防止乱提交表单
         $arc->add($data);
         $this->success('发布成功请等待管理员审核~');
     } else {
         self::pub_class();
         $this->display();
     }
 }
 public function index()
 {
     inject_check($_GET['typeid']);
     inject_check($_GET['p']);
     //读取数据库&判断
     $typeid = (int) $_GET['typeid'];
     $list_model = 'list/list_default.html';
     $type = M('type');
     $list = $type->where('typeid=' . intval($_GET['typeid']))->find();
     if (!$list) {
         $this->error('栏目不存在!');
     } else {
         //当前选中菜单
         $pid = get_first_father($list['typeid']);
         $cur_menu = get_field('type', 'typeid=' . $pid, 'drank');
         $this->assign('cur_menu', $cur_menu);
         if ($list['list_path'] != '' && file_exists(TMPL_PATH . cookie('think_template') . '/' . $list['list_path'])) {
             $list_model = $list['list_path'];
         }
     }
     ob_start();
     //用于生成静态HTML
     $is_build = C('IS_BUILD_HTML');
     //允许参数
     $allow_param = array('p', 'author_id');
     $static_file = './Html/' . cookie('think_template') . '/lists/' . $typeid;
     $mid_str = '';
     if (count($_REQUEST) > 1) {
         foreach ($_REQUEST as $k => $v) {
             if ($k != 'typeid' && in_array($k, $allow_param)) {
                 $mid_str .= '/' . $k . '/' . md5($v);
             }
         }
     }
     $static_file .= $mid_str . '.html';
     $path = './ListAction.class.php';
     $php_file = basename($path);
     parent::html_init($static_file, $php_file, $is_build);
     //以下是动态代码
     //家族树与子孙树
     parent::tree_dir($typeid, 'tree_list');
     parent::children_dir($typeid, 'child_list');
     //栏目基本信息封装
     $this->assign('title', $list['typename']);
     $this->assign('type', $list);
     //栏目导航
     $config = F('basic', '', './Web/Conf/');
     if ($config['listshowmode'] == 1) {
         $map['fid'] = $list['fid'];
     } else {
         $map['fid'] = intval($_GET['typeid']);
     }
     $map['islink'] = 0;
     $nav = $type->where($map)->field('typeid,typename')->select();
     $this->assign('dh', $nav);
     //第一次释放内存
     $pernum = isset($list['pernum']) && intval($list['pernum']) > 0 ? intval($list['pernum']) : $config['artlistnum'];
     unset($list, $nav, $map);
     $list_server = M('admin')->where('is_client=1')->select();
     $this->assign('list_server', $list_server);
     $vip_sn = M('vip_mess')->order('id desc')->getField('vip_sn');
     $this->assign('vip_sn', $vip_sn);
     //网站头部与友情链接
     R('Public/head');
     R('Public/py_link');
     //查询数据库和缓存
     $article = D('ArticleView');
     //封装条件
     $map['status'] = 1;
     //导入分页类
     import('ORG.Util.Page');
     //准备工作
     $arr = get_children($typeid);
     $map['article.typeid'] = array('in', $arr);
     //用户阅读权限
     if ($config['isread'] == 1) {
         $map['_string'] = 'article.typeid in(' . $_SESSION['dami_uservail'] . ')';
     }
     //分页处理
     $count = $article->where($map)->count();
     $p = new Page($count, $pernum);
     $p->setConfig('prev', '上一页');
     $p->setConfig('header', '篇文章');
     $p->setConfig('first', '首 页');
     $p->setConfig('last', '末 页');
     $p->setConfig('next', '下一页');
     if (check_wap()) {
         $temp_str = "%first%%upPage%%downPage%%end%";
     } else {
         $temp_str = "%first%%upPage%%prePage%%linkPage%%nextPage%%downPage%%end%\n\t\t<select name='select' onChange='javascript:window.location.href=(this.options[this.selectedIndex].value);'>%allPage%</select>共<font color='#CD4F07'><b>%totalRow%</b></font>篇 " . $config['artlistnum'] . "篇/每页";
     }
     $p->setConfig('theme', $temp_str);
     //数据查询
     $alist = $article->where($map)->order('istop desc,addtime desc')->limit($p->firstRow . ',' . $p->listRows)->select();
     //echo $article->getLastSql();
     //封装变量
     $this->assign('page', $p->show());
     $this->assign('list', $alist);
     //释放内存
     unset($article, $type, $p, $tlist, $alist);
     //模板输出
     $this->display(TMPL_PATH . cookie('think_template') . '/' . $list_model);
     if ($is_build == 1) {
         $c = ob_get_contents();
         if (!file_exists(dirname($static_file))) {
             @mk_dir(dirname($static_file));
         }
         file_put_contents($static_file, $c);
     }
 }