Beispiel #1
0
 public function topic_info_action()
 {
     $topic_info = $this->model('topic')->get_topic_by_id($_GET['topic_id']);
     $topic_info['type'] = 'topic';
     $topic_info['topic_title'] = H::sensitive_words($topic_info['topic_title']);
     $topic_info['topic_description'] = strip_tags(cjk_substr($topic_info['topic_description'], 0, 80, 'UTF-8', '...'));
     $topic_info['focus_count'] = $topic_info['focus_count'];
     if ($this->user_id) {
         $topic_info['focus'] = $this->model('topic')->has_focus_topic($this->user_id, $topic_info['topic_id']);
     }
     $topic_info['topic_pic'] = get_topic_pic_url('mid', $topic_info['topic_pic']);
     $topic_info['url'] = get_js_url('/topic/' . $topic_info['url_token']);
     H::ajax_json_output($topic_info);
 }
 /**
  * 数组JSON返回
  *
  * @param  $array
  */
 public static function ajax_json_output($array)
 {
     //HTTP::no_cache_header('text/javascript');
     echo str_replace(array("\r", "\n", "\t"), '', json_encode(H::sensitive_words($array)));
     exit;
 }
 public static function output($template_filename, $display = true)
 {
     if (!strstr($template_filename, self::$template_ext)) {
         $template_filename .= self::$template_ext;
     }
     $display_template_filename = 'default/' . $template_filename;
     if (self::$in_app) {
         if (get_setting('ui_style') != 'default') {
             $custom_template_filename = get_setting('ui_style') . '/' . $template_filename;
             if (file_exists(self::$template_path . '/' . $custom_template_filename)) {
                 $display_template_filename = $custom_template_filename;
             }
         }
         self::assign('template_name', get_setting('ui_style'));
         if (!self::$view->_meta_keywords) {
             self::set_meta('keywords', get_setting('keywords'));
         }
         if (!self::$view->_meta_description) {
             self::set_meta('description', get_setting('description'));
         }
     } else {
         self::assign('template_name', 'default');
     }
     if (self::$in_app and $display) {
         if ($plugins = AWS_APP::plugins()->parse($_GET['app'], $_GET['c'], $_GET['act'], str_replace(self::$template_ext, '', $template_filename))) {
             foreach ($plugins as $plugin_file) {
                 include_once $plugin_file;
             }
         }
     }
     $output = self::$view->getOutput($display_template_filename);
     if (self::$in_app and basename($template_filename) != 'debuger.tpl.htm') {
         $template_dirs = explode('/', $template_filename);
         if ($template_dirs[0] != 'admin') {
             $output = H::sensitive_words($output);
         }
         if (get_setting('url_rewrite_enable') != 'Y' or $template_dirs[0] == 'admin') {
             $output = preg_replace('/(\\s+href|\\s+action)=([\\"|\'])(?!http)(?!mailto)(?!file)(?!ftp)(?!javascript)(?![\\/|\\#])(?!\\.\\/)([^\\"\']+)([\\"|\'])/is', '\\1=\\2' . base_url() . '/' . G_INDEX_SCRIPT . '\\3\\4', $output);
         }
         if ($request_routes = get_request_route() and $template_dirs[0] != 'admin' and get_setting('url_rewrite_enable') == 'Y') {
             foreach ($request_routes as $key => $val) {
                 $output = preg_replace("/href=[\"|']" . $val[0] . "[\\#]/", "href=\"" . $val[1] . "#", $output);
                 $output = preg_replace("/href=[\"|']" . $val[0] . "[\"|']/", "href=\"" . $val[1] . "\"", $output);
             }
         }
         if (get_setting('url_rewrite_enable') == 'Y' and $template_dirs[0] != 'admin') {
             $output = preg_replace('/(href|action)=([\\"|\'])(?!mailto)(?!file)(?!ftp)(?!http)(?!javascript)(?![\\/|\\#])(?!\\.\\/)([^\\"\']+)([\\"|\'])/is', '\\1=\\2' . base_url() . '/' . '\\3\\4', $output);
         }
         //$output = preg_replace("/([a-zA-Z0-9]+_?[a-zA-Z0-9]+)-__|(__[a-zA-Z0-9]+_?[a-zA-Z0-9]+)-$/i", '', $output);
         $output = preg_replace('/[a-zA-Z0-9]+_?[a-zA-Z0-9]*\\-__/', '', $output);
         $output = preg_replace('/(__)?[a-zA-Z0-9]+_?[a-zA-Z0-9]*\\-([\'|"])/', '\\2', $output);
         if (AWS_APP::config()->get('system')->debug) {
             $output .= "\r\n<!-- Template End: " . $display_template_filename . " -->\r\n";
         }
     }
     if ($display) {
         echo $output;
         flush();
     } else {
         return $output;
     }
 }