<?php
if (!defined('ROOT')) exit('Can\'t Access !'); 
class mod_admin extends module_class{
 	function main(){
	  $_GET['get'] = $_GET['get'] ? $_GET['get'] : 'system';
	  if($_GET['get']=='system'){
         if(function_exists('ini_get')){
             $globals = ini_get('register_globals');
             $uploads = ini_get('file_uploads');
         }else{
             $globals = get_cfg_var('register_globals');
             $uploads = get_cfg_var('file_uploads');
         }
         $this->globals = $globals ? "开启" : "关闭";
         $this->uploads = $uploads ? "可以" : "不可以";
	  }
	  if($_GET['get']=='template'){
         if(submit()){
           config::update($_POST);
		   $this->message('go_back','更换模板成功，请更新缓存');
	     }
         $handler = opendir(PATH."./template/");
		 $i = 0;
         while(($filename = readdir($handler)) !== false){
		   $i++;
           if($filename != "." && $filename != ".." && $filename!="admin" && $filename!="cache" && $filename!="member"){
			  $this->files[$i]['pic'] = config::get("siteurl").'template/'.$filename.'/default.jpg';
			  $this->files[$i]['path'] = $filename;
		   }
		 }
	  }
	  if($_GET['get']=='cache'){
         $handler = opendir(PATH."./template/cache/");
         while(($filename = readdir($handler)) !== false){
           if($filename != "." && $filename != ".."){
			  @chmod(PATH."./template/cache/".$filename, 0777);
			  @unlink(PATH."./template/cache/".$filename);
		   }
		 }
		 $this->message('go_back','更新缓存成功');
	  }
	  
	  if($_GET['get']=='link'){
        if(submit()){
			$arrid = $_POST['id'];
			$arrname = $_POST['linkname'];
			$arrurl = $_POST['linkurl'];
			$arrorder = $_POST['linkorder'];
			foreach($arrid as $k=>$v){
			  $arr['linkname'] = $arrname[$k];
			  $arr['linkurl'] = $arrurl[$k]; 
			  $arr['linkorder'] = $arrorder[$k]; 
			  if($v == ''){
                 $this->mysql->insert("{$this->pre}link",$arr); 
			  }else{
                $this->mysql->update("{$this->pre}link",$arr,"id='$v'"); 
			  }
			}
	        $this->message('go_back','友情链接操作成功');	  
	    }
	    $query = $this->mysql->query("select * from {$this->pre}link order by linkorder asc");
	    $this->typelist=array();
	    while($rs=$this->mysql->assoc($query)){
		    $rs['delurl'] = rewrite::request("?mod={$this->module}&act={$this->action}&get=linkdel&id=".$rs['id']);
		    $this->typelist[]=$rs;
	    }
	  }
	  
	  if($_GET['get']=='linkdel'){
		$id = $_GET['id'];
		$this->mysql->delete("{$this->pre}link","id={$id}");  
	    $this->message('go_back','删除友情链接成功');	  	
	  }
	  
	  
	  
	}
	
 	function login(){
	  if($this->sessionadmin) location('admin');
	  if(submit()) $this->user->login($_POST['username'],$_POST['password'],$_POST['seccode'],true);
	}
	
 	function logout(){
	  $this->user->adminlogout('admin_login');
	}
		
	function config(){
	  $_GET['get'] = $_GET['get'] ? $_GET['get'] : 'basic';
      if(submit()){
		if($_GET['get']=='bili'){
		  $this->mysql->query("update {$this->pre}user set shsf='{$_POST[shsf]}'"); 	
		}
          $uploadpath = PATH.config::get('uploadpath').'/logo/';
		  $filepath = config::get("siteurl").config::get('uploadpath').'/logo/';
          $upload = new upload($uploadpath,array('gif','jpg'));
          $file = $upload->getfile();
		  if($file[0][saveName]){
			 @unlink(PATH.config::get("sitelogo"));
		     $_POST['sitelogo'] = $filepath.$file[0][saveName];
		  }
        config::update($_POST);
		$this->message('go_back','网站基础部署成功');
	  }else{
	    $configcontents = config::configs();
	    @preg_match_all("%//(\S+?)-(\S+?)\{%s", $configcontents, $config, PREG_PATTERN_ORDER);
	    foreach($config[1] as $key=>$val){
		    @preg_match_all("%//$val-(\S+?)\{(.+?)//\}%s", $configcontents, $result, PREG_PATTERN_ORDER); 
		    $configs[$val] = $result;  
	    }
	    foreach($configs as $key=>$val){
			$pregexp='\"(.*?)\"=>\"(.*?)\", //{title=(.*?)}{prompt=(.*?)}{type=(.*?)}{values=(.*?)}{option=(.*?)}{unit=(.*?)}';
		    preg_match_all("%$pregexp%s",$val[2][0], $pregval, PREG_SET_ORDER);
			foreach($pregval as $pk=>$pv) $pregval[$pk][2] = stripslashes($pregval[$pk][2]);
            $this->configs[$key]['key'] = $key;
		    $this->configs[$key]['name'] = $val[1][0];
		    $this->configs[$key]['arr'] = $pregval;
	    }
	  }
	}
	
	function profile(){
		$uid = $_GET['uid'];
		if($_GET['get']=='idcard'){
		   $this->profile = $this->mysql->select_one("select truename,idcard from {$this->pre}user where uid='$uid'");
		}
		if($_GET['get']=='editbank'){
           $this->bankuser = $this->mysql->select_one("select * from {$this->pre}user where uid='$uid'");
		   $this->bank = $this->mysql->getarr("select * from {$this->pre}atmbank where uid='$uid'");
		}
		if(submit()){
		  if($_GET['get']=='idcard'){
		    $arr['truename'] = $_POST['truename'];
			$arr['idcard'] = $_POST['idcard'];
			if($this->user->checkidcard($arr['idcard'],$uid)) $this->javascript("go_back","对不起，该身份证信息已经存在");
			$this->user->update($arr,$uid);
		  }
		}
	}
	
	function user(){
	  $_GET['get'] = $_GET['get'] ? $_GET['get'] : 'list';
	  if($_GET['get']=='list'){
		$where = "where uid>0";
		$keyword = $_GET['keywords'];
		if($_GET['groupid']) $where.=" and groupid='{$_GET['groupid']}'";
		if($keyword) $where.=" and (username like '%{$keyword}%' or idcard like '%{$keyword}%' or userphone like '%{$keyword}%' or address like '%{$keyword}%' or truename like '%{$keyword}%' or s_province like '%{$keyword}%' or s_city like '%{$keyword}%' or s_county like '%{$keyword}%' or jsr like '%{$keyword}%')";
	    $pagetotal = $this->pagetotal = $this->mysql->counts("select * from {$this->pre}user $where");
		$this->pageclass($pagetotal,8);
	    $query = $this->mysql->query("select * from {$this->pre}user $where order by status asc limit ".$this->page->start.",".$this->page->size);
	    $this->userlist=array();
	    while($rs=$this->mysql->assoc($query)){
		    $rs['editurl'] = rewrite::request("?mod={$this->module}&act={$this->action}&get=edit&uid=".$rs['uid']);
		    $rs['delurl'] = rewrite::request("?mod={$this->module}&act={$this->action}&get=del&uid=".$rs['uid']);
		    $rs['groupname'] = $this->mysql->value("{$this->pre}usergroup","groupname","groupid='$rs[groupid]'");
			$rs['username'] = str_replace($keyword,setgl($keyword),$rs['username']);
			$rs['userphone'] = str_replace($keyword,setgl($keyword),$rs['userphone']);
			$rs['truename'] = str_replace($keyword,setgl($keyword),$rs['truename']);
			$rs['jsr'] = str_replace($keyword,setgl($keyword),$rs['jsr']);
		    $this->userlist[]=$rs;
	    }
  	    $query = $this->mysql->query("select * from {$this->pre}usergroup order by system desc,isadmin desc,purviews desc,groupid asc");
	    while($rs=$this->mysql->assoc($query)){
           $rs['url'] = rewrite::request("?mod={$this->module}&act={$this->action}&groupid=".$rs['groupid']);
		   $this->channel[] = $rs;
	    }
	  }
	  
	  if($_GET['get']=='add'||$_GET['get']=='edit'){
		$uid = $_GET['uid'];
        if(submit()){
		  if($uid){
			 if($_POST['money']!=''){
				if($_POST['money']<0){
				  $action = "扣除";
                  $fuhao = "-"; 
				}else{
				  $action = "增加";
                  $fuhao = "+"; 
				}	
		        $moneylog['uid'] = $uid;
		        $moneylog['addtime'] = time();
		        $moneylog['content'] = "管理员后台操作,{$action}".str_replace('-','',$_POST['money'])."元现金。";
		        $moneylog['lognum'] = $fuhao.str_replace('-','',$_POST['money']);
                $this->mysql->insert("{$this->pre}log",$moneylog);
			 }
			 $_POST['money'] = $this->mysql->value("{$this->pre}user",'money',"uid='$uid'")+$_POST['money'];
			 $message = '编辑会员成功';
			 
			 
			 if($_POST['groupid']==5){
			    $checkdl = $this->mysql->select_one("select * from {$this->pre}user where groupid='5' and s_province='$_POST[s_province]' and s_city='$_POST[s_city]' and s_county='$_POST[s_county]' and uid!='{$uid}'");
		        if(is_array($checkdl)) $this->message("go_back",'该区域已经有区县代理了'); 
			 }
			 
			 if($_POST['groupid']==6){
			    $checkdl = $this->mysql->select_one("select * from {$this->pre}user where groupid='6' and s_province='$_POST[s_province]' and s_city='$_POST[s_city]' and uid!='{$uid}'");
		        if(is_array($checkdl)) $this->message("go_back",'该区域已经有市级代理了'); 
			 }
			 if($_POST['groupid']==7){
			    $checkdl = $this->mysql->select_one("select * from {$this->pre}user where groupid='7' and s_province='$_POST[s_province]' and uid!='{$uid}'");
		        if(is_array($checkdl)) $this->message("go_back",'该区域已经有省级代理了'); 
			 }
			 
			 
             $this->user->update($_POST,"$uid");
			 $user = $this->mysql->select_one("select * from {$this->pre}user where uid='$uid'");
			 $com = $this->mysql->select_one("select * from {$this->pre}company where uid='$uid'");
			 if($user['groupid']==4&&!is_array($com)){
                $company['person'] = sintrim($user['truename']);
		        $company['name'] = sintrim($user['company']);
		        $company['telphone'] = $user['userphone'];
		        $company['address'] = $user['address'];	
		        $company['s_province'] = $user['s_province'];
		        $company['s_city'] = $user['s_city'];
		        $company['s_county'] = $user['s_county'];
		        $company['pics'] = 1;
		        $company['addtime'] = time();
		        $company['checked'] = 0; 
		        $company['ishot'] = 0; 
		        $company['uid'] = $uid;
				$this->mysql->insert("{$this->pre}company",$company); 
			 }
		  }else{
		     $_POST['tjdls'] = $_POST['jsr'];
		     $_POST['dls'] = $_POST['jsr'];
			 if($_POST['username']=='') $this->message("go_back",'对不起，用户名不能为空');
			 if($_POST['password']=='') $this->message("go_back",'对不起，密码不能为空');
			 if($_POST['email']=='') $this->message("go_back",'对不起，电子邮箱不能为空');
			 if($this->user->checkemail($_POST['email'])) $this->message("go_back",'该电子邮箱已经存在');
			 if($_POST['userphone']=='') $this->message("go_back",'对不起，手机号码不能为空');
			 if($_POST['s_county']=='市、县级市') $this->message("go_back",'对不起，请选择用户所在区域');			 
             if($_POST['jsr']=='') $this->message("go_back",'对不起，请填写该用户的介绍人');	
			 
			 if($_POST['groupid']==5){
			    $checkdl = $this->mysql->select_one("select * from {$this->pre}user where groupid='5' and s_province='$_POST[s_province]' and s_city='$_POST[s_city]' and s_county='$_POST[s_county]'");
		        if(is_array($checkdl)) $this->message("go_back",'该区域已经有区县代理了'); 
			 }
			 
			 if($_POST['groupid']==6){
			    $checkdl = $this->mysql->select_one("select * from {$this->pre}user where groupid='6' and s_province='$_POST[s_province]' and s_city='$_POST[s_city]'");
		        if(is_array($checkdl)) $this->message("go_back",'该区域已经有市级代理了'); 
			 }
			 if($_POST['groupid']==7){
			    $checkdl = $this->mysql->select_one("select * from {$this->pre}user where groupid='7' and s_province='$_POST[s_province]'");
		        if(is_array($checkdl)) $this->message("go_back",'该区域已经有省级代理了'); 
			 }		 
			 $message = '添加会员成功';
             $this->user->insert($_POST); 
			 if($_POST['groupid']==4){
                $company['person'] = sintrim($_POST['truename']);
		        $company['name'] = sintrim($_POST['company']);
		        $company['telphone'] = $_POST['userphone'];
		        $company['address'] = $_POST['address'];	
		        $company['s_province'] = $_POST['s_province'];
		        $company['s_city'] = $_POST['s_city'];
		        $company['s_county'] = $_POST['s_county'];
		        $company['pics'] = 1;
		        $company['addtime'] = time();
		        $company['checked'] = 0; 
		        $company['ishot'] = 0; 
		        $company['uid'] = $this->mysql->insertid(); 	
				$this->mysql->insert("{$this->pre}company",$company); 
			 }
			 


			 
			 
			 
			 
		  }
		  $this->message('admin_user',$message);
	    }
        $this->thisuser = $this->mysql->select_one("select * from {$this->pre}user where uid='$uid'");
		$this->thisuser['money'] = fnum($this->thisuser['money']);
		$this->thisuser['keti'] = fnum($this->thisuser['keti']);
		$this->thisuser['balance'] = fnum($this->thisuser['balance']);
		$this->thisuser['consume'] = fnum($this->thisuser['consume']);
  	    $query = $this->mysql->query("select * from {$this->pre}usergroup order by isadmin desc,purviews desc,groupid asc");
	    while($rs=$this->mysql->assoc($query)){
		   $this->usergrouplist .= "[<$rs[groupid]><$rs[groupname]>]";
	    }
		if($_GET['get']=='add'){
		   $this->thisuser['balance'] = 0;
		   $this->thisuser['consume'] = 0;
		   $this->thisuser['money'] = 0;
		   $this->thisuser['keti'] = 0;
		   $this->thisuser['yyze'] = 0;
		   $this->thisuser['status'] = 1;
		}
	    if(!is_array($this->thisuser)&&$_GET['get']=='edit') $this->message('go_back','对不起，该用户信息不存在');	  	  
	  } 
	  
	  if($_GET['get']=='del'){
		$uid = $_GET['uid'];
		$user = $this->mysql->select_one("select * from {$this->pre}user where uid='{$uid}'");
		$atmlog = $this->mysql->select_one("select * from {$this->pre}atmlog where uid='{$uid}'");
		$log = $this->mysql->select_one("select * from {$this->pre}log where uid='{$uid}'");
		$res = $this->mysql->select_one("select * from {$this->pre}res where uid='{$uid}'");
		$reslog = $this->mysql->select_one("select * from {$this->pre}reslog where uid='{$uid}'");
		$store = $this->mysql->select_one("select * from {$this->pre}store where uid='{$uid}'");
		if(is_array($atmlog)||is_array($log)||is_array($res)||is_array($reslog)||is_array($store)){
			$this->message('go_back','该会员有消费记录不能删除');	 
		}
		$this->mysql->delete("{$this->pre}company","uid={$uid}"); 
		$this->mysql->delete("{$this->pre}user","uid={$uid}"); 
		$this->mysql->delete($this->pre."atmbank","uid='{$uid}'"); 
		$arr['jsr'] = config::get("referrals");
		$arr['tjdls'] = config::get("referrals");
		$arr['dls'] = config::get("referrals");
        $this->mysql->update("{$this->pre}user",$arr,"jsr='{$user['username']}'"); 
	    $this->message('go_back','删除会员成功');	  	
	  }
	  
	  if($_GET['get']=='group'){
	     $query = $this->mysql->query("select * from {$this->pre}usergroup order by system desc,isadmin desc,groupid asc");
	     $this->usergroup=array();
	     while($rs=$this->mysql->assoc($query)){
		     $rs['editurl'] = rewrite::request("?mod={$this->module}&act={$this->action}&get=groupedit&groupid=".$rs['groupid']);
		     $rs['delurl']  = rewrite::request("?mod={$this->module}&act={$this->action}&get=groupdel&groupid=".$rs['groupid']);
		     $rs['usercount'] = $this->mysql->counts("select uid from {$this->pre}user where groupid='$rs[groupid]'");
		     $this->usergroup[]=$rs;
	     }
	  }
	  
	  if($_GET['get']=='groupadd'||$_GET['get']=='groupedit'){
		 $groupid = $_GET['groupid'];
         if(submit()){
		  foreach($_POST as $key => $value) {
			  if(is_array($value)) $value = implode(',',$value);
			  $arr[$key] = $value;
			  if($key=='groupname'&&$value=='') $this->message('go_back','对不起，分组名称不能为空');
		  }			 
		   if($groupid){
			  $message = '编辑会员组成功';
              $this->mysql->update("{$this->pre}usergroup",$arr,"groupid='$groupid'"); 
		   }else{
			  $message = '添加会员组成功';
              $this->mysql->insert("{$this->pre}usergroup",$arr); 
		   }
		   $this->message('?mod=admin&act=user&get=group',$message);
	     }
	     foreach($this->purviews as $key=>$val){
		    if($val[2]){
			  if(strstr($key,"admin_")){
		         $this->apurviewlist .= "[<$key><$val[0]>]";
			  }else{
		         $this->upurviewlist .= "[<$key><$val[0]>]";
			  }
		    }
	     }
	 	 if($_GET['get']=='groupedit'){
           $this->usergroup = $this->mysql->select_one("select * from {$this->pre}usergroup where groupid='$groupid'");
	       if(!is_array($this->usergroup)) $this->message('go_back','该会员分组信息不存在');
	       if($this->usergroup['system']==1) $this->message('go_back','系统分组是禁止修改的');	
		 }
		 
	  } 
	  
	  if($_GET['get']=='password'){
        if(submit()){
		   $this->repost = 1;
		   $submit = true;
		   if($_POST['username']==''){
			  $this->usernametip = '对不起，请填写要重置用户的用户名';
			  $submit = false;
		   }else{
		      $user = $this->mysql->select_one("select * from {$this->pre}user where username='{$_POST[username]}'");
              if(!is_array($user)){
			     $this->usernametip = '对不起，该用户不存在请核实';
			     $submit = false;
		      }
		   }
		   
		   if($_POST['password']==''&&$_POST['repass']==''){
  		      $this->passwordtip = '对不起，不能一个密码也不修改';
			  $this->repasstip = '对不起，不能一个密码也不修改';
			  $submit = false;	  
		   }

		   if($submit){
			  if($_POST['password']=='') unset($_POST['password']);
			  if($_POST['repass']=='') unset($_POST['repass']);
			  $this->user->update($_POST,$user['uid']);
			  $this->message('go_back','密码重置成功。');
		   }
	    }
	  }	     
	  
	  if($_GET['get']=='clear'){
        if(submit()){
		   $this->repost = 1;
		   $submit = true;
		   if($_POST['username']==''){
			  $this->usernametip = '对不起，请填写要清除的用户';
			  $submit = false;
		   }else{
		      $user = $this->mysql->select_one("select * from {$this->pre}user where username='{$_POST[username]}'");
              if(!is_array($user)){
			     $this->usernametip = '对不起，该用户不存在请核实';
			     $submit = false;
		      }
		   }
		   
		   if($submit){
			  $this->mysql->delete($this->pre."atmlog","uid='{$user[uid]}'");
			  $this->mysql->delete($this->pre."log","uid='{$user[uid]}'");
			  $this->mysql->delete($this->pre."order","uid='{$user[uid]}'");
			  $this->mysql->delete($this->pre."payorder","uid='{$user[uid]}'");
			  $this->mysql->delete($this->pre."res","uid='{$user[uid]}'");
			  $this->mysql->delete($this->pre."reslog","uid='{$user[uid]}'");
			  $this->mysql->delete($this->pre."shopcart","uid='{$user[uid]}'");
			  $this->mysql->delete($this->pre."store","uid='{$user[uid]}'");
		      $this->mysql->delete($this->pre."company","uid='{$user[uid]}'"); 
			  $this->mysql->delete($this->pre."user","uid='{$user[uid]}'");
			  $this->mysql->delete($this->pre."atmbank","uid='{$user[uid]}'"); 
			  $arr['jsr'] = config::get("referrals");
			  $arr['tjdls'] = config::get("referrals");
			  $arr['dls'] = config::get("referrals");
              $this->mysql->update("{$this->pre}user",$arr,"jsr='{$user['username']}'"); 
			  $this->message('go_back','清除会员成功。');
		   }
	    }
	  }	
	  
	  
	}
	
   function ads(){	   
	  $_GET['get'] = $_GET['get'] ? $_GET['get'] : 'list';
	  if($_GET['get']=='list'){
        if(submit()){
		  if($_POST['id']){
		     $id = implode(',',$_POST['id']);
             $this->mysql->delete("{$this->pre}ads","id in({$id})");
             $this->message('go_back','批量删除广告成功'); 
		  }else{
			 $this->message('go_back','请选择要删除的广告'); 
		  }
	    }
	    $pagetotal = $this->pagetotal = $this->mysql->counts("select * from {$this->pre}ads");
		$this->pageclass($pagetotal);
	    $query = $this->mysql->query("select * from {$this->pre}ads order by id asc limit ".$this->page->start.",".$this->page->size);
	    $this->adslist=array();
	    while($rs=$this->mysql->assoc($query)){
		    $rs['editurl'] = rewrite::request("?mod={$this->module}&act={$this->action}&get=edit&id=".$rs['id']);
		    $rs['delurl'] = rewrite::request("?mod={$this->module}&act={$this->action}&get=del&id=".$rs['id']);
		    $this->adslist[]=$rs;
	    }	  
	  }
	  
	  if($_GET['get']=='add'||$_GET['get']=='edit'){
		$id = $_GET['id'];
        if(submit()){
		  $arr['adsname'] = sintrim($_POST['adsname']);
		  $arr['adstype'] = $_POST['adstype'];
		  $arr['width'] = $_POST['width'];
		  $arr['height'] = $_POST['height'];
		  $arr['adslink'] = sintrim($_POST['adslink']);
		  $filedate = formattime(time(),"Y-m-d");
          $uploadpath = PATH.config::get('uploadpath').'/ads/'.$filedate.'/';
		  $filepath = config::get("siteurl").config::get('uploadpath').'/ads/'.$filedate.'/';
          $upload = new upload($uploadpath,array('gif','jpg','jpge','swf'));
          $file = $upload->getfile();
		  if($file[0][saveName]){
		     if($id){
                $ads = $this->mysql->select_one("select * from {$this->pre}ads where id='$id'"); 
		        @unlink(PATH.$ads['adspic']);
		     }  
			 $arr['adspic'] = $filepath.$file[0][saveName];
		  }
		  if($id){
			 $message = '编辑广告成功';
             $this->mysql->update("{$this->pre}ads",$arr,"id='$id'"); 
		  }else{
			 $message = '添加广告成功';
             $this->mysql->insert("{$this->pre}ads",$arr); 
		  }
		  $this->message('admin_ads',$message);
	    }
        $this->ads = $this->mysql->select_one("select * from {$this->pre}ads where id='$id'");
	    if($_GET['get']=='edit'){
		   if(!is_array($this->ads)) $this->message('go_back','对不起，该广告信息不存在');	  
		   if($this->ads['adstype']=='1'){
		      $this->ads['shows'] = "<img src={$this->ads['adspic']} width={$this->ads['width']} height={$this->ads['height']} />";
		   }else{
		      $this->ads['shows'] = '<object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0 width='.$this->ads['width'].' height='.$this->ads['height'].'>';
		      $this->ads['shows'] .= '<param name=movie value='.$this->ads['adspic'].' />';
		      $this->ads['shows'] .= '<param name=quality value=high />';
		      $this->ads['shows'] .= '<embed src='.$this->ads['adspic'].' quality=high pluginspage=http://www.macromedia.com/go/getflashplayer type=application/x-shockwave-flash width='.$this->ads['width'].' height='.$this->ads['height'].'></embed>';
		      $this->ads['shows'] .= '</object>';
		   }
		}else{
		   $this->ads['adstype'] = 1;
		   $this->ads['adslink'] = "http://";
		}
	  } 
	  
	  if($_GET['get']=='del'){
        $ads = $this->mysql->select_one("select * from {$this->pre}ads where id='$id'"); 
		@unlink(PATH.$ads['pic']);		  
		$this->mysql->delete("{$this->pre}ads","id={$_GET['id']}");  
	    $this->message('go_back','删除广告成功');	  	
	  }
	  
	  if($_GET['get']=='focus'){
	    $query = $this->mysql->query("select * from {$this->pre}focus order by ord asc");
	    $this->focuslist=array();
	    while($rs=$this->mysql->assoc($query)){
		    $rs['editurl'] = rewrite::request("?mod={$this->module}&act={$this->action}&get=editfocus&id=".$rs['id']);
		    $rs['delurl'] = rewrite::request("?mod={$this->module}&act={$this->action}&get=delfocus&id=".$rs['id']);
            $rs['shows'] = "<img src={$rs['pic']} />";
		    $this->focuslist[]=$rs;
	    }
	  }
	  
	  if($_GET['get']=='addfocus'||$_GET['get']=='editfocus'){
		$id = $_GET['id'];
        if(submit()){
		  $arr['txt'] = sintrim($_POST['txt']);
		  $arr['url'] = $_POST['url'];
		  $arr['ord'] = $_POST['ord'];
          $uploadpath = PATH.config::get('uploadpath').'/ads/focus/';
		  $filepath = config::get("siteurl").config::get('uploadpath').'/ads/focus/';
          $upload = new upload($uploadpath,array('gif','jpg','jpge','swf'));
          $file = $upload->getfile();
		  if($file[0][saveName]){
		     if($id){
                $ads = $this->mysql->select_one("select * from {$this->pre}focus where id='$id'"); 
		        @unlink(PATH.$ads['pic']);
		     }  
			 $arr['pic'] = $filepath.$file[0][saveName];
		  }
		  if($id){
			 $message = '编辑焦点图片成功';
             $this->mysql->update("{$this->pre}focus",$arr,"id='$id'"); 
		  }else{
			 $message = '添加焦点图片成功';
             $this->mysql->insert("{$this->pre}focus",$arr); 
		  }
		  $this->message('?mod=admin&act=ads&get=focus',$message);
	    }
        $this->ads = $this->mysql->select_one("select * from {$this->pre}focus where id='$id'");
	    if($_GET['get']=='editfocus'){
		   if(!is_array($this->ads)) $this->message('go_back','对不起，该焦点图片信息不存在');	  
 	       $this->ads['shows'] = "<img src={$this->ads['pic']} />";
		}else{
		   $this->ads['ord'] = "0";
		}
	  }
	  
	  if($_GET['get']=='delfocus'){
		$id = $_GET['id'];
        $ads = $this->mysql->select_one("select * from {$this->pre}focus where id='$id'"); 
		@unlink(PATH.$ads['pic']);
		$this->mysql->delete("{$this->pre}focus","id={$id}");  
	    $this->message('go_back','删除焦点图片成功');	  	
	  }
	  
	  
   }
   

   function about(){	   
	  $_GET['get'] = $_GET['get'] ? $_GET['get'] : 'list';
	  if($_GET['get']=='list'){
        if(submit()){
		  if($_POST['id']){
		     $id = implode(',',$_POST['id']);
             $this->mysql->delete("{$this->pre}about","id in({$id})");
             $this->message('go_back','批量删除单页成功'); 
		  }else{
			 $this->message('go_back','请选择要删除的单页'); 
		  }
	    }
	    $pagetotal = $this->pagetotal = $this->mysql->counts("select * from {$this->pre}about");
		$this->pageclass($pagetotal,30);
	    $query = $this->mysql->query("select * from {$this->pre}about order by id asc limit ".$this->page->start.",".$this->page->size);
	    $this->aboutlist=array();
	    while($rs=$this->mysql->assoc($query)){
		    $rs['editurl'] = rewrite::request("?mod={$this->module}&act={$this->action}&get=edit&id=".$rs['id']);
		    $rs['delurl'] = rewrite::request("?mod={$this->module}&act={$this->action}&get=del&id=".$rs['id']);
		    $this->aboutlist[]=$rs;
	    }	  
	  }
	  
	  if($_GET['get']=='add'||$_GET['get']=='edit'){
		$id = $_GET['id'];
        if(submit()){
		  $arr['name'] = sintrim($_POST['name']);
		  $arr['content'] = $_POST['content'];
		  if($id){
			 $message = '编辑单页成功';
             $this->mysql->update("{$this->pre}about",$arr,"id='$id'"); 
		  }else{
			 $message = '添加单页成功';
             $this->mysql->insert("{$this->pre}about",$arr); 
		  }
		  $this->message('admin_about',$message);
	    }
        $this->about = $this->mysql->select_one("select * from {$this->pre}about where id='$id'");
	    if(!is_array($this->about)&&$_GET['get']=='edit') $this->message('go_back','对不起，该单页信息不存在');	  	  
	  } 
	  
	  if($_GET['get']=='del'){
		$this->mysql->delete("{$this->pre}about","id={$_GET['id']}");  
	    $this->message('go_back','删除单页成功');	  	
	  }
   }
   
   function news(){
	  $_GET['get'] = $_GET['get'] ? $_GET['get'] : 'list';
	  if($_GET['get']=='list'){
        if(submit()){
		  if($_POST['id']){
		     $id = implode(',',$_POST['id']);
             $this->mysql->delete("{$this->pre}news","id in({$id})");
             $this->message('go_back','批量删除新闻成功'); 
		  }else{
			 $this->message('go_back','请选择要删除的新闻'); 
		  }
	    }
	    $pagetotal = $this->pagetotal = $this->mysql->counts("select * from {$this->pre}news");
		$this->pageclass($pagetotal);
	    $query = $this->mysql->query("select * from {$this->pre}news order by addtime desc,id desc limit ".$this->page->start.",".$this->page->size);
	    $this->newslist=array();
	    while($rs=$this->mysql->assoc($query)){
		    $rs['editurl'] = rewrite::request("?mod={$this->module}&act={$this->action}&get=edit&id=".$rs['id']);
		    $rs['delurl'] = rewrite::request("?mod={$this->module}&act={$this->action}&get=del&id=".$rs['id']);
	  	    $rs['addtime'] = formattime($rs['addtime']);
		    $rs['typename'] = $this->mysql->value("{$this->pre}newstype",'typename',"id='$rs[typeid]'");
		    $this->newslist[]=$rs;
	    }	  
	  }
	  
	  if($_GET['get']=='add'||$_GET['get']=='edit'){
		$id = $_GET['id'];
        if(submit()){
		  $arr['title'] = sintrim($_POST['title']);
		  $arr['content'] = $_POST['content'];
		  $arr['typeid'] = $_POST['typeid'];
		  $arr['addtime'] = untime($_POST['addtime']);
		  if($id){
			 $message = '编辑新闻成功';
             $this->mysql->update("{$this->pre}news",$arr,"id='$id'"); 
		  }else{
			 $message = '添加新闻成功';
             $this->mysql->insert("{$this->pre}news",$arr); 
		  }
		  $this->message('admin_news',$message);
	    }
	    $typequery = $this->mysql->query("select * from {$this->pre}newstype order by `typeorder` asc");
	    while($typers=$this->mysql->assoc($typequery)){
		  $this->typelist .= "[<$typers[id]><$typers[typename]>]";;
	    }	
        $this->news = $this->mysql->select_one("select * from {$this->pre}news where id='$id'");
		$this->news['addtime'] = $this->news['addtime'] ? $this->news['addtime'] : time();
	    if(!is_array($this->news)&&$_GET['get']=='edit') $this->message('go_back','对不起，该新闻信息不存在');	  	  
	  } 
	  
	  if($_GET['get']=='del'){
		$this->mysql->delete("{$this->pre}news","id={$_GET['id']}");  
	    $this->message('go_back','删除新闻成功');	  	
	  }
	  
	  if($_GET['get']=='type'){
        if(submit()){
			$arrid = $_POST['id'];
			$arrtypename = $_POST['typename'];
			$arrtypeorder = $_POST['typeorder'];
			foreach($arrid as $k=>$v){
			  $arr['typename'] = $arrtypename[$k];
			  $arr['typeorder'] = $arrtypeorder[$k]; 
			  if($v == ''){
                 $this->mysql->insert("{$this->pre}newstype",$arr); 
			  }else{
                $this->mysql->update("{$this->pre}newstype",$arr,"id='$v'"); 
			  }
			}
	        $this->message('go_back','分类操作成功');	  
	    }
	    $query = $this->mysql->query("select * from {$this->pre}newstype order by typeorder asc");
	    $this->typelist=array();
	    while($rs=$this->mysql->assoc($query)){
		    $rs['delurl'] = rewrite::request("?mod={$this->module}&act={$this->action}&get=typedel&id=".$rs['id']);
		    $this->typelist[]=$rs;
	    }
	  }
	  
	  if($_GET['get']=='typedel'){
		$this->mysql->delete("{$this->pre}newstype","id={$_GET['id']}");  
	    $this->message('go_back','删除新闻分类成功');	  	
	  }
	  	  	  
	}
	
	function company(){
	  $_GET['get'] = $_GET['get'] ? $_GET['get'] : 'list';
	  if($_GET['get']=='list'){
	    $pagetotal = $this->pagetotal = $this->mysql->counts("select * from {$this->pre}company");
		$this->pageclass($pagetotal);
	    $query = $this->mysql->query("select * from {$this->pre}company order by checked asc,id desc limit ".$this->page->start.",".$this->page->size);
	    while($rs=$this->mysql->assoc($query)){
		    $rs['editurl'] = rewrite::request("?mod={$this->module}&act={$this->action}&get=edit&id=".$rs['id']);
		    $rs['delurl'] = rewrite::request("?mod={$this->module}&act={$this->action}&get=del&id=".$rs['id']);
	  	    $rs['addtime'] = formattime($rs['addtime'],"Y-m-d");
			$rs['checked'] = $rs['checked'] ? "通过" : "未通过";
		    $rs['typename'] = $this->mysql->value("{$this->pre}companytype",'typename',"id='$rs[typeid]'");
		    $rs['username'] = $this->mysql->value("{$this->pre}user",'username',"uid='$rs[uid]'");
		    $this->companylist[]=$rs;
	    }	  
	  }
	  
	  if($_GET['get']=='add'||$_GET['get']=='edit'){
		$id = $_GET['id'];
        if(submit()){
		  $arr['name'] = sintrim($_POST['name']);
		  $arr['address'] = $_POST['address'];
		  $arr['person'] = $_POST['person'];
		  $arr['telphone'] = $_POST['telphone'];
		  $arr['pics'] = $_POST['pics'];
		  $arr['typeid'] = $_POST['typeid'];
		  $arr['addtime'] = untime($_POST['addtime']);
		  $arr['content'] = $_POST['content'];
		  $arr['checked'] = $_POST['checked']; 
		  $arr['ishot'] = $_POST['ishot']; 
		  $arr['s_province'] = $_POST['s_province'];
		  $arr['s_city'] = $_POST['s_city']; 
		  $arr['s_county'] = $_POST['s_county'];
		  if($id){
			 $message = '编辑商家成功';
             $this->mysql->update("{$this->pre}company",$arr,"id='$id'"); 
		  }else{
			 $message = '添加商家成功';
             $this->mysql->insert("{$this->pre}company",$arr); 
		  }
		  $this->message('admin_company',$message);
	    }
	    $typequery = $this->mysql->query("select * from {$this->pre}companytype order by `typeorder` asc");
	    while($typers=$this->mysql->assoc($typequery)){
		  $this->typelist .= "[<$typers[id]><$typers[typename]>]";;
	    }
		if($_GET['get']=='edit'){
          $this->company = $this->mysql->select_one("select * from {$this->pre}company where id='$id'");
	      if(!is_array($this->company)) $this->message('go_back','对不起，该商家信息不存在');	  
		}else{
		  $this->company['addtime'] = time();
		  $this->company['checked'] = 1;
	    }
	  } 
	  
	  if($_GET['get']=='del'){
		$this->mysql->delete("{$this->pre}company","id={$_GET['id']}");  
	    $this->message('go_back','删除商家成功');	  	
	  }
	  
	  
	  if($_GET['get']=='type'){
        if(submit()){
			$arrid = $_POST['id'];
			$arrtypename = $_POST['typename'];
			$arrtypeorder = $_POST['typeorder'];
			foreach($arrid as $k=>$v){
			  $arr['typename'] = $arrtypename[$k];
			  $arr['typeorder'] = $arrtypeorder[$k]; 
			  if($v == ''){
                 $this->mysql->insert("{$this->pre}companytype",$arr); 
			  }else{
                $this->mysql->update("{$this->pre}companytype",$arr,"id='$v'"); 
			  }
			}
	        $this->message('go_back','分类操作成功');	  
	    }
	    $query = $this->mysql->query("select * from {$this->pre}companytype order by typeorder asc");
	    $this->typelist=array();
	    while($rs=$this->mysql->assoc($query)){
		    $rs['delurl'] = rewrite::request("?mod={$this->module}&act={$this->action}&get=typedel&id=".$rs['id']);
		    $this->typelist[]=$rs;
	    }
	  }
	  
	  if($_GET['get']=='typedel'){
		$this->mysql->delete("{$this->pre}companytype","id={$_GET['id']}");  
	    $this->message('go_back','删除商家分类成功');	  	
	  }
	  
	  	  
	}
	
	function refund(){
	  $_GET['get'] = $_GET['get'] ? $_GET['get'] : 'store';
	  if($_GET['get']=='store'){
	  
	  
		$keyword = $_GET['keyword'];
		if($keyword){
		  $user = $this->user->sql($keyword,'username');
		  if(!is_array($user)) $this->message('go_back','该会员不存在');	
		  $where = " where uid='{$user['uid']}'";
		} 
	  
	     $pagetotal = $this->pagetotal = $this->mysql->counts("select id from {$this->pre}store {$where}");
	     $this->pageclass($pagetotal);
	     $this->store = $this->mysql->getarr("select * from {$this->pre}store {$where} order by addtime desc limit {$this->page->start},{$this->page->size}"); 
	  }
	  
	  if($_GET['get']=='reslog'){
		 $pagetotal = $this->pagetotal = $this->mysql->counts("select id from {$this->pre}reslog");
	     $this->pageclass($pagetotal);
	     $this->reslog = $this->mysql->getarr("select * from {$this->pre}reslog  order by id desc limit {$this->page->start},{$this->page->size}");  
	  }
	  
	  if($_GET['get']=='atmlog'){
        if(submit()){
		  if($_POST['id']){
		     $id = implode(',',$_POST['id']);
			 $arr['checked'] = 1;
			 $this->mysql->update("{$this->pre}atmlog",$arr,"id in({$id})");
             $this->message('go_back','批量处理提现申请成功'); 
		  }else{
			 $this->message('go_back','请选择要处理的提现申请'); 
		  }
	    }
		 if($_GET['id']){
		    $atmlog = $this->mysql->select_one("select * from {$this->pre}atmlog where id='{$_GET['id']}' and checked='0'");
		    if(!is_array($atmlog)) $this->message('go_back','对不起，请不要非法操作');
		    $arr['checked'] = 1;
	        if($this->mysql->update("{$this->pre}atmlog",$arr,"id='{$_GET['id']}'")) $this->message('go_back',"确认支付成功");
		 }
	     $pagetotal = $this->pagetotal = $this->mysql->counts("select id from {$this->pre}atmlog");
	     $this->pageclass($pagetotal);
	     $this->atmlog = $this->mysql->getarr("select * from {$this->pre}atmlog order by id desc limit {$this->page->start},{$this->page->size}");  
	  }	 
	  
	  
	  if($_GET['get']=='atmexcel'){
		   $checked = $_GET['checked'];
		   $where = 'where id>0 ';
		   if($checked!='') $where.= "and checked='{$checked}'";
		   $time = untime($_GET['time']);
		   $timet = untime($_GET['timet']);
		   if($_GET['time']&&$_GET['timet']) $where.= "and addtime between '{$time}' and '{$timet}'";
		   
		   $nowtime = formattime(time(),"Y-m-d");
		   $filename = Sitize('导出提现记录');
           header("Content-type:application/octet-stream"); 
           header("Accept-Ranges:bytes"); 
           header("Content-Disposition:attachment;filename={$filename}.txt"); 
           header("Expires:0"); 
           header("Cache-Control:must-revalidate,post-check=0,pre-check=0"); 
           header("Pragma:public"); 
	       $query = $this->mysql->query("select * from {$this->pre}atmlog $where order by id desc");
	       while($rs=$this->mysql->assoc($query)){
			 $banknumber++; 
			 $user = $this->mysql->select_one("select * from ".$this->pre."user where uid=".$rs['uid']);
             echo $banknumber.",".$rs['bankcard'].",".$user['truename'].",".$rs['lognum'].",".formattime($rs['addtime'],"d").'号返利'."\r\n";
	       }
		   exit();
	  }

	  if($_GET['get']=='payorder'){
		$id = $_GET['id'];
		if($id){
		   $this->mysql->delete("{$this->pre}payorder","id='{$id}' and checked<>1");
		}
	    $pagetotal = $this->pagetotal = $this->mysql->counts("select id from {$this->pre}payorder");
	    $this->pageclass($pagetotal);
	    $this->paylog = $this->mysql->getarr("select * from {$this->pre}payorder order by id desc limit {$this->page->start},{$this->page->size}");
	  }
	  
	  
	  if($_GET['get']=='res'){
		$otime = untime(formattime(time(),"Y-m-d"));
		$ttime = $otime - 3600*24;
		$sql = "select sum(money) as i from {$this->pre}store where addtime<'$otime' and addtime>='$ttime'";
		$ztyye = $this->mysql->select_one($sql);
		$this->ztyye = fnum($ztyye['i']);
		$je = $this->mysql->select_one("select sum(money),sum(symoney) from {$this->pre}res");
		$this->allje = fnum($je['sum(money)']);
		$this->sfanje = fnum($je['sum(symoney)']);
		$this->yfanje = fnum($this->allje - $this->sfanje);
		$res = $this->mysql->select_one("select sum(money) as i from {$this->pre}res where restime<='{$otime}' and symoney>0");
	    $this->todayje = fnum($res['i']/config::get('date'));	
	    $pagetotal = $this->pagetotal = $this->mysql->counts("select id from {$this->pre}res");
	    $this->pageclass($pagetotal);
		$sql = "select * from {$this->pre}res order by id desc limit {$this->page->start},{$this->page->size}";
	    $this->res = $this->mysql->getarr($sql);
	  }
	  
	  if($_GET['get']=='settle'){		  
		  $twotime = untime(formattime(time(),'Y-m-d 00:00'));
		  $onetime = $twotime-(3600*24);
		  $moneytime = $twotime+(3600*24);
		  $time = formattime(time(),'Ymd');
	      $this->allmoney = $this->mysql->getsum("{$this->pre}store","money","(addtime<'{$twotime}' and addtime>'{$onetime}')");	
		  $this->unumber = $this->mysql->counts("select id from {$this->pre}res where checked='1' or checked='0'"); 
		  $this->_unumber = $this->mysql->counts("select id from {$this->pre}res where checked='1'"); 
          $this->restemp = $this->mysql->select_one("select * from {$this->pre}restemp where addtime='{$time}'");
		  $this->resmoney = formatnum($this->allmoney*0.05);
		  $this->onemoney = formatnum($this->resmoney/$this->_unumber);
		  
		  $mymoney = $this->mysql->select_one("select sum(money),sum(resmoney) from {$this->pre}res");
		  $this->allje = $mymoney['sum(money)'];
		  $this->yfanje = $mymoney['sum(resmoney)'];
		  $this->sfanje = fnum($this->allje - $this->yfanje);
		  
		  
		  $uid = $this->mysql->getid("select uid from {$this->pre}res where checked='1' and restime<'{$moneytime}' group by uid");


		  
		  
	      if(submit()){  
			 if(!is_array($this->restemp)){
			   $res['money'] = $_POST['howmoney'];
			   $res['addtime'] = $time;		  
			   $res['_res'] = $uid;
			   $res['res'] = "0";
			   $res['onemoney'] = formatnum($res['money']/$this->_unumber);
			   $this->mysql->insert("{$this->pre}restemp",$res);
			 }
			 $arr['error'] = "0";
			 $arr['_message'] = "初始化成功，正在进入数据结算．．．．";
			 $arr['url'] = Purl("?mod=admin&act=refund&get=settle&sin=start");
		     echo json($arr);
		     exit;
		   }else{
             if($_GET['sin']=='start'){
	           $res = $this->mysql->getarr("select uid from {$this->pre}user where uid in({$this->restemp['_res']}) and uid not in({$this->restemp['res']}) limit 100");  
               if(!is_array($res)||count($res)<1){	
			     $arr['error'] = "0";
			     $arr['message'] = "恭喜你，数据结算完毕";
		         $arr['gourl'] = Purl("?mod=admin&act=refund&get=reslog");
			     echo json($arr);
		         exit; 
			   }else{
				 foreach($res as $v){
				   $this->givemoney($v['uid']);
				   $u = $v['uid'];
				 }


			     $arr['error'] = "0";
			     $arr['_message'] = "{$u}等".count($res)."数据结算完毕，正在进入下一组...";
			     $arr['url'] = Purl("?mod=admin&act=refund&get=settle&sin=start");               
				 echo json($arr);
		         exit;
			   }
			 }
		   }

	  }	  
	  	  
	}
	
	
	function shop(){
	  $_GET['get'] = $_GET['get'] ? $_GET['get'] : 'list';
	  if($_GET['get']=='list'){
        if(submit()){
		  if($_POST['id']){
		     $id = implode(',',$_POST['id']);
             $this->mysql->delete("{$this->pre}shop","id in({$id})");
             $this->message('go_back','批量删除商品成功'); 
		  }else{
			 $this->message('go_back','请选择要删除的商品'); 
		  }
	    }
	    $pagetotal = $this->pagetotal = $this->mysql->counts("select * from {$this->pre}shop");
		$this->pageclass($pagetotal);
	    $query = $this->mysql->query("select * from {$this->pre}shop order by id desc limit ".$this->page->start.",".$this->page->size);
	    while($rs=$this->mysql->assoc($query)){
		    $rs['editurl'] = rewrite::request("?mod={$this->module}&act={$this->action}&get=edit&id=".$rs['id']);
		    $rs['delurl'] = rewrite::request("?mod={$this->module}&act={$this->action}&get=del&id=".$rs['id']);
	  	    $rs['addtime'] = formattime($rs['addtime'],"Y-m-d");
			$rs['checked'] = $rs['checked'] ? "是" : "否";
		    $rs['typename'] = $this->mysql->value("{$this->pre}shoptype",'typename',"id='$rs[typeid]'");
		    $this->companylist[]=$rs;
	    }	  
	  }
	  
	  if($_GET['get']=='add'||$_GET['get']=='edit'){
		$id = $_GET['id'];
        if(submit()){
		  $arr['name'] = sintrim($_POST['name']);
		  $arr['market'] = $_POST['market'];
		  $arr['money'] = $_POST['money'];
		  $arr['pics'] = implode('|',$_POST['uploadlist']);
		  $arr['typeid'] = $_POST['typeid'];
		  $arr['addtime'] = untime($_POST['addtime']);
		  $arr['content'] = $_POST['content'];
		  $arr['checked'] = $_POST['checked']; 
		  if($id){
			 $message = '编辑商品成功';
             $this->mysql->update("{$this->pre}shop",$arr,"id='$id'"); 
		  }else{
			 $message = '添加商品成功';
             $this->mysql->insert("{$this->pre}shop",$arr); 
		  }
		  $this->message('admin_shop',$message);
	    }
	    $typequery = $this->mysql->query("select * from {$this->pre}shoptype order by `typeorder` asc");
	    while($typers=$this->mysql->assoc($typequery)){
		  $this->typelist .= "[<$typers[id]><$typers[typename]>]";;
	    }
		if($_GET['get']=='edit'){
          $this->company = $this->mysql->select_one("select * from {$this->pre}shop where id='$id'");
		  $this->company['pics'] = array_filter(explode('|',$this->company['pics']));
	      if(!is_array($this->company)) $this->message('go_back','对不起，该商品信息不存在');	  
		}else{
		  $this->company['addtime'] = time();
		  $this->company['checked'] = 1;
	    }
	  } 
	  
	  if($_GET['get']=='del'){
		$this->mysql->delete("{$this->pre}shop","id={$_GET['id']}");  
	    $this->message('go_back','删除商品成功');	  	
	  }
	  
	  
	  if($_GET['get']=='type'){
        if(submit()){
			$arrid = $_POST['id'];
			$arrtypename = $_POST['typename'];
			$arrtypeorder = $_POST['typeorder'];
			foreach($arrid as $k=>$v){
			  $arr['typename'] = $arrtypename[$k];
			  $arr['typeorder'] = $arrtypeorder[$k]; 
			  if($v == ''){
                 $this->mysql->insert("{$this->pre}shoptype",$arr); 
			  }else{
                $this->mysql->update("{$this->pre}shoptype",$arr,"id='$v'"); 
			  }
			}
	        $this->message('go_back','商品分类操作成功');	  
	    }
	    $query = $this->mysql->query("select * from {$this->pre}shoptype order by typeorder asc");
	    $this->typelist=array();
	    while($rs=$this->mysql->assoc($query)){
		    $rs['delurl'] = rewrite::request("?mod={$this->module}&act={$this->action}&get=typedel&id=".$rs['id']);
		    $this->typelist[]=$rs;
	    }
	  }
	  
	  if($_GET['get']=='typedel'){
		$this->mysql->delete("{$this->pre}shoptype","id={$_GET['id']}");  
	    $this->message('go_back','删除商品分类成功');	  	
	  }
	  

	  if($_GET['get']=='order'){
		if($_GET['id']){
		   $order = $this->mysql->select_one("select * from {$this->pre}order where id='{$_GET['id']}'");
		   if(!is_array($order)) $this->message('go_back','对不起，请不要非法操作');
		   $arr['checked'] = $order['checked'] ? 0 : 1;
		   $message = $order['checked'] ? "取消发货成功" : "确认发货成功";
	       if($this->mysql->update("{$this->pre}order",$arr,"id='{$_GET['id']}'")) $this->message('go_back',$message);
		}
	    $pagetotal = $this->pagetotal = $this->mysql->counts("select id from {$this->pre}order");
	    $this->pageclass($pagetotal);
	    $query = $this->mysql->query("select * from {$this->pre}order order by checked asc,id desc limit {$this->page->start},{$this->page->size}");
	    while($rs=$this->mysql->assoc($query)){
		    $rs['shopname'] = explode('|##|',$rs['shopname']);
			$this->order[] = $rs;
	    } 
	  }

	}	
   
   
}
?>