Exemplo n.º 1
0
 public function API_goto()
 {
     $appid = (int) $_GET['appid'];
     $iid = (int) $_GET['iid'];
     $_GET = iS::escapeStr($_GET);
     iPHP::import(iPHP_APP_CORE . '/iAPP.class.php');
     $url = app::get_url($appid, $iid);
     iPHP::gotourl($url);
 }
Exemplo n.º 2
0
 function do_login()
 {
     if ($this->uid) {
         $user = iDB::row("SELECT * FROM `#iCMS@__user` WHERE `uid`='{$this->uid}' LIMIT 1;", ARRAY_A);
         iPHP::app('user.class', 'static');
         user::set_cookie($user['username'], $user['password'], $user);
         $url = iPHP::router(array('/{uid}/', $this->uid), iPHP_ROUTER_REWRITE);
         iPHP::gotourl($url);
     }
 }
Exemplo n.º 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['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;
     }
 }
Exemplo n.º 4
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;
     }
 }
Exemplo n.º 5
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 {
         if ($article['chapter']) {
             $all = iDB::all("SELECT id,subtitle FROM `#iCMS@__article_data` WHERE aid='" . (int) $id . "';", ARRAY_A);
             foreach ($all as $akey => $value) {
                 $article_data[] = $value;
             }
             unset($all);
             ksort($article_data);
         } else {
             $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;
     }
 }
Exemplo n.º 6
0
 public static function gotohtml($fp, $url = '')
 {
     if (iPHP::$iTPL_MODE == 'html' || empty($url) || stristr($url, '.php?') || iPHP_DEVICE != 'desktop') {
         return;
     }
     @is_file($fp) && iPHP::gotourl($url);
 }
Exemplo n.º 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;
         }
     }
 }
Exemplo n.º 8
0
 public static function status($url = null, $st = null)
 {
     $status = false;
     $auth = self::get_cookie(true);
     if ($auth) {
         $user = self::get($auth['userid'], false);
         if ($auth['username'] == $user->username && $auth['password'] == $user->password) {
             $status = true;
         }
         unset($user->password);
     }
     unset($auth);
     if ($status) {
         if ($url && $st == "login") {
             if (self::$format == 'json') {
                 return iPHP::code(1, 0, $url, 'json');
             }
             iPHP::gotourl($url);
         }
         return $user;
     } else {
         if ($url && $st == "nologin") {
             if (self::$format == 'json') {
                 return iPHP::code(0, 0, $url, 'json');
             }
             iPHP::gotourl($url);
         }
         return false;
     }
 }