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; } }
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; } }
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); } }
public function value($tag) { $categoryApp = iPHP::app("category"); if ($tag['cid']) { $category = $categoryApp->category($tag['cid'], false); $tag['category'] = $categoryApp->get_lite($category); } if ($tag['tcid']) { $tag_category = $categoryApp->category($tag['tcid'], false); $tag['tag_category'] = $categoryApp->get_lite($tag_category); } $tag['iurl'] = iURL::get('tag', array($tag, $category, $tag_category)); $tag['url'] or $tag['url'] = $tag['iurl']->href; $tag['link'] = '<a href="' . $tag['url'] . '" class="tag" target="_blank">' . $tag['name'] . '</a>'; if ($category['mode'] && stripos($tag['url'], '.php?') === false) { iCMS::set_html_url($tag['iurl']); } $tag['metadata'] && ($tag['meta'] = json_decode($tag['metadata'])); $tag['related'] && ($tag['relArray'] = explode(',', $tag['related'])); $tag['appid'] = iCMS_APP_TAG; $tag['pic'] = get_pic($tag['pic']); $tag['bpic'] = get_pic($tag['bpic']); $tag['mpic'] = get_pic($tag['mpic']); $tag['spic'] = get_pic($tag['spic']); return $tag; }
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) { $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 { $img_replace[$key] = '<p>' . $clicknext . '</p>'; $img_replace[$key] .= '<p>' . $clickimg . '</p>'; } } } $article['body'] = str_replace($img_array, $img_replace, $article['body']); } } if ($vars['tags']) { $article['tags_fname'] = $category['name']; if ($article['tags']) { $tagApp = iPHP::app("tag"); $tagArray = $tagApp->get_array($article['tags']); $article['tag_array'] = array(); foreach ((array) $tagArray as $tk => $tag) { $article['tag_array'][$tk] = $tag; $article['tags_link'] .= $tag['link']; $tag_name_array[] = $tag['name']; } $tag_name_array && ($article['tags_fname'] = $tag_name_array[0]); unset($tagApp, $tagArray, $tag_name_array); } } if ($vars['meta']) { if ($article['metadata']) { $article['meta'] = unserialize($article['metadata']); unset($article['metadata']); } } if ($vars['user']) { iPHP::app('user.class', 'static'); if ($article['postype']) { $article['user'] = user::empty_info($article['userid'], '#' . $article['editor']); } else { $article['user'] = user::info($article['userid'], $article['author']); } } if (strstr($article['source'], '||')) { list($s_name, $s_url) = explode('||', $article['source']); $article['source'] = '<a href="' . $s_url . '" target="_blank">' . $s_name . '</a>'; } if (strstr($article['author'], '||')) { list($a_name, $a_url) = explode('||', $article['author']); $article['author'] = '<a href="' . $a_url . '" target="_blank">' . $a_name . '</a>'; } $article['hits'] = array('script' => iCMS_API . '?app=article&do=hits&cid=' . $article['cid'] . '&id=' . $article['id'], 'count' => $article['hits'], 'today' => $article['hits_today'], 'yday' => $article['hits_yday'], 'week' => $article['hits_week'], 'month' => $article['hits_month']); $article['comment'] = array('url' => iCMS_API . "?app=article&do=comment&appid={$article['appid']}&iid={$article['id']}&cid={$article['cid']}", 'count' => $article['comments']); if ($article['picdata']) { $picdata = unserialize($article['picdata']); } unset($article['picdata']); $article['pic'] = get_pic($article['pic'], $picdata['b'], get_twh($vars['btw'], $vars['bth'])); $article['mpic'] = get_pic($article['mpic'], $picdata['m'], get_twh($vars['mtw'], $vars['mth'])); $article['spic'] = get_pic($article['spic'], $picdata['s'], get_twh($vars['stw'], $vars['sth'])); $article['param'] = array("appid" => $article['appid'], "iid" => $article['id'], "cid" => $article['cid'], "suid" => $article['userid'], "title" => $article['title'], "url" => $article['url']); return $article; }