1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace app\common\service;
- use file\DirHelper;
- use think\Controller;
- class WebService extends Controller
- {
-
- public function checkInstalled()
- {
- if ($this->request->module() != 'install' && !is_installed()) {
-
- $this->redirect("/install");
- }
- }
-
- public function checkOpenUserModule()
- {
- if (empty(\think\Env::get("open_user_module", false))) {
- $this->error('暂不开放此功能', '/');
- }
- }
-
- public function record($msg = "")
- {
- $savePath = RUNTIME_PATH . "notify_log" . DS . date('Y-m-d', time()) . DS;
- DirHelper::makeDir($savePath);
- $saveFile = $savePath . date('H-i-s_', time()) . '_' . rand(1000, 9999) . ".log";
- $input = "TIME: " . date('Y-m-d H:i:s', time()) . PHP_EOL
- . "URL: " . $this->request->url() . PHP_EOL
- . "MESSAGE: " . $msg . PHP_EOL . PHP_EOL;
- if ($this->request->isGet() && $this->request->get()) {
- $input = $input . "METHOD: " . "GET" . PHP_EOL
- . "PARAMS: " . json_encode($this->request->get(), JSON_UNESCAPED_UNICODE) . PHP_EOL . PHP_EOL;
- } elseif ($this->request->isPost() && $this->request->param()) {
- $input = $input . "METHOD: " . "POST" . PHP_EOL
- . "PARAMS: " . json_encode($this->request->param(), JSON_UNESCAPED_UNICODE) . PHP_EOL . PHP_EOL;
- }
- $callbackBody = file_get_contents('php://input');
- if ($callbackBody) {
- $input = $input . "METHOD: " . "INPUT" . PHP_EOL
- . "PARAMS: " . json_encode($callbackBody, JSON_UNESCAPED_UNICODE) . PHP_EOL . PHP_EOL;
- }
- if (false == file_put_contents($saveFile, $input)) {
- exit("创建文件失败,请检查目录权限");
- }
- return $msg;
- }
- }
|