Пример #1
0
    function init() {
        $this->archive = new archive();
        $this->category = category::getInstance();
        $this->view->category = $this->category->category;
        if (front::get('page'))
            $page = front::get('page');
        else
            $page = 1;
        $this->view->page = $page;
        front::check_type($page);
        $_catpage = category::categorypages(front::get('catid'));
        if ($_catpage) {
            $this->pagesize = $_catpage;
        } else {
            $this->pagesize = config::get('list_pagesize');
        }
        front::check_type($this->pagesize);
        $announcement = new announcement();
        $this->view->announcements = $announcement->getrows(null, 10);
        $this->view->usergroupid = 1000;
        front::check_type(cookie::get('login_username'), 'safe');
        front::check_type(cookie::get('login_password'), 'safe');
        $this->view->showarchive = archive::getInstance()->getrow(front::get('aid'));
        $addcontentuser = new user();
        $addcontentuser = $addcontentuser->getrow(array('userid' => $this->view->showarchive['userid']));
        if (is_array($addcontentuser)) {
            $this->view->adduser = $addcontentuser;
        }
        if (cookie::get('login_username') && cookie::get('login_password')) {
            $user = new user();
            $user = $user->getrow(array('username' => cookie::get('login_username')));
            if (is_array($user) && cookie::get('login_password') == front::cookie_encode($user['password'])) {
                $this->view->user = $user;
                $this->view->usergroupid = $user['groupid'];
				$obj = new usergroup();
				$this->roles = $obj->getrow(array('groupid'=>$this->view->usergroupid));
            }
        }
    }
Пример #2
0
 static function pages($record_count=0,$page_show=10) {
     $pa=self::getme();
     $pa->record_count=$record_count;
     $pa->page_show=$page_show;
     $_catpage=category::categorypages(front::$view->_var->catid);
     if ($_catpage) {
         $pa->page_size=$_catpage;
     }
     else {
         $pa->page_size=config::get('list_pagesize');
     }
     return $pa->put_array();
 }
Пример #3
0
    function make_list_action() {
    	$servip = gethostbyname($_SERVER['SERVER_NAME']);
    	if($servip==front::ip()&&front::get('ishtml')==1){
    	
    	}else{
    		chkpw('cache_category');
    	}
        header('Cache-control: private, must-revalidate');
        @set_time_limit(0);
        if (!front::post('submit'))
            return;
        $case = 'archive';
        $act = 'list';
        $_GET = array('case' => $case, 'act' => $act);
        $front = new front();
        front::$admin = false;
        front::$html = true;
        front::$rewrite = false;
        $case = $case . '_act';
        $case = new $case();
        $case->init();
        $method = $act . '_action';
        $totalpage = 100;
        $time_start = time::getTime();
        $category = category::getInstance();
        $categories = $category->sons(front::post('catid'));
        $categories[] = front::post('catid');
        $cpage = 0;
        $archive_all = new archive();
        foreach ($categories as $key => $catid) {
            $new_categories = $category->sons($catid);
            $new_categories[] = $catid;
            $archive_num[$catid] = $archive_all->rec_count('catid in(' . implode(',', $new_categories) . ') and checked=1 and `state`=1');
        }
        $i = 0;
        foreach ($categories as $catid) {
            if ($catid == 0)
                continue;
            if (!category::getishtml($catid))
                continue;
            front::$get['catid'] = $catid;
            $case->view->categories = category::getpositionlink2($catid);
            $_categories = $category->sons($catid);
            $_categories[] = $catid;
            $case->view->ifson = category::hasson($catid);
            for (front::$get['page'] = 1;; front::$get['page']++) {
                $view = $case->view;
                $_catpage = category::categorypages($catid);
                if ($_catpage) {
                    $pagesize = $_catpage;
                } else {
                    $pagesize = config::get('list_pagesize');
                }
                $limit = ((front::$get['page'] - 1) * $pagesize) . ',' . $pagesize;
                
                $archive = new archive();
                
                $tops = array();
                $tops = $archive->getrows("checked=1 AND state=1 AND toppost!=0",0,'toppost DESC,listorder=0,listorder ASC,aid DESC');
                
                if (@$category->category[$catid]['includecatarchives']) {
                    $case->view->archives = $archive->getrows('catid in(' . implode(',', $_categories) . ') and checked=1 and `state`=1', $limit, 'listorder=0,`listorder` asc,`adddate` DESC');
                } else {
                    $case->view->archives = $archive->getrows("catid=$catid and checked=1 and `state`=1", $limit, 'listorder=0,`listorder` asc,`adddate` DESC');
                }
                $case->view->page = front::$get['page'];

                if(is_array($tops) && !empty($tops)){
                	foreach($tops as $order => $arc){
                		if($arc['toppost'] == 3){
                			$tops[$order]['title'] = "[全站置顶]".$arc['title'];
                		}
                		if($arc['toppost'] == 2){
                			$subcatids = $category->sons($arc['catid']);
                			if($arc['catid'] != front::get('catid') && !in_array(front::get('catid'), $subcatids)){
                				unset($tops[$order]);
                			}else{
                				$tops[$order]['title'] = "[栏目置顶]".$arc['title'];
                			}
                		}
                	}
                	$case->view->archives = array_merge($tops , $case->view->archives);
                }
                
                foreach ($case->view->archives as $order => $arc) {
                    $articles = $arc;
                    if (!$arc['introduce'])
                        $arc['introduce'] = cut($arc['content'], 200);
                    $articles['url'] = archive::url($arc);
                    $articles['catname'] = category::name($arc['catid']);
                    $articles['caturl'] = category::url($arc['catid']);
                    $articles['image'] = @strstr($arc['image'], "http://") ? $arc['image'] : config::get('base_url') . '/' . $arc['image'];
                    $articles['strgrade'] = archive::getgrade($arc['grade']);
                    $articles['adddate'] = sdate($arc['adddate']);
                    $articles['buyurl'] = url('archive/orders/aid/' . $arc['aid']);
                    $articles['stitle'] = strip_tags($arc['title']);
                    if(strtolower(substr($arc['thumb'],0,7)) == 'http://'){
                    	$articles['sthumb'] = $arc['thumb'];
                    }else{
                    	$articles['sthumb'] = config::get('base_url').'/'.$arc['thumb'];
                    }
                    
                    if($arc['strong']) {
                    	$articles['title'] = '<strong>'.$arc['title'].'</strong>';
                    }
                    if($arc['color']) {
                    	$articles['title'] = '<font style="color:'.$arc['color'].';">'.$articles['title'].'</font>';
                    }
                    
                    $case->view->archives[$order] = $articles;
                }
                
                if (!isset($page_count)) {
                    front::$record_count = $case->view->record_count = $archive_num[$catid];
                    $case->view->page_count = ceil($case->view->record_count / $pagesize);
                    $page_count = $case->view->page_count;
                }
                $case->view->catid = $catid;
                $case->view->topid = category::gettopparent($catid);
                $case->view->parentid = $category->getparent($catid);
                $case->view->pages = @$category->category[$catid]['ispages'];
                
                if (front::get('page') > 1 && front::get('page') > $case->view->page_count) {
                    $page_count = null;
                    break;
                }
                if (front::get('page') > 1 && !@$category->category[$catid]['ispages']) {
                    $page_count = null;
                    break;
                }
                $template = @$category->category[$catid]['template'];
                
                if ($template && file_exists(TEMPLATE . '/' . $case->view->_style . '/' . $template))
                    $tpl = $template;
                else
                    $tpl = category::gettemplate($case->view->catid);
                $content = $case->fetch($tpl);
                $path = ROOT . category::url($catid, front::$get['page'] > 1 ? front::$get['page'] : null, true);
                if (!preg_match('/\.[a-zA-Z]+$/', $path))
                    $path = rtrim(rtrim($path, '/'), '\\') . '/index.html';
                $path = rtrim($path, '/');
                $path = rtrim($path, '\\');
                $path = str_replace('//', '/', $path);
                tool::mkdir(dirname($path));
                file_put_contents($path, $content);
                $indexpath = dirname($path) . '/index.html';
                if (front::$get['page'] == 1 && $indexpath != ROOT . '/index.html') {
                    file_put_contents($indexpath, $content);
                    $cpage++;
                }
                $cpage++;
                $case->view = $view;
                $case->view->archives = null;
            }
            $i++;
        }
        if ($cpage > 0)
            front::flash("成功生成html <b>$cpage</b> 页!");
        else
            front::flash("没有生成html!");
        front::$admin = true;
    }
Пример #4
0
function index_archive($catid) {
    $index_archive = new archive();
    $index_category = category::getInstance();
    $index_view_category = $index_category->category;
    if (front::get('page'))
        $page = front::get('page');
    else
        $page = 1;
    $index_view_page = $page;
    front::check_type($page);
    $_catpage = category::categorypages($catid);
    if ($_catpage) {
        $index_pagesize = $_catpage;
    } else {
        $index_pagesize = config::get('list_pagesize');
    }
    front::check_type($index_pagesize);
    $index_view_categorys = category::getpositionlink2($catid);
    $topid = category::gettopparent($catid);
    if (!isset($index_category->category[$catid]) ||
            !isset($index_category->category[$topid])) {
        $this->out('message/error.html');
    }
    $limit = (($index_view_page - 1) * $index_pagesize) . ',' . $index_pagesize;
    $categories = array();
    if (@$index_category->category[$catid]['ispages'])
        $categories = $index_category->sons($catid);
    $categories[] = $catid;
    $index_view_pages = @$index_category->category[$catid]['ispages'];
    if (!rank::catget($catid, $index_view_usergroupid))
        $this->out('message/error.html');
    $order = "`listorder` asc,`adddate` DESC";
    if (@$index_category->category[$catid]['includecatarchives'])
        $articles = $index_archive->getrows('catid in (' . implode(',', $categories) . ') and checked=1', $limit, $order);
    else
        $articles = $index_archive->getrows('catid=' . $catid . ' and checked=1', $limit, $order);
    if (!is_array($articles)) {
        $this->out('message/error.html');
    }
    foreach ($articles as $order => $arc) {
        $articles[$order]['url'] = archive::url($arc);
        $articles[$order]['catname'] = category::name($arc['catid']);
        $articles[$order]['caturl'] = category::url($arc['catid']);
        $articles[$order]['adddate'] = sdate($arc['adddate']);
        $articles[$order]['stitle'] = strip_tags($arc['title']);
        $articles[$order]['strgrade'] = archive::getgrade($arc['grade']);
    }
    $index_view_archives = $articles;
    if (@$index_category->category[$catid]['includecatarchives'])
        $index_view_record_count = $index_archive->rec_count('catid in(' . implode(',', $categories) . ')');
    else
        $index_view_record_count = $index_archive->rec_count('catid=' . $catid);
    front::$record_count = $index_view_record_count;
    return $index_view_archives;
}