Beispiel #1
0
 function do_action() {
     if(front::post('submit') &&front::post('vote') &&front::post('aid')) {
         front::check_type(front::post('aid'));
         if(!isset($this->view->user)) front::flash(lang('请登陆!'));
         $vote=new vote();
         $_vote=$vote->getrow('aid='.front::post('aid'));
         if(eregi($this->view->user['username'].',',$_vote['users'])) {
             front::flash(lang('不能重复投票!'));
             front::redirect(front::$from);
         }
         $_votes=$_vote['votes'];
         if(!$_votes) $_votes=array();
         else $_votes=unserialize($_votes);
         $_votes[front::post('vote')]=$_votes[front::post('vote')]+1;
         $votes=serialize($_votes);
         $vote_data=array_merge($_vote,array('votes'=>$votes,'aid'=>front::post('aid'),'users'=>$_vote['users'].$this->view->user['username'].','));
         $vote->rec_replace($vote_data,front::post('aid'));
         front::flash(lang('投票成功!'));
     }else {
         front::flash(lang('投票失败!'));
     }
     front::redirect(front::$from);
 }
 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);
     }
 }