public function add ($mainname,$charset,$email,$index,$login) {
$mysqli = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
$check = $mysqli->query("SELECT unid FROM vhosts WHERE mainname = '$this->mainname'");
if($check->num_rows>0) { echo "Произошла ошибка. Доменное имя, которое Вы ввели, уже привязано к другому сайту!";exit;}
$mysqli->query("INSERT INTO vhosts (mainname,charset,email,index,userid) VALUES ('$this->mainname' , '$this->charset', '$this->email' , '$this->index' , '$this->login')");
Include 'apacheconf.php';
Include 'nginxconf.php';
$vhostid = $mysqli->mysqli_insert_id;
file_put_contents ("/etc/apache2/sites-available/$vhostid.conf", $apacheconf);
file_put_contents ("/etc/nginx/sites-available/$vhostid", $nginxconf);
}
}
class site
{
public $id;
public $mainname;
public $aliases;
public $charset;
public $email;
public function getsiteinfo($id)
{
$mysqli = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
$getinfo = $mysqli->query("SELECT * FROM vhosts WHERE unid = '$id'");
$info = $getinfo->fetch_assoc();
$getaliases = $mysqli->query("SELECT name FROM domains WHERE vhost = '$id'");
$aliases = $getaliases->fetch_assoc();
$this->mainname = $info['mainname'];
$this->charset = $info['charset'];
$this->email = $info['email'];
$this->aliases = $aliases;
return $this;
}
}
location / {
proxy_pass http://127.0.0.1:81;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location ~ /\.ht {
deny all;
}