Esempio n. 1
0
 function show_action() {
     $tagname=urldecode(front::get('tag'));
     if(preg_match('/union/i',$tagname) || preg_match('/"/i',$tagname) ||preg_match('/\'/i',$tagname)){
     	exit('非法参数');
     }
     $tag=new tag();
     $tag=$tag->getrow('tagname="'.$tagname.'"');
     $tagid=$tag['tagid'];
     $archives=array();
     if($tagid) {
         $arctag=new arctag();
         if(front::get('page')) $page=front::get('page');
         else $page=1;
         $this->view->page=$page;
         $this->view->pagesize=config::get('list_pagesize');
         $limit=(($this->view->page-1)*$this->view->pagesize).','.$this->view->pagesize;
         $this->view->record_count=$arctag->rec_count('tagid='.$tagid);
         if($this->view->record_count>$this->view->pagesize)
             $this->view->pages=true;
         front::$record_count=$this->view->record_count;
         $arctags=$arctag->getrows('tagid='.$tagid,$limit);
         $arcids=array();
         foreach($arctags as $arctag) {
             $arcids[]=$arctag['aid'];
         }
         $archive=new archive();
         $archives=$archive->getrows('aid in ('.implode(',',$arcids).')',null,'aid desc');
         foreach($archives as $order=>$arc) {
             $archives[$order]['url']=archive::url($arc);
             $archives[$order]['catname']=category::name($arc['catid']);
             $archives[$order]['caturl']=category::url($arc['catid']);
             $archives[$order]['adddate']= sdate($arc['adddate']);
             $archives[$order]['stitle']= strip_tags($arc['title']);
         }
     }
     else echo lang('标签信息不存在');
     $this->view->tag=$tagname;
     $this->view->archive['title'] = $tagname;
     $this->view->archives=$archives;
     if (front::get('t') == 'wap') {
     	echo $this->fetch('wap/tag_show.html');
     	return;
     }
     $this->render();
 }
 function save_after($aid) {
     //$tag=preg_replace('/\s+/',' ',trim(front::$post['tag']));
     $tags=explode(',',trim(front::$post['tag']));
     //var_dump($tags);
     $tag_table=new tag();
     $arctag_table=new arctag();
     foreach($tags as $tag) {
         if($tag)
             if(!$tag_table->getrow('tagname="'.$tag.'"'))
                 $tag_table->rec_insert(array('tagname'=>$tag));
         $tag=$tag_table->getrow('tagname="'.$tag.'"');
         $arctag_table->rec_replace(array('aid'=>$aid,'tagid'=>$tag['tagid']));
     }
     //exit;
     $doit = false;
     if(session::get('attachment_id') ||front::post('attachment_id')) {
         $attachment_id=session::get('attachment_id')?session::get('attachment_id'):front::post('attachment_id');
         $attachment=new attachment();
         $attachment->rec_update(array('aid'=>$aid,'intro'=>front::post('attachment_intro')),$attachment_id);
         $doit = true;
         if(session::get('attachment_id')) session::del('attachment_id');
     }
     if(front::post('attachment_path') != '' && $doit == false) {
         $attachment=new attachment();
         $attachment->rec_insert(array('aid'=>$aid,'path'=>front::post('attachment_path'),'intro'=>front::post('attachment_intro'),'adddate'=>date('Y-m-d H:i:s')));
         $doit = false;
     }
     if(front::post('_ranks')) {
         $_ranks=serialize(front::post('_ranks'));
         $rank=new rank();
         if(is_array($rank->getrow(array('aid'=>$aid))))
             $rank->rec_update(array('ranks'=>$_ranks),'aid='.$aid);
         else
             $rank->rec_insert(array('aid'=>$aid,'ranks'=>$_ranks));
     }
     else {
         $rank=new rank();
         $rank->rec_delete('aid='.$aid);
     }
     if(front::post('vote')) {
         $votes=front::$post['vote'];
         $images=front::$post['vote_image'];
         $vote=new vote();
         $_vote=$vote->getrow('aid='.$aid);
         if(!$_vote) $_vote=array('aid'=>$aid);
         $_vote['titles']=serialize($votes);
         $_vote['images']=serialize($images);
         $vote->rec_replace($_vote,$aid);
     }
 }
Esempio n. 3
0
 function make_tag_action() {
 	chkpw('cache_tag');
 	header('Cache-control: private, must-revalidate');
 	set_time_limit(0);
 	if(!front::$get['tag']){
 		front::$get['tag'] = front::$post['tag'];
 	}
 	if(!front::$get['submit']){
 		front::$get['submit'] = front::$post['submit'];
 	}
 	$otag=new tag();
 	$tags=$otag->getrows("",0);
 	//var_dump($tags);
 	$tags = $this->view->hottags = array_to_hashmap($tags,'tagid','tagname');
 	
 	if (!front::get('submit'))
 		return;
 	if(!config::get('tag_html')||!front::$get['tag']){
 		front::flash("没有设置生成html!");
 		front::redirect(front::$from);
 		return;
 	}
 	$tagid = front::$get['tag'];
 	$tag = $tags[$tagid];
 	$pinyin = pinyin::get($tag);
 	
 	$arctag=new arctag();
 	$archive_num=$arctag->rec_count('tagid='.$tagid);
 	front::$record_count = $archive_num;
 	$pagesize = config::get('list_pagesize');
 	front::$pages = $pagesize;
 	$cpage = ceil($archive_num/$pagesize);
 	$j=0;
 	for($i=1;$i<=$cpage;$i++){
 		$path = 'tags/'.$pinyin.'_'.$tagid.'_'.$i.'.html';
 		tool::mkdir(dirname($path));
 		$data = file_get_contents(config::get('site_url').'index.php?case=tag&act=show&tag='.urlencode($tag).'&page='.$i);
 		if(file_put_contents($path, $data)){
 			$j++;
 		}
 	}
 	if ($j > 0){
 		front::flash("成功生成html <b>$j</b> 页!");
 		front::redirect(front::$from);
 	}else{
 		front::flash("没有数据生成html!");
 		front::redirect(front::$from);
 	}
 }