<?php



namespace app\controller;



use think\Controller;



use think\Db; 



 
 






class Admin extends Controller



{
public function pass(){

if(input('up')==1){ 

$user=input('admin_user');
$pass=input('admin_pass');
$rs=db('config')->where('id',1)->update(['admin_user'=>$user,'admin_pass'=>md5($pass)]);

if($rs){



$this->success('修改成功！','/index.php/admin/pass');

}else{

$this->error('修改成功！','/index.php/admin/pass');

}

}


$rs=db('config')->find();


$this->assign('rs',$rs);


return view('pass');
}


public function save(){



$web=input('web');

$website=input('website');

$seo_1=input('seo_1');

$seo_2=input('seo_2');

$seo_3=input('seo_3');

$beian=input('beian');

$tj=input('tj');

$logo=input('logo');

$key_time=input('key_time');

$keys3=input('keys3');

$img_true=input('img_true');

$img_server=input('img_server');

$url_index=input('url_index');

$key_true=input('key_true');

$web_key=input('web_key');

$cache_true=input('cache_true');

$cache_index=input('cache_index');

$cache_list=input('cache_list');

$cache_read=input('cache_read');





$rs=db('config')->where('id',1)->update(['web'=>$web,'website'=>$website,'seo_1'=>$seo_1,'seo_2'=>$seo_2,'seo_3'=>$seo_3,'beian'=>$beian,'tj'=>$tj,'logo'=>$logo,'key_time'=>$key_time,'keys3'=>$keys3,'img_true'=>$img_true,'img_server'=>$img_server,'url_index'=>$url_index,'key_true'=>$key_true,'web_key'=>$web_key,'cache_true'=>$cache_true,'cache_index'=>$cache_index,'cache_list'=>$cache_list,'cache_read'=>$cache_read,'ad'=>input('ad'),'ad3'=>input('ad3')]);



if($rs){



$this->success('保存成功！','/index.php/admin');

}else{

$this->error('没有变动！','/index.php/admin');

}





}





 public function _initialize(){ //初始化

	  

    if(session('admin')==''){

	echo "<script>window.location.href='/index.php/login';</script>";

	}

	

	

	 

      }

	  

	  public function cid(){

	  

	  

	  

	  $user=db('class');

	  

	  

	  if(input('editup')){
$sj=['ntitle'=>input('admin'),'py'=>input('py'),'seo1'=>input('seo1'),'seo2'=>input('seo2'),'seo3'=>input('seo3')];

//echo input('id');
//print_r($sj);
	 

	  $rs=$user->where('Id',input('id'))->update($sj);

	  $this->success('修改成功！','/index.php/admin/cid');

	  }

	  

	  if(input('save')){

	  

	  $rs=$user->insert(['ntitle'=>input('admin'),'zt'=>1,'py'=>input('py'),'seo1'=>input('seo1'),'seo2'=>input('seo2'),'seo3'=>input('seo3')]);

	  

	  }

	  

	  if(input('delete')){

	  

	  $rs=$user->where('Id',input('delete'))->delete();

	  

	  }

	  

	  

	  $sl=$user->count();

	  

	  $this->assign('sl',$sl);

	  

	  

	  if(input('pid')!=''){

	  

	  $pid=explode('-',input('pid'));

	  

	$user->where('id',$pid[1])->update(['pid'=>$pid[0]]);

	  

	  

	  }

	  

	  if(input('nindex')!=''){

	  

	  $user->where('id',input('id'))->update(['nindex'=>input('nindex')]);

	  }

	  

	  

	    if(input('zt')!=''){

	  

	  $user->where('id',input('id'))->update(['zt'=>input('zt')]);

	  }

	  

	  $rs=$user->order('pid,id desc')->select();

	  $id=input('id');
	  if($id){
      $cid=$user->where('id',$id)->find();
	  
	  $this->assign('cid',$cid);
	  }
	  $this->assign('rs',$rs);

	  

	  return view('content');

	  

	  }





    public function index()



    {



	

	$rs=db('config')->where('id',1)->find();

	 

	 

	 

	 $this->assign('rs',$rs);

	



	

  return view('system');



    }

	

	

	

	

	

	

	



}



