Created
June 6, 2019 06:32
-
-
Save anushshukla/20efde0f0a747608dde55c157d0f6e3b to your computer and use it in GitHub Desktop.
PHP file to send responses, parse request and etc.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| if(!function_exists("server")) { | |
| function server() { | |
| return new Server(func_get_args()); | |
| } | |
| } | |
| class Server { | |
| private CONST SERVICES = ["www","http","https","mysql","smtp","imap","pop3","ftp","ssh","sftp","telnet","nicname","gopher","finger"]; | |
| private CONST PROTOCOL = ["tcp","udp"]; | |
| private CONST VALID_KEYS = ["all"=>"a","os"=>"s","release"=>"r","version"=>"v","bits"=>"m","hostname"=>"n"]; | |
| private $protocol = $_SERVER['SERVER_PROTOCOL']; | |
| private $port = $_SERVER['SERVER_PORT']; | |
| private function __construct() | |
| { | |
| var_dump(posix_geteuid()); | |
| var_dump(get_current_user()); | |
| var_dump(getmyuid()); | |
| var_dump(exec('whoami')); | |
| var_dump(gethostname()) | |
| } | |
| function getInfo($key) { | |
| if(!array_key_exists($key,Server::$VALID_KEYS)){ | |
| throw new Exception("$key is invalid! Please enter a value from ".print_r(Server::VALID_KEYS,true),422); | |
| } | |
| return php_uname(Server::$VALID_KEYS[$key]); | |
| } | |
| function port($serviceName) { | |
| foreach (Server::SERVICES as $service) { | |
| $port = getservbyname($service, 'tcp'); | |
| echo $service . ":- " . $port . "<br />\n"; | |
| } | |
| } | |
| function php_extns_loaded() { | |
| return get_loaded_extensions(); | |
| } | |
| function php_extn_isLoaded($name=null) { | |
| return extension_loaded($name); | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment