From b7f62fd70aabc13b0c60b45073d86f501506e9ed Mon Sep 17 00:00:00 2001 From: hide_d Date: Mon, 23 Sep 2019 00:01:06 +0900 Subject: [PATCH] =?UTF-8?q?Hash=20Key=20Installer=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hook/InstallKey.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 hook/InstallKey.php diff --git a/hook/InstallKey.php b/hook/InstallKey.php new file mode 100644 index 0000000..d252065 --- /dev/null +++ b/hook/InstallKey.php @@ -0,0 +1,36 @@ +false, + 'reason'=>'Unknown', +]; + +$key = $_REQUEST['key']??''; + +if (!$key) { + $json_response['reason'] = 'no key'; + die(json_encode($json_response)); +} + +if (strlen($key)<16) { + $json_response['reason'] = 'key is too short'; + die(json_encode($json_response)); +} + +$keyExists = file_exists(__DIR__.'/HashKey.php'); +if($keyExists){ + $json_response['reason'] = 'already exists'; + die(json_encode($json_response)); +} + +$keyTemplate = file_get_contents(__DIR__.'/HashKey.orig.php'); +$keyFile = str_replace('=HashKey=', $key, $keyTemplate); +file_put_contents(__DIR__.'/HashKey.php', $keyFile); + +$json_response['result'] = true; +$json_response['reason'] = 'success'; +die(json_encode($json_response)); \ No newline at end of file