<?php
namespace app\admin\controller;
use think\Controller;
class Baidu extends Common
{
    
	
	public function index()
    {
       return view();
    }

	public function add()
    {
     if (warning() == shul()) {
       $path = 'application/extra/baidu.php';
       $file = include $path;      
       $config = array(
         'http' => input('http'),
         'key' => input('key'),
         'keys' => input('keys'),
       );
       $res = array_merge($file, $config);
       $str = '<?php return [';
       foreach ($res as $key => $value){
           $str .= '\''.$key.'\''.'=>'.'\''.$value.'\''.',';
       };
       $str .= ']; ';
       if(file_put_contents($path, $str)){
           return json(array('code'=>200,'msg'=>'修改成功'));
       }else {
           return json(array('code'=>0,'msg'=>'修改失败'));
       }
       }else {
           return json(array('code'=>0,'msg'=>config('web.sq')));
       }
    }
}
