#535 Webspace: User can manage domains

This commit is contained in:
Ulrich Block 2015-05-14 18:06:34 +02:00
parent aac850ca44
commit 63a83ef43f
20 changed files with 816 additions and 201 deletions

View File

@ -52,6 +52,19 @@ if (isset($include) and $include == true) {
$query = $sql->prepare("DELETE FROM `easywi_statistics`");
$query->execute();
$query = $sql->prepare("SELECT `webVhostID`,`userID`,`resellerID`,`dns`,`ownVhost`,`vhostTemplate` FROM `webVhost`");
$query->execute();
$query2 = $sql->prepare("INSERT INTO `webVhostDomain` (`webVhostID`,`userID`,`resellerID`,`domain`,`path`,`ownVhost`,`vhostTemplate`) VALUES (?,?,?,?,'',?,?)");
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
// Try catch as some admins might have maintained domains not be so unique
try {
$query2->execute(array($row['webVhostID'], $row['userID'], $row['resellerID'], $row['dns'], $row['ownVhost'], $row['vhostTemplate']));
$response->add('Migrated ' . $row['dns'] . ' to new table.');
} catch(PDOException $error) {
$response->add($error->getMessage());
}
}
$response->add('Repairing tables if needed.');
include(EASYWIDIR . '/stuff/methods/tables_repair.php');

View File

@ -46,11 +46,12 @@ function loadServerSettings (serverType, usageType) {
defaultVhostTemplate = 'server {\r\n';
defaultVhostTemplate += ' listen 80;\r\n';
defaultVhostTemplate += ' server_name %url%;\r\n';
defaultVhostTemplate += ' server_name %domain%;\r\n';
defaultVhostTemplate += ' autoindex off;\r\n';
defaultVhostTemplate += ' access_log %vhostpath%/%user%/%logDir%/access.log;\r\n';
defaultVhostTemplate += ' error_log %vhostpath%/%user%/%logDir%/error.log;\r\n';
defaultVhostTemplate += ' root %vhostpath%/%user%/%htdocs%/;\r\n';
defaultVhostTemplate += ' access_log %vhostpath%/%user%/%logDir%/access_%domain%.log;\r\n';
defaultVhostTemplate += ' error_log %vhostpath%/%user%/%logDir%/error_%domain%.log;\r\n';
defaultVhostTemplate += ' root %vhostpath%/%user%/%htdocs%/%path%/;\r\n';
if (usageType == 'W') {
@ -69,7 +70,7 @@ function loadServerSettings (serverType, usageType) {
defaultVhostTemplate += ' fastcgi_pass unix:/var/run/php5-fpm.sock;\r\n';
defaultVhostTemplate += ' fastcgi_index index.php;\r\n';
defaultVhostTemplate += ' include fastcgi_params;\r\n';
defaultVhostTemplate += ' fastcgi_param PHP_VALUE "open_basedir=%vhostpath%/%user%/%htdocs%\nsession.save_path=%vhostpath%/%user%/sessions\nupload_tmp_dir=%vhostpath%/%user%/tmp\nallow_url_fopen=Off\nallow_url_include=Off\n%phpConfiguration%";\r\n';
defaultVhostTemplate += ' fastcgi_param PHP_VALUE "open_basedir=%vhostpath%/%user%/%htdocs%/%path%\nsession.save_path=%vhostpath%/%user%/sessions\nupload_tmp_dir=%vhostpath%/%user%/tmp\nallow_url_fopen=Off\nallow_url_include=Off\n%phpConfiguration%";\r\n';
defaultVhostTemplate += ' }\r\n';
} else {
@ -88,10 +89,10 @@ function loadServerSettings (serverType, usageType) {
defaultVhostTemplate = '<VirtualHost *:80>\r\n';
defaultVhostTemplate += ' ServerAdmin %email%\r\n';
defaultVhostTemplate += ' DocumentRoot "%vhostpath%/%user%/%htdocs%"\r\n';
defaultVhostTemplate += ' ServerName %url%\r\n';
defaultVhostTemplate += ' ErrorLog "%vhostpath%/%user%/%logDir%/error.log"\r\n';
defaultVhostTemplate += ' CustomLog "%vhostpath%/%user%/%logDir%/access.log" common\r\n';
defaultVhostTemplate += ' DocumentRoot "%vhostpath%/%user%/%htdocs%/%path%"\r\n';
defaultVhostTemplate += ' ServerName %domain%\r\n';
defaultVhostTemplate += ' ErrorLog "%vhostpath%/%user%/%logDir%/error_%domain%.log"\r\n';
defaultVhostTemplate += ' CustomLog "%vhostpath%/%user%/%logDir%/access_%domain%.log" common\r\n';
if (usageType == 'W') {
@ -100,7 +101,7 @@ function loadServerSettings (serverType, usageType) {
defaultVhostTemplate += ' AssignUserId %user% %group%\r\n';
defaultVhostTemplate += ' MaxClientsVHost 50\r\n';
defaultVhostTemplate += ' NiceValue 10\r\n';
defaultVhostTemplate += ' php_admin_value open_basedir "%vhostpath%/%user%/%htdocs%"\r\n';
defaultVhostTemplate += ' php_admin_value open_basedir "%vhostpath%/%user%/%htdocs%/%path%"\r\n';
defaultVhostTemplate += ' php_admin_value session.save_path "%vhostpath%/%user%/sessions"\r\n';
defaultVhostTemplate += ' php_admin_value upload_tmp_dir "%vhostpath%/%user%/tmp"\r\n';
defaultVhostTemplate += ' php_admin_flag allow_url_fopen Off\r\n';
@ -110,7 +111,7 @@ function loadServerSettings (serverType, usageType) {
}
defaultVhostTemplate += ' <Directory %vhostpath%/%user%/%htdocs%>\r\n';
defaultVhostTemplate += ' <Directory %vhostpath%/%user%/%htdocs%/%path%>\r\n';
defaultVhostTemplate += ' Options -Indexes FollowSymLinks Includes\r\n';
defaultVhostTemplate += ' AllowOverride All\r\n';
defaultVhostTemplate += ' Order allow,deny\r\n';
@ -122,10 +123,10 @@ function loadServerSettings (serverType, usageType) {
defaultRestartCMD = 'sudo /etc/init.d/lighttpd reload';
defaultVhostTemplate = '$HTTP["host"] == "%url%" {\r\n';
defaultVhostTemplate += ' server.document-root = "%vhostpath%/%user%/%htdocs%"\r\n';
defaultVhostTemplate += ' server.errorlog = "%vhostpath%/%user%/%logDir%/error.log"\r\n';
defaultVhostTemplate += ' accesslog.filename = "%vhostpath%/%user%/%logDir%/access.log"\r\n';
defaultVhostTemplate = '$HTTP["host"] == "%domain%" {\r\n';
defaultVhostTemplate += ' server.document-root = "%vhostpath%/%user%/%htdocs%/%path%"\r\n';
defaultVhostTemplate += ' server.errorlog = "%vhostpath%/%user%/%logDir%/error_%domain%.log"\r\n';
defaultVhostTemplate += ' accesslog.filename = "%vhostpath%/%user%/%logDir%/access_%domain%.log"\r\n';
defaultVhostTemplate += ' dir-listing.activate = "disable""\r\n';
defaultVhostTemplate += '}';
@ -134,10 +135,10 @@ function loadServerSettings (serverType, usageType) {
defaultRestartCMD = 'sudo /etc/init.d/hiawatha reload';
defaultVhostTemplate = 'VirtualHost {\r\n';
defaultVhostTemplate += ' Hostname = %url%\r\n';
defaultVhostTemplate += ' WebsiteRoot = %vhostpath%/%user%/%htdocs%\r\n';
defaultVhostTemplate += ' AccessLogfile = %vhostpath%/%user%/%logDir%/access.log\r\n';
defaultVhostTemplate += ' ErrorLogfile = %vhostpath%/%user%/%logDir%/error.log\r\n';
defaultVhostTemplate += ' Hostname = %domain%\r\n';
defaultVhostTemplate += ' WebsiteRoot = %vhostpath%/%user%/%htdocs%/%path%\r\n';
defaultVhostTemplate += ' AccessLogfile = %vhostpath%/%user%/%logDir%/access_%domain%.log\r\n';
defaultVhostTemplate += ' ErrorLogfile = %vhostpath%/%user%/%logDir%/error_%domain%.log\r\n';
defaultVhostTemplate += ' ShowIndex = No\r\n';
defaultVhostTemplate += '}';

View File

@ -9,7 +9,7 @@
<api>API</api>
<apiAuth>Externe Authentifizierung</apiAuth>
<appMaster>App Master</appMaster>
<appRoot>App Server</appRoot>
<appRoot>App/Game Master</appRoot>
<backup>Backup</backup>
<change>ändern</change>
<chosenNoResult>Kein Suchergebnis für</chosenNoResult>

View File

@ -1,10 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<sprache>
<aRecordMissing>A Record der Domain %domain% nicht auf die IP %ip% konfiguriert</aRecordMissing>
<blocksize>Block Größe</blocksize>
<defaultdns>Standard Domain</defaultdns>
<dirHttpd>Htdocs Verzeichnis</dirHttpd>
<dirLogs>Logs Verzeichnis</dirLogs>
<dns>Domain</dns>
<domainNotUsed>Unzulässige Domain %domain% verworfen</domainNotUsed>
<error_password_not_match>FTP Passwörter stimmen nicht überein</error_password_not_match>
<error_password_not_set>FTP Passwort unzulässig, nicht angegeben, oder Wiederholung nicht angegeben.</error_password_not_set>
<fdlInfo>FastDL Info</fdlInfo>
@ -17,6 +19,7 @@
<hddOverbook>HDD Überbuchen</hddOverbook>
<hddUsage>Belegter Speicherplatz</hddUsage>
<help_blocksize>Bei den meisten Systemen beträgt die Block Größe 4096. D.h. ein Block enthält 4096 Byte an Daten.</help_blocksize>
<help_default_dns>Diese (Sub) Domain kann im Domain Bereich eingegeben werden. Wird sie in diesem entfernt, ist sie inaktiv.</help_default_dns>
<help_fdl_attention>Achtung! Es wird empfohlen, dass man je Spiel einen eigenen Unterordner wie cod4, cstrike, css, etc. erstellt und den Ordner in der Config mit angibt.</help_fdl_attention>
<help_fdl_hl>Half-Life 1 (CS 1.6, TFC, DOD, etc.) und Half-Life 2 (CSS, CSGO, DODS, L4D2, TF2, etc.) basierende Server brauchen folgenden Eintrag in der server.cfg</help_fdl_hl>
<help_fdl_cod>Call of Duty Server brauchen folgenden Eintrag in der server.cfg</help_fdl_cod>
@ -32,6 +35,8 @@
<other>Andere</other>
<overbookPercent>Überbuchen um</overbookPercent>
<ownVhost>Eigenes Vhosttemplate</ownVhost>
<path>Pfad</path>
<pathCorrected>Pfad von %pathGiven% zu %pathConverted% zur Domain %domain% korrigiert</pathCorrected>
<phpConfiguration>PHP Konfiguration</phpConfiguration>
<quotaActive>Quotas Aktivieren</quotaActive>
<quotaCmd>Quota Befehl</quotaCmd>

View File

@ -9,7 +9,7 @@
<api>API</api>
<apiAuth>External authentication</apiAuth>
<appMaster>App master</appMaster>
<appRoot>App server</appRoot>
<appRoot>App/Game master</appRoot>
<backup>Backup</backup>
<change>Change</change>
<chosenNoResult>No result found for</chosenNoResult>

View File

@ -1,10 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<sprache>
<aRecordMissing>A record for domain %domain% not configured to %ip%</aRecordMissing>
<blocksize>Blocksize</blocksize>
<defaultdns>Default Domain</defaultdns>
<dirHttpd>Htdocs Folder</dirHttpd>
<dirLogs>Logs Folder</dirLogs>
<dns>Domain</dns>
<domainNotUsed>Skipped not allowed domain %domain%</domainNotUsed>
<error_password_not_match>FTP passwords does not match</error_password_not_match>
<error_password_not_set>FTP password not allowed, not set, or not repeated.</error_password_not_set>
<fdlInfo>FastDL Info</fdlInfo>
@ -17,6 +19,7 @@
<hddOverbook>HDD Overbooking</hddOverbook>
<hddUsage>Used Diskspace</hddUsage>
<help_blocksize>Most filesystems are configured with a blocksize of 4096. This means one block contains 4096 Byte data.</help_blocksize>
<help_default_dns>This (sub) domain can be entered at domains. In case it is removed at the domain management, this default one is deactivated.</help_default_dns>
<help_fdl_attention>Warning! Recommended method is to create a subfolder for each game. Naming could be like cod4, cstrike, css, etc.</help_fdl_attention>
<help_fdl_hl>Half-Life 1 (CS 1.6, TFC, DOD, etc.) and Half-Life 2 (CSS, CSGO, DODS, L4D2, TF2, etc.) based servers need entries like this at the server.cfg</help_fdl_hl>
<help_fdl_cod>Call of Duty Server require eintries like this at the server.cfg</help_fdl_cod>
@ -32,6 +35,8 @@
<other>Other</other>
<overbookPercent>Overbook</overbookPercent>
<ownVhost>Own Vhost Template</ownVhost>
<path>Path</path>
<pathCorrected>Path belonging to domain %domain% corrected from %pathGiven% to %pathConverted%</pathCorrected>
<phpConfiguration>PHP Configuration</phpConfiguration>
<quotaActive>Activate Quotas</quotaActive>
<quotaCmd>Quota Command</quotaCmd>

View File

@ -116,7 +116,7 @@ if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
if ($ui->st('action', 'post') == 'ad') {
$query = $sql->prepare("INSERT INTO `mysql_external_servers` (`externalID`,`active`,`ip`,`port`,`user`,`password`,`max_databases`,`interface`,`max_queries_per_hour`,`max_updates_per_hour`,`max_connections_per_hour`,`max_userconnections_per_hour`,`connect_ip_only`,`external_address`,`resellerid`) VALUES (?,?,?,?,?,AES_ENCRYPT(?,?),?,?,?,?,?,?,?)");
$query = $sql->prepare("INSERT INTO `mysql_external_servers` (`externalID`,`active`,`ip`,`port`,`user`,`password`,`max_databases`,`interface`,`max_queries_per_hour`,`max_updates_per_hour`,`max_connections_per_hour`,`max_userconnections_per_hour`,`connect_ip_only`,`external_address`,`resellerid`) VALUES (?,?,?,?,?,AES_ENCRYPT(?,?),?,?,?,?,?,?,?,?,?)");
$query->execute(array($externalID, $active, $ip, $port, $user, $password, $aeskey, $max_databases, $interface, $max_queries_per_hour, $max_updates_per_hour, $max_connections_per_hour, $max_userconnections_per_hour, $connectIpOnly, $externalAddress, $resellerLockupID));
$rowCount = $query->rowCount();

View File

@ -150,44 +150,115 @@ php_admin_flag mod_rewrite off = OFF';
if (!$vhostTemplate or strlen($vhostTemplate) < 2) {
if ($serverType == 'N') {
$vhostTemplate = 'server {
if ($usageType == 'F') {
$vhostTemplate = 'server {
listen 80;
server_name %url%;
server_name %domain%;
autoindex off;
access_log %vhostpath%/%user%/%logDir%/access.log;
error_log %vhostpath%/%user%/%logDir%/error.log;
root %vhostpath%/%user%/%htdocs%/;
access_log %vhostpath%/%user%/%logDir%/access_%domain%.log;
error_log %vhostpath%/%user%/%logDir%/error_%domain%.log;
root %vhostpath%/%user%/%htdocs%/%path%/;
location / {
index index.html index.htm;
}
}';
} else {
$vhostTemplate = 'server {
listen 80;
server_name %domain%;
autoindex off;
access_log %vhostpath%/%user%/%logDir%/access_%domain%.log;
error_log %vhostpath%/%user%/%logDir%/error_%domain%.log;
root %vhostpath%/%user%/%htdocs%/%path%/;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
location ~ .php$ {
# fastcgi_split_path_info ^(.+.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param PHP_VALUE "open_basedir=%vhostpath%/%user%/%htdocs%/%path%
session.save_path=%vhostpath%/%user%/sessions
upload_tmp_dir=%vhostpath%/%user%/tmp
allow_url_fopen=Off
allow_url_include=Off
%phpConfiguration%";
}
}';
}
} else if ($serverType == 'A') {
$vhostTemplate = '<VirtualHost *:80>
if ($usageType == 'F') {
$vhostTemplate = '<VirtualHost *:80>
ServerAdmin %email%
DocumentRoot "%vhostpath%/%user%/%htdocs%"
ServerName %url%
ErrorLog "%vhostpath%/%user%/%logDir%/error.log"
CustomLog "%vhostpath%/%user%/%logDir%/access.log" common
<Directory %vhostpath%/%user%/%htdocs%>
DocumentRoot "%vhostpath%/%user%/%htdocs%/%path%"
ServerName %domain%
ErrorLog "%vhostpath%/%user%/%logDir%/error_%domain%.log"
CustomLog "%vhostpath%/%user%/%logDir%/access_%domain%.log" common
<Directory %vhostpath%/%user%/%htdocs%/%path%>
Options -Indexes FollowSymLinks Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>';
} else {
$vhostTemplate = '<VirtualHost *:80>
ServerAdmin %email%
DocumentRoot "%vhostpath%/%user%/%htdocs%/%path%"
ServerName %domain%
ErrorLog "%vhostpath%/%user%/%logDir%/error_%domain%.log"
CustomLog "%vhostpath%/%user%/%logDir%/access_%domain%.log" common
DirectoryIndex index.php index.html
<IfModule mpm_itk_module>
AssignUserId %user% %group%
MaxClientsVHost 50
NiceValue 10
php_admin_value open_basedir "%vhostpath%/%user%/%htdocs%/%path%"
php_admin_value session.save_path "%vhostpath%/%user%/sessions"
php_admin_value upload_tmp_dir "%vhostpath%/%user%/tmp"
php_admin_flag allow_url_fopen Off
php_admin_flag allow_url_include Off
%phpConfiguration%
</IfModule>
<Directory %vhostpath%/%user%/%htdocs%/%path%>
Options -Indexes FollowSymLinks Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>';
}
} else if ($serverType == 'L') {
$vhostTemplate = '$HTTP["host"] == "%url%" {
server.document-root = "%vhostpath%/%user%/%htdocs%"
server.errorlog = "%vhostpath%/%user%/%logDir%/error.log"
accesslog.filename = "%vhostpath%/%user%/%logDir%/access.log"
$vhostTemplate = '$HTTP["host"] == "%domain%" {
server.document-root = "%vhostpath%/%user%/%htdocs%/%path%"
server.errorlog = "%vhostpath%/%user%/%logDir%/error_%domain%.log"
accesslog.filename = "%vhostpath%/%user%/%logDir%/access_%domain%.log"
dir-listing.activate = "disable"
}';
} else if ($serverType == 'H') {
$vhostTemplate = 'VirtualHost {
Hostname = %url%
WebsiteRoot = %vhostpath%/%user%/%htdocs%
AccessLogfile = %vhostpath%/%user%/%logDir%/access.log
ErrorLogfile = %vhostpath%/%user%/%logDir%/error.log
Hostname = %domain%
WebsiteRoot = %vhostpath%/%user%/%htdocs%/%path%
AccessLogfile = %vhostpath%/%user%/%logDir%/access_%domain%.log
ErrorLogfile = %vhostpath%/%user%/%logDir%/error_%domain%.log
ShowIndex = No
}';
} else {
@ -291,15 +362,15 @@ if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
// In case the template has been changed we need to add change jobs for every vhost that uses the global template.
if ($oldVhostTemplate != $vhostTemplate) {
$query = $sql->prepare("SELECT `webVhostID`,`webMasterID`,`userID`,`dns` FROM `webVhost` WHERE `webMasterID`=? AND `resellerID`=? AND `ownVhost`='N'");
$query = $sql->prepare("SELECT `webVhostID`,`webMasterID`,`userID` FROM `webVhost` WHERE `webMasterID`=? AND `resellerID`=? AND `ownVhost`='N'");
$query2 = $sql->prepare("INSERT INTO `jobs` (`api`,`type`,`invoicedByID`,`affectedID`,`hostID`,`userID`,`name`,`status`,`date`,`action`,`extraData`,`resellerid`) VALUES ('S','wv',?,?,?,?,?,NULL,NOW(),'md','',?)");
$query->execute(array($id, $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$query2->execute(array($admin_id, $row['webVhostID'], $row['webMasterID'], $row['userID'], $row['dns'], $resellerLockupID));
$query2->execute(array($admin_id, $row['webVhostID'], $row['webMasterID'], $row['userID'], 'web-' . $row['webVhostID'], $resellerLockupID));
}
$query = $sql->prepare("UPDATE `webVhost` SET `vhostTemplate`=? WHERE `webMasterID`=? AND `resellerID`=? AND `ownVhost`='N'");
$query = $sql->prepare("UPDATE `webVhostDomain` SET `vhostTemplate`=? WHERE `ownVhost`='N' AND `webVhostID` IN (SELECT `webVhostID` FROM `webVhost` WHERE `webMasterID`=? AND `resellerID`=?)");
$query->execute(array($vhostTemplate, $id, $resellerLockupID));
}
@ -443,10 +514,10 @@ if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
$query->execute(array($id, $resellerLockupID));
$ip = $query->fetchColumn();
$query = $sql->prepare("SELECT `webVhostID`,`dns` FROM `webVhost` WHERE `webMasterID`=? AND `resellerID`=?");
$query = $sql->prepare("SELECT `webVhostID` FROM `webVhost` WHERE `webMasterID`=? AND `resellerID`=?");
$query->execute(array($id, $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$table[$row['webVhostID']] = $row['dns'];
$table[$row['webVhostID']] = 'web-' . $row['webVhostID'];
}
$template_file = 'admin_web_master_ri.tpl';
@ -457,7 +528,7 @@ if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
$reinstalledVhosts = array();
$ids = (array) $ui->id('dnsID', 10, 'post');
$query = $sql->prepare("SELECT `userID`,`dns` FROM `webVhost` WHERE `webVhostID`=? AND `resellerID`=?");
$query = $sql->prepare("SELECT `userID` FROM `webVhost` WHERE `webVhostID`=? AND `resellerID`=?");
$query2 = $sql->prepare("INSERT INTO `jobs` (`api`,`type`,`invoicedByID`,`affectedID`,`hostID`,`userID`,`name`,`status`,`date`,`action`,`extraData`,`resellerid`) VALUES ('S','wv',?,?,?,?,?,NULL,NOW(),'ri','',?)");
foreach ($ids as $v) {
@ -465,9 +536,9 @@ if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
$query->execute(array($v, $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$reinstalledVhosts[] = $row['dns'];
$reinstalledVhosts[] = 'web-' . $v;
$query2->execute(array($admin_id, $v, $id, $row['userID'], $row['dns'], $resellerLockupID));
$query2->execute(array($admin_id, $v, $id, $row['userID'], 'web-' . $v, $resellerLockupID));
$insertCount += $query2->rowCount();
}

View File

@ -67,7 +67,6 @@ $webMasterID = $ui->id('webMasterID', 10, 'post');
$userID = $ui->id('userID', 10, 'post');
$active = ($ui->active('active', 'post')) ? $ui->active('active', 'post') : 'Y';
$hdd = ($ui->id('hdd', 10, 'post')) ? $ui->id('hdd', 10, 'post') : 1000;
$dns = (string) strtolower($ui->domain('dns', 'post'));
$ftpPassword = ($ui->password('ftpPassword', 255, 'post')) ? $ui->password('ftpPassword', 255, 'post') : passwordgenerate(10);
$vhostTemplate = $ui->escaped('vhostTemplate', 'post');
$ownVhost = ($ui->active('ownVhost', 'post')) ? $ui->active('ownVhost', 'post') : 'N';
@ -133,10 +132,8 @@ if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
$active = $row['active'];
$hdd = $row['hdd'];
$hddUsage = (int) $row['hddUsage'];
$dns = $row['dns'];
$ftpPassword = $row['decryptedFTPPass'];
$ownVhost = $row['ownVhost'];
$vhostTemplate = $row['vhostTemplate'];
$dns = 'web-' . $id;
// Get masterserver. Sort by usage.
$query2 = $sql->prepare("SELECT m.`ip`,m.`description` FROM `webMaster` AS m WHERE m.`active`='Y' AND m.`webMasterID`=? AND m.`resellerID`=?");
@ -157,6 +154,8 @@ if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
// Form is submitted
} else if ($ui->st('action', 'post') == 'md' or $ui->st('action', 'post') == 'ad') {
$domainConfigurations = array();
if (!$active) {
$errors['active'] = $dedicatedLanguage->active;
}
@ -165,10 +164,6 @@ if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
$errors['ftpPassword'] = $sprache->ftpPassword;
}
if (!$dns) {
$errors['dns'] = $sprache->dns;
}
$oldHDD = 0;
// Only at ADD user and masterserver can be defined. We need to check if they exist
@ -178,9 +173,8 @@ if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
$query = $sql->prepare("SELECT `cname` FROM `userdata` WHERE `id`=? AND `resellerid`=? LIMIT 1");
$query->execute(array($userID, $resellerLockupID));
$dnsUser = $query->fetchColumn();
if (strlen($dnsUser) < 1) {
if ($query->rowCount() < 1) {
$errors['userID'] = $dedicatedLanguage->user;
}
@ -188,34 +182,17 @@ if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
$errors['userID'] = $dedicatedLanguage->user;
}
if ($webMasterID) {
$query = $sql->prepare("SELECT `defaultdns` FROM `webMaster` WHERE `webMasterID`=? AND `resellerID`=? LIMIT 1");
$query->execute(array($webMasterID, $resellerLockupID));
$defaultDns = (string) $query->fetchColumn();
if (strlen($defaultDns) < 1) {
$errors['webMasterID'] = $gsprache->master;
}
} else {
$errors['webMasterID'] = $gsprache->master;
}
} else {
$query = $sql->prepare("SELECT `webMasterID`,`active`,`hdd`,AES_DECRYPT(`ftpPassword`,?) AS `decryptedFTPPass` FROM `webVhost` WHERE `webVhostID`=? AND `resellerID`=? LIMIT 1");
$query = $sql->prepare("SELECT `webMasterID`,`active`,`hdd`,`userID`,AES_DECRYPT(`ftpPassword`,?) AS `decryptedFTPPass` FROM `webVhost` WHERE `webVhostID`=? AND `resellerID`=? LIMIT 1");
$query->execute(array($aeskey, $id, $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$webMasterID = $row['webMasterID'];
$oldHDD = $row['hdd'];
$oldActive = $row['active'];
$oldUserID = $row['userID'];
$oldFtpPassword = $row['decryptedFTPPass'];
}
if ($query->rowCount() == 0) {
$errors['webMasterID'] = $gsprache->master;
}
}
$phpConfiguration = array();
@ -225,19 +202,28 @@ if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
$maxHDD = 0;
$query = $sql->prepare("SELECT `phpConfiguration`,IF(`hddOverbook`='Y',(`maxHDD`/100) * (100+`overbookPercent`),`maxHDD`) AS `maxHDD` FROM `webMaster` WHERE `webMasterID`=? AND `resellerID`=? LIMIT 1");
$query = $sql->prepare("SELECT `defaultdns`,`vhostTemplate`,`phpConfiguration`,IF(`hddOverbook`='Y',(`maxHDD`/100) * (100+`overbookPercent`),`maxHDD`) AS `maxHDD` FROM `webMaster` WHERE `webMasterID`=? AND `resellerID`=? LIMIT 1");
$query->execute(array($webMasterID, $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$defaultDns = $row['defaultdns'];
$defaultVhostTemplate = $row['vhostTemplate'];
$maxHDD = (int) $row['maxHDD'];
$phpConfigurationMaster = @parse_ini_string($row['phpConfiguration'], true, INI_SCANNER_RAW);
}
if ($query->rowCount() == 0) {
$errors['webMasterID'] = $gsprache->master;
}
$query = $sql->prepare("SELECT SUM(`hdd`) AS `a` FROM `webVhost` WHERE `webMasterID`=? AND `resellerID`=?");
$query->execute(array($id, $resellerLockupID));
if (($maxHDD + $oldHDD - $query->fetchColumn() - $hdd) < 0) {
$errors['hdd'] = $sprache->hdd;
}
} else {
$errors['webMasterID'] = $gsprache->master;
}
// Submitted values are OK
@ -260,31 +246,100 @@ if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
// Make the inserts or updates define the log entry and get the affected rows from insert
if ($ui->st('action', 'post') == 'ad') {
$query = $sql->prepare("INSERT INTO `webVhost` (`webMasterID`,`userID`,`active`,`hdd`,`ftpPassword`,`ownVhost`,`vhostTemplate`,`phpConfiguration`,`externalID`,`resellerID`) VALUES (?,?,?,?,AES_ENCRYPT(?,?),?,?,?,?,?)");
$query->execute(array($webMasterID, $userID, $active, $hdd, $ftpPassword, $aeskey, $ownVhost, $vhostTemplate, $phpConfiguration, $externalID, $resellerLockupID));
$query = $sql->prepare("INSERT INTO `webVhost` (`webMasterID`,`userID`,`active`,`hdd`,`ftpPassword`,`phpConfiguration`,`externalID`,`resellerID`) VALUES (?,?,?,?,AES_ENCRYPT(?,?),?,?,?)");
$query->execute(array($webMasterID, $userID, $active, $hdd, $ftpPassword, $aeskey, $phpConfiguration, $externalID, $resellerLockupID));
$id = (int) $sql->lastInsertId();
$dnsUser .= '-' . $id;
$ftpUser = 'web-' . $id;
if ($defaultDns == $dns) {
$dns = str_replace('..', '.', $dnsUser . '.' .$defaultDns);
}
$query = $sql->prepare("UPDATE `webVhost` SET `dns`=?,`ftpUser`=? WHERE `webVhostID`=? AND `resellerID`=? LIMIT 1");
$query->execute(array($dns, $ftpUser, $id, $resellerLockupID));
$query = $sql->prepare("UPDATE `webVhost` SET `ftpUser`=? WHERE `webVhostID`=? AND `resellerID`=? LIMIT 1");
$query->execute(array($ftpUser, $id, $resellerLockupID));
$rowCount = $query->rowCount();
$loguseraction = '%add% %webvhost% ' . $dns;
$loguseraction = '%add% %webvhost% ' . $ftpUser;
} else if ($ui->st('action', 'post') == 'md' and $id) {
$query = $sql->prepare("UPDATE `webVhost` SET `active`=?,`hdd`=?,`dns`=?,`ftpPassword`=AES_ENCRYPT(?,?),`ownVhost`=?,`vhostTemplate`=?,`phpConfiguration`=?,`externalID`=? WHERE `webVhostID`=? AND `resellerID`=? LIMIT 1");
$query->execute(array($active, $hdd, $dns, $ftpPassword, $aeskey, $ownVhost, $vhostTemplate, $phpConfiguration, $externalID, $id, $resellerLockupID));
$ftpUser = 'web-' . $id;
$query = $sql->prepare("UPDATE `webVhost` SET `active`=?,`hdd`=?,`ftpPassword`=AES_ENCRYPT(?,?),`phpConfiguration`=?,`externalID`=? WHERE `webVhostID`=? AND `resellerID`=? LIMIT 1");
$query->execute(array($active, $hdd, $ftpPassword, $aeskey, $phpConfiguration, $externalID, $id, $resellerLockupID));
// Needs to be set for domain inserts
$userID = $oldUserID;
$rowCount = $query->rowCount();
$loguseraction = '%mod% %webvhost% ' . $dns;
$loguseraction = '%mod% %webvhost% ' . $ftpUser;
}
$domainRemove = array();
$query = $sql->prepare("SELECT `domain` FROM `webVhostDomain` WHERE `webVhostID`=? AND `userID`=? AND `resellerID`=?");
$query->execute(array($id, $userID, $resellerLockupID));
while($row = $query->fetch(PDO::FETCH_ASSOC)) {
$domainRemove[$row['domain']] = $row['domain'];
}
$domains = $ui->domain('domain', 'post');
if ($domains) {
$paths = $ui->path('path', 'post');
$ownVhosts = $ui->active('ownVhost', 'post');
$vhostTemplates = $ui->escaped('vhostTemplate', 'post');
foreach($domains as $index => $domain) {
if ($defaultDns == $domain) {
$domain = str_replace('..', '.', $ftpUser . '.' . $defaultDns);
}
$path = (property_exists($paths, $index)) ? $paths->$index : '';
$ownVhost = (property_exists($ownVhosts, $index)) ? $ownVhosts->$index : 'N';
$vhostTemplate = (property_exists($vhostTemplates, $index)) ? $vhostTemplates->$index : $defaultVhostTemplate;
// Check for file traversal and similar
$path = str_replace('..', '', $path);
while (strpos($path, './') !== false) {
$path = str_replace('./', '/', $path);
}
while (strpos($path, '//') !== false) {
$path = str_replace('//', '/', $path);
}
while (substr($path, 0, 1) == '/') {
$path = substr($path, 1);
}
$domainConfigurations[$domain] = array(
'path' => $path,
'ownVhost' => $ownVhost,
'vhostTemplate' => $vhostTemplate
);
}
}
// Insert/Delete of the domain configuration(s) Unique key is the domain
if (count($domainConfigurations) == 0) {
$domainConfigurations[str_replace('..', '.', $ftpUser . '.' . $defaultDns)] = '';
}
$query = $sql->prepare("INSERT INTO `webVhostDomain` (`webVhostID`,`userID`,`resellerID`,`domain`,`path`,`ownVhost`,`vhostTemplate`) VALUES (?,?,?,?,?,?,?) ON DUPLICATE KEY UPDATE `path`=VALUES(`path`),`ownVhost`=VALUES(`ownVhost`),`vhostTemplate`=VALUES(`vhostTemplate`)");
foreach($domainConfigurations as $domain => $path) {
$query->execute(array($id, $userID, $resellerLockupID, $domain, $path['path'], $path['ownVhost'], $path['vhostTemplate']));
$rowCount += $query->rowCount();
unset($domainRemove[$domain]);
}
if (count($domainRemove) > 0) {
$query = $sql->prepare("DELETE FROM `webVhostDomain` WHERE `webVhostID`=? AND `userID`=? AND `resellerID`=? AND `domain` IN('" . implode("','", $domainRemove) . "')");
$query->execute(array($id, $userID, $resellerLockupID));
$rowCount += $query->rowCount();
}
// Check if a row was affected during insert or update
@ -313,10 +368,9 @@ if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
} else {
$vhostObject->vhostMod($id);
$vhostObject->vhostMod($id, $domainRemove);
}
}
$vhostObject->restartHttpdServer();
@ -337,15 +391,6 @@ if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
$table = array();
$table2 = array();
$maxVhost = 0;
$maxHDD = 0;
$webVhosts = 0;
$leftHDD = 0;
$totalHDD = 0;
$totalVhosts = 0;
$quotaActive = 'N';
$dns = '';
// Get useraccounts
$query = $sql->prepare("SELECT `id`,`cname`,`vname`,`name` FROM `userdata` WHERE `resellerid`=? AND `accounttype`='u' AND `active`='Y' ORDER BY `id` DESC");
$query->execute(array($resellerLockupID));
@ -354,30 +399,12 @@ if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
}
// Get masterserver. Sort by usage.
$query = $sql->prepare("SELECT m.`webMasterID`,m.`ip`,m.`description`,(SELECT COUNT(v.`webVhostID`) AS `a` FROM `webVhost` AS v WHERE v.`webMasterID`=m.`webMasterID`)/(m.`maxVhost`/100) AS `percentVhostUsage`,(SELECT SUM(v.`hdd`) AS `a` FROM `webVhost` AS v WHERE v.`webMasterID`=m.`webMasterID`)/(IF(m.`hddOverbook`='Y',(m.`maxHDD`/100) * (100+m.`overbookPercent`),`maxHDD`)/100) AS `percentHDDUsage` FROM `webMaster` AS m WHERE m.`active`='Y' AND m.`resellerID`=? GROUP BY m.`webMasterID` HAVING (`percentVhostUsage`<100 OR `percentVhostUsage`IS NULL) AND (`percentHDDUsage`<100 OR `percentHDDUsage`IS NULL) ORDER BY `percentHDDUsage` ASC,`percentVhostUsage` ASC");
$query->execute(array($resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$table2[$row['webMasterID']] = trim($row['ip'] . ' ' . $row['description']);
}
if (count($table2) > 0) {
$bestID = key($table2);
$query = $sql->prepare("SELECT m.`vhostTemplate`,m.`maxVhost`,m.`maxHDD`,m.`quotaActive`,m.`defaultdns`,(SELECT COUNT(v.`webVhostID`) AS `a` FROM `webVhost` AS v WHERE v.`webMasterID`=m.`webMasterID`) AS `totalVhosts`,(SELECT SUM(v.`hdd`) AS `a` FROM `webVhost` AS v WHERE v.`webMasterID`=m.`webMasterID`) AS `totalHDD` FROM `webMaster` AS m WHERE m.`webMasterID`=? AND m.`resellerID`=? LIMIT 1");
$query->execute(array($bestID, $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$vhostTemplate = $row['vhostTemplate'];
$maxVhost = (int) $row['maxVhost'];
$maxHDD = (int) $row['maxHDD'];
$totalVhosts = (int) $row['totalVhosts'];
$leftHDD = (int) $row['maxHDD'] - $row['totalHDD'];
$quotaActive = $row['quotaActive'];
$dns = $row['defaultdns'];
}
}
$template_file = 'admin_web_vhost_add.tpl';
} else {
@ -389,18 +416,18 @@ if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
// Remove entries in case we have an ID given with the GET request
} else if (!isset($tokenError) and $ui->st('d', 'get') == 'dl' and $id) {
$query = $sql->prepare("SELECT v.`dns`,v.`webMasterID`,u.`cname`,u.`vname`,u.`name` FROM `webVhost` AS v LEFT JOIN `userdata` AS u ON v.`userID`=u.`id` WHERE v.`webVhostID`=? AND v.`resellerID`=? LIMIT 1");
$query = $sql->prepare("SELECT v.`webMasterID`,u.`cname`,u.`vname`,u.`name` FROM `webVhost` AS v LEFT JOIN `userdata` AS u ON v.`userID`=u.`id` WHERE v.`webVhostID`=? AND v.`resellerID`=? LIMIT 1");
$query->execute(array($id, $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$dns = $row['dns'];
$webMasterID = $row['webMasterID'];
$user = trim($row['cname'] . ' ' . trim($row['vname'] . ' ' . $row['name']));
}
// Nothing submitted yet, display the delete form
if (!$ui->st('action', 'post') and isset($user)) {
$dns = 'web-' . $id;
// Check if we could find an entry and if not display 404 page
$template_file = ($query->rowCount() > 0) ? 'admin_web_vhost_dl.tpl' : 'admin_404.tpl';
@ -416,12 +443,17 @@ if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
$query = $sql->prepare("DELETE FROM `webVhost` WHERE `webVhostID`=? AND `resellerID`=? LIMIT 1");
$query->execute(array($id, $resellerLockupID));
$queryCount = $query->rowCount();
$$query = $sql->prepare("DELETE d.* FROM `webVhostDomain` d LEFT JOIN `webVhost` v ON d.`webVhostID`=v.`webVhostID` WHERE v.`webVhostID` IS NULL");
$query->execute();
$queryCount += $query->rowCount();
// Check if a row was affected meaning an entry could be deleted. If yes add log entry and display success message
if ($query->rowCount() > 0) {
$template_file = $spracheResponse->table_del;
$loguseraction = '%del% %webvhost% ' . $dns;
$loguseraction = '%del% %webvhost% web-' . $id;
$insertlog->execute();
// Nothing was deleted, display an error
@ -436,10 +468,9 @@ if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
} else if (!isset($tokenError) and $ui->st('d', 'get') == 'ri' and $id) {
$query = $sql->prepare("SELECT `dns`,`webMasterID` FROM `webVhost` WHERE`webVhostID`=? AND `resellerID`=? LIMIT 1");
$query = $sql->prepare("SELECT `webMasterID` FROM `webVhost` WHERE`webVhostID`=? AND `resellerID`=? LIMIT 1");
$query->execute(array($id, $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$dns = $row['dns'];
$webMasterID = $row['webMasterID'];
}
@ -447,6 +478,8 @@ if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
// Nothing submitted yet, display the delete form
if (!$ui->st('action', 'post')) {
$dns = 'web-' . $id;
// Check if we could find an entry and if not display 404 page
$template_file = ($query->rowCount() > 0) ? 'admin_web_vhost_ri.tpl' : 'admin_404.tpl';
@ -461,7 +494,7 @@ if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
$vhostObject->restartHttpdServer();
$template_file = $spracheResponse->table_del;
$loguseraction = '%ri% %webvhost% ' . $dns;
$loguseraction = '%ri% %webvhost% web-' . $id;
$insertlog->execute();
} else {

View File

@ -83,10 +83,10 @@ if (isset($orderFields[$iSortCol]) and is_array($orderFields[$iSortCol])) {
if ($sSearch) {
$query = $sql->prepare("SELECT v.`dns`,v.`webVhostID`,v.`active`,v.`jobPending`,v.`hdd`,v.`hddUsage`,v.`userID`,u.`cname`,CONCAT(u.`vname`,' ',u.`name`) AS `full_name` FROM `webVhost` AS v LEFT JOIN `userdata` AS u ON v.`userID`=u.`id` WHERE v.`resellerID`=:reseller_id AND (v.`webVhostID` LIKE :search OR v.`dns` LIKE :search {$userInQuery} {$statusQuery}) ORDER BY $orderBy LIMIT {$iDisplayStart},{$iDisplayLength}");
$query = $sql->prepare("SELECT v.`webVhostID`,v.`active`,v.`jobPending`,v.`hdd`,v.`hddUsage`,v.`userID`,u.`cname`,CONCAT(u.`vname`,' ',u.`name`) AS `full_name` FROM `webVhost` AS v LEFT JOIN `userdata` AS u ON v.`userID`=u.`id` WHERE v.`resellerID`=:reseller_id AND (v.`webVhostID` LIKE :search OR v.`dns` LIKE :search {$userInQuery} {$statusQuery}) ORDER BY $orderBy LIMIT {$iDisplayStart},{$iDisplayLength}");
$query->execute(array(':search' => '%' . $sSearch . '%', ':reseller_id' => $resellerLockupID));
} else {
$query = $sql->prepare("SELECT v.`dns`,v.`webVhostID`,v.`active`,v.`jobPending`,v.`hdd`,v.`hddUsage`,v.`userID`,u.`cname`,CONCAT(u.`vname`,' ',u.`name`) AS `full_name` FROM `webVhost` AS v LEFT JOIN `userdata` AS u ON v.`userID`=u.`id` WHERE v.`resellerID`=? ORDER BY $orderBy LIMIT {$iDisplayStart},{$iDisplayLength}");
$query = $sql->prepare("SELECT v.`webVhostID`,v.`active`,v.`jobPending`,v.`hdd`,v.`hddUsage`,v.`userID`,u.`cname`,CONCAT(u.`vname`,' ',u.`name`) AS `full_name` FROM `webVhost` AS v LEFT JOIN `userdata` AS u ON v.`userID`=u.`id` WHERE v.`resellerID`=? ORDER BY $orderBy LIMIT {$iDisplayStart},{$iDisplayLength}");
$query->execute(array($resellerLockupID));
}
@ -126,5 +126,5 @@ while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$statusMessage = $gsprache->status_inactive;
}
$array['aaData'][] = array($row['dns'], $row['webVhostID'], returnButton($template_to_use, 'ajax_admin_show_status.tpl', '', '', $status, (string) $statusMessage), returnButton($template_to_use, 'ajax_admin_user_switch.tpl', $row['cname'], $row['full_name'], $row['userID'], ''), (int) $row['hddUsage'] . '/' . (int) $row['hdd'], (string) $jobPending, returnButton($template_to_use, 'ajax_admin_buttons_ri.tpl', 'wv', 'ri', $row['webVhostID'], $gsprache->reinstall) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_dl.tpl', 'wv', 'dl', $row['webVhostID'], $gsprache->del) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_md.tpl', 'wv', 'md', $row['webVhostID'], $gsprache->mod));
$array['aaData'][] = array('web-' . $row['webVhostID'], $row['webVhostID'], returnButton($template_to_use, 'ajax_admin_show_status.tpl', '', '', $status, (string) $statusMessage), returnButton($template_to_use, 'ajax_admin_user_switch.tpl', $row['cname'], $row['full_name'], $row['userID'], ''), (int) $row['hddUsage'] . '/' . (int) $row['hdd'], (string) $jobPending, returnButton($template_to_use, 'ajax_admin_buttons_ri.tpl', 'wv', 'ri', $row['webVhostID'], $gsprache->reinstall) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_dl.tpl', 'wv', 'dl', $row['webVhostID'], $gsprache->del) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_md.tpl', 'wv', 'md', $row['webVhostID'], $gsprache->mod));
}

View File

@ -53,7 +53,7 @@ $maxHDD = 1000;
$quotaActive = 'N';
$ownVhost = 'N';
$usageType = 'F';
$dns = '';
$dns = array();
$phpConfigurationMaster = array();
$phpConfigurationVhost = new stdClass();
@ -66,7 +66,7 @@ while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$totalVhosts = (int) $row['totalVhosts'];
$leftHDD = (int) $row['maxHDD'] - $row['totalHDD'];
$quotaActive = $row['quotaActive'];
$dns = $row['defaultdns'];
$dns[] = array('domain' => $row['defaultdns'], 'path' => '', 'ownVhost' => 'N', 'vhostTemplate' => $row['vhostTemplate']);
$usageType = $row['usageType'];
$phpConfigurationMaster = @parse_ini_string($row['phpConfiguration'], true, INI_SCANNER_RAW);
}
@ -74,15 +74,25 @@ while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
// Edit mode will provide the webhost ID
if ($ui->id('serverID', 10, 'get')) {
$query = $sql->prepare("SELECT `ownVhost`,`vhostTemplate`,`dns`,`hdd`,`phpConfiguration` FROM `webVhost` WHERE `webVhostID`=? AND `resellerID`=? LIMIT 1");
$query = $sql->prepare("SELECT `hdd`,`phpConfiguration` FROM `webVhost` WHERE `webVhostID`=? AND `resellerID`=? LIMIT 1");
$query->execute(array($ui->id('serverID', 10, 'get'), $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$ownVhost = $row['ownVhost'];
$vhostTemplate = $row['vhostTemplate'];
$dns = $row['dns'];
$maxHDD = $row['hdd'];
$phpConfigurationVhost = @json_decode($row['phpConfiguration']);
}
$query = $sql->prepare("SELECT `domain`,`path`,`ownVhost`,`vhostTemplate` FROM `webVhostDomain` WHERE `webVhostID`=? AND `resellerID`=? ORDER BY `domain`");
$query->execute(array($ui->id('serverID', 10, 'get'), $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$dns[] = array('domain' => $row['domain'], 'path' => $row['path'], 'ownVhost' => $row['ownVhost'], 'vhostTemplate' => $row['vhostTemplate']);
}
// Remove the first default entry, if others are given
if (count($dns) > 1) {
unset($dns[0]);
} else {
$dns[0]['domain'] = 'web-' . $ui->id('serverID', 10, 'get') . '.' . $dns[0]['domain'];
}
}
require_once IncludeTemplate($template_to_use, 'ajax_admin_web_master.tpl', 'ajax');

View File

@ -136,13 +136,14 @@ if (!isset($success['false']) and array_value_exists('action', 'add', $data)) {
$phpConfiguration = array();
$query = $sql->prepare("SELECT m.`webMasterID`,m.`defaultdns`,m.`phpConfiguration`,(SELECT COUNT(v.`webVhostID`) AS `a` FROM `webVhost` AS v WHERE v.`webMasterID`=m.`webMasterID`)/(m.`maxVhost`/100) AS `percentVhostUsage`,(SELECT SUM(v.`hdd`) AS `a` FROM `webVhost` AS v WHERE v.`webMasterID`=m.`webMasterID`)/(IF(m.`hddOverbook`='Y',(m.`maxHDD`/100) * (100+m.`overbookPercent`),`maxHDD`)/100) AS `percentHDDUsage` FROM `webMaster` AS m WHERE m.`active`='Y' AND m.`resellerID`=? GROUP BY m.`webMasterID` HAVING $inSQLArray (`percentVhostUsage`<100 OR `percentVhostUsage`IS NULL) AND (`percentHDDUsage`<100 OR `percentHDDUsage`IS NULL) ORDER BY `percentHDDUsage` ASC,`percentVhostUsage` ASC LIMIT 1");
$query = $sql->prepare("SELECT m.`webMasterID`,m.`defaultdns`,m.`phpConfiguration`,m.`vhostTemplate`,(SELECT COUNT(v.`webVhostID`) AS `a` FROM `webVhost` AS v WHERE v.`webMasterID`=m.`webMasterID`)/(m.`maxVhost`/100) AS `percentVhostUsage`,(SELECT SUM(v.`hdd`) AS `a` FROM `webVhost` AS v WHERE v.`webMasterID`=m.`webMasterID`)/(IF(m.`hddOverbook`='Y',(m.`maxHDD`/100) * (100+m.`overbookPercent`),`maxHDD`)/100) AS `percentHDDUsage` FROM `webMaster` AS m WHERE m.`active`='Y' AND m.`resellerID`=? GROUP BY m.`webMasterID` HAVING $inSQLArray (`percentVhostUsage`<100 OR `percentVhostUsage`IS NULL) AND (`percentHDDUsage`<100 OR `percentHDDUsage`IS NULL) ORDER BY `percentHDDUsage` ASC,`percentVhostUsage` ASC LIMIT 1");
$query->execute(array($resellerID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$webMasterID = $row['webMasterID'];
$hostExternalID = $row['externalID'];
$defaultDns = $row['defaultdns'];
$vhostTemplate = $row['vhostTemplate'];
$phpConfigurationMaster = @parse_ini_string($row['phpConfiguration'], true, INI_SCANNER_RAW);
@ -163,8 +164,8 @@ if (!isset($success['false']) and array_value_exists('action', 'add', $data)) {
$password = (isset($data['password']) and strlen($data['password']) > 0) ? $data['password'] : passwordgenerate(10);
$query = $sql->prepare("INSERT INTO `webVhost` (`externalID`,`webMasterID`,`userID`,`active`,`hdd`,`ftpPassword`,`ownVhost`,`vhostTemplate`,`phpConfiguration`,`jobPending`,`resellerID`) VALUES (?,?,?,?,?,AES_ENCRYPT(?,?),?,?,?,'Y',?)");
$query->execute(array($externalServerID, $webMasterID, $localUserLookupID, $active, $hdd, $password, $aeskey, $ownVhost, $vhostTemplate, $phpConfiguration, $resellerID));
$query = $sql->prepare("INSERT INTO `webVhost` (`externalID`,`webMasterID`,`userID`,`active`,`hdd`,`ftpPassword`,`phpConfiguration`,`jobPending`,`resellerID`) VALUES (?,?,?,?,?,AES_ENCRYPT(?,?),?,'Y',?)");
$query->execute(array($externalServerID, $webMasterID, $localUserLookupID, $active, $hdd, $password, $aeskey, $phpConfiguration, $resellerID));
$localServerID = (int) $sql->lastInsertId();
@ -174,6 +175,9 @@ if (!isset($success['false']) and array_value_exists('action', 'add', $data)) {
$dns = str_replace('..', '.', $ftpUser . '.' .$defaultDns);
}
$query = $sql->prepare("INSERT INTO `webVhostDomain` (`webVhostID`,`userID`,`resellerID`,`domain`,`path`,`ownVhost`,`vhostTemplate`) VALUES (?,?,?,?,?,?,?) ON DUPLICATE KEY UPDATE `path`=VALUES(`path`),`ownVhost`=VALUES(`ownVhost`),`vhostTemplate`=VALUES(`vhostTemplate`)");
$query->execute(array($id, $localUserLookupID, $resellerID, $dns, $dns, $ownVhost, $vhostTemplate));
$query = $sql->prepare("UPDATE `webVhost` SET `ftpUser`=? WHERE `webVhostID`=? AND `resellerID`=? LIMIT 1");
$query->execute(array($ftpUser, $localServerID, $resellerID));
@ -194,7 +198,7 @@ if (!isset($success['false']) and array_value_exists('action', 'add', $data)) {
$changedCount = 0;
$query = $sql->prepare("SELECT w.*,c.`cname` FROM `webVhost` AS w INNER JOIN `userdata` AS u ON u.`id`=w.`userID` WHERE w.`" . $from[$data['identify_server_by']] . "`=? AND w.`resellerID`=?");
$query = $sql->prepare("SELECT w.*,u.`cname`,m.`vhostTemplate` FROM `webVhost` AS w INNER JOIN `userdata` AS u ON u.`id`=w.`userID` INNER JOIN `webMaster` AS m ON m.`webMasterID`=w.`webMasterID` WHERE w.`" . $from[$data['identify_server_by']] . "`=? AND w.`resellerID`=?");
$query->execute(array($data[$data['identify_server_by']], $resellerID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
@ -211,16 +215,38 @@ if (!isset($success['false']) and array_value_exists('action', 'add', $data)) {
$userID = $row['userID'];
$oldHDD = $row['hdd'];
$dns = $row['dns'];
$active = $row['active'];
$private = $row['password'];
$hdd = $row['hdd'];
$ownVhost = $row['ownVhost'];
$query = $sql->prepare("SELECT COUNT(`jobID`) AS `amount` FROM `jobs` WHERE `affectedID`=? AND `type`='wv' AND `action`='dl' AND (`status` IS NULL OR `status`='1') LIMIT 1");
$query->execute(array($localServerID));
if ($query->fetchColumn() > 0) {
$domainRowCount = 0;
$query2 = $sql->prepare("SELECT COUNT(`jobID`) AS `amount` FROM `jobs` WHERE `affectedID`=? AND `type`='wv' AND `action`='dl' AND (`status` IS NULL OR `status`='1') LIMIT 1");
$query2->execute(array($localServerID));
if ($query2->fetchColumn() > 0) {
$success['false'][] = 'Server is marked for deletion';
} else if (isdomain($dns)) {
$oldDomains = array();
$query2 = $sql->prepare("SELECT `domain` FROM `webVhostDomain` WHERE `webVhostID`=? AND `userID`=? AND `resellerID`=?");
$query2->execute(array($localServerID));
while ($row2 = $query2->fetch(PDO::FETCH_ASSOC)) {
$oldDomains[] = $row2['domain'];
}
if (count($oldDomains) == 1) {
$query2 = $sql->prepare("UPDATE `webVhostDomain` SET `domain`=?,`ownVhost`=? WHERE `webVhostID`=? AND `userID`=? AND `resellerID`=? LIMIT 1");
$query2->execute(array($dns, $ownVhost, $localServerID, $userID, $resellerID));
} else {
$query2 = $sql->prepare("INSERT INTO `webVhostDomain` (`webVhostID`,`userID`,`resellerID`,`domain`,`path`,`ownVhost`,`vhostTemplate`) VALUES (?,?,?,?,'',?,?) ON DUPLICATE KEY UPDATE `ownVhost`=VALUES(`ownVhost`)");
$query2->execute(array($localServerID, $userID, $resellerID, $dns, $ownVhost, $row['vhostTemplate']));
}
$domainRowCount = $query2->rowCount();
}
$updateArray = array();
@ -232,12 +258,6 @@ if (!isset($success['false']) and array_value_exists('action', 'add', $data)) {
$active = $data['active'];
}
if (isset($data['dns']) and isdomain($data['dns'])) {
$updateArray[] = $data['dns'];
$eventualUpdate .= ',`dns`=?';
$dns = $data['dns'];
}
if (isset($data['password']) and is_password($data['password'], 255)) {
$updateArray[] = $data['private'];
$updateArray[] = $aeskey;
@ -263,18 +283,12 @@ if (!isset($success['false']) and array_value_exists('action', 'add', $data)) {
}
}
if (isset($data['ownVhost']) and active_check($data['ownVhost'])) {
$updateArray[] = $data['ownVhost'];
$eventualUpdate .= ',`ownVhost`=?';
$ownVhost = $data['ownVhost'];
}
if (isExternalID($data['server_external_id']) and $data['identify_server_by'] == 'server_local_id') {
$updateArray[] = $data['server_external_id'];
$eventualUpdate .= ',`externalID`=?';
}
if (count($updateArray) > 0 and count($success['false']) == 0) {
if (($domainRowCount > 0 or count($updateArray) > 0) and count($success['false']) == 0) {
$eventualUpdate = trim($eventualUpdate,',');
$eventualUpdate .= ',';
@ -362,9 +376,7 @@ if (!isset($success['false']) and array_value_exists('action', 'add', $data)) {
$webMasterID = $row['webMasterID'];
$externalServerID = $row['externalID'];
$active = $row['active'];
$dns = $row['dns'];
$hdd = $row['hdd'];
$ownVhost = $row['ownVhost'];
$localUserID = $row['userID'];
$externalUserID = $row['userExternalID'];

View File

@ -194,5 +194,6 @@ $sql->exec("DELETE v.* FROM `voice_server` v LEFT JOIN `userdata` u ON v.`userid
$sql->exec("DELETE v.* FROM `voice_server_backup` v LEFT JOIN `userdata` u ON v.`uid`=u.`id` WHERE u.`id` IS NULL");
$sql->exec("DELETE v.* FROM `webVhost` v LEFT JOIN `userdata` u ON v.`userID`=u.`id` WHERE u.`id` IS NULL");
$sql->exec("DELETE v.* FROM `webVhost` v LEFT JOIN `webMaster` m ON v.`webMasterID`=m.`webMasterID` WHERE m.`webMasterID` IS NULL");
$sql->exec("DELETE d.* FROM `webVhostDomain` d LEFT JOIN `webVhost` v ON d.`webVhostID`=v.`webVhostID` WHERE v.`webVhostID` IS NULL");
$sql->exec("DELETE s.* FROM `easywi_statistics_current` s LEFT JOIN `userdata` u ON s.`userID`=u.`id` WHERE s.`userID`!=0 AND u.`id` IS NULL");
$sql->exec("DELETE s.* FROM `easywi_statistics` s LEFT JOIN `userdata` u ON s.`userID`=u.`id` WHERE s.`userID`!=0 AND u.`id` IS NULL");

View File

@ -77,6 +77,7 @@ class HttpdManagement {
return false;
}
$this->hostData['defaultdns'] = $row['defaultdns'];
$this->hostData['ip'] = $row['ip'];
$this->hostData['port'] = $row['port'];
$this->hostData['ftpIP'] = (strlen($row['ftpIP']) > 0) ? $row['ftpIP'] : $row['ip'];
@ -143,41 +144,67 @@ class HttpdManagement {
if ($this->vhostData == false) {
$query = $this->sql->prepare("SELECT v.`active`,v.`ownVhost`,v.`vhostTemplate`,v.`dns`,v.`hdd`,v.`ftpUser`,v.`phpConfiguration`,AES_DECRYPT(v.`ftpPassword`,?) AS `decryptedFTPPass`,u.`mail` FROM `webVhost` AS v INNER JOIN `userdata` AS u ON u.`id`=v.`userID` WHERE v.`webVhostID`=? AND v.`resellerID`=? LIMIT 1");
$query = $this->sql->prepare("SELECT v.`active`,v.`userID`,v.`hdd`,v.`ftpUser`,v.`phpConfiguration`,AES_DECRYPT(v.`ftpPassword`,?) AS `decryptedFTPPass`,u.`mail` FROM `webVhost` AS v INNER JOIN `userdata` AS u ON u.`id`=v.`userID` WHERE v.`webVhostID`=? AND v.`resellerID`=? LIMIT 1");
$query->execute(array($this->aeskey, $vhostID, $this->resellerID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$this->vhostData['hdd'] = $row['hdd'];
$this->vhostData['dns'] = $row['dns'];
$this->vhostData['ftpUser'] = $row['ftpUser'];
$this->vhostData['ftpPassword'] = $row['decryptedFTPPass'];
$this->vhostData['vhostConfigFile'] = $this->removeNotNeededSlashes($this->hostData['vhostConfigPath'] . '/' . $this->vhostData['ftpUser'] . '.conf');
$this->vhostData['vhostConfigFile'] = $this->removeNotNeededSlashes($this->hostData['vhostConfigPath'] . '/' . $this->vhostData['ftpUser']) . '.conf';
$this->vhostData['vhostHomeDir'] = $this->removeNotNeededSlashes($this->hostData['vhostStoragePath'] . '/' . $this->vhostData['ftpUser']);
$this->vhostData['templateFileContent'] = "# DO NOT EDIT DIRECTLY!\r\n# This file is autogenerated by easy-wi.com.\r\n# Date and time of generation was " . date('Y-m-d H:i:s') . "\r\n\r\n";
$this->vhostData['templateFileContent'] .= ($row['ownVhost'] == 'Y') ? $row['vhostTemplate'] : $this->hostData['vhostTemplate'];
$this->vhostData['defaultDomain'] = 'web-' . $vhostID . '.' . $this->hostData['defaultdns'];
$phpConfigurationVhost = @json_decode($row['phpConfiguration']);
$this->vhostData['dns'] = array();
if ($phpConfigurationVhost and $this->hostData['usageType'] == 'W') {
// Workaround for migrations and other admin is breaking something faults
$query2 = $this->sql->prepare("SELECT 1 FROM `webVhostDomain` WHERE `webVhostID`=? LIMIT 1");
$query2->execute(array($vhostID));
if ($query2->rowCount() == 0) {
preg_match('/(\s{1,}%phpConfiguration%)/', $this->vhostData['templateFileContent'], $matches);
$match = array_shift($matches);
$whiteSpace = str_replace('%phpConfiguration%', '', $match);
try {
$query2 = $this->sql->prepare("INSERT INTO `webVhostDomain` (`webVhostID`,`userID`,`resellerID`,`domain`,`path`,`ownVhost`,`vhostTemplate`) VALUES (?,?,?,?,'','N',?)");
$query2->execute(array($vhostID, $row['userID'], $this->resellerID, $this->vhostData['defaultDomain'], $this->hostData['vhostTemplate']));
$phpOptions = '';
foreach ($phpConfigurationVhost as $phpOption) {
$phpOptions .= $whiteSpace . $phpOption;
// There is always a catch ...
} catch(PDOException $error) {
$error = $error->getMessage();
}
$this->vhostData['templateFileContent'] = str_replace('%phpConfiguration%', $phpOptions, $this->vhostData['templateFileContent']);
} else {
$this->vhostData['templateFileContent'] = str_replace('%phpConfiguration%', '', $this->vhostData['templateFileContent']);
}
$this->vhostData['templateFileContent'] = $this->removeNotNeededSlashes(str_replace(array('%url%', '%user%', '%group%', '%vhostpath%', '%email%', '%htdocs%', '%logDir%'), array($row['dns'], $row['ftpUser'], $this->hostData['userGroup'], $this->hostData['vhostStoragePath'], $row['mail'], $this->hostData['dirHttpd'], $this->hostData['dirLogs']), $this->vhostData['templateFileContent'])) . "\r\n";
$this->vhostData['templateFileContent'] = "# DO NOT EDIT DIRECTLY!\r\n# This file is autogenerated by easy-wi.com.\r\n# Date and time of generation was " . date('Y-m-d H:i:s') . "\r\n\r\n";
$query2 = $this->sql->prepare("SELECT `path`,`domain`,`ownVhost`,`vhostTemplate` FROM `webVhostDomain` WHERE `webVhostID`=?");
$query2->execute(array($vhostID));
while ($row2 = $query2->fetch(PDO::FETCH_ASSOC)) {
$templateFileContentTemp = ($row2['ownVhost'] == 'Y') ? $row2['vhostTemplate'] : $this->hostData['vhostTemplate'];
if ($phpConfigurationVhost and $this->hostData['usageType'] == 'W') {
preg_match('/(\s{1,}%phpConfiguration%)/', $templateFileContentTemp, $matches);
$match = array_shift($matches);
$whiteSpace = str_replace('%phpConfiguration%', '', $match);
$phpOptions = '';
foreach ($phpConfigurationVhost as $phpOption) {
$phpOptions .= $whiteSpace . $phpOption;
}
$templateFileContentTemp = str_replace('%phpConfiguration%', $phpOptions, $templateFileContentTemp);
} else {
$templateFileContentTemp = str_replace('%phpConfiguration%', '', $templateFileContentTemp);
}
$templateFileContentTemp = $this->removeNotNeededSlashes(str_replace(array('%user%', '%group%', '%vhostpath%', '%email%', '%htdocs%', '%logDir%'), array($row['ftpUser'], $this->hostData['userGroup'], $this->hostData['vhostStoragePath'], $row['mail'], $this->hostData['dirHttpd'], $this->hostData['dirLogs']), $templateFileContentTemp)) . "\r\n";
$templateFileContentTemp = $this->removeNotNeededSlashes(str_replace(array('%path%', '%url%', '%domain%'), array($row2['path'], $row2['domain'], $row2['domain']), $templateFileContentTemp)) . "\r\n";
$this->vhostData['templateFileContent'] .= $templateFileContentTemp;
}
return true;
}
@ -300,7 +327,7 @@ class HttpdManagement {
public function setInactive ($vhostID) {
$this->changePassword ($vhostID, passwordgenerate(10));
$this->changePassword($vhostID, passwordgenerate(10));
$this->removeVhost($vhostID, false);
$this->vhostData = false;

View File

@ -252,6 +252,7 @@ $query = "CREATE TABLE IF NOT EXISTS `easywi_statistics` (
`voiceserverCrashed` int(10) unsigned DEFAULT 0,
`webMasterInstalled` int(10) unsigned DEFAULT 0,
`webMasterActive` int(10) unsigned DEFAULT 0,
`webMasterCrashed` int(10) unsigned DEFAULT 0,
`webMasterSpaceAvailable` int(10) unsigned DEFAULT 0,
`webMasterVhostAvailable` int(10) unsigned DEFAULT 0,
`webspaceInstalled` int(10) unsigned DEFAULT 0,
@ -313,6 +314,7 @@ $query = "CREATE TABLE IF NOT EXISTS `easywi_statistics_current` (
`voiceserverCrashed` int(10) unsigned DEFAULT 0,
`webMasterInstalled` int(10) unsigned DEFAULT 0,
`webMasterActive` int(10) unsigned DEFAULT 0,
`webMasterCrashed` int(10) unsigned DEFAULT 0,
`webMasterSpaceAvailable` int(10) unsigned DEFAULT 0,
`webMasterVhostAvailable` int(10) unsigned DEFAULT 0,
`webspaceInstalled` int(10) unsigned DEFAULT 0,
@ -379,11 +381,8 @@ $query = "CREATE TABLE IF NOT EXISTS `webVhost` (
`jobPending` enum('Y','N') DEFAULT 'N',
`hdd` int(10) unsigned DEFAULT 0,
`hddUsage` int(10) unsigned DEFAULT 0,
`dns` varchar(255),
`ftpUser` varchar(255),
`ftpPassword` blob,
`ownVhost` enum('Y','N') DEFAULT 'N',
`vhostTemplate` text,
`phpConfiguration` text,
`externalID` varchar(255) DEFAULT '',
`resellerID` int(10) unsigned DEFAULT 0,
@ -392,6 +391,19 @@ $query = "CREATE TABLE IF NOT EXISTS `webVhost` (
$add = $sql->prepare($query);
$add->execute();
$query = "CREATE TABLE IF NOT EXISTS `webVhostDomain` (
`webVhostID` int(10) unsigned NOT NULL,
`userID` int(10) unsigned NOT NULL,
`resellerID` int(10) unsigned DEFAULT 0,
`domain` varchar(255) NOT NULL,
`path` varchar(255)NOT NULL,
`ownVhost` enum('Y','N') DEFAULT 'N',
`vhostTemplate` text,
PRIMARY KEY(`domain`,`webVhostID`),KEY(`userID`),KEY(`resellerID`)
) ENGINE=InnoDB";
$add = $sql->prepare($query);
$add->execute();
$query = "CREATE TABLE IF NOT EXISTS `feeds_news` (
`newsID` bigint(19) unsigned NOT NULL AUTO_INCREMENT,
`feedID` int(10) unsigned NOT NULL,

View File

@ -291,6 +291,7 @@ $defined['easywi_statistics'] = array(
'voiceserverCrashed' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"","Default"=>"0","Extra"=>""),
'webMasterInstalled' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"","Default"=>"0","Extra"=>""),
'webMasterActive' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"","Default"=>"0","Extra"=>""),
'webMasterCrashed' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"","Default"=>"0","Extra"=>""),
'webMasterSpaceAvailable' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"","Default"=>"0","Extra"=>""),
'webMasterVhostAvailable' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"","Default"=>"0","Extra"=>""),
'webspaceInstalled' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"","Default"=>"0","Extra"=>""),
@ -349,6 +350,7 @@ $defined['easywi_statistics_current'] = array(
'voiceserverCrashed' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"","Default"=>"0","Extra"=>""),
'webMasterInstalled' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"","Default"=>"0","Extra"=>""),
'webMasterActive' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"","Default"=>"0","Extra"=>""),
'webMasterCrashed' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"","Default"=>"0","Extra"=>""),
'webMasterSpaceAvailable' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"","Default"=>"0","Extra"=>""),
'webMasterVhostAvailable' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"","Default"=>"0","Extra"=>""),
'webspaceInstalled' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"","Default"=>"0","Extra"=>""),
@ -416,16 +418,23 @@ $defined['webVhost'] = array(
'jobPending' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"N","Extra"=>""),
'hdd' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"","Default"=>"0","Extra"=>""),
'hddUsage' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"","Default"=>"0","Extra"=>""),
'dns' => array("Type"=>"varchar(255)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
'ftpUser' => array("Type"=>"varchar(255)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
'ftpPassword' => array("Type"=>"blob","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
'ownVhost' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"N","Extra"=>""),
'vhostTemplate' => array("Type"=>"text","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
'phpConfiguration' => array("Type"=>"text","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
'externalID' => array("Type"=>"varchar(255)","Null"=>"YES","Key"=>"","Default"=>"0","Extra"=>""),
'resellerID' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
);
$defined['webVhostDomain'] = array(
'webVhostID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
'userID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
'resellerID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"0","Extra"=>""),
'domain' => array("Type"=>"varchar(255)","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
'path' => array("Type"=>"varchar(255)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
'ownVhost' => array("Type"=>"enum('Y','N')","Null"=>"NO","Key"=>"","Default"=>"N","Extra"=>""),
'vhostTemplate' => array("Type"=>"text","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>"")
);
$defined['feeds_news'] = array(
'newsID' => array("Type"=>"bigint(19) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
'feedID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"0","Extra"=>""),

View File

@ -62,16 +62,18 @@ if (isset($admin_id)) {
$logsubuser = 0;
}
if ($ui->id('id', 10, 'get') and in_array($ui->st('d', 'get'), array('if', 'pw', 'ri', 'md'))) {
if ($ui->id('id', 10, 'get') and in_array($ui->st('d', 'get'), array('if', 'pw', 'ri', 'md','dm'))) {
$query = $sql->prepare("SELECT v.`dns`,v.`webMasterID`,v.`phpConfiguration`,v.`phpConfiguration`,m.`usageType`,m.`phpConfiguration` AS `phpMasterConfiguration` FROM `webVhost` AS v INNER JOIN `webMaster` AS m ON m.`webMasterID`=v.`webMasterID` WHERE v.`webVhostID`=? AND v.`userID`=? AND v.`resellerID`=? AND v.`active`='Y'");
$query = $sql->prepare("SELECT v.`webMasterID`,v.`phpConfiguration`,v.`phpConfiguration`,m.`usageType`,m.`defaultdns`,m.`connect_ip_only`,m.`ftpIP`,m.`ip`,m.`phpConfiguration` AS `phpMasterConfiguration` FROM `webVhost` AS v INNER JOIN `webMaster` AS m ON m.`webMasterID`=v.`webMasterID` WHERE v.`webVhostID`=? AND v.`userID`=? AND v.`resellerID`=? AND v.`active`='Y'");
$query->execute(array($ui->id('id', 10, 'get'), $user_id, $reseller_id));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$dns = $row['dns'];
$defaultDns = 'web-' . $ui->id('id', 10, 'get') . '.' . $row['defaultdns'];
$dns = 'web-' . $ui->id('id', 10, 'get');
$webMasterID = $row['webMasterID'];
$usageType = $row['usageType'];
$phpConfigurationVhost = @json_decode($row['phpConfiguration']);
$phpConfigurationMaster = @parse_ini_string($row['phpMasterConfiguration'], true, INI_SCANNER_RAW);
$serverIP = ($row['connect_ip_only'] == 'Y') ? $row['ftpIP'] : $row['ip'];
}
}
@ -125,6 +127,131 @@ if (isset($webMasterID) and $ui->st('d', 'get') == 'pw' and $ui->id('id', 10, 'g
} else {
$template_file = 'userpanel_web_vhost_pw.tpl';
}
} else if (isset($webMasterID, $dns, $usageType, $phpConfigurationMaster) and $usageType == 'W' and $ui->st('d', 'get') == 'dm' and $ui->id('id', 10, 'get') and (!isset($_SESSION['sID']) or in_array($ui->id('id', 10, 'get'), $substituteAccess['ws']))) {
$id = $ui->id('id', 10, 'get');
if ($ui->st('action', 'post') == 'dm') {
$domainRemove = array();
$domainConfigurations = array();
$notice = array();
$query = $sql->prepare("SELECT `domain` FROM `webVhostDomain` WHERE `webVhostID`=? AND `userID`=? AND `resellerID`=?");
$query->execute(array($id, $user_id, $reseller_id));
while($row = $query->fetch(PDO::FETCH_ASSOC)) {
$domainRemove[$row['domain']] = $row['domain'];
}
$domains = $ui->domain('domain', 'post');
if ($domains) {
$query = $sql->prepare("SELECT 1 FROM `webVhostDomain` WHERE `webVhostID`!=? AND `domain`=? AND `resellerID`=? LIMIT 1");
$paths = $ui->path('path', 'post');
$ownVhosts = $ui->active('ownVhost', 'post');
$vhostTemplates = $ui->escaped('vhostTemplate', 'post');
foreach($domains as $index => $domain) {
$query->execute(array($id, $domain, $reseller_id));
if ($query->rowCount() > 0) {
$notice[] = str_replace('%domain%', $domain, $sprache->domainNotUsed);
} else {
$givenPath = (property_exists($paths, $index)) ? $paths->$index : '';
// Check for file traversal and similar
$path = str_replace('..', '', $givenPath);
while (strpos($path, './') !== false) {
$path = str_replace('./', '/', $path);
}
while (strpos($path, '//') !== false) {
$path = str_replace('//', '/', $path);
}
while (substr($path, 0, 1) == '/') {
$path = substr($path, 1);
}
if ($givenPath != $path) {
$notice[] = str_replace(array('%pathGiven%', '%pathConverted%', '%domain%'), array($givenPath, $path, $domain), $sprache->pathCorrected);
}
$aRecordIPs = gethostbynamel($domain);
if ($aRecordIPs === false or !in_array($serverIP, $aRecordIPs)) {
$notice[] = str_replace(array('%domain%', '%ip%'), array($domain, $serverIP), $sprache->aRecordMissing);
}
$domainConfigurations[$domain] = $path;
}
}
}
// Insert/Delete of the domain configuration(s) Unique key is the domain
if (count($domainConfigurations) == 0) {
$domainConfigurations[$defaultDns] = '';
}
$rowCount = 0;
$query = $sql->prepare("INSERT INTO `webVhostDomain` (`webVhostID`,`userID`,`resellerID`,`domain`,`path`,`ownVhost`,`vhostTemplate`) VALUES (?,?,?,?,?,'N',?) ON DUPLICATE KEY UPDATE `path`=VALUES(`path`)");
foreach($domainConfigurations as $domain => $path) {
$query->execute(array($id, $user_id, $reseller_id, $domain, $path, $path['vhostTemplate']));
$rowCount += $query->rowCount();
unset($domainRemove[$domain]);
}
if (count($domainRemove) > 0) {
$query = $sql->prepare("DELETE FROM `webVhostDomain` WHERE `webVhostID`=? AND `userID`=? AND `resellerID`=? AND `domain` IN('" . implode("','", $domainRemove) . "')");
$query->execute(array($id, $user_id, $reseller_id));
$rowCount += $query->rowCount();
}
$vhostObject = new HttpdManagement($webMasterID, $reseller_id);
if ($rowCount and $vhostObject != false and $vhostObject->ssh2Connect() and $vhostObject->sftpConnect()) {
$vhostObject->vhostMod($id);
$vhostObject->restartHttpdServer();
$template_file = $spracheResponse->table_add;
$loguseraction = '%md% %webvhost% ' . $dns;
$insertlog->execute();
} else {
$template_file = $spracheResponse->error_table;
}
if (count($notice) > 0) {
$template_file .= '<ul><li>' . implode('</li><li>', $notice) . '</li></ul>';
}
} else if (!$ui->st('action', 'post')) {
$dnsArray = array();
$query = $sql->prepare("SELECT `domain`,`path` FROM `webVhostDomain` WHERE `webVhostID`=? AND `userID`=? AND `resellerID`=? ORDER BY `domain`");
$query->execute(array($id, $user_id, $reseller_id));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$dnsArray[] = array('domain' => $row['domain'], 'path' => $row['path']);
}
$template_file = 'userpanel_web_vhost_dm.tpl';
// Request did not add up. Display 404 error.
} else {
$template_file = 'userpanel_404.tpl';
}
} else if (isset($webMasterID, $dns, $usageType, $phpConfigurationMaster) and $usageType == 'W' and $ui->st('d', 'get') == 'md' and $ui->id('id', 10, 'get') and (!isset($_SESSION['sID']) or in_array($ui->id('id', 10, 'get'), $substituteAccess['ws']))) {
@ -228,11 +355,11 @@ set sv_wwwDownload "1"';
$table = array();
$query = $sql->prepare("SELECT v.`webVhostID`,v.`dns`,v.`hdd`,v.`hddUsage`,v.`ftpUser`,AES_DECRYPT(v.`ftpPassword`,?) AS `decryptedFTPPass`,m.`ip`,m.`ftpIP`,m.`ftpPort`,m.`quotaActive`,m.`usageType` FROM `webVhost` AS v INNER JOIN `webMaster` AS m ON m.`webMasterID`=v.`webMasterID` WHERE v.`userID`=? AND v.`resellerID`=? AND v.`active`='Y'");
$query = $sql->prepare("SELECT v.`webVhostID`,v.`hdd`,v.`hddUsage`,v.`ftpUser`,AES_DECRYPT(v.`ftpPassword`,?) AS `decryptedFTPPass`,m.`ip`,m.`ftpIP`,m.`ftpPort`,m.`quotaActive`,m.`usageType`,m.`defaultdns`,m.`connect_ip_only` FROM `webVhost` AS v INNER JOIN `webMaster` AS m ON m.`webMasterID`=v.`webMasterID` WHERE v.`userID`=? AND v.`resellerID`=? AND v.`active`='Y'");
$query->execute(array($aeskey, $user_id, $reseller_id));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
if (!isset($_SESSION['sID']) or in_array($row['webVhostID'], $substituteAccess['ws'])) {
$table[] = array('id' => $row['webVhostID'], 'dns' => $row['dns'], 'hdd' => $row['hdd'], 'hddUsage' => $row['hddUsage'], 'quotaActive' => $row['quotaActive'], 'ftpIP' => (isip($row['ftpIP'], 'ip4')) ? $row['ftpIP'] : $row['ip'], 'ftpPort' => $row['ftpPort'], 'ftpUser' => $row['ftpUser'], 'ftpPass' => $row['decryptedFTPPass'], 'usageType' => $row['usageType']);
$table[] = array('id' => $row['webVhostID'], 'dns' => 'web-' . $row['webVhostID'], 'hdd' => $row['hdd'], 'hddUsage' => $row['hddUsage'], 'quotaActive' => $row['quotaActive'], 'ftpIP' => ($row['connect_ip_only'] == 'Y') ? $row['ftpIP'] : $row['ip'], 'ftpPort' => $row['ftpPort'], 'ftpUser' => $row['ftpUser'], 'ftpPass' => $row['decryptedFTPPass'], 'usageType' => $row['usageType']);
}
}

View File

@ -93,7 +93,6 @@
<button class="btn btn-success" id="inputEdit" type="submit"><i class="fa fa-plus-circle">&nbsp;<?php echo $gsprache->add;?></i></button>
</div>
</div>
</form>
</div>
</div>

View File

@ -17,20 +17,13 @@
<label for="inputHDD"><?php echo $sprache->hdd;?></label>
<div class="controls">
<div class="input-group">
<input class="form-control" id="inputHDD" type="number" name="maxHDD" value="<?php echo $maxHDD;?>">
<input class="form-control" id="inputHDD" type="number" name="hdd" value="<?php echo $maxHDD;?>">
<span class="input-group-addon">MB</span>
</div>
</div>
</div>
<?php } ?>
<div class="form-group">
<label for="inputDNS"><?php echo $sprache->dns;?></label>
<div class="controls">
<input class="form-control" id="inputDNS" type="text" name="dns" value="<?php echo $dns;?>" required>
</div>
</div>
<?php if ($usageType == 'W') { ?>
<?php foreach($phpConfigurationMaster as $groupName => $array) { ?>
<div class="form-group">
@ -62,6 +55,148 @@
<textarea class="form-control" id="inputvhostTemplate" name="vhostTemplate" rows="20"><?php echo $vhostTemplate;?></textarea>
</div>
</div>
<hr>
<h3><?php echo $gsprache->domains;?> <span class="btn btn-success btn-sm" onclick="addRow();"><i class="fa fa-plus-circle"></i></span></h3>
<div id="domains">
<textarea id="hiddenDefaultTemplate" style="display: none;"><?php echo $vhostTemplate;?></textarea>
<?php foreach($dns as $key => $domain) { ?>
<div id="domain-<?php echo $key;?>" class="row" data-id="<?php echo $key;?>">
<div class="col-xs-4">
<label for="inputDNS-<?php echo $key;?>"><?php echo $sprache->dns;?></label>
<input class="form-control" id="inputDNS-<?php echo $key;?>" type="text" name="domain[<?php echo $key;?>]" value="<?php echo $domain['domain'];?>" placeholder="domain.tld" required>
</div>
<div class="col-xs-4">
<label for="inputDNSPath-<?php echo $key;?>"><?php echo $sprache->path;?></label>
<input class="form-control" id="inputDNSPath-<?php echo $key;?>" type="text" name="path[<?php echo $key;?>]" value="<?php echo $domain['path'];?>" placeholder="some/path/">
</div>
<div class="col-xs-4">
<label for="inputOwnVhost-<?php echo $key;?>"><?php echo $sprache->ownVhost;?></label>
<select class="form-control" id="inputOwnVhost-<?php echo $key;?>" name="ownVhost[<?php echo $key;?>]" onchange="showHideVhost('<?php echo $key;?>', this.value);">
<option value="N"><?php echo $gsprache->no;?></option>
<option value="Y" <?php if ($domain['ownVhost']=='Y') echo 'selected="selected";'?>><?php echo $gsprache->yes;?></option>
</select>
</div>
</div>
<div id="vhostTemplateRow-<?php echo $key;?>" class="row <?php if($domain['ownVhost']=='N') echo 'display_none';?>">
<br>
<div class="col-xs-12">
<label for="inputvhostTemplate-<?php echo $key;?>"><?php echo $sprache->vhostTemplate;?></label>
<textarea class="form-control" id="inputvhostTemplate-<?php echo $key;?>" name="vhostTemplate[<?php echo $key;?>]" rows="20"><?php echo $domain['vhostTemplate'];?></textarea>
</div>
</div>
<div id="rm-<?php echo $key;?>" class="row">
<br>
<div class="col-xs-2 col-xs-offset-10">
<span class="btn btn-danger btn-sm" data-id="<?php echo $key;?>" onclick="removeRow(this);"><i class="fa fa-minus-circle"></i> <?php echo $sprache->dns.' '.$gsprache->del;?></span>
</div>
</div>
<?php } ?>
</div>
<script type="text/javascript">
SwitchShowHideRows('init_ready');
</script>
<script type="text/javascript">
function showHideVhost(divId, yesNo) {
var divContainer = document.getElementById('vhostTemplateRow-' + divId);
if (yesNo == 'Y') {
divContainer.style.display = "";
} else {
divContainer.style.display = "none";
}
}
function getNextFreeIndex() {
var domainDivs = $("div[id^='domain-']");
var usedIndexes = [];
var div;
for (div in domainDivs) {
if (domainDivs.hasOwnProperty(div)) {
if (domainDivs[div].dataset && domainDivs[div].dataset.id) {
usedIndexes.push(parseInt(domainDivs[div].dataset.id));
}
}
}
var i = 0;
while (usedIndexes.indexOf(i) > -1 && i < 1000) {
i++;
}
return i;
}
function removeAllChilds(domainNodeId) {
var domainNode = document.getElementById(domainNodeId);
while (domainNode.firstChild) {
domainNode.removeChild(domainNode.firstChild);
}
domainNode.remove();
}
function removeRow(clickedButton) {
var arrayKey = clickedButton.dataset.id;
removeAllChilds("domain-" + arrayKey);
removeAllChilds("vhostTemplateRow-" + arrayKey);
removeAllChilds("rm-" + arrayKey);
}
/* Yes its not nice to do it this way, but it works and the concert was about to begin */
function returnHtml(type, id) {
var div = document.createElement('div');
div.id = type + '-' + id;
div.className = "row";
var newRow = '';
if (type == 'domain') {
newRow = '<br><div class="col-xs-4"><label for="inputDNS-' + id + '"><?php echo $sprache->dns;?></label><input class="form-control" id="inputDNS-' + id + '" type="text" name="domain[' + id + ']" value="" placeholder="domain.tld" required></div>';
newRow += '<div class="col-xs-4"><label for="inputDNSPath-' + id + '"><?php echo $sprache->path;?></label><input class="form-control" id="inputDNSPath-' + id + '" type="text" name="path[' + id + ']" value="" placeholder="some/path/"></div>';
newRow += '<div class="col-xs-4"><label for="inputOwnVhost-' + id + '"><?php echo $sprache->ownVhost;?></label><select class="form-control" id="inputOwnVhost-' + id + '" name="ownVhost[' + id + ']" onchange="showHideVhost(' + id + ', this.value);"><option value="N"><?php echo $gsprache->no;?></option><option value="Y"><?php echo $gsprache->yes;?></option></select></div>';
div.dataset.id = "" + id;
} else if (type == 'vhostTemplateRow') {
newRow = '<br><div class="col-xs-12"><label for="inputvhostTemplate-' + id + '"><?php echo $sprache->vhostTemplate;?></label><textarea class="form-control" id="inputvhostTemplate-' + id + '" name="vhostTemplate[' + id + ']" rows="20"></textarea></div>';
div.style.display = "none";
} else if (type == 'rm') {
newRow = '<br><div class="col-xs-2 col-xs-offset-10"><span class="btn btn-danger btn-sm" data-id="' + id + '" onclick="removeRow(this);"><i class="fa fa-minus-circle"></i> <?php echo $sprache->dns." ".$gsprache->del;?></span></div>';
}
div.innerHTML = newRow;
return div;
}
function addRow() {
var nextId = getNextFreeIndex();
var domainsDiv = document.getElementById('domains');
domainsDiv.appendChild(returnHtml('domain', nextId));
domainsDiv.appendChild(returnHtml('vhostTemplateRow', nextId));
domainsDiv.appendChild(returnHtml('rm', nextId));
$('#inputvhostTemplate-' + nextId).val($('#hiddenDefaultTemplate').val());
}
</script>

View File

@ -0,0 +1,155 @@
<section class="content-header">
<h1><?php echo $gsprache->webspace.' '.$gsprache->domains;?></h1>
<ol class="breadcrumb">
<li><a href="userpanel.php"><i class="fa fa-home"></i> Home</a></li>
<li><a href="userpanel.php?w=wv"><i class="fa fa-cubes"></i> <?php echo $gsprache->webspace;?></a></li>
<li><i class="fa fa-cog"></i> <?php echo $gsprache->domains;?></li>
<li class="active"><?php echo $dns;?></li>
</ol>
</section>
<section class="content">
<div class="row">
<div class="col-md-12">
<div class="box box-primary">
<form role="form" action="userpanel.php?w=wv&amp;d=dm&amp;id=<?php echo $id;?>&amp;r=wv" onsubmit="return confirm('<?php echo $gsprache->sure;?>');" method="post">
<input type="hidden" name="token" value="<?php echo token();?>">
<input type="hidden" name="action" value="dm">
<textarea id="hiddenDefaultTemplate" style="display: none;"><?php echo $vhostTemplate;?></textarea>
<div class="box-header">
<h3 class="box-title"><?php echo $gsprache->domains;?></h3>
</div>
<div class="box-body">
<div class="form-group">
<label for="defaultdns"><?php echo $sprache->defaultdns;?></label>
<div class="controls">
<input class="form-control" id="defaultdns" type="text" name="defaultdns" value="<?php echo $defaultDns; ?>" readonly>
<span class="help-block alert alert-info">
<?php echo $sprache->help_default_dns;?>
</span>
</div>
</div>
<div id="domains">
<?php foreach($dnsArray as $key => $domain) { ?>
<div id="domain-<?php echo $key;?>" class="row" data-id="<?php echo $key;?>">
<div class="col-xs-5">
<label for="inputDNS-<?php echo $key;?>"><?php echo $sprache->dns;?></label>
<input class="form-control" id="inputDNS-<?php echo $key;?>" type="text" name="domain[<?php echo $key;?>]" value="<?php echo $domain['domain'];?>" placeholder="domain.tld" required>
</div>
<div class="col-xs-5">
<label for="inputDNSPath-<?php echo $key;?>"><?php echo $sprache->path;?></label>
<input class="form-control" id="inputDNSPath-<?php echo $key;?>" type="text" name="path[<?php echo $key;?>]" value="<?php echo $domain['path'];?>" placeholder="some/path/">
</div>
<div class="col-xs-2">
<label for="inputButton-<?php echo $key;?>"><?php echo $gsprache->del;?></label>
<div class="controls">
<button class="btn btn-danger btn-sm" id="inputButton-<?php echo $key;?>" data-id="<?php echo $key;?>" onclick="removeRow(this);"><i class="fa fa-minus-circle"></i></button>
</div>
</div>
</div>
<br>
<?php } ?>
</div>
<div class="row">
<div class="col-xs-2 col-xs-offset-10">
<span class="btn btn-success btn-sm" onclick="addRow();"><i class="fa fa-plus-circle"></i> <?php echo $gsprache->add;?></span>
</div>
</div>
</div>
<div class="box-footer">
<button class="btn btn-primary" id="inputEdit" type="submit"><i class="fa fa-save"></i> <?php echo $gsprache->save;?></button>
</div>
</form>
</div>
</div>
</div>
</section>
<script type="text/javascript">
SwitchShowHideRows('init_ready');
</script>
<script type="text/javascript">
function getNextFreeIndex() {
var domainDivs = $("div[id^='domain-']");
var usedIndexes = [];
var div;
for (div in domainDivs) {
if (domainDivs.hasOwnProperty(div)) {
if (domainDivs[div].dataset && domainDivs[div].dataset.id) {
usedIndexes.push(parseInt(domainDivs[div].dataset.id));
}
}
}
var i = 0;
while (usedIndexes.indexOf(i) > -1 && i < 1000) {
i++;
}
return i;
}
function removeAllChilds(domainNodeId) {
var domainNode = document.getElementById(domainNodeId);
while (domainNode.firstChild) {
domainNode.removeChild(domainNode.firstChild);
}
domainNode.remove();
}
function removeRow(clickedButton) {
var arrayKey = clickedButton.dataset.id;
removeAllChilds("domain-" + arrayKey);
removeAllChilds("br-" + arrayKey);
}
/* Yes its not nice to do it this way, but it works and the concert was about to begin */
function returnDomainRow(id) {
var div = document.createElement('div');
div.id = 'domain-' + id;
div.className = "row";
div.dataset.id = "" + id;
div.innerHTML = '<div class="col-xs-5"><label for="inputDNS-' + id + '"><?php echo $sprache->dns;?></label><input class="form-control" id="inputDNS-' + id + '" type="text" name="domain[' + id + ']" value="" placeholder="domain.tld" required></div>';
div.innerHTML += '<div class="col-xs-5"><label for="inputDNSPath-' + id + '"><?php echo $sprache->path;?></label><input class="form-control" id="inputDNSPath-' + id + '" type="text" name="path[' + id + ']" value="" placeholder="some/path/"></div>';
div.innerHTML += '<div class="col-xs-2"><label for="inputButton-' + id + '"><?php echo $gsprache->del;?></label><div class="controls"><button class="btn btn-danger btn-sm" id="inputButton-' + id + '" data-id="' + id + '" onclick="removeRow(this);"><i class="fa fa-minus-circle"></i></button></div></div>';
return div;
}
function returnBr(id) {
var br = document.createElement('br');
br.id = 'br-' + id;
return br;
}
function addRow() {
var nextId = getNextFreeIndex();
var domainsDiv = document.getElementById('domains');
domainsDiv.appendChild(returnDomainRow(nextId));
domainsDiv.appendChild(returnBr(nextId));
$('#inputvhostTemplate-' + nextId).val($('#hiddenDefaultTemplate').val());
}
</script>