$_Get $_Post $_Session $_Cookie $_Files $_Server Girdilerini Temizlemek

<?php
session_start();
class girdi{
	function girdi(){
		if(get_magic_quotes_gpc()){
			if(isset($_GET)		&& !isset($this->get))		$this->get		=	$this->temiz($_GET,false);
			if(isset($_POST)	&& !isset($this->post))		$this->post		=	$this->temiz($_POST,false);
			if(isset($_COOKIE)	&& !isset($this->cookie))	$this->cookie	=	$this->temiz($_COOKIE,false);
			if(isset($_SESSION)	&& !isset($this->session))	$this->session	=	$this->temiz($_SESSION,false);
			if(isset($_FILES)	&& !isset($this->files))	$this->files	=	$this->temiz($_FILES,false);
			if(isset($_SERVER)	&& !isset($this->server))	$this->server	=	$this->temiz($_SERVER,false);
		}else{
			if(isset($_GET)		&& !isset($this->get))		$this->get		=	$this->temiz($_GET,true);
			if(isset($_POST)	&& !isset($this->post))		$this->post		=	$this->temiz($_POST,true);
			if(isset($_COOKIE)	&& !isset($this->cookie))	$this->cookie	=	$this->temiz($_COOKIE,true);
			if(isset($_SESSION)	&& !isset($this->session))	$this->session	=	$this->temiz($_SESSION,true);
			if(isset($_FILES)	&& !isset($this->files))	$this->files	=	$this->temiz($_FILES,true);
			if(isset($_SERVER)	&& !isset($this->server))	$this->server	=	$this->temiz($_SERVER,false);
		}
		if(!isset($this->url)) $this->url	=	substr(@$this->server['PATH_INFO'],-1)!='/'?	basename($this->server['SCRIPT_NAME']).@$this->server['PATH_INFO'].'/':basename($this->server['SCRIPT_NAME']).@$this->server['PATH_INFO'];
		
		if(!isset($this->uri))	$this->uri=explode('/',substr(@$this->server['PATH_INFO'],-1)!='/'	?	basename($this->server['SCRIPT_NAME']).@$this->server['PATH_INFO']:basename($this->server['SCRIPT_NAME']).substr(@$this->server['PATH_INFO'],0,-1));
	}
	function temiz($veri, $temiz = true){
		$cikti=null;
		if(is_array($veri)){
			foreach($veri as $girdi=>$deger){
				$cikti[$girdi] = $this->temiz($deger,$temiz);
			}
			return $cikti;
		}elseif($temiz){
			return addslashes($veri);
		}else{
			return $veri;
		}
	}
}
$girdi = new girdi();
print_r($girdi->get);
print_r($girdi->post);
print_r($girdi->session);
print_r($girdi->cookie);
print_r($girdi->files);
print_r($girdi->server);
?>

Çıktısı

Array
(
    [PHPSESSID] => 908egm9dcnr2jqfgog4
)
Array
(
    [TMP] => C:/binaries/tmp
    [HTTP_HOST] => 127.0.0.1
    [HTTP_CONNECTION] => keep-alive
    [HTTP_CACHE_CONTROL] => max-age=0
    [HTTP_UPGRADE_INSECURE_REQUESTS] => 1
    [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.79 Safari/537.36
    [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
    [HTTP_ACCEPT_ENCODING] => gzip, deflate, br
    [HTTP_ACCEPT_LANGUAGE] => tr-TR,tr;q=0.9,en-US;q=0.8,en;q=0.7
    [HTTP_COOKIE] => PHPSESSID=908egm9dcnr2jqfgog4
    [PATH] => C:\php_runningversion; C:\Windows\system32;C:\Apache\bin;C:\PHP
    [SystemRoot] => C:\Windows
    [COMSPEC] => C:\Windows\system32\cmd.exe
    [PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
    [WINDIR] => C:\Windows
    [SERVER_SIGNATURE] => 
    [SERVER_SOFTWARE] => Apache/2.4.7 (Win32) PHP/5.4.24
    [SERVER_NAME] => 127.0.0.1
    [SERVER_ADDR] => 127.0.0.1
    [SERVER_PORT] => 80
    [REMOTE_ADDR] => 127.0.0.1
    [DOCUMENT_ROOT] => C:/data/localweb
    [REQUEST_SCHEME] => http
    [CONTEXT_PREFIX] => 
    [CONTEXT_DOCUMENT_ROOT] => C:/data/localweb
    [SERVER_ADMIN] => admin@127.0.0.1
    [SCRIPT_FILENAME] => C:/data/localweb/index.php
    [REMOTE_PORT] => 535583
    [GATEWAY_INTERFACE] => CGI/1.1
    [SERVER_PROTOCOL] => HTTP/1.1
    [REQUEST_METHOD] => GET
    [QUERY_STRING] => 
    [REQUEST_URI] => /
    [SCRIPT_NAME] => /index.php
    [PHP_SELF] => /index.php
    [REQUEST_TIME_FLOAT] => 152836397.365
    [REQUEST_TIME] => 1528368397
)

 

Uzak Sunucuya Erişim Kontrolü

<?php
class durum{
	function sunucu($adres){
			 if(strstr($adres,"/")){$adres = substr($adres, 0, strpos($adres, "/"));}
			 return $adres;
	}
	function durum($adres="",$port=80,$zamanasimi=3) {
		if($adres=="") $adres = $_SERVER['REMOTE_ADDR'];
		$churl = fsockopen($adres, $port, $errno, $errstr, $zamanasimi); 
		if (!$churl){
			echo 'Sunucu Çevrimdışı';
		} else{
			echo 'Sunucu Çevrimiçi';
		}
	}
	function portkontrol($adres,$zamanasimi,$port) {
		if($adres=="") $adres = $_SERVER['REMOTE_ADDR'];
		$churl = @fsockopen($adres, $port, $errno, $errstr, $zamanasimi); 
		if (!$churl){
			echo "Port $port çalışmıyor";
		}else{
			echo "Port $port çalışıyor";
		}
	}
}
$durum = new durum("216.58.212.46");
echo '<br>';
$durum->portkontrol("216.58.212.46",1,80);//google ip
?>

Çıktısı

Sunucu Çevrimiçi
Port 80 çalışıyor