public function index()
 {
     if (sp_is_mobile()) {
         $this->assign("m_banner_coco", $this->_getAd("m_banner_coco"));
     }
     //dump($_SESSION['user']);
     $category = $this->model_cat->where("recommended = 1")->find();
     if (empty($category)) {
         $this->error("活动尚未开始,敬请期待");
     }
     $this->assign('category', $category);
     $info = $this->model_coco->where("cid={$category['id']} and recommended=1")->order('post_like desc')->select();
     $count = ceil(count($info) / 2);
     $this->assign('count', $count);
     $this->assign('info', $info);
     //倒计时天数
     $end_time = $category['end_time'];
     $now_time = time();
     $day = floor(($end_time - $now_time) / 3600 / 24);
     $url = $this->_getUri();
     $this->assign('url', $url);
     $this->assign('day', $day);
     $this->assign("model_table", "Enroll");
     $this->display();
 }
 function info()
 {
     $id = I("get.id", 0, 'intval');
     if (empty($id)) {
         $where = "status = 1";
     } else {
         $where = "id={$id} and status=1";
     }
     $type = $this->model->where($where)->getField("cid");
     $smeta = $this->model->where($where)->getField("smeta");
     $title = $this->model->where($where)->getField('post_title');
     $this->assign('title', $title);
     $smeta = json_decode($smeta, true);
     $photo = $smeta['photo'];
     $display = '';
     if (sp_is_mobile()) {
         $this->assign("photo", $photo);
         $this->display("single1");
     } else {
         if ($type == 1) {
             $this->assign("home_head", $this->_getAd("banner_single"));
             $this->assign("photo", $photo);
             $display = "single2";
         } elseif ($type == 2) {
             $newPhoto = array();
             foreach ($photo as $item) {
                 array_push($newPhoto, "'" . __ROOT__ . "/{$item['url']}'");
             }
             $photoStr = join(",", $newPhoto);
             $this->assign("photo", $photoStr);
             $display = "single1";
         } elseif ($type == 3) {
             $this->assign("photo", $photo);
             $display = "single3";
         } elseif ($type == 4) {
             $this->assign("photo", $photo);
             $display = "single4";
         } else {
             $this->error("文章出错");
         }
         $this->assign("desc_beautiful", $this->_getAd("desc_beautiful"));
         //3个摆放在一起的二级页面广告位
         $this->assign("second_page_3", $this->_getAd("second_page_3"));
         //服务承诺
         $this->assign("servePromise", $this->_getAd("servePromise"));
         $this->display($display);
     }
 }
 /**
  * 首页
  */
 public function index()
 {
     if (sp_is_mobile()) {
         header("location:" . U("Dress/lists"));
         exit;
     }
     //banner
     $this->assign("home_head", $this->_getAd("banner_dress"));
     //最新广告推荐
     $this->assign('Ad_five', $this->_getAd("dress_index"));
     //首页中部广告
     $this->assign("home_mid_pic", $this->_getAd("home_mid_pic"));
     //绝美礼服
     $beauty = $this->getRecommended('Dress', false, array(), array('category=2'), 20);
     $this->assign("beauty", $beauty);
     //最新婚纱定制
     $dress = $this->getRecommended('Dress', false, array(), array('category=1'), 20);
     $this->assign("dress", $dress);
     //广告位显示
     $this->assign("promise", $this->_getAd("promise"));
     $this->assign("servePromise", $this->_getAd("servePromise"));
     $this->display('/Dress/index');
 }
 /**
  * 自动定位模板文件
  * @access protected
  * @param string $template 模板文件规则
  * @return string
  */
 public function parseTemplate($template = '')
 {
     $tmpl_path = C("SP_TMPL_PATH");
     // 获取当前主题名称
     $theme = C('SP_DEFAULT_THEME');
     if (C('TMPL_DETECT_THEME')) {
         // 自动侦测模板主题
         $t = C('VAR_TEMPLATE');
         if (isset($_GET[$t])) {
             $theme = $_GET[$t];
         } elseif (cookie('think_template')) {
             $theme = cookie('think_template');
         }
         if (!file_exists($tmpl_path . "/" . $theme)) {
             $theme = C('SP_DEFAULT_THEME');
         }
         cookie('think_template', $theme, 864000);
     }
     if (C('MOBILE_TPL_ENABLED')) {
         //开启手机模板支持
         if (sp_is_mobile()) {
             if (file_exists($tmpl_path . "/" . $theme . "_mobile")) {
                 $theme = $theme . "_mobile";
             }
         }
     }
     C('SP_DEFAULT_THEME', $theme);
     // 获取当前主题的模版路径
     define('THEME_PATH', $tmpl_path . $theme . "/");
     C("TMPL_PARSE_STRING.__TMPL__", __ROOT__ . "/" . THEME_PATH);
     C('SP_VIEW_PATH', $tmpl_path);
     C('DEFAULT_THEME', $theme);
     if (is_file($template)) {
         return $template;
     }
     $depr = C('TMPL_FILE_DEPR');
     $template = str_replace(':', $depr, $template);
     // 获取当前模块
     $module = MODULE_NAME;
     if (strpos($template, '@')) {
         // 跨模块调用模版文件
         list($module, $template) = explode('@', $template);
     }
     // 分析模板文件规则
     if ('' == $template) {
         // 如果模板文件名为空 按照默认规则定位
         $template = "/" . CONTROLLER_NAME . $depr . ACTION_NAME;
     } elseif (false === strpos($template, '/')) {
         $template = "/" . CONTROLLER_NAME . $depr . $template;
     }
     $file = THEME_PATH . $module . $template . C('TMPL_TEMPLATE_SUFFIX');
     if (!is_file($file)) {
         E(L('_TEMPLATE_NOT_EXIST_') . ':' . $file);
     }
     return $file;
 }
 private static function requireHtmlCache()
 {
     // 分析当前的静态规则
     $htmls = C('HTML_CACHE_RULES');
     // 读取静态规则
     if (!empty($htmls)) {
         $htmls = array_change_key_case($htmls);
         // 静态规则文件定义格式 actionName=>array('静态规则','缓存时间','附加规则')
         // 'read'=>array('{id},{name}',60,'md5') 必须保证静态规则的唯一性 和 可判断性
         // 检测静态规则
         $controllerName = strtolower(CONTROLLER_NAME);
         $actionName = strtolower(ACTION_NAME);
         if (isset($htmls[$controllerName . ':' . $actionName])) {
             $html = $htmls[$controllerName . ':' . $actionName];
             // 某个控制器的操作的静态规则
         } elseif (isset($htmls[$controllerName . ':'])) {
             // 某个控制器的静态规则
             $html = $htmls[$controllerName . ':'];
         } elseif (isset($htmls[$actionName])) {
             $html = $htmls[$actionName];
             // 所有操作的静态规则
         } elseif (isset($htmls['*'])) {
             $html = $htmls['*'];
             // 全局静态规则
         }
         if (!empty($html)) {
             // 解读静态规则
             $rule = is_array($html) ? $html[0] : $html;
             // 以$_开头的系统变量
             $callback = function ($match) {
                 switch ($match[1]) {
                     case '_GET':
                         $var = $_GET[$match[2]];
                         break;
                     case '_POST':
                         $var = $_POST[$match[2]];
                         break;
                     case '_REQUEST':
                         $var = $_REQUEST[$match[2]];
                         break;
                     case '_SERVER':
                         $var = $_SERVER[$match[2]];
                         break;
                     case '_SESSION':
                         $var = $_SESSION[$match[2]];
                         break;
                     case '_COOKIE':
                         $var = $_COOKIE[$match[2]];
                         break;
                 }
                 return count($match) == 4 ? $match[3]($var) : $var;
             };
             $rule = preg_replace_callback('/{\\$(_\\w+)\\.(\\w+)(?:\\|(\\w+))?}/', $callback, $rule);
             // {ID|FUN} GET变量的简写
             $rule = preg_replace_callback('/{(\\w+)\\|(\\w+)}/', function ($match) {
                 return $match[2]($_GET[$match[1]]);
             }, $rule);
             $rule = preg_replace_callback('/{(\\w+)}/', function ($match) {
                 return $_GET[$match[1]];
             }, $rule);
             // 特殊系统变量
             $rule = str_ireplace(array('{:controller}', '{:action}', '{:module}'), array(CONTROLLER_NAME, ACTION_NAME, MODULE_NAME), $rule);
             // {|FUN} 单独使用函数
             $rule = preg_replace_callback('/{|(\\w+)}/', function ($match) {
                 return $match[1]();
             }, $rule);
             $cacheTime = C('HTML_CACHE_TIME', null, 60);
             if (is_array($html)) {
                 if (!empty($html[2])) {
                     $rule = $html[2]($rule);
                 }
                 // 应用附加函数
                 $cacheTime = isset($html[1]) ? $html[1] : $cacheTime;
                 // 缓存有效期
             } else {
                 $cacheTime = $cacheTime;
             }
             $rule = C('MOBILE_TPL_ENABLED') && sp_is_mobile() ? $rule . "_mobile" : $rule;
             //修复手机模板开启时,只生成一个缓存
             // 当前缓存文件
             define('HTML_FILE_NAME', HTML_PATH . $rule . C('HTML_FILE_SUFFIX', null, '.html'));
             return $cacheTime;
         }
     }
     // 无需缓存
     return false;
 }
 /**
  * 设置错误,成功跳转界面
  */
 private function set_action_success_error_tpl()
 {
     $theme = C('SP_DEFAULT_THEME');
     if (C('TMPL_DETECT_THEME')) {
         // 自动侦测模板主题
         if (cookie('think_template')) {
             $theme = cookie('think_template');
         }
     }
     //by ayumi手机提示模板
     $tpl_path = '';
     if (C('MOBILE_TPL_ENABLED')) {
         //开启手机模板支持
         if (sp_is_mobile()) {
             if (file_exists(C("SP_TMPL_PATH") . "/" . $theme . "_mobile")) {
                 $theme = $theme . "_mobile";
                 $tpl_path = C("SP_TMPL_PATH") . $theme . "/";
             }
         }
     } else {
         $tpl_path = C("SP_TMPL_PATH") . $theme . "/";
     }
     //by ayumi手机提示模板
     $defaultjump = THINK_PATH . 'Tpl/dispatch_jump.tpl';
     $action_success = sp_add_template_file_suffix($tpl_path . C("SP_TMPL_ACTION_SUCCESS"));
     $action_error = sp_add_template_file_suffix($tpl_path . C("SP_TMPL_ACTION_ERROR"));
     if (file_exists_case($action_success)) {
         C("TMPL_ACTION_SUCCESS", $action_success);
     } else {
         C("TMPL_ACTION_SUCCESS", $defaultjump);
     }
     if (file_exists_case($action_error)) {
         C("TMPL_ACTION_ERROR", $action_error);
     } else {
         C("TMPL_ACTION_ERROR", $defaultjump);
     }
 }
 public function index()
 {
     try {
         if (sp_is_mobile()) {
             //首页头部轮播
             $this->assign("m_home_head", $this->_getAd("m_home_head"));
             //中部广告
             $this->assign("m_home_middle", $this->_getAd("m_home_middle"));
             //外景作品
             $outer = $this->getHomeContent("Photo", true, array(), 10, array("cid=3"));
             $this->assign("outer", $outer);
             //内景作品
             $inner = $this->getHomeContent("Photo", true, array(), 10, array("cid=1"));
             $this->assign("inner", $inner);
             //客照
             $this->assign("pcustom", $this->getHomeContent("Pcustom", true, array(), 10));
         } else {
             //首页头部轮播
             $this->assign("home_head", $this->_getAd("home_head"));
             //首页中部轮播
             $this->assign("home_middle", $this->_getAd("home_middle"));
             //首页中部广告
             $this->assign("home_mid_pic", $this->_getAd("home_mid_pic"));
             //最新活动
             $active = $this->_getAd("home_active");
             //$active = $this->getHomeContent("Active",false,array(),5);
             $this->assign("active", $active);
             //作品
             $ptheme = $this->getHomeContent("Photo", true);
             $this->assign("photo", $ptheme);
             //团购套系
             $group = $this->getHomeContent("Group", true, array("post_price", "post_num"));
             $this->assign("group", $group);
             //客照
             $this->assign("pcustom", $this->getHomeContent("Pcustom", true));
             //婚纱礼服
             $this->assign("dress", $this->getHomeContent("Dress", false, array("rent", "sale_price")));
             //好评
             $this->assign("good", $this->getHomeContent("Good", false, array("head_img", "post_excerpt"), 30));
             //婚嫁常识
             $article_cat = D("ArticleCat");
             $model_article = D("Article");
             $articleCat = $article_cat->select();
             $articleC = $article_cat->limit(0, 5)->select();
             $list = $this->getHomeContent("Article", false, array("post_excerpt", "post_date", "cid"), 6);
             $articles = array();
             foreach ($articleC as $item) {
                 $item['article'] = $model_article->field("id,post_title,post_pic,post_excerpt,post_date")->where("cid = " . $item['id'] . " and status=1")->order("listorder")->limit(0, 6)->select();
                 array_push($articles, $item);
             }
             $this->assign("articleCat", $articleCat);
             //分类
             $this->assign("articles", $articles);
             $this->assign('index', 'index');
             //广告位
             $this->assign("promise", $this->_getAd("promise"));
             $this->assign("servePromise", $this->_getAd("servePromise"));
         }
         // 			dump($this->_getAd("home_head"));exit;
     } catch (\Exception $e) {
         $this->error($e->getMessage());
     }
     $this->display("index");
 }