GET = $_GET; $this->POST = $_POST; $this->REMOTE_ADDR = $remote_addr; $this->PresetVariables(); $this->CheckGET(); } private function CheckGET(){ // wenn get ip angegeben wurde, ip setzen (fehlt noch) $section = false; if(isset($this->GET['port']) && !empty($this->GET['port']) && !isset($this->GET['type'])){$section = 1;} else if(isset($this->GET['multiport']) && !empty($this->GET['multiport'])){$section = 2;} else if(isset($this->GET['type']) && $this->GET['type'] == 'ip'){$section = 3;} else if(isset($this->GET['type']) && $this->GET['type'] == 'errno'){$section = 5;} else if(isset($this->GET['ip'])){$section = 3;} else if(isset($this->GET['ddns']) && isset($this->GET['type']) && isset($this->GET['type']) == "ddns" && !empty($this->GET['ddns'])){$section = 4;} switch($section){ case 1: $this->ports = array($this->GET['port']); break; case 2: $this->PrepareMultiport(); break; case 3: echo $this->ip; exit; break; case 4: $this->UpdateDDNS(); break; case 5: $this->GetErrno(); break; default: break; } } private function PrintCSS(){ echo ""; } private function PrepareMultiport(){ if(strpos($this->GET['multiport'], ",") > 0) { $this->ports = explode(",", $this->GET['multiport']); } else if (strpos($this->GET['multiport'], "-") > 0) { $maxRange = 20; $secureCount = 0; $pString = ""; $ports = explode("-", $this->GET['multiport']); for($i = $ports[0]; $i <= $ports[1]; $i++){ $pString .= (!empty($pString)?",":""); $pString .= $i; $secureCount++; if($secureCount > $maxRange) break; } $this->ports = explode(",", $pString); } else { $this->ports = array($this->GET['multiport']); } } private function UpdateDDNS(){ if(isset($this->GET['ddns'])) { $url = "http://gsdi:0836e91263f911e4ba179a4836b4ac7e@members.dyndns.org/v3/update?hostname={$this->GET['ddns']}&myip=" . $this->REMOTE_ADDR; header("Location: {$url}"); } else{ echo "Es wurde keine DDNS angegeben!!!"; } } private function PresetVariables(){ $this->imageList = array( "green" => "led_green_light.gif", "red" => "led_red.gif", "red2" => "led_red_light.gif", "blue" => "led_blue.gif", "gray" => "led_grey_light.gif", "orange" => "led_orange_error.gif" ); $this->errors = array( 0 => "Der Port ist offen, die Datenbank ist erreichbar.", 110 => "Der Port ist offen aber die Datenbank ist nicht erreichbar.", 113 => "Der Port is geschlossen!" ); $this->ip = $this->REMOTE_ADDR; $this->ports = array(2155); $this->timeout = 2; $this->rows = ""; } public function GetErrno(){ $port = (isset($this->GET['port']) && !empty($this->GET['port'])?$this->GET['port']:2155); fsockopen($this->ip, $port, $errno, $errstr, $this->timeout); echo $errno; exit; } public function CheckPort(){ $ip = filter_var($this->ip, FILTER_VALIDATE_IP,FILTER_FLAG_IPV4); if(!$ip){ $ip = filter_var($this->ip, FILTER_VALIDATE_IP,FILTER_FLAG_IPV6); $ip = '['.$ip.']'; } foreach($this->ports as $port) { $connection = fsockopen($ip, $port, $errno, $errstr, $this->timeout); switch($errno){ case 0: // Port offen DB erreichbar $img = "/gfx/" . $this->imageList['green']; break; case 110: // Port offen aber DB nicht erreichbar / Zeitüberschreitung $img = "/gfx/" . $this->imageList['orange']; break; case 113: // Port geschlossen $img = "/gfx/" . $this->imageList['red']; break; default: // Standard erst mal Rot! $img = "/gfx/" . $this->imageList['red']; break; } $this->rows .= ""; $this->rows .= "{$port}"; $this->rows .= ""; $this->rows .= "{$errstr}
{$this->errors[$errno]}"; $this->rows .= "{$errno}"; $this->rows .= ""; } $this->CreateView(); } private function CreateView(){ $table = ""; $table .= ""; $table .= ""; $table .= $this->rows; $table .= ""; $table .= "

IP

{$this->ip}

Gescannte PortsStatusErrorError Code
"; $table .= ""; $table .= ""; $table .= ""; $table .= ""; $table .= ""; $table .= ""; $table .= ""; $table .= "

Mögliche Parameter:

?port=[port]Ruft die Abfrage für einen speziellen Port auf
?multiport=[startport]-[endport]Ruft die Abfrage für eine Portrange auf
?multiport=[port1],[port2],[port3]...Ruft die Abfrage für mehrere Ports auf
?ipGibt die IP in Textform zurück
?type=ipGibt ebenfalls die IP in Textform zurück
?type=ddns&ddns=[ddns]aktualisiert die gegebene Dyndns
"; $this->PrintCSS(); echo $table; } } $sdi = new sdigroup($_SERVER['REMOTE_ADDR']); $sdi->CheckPort();