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($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 { $img_replace[$key] = '<p>' . $clicknext . '</p>'; $img_replace[$key] .= '<p>' . $clickimg . '</p>'; } } } $article['body'] = str_replace($img_array, $img_replace, $article['body']); } } if ($vars['prev_next'] && iCMS::$config['article']['prev_next']) { //上一篇 $prev_cache = iPHP_DEVICE . '/article/' . $article['id'] . '/prev'; $prev_array = iCache::get($prev_cache); if (empty($prev_array)) { $prev_array = array('empty' => true, 'title' => iPHP::lang('iCMS:article:first'), 'pic' => array(), 'url' => 'javascript:;'); $prevrs = iDB::row("SELECT * FROM `#iCMS@__article` WHERE `id` < '{$article['id']}' AND `cid`='{$article['cid']}' AND `status`='1' order by id DESC LIMIT 1;"); if ($prevrs) { $prev_array = array('empty' => false, 'title' => $prevrs->title, 'pic' => get_pic($prevrs->pic), 'url' => iURL::get('article', array((array) $prevrs, $category))->href); } iCache::set($prev_cache, $prev_array); } $article['prev'] = $prev_array; //下一篇 $next_cache = iPHP_DEVICE . '/article/' . $article['id'] . '/next'; $next_array = iCache::get($next_cache); if (empty($next_array)) { $next_array = array('empty' => true, 'title' => iPHP::lang('iCMS:article:last'), 'pic' => array(), 'url' => 'javascript:;'); $nextrs = iDB::row("SELECT * FROM `#iCMS@__article` WHERE `id` > '{$article['id']}' and `cid`='{$article['cid']}' AND `status`='1' order by id ASC LIMIT 1;"); if ($nextrs) { $next_array = array('empty' => false, 'title' => $nextrs->title, 'pic' => get_pic($nextrs->pic), 'url' => iURL::get('article', array((array) $nextrs, $category))->href); } iCache::set($next_cache, $next_array); } $article['next'] = $next_array; } 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]['name'] = $tag['name']; $article['tag_array'][$tk]['url'] = $tag['url']; $article['tag_array'][$tk]['link'] = $tag['link']; $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; }
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; }