diff --git a/classes/_ExtraProcesses.php b/classes/_ExtraProcesses.php new file mode 100644 index 0000000..29a354e --- /dev/null +++ b/classes/_ExtraProcesses.php @@ -0,0 +1,270 @@ +fileLoc = $fileLoc; + $this->fileName = $fileName; + $this->username = $_SESSION['username']; + $this->system = new System; + } + + /** + * @param $action + * @param string $msg + */ + private function writeLog($action, $msg = ""): void + { + $username = "" !== $this->username ? $this->username : "default-user"; + + $this->system->writeLog( + "{$username}.log", + "{$action} >>> " . date("D dS M Y h:i:sa") . " : " . ($this->fileLoc) . "/" . ($this->fileName) . ("" !== $msg ? " : " . $msg : "") . "\n" + ); + } + + /** + * @param string $doNext + * @return string + */ + public function onLoad($doNext = ""): string + { + // PHP example: + // $this->writeLog("LOAD"); + + // JS example: + // $doNext .= "alert('Loaded');"; + + return $doNext; + } + + /** + * + */ + public function onFileLoad(): void + { + // PHP example: + // $this->writeLog("FILE LOAD"); + } + + /** + * @param string $doNext + * @return string + */ + public function onFileSave($doNext = ""): string + { + // PHP example: + // $this->writeLog("SAVE"); + + // JS example: + // $doNext .= "alert('Saved');"; + + return $doNext; + } + + /** + * @param string $doNext + * @return string + */ + public function onGetRemoteFile($doNext = ""): string + { + // PHP example: + // $this->writeLog("GET REMOTE FILE"); + + // JS example: + // $doNext .= "alert('Got remote file');"; + + return $doNext; + + } + + /** + * @param string $doNext + * @param $uploads + * @return string + */ + public function onFileUpload($doNext = "", $uploads = []): string + { + // PHP example: + // foreach ($uploads as $upload) { + // $this->writeLog("UPLOAD FILE", $upload->name); + // } + + // JS example: + // $doNext .= "alert('Uploaded');"; + + return $doNext; + + } + + /** + * @param string $doNext + * @param string $file + * @return string + */ + public function onFileReplaceText($doNext = "", $file = ""): string + { + // PHP example: + // $this->writeLog("REPLACE TEXT IN FILE", $file); + + // JS example: + // $doNext .= "alert('Replaced text in file');"; + + return $doNext; + } + + + /** + * @param string $doNext + * @return string + */ + public function onDirNew($doNext = ""): string + { + // PHP example: + // $this->writeLog("NEW DIR"); + + // JS example: + // $doNext .= "alert('new dir');"; + + return $doNext; + + } + + /** + * @param string $doNext + * @return string + */ + public function onFileDirDelete($doNext = ""): string + { + // PHP example: + // $this->writeLog("DELETE FILE/DIR"); + + // JS example: + // $doNext .= "alert('Deleted file/dir');"; + + return $doNext; + } + + /** + * @param string $doNext + * @param string $file + * @return string + */ + public function onFileDirPaste($doNext = "", $file = ""): string + { + // PHP example: + // $this->writeLog("PASTE FILE/DIR"); + + // JS example: + // $doNext .= "alert('Pasted file/dir');"; + + return $doNext; + } + + /** + * @param string $doNext + * @return string + */ + public function onFileDirMove($doNext = ""): string + { + // PHP example: + // $this->writeLog("MOVE FILE/DIR"); + + // JS example: + // $doNext .= "alert('Moved');"; + + return $doNext; + } + + /** + * @param string $doNext + * @return string + */ + public function onFileDirRename($doNext = ""): string + { + // PHP example: + // $this->writeLog("RENAME FILE/DIR"); + + // JS example: + // $doNext .= "alert('Renamed file/dir');"; + + return $doNext; + } + + /** + * @param string $doNext + * @param string $perms + * @return string + */ + public function onFileDirPerms($doNext = "", $perms = "unknown"): string + { + // PHP example: + // $this->writeLog("PERMS", $perms); + + // JS example: + // $doNext .= "alert('Perms changed to ' + $perms);"; + + return $doNext; + } + + /** + * @param string $username + */ + public function onUserNew($username = ""): void + { + // PHP example: + // $this->writeLog("USER NEW", $username ?? ""); + } + + /** + * @param string $username + */ + public function onUserLogin($username = ""): void + { + // PHP example: + // $this->writeLog("USER LOGIN", $username ?? ""); + } + + /** + * @param string $username + */ + public function onUserLogout($username = ""): void + { + // PHP example: + // $this->writeLog("USER LOGOUT", $username ?? ""); + } + + /** + * @param string $username + */ + public function onUserLoginFail($username = ""): void + { + // PHP example: + // $this->writeLog("USER LOGIN FAIL", $username ?? ""); + } + + /** + * @param string $result + * @param string $status + */ + public function onBugCheckResult($result = "", $status = ""): void + { + // PHP example: + // $this->writeLog("BUG CHECK", $result . " : ". var_export($status, true)); + } +}