extraPath = config_path() . 'extra/'; if (!is_dir($this->extraPath)) { if (is_writable(config_path())) { mkdir($this->extraPath, 0777, true); } else { halt('请联系系统管理人员配置文件夹读写权限!请添加'.$this->extraPath.'文件夹的读写权限'); } } elseif (!is_writable($this->extraPath)) { halt('请联系系统管理人员配置文件夹读写权限!请添加'.$this->extraPath.'文件夹的读写权限'); } } public function wechat() { if ($this->request->isPost()) { $data = input("post."); unset($data['_token']); $php = var_export($data, true); file_put_contents($this->extraPath . 'wechat.php', 'json(); } else { CConfig::load('extra/wechat', 'wechat'); $this->data['item'] = config('wechat'); return $this->view(); } } public function alipay() { if ($this->request->isPost()) { $data = input("post."); unset($data['_token']); $php = var_export($data, true); file_put_contents($this->extraPath . 'alipay.php', 'json(); } else { CConfig::load('extra/alipay', 'alipay'); $this->data['item'] = config('alipay'); return $this->view(); } } public function upload() { if ($this->request->isPost()) { $data = input("post."); System::updateById(1,$data); unset($data['_token']); $php = var_export($data, true); file_put_contents($this->extraPath . 'upload.php', 'json(); } else { CConfig::load('extra/upload', 'system_upload'); if(empty(config('system_upload'))){ $this->data['item'] = System::findById(1); }else{ $this->data['item'] = config('system_upload'); } return $this->view(); } } public function __call($name, $args) { if ($this->request->isPost()) { try { $data = input("post."); $php = var_export($data, true); file_put_contents(config_path().'extra/'.$name.'.php', 'json(); } catch (Exception $e) { return $this->json(4001, $e->getMessage()); } } else { CConfig::load('extra/'.$name, $name); $this->data['item'] = config($name); $this->data['action'] = $name; return $this->view('manager/config/'.$name); } } }