Exemple #1
0
 public function tag($val, $field = 'name', $tpl = 'tag')
 {
     $val or iPHP::throw404('运行出错!TAG不能为空', 30002);
     $tag = iDB::row("SELECT * FROM `#iCMS@__tags` where `{$field}`='{$val}' AND `status`='1'  LIMIT 1;", ARRAY_A);
     if (empty($tag)) {
         if ($tpl) {
             iPHP::throw404('运行出错!找不到标签: <b>' . $field . ':' . $val . '</b>', 30003);
         } else {
             return false;
         }
     }
     $tag = $this->value($tag);
     $tag['param'] = array("appid" => $tag['appid'], "iid" => $tag['id'], "cid" => $tag['cid'], "suid" => $tag['uid'], "title" => $tag['name'], "url" => $tag['url']);
     if ($tpl) {
         iCMS::hooks('enable_comment', true);
         iPHP::assign('category', $tag['category']);
         iPHP::assign('tag_category', $tag['tag_category']);
         unset($tag['category'], $tag['tag_category']);
         iPHP::assign("tag", $tag);
         if (strstr($tpl, '.htm')) {
             return iPHP::view($tpl, 'tag');
         }
         $html = iPHP::view($tag['tpl'] ? $tag['tpl'] : '{iTPL}/tag.index.htm', 'tag');
         if (iPHP::$iTPL_MODE == "html") {
             return array($html, $tag);
         }
     } else {
         return $tag;
     }
 }
Exemple #2
0
 public function category($id, $tpl = 'index')
 {
     $category = iCache::get('iCMS/category/' . $id);
     if (empty($category) && $tpl) {
         iPHP::throw404('运行出错!找不到该栏目<b>cid:' . $id . '</b> 请更新栏目缓存或者确认栏目是否存在', 20001);
     }
     if ($category['status'] == 0) {
         return false;
     }
     $iurl = iURL::get('category', $category);
     if ($tpl) {
         if (iPHP::$iTPL_MODE == "html" && (strstr($category['contentRule'], '{PHP}') || $category['outurl'] || empty($category['mode']))) {
             return false;
         }
         $category['url'] && iPHP::gotourl($category['url']);
         $category['mode'] == '1' && iCMS::gotohtml($iurl->path, $iurl->href);
     }
     $category['iurl'] = (array) $iurl;
     $category['subid'] = iCache::get('iCMS/category/rootid', $id);
     $category['subids'] = implode(',', (array) $category['subid']);
     $category = array_merge($category, $this->get_lite($category));
     // if($category['password']){
     //     $category_auth        = iPHP::get_cookie('category_auth_'.$id);
     //     list($ca_cid,$ca_psw) = explode('#=iCMS!=#',authcode($category_auth,'DECODE'));
     // 	if($ca_psw!=md5($category['password'])){
     // 		iPHP::assign('forward',__REF__);
     //  	iPHP::view('{iTPL}/category.password.htm','category.password');
     //  	exit;
     // 	}
     // }
     if ($category['hasbody']) {
         $category['body'] = iCache::get('iCMS/category/' . $category['cid'] . '.body');
         $category['body'] && ($category['body'] = stripslashes($category['body']));
     }
     $category['appid'] = iCMS_APP_CATEGORY;
     $category['param'] = array("appid" => $category['appid'], "iid" => $category['cid'], "cid" => $category['rootid'], "suid" => $category['userid'], "title" => $category['name'], "url" => $category['url']);
     if ($tpl) {
         $category['mode'] && iCMS::set_html_url($iurl);
         iCMS::hooks('enable_comment', true);
         iPHP::assign('category', $category);
         if (strpos($tpl, '.htm') !== false) {
             return iPHP::view($tpl, 'category');
         }
         $GLOBALS['page'] > 1 && ($tpl = 'list');
         $html = iPHP::view($category[$tpl . 'TPL'], 'category.' . $tpl);
         if (iPHP::$iTPL_MODE == "html") {
             return array($html, $category);
         }
     } else {
         return $category;
     }
 }
Exemple #3
0
 public function category($id, $tpl = 'index')
 {
     $category = iCache::get('iCMS/category/' . $id);
     if (empty($category) && $tpl) {
         iPHP::throw404('运行出错!找不到该栏目<b>cid:' . $id . '</b> 请更新栏目缓存或者确认栏目是否存在', 20001);
     }
     if ($category['status'] == 0) {
         return false;
     }
     $iurl = iURL::get('category', $category);
     if ($tpl) {
         if (iPHP::$iTPL_MODE == "html" && (strstr($category['contentRule'], '{PHP}') || $category['outurl'] || empty($category['mode']))) {
             return false;
         }
         $category['url'] && iPHP::gotourl($category['url']);
         $category['mode'] == '1' && iCMS::gotohtml($iurl->path, $iurl->href);
     }
     $category['iurl'] = (array) $iurl;
     $category['subid'] = iCache::get('iCMS/category/rootid', $id);
     $category['subids'] = implode(',', (array) $category['subid']);
     $category = array_merge($category, $this->get_lite($category));
     if ($category['hasbody']) {
         $category['body'] = iCache::get('iCMS/category/' . $category['cid'] . '.body');
         $category['body'] && ($category['body'] = stripslashes($category['body']));
     }
     $category['appid'] = iCMS_APP_CATEGORY;
     $category['param'] = array("appid" => $category['appid'], "iid" => $category['cid'], "cid" => $category['rootid'], "suid" => $category['userid'], "title" => $category['name'], "url" => $category['url']);
     if ($tpl) {
         $category['mode'] && iCMS::set_html_url($iurl);
         iCMS::hooks('enable_comment', true);
         iPHP::assign('category', $category);
         if (isset($_GET['tpl'])) {
             $tpl = iS::escapeStr($_GET['tpl']);
             if (strpos($tpl, '..') !== false) {
                 exit('what the f**k!!');
             } else {
                 $tpl = $tpl . '.htm';
             }
         }
         if (strpos($tpl, '.htm') !== false) {
             return iPHP::view($tpl, 'category');
         }
         $GLOBALS['page'] > 1 && ($tpl = 'list');
         $html = iPHP::view($category[$tpl . 'TPL'], 'category.' . $tpl);
         if (iPHP::$iTPL_MODE == "html") {
             return array($html, $category);
         }
     } else {
         return $category;
     }
 }
Exemple #4
0
 public function index($a = null)
 {
     $index_name = $a[1] ? $a[1] : iCMS::$config['template']['index_name'];
     $index_tpl = $a[0] ? $a[0] : iCMS::$config['template']['index'];
     $index_name or $index_name = 'index';
     $iurl = iURL::get('index', array('urlRule' => $index_name . iCMS::$config['router']['html_ext']));
     if (iCMS::$config['template']['index_mode'] && iPHP_DEVICE == "desktop") {
         iCMS::gotohtml($iurl->path, $iurl->href);
     }
     if (iPHP::$iTPL_MODE == "html" || iCMS::$config['template']['index_rewrite']) {
         iCMS::set_html_url($iurl);
     }
     $html = iPHP::view($index_tpl);
     if (iPHP::$iTPL_MODE == "html") {
         return array($html, $iurl);
     }
 }
Exemple #5
0
 public function search($tpl = false)
 {
     $q = htmlspecialchars(rawurldecode($_GET['q']));
     $encode = mb_detect_encoding($q, array("ASCII", "UTF-8", "GB2312", "GBK", "BIG5"));
     if (strtoupper($encode) != 'UTF-8') {
         if (function_exists('iconv')) {
             $q = iconv($encode, 'UTF-8//IGNORE', $q);
         } elseif (function_exists('mb_convert_encoding')) {
             $q = mb_convert_encoding($q, 'UTF-8//IGNORE', $encode);
         }
     }
     $q = iS::escapeStr($q);
     //empty($q) && iPHP::throw404('应用程序运行出错.亲!搜点什么吧!!', 60001);
     $fwd = iCMS::filter($q);
     $fwd && iPHP::throw404('非法搜索词!', 60002);
     $search['title'] = stripslashes($q);
     $search['keyword'] = $q;
     $tpl === false && ($tpl = '{iTPL}/search.htm');
     $q && $this->slog($q);
     iPHP::assign("search", $search);
     return iPHP::view($tpl, 'search');
 }
Exemple #6
0
function public_common($vars = null)
{
    echo iPHP::view('iCMS://public.common.htm');
}
Exemple #7
0
 public function openid()
 {
     if (!isset($_GET['sign'])) {
         return;
     }
     $sign = $_GET['sign'];
     $code = $_GET['code'];
     $state = $_GET['state'];
     $platform_map = array('WX' => 1, 'QQ' => 2, 'WB' => 3, 'TB' => 4);
     $class_name = strtoupper($sign);
     $platform = $platform_map[$class_name];
     $bind = $sign;
     if ($platform) {
         iPHP::app('user.open/' . $class_name . '.class', 'static');
         $api = new $class_name();
         $api->appid = iCMS::$config['open'][$class_name]['appid'];
         $api->appkey = iCMS::$config['open'][$class_name]['appkey'];
         $redirect_uri = rtrim(iCMS::$config['open'][$class_name]['redirect'], '/');
         $api->url = user::login_uri($redirect_uri) . 'sign=' . $sign;
         if (isset($_GET['bind']) && $_GET['bind'] == $sign) {
             $api->get_openid();
         } else {
             $api->callback();
         }
         $userid = user::openid($api->openid, $platform);
         if ($userid) {
             $user = user::get($userid, false);
             user::set_cookie($user->username, $user->password, array('uid' => $userid, 'username' => $user->username, 'nickname' => $user->nickname, 'status' => $user->status));
             $api->cleancookie();
             iPHP::gotourl($this->forward);
         } else {
             if (isset($_GET['bind'])) {
                 $user = array();
                 $user['openid'] = $api->openid;
                 $user['platform'] = $platform;
                 $api->cleancookie();
                 iPHP::assign('user', $user);
                 iPHP::view('iCMS://user/login.htm');
             } else {
                 $user = $api->get_user_info();
                 $user['openid'] = $api->openid;
                 $user['platform'] = $platform;
                 iDB::value("SELECT `uid` FROM `#iCMS@__user` where `nickname`='" . $user['nickname'] . "' LIMIT 1") && ($user['nickname'] = $sign . '_' . $user['nickname']);
                 iPHP::assign('user', $user);
                 iPHP::assign('query', compact(array('sign', 'code', 'state', 'bind')));
                 iPHP::view('iCMS://user/register.htm');
             }
             exit;
         }
     }
 }
Exemple #8
0
 public function article($id, $page = 1, $tpl = true)
 {
     $article = iDB::row("SELECT * FROM `#iCMS@__article` WHERE id='" . (int) $id . "' AND `status` ='1' LIMIT 1;", ARRAY_A);
     $article or iPHP::throw404('运行出错!找不到文章: <b>ID:' . $id . '</b>', 10001);
     if ($article['url']) {
         if (iPHP::$iTPL_MODE == "html") {
             return false;
         } else {
             $this->API_hits($id);
             iPHP::gotourl($article['url']);
         }
     }
     if (iCMS_ARTICLE_DATA === "TEXT") {
         iPHP::app('article.table');
         $article_data = articleTable::get_text($id);
     } else {
         $article && ($article_data = iDB::row("SELECT body,subtitle FROM `#iCMS@__article_data` WHERE aid='" . (int) $id . "' LIMIT 1;", ARRAY_A));
     }
     $vars = array('tags' => true, 'user' => true, 'meta' => true, 'prev_next' => true, 'category_lite' => false);
     $article = $this->value($article, $article_data, $vars, $page, $tpl);
     unset($article_data);
     if ($article === false) {
         return false;
     }
     if ($tpl) {
         iCMS::hooks('enable_comment', true);
         $article_tpl = empty($article['tpl']) ? $article['category']['contentTPL'] : $article['tpl'];
         strstr($tpl, '.htm') && ($article_tpl = $tpl);
         iPHP::assign('category', $article['category']);
         unset($article['category']);
         iPHP::assign('article', $article);
         $html = iPHP::view($article_tpl, 'article');
         if (iPHP::$iTPL_MODE == "html") {
             return array($html, $article);
         }
     } else {
         return $article;
     }
 }
Exemple #9
0
 public function API_interface()
 {
     if (iPHP_DEBUG) {
         // ob_start();
         // iDB::$show_errors = true;
     }
     if ($_GET["api_token"] != iCMS::$config['api']['weixin']['token']) {
         throw new Exception('TOKEN is error!');
     }
     if ($_GET["echostr"] && !$_GET['msg_signature']) {
         if ($this->checkSignature()) {
             echo $_GET["echostr"];
             exit;
         }
     }
     $input = file_get_contents("php://input");
     if ($input) {
         $xml = simplexml_load_string($input, 'SimpleXMLElement', LIBXML_NOCDATA);
         $FromUserName = $xml->FromUserName;
         $ToUserName = $xml->ToUserName;
         $content = trim($xml->Content);
         $msgType = $xml->MsgType;
         $event = $xml->Event;
         $eventKey = $xml->EventKey;
         $CreateTime = time();
         $dayline = get_date('', 'Y-m-d H:i:s');
         if ($event == 'LOCATION') {
             $Latitude = $xml->Latitude;
             //地理位置纬度
             $Longitude = $xml->Longitude;
             //地理位置经度
             $Precision = $xml->Precision;
             //地理位置精度
         }
         if ($event == 'SCAN') {
             $Ticket = $xml->Ticket;
             //二维码的ticket,可用来换取二维码图片
         }
         if ($msgType == 'voice') {
             $MediaId = $xml->MediaId;
             //语音消息媒体id,可以调用多媒体文件下载接口拉取该媒体
             $Format = $xml->Format;
             //语音格式:amr
             $Recognition = $xml->Recognition;
             //语音识别结果,UTF8编码
             $MsgID = $xml->MsgID;
             //消息id,64位整型
         }
         if ($msgType != "text") {
             $content = $event;
         }
         $fields = array('ToUserName', 'FromUserName', 'CreateTime', 'content', 'dayline');
         $data = compact($fields);
         $content && iDB::insert('weixin_api_log', $data);
         $site_name = addslashes(iCMS::$config['site']['name']);
         $site_desc = addslashes(iCMS::$config['site']['description']);
         $site_key = addslashes(iCMS::$config['site']['keywords']);
         $site_host = str_replace('http://', '', iCMS_URL);
         if (in_array($event, array('subscribe', 'unsubscribe'))) {
             if ($event == 'subscribe') {
                 $subscribe_msg = $site_name . ' (' . $site_host . ') ' . $site_desc . "\n\n回复:" . $site_key . ' 将会收到我们最新为您准备的信息';
                 iCMS::$config['api']['weixin']['subscribe'] && ($subscribe_msg = iCMS::$config['api']['weixin']['subscribe']);
                 //$subscribe_msg = str_replace(array('{site.name}'), replace, subject)
                 $this->msg_xml($subscribe_msg, $FromUserName, $ToUserName);
             }
             if ($event == 'unsubscribe') {
                 $subscribe_msg = "非常感谢您一直以来对我们【" . iCMS::$config['api']['weixin']['name'] . "】的支持!我们会继续努力,做出更好的内容!\n";
                 iCMS::$config['api']['weixin']['unsubscribe'] && ($subscribe_msg = iCMS::$config['api']['weixin']['unsubscribe']);
                 //$subscribe_msg = str_replace(array('{site.name}'), replace, subject)
                 $this->msg_xml($subscribe_msg, $FromUserName, $ToUserName);
             }
         }
         if (in_array($content, array("1", "2", "3", "?", "?", "你好"))) {
             $this->msg_xml($site_name . ' (' . $site_host . ') ' . $site_desc . "\n\n回复:" . $site_key . ' 将会收到我们最新为您准备的信息', $FromUserName, $ToUserName);
         }
         iPHP::assign('weixin', $data);
         iPHP::view("iCMS://weixin.api.htm");
     }
     if (iPHP_DEBUG) {
         // $output = ob_get_contents();
         // ob_end_clean();
         // echo $output;
         // iFS::write('weixin.api.debug.log',$output,1,'ab+');
     }
 }
Exemple #10
0
function comment_form($vars)
{
    if (!iCMS::$hooks['enable_comment']) {
        iPHP::warning('此页面禁止调用 iCMS&#x3a;comment&#x3a;form 标签!');
    }
    if ($vars['ref']) {
        $_vars = iCMS::app_ref($vars['ref']);
        unset($vars['ref']);
        $vars = array_merge($vars, $_vars);
    }
    $vars['iid'] or iPHP::warning('iCMS&#x3a;comment&#x3a;form 标签出错! 缺少"iid"属性或"iid"值为空.');
    $vars['cid'] or iPHP::warning('iCMS&#x3a;comment&#x3a;form 标签出错! 缺少"cid"属性或"cid"值为空.');
    $vars['appid'] or iPHP::warning('iCMS&#x3a;comment&#x3a;form 标签出错! 缺少"appid"属性或"appid"值为空.');
    $vars['title'] or iPHP::warning('iCMS&#x3a;comment&#x3a;form 标签出错! 缺少"title"属性或"title"值为空.');
    switch ($vars['display']) {
        case 'iframe':
            $tpl = 'form.iframe';
            $vars['do'] = 'form';
            break;
        default:
            isset($vars['_display']) && ($vars['display'] = $vars['_display']);
            $vars['param'] = array('suid' => $vars['suid'], 'iid' => $vars['iid'], 'cid' => $vars['cid'], 'appid' => $vars['appid'], 'title' => $vars['title']);
            $tpl = 'form.default';
            break;
    }
    unset($vars['method'], $vars['_display']);
    $vars['query'] = http_build_query($vars);
    iPHP::assign('comment_vars', $vars);
    echo iPHP::view('iCMS://comment/' . $tpl . '.htm');
}
Exemple #11
0
 public function API_sitemap()
 {
     header("Content-type:text/xml");
     iPHP::assign('cid', (int) $_GET['cid']);
     iPHP::view('iCMS://sitemap.baidu.htm');
 }