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