config=D('Config'); } public function index() { $activate = M('activate_list'); $count = $activate->count(); $p = getpage($count,8); $list = $activate->field(true)->order('id desc')->limit($p->firstRow, $p->listRows)->select(); $this->assign('meta_title','激活列表'); $this->assign('list', $list); // 赋值数据集 $this->assign('page', $p->show()); // 赋值分页输出 $this->display(); } public function detail() { $id = I('id'); if (empty($id)) { $this->error('id不能为空'); } $detail = M('activate_list') ->where('id = '.$id)->select(); //判断激活状态 $a = $detail[0][succ]+$detail[0][fail]; if($a==0){ $status = 0; }else if($detail['num']>$a){ $status = 1; }else{ $status = 1; } //读取文件 start $upload = "Data/Code_Active_list/".$detail[0][active_batch].'/0/'; $active = "Data/Code_Active_list/".$detail[0][active_batch].'/1/'; $upload_files=scandir($upload); $upload_txt = ''; $active_files=scandir($active); $active_txt = ''; foreach($upload_files as $key ){ if(get_extension($key)=='txt'){ //更新缓存 $upload_txt.=$key.'  '; } } if($upload_txt==''){ $upload_txt = '无'; } foreach($active_files as $key ){ if(get_extension($key)=='txt'){ //更新缓存 $active_txt.=$key.'  '; } } if($active_txt==''){ $active_txt = '无'; } $this->assign('upload_txt', $upload_txt); $this->assign('active_txt', $active_txt); //读取文件 stop $this->assign('status', $status); $this->assign('detail', $detail); $this->assign('meta_title', '激活详情'); $this->display(); } public function add() { if (IS_POST) { $activate = M('activate_list'); $list = array(); $list['active_batch'] = $_POST['active_batch']; /*查询 start*/ $list['active_batch'] = repeat($list['active_batch']); /*查询 stop*/ $list['remark'] = $_POST['remark']; $list['status'] = 0; $list['time'] = time(); $return = $activate->add($list); if($return){ //创建激活文件夹 $dir = 'Data/Code_Active_list/'.$list['active_batch']; if(!file_exists($dir.'/0')){ mkdir($dir.'/0',0777,true); } if(!file_exists($dir.'/1')){ mkdir($dir.'/1',0777,true); } alert(array('info' => '申请成功', 'url' => "index.php?s=/Admin/Activatelist/index.html", 'status' => 1)); }else{ alert(array('info' => '申请失败', 'url' => "index.php?s=/Admin/Activatelist/add.html", 'status' => 0)); } }else{ $res = M('activate_list')->field('id')->order('id desc')->limit(1)->find(); $rand = $res['id']+100000+1; $this->assign('rand',$rand); $this->display(); } } }