function archive($catid='0',$typeid='0',$spid=0,$area='0,0,0',$length=20,$ordertype='aid',$limit=10,$image=false,$attr1=null,$son=true,$wheretype='',$tpl=null,$intro_len='0',$istop=0) {
    $_ordertype=$ordertype;
    $cache_id=md5($catid.$typeid.$spid.$area.$length.$ordertype.$limit.$son.$wheretype.$tpl.$intro_len.$istop);
    if ($ordertype == 'rand()')
        $cache_id=$cache_id.time();
    if (cache::get($cache_id))
        $archives=cache::get($cache_id);
    else {
        $ordertype=str_replace('-',' ',$ordertype);
        $wheretype=str_replace('-',' ',$wheretype);
        $order = 'listorder=0,listorder ASC ';
        if (preg_match('/^\w+$/',$ordertype))
            $order .= ','.$ordertype.' desc';
        elseif ($ordertype)
            $order .= ','.$ordertype;
        $where=array();
        if ($wheretype)
            foreach (explode(',',$wheretype) as $_wheretype)
                switch ($_wheretype) {
                    case 'day': $where[]='adddate>'.date('Y-m-d H:i:s',time() -3600 * 24);
                        break;
                    case 'week': $where[]='adddate>'.date('Y-m-d H:i:s',time() -3600 * 24 * 7);
                        break;
                    case 'month': $where[]='adddate>'.date('Y-m-d H:i:s',time() -3600 * 24 * 30);
                        break;
                    default:
                        if (preg_match('/commend=(\d+)/i',$_wheretype,$match))
                            $where[]=" attr1 REGEXP  '(^|,)$match[1](,|$)'  ";
                        else
                        if (preg_match('/^\w+$/',$_wheretype))
                            $where[]=$_wheretype."<>''";
                        else
                            $where[]=$_wheretype;
                        break;
                }
        if (!empty($where))
            $where=' and '.implode(' and ',$where);
        else
            $where='';
        $archive=archive::getInstance();
        $category=category::getInstance();
        $categories=array();
        if (isset($catid) &&$catid != '0') {
            $catid=explode('-',$catid);
            //var_dump($catid);
            $categories=$catid;
            $_categories1=array();
            if ($son) {
                
                foreach ($categories as $key=>$val) {
                    $_categories[$key]=$category->sons($val);
                    $_categories1=array_merge($_categories[$key],$_categories1);
                }
                //var_dump($_categories);
            }
            //var_dump($categories);
            $categories=array_merge($categories,$_categories1);
            //var_dump($categories);
        }
        //var_dump($categories);
        $type=type::getInstance();
        $types=array();
        if (isset($typeid) &&$typeid != '0') {
            $types[]=$typeid;
            if ($son) {
                $_types=$type->sons($typeid);
            }
            $types=array_merge($types,$_types);
        }
        $where='1';
        if (!empty($types))
            $where.=' and typeid in ('.implode(',',$types).')';
        if (!empty($categories))
            $where.=' and catid in ('.implode(',',$categories).')';
        if ($spid)
            $where.=' and spid='.$spid;
        list($province_id,$city_id,$section_id)=explode(',',$area);
        if ($province_id)
            $where.=' and province_id='.$province_id;
        if ($city_id)
            $where.=' and city_id='.$city_id;
        if ($section_id)
            $where.=' and section_id='.$section_id;
        if ($image)
            $where.=' and thumb <> "" ';
        if ($attr1)
            $where.=" and FIND_IN_SET('$attr1',attr1) ";
        if ($_ordertype == 'aid-asc') {
            $order .=',aid asc';
        }
        if ($_ordertype == 'new') {
        	$order .= ',adddate desc';
        }
        if($istop){
        	$tops = $archive->getrows($where." AND checked=1 AND state=1 AND toppost!=0",0,'toppost DESC,listorder=0,listorder ASC,aid DESC');
        }
        $archives = $archive->getrows($where.' AND state=1 AND checked=1',$limit-count($tops),$order,$archive->getcols('list'));
        
        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'] != $catid[0] && !in_array($catid[0], $subcatids)){
        				unset($tops[$order]);
        			}else{
        				$tops[$order]['title'] = "[栏目置顶]".$arc['title'];
        			}
        		}
        	}
        	$archives = array_merge($tops , $archives);
        }
        
        foreach ($archives as $order=>$arc) {
            if (!$arc['introduce'])
                $arc['introduce']=cut($arc['content'],$arc['introduce_len'] ?$arc['introduce_len'] : 200);
            $archives[$order]['url']=$arc['linkto'] ?$arc['linkto'] : archive::url($arc);
            $archives[$order]['catname']=category::name($arc['catid']);
            $archives[$order]['caturl']=category::url($arc['catid']);
            $archives[$order]['image']=@strstr($arc['image'],"http://") ?$arc['image'] : config::get('base_url').'/'.$arc['image'];
            $archives[$order]['adddate']=sdate($arc['adddate']);
            $archives[$order]['stitle']=strip_tags($arc['title']);
            $archives[$order]['title']=tool::cn_substr($arc['title'],$length);
            $archives[$order]['strgrade'] = archive::getgrade($arc['grade']);
            $archives[$order]['buyurl']=url('archive/orders/aid/'.$arc['aid']);
            $prices = getPrices($arc['attr2']);
            $archives[$order]['oldprice'] = $prices['oldprice'];
            $archives[$order]['attr2'] = $prices['price'];
            if(!$intro_len){
            	$archives[$order]['intro'] = '';
            }else if($intro_len == '-1'){
            	$archives[$order]['intro'] = $arc['introduce'];
            }else{
            	$archives[$order]['intro'] = cut($arc['introduce'],$intro_len);
            }
            if(strtolower(substr($arc['thumb'],0,7)) == 'http://'){
            	$archives[$order]['sthumb'] = $arc['thumb'];
            }else{
            	$archives[$order]['sthumb'] = config::get('base_url').'/'.$arc['thumb'];
            }
            if($arc['strong']){
                $archives[$order]['title'] = '<strong>'.$archives[$order]['title'].'</strong>';
            }
            if($arc['color'] !="#000000"){
                $archives[$order]['title'] = '<font style="color:'.$arc['color'].';">'.$archives[$order]['title'].'</font>';
            }
            cb_data($archives[$order]);
            /*if($arc['toppost'] == '3'){
                $tmp[] = $archives[$order];
                unset($archives[$order]);
            }
            if($arc['toppost'] == '2' && front::get('catid') == $arc['catid']) {
            	$tmp2[] = $archives[$order];
            	unset($articles[$order]);
            }*/
            
            /*foreach ($archives[$order] as $key => $value){
            	if(!preg_match('/^my/',$key) || !$value) continue;
            	$category = category::getInstance();
            	$sonids = $category->sons(setting::$var['archive'][$key]['catid']);
            	if(setting::$var['archive'][$key]['catid'] != $archive['catid'] && !in_array($archive['catid'],$sonids) && (setting::$var['archive'][$key]['catid'])){
            		unset($field[$key]);
                	continue;
                	$archives[$order][$key] = $value;
            	}
            }*/
        }
        /*if(is_array($tmp)){
            $archives = array_merge($tmp,$archives);
        }*/
        if ($ordertype != 'rand()')
            cache::set($cache_id,$archives);
    }
    //run::_start();
    if ($tpl) {
        front::$view->_var->articles=$archives;
        return template($tpl);
    }
    else
        return $archives;
}
Beispiel #2
0
” </span><?php 
echo lang(searchresults);
?>
:</h1></div><div class="r_box_bottom"></div></div>

<div id="content" class="clear">


<div class="blank30"></div>

<!-- 列表结束 -->
<ul class="news_list">
<?php 
if (is_array($articles) && !empty($articles)) {
    foreach ($articles as $article) {
        echo cb_data($article);
        ?>
<li>[<a href="<?php 
        echo $article['caturl'];
        ?>
"  target="_blank">&nbsp;<?php 
        echo $article['catname'];
        ?>
&nbsp;</a>]&nbsp;-&nbsp;<a href="<?php 
        echo $article['url'];
        ?>
"  target="_blank"><?php 
        if ($keyword) {
            echo str_replace($keyword, "<font style=color:red;font-weight:bold;>{$keyword}</font>", $article['title']);
        } else {
            echo $article['title'];
    function show_action() {
        if (!front::get('aid'))
            front::$get['aid'] = front::get('id');
        front::check_type(front::$get['aid']);
        $this->view->aid = trim(front::get('aid'));
        $this->view->archive = archive::getInstance()->getrow(front::get('aid'));
        $this->view->categorys = category::getpositionlink2($this->view->archive['catid']);
        if (!is_array($this->view->archive))
            $this->out('message/error.html');
        if ($this->view->archive['checked'] < 1)
            exit(lang('未审核!<a href="'.front::$from.'">返回</a>'));
        if (!rank::arcget(front::get('aid'), $this->view->usergroupid)) {
            $this->out('message/error.html');
        }
        $this->view->catid = $this->view->archive['catid'];
        $this->view->topid = category::gettopparent($this->view->catid);
        $this->view->parentid = $this->category->getparent($this->view->catid);
        if (!rank::catget($this->view->catid, $this->view->usergroupid))
            $this->out('message/error.html');
        if (!isset($this->category->category[$this->view->catid]) ||
                !isset($this->category->category[$this->view->topid])) {

        }
        $template = @$this->view->archive['template'];
        $linkword = new linkword();
        $linkwords = $linkword->getrows(null, 1000, 'linkorder desc');
        $content = $this->view->archive['content'];
        $contents = preg_split('%<div style="page-break-after(.*?)</div>%si', $content);
        if ($contents) {
            $this->view->pages = count($contents);
            front::$record_count = $this->view->pages * config::get('list_pagesize');
            $content = $contents[$this->view->page - 1];
        }

        //$content = preg_replace("/(<a(.*))(>)(.*)(<)(\/a>)/isU", '\\1-]-\\4-[-\\6', $content);

        foreach ($linkwords as $linkword) {
            $linkword['linktimes'] = (int) $linkword['linktimes'];
            if (trim($linkword['linkurl']) && !preg_match('%^http://$%', trim($linkword['linkurl']))) {
                $link = "<a href='$linkword[linkurl]' target='_blank'>$linkword[linkword]</a>";
            } else {
                $link = "<a href='" . url('archive/search/keyword/' . urlencode($linkword['linkword'])) . "' target='_blank'>$linkword[linkword]</a>";
            }
            $content = _keylinks($content,$linkword['linkword'],$link,$linkword['linktimes']);
        }

        $this->view->likenews = $this->getLike($this->view->archive['tag'], $this->view->archive['keyword']);

        $taghtml = '';
        $tag_table = new tag();
        foreach ($tag_table->urls($this->view->archive['tag']) as $tag => $url) {
            $taghtml.="<a href='$url' target='_blank'>$tag</a>&nbsp;&nbsp;";
        }
        $this->view->archive['tag'] = $taghtml;

        $this->view->archive['special'] = null;
        if ($this->view->archive['spid']) {
            $spurl = special::url($this->view->archive['spid'],special::getishtml($this->view->archive['spid']));
            $sptitle = special::gettitle($this->view->archive['spid']);
            $this->view->archive['special'] = "<a href='$spurl' target='_blank'>$sptitle</a>&nbsp;&nbsp;";
        }
        $this->view->archive['type'] = null;
        if ($this->view->archive['typeid']) {
            $typeurl = type::url($this->view->archive['typeid'],1);
            $typetitle = type::name($this->view->archive['typeid']);
            $this->view->archive['type'] = "<a href='$typeurl' target='_blank'>$typetitle</a>&nbsp;&nbsp;";
        }
        $this->view->archive['area'] = null;
        $this->view->archive['area'] = area::getpositonhtml($this->view->archive['province_id'], $this->view->archive['city_id'], $this->view->archive['section_id']);
        $this->view->archive['content'] = $content;
        $aid = front::$get['aid'];
        $catid = $this->view->catid;
        if(!$this->view->archive['showform']) {
            $this->getshowform($catid);
        }else if($this->view->archive['showform'] && $this->view->archive['showform'] == '1') {
            $this->showform = 1;
        }else {
            $this->showform = $this->view->archive['showform'];
        }
        if(preg_match('/^my_/is',$this->showform)) {
            $this->view->archive['showform'] = $this->showform;
            $o_table = new defind($this->showform);
            front::$get['form'] = $this->showform;
            $this->view->primary_key = $o_table->primary_key;
            $field = $o_table->getFields();
            $fieldlimit = $o_table->getcols('user_modify');
            helper::filterField($field,$fieldlimit);
            $this->view->field = $field;
        }else {
            $this->view->archive['showform'] = '';
        }
        
        $str = "";
        cb_data($this->view->archive);
        foreach( $this->view->archive as $key => $value){
        	if(!preg_match('/^my/',$key) || !$value)
        		continue;
        	$category = category::getInstance();
        	$sonids = $category->sons(setting::$var['archive'][$key]['catid']);
        	if(setting::$var['archive'][$key]['catid'] != $this->view->archive['catid'] && !in_array($this->view->archive['catid'],$sonids) && (setting::$var['archive'][$key]['catid'])){
        		unset($this->view->field[$key]);
        		continue;
        	}
        	$str .= '<p> '.setting::$var['archive'][$key]['cname'].':'. $value.'</p>';
        }
        $this->view->archive['my_fields'] = $str;

        $sql1 = "SELECT aid,title,catid FROM `{$this->archive->name}` WHERE catid = '$catid' AND aid > '$aid' ORDER BY aid ASC LIMIT 0,1";
        $sql2 = "SELECT aid,title,catid FROM `{$this->archive->name}` WHERE catid = '$catid' AND aid < '$aid' ORDER BY aid DESC LIMIT 0,1";
        $n = $this->archive->rec_query_one($sql1);
        $p = $this->archive->rec_query_one($sql2);
        $this->view->archive['p'] = $p;
        $this->view->archive['n'] = $n;
        $this->view->archive['p']['url'] = archive::url($p);
        $this->view->archive['n']['url'] = archive::url($n);

        $this->view->archive['strgrade'] = archive::getgrade($this->view->archive['grade']);
        $prices = getPrices($this->view->archive['attr2']);
        $this->view->archive['attr2'] = $prices['price'];
        $this->view->archive['oldprice'] = $prices['oldprice'];
		$this->view->groupname = $prices['groupname'];
		
		//$this->view->archive['pics'] = unserialize($this->view->archive['pics']);
		if(is_array($this->view->archive['pics']) && !empty($this->view->archive['pics'])){
			foreach ($this->view->archive['pics'] as $k => $v){
				if(strtolower(substr($v,0,7)) == 'http://'){
					$this->view->archive['pics'][$k] = $v;
				}else{
					$this->view->archive['pics'][$k] = $v;
				}
			}
		}
		//$this->view->archive['pics'] = unserialize($this->view->archive['pics']);
		//var_dump($this->view->archive);

        if (front::get('t') == 'wap') {
        	$tpl = category::gettemplate($this->view->catid, 'showtemplatewap');
        	if(!$tpl) $tpl = 'wap/show.html';
            $this->out($tpl);
            return;
        }

        if ($template && file_exists(TEMPLATE . '/' . $this->view->_style . '/' . $template))
            $this->out($template);
        else {
            $tpl = category::gettemplate($this->view->catid, 'showtemplate');
            if (category::getarcishtml($this->view->archive)) {
                $path = ROOT . archive::url($this->view->archive);
                if (!preg_match('/\.[a-zA-Z]+$/', $path))
                    $path = rtrim(rtrim($path, '/'), '\\') . '/index.html';
                $this->cache_path = $path;
            }
            $this->out($tpl);
        }
    }
 function make_show_action() {
     header('Cache-control: private, must-revalidate');
     @set_time_limit(0);
     $submit = front::post('submit') ? front::post('submit') : front::get('submit');
     if (!$submit)
         return;
     chkpw('cache_content');
     //time::start();
     $post = front::$post + front::$get;
     unset($post['submit']);
     $c_url = preg_replace('#&make_page=(\d+)#', '', $_SERVER['QUERY_STRING']);
     $c_url = preg_replace('#&aid_start=(\d+)#', '', $c_url);
     $c_url = preg_replace('#&aid_end=(\d+)#', '', $c_url);
     $c_url = preg_replace('#&catid=(\d+)#', '', $c_url);
     $c_url = preg_replace('#&submit=(\d+)#', '', $c_url);
     $c_url = 'index.php?' . $c_url;
     $c_url.='&submit=1';
     
     $category = category::getInstance(); //实例化栏目类
     
     if ($post['aid_start']) {
         $aid_start = $post['aid_start'];
         $aid_end = $post['aid_end'];
         $where = "aid>=$aid_start and aid<=$aid_end AND checked=1 AND (ishtml IS NULL OR ishtml!=2)";
         $c_url.='&aid_start=' . $aid_start . '&aid_end=' . $aid_end;
     } elseif (isset($post['catid'])) {
         $catid = $post['catid'];
         $categories = $category->sons($catid);
         $categories[] = $catid;
         $categories = implode(',', $categories);
         $where = "catid in(" . $categories . ') and checked=1 AND (ishtml IS NULL OR ishtml!=2)';
         $c_url.='&catid=' . $catid;
     }else
         return;
     $case = 'archive';
     $act = 'show';
     $_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';
     //$time_start = time::getTime();
     
     $archive = new archive(); //实例化文章类
     
     if (config::get('group_on')) { //启用分组生成
         $make_page = $post['make_page'] == '' ? 1 : $post['make_page'];
         $archive->getrows($where);
         $archive_num = $archive->record_count;
         $group_count = config::get('group_count');
         $make_page_num = ceil($archive_num / $group_count);
         $totalpage = (($make_page - 1) * $group_count) . ',' . $group_count;
         $c_url.='&make_page=' . ($make_page + 1);
     } else {
         $totalpage = "";
     }
     
     $archives = $archive->getrows($where, $totalpage, '1'); //取到要生成的所有文章
     
     $cpage = 0;
     foreach ($archives as $arc) {
         if (!category::getarcishtml($arc))  //如果文章设置不生成则跳过
             continue;
         if($arc['linkto']){ //如果有跳转连接则跳过生成
         	continue;
         }
         $case->view->archive = $arc;
         front::$get['aid'] = $case->view->aid = $case->view->archive['aid'];
         $case->view->catid = $case->view->archive['catid'];
         
         $case->view->topid = category::gettopparent($case->view->catid);
         $case->view->parentid = $category->getparent($case->view->catid);
         
         $template = $case->view->archive['template'];
         $content = $case->view->archive['content'];
         
         $case->view->categories = category::getpositionlink2($case->view->catid);
         
         //关键字连接
         $linkword = new linkword();
         $linkwords = $linkword->getrows(null, 1000, 'linkorder desc');
         foreach ($linkwords as $linkword) {
             if (trim($linkword['linkurl']) && !preg_match('%^http://$%', trim($linkword['linkurl']))) {
                 $linkword['linktimes'] = (int) $linkword['linktimes'];
                 $link = "<a href='$linkword[linkurl]' target='_blank'>$linkword[linkword]</a>";
             } else {
                 $link = "<a href='" . url('archive/search/keyword/' . urlencode($linkword['linkword'])) . "' target='_blank'>$linkword[linkword]</a>";
             }
             if (isset($link)) {
                 $content = preg_replace("%(?!\"]*>)$linkword[linkword](?!\s*\")%i", "\\1$link\\2", $content, $linkword['linktimes']);
             }
             unset($link);
         }
         
         //相关文章
         $case->view->likenews = $case->getLike($case->view->archive['tag'], $case->view->archive['keyword']);
         
         //内容分页
         $contents = preg_split('%<div style="page-break-after(.*?)</div>%si', $content);
         if (!empty($contents)) {
             $case->view->pages = count($contents);
             front::$record_count = $case->view->pages * config::get('list_pagesize');
             $case->view->pages = count($contents);
         } else {
             $case->view->pages = 1;
         }
         
         //标签连接
         $taghtml = '';
         $tag_table = new tag();
         foreach ($tag_table->urls($case->view->archive['tag']) as $tag => $url) {
             $taghtml.="<a href='$url' target='_blank'>$tag</a>&nbsp;&nbsp;";
         }
         $case->view->archive['tag'] = $taghtml;
         
         //专题连接
         $case->view->archive['special'] = null;
         if ($case->view->archive['spid']) {
             $spurl = special::url($case->view->archive['spid'],special::getishtml($case->view->archive['spid']));
             $sptitle = special::gettitle($case->view->archive['spid']);
             $case->view->archive['special'] = "<a href='$spurl' target='_blank'>$sptitle</a>&nbsp;&nbsp;";
         }
         
         //分类连接
         $case->view->archive['type'] = null;
         if ($case->view->archive['typeid']) {
             $typeurl = type::url($case->view->archive['typeid'],1);
             $typetitle = type::name($case->view->archive['typeid']);
             $case->view->archive['type'] = "<a href='$typeurl' target='_blank'>$typetitle</a>&nbsp;&nbsp;";
         }
         
         //地区连接
         $case->view->archive['area'] = null;
         $case->view->archive['area'] = area::getpositonhtml($case->view->archive['province_id'], $case->view->archive['city_id'], $case->view->archive['section_id']);
         
         //$arc = $case->view->archive;
         for ($c = 1; $c <= $case->view->pages; $c++) {
             front::$get['page'] = $c;
             $case->view->page = $c;
             if (!empty($contents)) {
                 $content = $contents[$c - 1];
             }
             $case->view->archive['content'] = $content;
             
             //自定义字段
             cb_data($case->view->archive);
             $str = "";
             foreach( $case->view->archive as $key => $value){
             	if(!preg_match('/^my/',$key) || !$value)
             		continue;
             	$sonids = $category->sons(setting::$var['archive'][$key]['catid']);
             	$sonids[] = setting::$var['archive'][$key]['catid'];
             	if(!in_array($case->view->archive['catid'],$sonids) && intval(setting::$var['archive'][$key]['catid'])){
             		//unset($case->view->field[$key]);
             		continue;
             	}
             	$str .= '<p> '.setting::$var['archive'][$key]['cname'].':'. $value.'</p>';
             }
             $arc['my_fields'] = $str;
             
             //上一篇,下一篇
             $aid = $case->view->archive['aid'];
             $catid = $case->view->archive['catid'];
             $sql1 = "SELECT * FROM `{$archive->name}` WHERE catid = '$catid' AND aid > '$aid' ORDER BY aid ASC LIMIT 0,1";
             $sql2 = "SELECT * FROM `{$archive->name}` WHERE catid = '$catid' AND aid < '$aid' ORDER BY aid DESC LIMIT 0,1";
             $n = $archive->rec_query_one($sql1);
             $p = $archive->rec_query_one($sql2);
             $case->view->archive['p'] = $p;
             $case->view->archive['n'] = $n;
             $case->view->archive['p']['url'] = archive::url($p);
             $case->view->archive['n']['url'] = archive::url($n);
             
             //评级
             $case->view->archive['strgrade'] = archive::getgrade($arc['grade']);
             
             //图片
             $case->view->archive['pics'] = unserialize($case->view->archive['pics']);
             if(is_array($case->view->archive['pics']) && !empty($case->view->archive['pics'])){
             	foreach ($case->view->archive['pics'] as $k => $v){
             		if(strtolower(substr($v,0,7)) == 'http://'){
             			$case->view->archive['pics'][$k] = $v;
             		}else{
             			$case->view->archive['pics'][$k] = $v;
             		}
             	}
             }
             $case->view->archive['pics'] = serialize($case->view->archive['pics']);
             
             if ($template && file_exists(TEMPLATE . '/' . $case->view->_style . '/' . $template))
                 $tpl = $template;
             else
                 $tpl = category::gettemplate($case->view->catid, 'showtemplate');
             $content = $case->fetch($tpl);
             $path = ROOT . archive::url($case->view->archive, 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);
             $cpage++;
             if ($case->view->pages > 1 && $c == 1) {
                 $path = ROOT . archive::url($case->view->archive, 1, 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('logs.txt', file_get_contents('logs.txt')."\r\n".$path);
                 $f = fopen($path,'w');
                 fwrite($f, $content);
                 fclose($f);
                 $cpage++;
             }
         }
     }
     $totalpage = count($archives);
     if (!isset($archives[0]))
         $totalpage = 0;
     if ($make_page >= $make_page_num) {
         $show_msg = "本组生成html <b>{$cpage}</b> 页!  生成html完毕,本次共生成 <b>{$archive_num}</b> 页! 3秒后自动返回内容生成首页面!\n";
         $c_url = preg_replace('#&make_page=(\d+)#', '', $_SERVER['QUERY_STRING']);
         $c_url = preg_replace('#&aid_start=(\d+)#', '', $c_url);
         $c_url = preg_replace('#&aid_end=(\d+)#', '', $c_url);
         $c_url = preg_replace('#&catid=(\d+)#', '', $c_url);
         $c_url = preg_replace('#&submit=(\d+)#', '', $c_url);
         $c_url = 'index.php?' . $c_url;
     } else {
         $show_msg = "第 <b>{$make_page}</b> 组成功生成html <b>{$cpage}</b> 页! 本次共需生成 <b>{$archive_num}</b> 页! 已经生成 <b>" . ($make_page * $group_count) . "</b> 页! 3秒后自动跳入下组生成!\n";
     }
     $getnexturl = "<script>";
     $getnexturl.="var t=4;\n";
     $getnexturl.="setInterval('testTime()',3000);\n";
     $getnexturl.="function testTime() \n";
     $getnexturl.=" { \n";
     $getnexturl.="if(t == 0) location = '" . $c_url . "'; \n";
     $getnexturl.=" t--;\n";
     $getnexturl.="}\n</script> \n";
     if ($cpage > 0) {
         if (!config::get('group_on')) {
             front::flash("成功生成html <b>{$cpage}</b> 页!用时".time::getTime()."!\n");
         } else {
             front::flash($show_msg . "\n" . $getnexturl);
         }
     } else {
         front::flash("没有需要生成的html,可能您选择的栏目暂无内容或者网站并未开启内容生成静态功能!");
     }
     front::$admin = true;
     front::$post = $post;
 }