本文整理汇总了PHP中iPHP::throw404方法的典型用法代码示例。如果您正苦于以下问题:PHP iPHP::throw404方法的具体用法?PHP iPHP::throw404怎么用?PHP iPHP::throw404使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iPHP
的用法示例。
在下文中一共展示了iPHP::throw404方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tag
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;
}
}
示例2: user
private function user($userdata = false)
{
$status = array('logined' => false, 'followed' => false, 'isme' => false);
if ($this->uid) {
// &uid=
$this->user = user::get($this->uid);
empty($this->user) && iPHP::throw404('运行出错!找不到该用户', "user:" . $this->uid);
}
$this->me = user::status();
//判断是否登陆
if (empty($this->me) && empty($this->user)) {
iPHP::set_cookie('forward', '', -31536000);
iPHP::gotourl($this->login_uri);
}
if ($this->me) {
$status['logined'] = true;
$status['followed'] = (int) user::follow($this->me->uid, $this->user->uid);
empty($this->user) && ($this->user = $this->me);
if ($this->user->uid == $this->me->uid) {
$status['isme'] = true;
$this->user = $this->me;
}
iPHP::assign('me', (array) $this->me);
}
$this->user->hits_script = iCMS_API . '?app=user&do=hits&uid=' . $this->user->uid;
iPHP::assign('status', $status);
iPHP::assign('user', (array) $this->user);
$userdata && iPHP::assign('userdata', (array) user::data($this->user->uid));
}
示例3: category
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;
}
}
示例4: category
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 fuck!!');
} 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;
}
}
示例5: run
public static function run($app = NULL, $do = NULL, $args = NULL, $prefix = "do_")
{
//empty($app) && $app = $_GET['app']; //单一入口
if (empty($app)) {
$fi = iFS::name(__SELF__);
$app = $fi['name'];
}
if (!in_array($app, self::$apps) && iPHP_DEBUG) {
iPHP::throw404('运行出错!找不到应用程序: <b>' . $app . '</b>', '0001');
}
self::$app_path = iPHP_APP_DIR . '/' . $app;
self::$app_file = self::$app_path . '/' . $app . '.app.php';
is_file(self::$app_file) or iPHP::throw404('运行出错!找不到文件: <b>' . $app . '.app.php</b>', '0002');
if ($do === NULL) {
$do = iPHP_APP;
$_GET['do'] && ($do = iS::escapeStr($_GET['do']));
}
if ($_POST['action']) {
$do = iS::escapeStr($_POST['action']);
$prefix = 'ACTION_';
}
self::$app_name = $app;
self::$app_do = $do;
self::$app_method = $prefix . $do;
self::$app_tpl = iPHP_APP_DIR . '/' . $app . '/template';
self::$app_vars = array("MOBILE" => iPHP::$mobile, 'COOKIE_PRE' => iPHP_COOKIE_PRE, 'REFER' => __REF__, 'CONFIG' => self::$config, "APP" => array('NAME' => self::$app_name, 'DO' => self::$app_do, 'METHOD' => self::$app_method));
iPHP::$iTPL->_iTPL_VARS['SAPI'] .= self::$app_name;
iPHP::$iTPL->_iTPL_VARS += self::$app_vars;
self::$app = iPHP::app($app);
if (self::$app_do && self::$app->methods) {
in_array(self::$app_do, self::$app->methods) or iPHP::throw404('运行出错! <b>' . self::$app_name . '</b> 类中找不到方法定义: <b>' . self::$app_method . '</b>', '0003');
$method = self::$app_method;
$args === null && ($args = self::$app_args);
if ($args) {
if ($args === 'object') {
return self::$app;
}
return call_user_func_array(array(self::$app, $method), (array) $args);
} else {
method_exists(self::$app, self::$app_method) or iPHP::throw404('运行出错! <b>' . self::$app_name . '</b> 类中 <b>' . self::$app_method . '</b> 方法不存在', '0004');
return self::$app->{$method}();
}
} else {
iPHP::throw404('运行出错! <b>' . self::$app_name . '</b> 类中 <b>' . self::$app_method . '</b> 方法不存在', '0005');
}
}
示例6: search
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');
}
示例7: value
public function value($article, $art_data = "", $vars = array(), $page = 1, $tpl = false)
{
$article['appid'] = iCMS_APP_ARTICLE;
$categoryApp = iPHP::app("category");
$category = $categoryApp->category($article['cid'], false);
if ($tpl) {
$category or iPHP::throw404('运行出错!找不到该文章的栏目缓存<b>cid:' . $article['cid'] . '</b> 请更新栏目缓存或者确认栏目是否存在', 10002);
} else {
if (empty($category)) {
return false;
}
}
if ($category['status'] == 0) {
return false;
}
if (iPHP::$iTPL_MODE == "html" && $tpl && (strstr($category['contentRule'], '{PHP}') || $category['outurl'] || $category['mode'] == "0")) {
return false;
}
$_iurlArray = array($article, $category);
$article['iurl'] = iURL::get('article', $_iurlArray, $page);
$article['url'] = $article['iurl']->href;
$article['link'] = "<a href='{$article['url']}'>{$article['title']}</a>";
$tpl && $category['mode'] == '1' && iCMS::gotohtml($article['iurl']->path, $article['iurl']->href);
if ($vars['category_lite']) {
$article['category'] = $categoryApp->get_lite($category);
} else {
$article['category'] = $category;
}
$this->taoke = false;
if ($art_data) {
$pageurl = $article['iurl']->pageurl;
// if(strpos($art_data['body'], '#--iCMS.ArticleData--#')!==false){
// iPHP::app('article.table');
// $art_data['body'] = articleTable::get_text($article['id']);
// }
$art_data['body'] = $this->ubb($art_data['body']);
preg_match_all("/<img.*?src\\s*=[\"|'|\\s]*(http:\\/\\/.*?\\.(gif|jpg|jpeg|bmp|png)).*?>/is", $art_data['body'], $pic_array);
$p_array = array_unique($pic_array[1]);
if ($p_array) {
foreach ($p_array as $key => $_pic) {
$article['pics'][$key] = trim($_pic);
}
}
if (strpos($art_data['body'], '#--iCMS.Markdown--#') !== false) {
$art_data['body'] = iPHP::Markdown($art_data['body']);
}
$body = explode('#--iCMS.PageBreak--#', $art_data['body']);
$count = count($body);
$total = $count + intval(iCMS::$config['article']['pageno_incr']);
$article['body'] = $this->keywords($body[intval($page - 1)]);
$article['body'] = $this->taoke($article['body']);
$article['subtitle'] = $art_data['subtitle'];
$article['taoke'] = $this->taoke;
unset($art_data);
if ($total > 1) {
$flag = 0;
$num_nav = '';
for ($i = $page - 3; $i <= $page - 1; $i++) {
if ($i < 1) {
continue;
}
$num_nav .= "<a href='" . iPHP::p2num($pageurl, $i) . "' target='_self'>{$i}</a>";
$flag++;
}
$num_nav .= '<span class="current">' . $page . '</span>';
for ($i = $page + 1; $i <= $total; $i++) {
$num_nav .= "<a href='" . iPHP::p2num($pageurl, $i) . "' target='_self'>{$i}</a>";
$flag++;
if ($flag == 6) {
break;
}
}
$index_nav = '<a href="' . $article['url'] . '" class="first" target="_self">' . iPHP::lang('iCMS:page:index') . '</a>';
$prev_url = iPHP::p2num($pageurl, $page - 1 > 1 ? $page - 1 : 1);
$prev_nav = '<a href="' . $prev_url . '" class="prev" target="_self">' . iPHP::lang('iCMS:page:prev') . '</a>';
$next_url = iPHP::p2num($pageurl, $total - $page > 0 ? $page + 1 : $page);
$next_nav = '<a href="' . $next_url . '" class="next" target="_self">' . iPHP::lang('iCMS:page:next') . '</a>';
$end_nav = '<a href="' . iPHP::p2num($pageurl, $total) . '" class="end" target="_self">共' . $total . '页</a>';
$text_nav = $index_nav . $prev_nav . '<span class="current">第' . $page . '页</span>' . $next_nav . $end_nav;
$pagenav = $index_nav . $prev_nav . $num_nav . $next_nav . $end_nav;
}
$article['page'] = array('total' => $total, 'count' => $count, 'current' => $page, 'num' => $num_nav, 'text' => $text_nav, 'nav' => $pagenav, 'prev' => $prev_url, 'next' => $next_url, 'pageurl' => $pageurl, 'last' => $page == $count ? true : false, 'end' => $page == $total ? true : false);
unset($index_nav, $prev_nav, $num_nav, $next_nav, $end_nav, $pagenav);
//var_dump($page,$total,$count);
if ($pic_array[0]) {
$img_array = array_unique($pic_array[0]);
foreach ($img_array as $key => $img) {
$img = str_replace('<img', '<img title="' . $article['title'] . '" alt="' . $article['title'] . '"', $img);
if (iCMS::$config['article']['pic_center']) {
$img_replace[$key] = '<p align="center">' . $img . '</p>';
} else {
$img_replace[$key] = $img;
}
if (iCMS::$config['article']['pic_next'] && $count > 1) {
$clicknext = '<a href="' . $next_url . '"><b>' . iPHP::lang('iCMS:article:clicknext') . '</b></a>';
$clickimg = '<a href="' . $next_url . '" title="' . $article['title'] . '" class="img">' . $img . '</a>';
if (iCMS::$config['article']['pic_center']) {
$img_replace[$key] = '<p align="center">' . $clicknext . '</p>';
$img_replace[$key] .= '<p align="center">' . $clickimg . '</p>';
} else {
//.........这里部分代码省略.........
示例8: value
public function value($article, $art_data = "", $vars = array(), $page = 1, $tpl = false)
{
$article['appid'] = iCMS_APP_ARTICLE;
$categoryApp = iPHP::app("category");
$category = $categoryApp->category($article['cid'], false);
if ($tpl) {
$category or iPHP::throw404('运行出错!找不到该文章的栏目缓存<b>cid:' . $article['cid'] . '</b> 请更新栏目缓存或者确认栏目是否存在', 10002);
} else {
if (empty($category)) {
return false;
}
}
if ($category['status'] == 0) {
return false;
}
if (iPHP::$iTPL_MODE == "html" && $tpl && (strstr($category['contentRule'], '{PHP}') || $category['outurl'] || $category['mode'] == "0")) {
return false;
}
$_iurlArray = array($article, $category);
$article['iurl'] = iURL::get('article', $_iurlArray, $page);
$article['url'] = $article['iurl']->href;
$article['link'] = "<a href='{$article['url']}'>{$article['title']}</a>";
$tpl && $category['mode'] == '1' && iCMS::gotohtml($article['iurl']->path, $article['iurl']->href);
if ($vars['category_lite']) {
$article['category'] = $categoryApp->get_lite($category);
} else {
$article['category'] = $category;
}
$this->taoke = false;
if ($art_data) {
$pkey = intval($page - 1);
$pageurl = $article['iurl']->pageurl;
if ($article['chapter']) {
$chapterArray = $art_data;
$count = count($chapterArray);
$adid = $chapterArray[$pkey]['id'];
$art_data = iDB::row("SELECT body,subtitle FROM `#iCMS@__article_data` WHERE aid='" . (int) $article['id'] . "' AND id='" . (int) $adid . "' LIMIT 1;", ARRAY_A);
}
$art_data['body'] = $this->ubb($art_data['body']);
preg_match_all("/<img.*?src\\s*=[\"|'|\\s]*(http:\\/\\/.*?\\.(gif|jpg|jpeg|bmp|png)).*?>/is", $art_data['body'], $pic_array);
$p_array = array_unique($pic_array[1]);
if ($p_array) {
foreach ($p_array as $key => $_pic) {
$article['pics'][$key] = trim($_pic);
}
}
if (substr($art_data['body'], 0, 19) == '#--iCMS.Markdown--#') {
// $art_data['body'] = iPHP::Markdown($art_data['body']);
$art_data['body'] = substr($art_data['body'], 19);
$article['markdown'] = ture;
}
if ($article['chapter']) {
$article['body'] = $art_data['body'];
} else {
$body = explode('#--iCMS.PageBreak--#', $art_data['body']);
$count = count($body);
$article['body'] = $body[$pkey];
}
$total = $count + intval(iCMS::$config['article']['pageno_incr']);
$article['body'] = $this->keywords($article['body']);
$article['body'] = $this->taoke($article['body']);
$article['taoke'] = $this->taoke;
$article['subtitle'] = $art_data['subtitle'];
unset($body, $art_data);
$pageArray = array();
if ($total > 1) {
iPHP::loadClass("Pages");
$_GLOBALS_iPage = $GLOBALS['iPage'];
$category['mode'] && iCMS::set_html_url($article['iurl']);
$pageconf = array('page_name' => 'p', 'url' => $pageurl, 'total' => $total, 'perpage' => 1, 'nowindex' => (int) $_GET['p'], 'lang' => iPHP::lang(iPHP_APP . ':page'));
if ($article['chapter']) {
foreach ((array) $chapterArray as $key => $value) {
$pageconf['titles'][$key + 1] = $value['subtitle'];
}
}
$iPages = new iPages($pageconf);
unset($GLOBALS['iPage']);
$GLOBALS['iPage'] = $_GLOBALS_iPage;
unset($_GLOBALS_iPage);
$pageArray['list'] = $iPages->list_page();
$pageArray['index'] = $iPages->first_page('array');
$pageArray['prev'] = $iPages->prev_page('array');
$pageArray['next'] = $iPages->next_page('array');
$pageArray['endof'] = $iPages->last_page('array');
$pagenav = $iPages->show(0);
$pagetext = $iPages->show(10);
}
$article['page'] = array('pn' => $page, 'total' => $total, 'count' => $count, 'current' => $page, 'nav' => $pagenav, 'pageurl' => $pageurl, 'text' => $pagetext, 'PAGES' => $iPages, 'args' => iS::escapeStr($_GET['pageargs']), 'first' => $page == "1" ? true : false, 'last' => $page == $count ? true : false, 'end' => $page == $total ? true : false) + $pageArray;
$next_url = $pageArray['next']['url'];
unset($pagenav, $pagetext, $iPages, $pageArray);
if ($pic_array[0]) {
$img_array = array_unique($pic_array[0]);
foreach ($img_array as $key => $img) {
$img = str_replace('<img', '<img title="' . $article['title'] . '" alt="' . $article['title'] . '"', $img);
if (iCMS::$config['article']['pic_center']) {
$img_replace[$key] = '<p align="center">' . $img . '</p>';
} else {
$img_replace[$key] = $img;
}
if (iCMS::$config['article']['pic_next'] && $count > 1) {
//.........这里部分代码省略.........
示例9: run
/**
* 运行应用程序
* @param string $app 应用程序名称
* @param string $do 动作名称
* @return iCMS
*/
public static function run($app = NULL, $do = NULL, $args = NULL, $prefix = "do_")
{
//empty($app) && $app = $_GET['app']; //单一入口
if (empty($app)) {
$fi = iFS::name(__SELF__);
$app = $fi['name'];
}
if (!in_array($app, self::$apps) && iPHP_DEBUG) {
iPHP::throw404('运行出错!找不到应用程序: <b>' . $app . '</b>', '0001');
}
self::$app_path = iPHP_APP_DIR . '/' . $app;
self::$app_file = self::$app_path . '/' . $app . '.app.php';
is_file(self::$app_file) or iPHP::throw404('运行出错!找不到文件: <b>' . $app . '.app.php</b>', '0002');
if ($do === NULL) {
$do = iPHP_APP;
$_GET['do'] && ($do = iS::escapeStr($_GET['do']));
}
if ($_POST['action']) {
$do = iS::escapeStr($_POST['action']);
$prefix = 'ACTION_';
}
self::$app_name = $app;
self::$app_do = $do;
self::$app_method = $prefix . $do;
self::$app_tpl = iPHP_APP_DIR . '/' . $app . '/template';
self::$app_vars = array('VERSION' => iCMS_VER, "MOBILE" => iPHP::$mobile, 'API' => iCMS_API, 'UI' => iCMS_UI, 'UI_URL' => iCMS_UI_URL, 'SAPI' => iCMS_API . '?app=' . self::$app_name, 'COOKIE_PRE' => iPHP_COOKIE_PRE, 'REFER' => __REF__, 'CONFIG' => self::$config, "APP" => array('NAME' => self::$app_name, 'DO' => self::$app_do, 'METHOD' => self::$app_method), "APPID" => array('ARTICLE' => iCMS_APP_ARTICLE, 'CATEGORY' => iCMS_APP_CATEGORY, 'TAG' => iCMS_APP_TAG, 'PUSH' => iCMS_APP_PUSH, 'COMMENT' => iCMS_APP_COMMENT, 'PROP' => ICMS_APP_PROP, 'MESSAGE' => iCMS_APP_MESSAGE, 'FAVORITE' => iCMS_APP_FAVORITE, 'USER' => iCMS_APP_USER));
define('iCMS_API_URL', iCMS_API . '?app=' . self::$app_name);
iPHP::$iTPL->_iTPL_VARS = self::$app_vars;
self::$app = iPHP::app($app);
if (self::$app_do && self::$app->methods) {
in_array(self::$app_do, self::$app->methods) or iPHP::throw404('运行出错! <b>' . self::$app_name . '</b> 类中找不到方法定义: <b>' . self::$app_method . '</b>', '0003');
$method = self::$app_method;
$args === null && ($args = self::$app_args);
if ($args) {
if ($args === 'object') {
return self::$app;
}
return call_user_func_array(array(self::$app, $method), (array) $args);
} else {
method_exists(self::$app, self::$app_method) or iPHP::throw404('运行出错! <b>' . self::$app_name . '</b> 类中 <b>' . self::$app_method . '</b> 方法不存在', '0004');
return self::$app->{$method}();
}
} else {
iPHP::throw404('运行出错! <b>' . self::$app_name . '</b> 类中 <b>' . self::$app_method . '</b> 方法不存在', '0005');
}
}