function delete_action() {
 	chkpw('defined_form_del');
     $table=new defind(front::get('table'));
     $delete=archive::getInstance()->query("DROP TABLE {$table->name}");
     if($delete)  front::flash("删除表单成功!");
     front::redirect(url::modify('act/listform/table/'.$table->name));
 }
    function add_action() {
        if(front::post('submit') &&front::post('aid')) {
        	if(config::get('verifycode')) {
	            if(front::post('verify')<>session::get('verify')) {
	                 alertinfo('验证码错误。', front::$from);
	                //front::redirect(front::$from);
	            }
        	}
            if(!front::post('username')) {
                /*front::flash(lang('请留下你的名字!'));
                front::redirect(front::$from);*/
            	alertinfo('请留下你的名字!', front::$from);
            }
            if(!front::post('content')) {
                /*front::flash(lang('请填写评论内容!'));
                front::redirect(front::$from);*/
                alertinfo('请填写评论内容!', front::$from);
            }
            $this->manage->filter();
            $comment=new comment();
            $archive=new archive();
            front::$post['state'] = '0';
            front::$post['adddate']=date('Y-m-d H:i:s');
            $comment->rec_insert(front::$post);
            $archive->rec_update('comment=comment+1',front::post('aid'));
            //front::flash(lang('提交成功!'));
            alertinfo('评论提交成功。', front::$from);
            //front::redirect(front::$from);
        }else {
            front::flash(lang('提交失败!'));
            front::redirect(front::$from);
        }
    }
 function dorestore_action() {
     $dir=ROOT.'/data/'.front::get('db_dir');
     if(is_dir($dir)) {
         $db_files=front::scan($dir);
         foreach($db_files as $db_file) {
             if(!preg_match('/^\./',$db_file)) tdatabase::getInstance()->restoreTables($dir.'/'.$db_file);
         }
         front::flash('数据库还原成功!');
     }
     front::redirect(url::create('database/restore'));
 }
 function deleteimg_action() {
     if (!front::get('dir') || !front::get('imgname'))
         return;
     $img = ROOT . '/upload/images/' . front::get('dir') . '/' . str_replace('___', '.', front::get('imgname'));
     if (!file_exists($img))
         front::flash('图片不存在');
     if (!unlink($img))
         front::flash('删除失败,请检查权限');
     else
         front::flash('图片已删除');
     front::redirect(url::modify('act/listimg/dir/' . front::get('dir')));
 }
 function logout_action() {
     cookie::del('login_username');
     cookie::del('login_password');
     session::del('username');
     session::del('roles');
     require_once ROOT.'/celive/include/config.inc.php';
     require_once ROOT.'/celive/include/celive.class.php';
     $login=new celive();
     $login->auth();
     $GLOBALS['auth']->logout();
     $GLOBALS['auth']->check_logout1();
     front::redirect(url::create('index'));
 }
 function delete_before() {
     $user = new user();
     $row = $user->getrow(front::get('id'));
     if($row['username'] == config::get('install_admin')) {
         front::flash("不能删除安装管理员!");
         front::redirect(front::$from);
     }
     if(front::get('id')==front::$user['userid']) {
         front::flash("不能删除当前用户!");
         front::redirect(front::$from);
     }
     if(is_array(front::post('select')) &&in_array(front::$user['userid'],front::post('select'))) {
         front::flash("不能删除当前用户!");
         front::redirect(front::$from);
     }
 }
Beispiel #7
0
 function check_admin() {
     if (cookie::get('login_username')&&cookie::get('login_password')) {
         $user=new user();
         $user=$user->getrow(array('username'=>cookie::get('login_username')));
         $roles = session::get('roles');
         if ($roles && is_array($user)&&cookie::get('login_password')==front::cookie_encode($user['password'])) {
             $this->view->user=$user;
             front::$user=$user;
         }else{
         	$user=null;
         }
     }
     if (!isset($user)||!is_array($user)) {
         front::redirect(url::create('admin/login'));
     }
 }
Beispiel #8
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);
 }
Beispiel #9
0
    function register_action() {
        if(front::post('submit')) {
            if(!config::get('reg_on')) {
                front::flash(lang('网站已经关闭注册!'));
                return;
            }
            if(config::get('verifycode')) {
                if(!session::get('verify') ||front::post('verify')<>session::get('verify')) {
                    front::flash(lang('验证码错误!'));
                    return;
                }
            }
            if(front::post('username') != strip_tags(front::post('username'))
                    ||front::post('username') != htmlspecialchars(front::post('username'))
            ) {
                front::flash(lang('用户名不规范!'));
                return;
            }
            if(strlen(front::post('username'))<4) {
                front::flash(lang('用户名太短!'));
                return;
            }
            if(strlen(front::post('e_mail'))<1) {
                front::flash(lang('请填写邮箱!'));
                return;
            }
			if(strlen(front::post('tel'))<1) {
                front::flash(lang('请填写手机号码!'));
                return;
            }
		
			
            if(front::post('username') &&front::post('password')) {
                $username=front::post('username');
                $password=md5(front::post('password'));
                $e_mail=front::post('e_mail');
                $tel=front::post('tel');
                if(!preg_match('/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/', front::ip())&&!preg_match('@^\s*((([0-9A-Fa-f]{1,4}:){7}(([0-9A-Fa-f]{1,4})|:))|(([0-9A-Fa-f]{1,4}:){6}(:|((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})|(:[0-9A-Fa-f]{1,4})))|(([0-9A-Fa-f]{1,4}:){5}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){0,1}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){0,2}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){0,3}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:)(:[0-9A-Fa-f]{1,4}){0,4}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(:(:[0-9A-Fa-f]{1,4}){0,5}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})))(%.+)?\s*$@', front::ip())){
                	exit('来源非法');
                }
                $data=array(
                        'username'=>$username,
                        'password'=>$password,
                        'e_mail'=>$e_mail,
                        'tel'=>$tel,
                        'groupid'=>101,
                        'userip'=>front::ip()
                );
                //phpox 2011-06-10
                foreach($this->view->field as $f){
                    $name=$f['name'];
                    if(!preg_match('/^my_/',$name)) {
                        unset($field[$name]);
                        continue;
                    }
                    if(!setting::$var['user'][$name]['showinreg']) {
                        continue;
                    }
                    $data[$name] = front::post($name);
                }
                if($this->_user->getrow(array('username'=>$username))) {
                    front::flash(lang('该用户名已被注册!'));
                    return;
                }
                $insert=$this->_user->rec_insert($data);
                $_userid = $this->_user->insert_id();
                if($insert){
                    if(config::get('sms_on') && config::get('sms_reg_on')){
                        sendMsg($tel,config::get('sms_reg'));
                    }
                    $cmsname = config::get('sitename');
                    if(config::get('email_reg_on')){
                    	$this->sendmail($e_mail,"欢迎注册 $cmsname !",lang('尊敬的').$username.', '.lang('您好!欢迎你注册'.$cmsname.'!'));
                    }
                    
                    front::flash(lang('注册成功!'));
                }else {
                    front::flash(lang('注册失败!'));
                    return;
                }
                if(union::getconfig('enabled')) {
                    $union_visitid = intval(cookie::get('union_visitid'));
                    $union_userid = intval(cookie::get('union_userid'));
                    if($union_visitid &&$union_userid) {
                        $union_reg = new union();
                        $r = $union_reg->getrow(array('userid'=>$union_userid));
                        if($r) {
                            $union_reg->rec_update(array('registers'=>'[registers+1]'),array('userid'=>$union_userid));
                            if($union_reg->affected_rows()) {
                                $union_visit_reg = new union_visit();
                                $union_visit_reg->rec_update(array('regusername'=>front::post('username'),'regtime'=>time()),array('visitid'=>$union_visitid));
                                $this->_user->rec_update(array('introducer'=>$union_userid),array('userid'=>$_userid));
                                $regrewardtype = union::getconfig('regrewardtype');
                                $regrewardnumber = union::getconfig('regrewardnumber');
                                switch($regrewardtype) {
                                    case 'point':
                                        union::pointadd($r['username'],$regrewardnumber,'union');
                                        break;
                                }
                            }
                        }
                    }
                }
                $user=$data;
                cookie::set('login_username',$user['username']);
                cookie::set('login_password',front::cookie_encode($user['password']));
                session::set('username',$user['username']);
                front::redirect(url::create('user'));
                exit;
            }
            else {
                front::flash(lang('注册失败!'));
                return;
            }
        }
    }
    static function get() {
        if (front::get('mod')) {
            $mod=front::get('mod');
            session::set('mod',$mod);
        }
        if (front::get('act')) {
            $act=front::get('act');
            session::set('act',$act);
        }
        if (front::get('table')) {
            $table=front::get('table');
            session::set('table',$table);
        }
        if (front::get('set')) {
            $set=front::get('set');
            session::set('set',$set);
        }
        if (front::get('tagfrom')) {
            $tagfrom=front::get('tagfrom');
            session::set('tagfrom',$tagfrom);
        }
        if (front::get('item')) {
            $item=front::get('item');
            session::set('item',$item);
        }
        if (front::get('item')) {
            $item=front::get('item');
            session::set('item',$item);
        }
        $mod=session::get('mod');
        $menu = array();
        switch ($mod) {
            case 'system':
                $menu=self::fetch('网站设置,数据库管理,数据维护');
                break;
            case 'config':
            	$menu=self::fetch('网站设置,多站点设置');
                break;
            case 'content':
                $menu=self::fetch('栏目管理,内容管理,分类管理,专题管理');
                break;
            case 'cache':
                $menu=self::fetch('生成管理,手机版生成');
                break;
            case 'order':
                $menu=self::fetch('订单管理');
                break;
            case 'celive':
                $menu=self::fetch('客服系统管理,客服中心,账号管理,生成代码');
                break;
            case 'user':
                $menu=self::fetch('用户管理,用户组管理,推广联盟');
                break;
            case 'func':
                $menu=self::fetch('公告管理,留言评论,投票管理,数据管理,网站安全');
                break;
            case 'defined':
                $menu=self::fetch('自定义字段,自定义表单');
                break;
            case 'help':
                $menu=self::fetch('模板管理,添加标签,标签列表');
                break;
            case 'seo':
                $menu=self::fetch('数据统计,内容链接管理,友情链接管理,邮件管理');
                break;
            case 'map':
                $menu=self::fetch('网站设置,数据库管理,数据维护,内容管理,生成管理,栏目管理,分类管理,专题管理,幻灯片管理,用户管理,用户组管理,公告管理,自定义字段,自定义表单,订单管理,留言管理,专题管理,评论管理,投票管理,数据备份,批量替换,模板管理,添加标签,标签列表,内容链接管理,推广联盟,友情链接管理,统计管理,邮件管理,内容链接管理,推广联盟,友情链接管理,统计管理,邮件管理,系统管理,客服中心,账号管理,生成代码');
                break;
			case 'bbs':
                $menu=self::fetch('论坛专题,帖子管理');
                break;
            default:
                $menu=self::fetch('常用操作');
                break;
        }
        if(empty($menu)){
        	return;
        }
        $menu=array_merge($menu,self::$menu);
        if (front::get('mod')) {
            foreach ($menu as $menu_1) {
                foreach ($menu_1 as $menu_2) {
                    if ($menu_2)
                        break;
                }
                if ($menu_2)
                    break;
            }
            front::redirect($menu_2);
        }
        return $menu;
    }
 function delete_action() {
     $this->manage->delete_before(front::get('id'));
     $delete=$this->_table->rec_delete(front::get('id'));
     if ($delete) front::flash("删除{$this->tname}成功!");
     front::redirect(url::modify('act/list/table/'.$this->table.'/bid/'.session::get('bid')));
 }
Beispiel #12
0
                $dir2=opendir($path);
                while ($file=readdir($dir2)) {
                    $files++;
                }
                $koption='<option value="">选择关键词...</option>';
                while ($file=readdir($dir)) {
                    if ($file != '..' && $file != '.' && !is_dir($path.'/'.$file) || $files == 0) {
                        if ($files == 0)
                            $keyword=null;
                        else
                            $keyword=urldecode(substr($file, 0, -4));
                        if ($_keyword) {
                            if ($_keyword != $keyword) {
                                $path1=ROOT.'/data/hotsearch/'.urlencode($_keyword).'.txt';
                                file_put_contents($path1, $_keywordcount);
                                front::redirect(url::create('index/hotsearch/post/1'));
                            }
                        }
                        $keywordcount = @file_get_contents($path.'/'.$file);
                        echo '<a href="'.config::get('site_url').'?case=archive&act=search&keyword='.str_replace('%', '-', urlencode($keyword)).'&ule=1" target="_blank"><span>'.$keyword.'</span> ('.$keywordcount.')&nbsp;&nbsp;</a>';
                        $koption .= '<option value="'.$file.'">'.$keyword.'</option>';
                    }
                }
            }
            ?>
</div>

<div class="blank10"></div>
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="table1">

<tr>
    function index_action() {
        $this->list_action();
        if(front::post('submit')) {
			if(!front::post('guesttel')) {
                front::flash(lang('请填写联系电话!'));
                return false;
            }
            if(!front::post('title')) {
                front::flash(lang('请填写标题!'));
                return false;
            }
            if(!front::post('content')) {
                front::flash(lang('请选择内容!'));
                return false;
            }
            if(config::get('verifycode')) {
                if(front::post('verify')<>session::get('verify')) {
                    front::flash(lang('验证码错误!'));
                    return false;
                }
            }
            front::$post['checked']=0;
            if(empty($this->view->user)) {
                front::$post['userid']=0;
                front::$post['username']='******'.front::$post['nickname'];
            }else {
                front::$post['userid']=$this->view->user['userid'];
                front::$post['username']=$this->view->user['username'];
            }
            front::$post['adddate']=date('Y-m-d H:i:s');
            front::$post['ip']=front::ip();
            if (!get_magic_quotes_gpc()) {
                front::$post['content'] = front::$post['content'];
            }
            front::$post['title']=strip_tags(front::$post['title']);
            $data=front::$post;
            $insert=$this->_table->rec_insert($data);
            if($insert<1) {
                front::flash(lang('留言失败!'));
            }
            else {
            	if(config::get('email_gust_send_cust') && front::$post['guestemail']){
            		$title = "您在".config::get('sitename')."的留言已提交";
            		$this->sendmail(front::$post['guestemail'], $title, $title);
            	}
            	if(config::get('email_guest_send_admin') && config::get('email')){
            		$title = '网站在' . date('Y-m-d H:i:s') . '有新留言了';
            		$this->sendmail(config::get('email'), $title, $title);
            	}
                if(config::get('sms_on') && config::get('sms_guestbook_on')){
                    sendMsg(front::$post['guesttel'],config::get('sms_guestbook'));
                }
                if(config::get('sms_on') && config::get('sms_guestbook_admin_on') && $mobile = config::get('site_mobile')){
                    sendMsg($mobile,front::$post['username'].'在'.date('Y-m-d H:i:s').'留言了');
                }
                
                front::flash(lang('留言成功!'));
                $this->view->submit_success=true;
                if(front::get('t') == 'wap'){
                	front::redirect(url::create('guestbook/index/t/wap/success/'.time()));
                }else{
                	front::redirect(url::create('guestbook/index/success/'.time()));
                }
            }
        }
    }
 function delete_action() {
 	if($this->table == 'category'){
 		chkpw('category_del');
 	}
 	if($this->table == 'type'){
 		chkpw('type_del');
 	}
 	if($this->table == 'special'){
 		chkpw('special_del');
 	}
 	if($this->table == 'user'){
 		chkpw('user_del');
 	}
 	if($this->table == 'usergroup'){
 		chkpw('usergroup_del');
 	}
 	if($this->table == 'orders'){
 		chkpw('order_del');
 	}
 	if($this->table == 'comment'){
 		chkpw('func_book_pldel');
 	}
 	if($this->table == 'guestbook'){
 		chkpw('func_book_del');
 	}
 	if($this->table == 'announcement'){
 		chkpw('func_announc_del');
 	}
 	if($this->table == 'linkword'){
 		chkpw('seo_linkword_del');
 	}
 	if($this->table == 'friendlink'){
 		chkpw('seo_friendlink_del');
 	}
 	
     $this->manage->delete_before(front::get('id'));
     $delete=$this->_table->rec_delete(front::get('id'));
     if ($delete){
         front::flash("删除{$this->tname}成功!");
         event::log("删除{$this->tname}",'成功 id='.front::get('id'));
     }
     front::redirect(url::modify('act/list/table/'.$this->table.'/bid/'.session::get('bid')));
 }
 function delete_action() {
     front::check_type(front::get('id'));
     $row = $this->_table->getrow(array('id'=>front::get('id')));
     if($row['mid'] != $this->view->user['userid']){
     	exit('你没权限删除');
     }
     $delete=$this->_table->rec_delete(front::get('id'));
     if($delete)  front::flash(lang('删除记录成功!'));
     front::redirect(url::modify('act/list/manage/'.$this->table));
 }
 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);
 	}
 }
Beispiel #17
0
 function register_action() {
     $r = $this->_union->getrow(array('userid'=>$this->view->data['userid']));
     if($r) {
         echo '<script type="text/javascript">alert("'.lang('你已经申请,转入联盟页面!').'")</script>';
         front::refresh(url::create('union/stats'));
     }
     if(front::post('submit')) {
         if(!config::get('reg_on')) {
             front::flash(lang('网站已经关闭注册!'));
             return;
         }
         if(config::get('verifycode')) {
             if(!session::get('verify') ||front::post('verify')<>session::get('verify')) {
                 front::flash(lang('验证码错误!'));
                 return;
             }
         }
         if(front::post('nickname') != strip_tags(front::post('nickname'))
                 ||front::post('nickname') != htmlspecialchars(front::post('nickname'))
         ) {
             front::flash(lang('姓名不规范!'));
             return;
         }
         if(strlen(front::post('nickname'))<4) {
             front::flash(lang('请填写认真填写真实姓名!'));
             return;
         }
         if(strlen(front::post('payaccount'))<1) {
             front::flash(lang('请填写支付账号!'));
             return;
         }
         if(strlen(front::post('tel'))<1) {
             front::flash(lang('请填写联系电话!'));
             return;
         }
         if(strlen(front::post('address'))<1) {
             front::flash(lang('请填写联系地址!'));
             return;
         }
         if(strlen(front::post('website'))<1) {
             front::flash(lang('请填写网站地址!'));
             return;
         }
         /*if(strlen(front::post('e_mail'))<1) {
             front::flash(lang('请填写邮箱!'));
             return;
         }*/
         if(is_array($_POST)){
         	foreach ($_POST as $v){
         		if(preg_match('/(select|load_file|\[|password)/i', $v)){
         			exit('not access');
         		}
         	}
         }
         $userarr = array();
         $userarr['nickname'] = front::$post['nickname'];
         $userarr['tel'] = front::$post['tel'];
         $userarr['address'] = front::$post['address'];
         //$userarr['e_mail'] = front::$post['e_mail'];
         $unionarr = array();
         $unionarr['userid'] = $this->view->data['userid'];
         $unionarr['username'] = $this->view->data['username'];
         $unionarr['payaccount'] = front::$post['payaccount'];
         $unionarr['website'] = front::$post['website'];
         $unionarr['profitmargin'] = union::getconfig('profitmargin');
         $unionarr['regtime'] = time();
         $unionarr['regip'] = front::ip();
         $unionarr['passed'] = 1;
         if(front::post('nickname') &&$this->view->data['userid']) {
             $insert=$this->_user->rec_update($userarr,'userid='.$this->view->user['userid']);
             $insert1 = $this->_union->rec_insert($unionarr);
             if($insert &&$insert1) front::flash(lang('申请成功!'));
             else {
                 front::flash(lang('申请失败!'));
                 return;
             }
             front::redirect(url::create('union/stats'));
             exit;
         }
         else {
             front::flash(lang('申请失败!'));
             return;
         }
     }
 }
Beispiel #18
0
 function add_action() {
     if(front::$post['submit']) {
         if(config::get('verifycode')) {
             if(!session::get('verify') ||front::post('verify')<>session::get('verify')) {
                 alerterror(lang('验证码错误!'));
                 $this->render(@setting::$var[$this->table]['myform']['template']);
                 $this->end=false;
                 return;
             }
         }
         front::$post['checked']=0;
         front::$post['userid']=$this->view->user['userid'];
         front::$post['username']=$this->view->user['username'];
         front::$post['author']=$this->view->user['username'];
         front::$post['adddate']=date('Y-m-d H:i:s');
         front::$post['ip']=front::ip();
         foreach(front::$post as $k=>$p) {
             if( is_array($p))  front::$post[$k]=implode(',',$p);
         }
         $data=front::$post;
         $insert=$this->_table->rec_insert($data);
         if($insert<1) {
             front::flash(lang('表单提交失败!'));
         }
         else {
             if(is_array(front::$post) &&!empty(front::$post)) {
                 foreach(front::$post as $k =>$v) {
                     if(preg_match('/^my_.*?mail$/i',$k) &&strstr($v,'@')) {
                         $email = front::$post[$k];
                         break;
                     }
                 }
                 foreach(front::$post as $k =>$v) {
                     if(preg_match('/^my_.*?tel$/i',$k) &&strstr($v,'@')) {
                         $tel = front::$post[$k];
                         break;
                     }
                 }
             }
             $code = '';
             foreach ($this->view->field as $k =>$v) {
                 $cname = setting::$var[$this->table][$k]['cname'];
                 $val = front::$post[$k];
                 $code .= $cname.": ".$val."<br>";
             }
             $smtpemailto = config::get('email');
             $title = setting::$var[$this->table]['myform']['cname'].lang('的结果');
             if(config::get('email_form_on') && $email) {
                 $this->sendmail($email,$title,$code);
             }
             if(config::get('email_form_on') && $smtpemailto) {
                 $this->sendmail($smtpemailto,$title,$code);
             }
             if($tel) {
                 if(config::get('sms_on') && config::get('sms_form_on')){
                     sendMsg($tel,config::get('sms_form'));
                 }
                 if(config::get('sms_on') && config::get('sms_form_admin_on') && $mobile = config::get('site_mobile')){
                     sendMsg($mobile,front::$post['username'].'在'.date('Y-m-d H:i:s').'提交了表单');
                 }
             }
             if(front::$post['aid']){
                 echo "<script>alert('表单提交成功!');window.location.href='".url::create('/archive/show/aid/'.front::$post['aid'])."'</script>";
                 //front::redirect();
             }else{
                 front::redirect(url::create('/form/message'));
             }
         }
     }
     $this->render(@setting::$var[$this->table]['myform']['template']);
     $this->end=false;
 }
 function batch_action(){
 	if(is_array(front::$post['select']) && !empty(front::$post['select'])){
 		foreach(front::$post['select'] as $v){
 			if(!preg_match('/^my_.+/',$v)) {
 				front::flash('字段名称不正确!');
 			}
 			$delete=$this->_table->query("ALTER TABLE `{$this->_table->name}` DROP `".$v."`");
 			if(!$delete) {
 				front::flash('字段删除失败!');
 			}else {
 				unset(setting::$var[$this->table][$v]);
 				setting::save();
 				front::flash('字段删除成功!');
 				front::redirect(url::modify('act/list',true));
 			}
 		}
 	}
 }
 function init() {