vigge_sWe
By: a guest | Mar 15th, 2010 | Syntax:
PHP | Size: 1.36 KB | Hits: 29 | Expires: Never
<?php
include("includes/config.php");
$add = new AddSite;
class AddSite {
public function __construct() {
if($this->formSubmitted()) {
$this->addSite($_POST['name'], $_POST['url'], $_POST['ports'], isset($_POST['email']));
} else {
echo "Please submit the form first";
}
}
public function formSubmitted(){
if(!isset($_POST['submit'])||empty($_POST['name'])||empty($_POST['url'])||empty($_POST['ports'])){
return false;
}
return true;
}
public function addSite($name, $url, $ports, $email) {
global $host, $username, $password, $database;
if($mysqli = new mysqli($host,$username,$password,$database)){
$nameSanitized = $mysqli->real_escape_string($name);
$urlSanitized = $mysqli->real_escape_string($url);
$portsSanitized = $mysqli->real_escape_string($ports);
$emailSanitized = $mysqli->real_escape_string($email);
$port = explode('|', $ports);
$count = count($port);
$status = "";
foreach($port as $p){
@$fp = fsockopen($url,$p, $errno, $errstr, 5);
if($fp){
$status += "up|";
} else {
$status += "down|";
}
}
echo $status;
} else {
echo "There was an error connecting to the DB";
}
}
}
?>