Merge pull request #93 from Guite/master
Minor coding-style related changes
This commit is contained in:
@@ -16,24 +16,17 @@
|
||||
*/
|
||||
|
||||
define('AREA', 'admin');
|
||||
require_once('./lib/init.php');
|
||||
|
||||
require_once("./lib/init.php");
|
||||
|
||||
if(isset($_POST['id']))
|
||||
{
|
||||
if (isset($_POST['id'])) {
|
||||
$id = intval($_POST['id']);
|
||||
}
|
||||
elseif(isset($_GET['id']))
|
||||
{
|
||||
} elseif(isset($_GET['id'])) {
|
||||
$id = intval($_GET['id']);
|
||||
}
|
||||
|
||||
if($page == 'cronjobs'
|
||||
|| $page == 'overview')
|
||||
{
|
||||
if($action == '')
|
||||
{
|
||||
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_cronjobs");
|
||||
if ($page == 'cronjobs' || $page == 'overview') {
|
||||
if ($action == '') {
|
||||
$log->logAction(ADM_ACTION, LOG_NOTICE, 'viewed admin_cronjobs');
|
||||
|
||||
$fields = array(
|
||||
'c.lastrun' => $lng['cron']['lastrun'],
|
||||
@@ -56,88 +49,65 @@ if($page == 'cronjobs'
|
||||
$i = 0;
|
||||
$count = 0;
|
||||
|
||||
while($row = $db->fetch_array($result))
|
||||
{
|
||||
if($paging->checkDisplay($i))
|
||||
{
|
||||
while ($row = $db->fetch_array($result)) {
|
||||
if ($paging->checkDisplay($i)) {
|
||||
$row = htmlentities_array($row);
|
||||
|
||||
|
||||
$row['lastrun'] = date('d.m.Y H:i', $row['lastrun']);
|
||||
|
||||
if((int)$row['isactive'] == 1)
|
||||
{
|
||||
$row['isactive'] = $lng['panel']['yes'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$row['isactive'] = $lng['panel']['no'];
|
||||
}
|
||||
|
||||
$row['isactive'] = ((int)$row['isactive'] == 1) ? $lng['panel']['yes'] : $lng['panel']['no'];
|
||||
|
||||
$description = $lng['crondesc'][$row['desc_lng_key']];
|
||||
|
||||
eval("\$crons.=\"" . getTemplate("cronjobs/cronjobs_cronjob") . "\";");
|
||||
|
||||
eval("\$crons.=\"" . getTemplate('cronjobs/cronjobs_cronjob') . "\";");
|
||||
$count++;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
eval("echo \"" . getTemplate("cronjobs/cronjobs") . "\";");
|
||||
eval("echo \"" . getTemplate('cronjobs/cronjobs') . "\";");
|
||||
|
||||
}
|
||||
elseif($action == 'new')
|
||||
{
|
||||
} elseif ($action == 'new') {
|
||||
/*
|
||||
* @TODO later
|
||||
*/
|
||||
}
|
||||
elseif($action == 'edit'
|
||||
&& $id != 0)
|
||||
{
|
||||
} elseif ($action == 'edit' && $id != 0) {
|
||||
$result = $db->query_first("SELECT * FROM `" . TABLE_PANEL_CRONRUNS . "` WHERE `id`='" . (int)$id . "'");
|
||||
|
||||
if ($result['cronfile'] != '')
|
||||
{
|
||||
if(isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send')
|
||||
{
|
||||
if ($result['cronfile'] != '') {
|
||||
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||
$isactive = isset($_POST['isactive']) ? 1 : 0;
|
||||
$interval_value = validate($_POST['interval_value'], 'interval_value', '/^([0-9]+)$/Di', 'stringisempty');
|
||||
$interval_interval = validate($_POST['interval_interval'], 'interval_interval');
|
||||
|
||||
if($isactive != 1)
|
||||
{
|
||||
|
||||
if ($isactive != 1) {
|
||||
$isactive = 0;
|
||||
}
|
||||
|
||||
$interval = $interval_value.' '.strtoupper($interval_interval);
|
||||
|
||||
|
||||
$interval = $interval_value . ' ' . strtoupper($interval_interval);
|
||||
|
||||
$db->query("UPDATE `" . TABLE_PANEL_CRONRUNS . "`
|
||||
SET `isactive` = '".(int)$isactive."',
|
||||
`interval` = '".$interval."'
|
||||
WHERE `id` = '" . (int)$id . "'");
|
||||
|
||||
redirectTo($filename, Array('page' => $page, 's' => $s));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
//$isactive = makeyesno('isactive', '1', '0', $result['isactive']);
|
||||
// interval
|
||||
$interval_nfo = explode(' ', $result['interval']);
|
||||
$interval_value = $interval_nfo[0];
|
||||
|
||||
$interval_interval = '';
|
||||
$interval_interval.= makeoption($lng['cronmgmt']['seconds'], 'SECOND', $interval_nfo[1]);
|
||||
$interval_interval.= makeoption($lng['cronmgmt']['minutes'], 'MINUTE', $interval_nfo[1]);
|
||||
$interval_interval.= makeoption($lng['cronmgmt']['hours'], 'HOUR', $interval_nfo[1]);
|
||||
$interval_interval.= makeoption($lng['cronmgmt']['days'], 'DAY', $interval_nfo[1]);
|
||||
$interval_interval.= makeoption($lng['cronmgmt']['weeks'], 'WEEK', $interval_nfo[1]);
|
||||
$interval_interval.= makeoption($lng['cronmgmt']['months'], 'MONTH', $interval_nfo[1]);
|
||||
$interval_interval .= makeoption($lng['cronmgmt']['seconds'], 'SECOND', $interval_nfo[1]);
|
||||
$interval_interval .= makeoption($lng['cronmgmt']['minutes'], 'MINUTE', $interval_nfo[1]);
|
||||
$interval_interval .= makeoption($lng['cronmgmt']['hours'], 'HOUR', $interval_nfo[1]);
|
||||
$interval_interval .= makeoption($lng['cronmgmt']['days'], 'DAY', $interval_nfo[1]);
|
||||
$interval_interval .= makeoption($lng['cronmgmt']['weeks'], 'WEEK', $interval_nfo[1]);
|
||||
$interval_interval .= makeoption($lng['cronmgmt']['months'], 'MONTH', $interval_nfo[1]);
|
||||
// end of interval
|
||||
|
||||
|
||||
$change_cronfile = false;
|
||||
if (substr($result['module'], 0, strpos($result['module'], '/')) != 'froxlor')
|
||||
{
|
||||
if (substr($result['module'], 0, strpos($result['module'], '/')) != 'froxlor') {
|
||||
$change_cronfile = true;
|
||||
}
|
||||
|
||||
@@ -147,13 +117,11 @@ if($page == 'cronjobs'
|
||||
$title = $cronjobs_edit_data['cronjobs_edit']['title'];
|
||||
$image = $cronjobs_edit_data['cronjobs_edit']['image'];
|
||||
|
||||
eval("echo \"" . getTemplate("cronjobs/cronjob_edit") . "\";");
|
||||
eval("echo \"" . getTemplate('cronjobs/cronjob_edit') . "\";");
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif($action == 'delete'
|
||||
&& $id != 0)
|
||||
{
|
||||
elseif ($action == 'delete' && $id != 0) {
|
||||
/*
|
||||
* @TODO later
|
||||
*/
|
||||
|
||||
@@ -22,14 +22,12 @@ define('AREA', 'admin');
|
||||
/**
|
||||
* Include our init.php, which manages Sessions, Language etc.
|
||||
*/
|
||||
require('./lib/init.php');
|
||||
|
||||
require ("./lib/init.php");
|
||||
|
||||
if($page == 'log'
|
||||
&& $userinfo['change_serversettings'] == '1')
|
||||
{
|
||||
if($action == '')
|
||||
{
|
||||
if ($page == 'log'
|
||||
&& $userinfo['change_serversettings'] == '1'
|
||||
) {
|
||||
if ($action == '') {
|
||||
$fields = array(
|
||||
'date' => $lng['logger']['date'],
|
||||
'type' => $lng['logger']['type'],
|
||||
@@ -47,24 +45,21 @@ if($page == 'log'
|
||||
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$clog = array();
|
||||
|
||||
while($row = $db->fetch_array($result))
|
||||
{
|
||||
if(!isset($clog[$row['action']])
|
||||
|| !is_array($clog[$row['action']]))
|
||||
{
|
||||
while ($row = $db->fetch_array($result)) {
|
||||
if (!isset($clog[$row['action']])
|
||||
|| !is_array($clog[$row['action']])
|
||||
) {
|
||||
$clog[$row['action']] = array();
|
||||
}
|
||||
|
||||
$clog[$row['action']][$row['logid']] = $row;
|
||||
}
|
||||
|
||||
if($paging->sortfield == 'date'
|
||||
&& $paging->sortorder == 'desc')
|
||||
{
|
||||
if ($paging->sortfield == 'date'
|
||||
&& $paging->sortorder == 'desc'
|
||||
) {
|
||||
krsort($clog);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ksort($clog);
|
||||
}
|
||||
|
||||
@@ -72,20 +67,15 @@ if($page == 'log'
|
||||
$count = 0;
|
||||
$log_count = 0;
|
||||
$log = '';
|
||||
foreach($clog as $action => $logrows)
|
||||
{
|
||||
foreach ($clog as $action => $logrows) {
|
||||
$_action = 0;
|
||||
foreach($logrows as $row)
|
||||
{
|
||||
if($paging->checkDisplay($i))
|
||||
{
|
||||
foreach ($logrows as $row) {
|
||||
if ($paging->checkDisplay($i)) {
|
||||
$row = htmlentities_array($row);
|
||||
$row['date'] = date("d.m.y H:i:s", $row['date']);
|
||||
|
||||
if($_action != $action)
|
||||
{
|
||||
switch($action)
|
||||
{
|
||||
if ($_action != $action) {
|
||||
switch ($action) {
|
||||
case USR_ACTION:
|
||||
$_action = $lng['admin']['customer'];
|
||||
break;
|
||||
@@ -107,15 +97,14 @@ if($page == 'log'
|
||||
}
|
||||
|
||||
$row['action'] = $_action;
|
||||
eval("\$log.=\"" . getTemplate("logger/logger_action") . "\";");
|
||||
eval("\$log.=\"" . getTemplate('logger/logger_action') . "\";");
|
||||
}
|
||||
|
||||
$log_count++;
|
||||
$type = $row['type'];
|
||||
$_type = 'unknown';
|
||||
|
||||
switch($type)
|
||||
{
|
||||
switch ($type) {
|
||||
case LOG_INFO:
|
||||
$_type = 'Information';
|
||||
break;
|
||||
@@ -137,32 +126,27 @@ if($page == 'log'
|
||||
}
|
||||
|
||||
$row['type'] = $_type;
|
||||
eval("\$log.=\"" . getTemplate("logger/logger_log") . "\";");
|
||||
eval("\$log.=\"" . getTemplate('logger/logger_log') . "\";");
|
||||
$count++;
|
||||
$_action = $action;
|
||||
}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
eval("echo \"" . getTemplate("logger/logger") . "\";");
|
||||
}
|
||||
elseif($action == 'truncate')
|
||||
{
|
||||
if(isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send')
|
||||
{
|
||||
eval("echo \"" . getTemplate('logger/logger') . "\";");
|
||||
} elseif ($action == 'truncate') {
|
||||
if (isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send'
|
||||
) {
|
||||
$yesterday = time() - (60 * 10);
|
||||
|
||||
/* (60*60*24); */
|
||||
|
||||
$db->query("DELETE FROM `" . TABLE_PANEL_LOG . "` WHERE `date` < '" . $yesterday . "'");
|
||||
$log->logAction(ADM_ACTION, LOG_WARNING, "truncated the system-log (mysql)");
|
||||
$log->logAction(ADM_ACTION, LOG_WARNING, 'truncated the system-log (mysql)');
|
||||
redirectTo($filename, Array('page' => $page, 's' => $s));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ask_yesno('logger_reallytruncate', $filename, array('page' => $page, 'action' => $action), TABLE_PANEL_LOG);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,79 +22,60 @@ define('AREA', 'admin');
|
||||
/**
|
||||
* Include our init.php, which manages Sessions, Language etc.
|
||||
*/
|
||||
require('./lib/init.php');
|
||||
|
||||
require ("./lib/init.php");
|
||||
|
||||
if(isset($_POST['id']))
|
||||
{
|
||||
if (isset($_POST['id'])) {
|
||||
$id = intval($_POST['id']);
|
||||
}
|
||||
elseif(isset($_GET['id']))
|
||||
{
|
||||
} elseif (isset($_GET['id'])) {
|
||||
$id = intval($_GET['id']);
|
||||
}
|
||||
|
||||
if($page == 'message')
|
||||
{
|
||||
if($action == '')
|
||||
{
|
||||
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed panel_message");
|
||||
if ($page == 'message') {
|
||||
if ($action == '') {
|
||||
$log->logAction(ADM_ACTION, LOG_NOTICE, 'viewed panel_message');
|
||||
|
||||
if(isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send')
|
||||
{
|
||||
if($_POST['receipient'] == 0
|
||||
&& $userinfo['customers_see_all'] == '1')
|
||||
{
|
||||
$log->logAction(ADM_ACTION, LOG_NOTICE, "sending messages to admins");
|
||||
if (isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send'
|
||||
) {
|
||||
if ($_POST['receipient'] == 0
|
||||
&& $userinfo['customers_see_all'] == '1'
|
||||
) {
|
||||
$log->logAction(ADM_ACTION, LOG_NOTICE, 'sending messages to admins');
|
||||
$result = $db->query('SELECT `name`, `email` FROM `' . TABLE_PANEL_ADMINS . "`");
|
||||
}
|
||||
elseif($_POST['receipient'] == 1)
|
||||
{
|
||||
if($userinfo['customers_see_all'] == "1")
|
||||
{
|
||||
$log->logAction(ADM_ACTION, LOG_NOTICE, "sending messages to ALL customers");
|
||||
} elseif ($_POST['receipient'] == 1) {
|
||||
if ($userinfo['customers_see_all'] == '1') {
|
||||
$log->logAction(ADM_ACTION, LOG_NOTICE, 'sending messages to ALL customers');
|
||||
$result = $db->query('SELECT `firstname`, `name`, `email` FROM `' . TABLE_PANEL_CUSTOMERS . "`");
|
||||
}
|
||||
else
|
||||
{
|
||||
$log->logAction(ADM_ACTION, LOG_NOTICE, "sending messages to customers");
|
||||
} else {
|
||||
$log->logAction(ADM_ACTION, LOG_NOTICE, 'sending messages to customers');
|
||||
$result = $db->query('SELECT `firstname`, `name`, `email` FROM `' . TABLE_PANEL_CUSTOMERS . "` WHERE `adminid`='" . $userinfo['adminid'] . "'");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
standard_error('noreceipientsgiven');
|
||||
}
|
||||
|
||||
$subject = $_POST['subject'];
|
||||
$message = wordwrap($_POST['message'], 70);
|
||||
|
||||
if(!empty($message))
|
||||
{
|
||||
if (!empty($message)) {
|
||||
$mailcounter = 0;
|
||||
$mail->Body = $message;
|
||||
$mail->Subject = $subject;
|
||||
|
||||
while($row = $db->fetch_array($result))
|
||||
{
|
||||
while ($row = $db->fetch_array($result)) {
|
||||
$mail->AddAddress($row['email'], (isset($row['firstname']) ? $row['firstname'] . ' ' : '') . $row['name']);
|
||||
$mail->From = $userinfo['email'];
|
||||
$mail->FromName = (isset($userinfo['firstname']) ? $userinfo['firstname'] . ' ' : '') . $userinfo['name'];
|
||||
|
||||
if(!$mail->Send())
|
||||
{
|
||||
if($mail->ErrorInfo != '')
|
||||
{
|
||||
if (!$mail->Send()) {
|
||||
if ($mail->ErrorInfo != '') {
|
||||
$mailerr_msg = $mail->ErrorInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mailerr_msg = $row["email"];
|
||||
} else {
|
||||
$mailerr_msg = $row['email'];
|
||||
}
|
||||
|
||||
$log->logAction(ADM_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg);
|
||||
standard_error('errorsendingmail', $row["email"]);
|
||||
$log->logAction(ADM_ACTION, LOG_ERR, 'Error sending mail: ' . $mailerr_msg);
|
||||
standard_error('errorsendingmail', $row['email']);
|
||||
}
|
||||
|
||||
$mailcounter++;
|
||||
@@ -102,47 +83,34 @@ if($page == 'message')
|
||||
}
|
||||
|
||||
redirectTo($filename, Array('page' => $page, 's' => $s, 'action' => 'showsuccess', 'sentitems' => $mailcounter));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
standard_error('nomessagetosend');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($action == 'showsuccess')
|
||||
{
|
||||
if ($action == 'showsuccess') {
|
||||
$success = 1;
|
||||
$sentitems = isset($_GET['sentitems']) ? (int)$_GET['sentitems'] : 0;
|
||||
|
||||
if($sentitems == 0)
|
||||
{
|
||||
if ($sentitems == 0) {
|
||||
$successmessage = $lng['message']['noreceipients'];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$successmessage = str_replace('%s', $sentitems, $lng['message']['success']);
|
||||
}
|
||||
|
||||
$action = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$success = 0;
|
||||
$sentitems = 0;
|
||||
$successmessage = '';
|
||||
$action = '';
|
||||
}
|
||||
$action = '';
|
||||
|
||||
$receipients = '';
|
||||
|
||||
if($userinfo['customers_see_all'] == "1")
|
||||
{
|
||||
if ($userinfo['customers_see_all'] == '1') {
|
||||
$receipients.= makeoption($lng['panel']['reseller'], 0);
|
||||
}
|
||||
|
||||
$receipients.= makeoption($lng['panel']['customer'], 1);
|
||||
eval("echo \"" . getTemplate("message/message") . "\";");
|
||||
$receipients .= makeoption($lng['panel']['customer'], 1);
|
||||
eval("echo \"" . getTemplate('message/message') . "\";");
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -16,10 +16,9 @@
|
||||
*/
|
||||
|
||||
define('AREA', 'admin');
|
||||
require ("./lib/init.php");
|
||||
require('./lib/init.php');
|
||||
|
||||
if($page == 'overview')
|
||||
{
|
||||
if ($page == 'overview') {
|
||||
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_updates");
|
||||
|
||||
/**
|
||||
@@ -29,13 +28,13 @@ if($page == 'overview')
|
||||
*/
|
||||
if (!isFroxlor()) {
|
||||
if (!isset($settings['panel']['version'])
|
||||
|| $settings['panel']['version'] == ''
|
||||
|| $settings['panel']['version'] == ''
|
||||
) {
|
||||
$settings['panel']['version'] = '1.4.2.1';
|
||||
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('panel','version','".$settings['panel']['version']."')");
|
||||
}
|
||||
if (!isset($settings['system']['dbversion'])
|
||||
|| $settings['system']['dbversion'] == ''
|
||||
|| $settings['system']['dbversion'] == ''
|
||||
) {
|
||||
/**
|
||||
* for syscp-stable (1.4.2.1) this value has to be 0
|
||||
@@ -43,11 +42,9 @@ if($page == 'overview')
|
||||
* and the svn-version has its value in the database
|
||||
* -> bug #54
|
||||
*/
|
||||
|
||||
$result = $db->query_first("SELECT `value` FROM `" . TABLE_PANEL_SETTINGS . "` WHERE `varname` = 'dbversion'");
|
||||
|
||||
if(isset($result['value']))
|
||||
{
|
||||
|
||||
if (isset($result['value'])) {
|
||||
$settings['system']['dbversion'] = (int)$result['value'];
|
||||
} else {
|
||||
$settings['system']['dbversion'] = 0;
|
||||
@@ -55,40 +52,36 @@ if($page == 'overview')
|
||||
}
|
||||
}
|
||||
|
||||
if(hasUpdates($version))
|
||||
{
|
||||
if (hasUpdates($version)) {
|
||||
$successful_update = false;
|
||||
$message = '';
|
||||
|
||||
if(isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send')
|
||||
{
|
||||
if((isset($_POST['update_preconfig'])
|
||||
if (isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send'
|
||||
) {
|
||||
if ((isset($_POST['update_preconfig'])
|
||||
&& isset($_POST['update_changesagreed'])
|
||||
&& intval($_POST['update_changesagreed']) != 0)
|
||||
|| !isset($_POST['update_preconfig'])
|
||||
) {
|
||||
eval("echo \"" . getTemplate("update/update_start") . "\";");
|
||||
eval("echo \"" . getTemplate('update/update_start') . "\";");
|
||||
|
||||
include_once './install/updatesql.php';
|
||||
|
||||
$redirect_url = 'admin_index.php?s=' . $s;
|
||||
eval("echo \"" . getTemplate("update/update_end") . "\";");
|
||||
eval("echo \"" . getTemplate('update/update_end') . "\";");
|
||||
|
||||
updateCounters();
|
||||
inserttask('1');
|
||||
@chmod('./lib/userdata.inc.php', 0440);
|
||||
|
||||
$successful_update = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = '<br /><strong style="color:#ff0000;">You have to agree that you have read the update notifications.</strong>';
|
||||
} else {
|
||||
$message = '<br /><strong style="color: red">You have to agree that you have read the update notifications.</strong>';
|
||||
}
|
||||
}
|
||||
|
||||
if(!$successful_update)
|
||||
{
|
||||
if (!$successful_update) {
|
||||
$current_version = $settings['panel']['version'];
|
||||
$new_version = $version;
|
||||
|
||||
@@ -96,29 +89,23 @@ if($page == 'overview')
|
||||
$ui_text = str_replace('%curversion', $current_version, $ui_text);
|
||||
$ui_text = str_replace('%newversion', $new_version, $ui_text);
|
||||
$update_information = $ui_text;
|
||||
|
||||
|
||||
include_once './install/updates/preconfig.php';
|
||||
$preconfig = getPreConfig($current_version);
|
||||
if($preconfig != '')
|
||||
{
|
||||
$update_information .= '<br />'.$preconfig.$message;
|
||||
if ($preconfig != '') {
|
||||
$update_information .= '<br />' . $preconfig . $message;
|
||||
}
|
||||
|
||||
|
||||
$update_information .= $lng['update']['update_information']['part_b'];
|
||||
|
||||
eval("echo \"" . getTemplate("update/index") . "\";");
|
||||
eval("echo \"" . getTemplate('update/index') . "\";");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/*
|
||||
* @TODO version-webcheck check here
|
||||
*/
|
||||
|
||||
$success_message = $lng['update']['noupdatesavail'];
|
||||
$redirect_url = 'admin_index.php?s=' . $s;
|
||||
eval("echo \"" . getTemplate("update/noupdatesavail") . "\";");
|
||||
eval("echo \"" . getTemplate('update/noupdatesavail') . "\";");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -17,18 +17,18 @@
|
||||
*
|
||||
*/
|
||||
|
||||
// Required code
|
||||
|
||||
define('AREA', 'customer');
|
||||
require ("./lib/init.php");
|
||||
require ('./lib/init.php');
|
||||
|
||||
$Id = 0;
|
||||
if (isset($_GET['id'])) {
|
||||
$Id = (int)$_GET['id'];
|
||||
}
|
||||
if (isset($_POST['id'])) {
|
||||
$Id = (int)$_POST['id'];
|
||||
}
|
||||
|
||||
if(isset($_GET['id']))$Id = (int)$_GET['id'];
|
||||
|
||||
if(isset($_POST['id']))$Id = (int)$_POST['id'];
|
||||
eval("echo \"" . getTemplate("aps/header") . "\";");
|
||||
eval("echo \"" . getTemplate('aps/header') . "\";");
|
||||
$Aps = new ApsParser($userinfo, $settings, $db);
|
||||
$Aps->MainHandler($action);
|
||||
eval("echo \"" . getTemplate("aps/footer") . "\";");
|
||||
|
||||
?>
|
||||
eval("echo \"" . getTemplate('aps/footer') . "\";");
|
||||
|
||||
@@ -17,18 +17,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
// Required code
|
||||
|
||||
define('AREA', 'customer');
|
||||
require ("./lib/init.php");
|
||||
require('./lib/init.php');
|
||||
|
||||
// Create new autoresponder
|
||||
|
||||
if($action == "add")
|
||||
{
|
||||
if(isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send')
|
||||
{
|
||||
if ($action == 'add') {
|
||||
// Create new autoresponder
|
||||
if (isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send'
|
||||
) {
|
||||
$account = trim($_POST['account']);
|
||||
$subject = trim($_POST['subject']);
|
||||
$message = trim($_POST['message']);
|
||||
@@ -42,39 +38,31 @@ if($action == "add")
|
||||
$ts_from = -1;
|
||||
$ts_until = -1;
|
||||
|
||||
if($date_from_off > -1)
|
||||
{
|
||||
if ($date_from_off > -1) {
|
||||
$date_from = $_POST['date_from'];
|
||||
$ts_from = mktime(0, 0, 0, substr($date_from, 3, 2), substr($date_from, 0, 2), substr($date_from, 6, 4));
|
||||
}
|
||||
if($date_until_off > -1)
|
||||
{
|
||||
if ($date_until_off > -1) {
|
||||
$date_until = $_POST['date_until'];
|
||||
$ts_until = mktime(0, 0, 0, substr($date_until, 3, 2), substr($date_until, 0, 2), substr($date_until, 6, 4));
|
||||
}
|
||||
|
||||
if(empty($account)
|
||||
if (empty($account)
|
||||
|| empty($subject)
|
||||
|| empty($message))
|
||||
{
|
||||
|| empty($message)
|
||||
) {
|
||||
standard_error('missingfields');
|
||||
}
|
||||
|
||||
// Does account exist?
|
||||
|
||||
$result = $db->query("SELECT `email` FROM `" . TABLE_MAIL_USERS . "` WHERE `customerid` = '" . (int)$userinfo['customerid'] . "' AND `email` = '" . $db->escape($account) . "' LIMIT 0,1");
|
||||
|
||||
if($db->num_rows($result) == 0)
|
||||
{
|
||||
if ($db->num_rows($result) == 0) {
|
||||
standard_error('accountnotexisting');
|
||||
}
|
||||
|
||||
// Does autoresponder exist?
|
||||
|
||||
$result = $db->query("SELECT `email` FROM `" . TABLE_MAIL_AUTORESPONDER . "` WHERE `customerid` = '" . (int)$userinfo['customerid'] . "' AND `email` = '" . $db->escape($account) . "' LIMIT 0,1");
|
||||
|
||||
if($db->num_rows($result) == 1)
|
||||
{
|
||||
if ($db->num_rows($result) == 1) {
|
||||
standard_error('autoresponderalreadyexists');
|
||||
}
|
||||
|
||||
@@ -92,19 +80,14 @@ if($action == "add")
|
||||
}
|
||||
|
||||
// Get accounts
|
||||
|
||||
$result = $db->query("SELECT `email` FROM `" . TABLE_MAIL_USERS . "` WHERE `customerid` = '" . (int)$userinfo['customerid'] . "' AND `email` NOT IN (SELECT `email` FROM `" . TABLE_MAIL_AUTORESPONDER . "`) ORDER BY email ASC");
|
||||
|
||||
if($db->num_rows($result) == 0)
|
||||
{
|
||||
if ($db->num_rows($result) == 0) {
|
||||
standard_error('noemailaccount');
|
||||
}
|
||||
|
||||
$accounts = '';
|
||||
|
||||
while($row = $db->fetch_array($result))
|
||||
{
|
||||
$accounts.= "<option value=\"" . $row['email'] . "\">" . $row['email'] . "</option>";
|
||||
while ($row = $db->fetch_array($result)) {
|
||||
$accounts .= '<option value="' . $row['email'] . '">' . $row['email'] . '</option>';
|
||||
}
|
||||
|
||||
$date_from_off = makecheckbox('date_from_off', $lng['panel']['not_activated'], '-1', false, '-1', true, true);
|
||||
@@ -118,18 +101,12 @@ if($action == "add")
|
||||
$title = $autoresponder_add_data['autoresponder_add']['title'];
|
||||
$image = $autoresponder_add_data['autoresponder_add']['image'];
|
||||
|
||||
eval("echo \"" . getTemplate("autoresponder/autoresponder_add") . "\";");
|
||||
}
|
||||
|
||||
// Edit autoresponder
|
||||
|
||||
else
|
||||
|
||||
if($action == "edit")
|
||||
{
|
||||
if(isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send')
|
||||
{
|
||||
eval("echo \"" . getTemplate('autoresponder/autoresponder_add') . "\";");
|
||||
} elseif ($action == 'edit') {
|
||||
// Edit autoresponder
|
||||
if (isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send'
|
||||
) {
|
||||
$account = trim($_POST['account']);
|
||||
$subject = trim($_POST['subject']);
|
||||
$message = trim($_POST['message']);
|
||||
@@ -143,49 +120,36 @@ if($action == "edit")
|
||||
$ts_from = -1;
|
||||
$ts_until = -1;
|
||||
|
||||
if($date_from_off > -1)
|
||||
{
|
||||
if ($date_from_off > -1) {
|
||||
$date_from = $_POST['date_from'];
|
||||
$ts_from = mktime(0, 0, 0, substr($date_from, 3, 2), substr($date_from, 0, 2), substr($date_from, 6, 4));
|
||||
}
|
||||
if($date_until_off > -1)
|
||||
{
|
||||
if ($date_until_off > -1) {
|
||||
$date_until = $_POST['date_until'];
|
||||
$ts_until = mktime(0, 0, 0, substr($date_until, 3, 2), substr($date_until, 0, 2), substr($date_until, 6, 4));
|
||||
}
|
||||
|
||||
if(empty($account)
|
||||
if (empty($account)
|
||||
|| empty($subject)
|
||||
|| empty($message))
|
||||
{
|
||||
|| empty($message)
|
||||
) {
|
||||
standard_error('missingfields');
|
||||
}
|
||||
|
||||
// Does account exist?
|
||||
|
||||
$result = $db->query("SELECT `email` FROM `" . TABLE_MAIL_USERS . "` WHERE `customerid` = '" . (int)$userinfo['customerid'] . "' AND `email` = '" . $db->escape($account) . "' LIMIT 0,1");
|
||||
|
||||
if($db->num_rows($result) == 0)
|
||||
if ($db->num_rows($result) == 0)
|
||||
{
|
||||
standard_error('accountnotexisting');
|
||||
}
|
||||
|
||||
// Does autoresponder exist?
|
||||
|
||||
$result = $db->query("SELECT `email` FROM `" . TABLE_MAIL_AUTORESPONDER . "` WHERE `customerid` = '" . (int)$userinfo['customerid'] . "' AND `email` = '" . $db->escape($account) . "' LIMIT 0,1");
|
||||
|
||||
if($db->num_rows($result) == 0)
|
||||
{
|
||||
if ($db->num_rows($result) == 0) {
|
||||
standard_error('invalidautoresponder');
|
||||
}
|
||||
|
||||
$ResponderActive = 0;
|
||||
|
||||
if(isset($_POST['active'])
|
||||
&& $_POST['active'] == '1')
|
||||
{
|
||||
$ResponderActive = 1;
|
||||
}
|
||||
$ResponderActive = (isset($_POST['active']) && $_POST['active'] == '1') ? 1 : 0;
|
||||
|
||||
$db->query("UPDATE `" . TABLE_MAIL_AUTORESPONDER . "`
|
||||
SET `message` = '" . $db->escape($message) . "',
|
||||
@@ -202,11 +166,8 @@ if($action == "edit")
|
||||
$email = trim(htmlspecialchars($_GET['email']));
|
||||
|
||||
// Get account data
|
||||
|
||||
$result = $db->query("SELECT * FROM `" . TABLE_MAIL_AUTORESPONDER . "` WHERE `customerid` = '" . (int)$userinfo['customerid'] . "' AND `email` = '" . $db->escape($email) . "' LIMIT 0,1");
|
||||
|
||||
if($db->num_rows($result) == 0)
|
||||
{
|
||||
if ($db->num_rows($result) == 0) {
|
||||
standard_error('invalidautoresponder');
|
||||
}
|
||||
|
||||
@@ -217,25 +178,19 @@ if($action == "edit")
|
||||
$date_from = (int)$row['date_from'];
|
||||
$date_until = (int)$row['date_until'];
|
||||
|
||||
if($date_from == -1)
|
||||
{
|
||||
if ($date_from == -1) {
|
||||
$deactivated = '-1';
|
||||
$date_from = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$deactivated = '0';
|
||||
$date_from = date('d-m-Y', $date_from);
|
||||
}
|
||||
$date_from_off = makecheckbox('date_from_off', $lng['panel']['not_activated'], '-1', false, $deactivated, true, true);
|
||||
|
||||
if($date_until == -1)
|
||||
{
|
||||
if ($date_until == -1) {
|
||||
$deactivated = '-1';
|
||||
$date_until = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$deactivated = '0';
|
||||
$date_until = date('d-m-Y', $date_until);
|
||||
}
|
||||
@@ -249,26 +204,17 @@ if($action == "edit")
|
||||
$title = $autoresponder_edit_data['autoresponder_edit']['title'];
|
||||
$image = $autoresponder_edit_data['autoresponder_edit']['image'];
|
||||
|
||||
eval("echo \"" . getTemplate("autoresponder/autoresponder_edit") . "\";");
|
||||
}
|
||||
|
||||
// Delete autoresponder
|
||||
|
||||
else
|
||||
|
||||
if($action == "delete")
|
||||
{
|
||||
if(isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send')
|
||||
{
|
||||
eval("echo \"" . getTemplate('autoresponder/autoresponder_edit') . "\";");
|
||||
} elseif ($action == 'delete') {
|
||||
// Delete autoresponder
|
||||
if (isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send'
|
||||
) {
|
||||
$account = trim($_POST['account']);
|
||||
|
||||
// Does autoresponder exist?
|
||||
|
||||
$result = $db->query("SELECT `email` FROM `" . TABLE_MAIL_AUTORESPONDER . "` WHERE `customerid` = '" . (int)$userinfo['customerid'] . "' AND `email` = '" . $db->escape($account) . "' LIMIT 0,1");
|
||||
|
||||
if($db->num_rows($result) == 0)
|
||||
{
|
||||
if ($db->num_rows($result) == 0) {
|
||||
standard_error('invalidautoresponder');
|
||||
}
|
||||
|
||||
@@ -282,37 +228,25 @@ if($action == "delete")
|
||||
|
||||
$email = trim(htmlspecialchars($_GET['email']));
|
||||
ask_yesno('autoresponderdelete', $filename, array('action' => $action, 'account' => $email));
|
||||
}
|
||||
|
||||
// List existing autoresponders
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// List existing autoresponders
|
||||
$autoresponder = '';
|
||||
$count = 0;
|
||||
$result = $db->query("SELECT * FROM `" . TABLE_MAIL_AUTORESPONDER . "` WHERE `customerid` = '" . (int)$userinfo['customerid'] . "' ORDER BY email ASC");
|
||||
|
||||
while($row = $db->fetch_array($result))
|
||||
{
|
||||
if($row['date_from'] == -1 && $row['date_until'] == -1)
|
||||
{
|
||||
while ($row = $db->fetch_array($result)) {
|
||||
if ($row['date_from'] == -1 && $row['date_until'] == -1) {
|
||||
$activated_date = $lng['panel']['not_activated'];
|
||||
}
|
||||
elseif($row['date_from'] == -1 && $row['date_until'] != -1)
|
||||
{
|
||||
} elseif($row['date_from'] == -1 && $row['date_until'] != -1) {
|
||||
$activated_date = $lng['autoresponder']['date_until'].': '.date('d-m-Y', $row['date_until']);
|
||||
}
|
||||
elseif($row['date_from'] != -1 && $row['date_until'] == -1)
|
||||
{
|
||||
} elseif($row['date_from'] != -1 && $row['date_until'] == -1) {
|
||||
$activated_date = $lng['autoresponder']['date_from'].': '.date('d-m-Y', $row['date_from']);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$activated_date = date('d-m-Y', $row['date_from']) . ' - ' . date('d-m-Y', $row['date_until']);
|
||||
}
|
||||
eval("\$autoresponder.=\"" . getTemplate("autoresponder/autoresponder_autoresponder") . "\";");
|
||||
eval("\$autoresponder.=\"" . getTemplate('autoresponder/autoresponder_autoresponder') . "\";");
|
||||
$count++;
|
||||
}
|
||||
|
||||
eval("echo \"" . getTemplate("autoresponder/autoresponder") . "\";");
|
||||
eval("echo \"" . getTemplate('autoresponder/autoresponder') . "\";");
|
||||
}
|
||||
|
||||
226
customer_ftp.php
226
customer_ftp.php
@@ -22,27 +22,20 @@ define('AREA', 'customer');
|
||||
/**
|
||||
* Include our init.php, which manages Sessions, Language etc.
|
||||
*/
|
||||
require('./lib/init.php');
|
||||
|
||||
require ("./lib/init.php");
|
||||
|
||||
if(isset($_POST['id']))
|
||||
{
|
||||
$id = 0;
|
||||
if (isset($_POST['id'])) {
|
||||
$id = intval($_POST['id']);
|
||||
}
|
||||
elseif(isset($_GET['id']))
|
||||
{
|
||||
} elseif(isset($_GET['id'])) {
|
||||
$id = intval($_GET['id']);
|
||||
}
|
||||
|
||||
if($page == 'overview')
|
||||
{
|
||||
if ($page == 'overview') {
|
||||
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_ftp");
|
||||
eval("echo \"" . getTemplate("ftp/ftp") . "\";");
|
||||
}
|
||||
elseif($page == 'accounts')
|
||||
{
|
||||
if($action == '')
|
||||
{
|
||||
eval("echo \"" . getTemplate('ftp/ftp') . "\";");
|
||||
} elseif ($page == 'accounts') {
|
||||
if ($action == '') {
|
||||
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_ftp::accounts");
|
||||
$fields = array(
|
||||
'username' => $lng['login']['username'],
|
||||
@@ -59,23 +52,18 @@ elseif($page == 'accounts')
|
||||
$count = 0;
|
||||
$accounts = '';
|
||||
|
||||
while($row = $db->fetch_array($result))
|
||||
{
|
||||
if($paging->checkDisplay($i))
|
||||
{
|
||||
if(strpos($row['homedir'], $userinfo['documentroot']) === 0)
|
||||
{
|
||||
while ($row = $db->fetch_array($result)) {
|
||||
if ($paging->checkDisplay($i)) {
|
||||
if (strpos($row['homedir'], $userinfo['documentroot']) === 0) {
|
||||
$row['documentroot'] = substr($row['homedir'], strlen($userinfo['documentroot']));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$row['documentroot'] = $row['homedir'];
|
||||
}
|
||||
|
||||
$row['documentroot'] = makeCorrectDir($row['documentroot']);
|
||||
|
||||
$row = htmlentities_array($row);
|
||||
eval("\$accounts.=\"" . getTemplate("ftp/accounts_account") . "\";");
|
||||
eval("\$accounts.=\"" . getTemplate('ftp/accounts_account') . "\";");
|
||||
$count++;
|
||||
}
|
||||
|
||||
@@ -83,19 +71,16 @@ elseif($page == 'accounts')
|
||||
}
|
||||
|
||||
$ftps_count = $db->num_rows($result);
|
||||
eval("echo \"" . getTemplate("ftp/accounts") . "\";");
|
||||
}
|
||||
elseif($action == 'delete'
|
||||
&& $id != 0)
|
||||
{
|
||||
eval("echo \"" . getTemplate('ftp/accounts') . "\";");
|
||||
} elseif ($action == 'delete' && $id != 0) {
|
||||
$result = $db->query_first("SELECT `id`, `username`, `homedir`, `up_count`, `up_bytes`, `down_count`, `down_bytes` FROM `" . TABLE_FTP_USERS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'");
|
||||
|
||||
if(isset($result['username'])
|
||||
&& $result['username'] != $userinfo['loginname'])
|
||||
{
|
||||
if(isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send')
|
||||
{
|
||||
if (isset($result['username'])
|
||||
&& $result['username'] != $userinfo['loginname']
|
||||
) {
|
||||
if (isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send'
|
||||
) {
|
||||
$db->query("UPDATE `" . TABLE_FTP_USERS . "` SET `up_count`=`up_count`+'" . (int)$result['up_count'] . "', `up_bytes`=`up_bytes`+'" . (int)$result['up_bytes'] . "', `down_count`=`down_count`+'" . (int)$result['down_count'] . "', `down_bytes`=`down_bytes`+'" . (int)$result['down_bytes'] . "' WHERE `username`='" . $db->escape($userinfo['loginname']) . "'");
|
||||
$result = $db->query_first("SELECT `username`, `homedir` FROM `" . TABLE_FTP_USERS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'");
|
||||
$db->query("DELETE FROM `" . TABLE_FTP_QUOTATALLIES . "` WHERE `name` = '" . $db->escape($result['username']) . "'");
|
||||
@@ -103,96 +88,69 @@ elseif($page == 'accounts')
|
||||
$log->logAction(USR_ACTION, LOG_INFO, "deleted ftp-account '" . $result['username'] . "'");
|
||||
$db->query("UPDATE `" . TABLE_FTP_GROUPS . "` SET `members`=REPLACE(`members`,'," . $db->escape($result['username']) . "','') WHERE `customerid`='" . (int)$userinfo['customerid'] . "'");
|
||||
|
||||
if($userinfo['ftps_used'] == '1')
|
||||
{
|
||||
$resetaccnumber = " , `ftp_lastaccountnumber`='0'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$resetaccnumber = '';
|
||||
}
|
||||
$resetaccnumber = ($userinfo['ftps_used'] == '1') ? " , `ftp_lastaccountnumber`='0'" : '';
|
||||
|
||||
// refs #293
|
||||
if(isset($_POST['delete_userfiles'])
|
||||
&& (int)$_POST['delete_userfiles'] == 1)
|
||||
{
|
||||
if (isset($_POST['delete_userfiles'])
|
||||
&& (int)$_POST['delete_userfiles'] == 1
|
||||
) {
|
||||
inserttask('8', $userinfo['loginname'], $result['homedir']);
|
||||
}
|
||||
|
||||
$result = $db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `ftps_used`=`ftps_used`-1 $resetaccnumber WHERE `customerid`='" . (int)$userinfo['customerid'] . "'");
|
||||
redirectTo($filename, Array('page' => $page, 's' => $s));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ask_yesno_withcheckbox('ftp_reallydelete', 'admin_customer_alsoremoveftphomedir', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $result['username']);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
standard_error('ftp_cantdeletemainaccount');
|
||||
}
|
||||
}
|
||||
elseif($action == 'add')
|
||||
{
|
||||
if($userinfo['ftps_used'] < $userinfo['ftps']
|
||||
|| $userinfo['ftps'] == '-1')
|
||||
{
|
||||
if(isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send')
|
||||
{
|
||||
} elseif ($action == 'add') {
|
||||
if ($userinfo['ftps_used'] < $userinfo['ftps']
|
||||
|| $userinfo['ftps'] == '-1'
|
||||
) {
|
||||
if (isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send'
|
||||
) {
|
||||
$path = validate($_POST['path'], 'path');
|
||||
$password = validate($_POST['ftp_password'], 'password');
|
||||
$password = validatePassword($password);
|
||||
|
||||
$sendinfomail = isset($_POST['sendinfomail']) ? 1 : 0;
|
||||
if($sendinfomail != 1)
|
||||
{
|
||||
if ($sendinfomail != 1) {
|
||||
$sendinfomail = 0;
|
||||
}
|
||||
|
||||
if($settings['customer']['ftpatdomain'] == '1')
|
||||
{
|
||||
if ($settings['customer']['ftpatdomain'] == '1') {
|
||||
$ftpusername = validate($_POST['ftp_username'], 'username', '/^[a-zA-Z0-9][a-zA-Z0-9\-_]+\$?$/');
|
||||
if($ftpusername == '')
|
||||
{
|
||||
if ($ftpusername == '') {
|
||||
standard_error(array('stringisempty', 'username'));
|
||||
}
|
||||
$ftpdomain = $idna_convert->encode(validate($_POST['ftp_domain'], 'domain'));
|
||||
$ftpdomain_check = $db->query_first("SELECT `id`, `domain`, `customerid` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `domain`='" . $db->escape($ftpdomain) . "' AND `customerid`='" . (int)$userinfo['customerid'] . "'");
|
||||
if($ftpdomain_check['domain'] != $ftpdomain)
|
||||
{
|
||||
if ($ftpdomain_check['domain'] != $ftpdomain) {
|
||||
standard_error('maindomainnonexist', $domain);
|
||||
}
|
||||
$username = $ftpusername . "@" . $ftpdomain;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$username = $userinfo['loginname'] . $settings['customer']['ftpprefix'] . (intval($userinfo['ftp_lastaccountnumber']) + 1);
|
||||
}
|
||||
|
||||
$username_check = $db->query_first('SELECT * FROM `' . TABLE_FTP_USERS .'` WHERE `username` = \'' . $db->escape($username) . '\'');
|
||||
|
||||
if(!empty($username_check) && $username_check['username'] = $username)
|
||||
{
|
||||
if (!empty($username_check) && $username_check['username'] = $username) {
|
||||
standard_error('usernamealreadyexists', $username);
|
||||
}
|
||||
elseif($password == '')
|
||||
{
|
||||
} elseif ($password == '') {
|
||||
standard_error(array('stringisempty', 'mypassword'));
|
||||
}
|
||||
elseif($path == '')
|
||||
{
|
||||
} elseif ($path == '') {
|
||||
standard_error('patherror');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$path = makeCorrectDir($userinfo['documentroot'] . '/' . $path);
|
||||
|
||||
$cryptPassword = makeCryptPassword($password);
|
||||
$db->query("INSERT INTO `" . TABLE_FTP_USERS . "` (`customerid`, `username`, `password`, `homedir`, `login_enabled`, `uid`, `gid`) VALUES ('" . (int)$userinfo['customerid'] . "', '" . $db->escape($username) . "', '" . $db->escape($cryptPassword) . "', '" . $db->escape($path) . "', 'y', '" . (int)$userinfo['guid'] . "', '" . (int)$userinfo['guid'] . "')");
|
||||
$result = $db->query("SELECT `bytes_in_used` FROM `" . TABLE_FTP_QUOTATALLIES . "` WHERE `name` = '" . $userinfo['loginname'] . "'");
|
||||
while($row = $db->fetch_array($result))
|
||||
{
|
||||
while ($row = $db->fetch_array($result)) {
|
||||
$db->query("INSERT INTO `" . TABLE_FTP_QUOTATALLIES . "` (`name`, `quota_type`, `bytes_in_used`, `bytes_out_used`, `bytes_xfer_used`, `files_in_used`, `files_out_used`, `files_xfer_used`) VALUES ('" . $db->escape($username) . "', 'user', '" . $db->escape($row['bytes_in_used']) . "', '0', '0', '0', '0', '0')");
|
||||
}
|
||||
$db->query("UPDATE `" . TABLE_FTP_GROUPS . "` SET `members`=CONCAT_WS(',',`members`,'" . $db->escape($username) . "') WHERE `customerid`='" . $userinfo['customerid'] . "' AND `gid`='" . (int)$userinfo['guid'] . "'");
|
||||
@@ -201,8 +159,7 @@ elseif($page == 'accounts')
|
||||
$log->logAction(USR_ACTION, LOG_INFO, "added ftp-account '" . $username . " (" . $path . ")'");
|
||||
inserttask(5);
|
||||
|
||||
if($sendinfomail == 1)
|
||||
{
|
||||
if ($sendinfomail == 1) {
|
||||
$replace_arr = array(
|
||||
'SALUTATION' => getCorrectUserSalutation($userinfo),
|
||||
'CUST_NAME' => getCorrectUserSalutation($userinfo), // < keep this for compatibility
|
||||
@@ -242,29 +199,23 @@ elseif($page == 'accounts')
|
||||
|
||||
redirectTo($filename, Array('page' => $page, 's' => $s));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $settings['panel']['pathedit'], '/');
|
||||
|
||||
if($settings['customer']['ftpatdomain'] == '1')
|
||||
{
|
||||
if ($settings['customer']['ftpatdomain'] == '1') {
|
||||
$domainlist = array();
|
||||
$domains = '';
|
||||
|
||||
$result_domains = $db->query("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "'");
|
||||
|
||||
while($row_domain = $db->fetch_array($result_domains))
|
||||
{
|
||||
while ($row_domain = $db->fetch_array($result_domains)) {
|
||||
$domainlist[] = $row_domain['domain'];
|
||||
}
|
||||
|
||||
sort($domainlist);
|
||||
|
||||
if(isset($domainlist[0]) && $domainlist[0] != '')
|
||||
{
|
||||
foreach($domainlist as $dom)
|
||||
{
|
||||
if (isset($domainlist[0]) && $domainlist[0] != '') {
|
||||
foreach ($domainlist as $dom) {
|
||||
$domains .= makeoption($idna_convert->decode($dom), $dom);
|
||||
}
|
||||
}
|
||||
@@ -278,59 +229,47 @@ elseif($page == 'accounts')
|
||||
$title = $ftp_add_data['ftp_add']['title'];
|
||||
$image = $ftp_add_data['ftp_add']['image'];
|
||||
|
||||
eval("echo \"" . getTemplate("ftp/accounts_add") . "\";");
|
||||
eval("echo \"" . getTemplate('ftp/accounts_add') . "\";");
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif($action == 'edit'
|
||||
&& $id != 0)
|
||||
{
|
||||
} elseif ($action == 'edit' && $id != 0) {
|
||||
$result = $db->query_first("SELECT `id`, `username`, `homedir`, `uid`, `gid` FROM `" . TABLE_FTP_USERS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'");
|
||||
|
||||
if(isset($result['username'])
|
||||
&& $result['username'] != '')
|
||||
{
|
||||
if(isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send')
|
||||
{
|
||||
if (isset($result['username'])
|
||||
&& $result['username'] != ''
|
||||
) {
|
||||
if (isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send'
|
||||
) {
|
||||
$path = validate($_POST['path'], 'path');
|
||||
|
||||
$_setnewpass = false;
|
||||
if(isset($_POST['ftp_password']) && $_POST['ftp_password'] != '')
|
||||
{
|
||||
if (isset($_POST['ftp_password']) && $_POST['ftp_password'] != '') {
|
||||
$password = validate($_POST['ftp_password'], 'password');
|
||||
$password = validatePassword($password);
|
||||
$_setnewpass = true;
|
||||
}
|
||||
|
||||
if($_setnewpass)
|
||||
{
|
||||
if($password == '')
|
||||
{
|
||||
if ($_setnewpass) {
|
||||
if ($password == '') {
|
||||
standard_error(array('stringisempty', 'mypassword'));
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$log->logAction(USR_ACTION, LOG_INFO, "updated ftp-account password for '" . $result['username'] . "'");
|
||||
$cryptPassword = makeCryptPassword($password);
|
||||
$db->query("UPDATE `" . TABLE_FTP_USERS . "` SET `password`='" . $db->escape($cryptPassword) . "' WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'");
|
||||
$log->logAction(USR_ACTION, LOG_INFO, "updated ftp-account password for '" . $result['username'] . "'");
|
||||
$cryptPassword = makeCryptPassword($password);
|
||||
$db->query("UPDATE `" . TABLE_FTP_USERS . "` SET `password`='" . $db->escape($cryptPassword) . "' WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'");
|
||||
|
||||
// also update customers backup user password if password of main ftp user is changed
|
||||
if(!preg_match('/' . $settings['customer']['ftpprefix'] . '/', $result['username'])){
|
||||
$db->query("UPDATE `" . TABLE_FTP_USERS . "` SET `password`='" . $db->escape($cryptPassword) . "' WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `username`='" . $result['username'] . "_backup'");
|
||||
}
|
||||
// also update customers backup user password if password of main ftp user is changed
|
||||
if(!preg_match('/' . $settings['customer']['ftpprefix'] . '/', $result['username'])){
|
||||
$db->query("UPDATE `" . TABLE_FTP_USERS . "` SET `password`='" . $db->escape($cryptPassword) . "' WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `username`='" . $result['username'] . "_backup'");
|
||||
}
|
||||
}
|
||||
|
||||
if($path != '')
|
||||
{
|
||||
if ($path != '') {
|
||||
$path = makeCorrectDir($userinfo['documentroot'] . '/' . $path);
|
||||
|
||||
if($path != $result['homedir'])
|
||||
{
|
||||
if(!file_exists($path))
|
||||
{
|
||||
|
||||
if ($path != $result['homedir']) {
|
||||
if (!file_exists($path)) {
|
||||
mkDirWithCorrectOwnership($userinfo['documentroot'], $path, $result['uid'], $result['gid']);
|
||||
inserttask(5); /* Let the cronjob do the rest */
|
||||
}
|
||||
@@ -341,30 +280,23 @@ elseif($page == 'accounts')
|
||||
}
|
||||
|
||||
redirectTo($filename, Array('page' => $page, 's' => $s));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(strpos($result['homedir'], $userinfo['documentroot']) === 0)
|
||||
{
|
||||
} else {
|
||||
if (strpos($result['homedir'], $userinfo['documentroot']) === 0) {
|
||||
$homedir = substr($result['homedir'], strlen($userinfo['documentroot']));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$homedir = $result['homedir'];
|
||||
}
|
||||
$homedir = makeCorrectDir($homedir);
|
||||
|
||||
$pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $settings['panel']['pathedit'], $homedir);
|
||||
|
||||
if($settings['customer']['ftpatdomain'] == '1')
|
||||
{
|
||||
if ($settings['customer']['ftpatdomain'] == '1') {
|
||||
$domains = '';
|
||||
|
||||
$result_domains = $db->query("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "'");
|
||||
|
||||
while($row_domain = $db->fetch_array($result_domains))
|
||||
{
|
||||
$domains.= makeoption($idna_convert->decode($row_domain['domain']), $row_domain['domain']);
|
||||
while ($row_domain = $db->fetch_array($result_domains)) {
|
||||
$domains .= makeoption($idna_convert->decode($row_domain['domain']), $row_domain['domain']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,10 +306,8 @@ elseif($page == 'accounts')
|
||||
$title = $ftp_edit_data['ftp_edit']['title'];
|
||||
$image = $ftp_edit_data['ftp_edit']['image'];
|
||||
|
||||
eval("echo \"" . getTemplate("ftp/accounts_edit") . "\";");
|
||||
eval("echo \"" . getTemplate('ftp/accounts_edit') . "\";");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -22,35 +22,27 @@ define('AREA', 'customer');
|
||||
/**
|
||||
* Include our init.php, which manages Sessions, Language etc.
|
||||
*/
|
||||
require('./lib/init.php');
|
||||
|
||||
require ("./lib/init.php");
|
||||
if ($action == 'logout') {
|
||||
$log->logAction(USR_ACTION, LOG_NOTICE, 'logged out');
|
||||
|
||||
if($action == 'logout')
|
||||
{
|
||||
$log->logAction(USR_ACTION, LOG_NOTICE, "logged out");
|
||||
|
||||
if($settings['session']['allow_multiple_login'] == '1')
|
||||
{
|
||||
$db->query("DELETE FROM `" . TABLE_PANEL_SESSIONS . "` WHERE `userid` = '" . (int)$userinfo['customerid'] . "' AND `adminsession` = '0' AND `hash` = '" . $s . "'");
|
||||
$query = "DELETE FROM `" . TABLE_PANEL_SESSIONS . "` WHERE `userid` = '" . (int)$userinfo['customerid'] . "' AND `adminsession` = '0'";
|
||||
if ($settings['session']['allow_multiple_login'] == '1') {
|
||||
$query .= " AND `hash` = '" . $s . "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->query("DELETE FROM `" . TABLE_PANEL_SESSIONS . "` WHERE `userid` = '" . (int)$userinfo['customerid'] . "' AND `adminsession` = '0'");
|
||||
}
|
||||
|
||||
$db->query($query);
|
||||
redirectTo('index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if($page == 'overview')
|
||||
{
|
||||
if ($page == 'overview') {
|
||||
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_index");
|
||||
$domains = '';
|
||||
$result = $db->query("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `parentdomainid`='0' AND `id` <> '" . (int)$userinfo['standardsubdomain'] . "' ");
|
||||
$domainArray = array();
|
||||
|
||||
while($row = $db->fetch_array($result))
|
||||
{
|
||||
while ($row = $db->fetch_array($result)) {
|
||||
$domainArray[] = $idna_convert->decode($row['domain']);
|
||||
}
|
||||
|
||||
@@ -77,22 +69,15 @@ if($page == 'overview')
|
||||
$awaitingtickets = $opentickets['count'];
|
||||
$awaitingtickets_text = '';
|
||||
|
||||
if($opentickets > 0)
|
||||
{
|
||||
if ($opentickets > 0) {
|
||||
$awaitingtickets_text = strtr($lng['ticket']['awaitingticketreply'], array('%s' => '<a href="customer_tickets.php?page=tickets&s=' . $s . '">' . $opentickets['count'] . '</a>'));
|
||||
}
|
||||
|
||||
eval("echo \"" . getTemplate("index/index") . "\";");
|
||||
}
|
||||
elseif($page == 'change_password')
|
||||
{
|
||||
if(isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send')
|
||||
{
|
||||
eval("echo \"" . getTemplate('index/index') . "\";");
|
||||
} elseif ($page == 'change_password') {
|
||||
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||
$old_password = validate($_POST['old_password'], 'old password');
|
||||
|
||||
if(md5($old_password) != $userinfo['password'])
|
||||
{
|
||||
if (md5($old_password) != $userinfo['password']) {
|
||||
standard_error('oldpasswordnotcorrect');
|
||||
exit;
|
||||
}
|
||||
@@ -100,45 +85,33 @@ elseif($page == 'change_password')
|
||||
$new_password = validatePassword($_POST['new_password'], 'new password');
|
||||
$new_password_confirm = validatePassword($_POST['new_password_confirm'], 'new password confirm');
|
||||
|
||||
if($old_password == '')
|
||||
{
|
||||
if ($old_password == '') {
|
||||
standard_error(array('stringisempty', 'oldpassword'));
|
||||
}
|
||||
elseif($new_password == '')
|
||||
{
|
||||
} elseif($new_password == '') {
|
||||
standard_error(array('stringisempty', 'newpassword'));
|
||||
}
|
||||
elseif($new_password_confirm == '')
|
||||
{
|
||||
} elseif($new_password_confirm == '') {
|
||||
standard_error(array('stringisempty', 'newpasswordconfirm'));
|
||||
}
|
||||
elseif($new_password != $new_password_confirm)
|
||||
{
|
||||
} elseif($new_password != $new_password_confirm) {
|
||||
standard_error('newpasswordconfirmerror');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `password`='" . md5($new_password) . "' WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `password`='" . md5($old_password) . "'");
|
||||
$log->logAction(USR_ACTION, LOG_NOTICE, 'changed password');
|
||||
|
||||
if(isset($_POST['change_main_ftp'])
|
||||
&& $_POST['change_main_ftp'] == 'true')
|
||||
{
|
||||
if (isset($_POST['change_main_ftp'])
|
||||
&& $_POST['change_main_ftp'] == 'true'
|
||||
) {
|
||||
$cryptPassword = makeCryptPassword($new_password);
|
||||
$db->query("UPDATE `" . TABLE_FTP_USERS . "` SET `password`='" . $db->escape($cryptPassword) . "' WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `username`='" . $db->escape($userinfo['loginname']) . "'");
|
||||
$log->logAction(USR_ACTION, LOG_NOTICE, 'changed main ftp password');
|
||||
}
|
||||
|
||||
if(isset($_POST['change_webalizer'])
|
||||
&& $_POST['change_webalizer'] == 'true')
|
||||
{
|
||||
if(CRYPT_STD_DES == 1)
|
||||
{
|
||||
if (isset($_POST['change_webalizer'])
|
||||
&& $_POST['change_webalizer'] == 'true'
|
||||
) {
|
||||
if (CRYPT_STD_DES == 1) {
|
||||
$saltfordescrypt = substr(md5(uniqid(microtime(), 1)), 4, 2);
|
||||
$new_webalizer_password = crypt($new_password, $saltfordescrypt);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$new_webalizer_password = crypt($new_password);
|
||||
}
|
||||
|
||||
@@ -147,72 +120,52 @@ elseif($page == 'change_password')
|
||||
|
||||
redirectTo($filename, Array('s' => $s));
|
||||
}
|
||||
} else {
|
||||
eval("echo \"" . getTemplate('index/change_password') . "\";");
|
||||
}
|
||||
else
|
||||
{
|
||||
eval("echo \"" . getTemplate("index/change_password") . "\";");
|
||||
}
|
||||
}
|
||||
elseif($page == 'change_language')
|
||||
{
|
||||
if(isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send')
|
||||
{
|
||||
} elseif ($page == 'change_language') {
|
||||
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||
$def_language = validate($_POST['def_language'], 'default language');
|
||||
|
||||
if(isset($languages[$def_language]))
|
||||
{
|
||||
if (isset($languages[$def_language])) {
|
||||
$db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `def_language`='" . $db->escape($def_language) . "' WHERE `customerid`='" . (int)$userinfo['customerid'] . "'");
|
||||
$db->query("UPDATE `" . TABLE_PANEL_SESSIONS . "` SET `language`='" . $db->escape($def_language) . "' WHERE `hash`='" . $db->escape($s) . "'");
|
||||
$log->logAction(USR_ACTION, LOG_NOTICE, "changed default language to '" . $def_language . "'");
|
||||
}
|
||||
|
||||
redirectTo($filename, Array('s' => $s));
|
||||
}
|
||||
else
|
||||
{
|
||||
$language_options = '';
|
||||
|
||||
} else {
|
||||
$default_lang = $settings['panel']['standardlanguage'];
|
||||
if($userinfo['def_language'] != '') {
|
||||
if ($userinfo['def_language'] != '') {
|
||||
$default_lang = $userinfo['def_language'];
|
||||
}
|
||||
|
||||
while(list($language_file, $language_name) = each($languages))
|
||||
{
|
||||
$language_options.= makeoption($language_name, $language_file, $default_lang, true);
|
||||
$language_options = '';
|
||||
while (list($language_file, $language_name) = each($languages)) {
|
||||
$language_options .= makeoption($language_name, $language_file, $default_lang, true);
|
||||
}
|
||||
|
||||
eval("echo \"" . getTemplate("index/change_language") . "\";");
|
||||
eval("echo \"" . getTemplate('index/change_language') . "\";");
|
||||
}
|
||||
}
|
||||
elseif($page == 'change_theme')
|
||||
{
|
||||
if(isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send'
|
||||
) {
|
||||
} elseif ($page == 'change_theme') {
|
||||
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||
$theme = validate($_POST['theme'], 'theme');
|
||||
|
||||
$db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `theme`='" . $db->escape($theme) . "' WHERE `customerid`='" . (int)$userinfo['customerid'] . "'");
|
||||
$db->query("UPDATE `" . TABLE_PANEL_SESSIONS . "` SET `theme`='" . $db->escape($theme) . "' WHERE `hash`='" . $db->escape($s) . "'");
|
||||
$log->logAction(USR_ACTION, LOG_NOTICE, "changed default theme to '" . $theme . "'");
|
||||
redirectTo($filename, Array('s' => $s));
|
||||
}
|
||||
else
|
||||
{
|
||||
$theme_options = '';
|
||||
|
||||
} else {
|
||||
$default_theme = $settings['panel']['default_theme'];
|
||||
if($userinfo['theme'] != '') {
|
||||
if ($userinfo['theme'] != '') {
|
||||
$default_theme = $userinfo['theme'];
|
||||
}
|
||||
|
||||
$theme_options = '';
|
||||
$themes_avail = getThemes();
|
||||
foreach($themes_avail as $t)
|
||||
{
|
||||
$theme_options.= makeoption($t, $t, $default_theme, true);
|
||||
foreach ($themes_avail as $t) {
|
||||
$theme_options .= makeoption($t, $t, $default_theme, true);
|
||||
}
|
||||
|
||||
eval("echo \"" . getTemplate("index/change_theme") . "\";");
|
||||
eval("echo \"" . getTemplate('index/change_theme') . "\";");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,30 +22,22 @@ define('AREA', 'customer');
|
||||
/**
|
||||
* Include our init.php, which manages Sessions, Language etc.
|
||||
*/
|
||||
|
||||
$need_db_sql_data = true;
|
||||
$need_root_db_sql_data = true;
|
||||
require ("./lib/init.php");
|
||||
require('./lib/init.php');
|
||||
|
||||
if(isset($_POST['id']))
|
||||
{
|
||||
if (isset($_POST['id'])) {
|
||||
$id = intval($_POST['id']);
|
||||
}
|
||||
elseif(isset($_GET['id']))
|
||||
{
|
||||
} elseif(isset($_GET['id'])) {
|
||||
$id = intval($_GET['id']);
|
||||
}
|
||||
|
||||
if($page == 'overview')
|
||||
{
|
||||
if ($page == 'overview') {
|
||||
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_mysql");
|
||||
$lng['mysql']['description'] = str_replace('<SQL_HOST>', $sql['host'], $lng['mysql']['description']);
|
||||
eval("echo \"" . getTemplate("mysql/mysql") . "\";");
|
||||
}
|
||||
elseif($page == 'mysqls')
|
||||
{
|
||||
if($action == '')
|
||||
{
|
||||
eval("echo \"" . getTemplate('mysql/mysql') . "\";");
|
||||
} elseif($page == 'mysqls') {
|
||||
if ($action == '') {
|
||||
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_mysql::mysqls");
|
||||
$fields = array(
|
||||
'databasename' => $lng['mysql']['databasename'],
|
||||
@@ -64,53 +56,44 @@ elseif($page == 'mysqls')
|
||||
|
||||
// Begin root-session
|
||||
$db_root = new db($sql_root[0]['host'], $sql_root[0]['user'], $sql_root[0]['password'], '');
|
||||
while($row = $db->fetch_array($result))
|
||||
{
|
||||
if($paging->checkDisplay($i))
|
||||
{
|
||||
while ($row = $db->fetch_array($result)) {
|
||||
if ($paging->checkDisplay($i)) {
|
||||
$row = htmlentities_array($row);
|
||||
$mbdata = $db_root->query_first("SELECT SUM( data_length + index_length) / 1024 / 1024 'MB' FROM information_schema.TABLES WHERE table_schema = '" . $db_root->escape($row['databasename']) . "' GROUP BY table_schema ;");
|
||||
$row['size'] = number_format($mbdata['MB'], 3, '.', '');
|
||||
eval("\$mysqls.=\"" . getTemplate("mysql/mysqls_database") . "\";");
|
||||
eval("\$mysqls.=\"" . getTemplate('mysql/mysqls_database') . "\";");
|
||||
$count++;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
$db_root->close();
|
||||
// End root-session
|
||||
|
||||
$mysqls_count = $db->num_rows($result);
|
||||
eval("echo \"" . getTemplate("mysql/mysqls") . "\";");
|
||||
}
|
||||
elseif($action == 'delete'
|
||||
&& $id != 0)
|
||||
{
|
||||
eval("echo \"" . getTemplate('mysql/mysqls') . "\";");
|
||||
} elseif($action == 'delete' && $id != 0) {
|
||||
$result = $db->query_first('SELECT `id`, `databasename`, `description`, `dbserver` FROM `' . TABLE_PANEL_DATABASES . '` WHERE `customerid`="' . (int)$userinfo['customerid'] . '" AND `id`="' . (int)$id . '"');
|
||||
|
||||
if(isset($result['databasename'])
|
||||
&& $result['databasename'] != '')
|
||||
{
|
||||
if(!isset($sql_root[$result['dbserver']]) || !is_array($sql_root[$result['dbserver']]))
|
||||
{
|
||||
if (isset($result['databasename'])
|
||||
&& $result['databasename'] != ''
|
||||
) {
|
||||
if (!isset($sql_root[$result['dbserver']]) || !is_array($sql_root[$result['dbserver']])) {
|
||||
$result['dbserver'] = 0;
|
||||
}
|
||||
|
||||
if(isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send')
|
||||
{
|
||||
if (isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send'
|
||||
) {
|
||||
// Begin root-session
|
||||
|
||||
$db_root = new db($sql_root[$result['dbserver']]['host'], $sql_root[$result['dbserver']]['user'], $sql_root[$result['dbserver']]['password'], '');
|
||||
$log->logAction(USR_ACTION, LOG_INFO, "deleted database '" . $result['databasename'] . "'");
|
||||
if(mysql_get_server_info() < '5.0.2') {
|
||||
if (mysql_get_server_info() < '5.0.2') {
|
||||
// Revoke privileges (only required for MySQL 4.1.2 - 5.0.1)
|
||||
$db_root->query('REVOKE ALL PRIVILEGES, GRANT OPTION FROM \'' . $db_root->escape($result['databasename']) .'\'',false,true);
|
||||
}
|
||||
|
||||
$host_res = $db_root->query("SELECT `Host` FROM `mysql`.`user` WHERE `User`='" . $db_root->escape($result['databasename']) . "'");
|
||||
while($host = $db_root->fetch_array($host_res))
|
||||
{
|
||||
while ($host = $db_root->fetch_array($host_res)) {
|
||||
// as of MySQL 5.0.2 this also revokes privileges. (requires MySQL 4.1.2+)
|
||||
$db_root->query('DROP USER \'' . $db_root->escape($result['databasename']). '\'@\'' . $db_root->escape($host['Host']) . '\'', false, true);
|
||||
}
|
||||
@@ -118,70 +101,47 @@ elseif($page == 'mysqls')
|
||||
$db_root->query('DROP DATABASE IF EXISTS `' . $db_root->escape($result['databasename']) . '`');
|
||||
$db_root->query('FLUSH PRIVILEGES');
|
||||
$db_root->close();
|
||||
|
||||
// End root-session
|
||||
|
||||
$db->query('DELETE FROM `' . TABLE_PANEL_DATABASES . '` WHERE `customerid`="' . (int)$userinfo['customerid'] . '" AND `id`="' . (int)$id . '"');
|
||||
|
||||
if($userinfo['mysqls_used'] == '1')
|
||||
{
|
||||
$resetaccnumber = " , `mysql_lastaccountnumber`='0' ";
|
||||
}
|
||||
else
|
||||
{
|
||||
$resetaccnumber = '';
|
||||
}
|
||||
$resetaccnumber = ($userinfo['mysqls_used'] == '1') ? " , `mysql_lastaccountnumber`='0' " : '';
|
||||
|
||||
$result = $db->query('UPDATE `' . TABLE_PANEL_CUSTOMERS . '` SET `mysqls_used`=`mysqls_used`-1 ' . $resetaccnumber . 'WHERE `customerid`="' . (int)$userinfo['customerid'] . '"');
|
||||
redirectTo($filename, Array('page' => $page, 's' => $s));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$dbnamedesc = $result['databasename'];
|
||||
if(isset($result['description']) && $result['description'] != '') {
|
||||
$dbnamedesc.= ' ('.$result['description'].')';
|
||||
if (isset($result['description']) && $result['description'] != '') {
|
||||
$dbnamedesc .= ' ('.$result['description'].')';
|
||||
}
|
||||
ask_yesno('mysql_reallydelete', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $dbnamedesc);
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif($action == 'add')
|
||||
{
|
||||
if($userinfo['mysqls_used'] < $userinfo['mysqls']
|
||||
|| $userinfo['mysqls'] == '-1')
|
||||
{
|
||||
if(isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send')
|
||||
{
|
||||
} elseif ($action == 'add') {
|
||||
if ($userinfo['mysqls_used'] < $userinfo['mysqls']
|
||||
|| $userinfo['mysqls'] == '-1'
|
||||
) {
|
||||
if (isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send'
|
||||
) {
|
||||
$password = validate($_POST['mysql_password'], 'password');
|
||||
$password = validatePassword($password);
|
||||
|
||||
$sendinfomail = isset($_POST['sendinfomail']) ? 1 : 0;
|
||||
if($sendinfomail != 1)
|
||||
{
|
||||
if ($sendinfomail != 1) {
|
||||
$sendinfomail = 0;
|
||||
}
|
||||
|
||||
if($password == '')
|
||||
{
|
||||
if ($password == '') {
|
||||
standard_error(array('stringisempty', 'mypassword'));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if(count($sql_root) > 1)
|
||||
{
|
||||
} else {
|
||||
$dbserver = 0;
|
||||
if (count($sql_root) > 1) {
|
||||
$dbserver = validate($_POST['mysql_server'], html_entity_decode($lng['mysql']['mysql_server']), '', '', 0);
|
||||
|
||||
if(!isset($sql_root[$dbserver]) || !is_array($sql_root[$dbserver]))
|
||||
{
|
||||
if (!isset($sql_root[$dbserver]) || !is_array($sql_root[$dbserver])) {
|
||||
$dbserver = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$dbserver = 0;
|
||||
}
|
||||
|
||||
// validate description before actual adding the database, #1052
|
||||
$databasedescription = validate(trim($_POST['description']), 'description');
|
||||
@@ -189,13 +149,13 @@ elseif($page == 'mysqls')
|
||||
// Begin root-session
|
||||
$db_root = new db($sql_root[$dbserver]['host'], $sql_root[$dbserver]['user'], $sql_root[$dbserver]['password'], '');
|
||||
|
||||
if (strtoupper($settings['customer']['mysqlprefix']) == "RANDOM") {
|
||||
if (strtoupper($settings['customer']['mysqlprefix']) == 'RANDOM') {
|
||||
$result = $db_root->query('SELECT `User` FROM mysql.user');
|
||||
while ($row = $db_root->fetch_array($result)) {
|
||||
$allsqlusers[] = $row[User];
|
||||
}
|
||||
$username = $userinfo['loginname'] . '-' . substr(md5(uniqid(microtime(), 1)), 20, 3);
|
||||
while (in_Array($username , $allsqlusers)) {
|
||||
while (in_array($username , $allsqlusers)) {
|
||||
$username = $userinfo['loginname'] . '-' . substr(md5(uniqid(microtime(), 1)), 20, 3);
|
||||
}
|
||||
} else {
|
||||
@@ -204,8 +164,7 @@ elseif($page == 'mysqls')
|
||||
|
||||
$db_root->query('CREATE DATABASE `' . $db_root->escape($username) . '`');
|
||||
$log->logAction(USR_ACTION, LOG_INFO, "created database '" . $username . "'");
|
||||
foreach(array_map('trim', explode(',', $settings['system']['mysql_access_host'])) as $mysql_access_host)
|
||||
{
|
||||
foreach (array_map('trim', explode(',', $settings['system']['mysql_access_host'])) as $mysql_access_host) {
|
||||
$db_root->query('GRANT ALL PRIVILEGES ON `' . str_replace('_', '\_', $db_root->escape($username)) . '`.* TO `' . $db_root->escape($username) . '`@`' . $db_root->escape($mysql_access_host) . '` IDENTIFIED BY \'password\'');
|
||||
$db_root->query('SET PASSWORD FOR `' . $db_root->escape($username) . '`@`' . $db_root->escape($mysql_access_host) . '` = PASSWORD(\'' . $db_root->escape($password) . '\')');
|
||||
$log->logAction(USR_ACTION, LOG_NOTICE, "grant all privileges for '" . $username . "'@'" . $mysql_access_host . "'");
|
||||
@@ -213,17 +172,15 @@ elseif($page == 'mysqls')
|
||||
|
||||
$db_root->query('FLUSH PRIVILEGES');
|
||||
$db_root->close();
|
||||
|
||||
// End root-session
|
||||
// Statement modifyed for Database description -- PH 2004-11-29
|
||||
|
||||
// Statement modified for Database description -- PH 2004-11-29
|
||||
$result = $db->query('INSERT INTO `' . TABLE_PANEL_DATABASES . '` (`customerid`, `databasename`, `description`, `dbserver`) VALUES ("' . (int)$userinfo['customerid'] . '", "' . $db->escape($username) . '", "' . $db->escape($databasedescription) . '", "' . $db->escape($dbserver) . '")');
|
||||
$result = $db->query('UPDATE `' . TABLE_PANEL_CUSTOMERS . '` SET `mysqls_used`=`mysqls_used`+1, `mysql_lastaccountnumber`=`mysql_lastaccountnumber`+1 WHERE `customerid`="' . (int)$userinfo['customerid'] . '"');
|
||||
|
||||
if($sendinfomail == 1)
|
||||
{
|
||||
if ($sendinfomail == 1) {
|
||||
$pma = $lng['admin']['notgiven'];
|
||||
if($settings['panel']['phpmyadmin_url'] != '')
|
||||
{
|
||||
if ($settings['panel']['phpmyadmin_url'] != '') {
|
||||
$pma = $settings['panel']['phpmyadmin_url'];
|
||||
}
|
||||
|
||||
@@ -268,13 +225,10 @@ elseif($page == 'mysqls')
|
||||
|
||||
redirectTo($filename, Array('page' => $page, 's' => $s));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$mysql_servers = '';
|
||||
|
||||
foreach($sql_root as $mysql_server => $mysql_server_details)
|
||||
{
|
||||
foreach ($sql_root as $mysql_server => $mysql_server_details) {
|
||||
$mysql_servers .= makeoption($mysql_server_details['caption'], $mysql_server);
|
||||
}
|
||||
|
||||
@@ -286,44 +240,36 @@ elseif($page == 'mysqls')
|
||||
$title = $mysql_add_data['mysql_add']['title'];
|
||||
$image = $mysql_add_data['mysql_add']['image'];
|
||||
|
||||
eval("echo \"" . getTemplate("mysql/mysqls_add") . "\";");
|
||||
eval("echo \"" . getTemplate('mysql/mysqls_add') . "\";");
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif($action == 'edit'
|
||||
&& $id != 0)
|
||||
{
|
||||
} elseif ($action == 'edit' && $id != 0) {
|
||||
$result = $db->query_first('SELECT `id`, `databasename`, `description`, `dbserver` FROM `' . TABLE_PANEL_DATABASES . '` WHERE `customerid`="' . $userinfo['customerid'] . '" AND `id`="' . $id . '"');
|
||||
|
||||
if(isset($result['databasename'])
|
||||
&& $result['databasename'] != '')
|
||||
{
|
||||
if(!isset($sql_root[$result['dbserver']]) || !is_array($sql_root[$result['dbserver']]))
|
||||
{
|
||||
if (isset($result['databasename'])
|
||||
&& $result['databasename'] != ''
|
||||
) {
|
||||
if (!isset($sql_root[$result['dbserver']]) || !is_array($sql_root[$result['dbserver']])) {
|
||||
$result['dbserver'] = 0;
|
||||
}
|
||||
|
||||
if(isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send')
|
||||
{
|
||||
if (isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send'
|
||||
) {
|
||||
// Only change Password if it is set, do nothing if it is empty! -- PH 2004-11-29
|
||||
$password = validate($_POST['mysql_password'], 'password');
|
||||
|
||||
if($password != '')
|
||||
{
|
||||
if ($password != '') {
|
||||
// validate password
|
||||
$password = validatePassword($password);
|
||||
|
||||
// Begin root-session
|
||||
$db_root = new db($sql_root[$result['dbserver']]['host'], $sql_root[$result['dbserver']]['user'], $sql_root[$result['dbserver']]['password'], '');
|
||||
foreach(array_map('trim', explode(',', $settings['system']['mysql_access_host'])) as $mysql_access_host)
|
||||
{
|
||||
foreach (array_map('trim', explode(',', $settings['system']['mysql_access_host'])) as $mysql_access_host) {
|
||||
$db_root->query('SET PASSWORD FOR `' . $db_root->escape($result['databasename']) . '`@`' . $db_root->escape($mysql_access_host) . '` = PASSWORD(\'' . $db_root->escape($password) . '\')');
|
||||
}
|
||||
|
||||
$db_root->query('FLUSH PRIVILEGES');
|
||||
$db_root->close();
|
||||
|
||||
// End root-session
|
||||
}
|
||||
|
||||
@@ -332,19 +278,15 @@ elseif($page == 'mysqls')
|
||||
$databasedescription = validate($_POST['description'], 'description');
|
||||
$result = $db->query('UPDATE `' . TABLE_PANEL_DATABASES . '` SET `description`="' . $db->escape($databasedescription) . '" WHERE `customerid`="' . (int)$userinfo['customerid'] . '" AND `id`="' . (int)$id . '"');
|
||||
redirectTo($filename, Array('page' => $page, 's' => $s));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$mysql_edit_data = include_once dirname(__FILE__).'/lib/formfields/customer/mysql/formfield.mysql_edit.php';
|
||||
$mysql_edit_form = htmlform::genHTMLForm($mysql_edit_data);
|
||||
|
||||
$title = $mysql_edit_data['mysql_edit']['title'];
|
||||
$image = $mysql_edit_data['mysql_edit']['image'];
|
||||
|
||||
eval("echo \"" . getTemplate("mysql/mysqls_edit") . "\";");
|
||||
eval("echo \"" . getTemplate('mysql/mysqls_edit') . "\";");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -23,20 +23,19 @@ define('AREA', 'customer');
|
||||
* Include our init.php, which manages Sessions, Language etc.
|
||||
*/
|
||||
$intrafficpage = 1;
|
||||
require ("./lib/init.php");
|
||||
require('./lib/init.php');
|
||||
$traffic = '';
|
||||
$month = null;
|
||||
$year = null;
|
||||
|
||||
if(isset($_POST['month'])
|
||||
&& isset($_POST['year']))
|
||||
{
|
||||
if (isset($_POST['month'])
|
||||
&& isset($_POST['year'])
|
||||
) {
|
||||
$month = intval($_POST['month']);
|
||||
$year = intval($_POST['year']);
|
||||
}
|
||||
elseif(isset($_GET['month'])
|
||||
&& isset($_GET['year']))
|
||||
{
|
||||
} elseif (isset($_GET['month'])
|
||||
&& isset($_GET['year'])
|
||||
) {
|
||||
$month = intval($_GET['month']);
|
||||
$year = intval($_GET['year']);
|
||||
}
|
||||
@@ -44,31 +43,24 @@ elseif(isset($_GET['month'])
|
||||
//BAM! $_GET???
|
||||
|
||||
elseif (isset($_GET['page'])
|
||||
&& $_GET['page'] == "current")
|
||||
{
|
||||
if(date('d') != '01')
|
||||
{
|
||||
&& $_GET['page'] == 'current'
|
||||
) {
|
||||
if (date('d') != '01') {
|
||||
$month = date('m');
|
||||
$year = date('Y');
|
||||
}
|
||||
else
|
||||
{
|
||||
if(date('m') == '01')
|
||||
{
|
||||
} else {
|
||||
if (date('m') == '01') {
|
||||
$month = 12;
|
||||
$year = date('Y') - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$month = date('m') - 1;
|
||||
$year = date('Y');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!is_null($month)
|
||||
&& !is_null($year))
|
||||
{
|
||||
if (!is_null($month)
|
||||
&& !is_null($year)) {
|
||||
$traf['byte'] = 0;
|
||||
$result = $db->query("SELECT
|
||||
SUM(`http`) as 'http', SUM(`ftp_up`) AS 'ftp_up', SUM(`ftp_down`) as 'ftp_down', SUM(`mail`) as 'mail',
|
||||
@@ -82,19 +74,17 @@ if(!is_null($month)
|
||||
$traffic_complete['mail'] = 0;
|
||||
$show = '';
|
||||
|
||||
while($row = $db->fetch_array($result))
|
||||
{
|
||||
while ($row = $db->fetch_array($result)) {
|
||||
$http = $row['http'];
|
||||
$ftp = $row['ftp_up'] + $row['ftp_down'];
|
||||
$mail = $row['mail'];
|
||||
$traf['byte'] = $http + $ftp + $mail;
|
||||
$traffic_complete['http']+= $http;
|
||||
$traffic_complete['ftp']+= $ftp;
|
||||
$traffic_complete['mail']+= $mail;
|
||||
$traf['day'] = $row['day'] . ".";
|
||||
$traffic_complete['http'] += $http;
|
||||
$traffic_complete['ftp'] += $ftp;
|
||||
$traffic_complete['mail'] += $mail;
|
||||
$traf['day'] = $row['day'] . '.';
|
||||
|
||||
if(extension_loaded('bcmath'))
|
||||
{
|
||||
if (extension_loaded('bcmath')) {
|
||||
$traf['ftptext'] = bcdiv($row['ftp_up'], 1024, $settings['panel']['decimal_places']) . " MB up/ " . bcdiv($row['ftp_down'], 1024, $settings['panel']['decimal_places']) . " MB down (FTP)";
|
||||
$traf['httptext'] = bcdiv($http, 1024, $settings['panel']['decimal_places']) . " MB (HTTP)";
|
||||
$traf['mailtext'] = bcdiv($mail, 1024, $settings['panel']['decimal_places']) . " MB (Mail)";
|
||||
@@ -102,9 +92,7 @@ if(!is_null($month)
|
||||
$traf['http'] = bcdiv($http, 1024, $settings['panel']['decimal_places']);
|
||||
$traf['mail'] = bcdiv($mail, 1024, $settings['panel']['decimal_places']);
|
||||
$traf['byte'] = bcdiv($traf['byte'], 1024, $settings['panel']['decimal_places']);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$traf['ftptext'] = round($row['ftp_up'] / 1024, $settings['panel']['decimal_places']) . " MB up/ " . round($row['ftp_down'] / 1024, $settings['panel']['decimal_places']) . " MB down (FTP)";
|
||||
$traf['httptext'] = round($http / 1024, $settings['panel']['decimal_places']) . " MB (HTTP)";
|
||||
$traf['mailtext'] = round($mail / 1024, $settings['panel']['decimal_places']) . " MB (Mail)";
|
||||
@@ -114,28 +102,22 @@ if(!is_null($month)
|
||||
$traf['byte'] = round($traf['byte'] / 1024, $settings['panel']['decimal_places']);
|
||||
}
|
||||
|
||||
eval("\$traffic.=\"" . getTemplate("traffic/traffic_month") . "\";");
|
||||
$show = $lng['traffic']['months'][intval($row['month'])] . " " . $row['year'];
|
||||
eval("\$traffic.=\"" . getTemplate('traffic/traffic_month') . "\";");
|
||||
$show = $lng['traffic']['months'][intval($row['month'])] . ' ' . $row['year'];
|
||||
}
|
||||
|
||||
if(extension_loaded('bcmath'))
|
||||
{
|
||||
if (extension_loaded('bcmath')) {
|
||||
$traffic_complete['http'] = bcdiv($traffic_complete['http'], 1024, $settings['panel']['decimal_places']);
|
||||
$traffic_complete['ftp'] = bcdiv($traffic_complete['ftp'], 1024, $settings['panel']['decimal_places']);
|
||||
$traffic_complete['mail'] = bcdiv($traffic_complete['mail'], 1024, $settings['panel']['decimal_places']);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$traffic_complete['http'] = round($traffic_complete['http'] / 1024, $settings['panel']['decimal_places']);
|
||||
$traffic_complete['ftp'] = round($traffic_complete['ftp'] / 1024, $settings['panel']['decimal_places']);
|
||||
$traffic_complete['mail'] = round($traffic_complete['mail'] / 1024, $settings['panel']['decimal_places']);
|
||||
}
|
||||
|
||||
eval("echo \"" . getTemplate("traffic/traffic_details") . "\";");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
eval("echo \"" . getTemplate('traffic/traffic_details') . "\";");
|
||||
} else {
|
||||
$result = $db->query("SELECT `month`, `year`, SUM(`http`) AS http, SUM(`ftp_up`) AS ftp_up, SUM(`ftp_down`) AS ftp_down, SUM(`mail`) AS mail
|
||||
FROM `" . TABLE_PANEL_TRAFFIC . "` WHERE `customerid` = '" . $userinfo['customerid'] . "'
|
||||
GROUP BY CONCAT(`year`,`month`) ORDER BY CONCAT(`year`,`month`) DESC LIMIT 12");
|
||||
@@ -143,22 +125,20 @@ else
|
||||
$traffic_complete['ftp'] = 0;
|
||||
$traffic_complete['mail'] = 0;
|
||||
|
||||
while($row = $db->fetch_array($result))
|
||||
{
|
||||
while ($row = $db->fetch_array($result)) {
|
||||
$http = $row['http'];
|
||||
$ftp_up = $row['ftp_up'];
|
||||
$ftp_down = $row['ftp_down'];
|
||||
$mail = $row['mail'];
|
||||
$traffic_complete['http']+= $http;
|
||||
$traffic_complete['ftp']+= $ftp_up + $ftp_down;
|
||||
$traffic_complete['mail']+= $mail;
|
||||
$traffic_complete['http'] += $http;
|
||||
$traffic_complete['ftp'] += $ftp_up + $ftp_down;
|
||||
$traffic_complete['mail'] += $mail;
|
||||
$traf['month'] = $row['month'];
|
||||
$traf['year'] = $row['year'];
|
||||
$traf['monthname'] = $lng['traffic']['months'][intval($row['month'])] . " " . $row['year'];
|
||||
$traf['byte'] = $http + $ftp_up + $ftp_down + $mail;
|
||||
|
||||
if(extension_loaded('bcmath'))
|
||||
{
|
||||
if (extension_loaded('bcmath')) {
|
||||
$traf['ftptext'] = bcdiv($ftp_up, 1024, $settings['panel']['decimal_places']) . " MB up/ " . bcdiv($ftp_down, 1024, $settings['panel']['decimal_places']) . " MB down (FTP)";
|
||||
$traf['httptext'] = bcdiv($http, 1024, $settings['panel']['decimal_places']) . " MB (HTTP)";
|
||||
$traf['mailtext'] = bcdiv($mail, 1024, $settings['panel']['decimal_places']) . " MB (Mail)";
|
||||
@@ -166,9 +146,7 @@ else
|
||||
$traf['http'] = bcdiv($http, 1024, $settings['panel']['decimal_places']);
|
||||
$traf['mail'] = bcdiv($mail, 1024, $settings['panel']['decimal_places']);
|
||||
$traf['byte'] = bcdiv($traf['byte'], 1024 * 1024, $settings['panel']['decimal_places']);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$traf['ftptext'] = round($ftp_up / 1024, $settings['panel']['decimal_places']) . " MB up/ " . round($ftp_down / 1024, $settings['panel']['decimal_places']) . " MB down (FTP)";
|
||||
$traf['httptext'] = round($http / 1024, $settings['panel']['decimal_places']) . " MB (HTTP)";
|
||||
$traf['mailtext'] = round($mail / 1024, $settings['panel']['decimal_places']) . " MB (Mail)";
|
||||
@@ -178,23 +156,18 @@ else
|
||||
$traf['byte'] = round($traf['byte'] / (1024 * 1024), $settings['panel']['decimal_places']);
|
||||
}
|
||||
|
||||
eval("\$traffic.=\"" . getTemplate("traffic/traffic_traffic") . "\";");
|
||||
eval("\$traffic.=\"" . getTemplate('traffic/traffic_traffic') . "\";");
|
||||
}
|
||||
|
||||
if(extension_loaded('bcmath'))
|
||||
{
|
||||
if (extension_loaded('bcmath')) {
|
||||
$traffic_complete['http'] = bcdiv($traffic_complete['http'], 1024 * 1024, $settings['panel']['decimal_places']);
|
||||
$traffic_complete['ftp'] = bcdiv($traffic_complete['ftp'], 1024 * 1024, $settings['panel']['decimal_places']);
|
||||
$traffic_complete['mail'] = bcdiv($traffic_complete['mail'], 1024 * 1024, $settings['panel']['decimal_places']);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$traffic_complete['http'] = round($traffic_complete['http'] / (1024 * 1024), $settings['panel']['decimal_places']);
|
||||
$traffic_complete['ftp'] = round($traffic_complete['ftp'] / (1024 * 1024), $settings['panel']['decimal_places']);
|
||||
$traffic_complete['mail'] = round($traffic_complete['mail'] / (1024 * 1024), $settings['panel']['decimal_places']);
|
||||
}
|
||||
|
||||
eval("echo \"" . getTemplate("traffic/traffic") . "\";");
|
||||
eval("echo \"" . getTemplate('traffic/traffic') . "\";");
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
246
index.php
246
index.php
@@ -22,106 +22,74 @@ define('AREA', 'login');
|
||||
/**
|
||||
* Include our init.php, which manages Sessions, Language etc.
|
||||
*/
|
||||
require ('./lib/init.php');
|
||||
|
||||
require ("./lib/init.php");
|
||||
|
||||
if($action == '')
|
||||
{
|
||||
if ($action == '') {
|
||||
$action = 'login';
|
||||
}
|
||||
|
||||
if($action == 'login')
|
||||
{
|
||||
if(isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send')
|
||||
{
|
||||
if ($action == 'login') {
|
||||
if (isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send'
|
||||
) {
|
||||
$loginname = validate($_POST['loginname'], 'loginname');
|
||||
$password = validate($_POST['password'], 'password');
|
||||
|
||||
$row = $db->query_first("SELECT `loginname` AS `customer` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `loginname`='" . $db->escape($loginname) . "'");
|
||||
|
||||
if($row['customer'] == $loginname)
|
||||
{
|
||||
if ($row['customer'] == $loginname) {
|
||||
$table = "`" . TABLE_PANEL_CUSTOMERS . "`";
|
||||
$uid = 'customerid';
|
||||
$adminsession = '0';
|
||||
$is_admin = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((int)$settings['login']['domain_login'] == 1)
|
||||
{
|
||||
} else {
|
||||
$is_admin = true;
|
||||
if ((int)$settings['login']['domain_login'] == 1) {
|
||||
/**
|
||||
* check if the customer tries to login with a domain, #374
|
||||
*/
|
||||
$domainname = $idna_convert->encode(preg_replace(Array('/\:(\d)+$/', '/^https?\:\/\//'), '', $loginname));
|
||||
$row2 = $db->query_first("SELECT `customerid` FROM `".TABLE_PANEL_DOMAINS."` WHERE `domain` = '".$db->escape($domainname)."'");
|
||||
|
||||
if(isset($row2['customerid']) && $row2['customerid'] > 0)
|
||||
{
|
||||
if (isset($row2['customerid']) && $row2['customerid'] > 0) {
|
||||
$loginname = getCustomerDetail($row2['customerid'], 'loginname');
|
||||
|
||||
if($loginname !== false)
|
||||
{
|
||||
if ($loginname !== false) {
|
||||
$row3 = $db->query_first("SELECT `loginname` AS `customer` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `loginname`='" . $db->escape($loginname) . "'");
|
||||
|
||||
if($row3['customer'] == $loginname)
|
||||
{
|
||||
if ($row3['customer'] == $loginname) {
|
||||
$table = "`" . TABLE_PANEL_CUSTOMERS . "`";
|
||||
$uid = 'customerid';
|
||||
$adminsession = '0';
|
||||
$is_admin = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$is_admin = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$is_admin = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$is_admin = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(hasUpdates($version) && $is_admin == false)
|
||||
{
|
||||
if (hasUpdates($version) && $is_admin == false) {
|
||||
redirectTo('index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if($is_admin)
|
||||
{
|
||||
if(hasUpdates($version))
|
||||
{
|
||||
if ($is_admin) {
|
||||
if (hasUpdates($version)) {
|
||||
$row = $db->query_first("SELECT `loginname` AS `admin` FROM `" . TABLE_PANEL_ADMINS . "` WHERE `loginname`='" . $db->escape($loginname) . "' AND `change_serversettings` = '1'");
|
||||
/*
|
||||
* not an admin who can see updates
|
||||
*/
|
||||
if(!isset($row['admin']))
|
||||
{
|
||||
if (!isset($row['admin'])) {
|
||||
redirectTo('index.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$row = $db->query_first("SELECT `loginname` AS `admin` FROM `" . TABLE_PANEL_ADMINS . "` WHERE `loginname`='" . $db->escape($loginname) . "'");
|
||||
}
|
||||
|
||||
if($row['admin'] == $loginname)
|
||||
{
|
||||
if ($row['admin'] == $loginname) {
|
||||
$table = "`" . TABLE_PANEL_ADMINS . "`";
|
||||
$uid = 'adminid';
|
||||
$adminsession = '1';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
redirectTo('index.php', Array('showmessage' => '2'), true);
|
||||
exit;
|
||||
}
|
||||
@@ -129,64 +97,48 @@ if($action == 'login')
|
||||
|
||||
$userinfo = $db->query_first("SELECT * FROM $table WHERE `loginname`='" . $db->escape($loginname) . "'");
|
||||
|
||||
if($userinfo['loginfail_count'] >= $settings['login']['maxloginattempts']
|
||||
&& $userinfo['lastlogin_fail'] > (time() - $settings['login']['deactivatetime']))
|
||||
{
|
||||
if ($userinfo['loginfail_count'] >= $settings['login']['maxloginattempts']
|
||||
&& $userinfo['lastlogin_fail'] > (time() - $settings['login']['deactivatetime'])
|
||||
) {
|
||||
redirectTo('index.php', Array('showmessage' => '3'), true);
|
||||
exit;
|
||||
}
|
||||
elseif($userinfo['password'] == md5($password))
|
||||
{
|
||||
} elseif($userinfo['password'] == md5($password)) {
|
||||
// login correct
|
||||
// reset loginfail_counter, set lastlogin_succ
|
||||
|
||||
$db->query("UPDATE $table SET `lastlogin_succ`='" . time() . "', `loginfail_count`='0' WHERE `$uid`='" . (int)$userinfo[$uid] . "'");
|
||||
$userinfo['userid'] = $userinfo[$uid];
|
||||
$userinfo['adminsession'] = $adminsession;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// login incorrect
|
||||
|
||||
$db->query("UPDATE $table SET `lastlogin_fail`='" . time() . "', `loginfail_count`=`loginfail_count`+1 WHERE `$uid`='" . (int)$userinfo[$uid] . "'");
|
||||
unset($userinfo);
|
||||
redirectTo('index.php', Array('showmessage' => '2'), true);
|
||||
exit;
|
||||
}
|
||||
|
||||
if(isset($userinfo['userid'])
|
||||
&& $userinfo['userid'] != '')
|
||||
{
|
||||
if (isset($userinfo['userid'])
|
||||
&& $userinfo['userid'] != ''
|
||||
) {
|
||||
$s = md5(uniqid(microtime(), 1));
|
||||
|
||||
if(isset($_POST['language']))
|
||||
{
|
||||
if (isset($_POST['language'])) {
|
||||
$language = validate($_POST['language'], 'language');
|
||||
|
||||
if($language == 'profile')
|
||||
{
|
||||
if ($language == 'profile') {
|
||||
$language = $userinfo['def_language'];
|
||||
}
|
||||
elseif(!isset($languages[$language]))
|
||||
{
|
||||
} elseif(!isset($languages[$language])) {
|
||||
$language = $settings['panel']['standardlanguage'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$language = $settings['panel']['standardlanguage'];
|
||||
}
|
||||
|
||||
if(isset($userinfo['theme']) && $userinfo['theme'] != '') {
|
||||
if (isset($userinfo['theme']) && $userinfo['theme'] != '') {
|
||||
$theme = $userinfo['theme'];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$theme = $settings['panel']['default_theme'];
|
||||
}
|
||||
|
||||
if($settings['session']['allow_multiple_login'] != '1')
|
||||
{
|
||||
if ($settings['session']['allow_multiple_login'] != '1') {
|
||||
$db->query("DELETE FROM `" . TABLE_PANEL_SESSIONS . "` WHERE `userid` = '" . (int)$userinfo['userid'] . "' AND `adminsession` = '" . $db->escape($userinfo['adminsession']) . "'");
|
||||
}
|
||||
|
||||
@@ -195,56 +147,41 @@ if($action == 'login')
|
||||
$columns = mysql_num_fields($fields);
|
||||
$field_array = array();
|
||||
for ($i = 0; $i < $columns; $i++) {
|
||||
$field_array[] = mysql_field_name($fields, $i);
|
||||
$field_array[] = mysql_field_name($fields, $i);
|
||||
}
|
||||
|
||||
if (!in_array('theme', $field_array)) {
|
||||
if (!in_array('theme', $field_array)) {
|
||||
$db->query("INSERT INTO `" . TABLE_PANEL_SESSIONS . "` (`hash`, `userid`, `ipaddress`, `useragent`, `lastactivity`, `language`, `adminsession`) VALUES ('" . $db->escape($s) . "', '" . (int)$userinfo['userid'] . "', '" . $db->escape($remote_addr) . "', '" . $db->escape($http_user_agent) . "', '" . time() . "', '" . $db->escape($language) . "', '" . $db->escape($userinfo['adminsession']) . "')");
|
||||
} else {
|
||||
$db->query("INSERT INTO `" . TABLE_PANEL_SESSIONS . "` (`hash`, `userid`, `ipaddress`, `useragent`, `lastactivity`, `language`, `adminsession`, `theme`) VALUES ('" . $db->escape($s) . "', '" . (int)$userinfo['userid'] . "', '" . $db->escape($remote_addr) . "', '" . $db->escape($http_user_agent) . "', '" . time() . "', '" . $db->escape($language) . "', '" . $db->escape($userinfo['adminsession']) . "', '" . $db->escape($theme) . "')");
|
||||
}
|
||||
} else {
|
||||
$db->query("INSERT INTO `" . TABLE_PANEL_SESSIONS . "` (`hash`, `userid`, `ipaddress`, `useragent`, `lastactivity`, `language`, `adminsession`, `theme`) VALUES ('" . $db->escape($s) . "', '" . (int)$userinfo['userid'] . "', '" . $db->escape($remote_addr) . "', '" . $db->escape($http_user_agent) . "', '" . time() . "', '" . $db->escape($language) . "', '" . $db->escape($userinfo['adminsession']) . "', '" . $db->escape($theme) . "')");
|
||||
}
|
||||
|
||||
if($userinfo['adminsession'] == '1')
|
||||
{
|
||||
if(hasUpdates($version))
|
||||
{
|
||||
if ($userinfo['adminsession'] == '1') {
|
||||
if (hasUpdates($version)) {
|
||||
redirectTo('admin_updates.php', Array('s' => $s), true);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
redirectTo('admin_index.php', Array('s' => $s), true);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
redirectTo('customer_index.php', Array('s' => $s), true);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
redirectTo('index.php', Array('showmessage' => '2'), true);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
exit;
|
||||
} else {
|
||||
$language_options = '';
|
||||
$language_options.= makeoption($lng['login']['profile_lng'], 'profile', 'profile', true, true);
|
||||
$language_options .= makeoption($lng['login']['profile_lng'], 'profile', 'profile', true, true);
|
||||
|
||||
while(list($language_file, $language_name) = each($languages))
|
||||
{
|
||||
$language_options.= makeoption($language_name, $language_file, 'profile', true);
|
||||
while (list($language_file, $language_name) = each($languages)) {
|
||||
$language_options .= makeoption($language_name, $language_file, 'profile', true);
|
||||
}
|
||||
|
||||
$smessage = isset($_GET['showmessage']) ? (int)$_GET['showmessage'] : 0;
|
||||
$message = '';
|
||||
$successmessage = '';
|
||||
|
||||
switch($smessage)
|
||||
{
|
||||
switch ($smessage) {
|
||||
case 1:
|
||||
$successmessage = $lng['pwdreminder']['success'];
|
||||
break;
|
||||
@@ -264,23 +201,21 @@ if($action == 'login')
|
||||
}
|
||||
|
||||
$update_in_progress = '';
|
||||
if(hasUpdates($version))
|
||||
{
|
||||
if (hasUpdates($version)) {
|
||||
$update_in_progress = $lng['update']['updateinprogress_onlyadmincanlogin'];
|
||||
}
|
||||
|
||||
eval("echo \"" . getTemplate("login") . "\";");
|
||||
eval("echo \"" . getTemplate('login') . "\";");
|
||||
}
|
||||
}
|
||||
|
||||
if($action == 'forgotpwd')
|
||||
{
|
||||
if ($action == 'forgotpwd') {
|
||||
$adminchecked = false;
|
||||
$message = '';
|
||||
|
||||
if(isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send')
|
||||
{
|
||||
if (isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send'
|
||||
) {
|
||||
$loginname = validate($_POST['loginname'], 'loginname');
|
||||
$email = validateEmail($_POST['loginemail'], 'email');
|
||||
$sql = "SELECT `adminid`, `customerid`, `firstname`, `name`, `company`, `email`, `loginname`, `def_language`, `deactivated` FROM `" . TABLE_PANEL_CUSTOMERS . "`
|
||||
@@ -288,64 +223,48 @@ if($action == 'forgotpwd')
|
||||
AND `email`='" . $db->escape($email) . "'";
|
||||
$result = $db->query($sql);
|
||||
|
||||
if($db->num_rows() == 0)
|
||||
{
|
||||
if ($db->num_rows() == 0) {
|
||||
$sql = "SELECT `adminid`, `name`, `email`, `loginname`, `def_language` FROM `" . TABLE_PANEL_ADMINS . "`
|
||||
WHERE `loginname`='" . $db->escape($loginname) . "'
|
||||
AND `email`='" . $db->escape($email) . "'";
|
||||
$result = $db->query($sql);
|
||||
|
||||
if($db->num_rows() > 0)
|
||||
{
|
||||
if ($db->num_rows() > 0) {
|
||||
$adminchecked = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$result = null;
|
||||
}
|
||||
}
|
||||
|
||||
if($result !== null)
|
||||
{
|
||||
if ($result !== null) {
|
||||
$user = $db->fetch_array($result);
|
||||
|
||||
/* Check whether user is banned */
|
||||
if($user['deactivated'])
|
||||
{
|
||||
if ($user['deactivated']) {
|
||||
$message = $lng['pwdreminder']['notallowed'];
|
||||
redirectTo('index.php', Array('showmessage' => '5'), true);
|
||||
}
|
||||
|
||||
if(($adminchecked && $settings['panel']['allow_preset_admin'] == '1')
|
||||
|| $adminchecked == false)
|
||||
{
|
||||
if($user !== false)
|
||||
{
|
||||
if (($adminchecked && $settings['panel']['allow_preset_admin'] == '1')
|
||||
|| $adminchecked == false
|
||||
) {
|
||||
if ($user !== false) {
|
||||
if ($settings['panel']['password_min_length'] <= 6) {
|
||||
$password = substr(md5(uniqid(microtime(), 1)), 12, 6);
|
||||
} else {
|
||||
// make it two times larger than password_min_length
|
||||
$rnd = '';
|
||||
$minlength = $settings['panel']['password_min_length'];
|
||||
while (strlen($rnd) < ($minlength * 2))
|
||||
{
|
||||
while (strlen($rnd) < ($minlength * 2)) {
|
||||
$rnd .= md5(uniqid(microtime(), 1));
|
||||
}
|
||||
$password = substr($rnd, (int)($minlength / 2), $minlength);
|
||||
}
|
||||
|
||||
if($adminchecked)
|
||||
{
|
||||
$db->query("UPDATE `" . TABLE_PANEL_ADMINS . "` SET `password`='" . md5($password) . "'
|
||||
WHERE `loginname`='" . $user['loginname'] . "'
|
||||
AND `email`='" . $user['email'] . "'");
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `password`='" . md5($password) . "'
|
||||
WHERE `loginname`='" . $user['loginname'] . "'
|
||||
AND `email`='" . $user['email'] . "'");
|
||||
}
|
||||
$passwordTable = $adminchecked ? TABLE_PANEL_ADMINS : TABLE_PANEL_CUSTOMERS;
|
||||
$db->query("UPDATE `" . $passwordTable . "` SET `password`='" . md5($password) . "'
|
||||
WHERE `loginname`='" . $user['loginname'] . "'
|
||||
AND `email`='" . $user['email'] . "'");
|
||||
|
||||
$rstlog = FroxlorLogger::getInstanceOf(array('loginname' => 'password_reset'), $db, $settings);
|
||||
$rstlog->logAction(USR_ACTION, LOG_WARNING, "Password for user '" . $user['loginname'] . "' has been reset!");
|
||||
@@ -389,9 +308,7 @@ if($action == 'forgotpwd')
|
||||
$mail->ClearAddresses();
|
||||
redirectTo('index.php', Array('showmessage' => '1'), true);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$rstlog = FroxlorLogger::getInstanceOf(array('loginname' => 'password_reset'), $db, $settings);
|
||||
$rstlog->logAction(USR_ACTION, LOG_WARNING, "User '" . $loginname . "' tried to reset pwd but wasn't found in database!");
|
||||
$message = $lng['login']['combination_not_found'];
|
||||
@@ -399,28 +316,21 @@ if($action == 'forgotpwd')
|
||||
|
||||
unset($user);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$message = $lng['login']['usernotfound'];
|
||||
}
|
||||
}
|
||||
|
||||
if($adminchecked)
|
||||
{
|
||||
if($settings['panel']['allow_preset_admin'] != '1')
|
||||
{
|
||||
if ($adminchecked) {
|
||||
if ($settings['panel']['allow_preset_admin'] != '1') {
|
||||
$message = $lng['pwdreminder']['notallowed'];
|
||||
unset ($adminchecked);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($settings['panel']['allow_preset'] != '1')
|
||||
{
|
||||
} else {
|
||||
if ($settings['panel']['allow_preset'] != '1') {
|
||||
$message = $lng['pwdreminder']['notallowed'];
|
||||
}
|
||||
}
|
||||
|
||||
eval("echo \"" . getTemplate("fpwd") . "\";");
|
||||
eval("echo \"" . getTemplate('fpwd') . "\";");
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -68,8 +68,7 @@ class lighttpd
|
||||
|
||||
public function reload()
|
||||
{
|
||||
if((int)$this->settings['phpfpm']['enabled'] == 1)
|
||||
{
|
||||
if ((int)$this->settings['phpfpm']['enabled'] == 1) {
|
||||
fwrite($this->debugHandler, ' lighttpd::reload: reloading php-fpm' . "\n");
|
||||
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading php-fpm');
|
||||
safe_exec(escapeshellcmd($this->settings['phpfpm']['reload']));
|
||||
@@ -84,16 +83,12 @@ class lighttpd
|
||||
$query = "SELECT * FROM `" . TABLE_PANEL_IPSANDPORTS . "` ORDER BY `ip` ASC, `port` ASC";
|
||||
$result_ipsandports = $this->db->query($query);
|
||||
|
||||
while($row_ipsandports = $this->db->fetch_array($result_ipsandports))
|
||||
{
|
||||
if(filter_var($row_ipsandports['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6))
|
||||
{
|
||||
while ($row_ipsandports = $this->db->fetch_array($result_ipsandports)) {
|
||||
if (filter_var($row_ipsandports['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
|
||||
$ip = '[' . $row_ipsandports['ip'] . ']';
|
||||
$port = $row_ipsandports['port'];
|
||||
$ipv6 = 'server.use-ipv6 = "enable"'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$ip = $row_ipsandports['ip'];
|
||||
$port = $row_ipsandports['port'];
|
||||
$ipv6 = '';
|
||||
@@ -103,39 +98,30 @@ class lighttpd
|
||||
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'creating ip/port settings for ' . $ip . ":" . $port);
|
||||
$vhost_filename = makeCorrectFile($this->settings['system']['apacheconf_vhost'] . '/10_froxlor_ipandport_' . trim(str_replace(':', '.', $row_ipsandports['ip']), '.') . '.' . $row_ipsandports['port'] . '.conf');
|
||||
|
||||
if(!isset($this->lighttpd_data[$vhost_filename]))
|
||||
{
|
||||
if (!isset($this->lighttpd_data[$vhost_filename])) {
|
||||
$this->lighttpd_data[$vhost_filename] = '';
|
||||
}
|
||||
|
||||
$this->lighttpd_data[$vhost_filename].= '$SERVER["socket"] == "' . $ip . ':' . $port . '" {' . "\n";
|
||||
|
||||
if($row_ipsandports['listen_statement'] == '1')
|
||||
{
|
||||
if ($row_ipsandports['listen_statement'] == '1') {
|
||||
$this->lighttpd_data[$vhost_filename].= 'server.port = ' . $port . "\n";
|
||||
$this->lighttpd_data[$vhost_filename].= 'server.bind = "' . $ip . '"' . "\n";
|
||||
$this->lighttpd_data[$vhost_filename].= $ipv6;
|
||||
}
|
||||
|
||||
if($row_ipsandports['vhostcontainer'] == '1')
|
||||
{
|
||||
|
||||
if ($row_ipsandports['vhostcontainer'] == '1') {
|
||||
$myhost = str_replace('.', '\.', $this->settings['system']['hostname']);
|
||||
$this->lighttpd_data[$vhost_filename].= '# Froxlor default vhost' . "\n";
|
||||
$this->lighttpd_data[$vhost_filename].= '$HTTP["host"] =~ "^(?:www\.|)' . $myhost . '$" {' . "\n";
|
||||
|
||||
if($row_ipsandports['docroot'] == '')
|
||||
{
|
||||
if($this->settings['system']['froxlordirectlyviahostname'])
|
||||
{
|
||||
if ($row_ipsandports['docroot'] == '') {
|
||||
if ($this->settings['system']['froxlordirectlyviahostname']) {
|
||||
$mypath = makeCorrectDir(dirname(dirname(dirname(__FILE__))));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$mypath = makeCorrectDir(dirname(dirname(dirname(dirname(__FILE__)))));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// user-defined docroot, #417
|
||||
$mypath = makeCorrectDir($row_ipsandports['docroot']);
|
||||
}
|
||||
@@ -154,8 +140,7 @@ class lighttpd
|
||||
/**
|
||||
* own php-fpm vhost
|
||||
*/
|
||||
if((int)$this->settings['phpfpm']['enabled'] == 1)
|
||||
{
|
||||
if ((int)$this->settings['phpfpm']['enabled'] == 1) {
|
||||
$domain = array(
|
||||
'id' => 'none',
|
||||
'domain' => $this->settings['system']['hostname'],
|
||||
@@ -182,33 +167,27 @@ class lighttpd
|
||||
$this->lighttpd_data[$vhost_filename].= ' )'."\n";
|
||||
}
|
||||
|
||||
if($row_ipsandports['specialsettings'] != '')
|
||||
{
|
||||
if ($row_ipsandports['specialsettings'] != '') {
|
||||
$this->lighttpd_data[$vhost_filename].= $row_ipsandports['specialsettings'] . "\n";
|
||||
}
|
||||
|
||||
$this->lighttpd_data[$vhost_filename].= '}' . "\n";
|
||||
}
|
||||
|
||||
if($row_ipsandports['ssl'] == '1')
|
||||
{
|
||||
if($row_ipsandports['ssl_cert_file'] == '')
|
||||
{
|
||||
if ($row_ipsandports['ssl'] == '1') {
|
||||
if ($row_ipsandports['ssl_cert_file'] == '') {
|
||||
$row_ipsandports['ssl_cert_file'] = $this->settings['system']['ssl_cert_file'];
|
||||
}
|
||||
|
||||
if($row_ipsandports['ssl_ca_file'] == '')
|
||||
{
|
||||
if ($row_ipsandports['ssl_ca_file'] == '') {
|
||||
$row_ipsandports['ssl_ca_file'] = $this->settings['system']['ssl_ca_file'];
|
||||
}
|
||||
|
||||
if($row_ipsandports['ssl_cert_file'] != '')
|
||||
{
|
||||
if ($row_ipsandports['ssl_cert_file'] != '') {
|
||||
$this->lighttpd_data[$vhost_filename].= 'ssl.engine = "enable"' . "\n";
|
||||
$this->lighttpd_data[$vhost_filename].= 'ssl.pemfile = "' . makeCorrectFile($row_ipsandports['ssl_cert_file']) . '"' . "\n";
|
||||
|
||||
if($row_ipsandports['ssl_ca_file'] != '')
|
||||
{
|
||||
|
||||
if ($row_ipsandports['ssl_ca_file'] != '') {
|
||||
$this->lighttpd_data[$vhost_filename].= 'ssl.ca-file = "' . makeCorrectFile($row_ipsandports['ssl_ca_file']) . '"' . "\n";
|
||||
}
|
||||
}
|
||||
@@ -220,12 +199,11 @@ class lighttpd
|
||||
* refs #70
|
||||
*/
|
||||
$vhosts = $this->createLighttpdHosts($row_ipsandports['ip'], $row_ipsandports['port'], $row_ipsandports['ssl'], $vhost_filename);
|
||||
if($vhosts !== null && is_array($vhosts) && isset($vhosts[0]))
|
||||
{
|
||||
if ($vhosts !== null && is_array($vhosts) && isset($vhosts[0])) {
|
||||
// sort vhosts by number (subdomains first!)
|
||||
sort($vhosts);
|
||||
|
||||
foreach($vhosts as $vhost) {
|
||||
foreach ($vhosts as $vhost) {
|
||||
$this->lighttpd_data[$vhost_filename].= ' include "'.$vhost.'"'."\n";
|
||||
}
|
||||
}
|
||||
@@ -244,13 +222,12 @@ class lighttpd
|
||||
*/
|
||||
private function _createStandardErrorHandler()
|
||||
{
|
||||
if($this->settings['defaultwebsrverrhandler']['enabled'] == '1'
|
||||
if ($this->settings['defaultwebsrverrhandler']['enabled'] == '1'
|
||||
&& $this->settings['defaultwebsrverrhandler']['err404'] != ''
|
||||
) {
|
||||
$vhost_filename = makeCorrectFile($this->settings['system']['apacheconf_vhost'] . '/05_froxlor_default_errorhandler.conf');
|
||||
|
||||
if(!isset($this->lighttpd_data[$vhost_filename]))
|
||||
{
|
||||
if (!isset($this->lighttpd_data[$vhost_filename])) {
|
||||
$this->lighttpd_data[$vhost_filename] = '';
|
||||
}
|
||||
|
||||
@@ -269,21 +246,18 @@ class lighttpd
|
||||
$result_htpasswds = $this->db->query($htpasswd_query);
|
||||
|
||||
$htaccess_text = '';
|
||||
while($row_htpasswds = $this->db->fetch_array($result_htpasswds))
|
||||
{
|
||||
while ($row_htpasswds = $this->db->fetch_array($result_htpasswds)) {
|
||||
$row_htpasswds['path'] = makeCorrectDir($row_htpasswds['path']);
|
||||
mkDirWithCorrectOwnership($domain['documentroot'], $row_htpasswds['path'], $domain['guid'], $domain['guid']);
|
||||
|
||||
$filename = $row_htpasswds['customerid'] . '-' . md5($row_htpasswds['path']) . '.htpasswd';
|
||||
|
||||
if(!in_array($row_htpasswds['path'], $needed_htpasswds))
|
||||
{
|
||||
if(!isset($this->needed_htpasswds[$filename])) {
|
||||
if (!in_array($row_htpasswds['path'], $needed_htpasswds)) {
|
||||
if (!isset($this->needed_htpasswds[$filename])) {
|
||||
$this->needed_htpasswds[$filename] = '';
|
||||
}
|
||||
|
||||
if(!strstr($this->needed_htpasswds[$filename], $row_htpasswds['username'] . ':' . $row_htpasswds['password']))
|
||||
{
|
||||
if (!strstr($this->needed_htpasswds[$filename], $row_htpasswds['username'] . ':' . $row_htpasswds['password'])) {
|
||||
$this->needed_htpasswds[$filename].= $row_htpasswds['username'] . ':' . $row_htpasswds['password'] . "\n";
|
||||
}
|
||||
|
||||
@@ -331,22 +305,16 @@ class lighttpd
|
||||
$query = "SELECT * FROM " . TABLE_PANEL_IPSANDPORTS . " WHERE `ip`='" . $ip . "' AND `port`='" . $port . "'";
|
||||
$ipandport = $this->db->query_first($query);
|
||||
|
||||
if($ssl == '0')
|
||||
{
|
||||
if ($ssl == '0') {
|
||||
$query2 = "SELECT `d`.*, `pd`.`domain` AS `parentdomain`, `c`.`loginname`, `c`.`guid`, `c`.`email`, `c`.`documentroot` AS `customerroot`, `c`.`deactivated`, `c`.`phpenabled` AS `phpenabled` FROM `" . TABLE_PANEL_DOMAINS . "` `d` LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`) LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `pd` ON (`pd`.`id` = `d`.`parentdomainid`) WHERE `d`.`ipandport`='" . $ipandport['id'] . "' AND `d`.`aliasdomain` IS NULL AND `d`.`email_only` <> 1 ORDER BY `d`.`parentdomainid` DESC, `d`.`iswildcarddomain`, `d`.`domain` ASC";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$query2 = "SELECT `d`.*, `pd`.`domain` AS `parentdomain`, `c`.`loginname`, `c`.`guid`, `c`.`email`, `c`.`documentroot` AS `customerroot`, `c`.`deactivated`, `c`.`phpenabled` AS `phpenabled` FROM `" . TABLE_PANEL_DOMAINS . "` `d` LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`) LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `pd` ON (`pd`.`id` = `d`.`parentdomainid`) WHERE `d`.`ssl_ipandport`='" . $ipandport['id'] . "' AND `d`.`aliasdomain` IS NULL AND `d`.`email_only` <> 1 ORDER BY `d`.`parentdomainid` DESC, `d`.`iswildcarddomain`, `d`.`domain` ASC";
|
||||
}
|
||||
|
||||
$included_vhosts = array();
|
||||
$result_domains = $this->db->query($query2);
|
||||
while($domain = $this->db->fetch_array($result_domains))
|
||||
{
|
||||
|
||||
if (is_dir($this->settings['system']['apacheconf_vhost']))
|
||||
{
|
||||
while ($domain = $this->db->fetch_array($result_domains)) {
|
||||
if (is_dir($this->settings['system']['apacheconf_vhost'])) {
|
||||
safe_exec('mkdir -p '.escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'].'/vhosts/')));
|
||||
|
||||
// determine correct include-path:
|
||||
@@ -392,13 +360,10 @@ class lighttpd
|
||||
&& !is_dir($this->settings['system']['apacheconf_vhost']))
|
||||
|| is_dir($this->settings['system']['apacheconf_vhost'])
|
||||
) {
|
||||
if($ssl == '1')
|
||||
{
|
||||
if ($ssl == '1') {
|
||||
$ssl_vhost = true;
|
||||
$ips_and_ports_index = 'ssl_ipandport';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$ssl_vhost = false;
|
||||
$ips_and_ports_index = 'ipandport';
|
||||
}
|
||||
@@ -418,13 +383,11 @@ class lighttpd
|
||||
return '';
|
||||
}
|
||||
|
||||
if($ssl_vhost === true
|
||||
&& $domain['ssl'] == '1')
|
||||
{
|
||||
if ($ssl_vhost === true
|
||||
&& $domain['ssl'] == '1'
|
||||
) {
|
||||
$query = "SELECT * FROM " . TABLE_PANEL_IPSANDPORTS . " WHERE `id`='" . $domain['ssl_ipandport'] . "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$query = "SELECT * FROM " . TABLE_PANEL_IPSANDPORTS . " WHERE `id`='" . $domain['ipandport'] . "'";
|
||||
}
|
||||
|
||||
@@ -434,12 +397,9 @@ class lighttpd
|
||||
$domain['ssl_cert_file'] = $ipandport['ssl_cert_file'];
|
||||
$domain['ssl_ca_file'] = $ipandport['ssl_ca_file'];
|
||||
|
||||
if(filter_var($domain['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6))
|
||||
{
|
||||
if (filter_var($domain['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
|
||||
$ipport = '[' . $domain['ip'] . ']:' . $domain['port'];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$ipport = $domain['ip'] . ':' . $domain['port'];
|
||||
}
|
||||
|
||||
@@ -454,14 +414,11 @@ class lighttpd
|
||||
$domain['documentroot'] = 'https://' . $domain['domain'] . '/';
|
||||
}
|
||||
|
||||
if(preg_match('/^https?\:\/\//', $domain['documentroot']))
|
||||
{
|
||||
if (preg_match('/^https?\:\/\//', $domain['documentroot'])) {
|
||||
$vhost_content.= ' url.redirect = (' . "\n";
|
||||
$vhost_content.= ' "^/(.*)$" => "'. $this->idnaConvert->encode($domain['documentroot']) . '$1"'. "\n";
|
||||
$vhost_content.= ' )' . "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
mkDirWithCorrectOwnership($domain['customerroot'], $domain['documentroot'], $domain['guid'], $domain['guid'], true, true);
|
||||
|
||||
$only_webroot = false;
|
||||
@@ -508,23 +465,19 @@ class lighttpd
|
||||
&& $domain['ssl'] == '1'
|
||||
&& (int)$this->settings['system']['use_ssl'] == 1
|
||||
) {
|
||||
if($domain['ssl_cert_file'] == '')
|
||||
{
|
||||
if ($domain['ssl_cert_file'] == '') {
|
||||
$domain['ssl_cert_file'] = $this->settings['system']['ssl_cert_file'];
|
||||
}
|
||||
|
||||
if($domain['ssl_ca_file'] == '')
|
||||
{
|
||||
if ($domain['ssl_ca_file'] == '') {
|
||||
$domain['ssl_ca_file'] = $this->settings['system']['ssl_ca_file'];
|
||||
}
|
||||
|
||||
if($domain['ssl_cert_file'] != '')
|
||||
{
|
||||
if ($domain['ssl_cert_file'] != '') {
|
||||
$ssl_settings.= 'ssl.engine = "enable"' . "\n";
|
||||
$ssl_settings.= 'ssl.pemfile = "' . makeCorrectFile($domain['ssl_cert_file']) . '"' . "\n";
|
||||
|
||||
if($domain['ssl_ca_file'] != '')
|
||||
{
|
||||
|
||||
if ($domain['ssl_ca_file'] != '') {
|
||||
$ssl_settings.= 'ssl.ca-file = "' . makeCorrectFile($domain['ssl_ca_file']) . '"' . "\n";
|
||||
}
|
||||
}
|
||||
@@ -536,15 +489,13 @@ class lighttpd
|
||||
|
||||
$logfiles_text = '';
|
||||
|
||||
if($domain['speciallogfile'] == '1') {
|
||||
|
||||
$speciallogfile = '';
|
||||
if ($domain['speciallogfile'] == '1') {
|
||||
if ($domain['parentdomainid'] == '0') {
|
||||
$speciallogfile = '-' . $domain['domain'];
|
||||
} else {
|
||||
$speciallogfile = '-' . $domain['parentdomain'];
|
||||
}
|
||||
} else {
|
||||
$speciallogfile = '';
|
||||
}
|
||||
|
||||
// The normal access/error - logging is enabled
|
||||
@@ -622,10 +573,8 @@ class lighttpd
|
||||
$error_string.= ' server.error-handler-404 = "' . $defhandler . '"' . "\n\n";
|
||||
}
|
||||
|
||||
if($row['options_indexes'] != '0')
|
||||
{
|
||||
if(!empty($error_string))
|
||||
{
|
||||
if ($row['options_indexes'] != '0') {
|
||||
if (!empty($error_string)) {
|
||||
$path_options.= $error_string;
|
||||
// reset $error_string here to prevent duplicate entries
|
||||
$error_string = '';
|
||||
@@ -635,21 +584,19 @@ class lighttpd
|
||||
mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']);
|
||||
|
||||
// We need to remove the last slash, otherwise the regex wouldn't work
|
||||
if($row['path'] != $domain['documentroot']) {
|
||||
if ($row['path'] != $domain['documentroot']) {
|
||||
$path = substr($path, 0, -1);
|
||||
}
|
||||
$path_options.= ' $HTTP["url"] =~ "^' . $path . '($|/)" {' . "\n";
|
||||
$path_options.= "\t" . 'dir-listing.activate = "enable"' . "\n";
|
||||
$path_options.= ' }' . "\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$path_options = $error_string;
|
||||
}
|
||||
|
||||
if(customerHasPerlEnabled($domain['customerid'])
|
||||
&& $row['options_cgi'] != '0')
|
||||
{
|
||||
if (customerHasPerlEnabled($domain['customerid'])
|
||||
&& $row['options_cgi'] != '0'
|
||||
) {
|
||||
$path = makeCorrectDir(substr($row['path'], strlen($domain['documentroot']) - 1));
|
||||
mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']);
|
||||
|
||||
@@ -674,24 +621,20 @@ class lighttpd
|
||||
$query = "SELECT * FROM " . TABLE_PANEL_HTPASSWDS . " WHERE `customerid`='" . $domain['customerid'] . "'";
|
||||
$result = $this->db->query($query);
|
||||
|
||||
while($row_htpasswds = $this->db->fetch_array($result))
|
||||
{
|
||||
if($auth_backend_loaded[$domain['ipandport']] != 'yes'
|
||||
&& $auth_backend_loaded[$domain['ssl_ipandport']] != 'yes')
|
||||
{
|
||||
while ($row_htpasswds = $this->db->fetch_array($result)) {
|
||||
if ($auth_backend_loaded[$domain['ipandport']] != 'yes'
|
||||
&& $auth_backend_loaded[$domain['ssl_ipandport']] != 'yes'
|
||||
) {
|
||||
$filename = $domain['customerid'] . '.htpasswd';
|
||||
|
||||
if($this->auth_backend_loaded[$domain['ipandport']] != 'yes')
|
||||
{
|
||||
if ($this->auth_backend_loaded[$domain['ipandport']] != 'yes')
|
||||
$auth_backend_loaded[$domain['ipandport']] = 'yes';
|
||||
$diroption_text.= 'auth.backend = "htpasswd"' . "\n";
|
||||
$diroption_text.= 'auth.backend.htpasswd.userfile = "' . makeCorrectFile($this->settings['system']['apacheconf_htpasswddir'] . '/' . $filename) . '"' . "\n";
|
||||
$this->needed_htpasswds[$filename] = $row_htpasswds['username'] . ':' . $row_htpasswds['password'] . "\n";
|
||||
$diroption_text.= 'auth.require = ( ' . "\n";
|
||||
$previous_domain_id = '1';
|
||||
}
|
||||
elseif($this->auth_backend_loaded[$domain['ssl_ipandport']] != 'yes')
|
||||
{
|
||||
} elseif($this->auth_backend_loaded[$domain['ssl_ipandport']] != 'yes') {
|
||||
$auth_backend_loaded[$domain['ssl_ipandport']] = 'yes';
|
||||
$diroption_text.= 'auth.backend= "htpasswd"' . "\n";
|
||||
$diroption_text.= 'auth.backend.htpasswd.userfile = "' . makeCorrectFile($this->settings['system']['apacheconf_htpasswddir'] . '/' . $filename) . '"' . "\n";
|
||||
@@ -708,13 +651,11 @@ class lighttpd
|
||||
$diroption_text.= ' "require" => "valid-user"' . "\n";
|
||||
$diroption_text.= ')' . "\n";
|
||||
|
||||
if($this->auth_backend_loaded[$domain['ssl_ipandport']] == 'yes')
|
||||
{
|
||||
if ($this->auth_backend_loaded[$domain['ssl_ipandport']] == 'yes') {
|
||||
$this->needed_htpasswds[$domain['ssl_ipandport']].= $diroption_text;
|
||||
}
|
||||
|
||||
if($this->auth_backend_loaded[$domain['ipandport']] != 'yes')
|
||||
{
|
||||
if ($this->auth_backend_loaded[$domain['ipandport']] != 'yes') {
|
||||
$this->needed_htpasswds[$domain['ipandport']].= $diroption_text;
|
||||
}
|
||||
}
|
||||
@@ -727,73 +668,51 @@ class lighttpd
|
||||
$server_string = array();
|
||||
$domain_name = str_replace('.', '\.', $domain['domain']);
|
||||
|
||||
if($domain['iswildcarddomain'] == '1')
|
||||
{
|
||||
if ($domain['iswildcarddomain'] == '1') {
|
||||
$server_string[] = '(?:^|\.)' . $domain_name . '$';
|
||||
}
|
||||
else
|
||||
{
|
||||
if($domain['wwwserveralias'] == '1')
|
||||
{
|
||||
} else {
|
||||
if ($domain['wwwserveralias'] == '1') {
|
||||
$server_string[] = '^(?:www\.|)' . $domain_name . '$';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$server_string[] = '^'.$domain_name.'$';
|
||||
}
|
||||
}
|
||||
|
||||
$alias_domains = $this->db->query('SELECT `domain`, `iswildcarddomain`, `wwwserveralias` FROM `' . TABLE_PANEL_DOMAINS . '` WHERE `aliasdomain`=\'' . $domain['id'] . '\'');
|
||||
|
||||
while(($alias_domain = $this->db->fetch_array($alias_domains)) !== false)
|
||||
{
|
||||
while (($alias_domain = $this->db->fetch_array($alias_domains)) !== false) {
|
||||
$alias_domain_name = ereg_replace('\.', '\.', $alias_domain['domain']);
|
||||
|
||||
if($alias_domain['iswildcarddomain'] == '1')
|
||||
{
|
||||
if ($alias_domain['iswildcarddomain'] == '1') {
|
||||
$server_string[] = '(?:^|\.)' . $alias_domain_name . '$';
|
||||
}
|
||||
else
|
||||
{
|
||||
if($alias_domain['wwwserveralias'] == '1')
|
||||
{
|
||||
} else {
|
||||
if ($alias_domain['wwwserveralias'] == '1') {
|
||||
$server_string[] = '^(?:www\.|)' . $alias_domain_name . '$';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$server_string[] = '^'.$alias_domain_name . '$';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 0;$i < sizeof($server_string);$i++)
|
||||
{
|
||||
for ($i = 0;$i < sizeof($server_string); $i++) {
|
||||
$data = $server_string[$i];
|
||||
|
||||
if(sizeof($server_string) > 1)
|
||||
{
|
||||
if($i == 0)
|
||||
{
|
||||
if (sizeof($server_string) > 1) {
|
||||
if ($i == 0) {
|
||||
$servernames_text = '(' . $data . '|';
|
||||
} elseif(sizeof($server_string) - 1 == $i) {
|
||||
$servernames_text .= $data . ')';
|
||||
} else {
|
||||
$servernames_text .= $data . '|';
|
||||
}
|
||||
elseif(sizeof($server_string) - 1 == $i)
|
||||
{
|
||||
$servernames_text.= $data . ')';
|
||||
}
|
||||
else
|
||||
{
|
||||
$servernames_text.= $data . '|';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$servernames_text = $data;
|
||||
}
|
||||
}
|
||||
|
||||
unset($data);
|
||||
|
||||
if($servernames_text != '') {
|
||||
if ($servernames_text != '') {
|
||||
$servernames_text = '$HTTP["host"] =~ "' . $servernames_text . '"';
|
||||
} else {
|
||||
$servernames_text = '$HTTP["host"] == "' . $domain['domain'] . '"';
|
||||
@@ -806,36 +725,30 @@ class lighttpd
|
||||
{
|
||||
$webroot_text = '';
|
||||
|
||||
if($domain['deactivated'] == '1'
|
||||
&& $this->settings['system']['deactivateddocroot'] != '')
|
||||
{
|
||||
if ($domain['deactivated'] == '1'
|
||||
&& $this->settings['system']['deactivateddocroot'] != ''
|
||||
) {
|
||||
$webroot_text.= ' # Using docroot for deactivated users...' . "\n";
|
||||
$webroot_text.= ' server.document-root = "' . makeCorrectDir($this->settings['system']['deactivateddocroot']) . "\"\n";
|
||||
$this->_deactivated = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if($ssl === false
|
||||
&& $domain['ssl_redirect'] == '1')
|
||||
{
|
||||
} else {
|
||||
if ($ssl === false
|
||||
&& $domain['ssl_redirect'] == '1'
|
||||
) {
|
||||
$redirect_domain = $this->idnaConvert->encode('https://' . $domain['domain']);
|
||||
$webroot_text.= ' url.redirect = ('."\n";
|
||||
$webroot_text.= "\t" . '"^/(.*)" => "' . $redirect_domain . '/$1",' . "\n";
|
||||
$webroot_text.= "\t" . '"" => "' . $redirect_domain . '",' . "\n";
|
||||
$webroot_text.= "\t" . '"/" => "' . $redirect_domain . '"' . "\n";
|
||||
$webroot_text.= ' )'."\n";
|
||||
}
|
||||
elseif(preg_match("#^https?://#i", $domain['documentroot']))
|
||||
{
|
||||
} elseif(preg_match("#^https?://#i", $domain['documentroot'])) {
|
||||
$redirect_domain = $this->idnaConvert->encode($domain['documentroot']);
|
||||
$webroot_text.= ' url.redirect = ('."\n";
|
||||
$webroot_text.= "\t" . '"^/(.*)" => "' . $redirect_domain . '/$1",' . "\n";
|
||||
$webroot_text.= "\t" . '"" => "' . $redirect_domain . '",' . "\n";
|
||||
$webroot_text.= "\t" . '"/" => "' . $redirect_domain . '"' . "\n";
|
||||
$webroot_text.= ' )'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$webroot_text.= ' server.document-root = "' . makeCorrectDir($domain['documentroot']) . "\"\n";
|
||||
}
|
||||
$this->_deactivated = false;
|
||||
@@ -848,12 +761,11 @@ class lighttpd
|
||||
* Lets set the text part for the stats software
|
||||
*/
|
||||
|
||||
protected function getStats($domain) {
|
||||
|
||||
protected function getStats($domain)
|
||||
{
|
||||
$stats_text = '';
|
||||
|
||||
if ($domain['speciallogfile'] == '1') {
|
||||
|
||||
if ($domain['parentdomainid'] == '0') {
|
||||
if ($this->settings['system']['awstats_enabled'] == '1') {
|
||||
$stats_text.= ' alias.url = ( "/awstats/" => "'.makeCorrectFile($domain['customerroot'] . '/awstats/' . $domain['domain']).'" )' . "\n";
|
||||
@@ -896,8 +808,7 @@ class lighttpd
|
||||
fwrite($this->debugHandler, ' lighttpd::writeConfigs: rebuilding ' . $this->settings['system']['apacheconf_vhost'] . "\n");
|
||||
$this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . $this->settings['system']['apacheconf_vhost']);
|
||||
|
||||
if(!isConfigDir($this->settings['system']['apacheconf_vhost']))
|
||||
{
|
||||
if (!isConfigDir($this->settings['system']['apacheconf_vhost'])) {
|
||||
// Save one big file
|
||||
$vhosts_file = '';
|
||||
|
||||
@@ -908,41 +819,32 @@ class lighttpd
|
||||
// (former #437) - #833 (the numbering is done in createLighttpdHosts())
|
||||
ksort($this->lighttpd_data);
|
||||
|
||||
foreach($this->lighttpd_data as $vhosts_filename => $vhost_content)
|
||||
{
|
||||
foreach ($this->lighttpd_data as $vhosts_filename => $vhost_content) {
|
||||
$vhosts_file.= $vhost_content . "\n\n";
|
||||
}
|
||||
|
||||
$vhosts_filename = $this->settings['system']['apacheconf_vhost'];
|
||||
|
||||
// Apply header
|
||||
|
||||
$vhosts_file = '# ' . basename($vhosts_filename) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n" . $vhosts_file;
|
||||
$vhosts_file_handler = fopen($vhosts_filename, 'w');
|
||||
fwrite($vhosts_file_handler, $vhosts_file);
|
||||
fclose($vhosts_file_handler);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!file_exists($this->settings['system']['apacheconf_vhost']))
|
||||
{
|
||||
} else {
|
||||
if (!file_exists($this->settings['system']['apacheconf_vhost'])) {
|
||||
fwrite($this->debugHandler, ' lighttpd::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'])) . "\n");
|
||||
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'])));
|
||||
safe_exec('mkdir ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'])));
|
||||
}
|
||||
|
||||
// Write a single file for every vhost
|
||||
|
||||
foreach($this->lighttpd_data as $vhosts_filename => $vhosts_file)
|
||||
{
|
||||
foreach ($this->lighttpd_data as $vhosts_filename => $vhosts_file) {
|
||||
$this->known_filenames[] = basename($vhosts_filename);
|
||||
|
||||
// Apply header
|
||||
|
||||
$vhosts_file = '# ' . basename($vhosts_filename) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n" . $vhosts_file;
|
||||
|
||||
if(!empty($vhosts_filename))
|
||||
{
|
||||
if (!empty($vhosts_filename)) {
|
||||
$vhosts_file_handler = fopen($vhosts_filename, 'w');
|
||||
fwrite($vhosts_file_handler, $vhosts_file);
|
||||
fclose($vhosts_file_handler);
|
||||
@@ -952,12 +854,9 @@ class lighttpd
|
||||
|
||||
// Write the diroptions
|
||||
|
||||
if(isConfigDir($this->settings['system']['apacheconf_htpasswddir']))
|
||||
{
|
||||
foreach($this->needed_htpasswds as $key => $data)
|
||||
{
|
||||
if(!is_dir($this->settings['system']['apacheconf_htpasswddir']))
|
||||
{
|
||||
if (isConfigDir($this->settings['system']['apacheconf_htpasswddir'])) {
|
||||
foreach ($this->needed_htpasswds as $key => $data) {
|
||||
if (!is_dir($this->settings['system']['apacheconf_htpasswddir'])) {
|
||||
mkdir(makeCorrectDir($this->settings['system']['apacheconf_htpasswddir']));
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ class nginx
|
||||
protected $auth_backend_loaded = false;
|
||||
protected $htpasswds_data = array();
|
||||
protected $known_htpasswdsfilenames = array();
|
||||
protected $mod_accesslog_loaded = "0";
|
||||
protected $mod_accesslog_loaded = '0';
|
||||
protected $vhost_root_autoindex = false;
|
||||
protected $known_vhostfilenames = array();
|
||||
/**
|
||||
@@ -79,9 +79,7 @@ class nginx
|
||||
fwrite($this->debugHandler, ' nginx::reload: restarting php processes' . "\n");
|
||||
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'restarting php processes');
|
||||
safe_exec($this->settings['system']['phpreload_command']);
|
||||
}
|
||||
elseif((int)$this->settings['phpfpm']['enabled'] == 1)
|
||||
{
|
||||
} elseif ((int)$this->settings['phpfpm']['enabled'] == 1) {
|
||||
fwrite($this->debugHandler, ' nginx::reload: reloading php-fpm' . "\n");
|
||||
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading php-fpm');
|
||||
safe_exec(escapeshellcmd($this->settings['phpfpm']['reload']));
|
||||
@@ -94,15 +92,14 @@ class nginx
|
||||
*/
|
||||
private function _createStandardErrorHandler()
|
||||
{
|
||||
if($this->settings['defaultwebsrverrhandler']['enabled'] == '1'
|
||||
if ($this->settings['defaultwebsrverrhandler']['enabled'] == '1'
|
||||
&& ($this->settings['defaultwebsrverrhandler']['err401'] != ''
|
||||
|| $this->settings['defaultwebsrverrhandler']['err403'] != ''
|
||||
|| $this->settings['defaultwebsrverrhandler']['err404'] != ''
|
||||
|| $this->settings['defaultwebsrverrhandler']['err500'] != '')
|
||||
) {
|
||||
$vhosts_folder = '';
|
||||
if(is_dir($this->settings['system']['apacheconf_vhost']))
|
||||
{
|
||||
if (is_dir($this->settings['system']['apacheconf_vhost'])) {
|
||||
$vhosts_folder = makeCorrectDir($this->settings['system']['apacheconf_vhost']);
|
||||
} else {
|
||||
$vhosts_folder = makeCorrectDir(dirname($this->settings['system']['apacheconf_vhost']));
|
||||
@@ -110,48 +107,29 @@ class nginx
|
||||
|
||||
$vhosts_filename = makeCorrectFile($vhosts_folder . '/05_froxlor_default_errorhandler.conf');
|
||||
|
||||
if(!isset($this->nginx_data[$vhosts_filename]))
|
||||
{
|
||||
if (!isset($this->nginx_data[$vhosts_filename])) {
|
||||
$this->nginx_data[$vhosts_filename] = '';
|
||||
}
|
||||
|
||||
if ($this->settings['defaultwebsrverrhandler']['err401'] != '') {
|
||||
$defhandler = $this->settings['defaultwebsrverrhandler']['err401'];
|
||||
if (!validateUrl($defhandler)) {
|
||||
$defhandler = makeCorrectFile($defhandler);
|
||||
}
|
||||
$this->nginx_data[$vhosts_filename].= 'error_page 401 ' . $defhandler . ';' . "\n";
|
||||
}
|
||||
|
||||
if ($this->settings['defaultwebsrverrhandler']['err403'] != '') {
|
||||
$defhandler = $this->settings['defaultwebsrverrhandler']['err403'];
|
||||
if (!validateUrl($defhandler)) {
|
||||
$defhandler = makeCorrectFile($defhandler);
|
||||
$statusCodes = array('401', '403', '404', '500');
|
||||
foreach ($statusCodes as $statusCode) {
|
||||
if ($this->settings['defaultwebsrverrhandler']['err' . $statusCode] != '') {
|
||||
$defhandler = $this->settings['defaultwebsrverrhandler']['err' . $statusCode];
|
||||
if (!validateUrl($defhandler)) {
|
||||
$defhandler = makeCorrectFile($defhandler);
|
||||
}
|
||||
$this->nginx_data[$vhosts_filename].= 'error_page ' . $statusCode . ' ' . $defhandler . ';' . "\n";
|
||||
}
|
||||
$this->nginx_data[$vhosts_filename].= 'error_page 403 ' . $defhandler . ';' . "\n";
|
||||
}
|
||||
|
||||
if ($this->settings['defaultwebsrverrhandler']['err404'] != '') {
|
||||
$defhandler = $this->settings['defaultwebsrverrhandler']['err404'];
|
||||
if (!validateUrl($defhandler)) {
|
||||
$defhandler = makeCorrectFile($defhandler);
|
||||
}
|
||||
$this->nginx_data[$vhosts_filename].= 'error_page 404 ' . $defhandler . ';' . "\n";
|
||||
}
|
||||
|
||||
if ($this->settings['defaultwebsrverrhandler']['err500'] != '') {
|
||||
$defhandler = $this->settings['defaultwebsrverrhandler']['err500'];
|
||||
if (!validateUrl($defhandler)) {
|
||||
$defhandler = makeCorrectFile($defhandler);
|
||||
}
|
||||
$this->nginx_data[$vhosts_filename].= 'error_page 500 ' . $defhandler . ';' . "\n";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public function createVirtualHosts(){
|
||||
|
||||
public function createVirtualHosts()
|
||||
{
|
||||
}
|
||||
public function createFileDirOptions(){
|
||||
|
||||
public function createFileDirOptions()
|
||||
{
|
||||
}
|
||||
|
||||
public function createIpPort()
|
||||
@@ -160,7 +138,6 @@ class nginx
|
||||
$result_ipsandports = $this->db->query($query);
|
||||
|
||||
while ($row_ipsandports = $this->db->fetch_array($result_ipsandports)) {
|
||||
|
||||
if (filter_var($row_ipsandports['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
|
||||
$ip = '[' . $row_ipsandports['ip'] . ']';
|
||||
} else {
|
||||
@@ -178,17 +155,17 @@ class nginx
|
||||
|
||||
if ($row_ipsandports['vhostcontainer'] == '1') {
|
||||
|
||||
$this->nginx_data[$vhost_filename].= 'server { ' . "\n";
|
||||
$this->nginx_data[$vhost_filename] .= 'server { ' . "\n";
|
||||
|
||||
/**
|
||||
* this HAS to be set for the default host in nginx or else no vhost will work
|
||||
*/
|
||||
$this->nginx_data[$vhost_filename].= "\t". 'listen ' . $ip . ':' . $port . ' default;' . "\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t". 'listen ' . $ip . ':' . $port . ' default;' . "\n";
|
||||
|
||||
$this->nginx_data[$vhost_filename].= "\t".'# Froxlor default vhost' . "\n";
|
||||
$this->nginx_data[$vhost_filename].= "\t".'server_name ' . $this->settings['system']['hostname'] . ';' . "\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t".'# Froxlor default vhost' . "\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t".'server_name ' . $this->settings['system']['hostname'] . ';' . "\n";
|
||||
|
||||
$this->nginx_data[$vhost_filename].= "\t".'access_log /var/log/nginx/access.log;' . "\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t".'access_log /var/log/nginx/access.log;' . "\n";
|
||||
|
||||
$mypath = '';
|
||||
|
||||
@@ -206,10 +183,10 @@ class nginx
|
||||
$mypath = makeCorrectDir($row_ipsandports['docroot']);
|
||||
}
|
||||
|
||||
$this->nginx_data[$vhost_filename].= "\t".'root '.$mypath.';'."\n";
|
||||
$this->nginx_data[$vhost_filename].= "\t".'location / {'."\n";
|
||||
$this->nginx_data[$vhost_filename].= "\t\t".'index index.php index.html index.htm;'."\n";
|
||||
$this->nginx_data[$vhost_filename].= "\t".'}'."\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t".'root '.$mypath.';'."\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t".'location / {'."\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t\t".'index index.php index.html index.htm;'."\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t".'}'."\n";
|
||||
|
||||
if ($row_ipsandports['specialsettings'] != '') {
|
||||
$this->nginx_data[$vhost_filename].= $row_ipsandports['specialsettings'] . "\n";
|
||||
@@ -229,26 +206,26 @@ class nginx
|
||||
$row_ipsandports['ssl_ca_file'] = $this->settings['system']['ssl_ca_file'];
|
||||
}
|
||||
if ($row_ipsandports['ssl_cert_file'] != '') {
|
||||
$this->nginx_data[$vhost_filename].= "\t" . 'ssl on;' . "\n";
|
||||
$this->nginx_data[$vhost_filename].= "\t" . 'ssl_certificate ' . makeCorrectFile($row_ipsandports['ssl_cert_file']) . ';' . "\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t" . 'ssl on;' . "\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t" . 'ssl_certificate ' . makeCorrectFile($row_ipsandports['ssl_cert_file']) . ';' . "\n";
|
||||
}
|
||||
if ($row_ipsandports['ssl_key_file'] != '') {
|
||||
$this->nginx_data[$vhost_filename].= "\t" . 'ssl_certificate_key ' .makeCorrectFile($row_ipsandports['ssl_key_file']) . ';' . "\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t" . 'ssl_certificate_key ' .makeCorrectFile($row_ipsandports['ssl_key_file']) . ';' . "\n";
|
||||
}
|
||||
if ($row_ipsandports['ssl_ca_file'] != '') {
|
||||
$this->nginx_data[$vhost_filename].= 'ssl_client_certificate ' . makeCorrectFile($row_ipsandports['ssl_ca_file']) . ';' . "\n";
|
||||
$this->nginx_data[$vhost_filename] .= 'ssl_client_certificate ' . makeCorrectFile($row_ipsandports['ssl_ca_file']) . ';' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
$this->nginx_data[$vhost_filename].= "\t".'location ~ \.php$ {'."\n";
|
||||
$this->nginx_data[$vhost_filename].= "\t\t".' if (!-f $request_filename) {'."\n";
|
||||
$this->nginx_data[$vhost_filename].= "\t\t\t".'return 404;'."\n";
|
||||
$this->nginx_data[$vhost_filename].= "\t\t".'}'."\n";
|
||||
$this->nginx_data[$vhost_filename].= "\t\t".'fastcgi_index index.php;'."\n";
|
||||
$this->nginx_data[$vhost_filename].= "\t\t".'include '.$this->settings['nginx']['fastcgiparams'].';'."\n";
|
||||
$this->nginx_data[$vhost_filename].= "\t\t".'fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;'."\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t".'location ~ \.php$ {'."\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t\t".' if (!-f $request_filename) {'."\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t\t\t".'return 404;'."\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t\t".'}'."\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t\t".'fastcgi_index index.php;'."\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t\t".'include '.$this->settings['nginx']['fastcgiparams'].';'."\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t\t".'fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;'."\n";
|
||||
if ($row_ipsandports['ssl'] == '1') {
|
||||
$this->nginx_data[$vhost_filename].= "\t\t".'fastcgi_param HTTPS on;'."\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t\t".'fastcgi_param HTTPS on;'."\n";
|
||||
}
|
||||
if ((int)$this->settings['phpfpm']['enabled'] == 1
|
||||
&& (int)$this->settings['phpfpm']['enabled_ownvhost'] == 1
|
||||
@@ -267,13 +244,12 @@ class nginx
|
||||
);
|
||||
|
||||
$php = new phpinterface($this->getDB(), $this->settings, $domain);
|
||||
$this->nginx_data[$vhost_filename].= "\t\t".'fastcgi_pass unix:' . $php->getInterface()->getSocketFile() . ';' . "\n";
|
||||
|
||||
$this->nginx_data[$vhost_filename] .= "\t\t".'fastcgi_pass unix:' . $php->getInterface()->getSocketFile() . ';' . "\n";
|
||||
} else {
|
||||
$this->nginx_data[$vhost_filename].= "\t\t".'fastcgi_pass ' . $this->settings['system']['nginx_php_backend'] . ';' . "\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t\t".'fastcgi_pass ' . $this->settings['system']['nginx_php_backend'] . ';' . "\n";
|
||||
}
|
||||
$this->nginx_data[$vhost_filename].= "\t".'}'."\n";
|
||||
$this->nginx_data[$vhost_filename].= '}' . "\n\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t".'}'."\n";
|
||||
$this->nginx_data[$vhost_filename] .= '}' . "\n\n";
|
||||
// End of Froxlor server{}-part
|
||||
}
|
||||
$this->createNginxHosts($row_ipsandports['ip'], $row_ipsandports['port'], $row_ipsandports['ssl'], $vhost_filename);
|
||||
@@ -287,30 +263,26 @@ class nginx
|
||||
|
||||
protected function createNginxHosts($ip, $port, $ssl, $vhost_filename)
|
||||
{
|
||||
$query = "SELECT * FROM " . TABLE_PANEL_IPSANDPORTS . " WHERE `ip`='" . $ip . "' AND `port`='" . $port . "'";
|
||||
$query = "SELECT * FROM " . TABLE_PANEL_IPSANDPORTS . " WHERE `ip` = '" . $ip . "' AND `port` = '" . $port . "'";
|
||||
$ipandport = $this->db->query_first($query);
|
||||
|
||||
if($ssl == '0')
|
||||
{
|
||||
$query2 = "SELECT `d`.*, `pd`.`domain` AS `parentdomain`, `c`.`loginname`, `c`.`guid`, `c`.`email`, `c`.`documentroot` AS `customerroot`, `c`.`deactivated`, `c`.`phpenabled` AS `phpenabled` FROM `" . TABLE_PANEL_DOMAINS . "` `d` LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`) LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `pd` ON (`pd`.`id` = `d`.`parentdomainid`) WHERE `d`.`ipandport`='" . $ipandport['id'] . "' AND `d`.`aliasdomain` IS NULL AND `d`.`email_only` <> 1 ORDER BY `d`.`iswildcarddomain`, `d`.`domain` ASC";
|
||||
}
|
||||
else
|
||||
{
|
||||
$query2 = "SELECT `d`.*, `pd`.`domain` AS `parentdomain`, `c`.`loginname`, `c`.`guid`, `c`.`email`, `c`.`documentroot` AS `customerroot`, `c`.`deactivated`, `c`.`phpenabled` AS `phpenabled` FROM `" . TABLE_PANEL_DOMAINS . "` `d` LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`) LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `pd` ON (`pd`.`id` = `d`.`parentdomainid`) WHERE `d`.`ssl_ipandport`='" . $ipandport['id'] . "' AND `d`.`aliasdomain` IS NULL AND `d`.`email_only` <> 1 ORDER BY `d`.`iswildcarddomain`, `d`.`domain` ASC";
|
||||
$query2 = "SELECT `d`.*, `pd`.`domain` AS `parentdomain`, `c`.`loginname`, `c`.`guid`, `c`.`email`, `c`.`documentroot` AS `customerroot`, `c`.`deactivated`, `c`.`phpenabled` AS `phpenabled` FROM `" . TABLE_PANEL_DOMAINS . "` `d` LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`) LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `pd` ON (`pd`.`id` = `d`.`parentdomainid`) ";
|
||||
if ($ssl == '0') {
|
||||
$query2 .= "WHERE `d`.`ipandport` = '" . $ipandport['id'] . "' ";
|
||||
} else {
|
||||
$query2 .= "WHERE `d`.`ssl_ipandport` = '" . $ipandport['id'] . "' ";
|
||||
}
|
||||
$query2 .= "AND `d`.`aliasdomain` IS NULL AND `d`.`email_only` <> 1 ORDER BY `d`.`iswildcarddomain`, `d`.`domain` ASC";
|
||||
|
||||
$included_vhosts = array();
|
||||
$result_domains = $this->db->query($query2);
|
||||
while($domain = $this->db->fetch_array($result_domains))
|
||||
{
|
||||
if (is_dir($this->settings['system']['apacheconf_vhost']))
|
||||
{
|
||||
while ($domain = $this->db->fetch_array($result_domains)) {
|
||||
if (is_dir($this->settings['system']['apacheconf_vhost'])) {
|
||||
safe_exec('mkdir -p '.escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'])));
|
||||
$vhost_filename = $this->getVhostFilename($domain);
|
||||
}
|
||||
|
||||
if(!isset($this->nginx_data[$vhost_filename]))
|
||||
{
|
||||
if (!isset($this->nginx_data[$vhost_filename])) {
|
||||
$this->nginx_data[$vhost_filename] = '';
|
||||
}
|
||||
|
||||
@@ -320,16 +292,13 @@ class nginx
|
||||
$domain['port'] = $ipandport['port'];
|
||||
$domain['ssl_cert_file'] = $ipandport['ssl_cert_file'];
|
||||
|
||||
if( (!empty($this->nginx_data[$vhost_filename]) && !is_dir($this->settings['system']['apacheconf_vhost']))
|
||||
|| is_dir($this->settings['system']['apacheconf_vhost']))
|
||||
{
|
||||
if($ssl == '1')
|
||||
{
|
||||
if ((!empty($this->nginx_data[$vhost_filename]) && !is_dir($this->settings['system']['apacheconf_vhost']))
|
||||
|| is_dir($this->settings['system']['apacheconf_vhost'])
|
||||
) {
|
||||
if ($ssl == '1') {
|
||||
$ssl_vhost = true;
|
||||
$ips_and_ports_index = 'ssl_ipandport';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$ssl_vhost = false;
|
||||
$ips_and_ports_index = 'ipandport';
|
||||
}
|
||||
@@ -342,30 +311,24 @@ class nginx
|
||||
|
||||
protected function getVhostFilename($domain, $ssl_vhost = false)
|
||||
{
|
||||
if((int)$domain['parentdomainid'] == 0
|
||||
&& isCustomerStdSubdomain((int)$domain['id']) == false
|
||||
&& ((int)$domain['ismainbutsubto'] == 0
|
||||
|| domainMainToSubExists($domain['ismainbutsubto']) == false)
|
||||
if ((int)$domain['parentdomainid'] == 0
|
||||
&& isCustomerStdSubdomain((int)$domain['id']) == false
|
||||
&& ((int)$domain['ismainbutsubto'] == 0
|
||||
|| domainMainToSubExists($domain['ismainbutsubto']) == false)
|
||||
) {
|
||||
$vhost_no = '22';
|
||||
}
|
||||
elseif((int)$domain['parentdomainid'] == 0
|
||||
&& isCustomerStdSubdomain((int)$domain['id']) == false
|
||||
&& (int)$domain['ismainbutsubto'] > 0
|
||||
} elseif ((int)$domain['parentdomainid'] == 0
|
||||
&& isCustomerStdSubdomain((int)$domain['id']) == false
|
||||
&& (int)$domain['ismainbutsubto'] > 0
|
||||
) {
|
||||
$vhost_no = '21';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$vhost_no = '20';
|
||||
}
|
||||
|
||||
if($ssl_vhost === true)
|
||||
{
|
||||
if ($ssl_vhost === true) {
|
||||
$vhost_filename = makeCorrectFile($this->settings['system']['apacheconf_vhost'] . '/'.$vhost_no.'_froxlor_ssl_vhost_' . $domain['domain'] . '.conf');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$vhost_filename = makeCorrectFile($this->settings['system']['apacheconf_vhost'] . '/'.$vhost_no.'_froxlor_normal_vhost_' . $domain['domain'] . '.conf');
|
||||
}
|
||||
|
||||
@@ -374,19 +337,17 @@ class nginx
|
||||
|
||||
protected function getVhostContent($domain, $ssl_vhost = false)
|
||||
{
|
||||
if($ssl_vhost === true
|
||||
&& $domain['ssl'] != '1')
|
||||
{
|
||||
if ($ssl_vhost === true
|
||||
&& $domain['ssl'] != '1'
|
||||
) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if($ssl_vhost === true
|
||||
&& $domain['ssl'] == '1')
|
||||
{
|
||||
if ($ssl_vhost === true
|
||||
&& $domain['ssl'] == '1'
|
||||
) {
|
||||
$query = "SELECT * FROM " . TABLE_PANEL_IPSANDPORTS . " WHERE `id`='" . $domain['ssl_ipandport'] . "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$query = "SELECT * FROM " . TABLE_PANEL_IPSANDPORTS . " WHERE `id`='" . $domain['ipandport'] . "'";
|
||||
}
|
||||
|
||||
@@ -395,27 +356,24 @@ class nginx
|
||||
$domain['port'] = $ipandport['port'];
|
||||
$domain['ssl_cert_file'] = $ipandport['ssl_cert_file'];
|
||||
|
||||
if(filter_var($domain['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6))
|
||||
{
|
||||
if (filter_var($domain['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
|
||||
$ipport = '[' . $domain['ip'] . ']:' . $domain['port'];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$ipport = $domain['ip'] . ':' . $domain['port'];
|
||||
}
|
||||
|
||||
$vhost_content = '';
|
||||
|
||||
// open vhost-container
|
||||
$vhost_content.= 'server { ' . "\n";
|
||||
$vhost_content .= 'server { ' . "\n";
|
||||
// listening statement (required)
|
||||
$vhost_content.= "\t" . 'listen ' . $ipport . ';' . "\n";
|
||||
$vhost_content .= "\t" . 'listen ' . $ipport . ';' . "\n";
|
||||
|
||||
// get all server-names
|
||||
$vhost_content.= $this->getServerNames($domain);
|
||||
$vhost_content .= $this->getServerNames($domain);
|
||||
|
||||
// respect ssl_redirect settings, #542
|
||||
if($ssl_vhost == false
|
||||
if ($ssl_vhost == false
|
||||
&& $domain['ssl'] == '1'
|
||||
&& $domain['ssl_redirect'] == '1'
|
||||
) {
|
||||
@@ -424,49 +382,50 @@ class nginx
|
||||
|
||||
// if the documentroot is an URL we just redirect
|
||||
if (preg_match('/^https?\:\/\//', $domain['documentroot'])) {
|
||||
$vhost_content.= "\t".'rewrite ^(.*) '.$this->idnaConvert->encode($domain['documentroot']).'$1 permanent;'."\n";
|
||||
$vhost_content .= "\t".'rewrite ^(.*) '.$this->idnaConvert->encode($domain['documentroot']).'$1 permanent;'."\n";
|
||||
} else {
|
||||
mkDirWithCorrectOwnership($domain['customerroot'], $domain['documentroot'], $domain['guid'], $domain['guid'], true);
|
||||
|
||||
$vhost_content.= $this->getLogFiles($domain);
|
||||
$vhost_content.= $this->getWebroot($domain, $ssl_vhost);
|
||||
$vhost_content .= $this->getLogFiles($domain);
|
||||
$vhost_content .= $this->getWebroot($domain, $ssl_vhost);
|
||||
|
||||
if ($this->_deactivated == false) {
|
||||
$vhost_content.= $this->create_pathOptions($domain);
|
||||
$vhost_content.= $this->composePhpOptions($domain, $ssl_vhost);
|
||||
$vhost_content .= $this->create_pathOptions($domain);
|
||||
$vhost_content .= $this->composePhpOptions($domain, $ssl_vhost);
|
||||
|
||||
if ($domain['specialsettings'] != "") {
|
||||
$vhost_content.= $domain['specialsettings'] . "\n";
|
||||
$vhost_content .= $domain['specialsettings'] . "\n";
|
||||
}
|
||||
|
||||
if ($ipandport['default_vhostconf_domain'] != '') {
|
||||
$vhost_content.= $ipandport['default_vhostconf_domain'] . "\n";
|
||||
$vhost_content .= $ipandport['default_vhostconf_domain'] . "\n";
|
||||
}
|
||||
|
||||
if ($this->settings['system']['default_vhostconf'] != '') {
|
||||
$vhost_content.= $this->settings['system']['default_vhostconf'] . "\n";
|
||||
$vhost_content .= $this->settings['system']['default_vhostconf'] . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// merge duplicate / sections, #1193
|
||||
$l_regex1="/(location\ \/\ \{)(.*)(\})/smU";
|
||||
$l_regex2="/(location\ \/\ \{.*\})/smU";
|
||||
$replace_by="";
|
||||
$replacements=preg_match_all($l_regex1,$vhost_content,$out);
|
||||
$l_regex1 = "/(location\ \/\ \{)(.*)(\})/smU";
|
||||
$l_regex2 = "/(location\ \/\ \{.*\})/smU";
|
||||
$replace_by = '';
|
||||
$replacements = preg_match_all($l_regex1,$vhost_content,$out);
|
||||
if ($replacements > 1) {
|
||||
foreach ($out[2] as $val) {
|
||||
$replace_by.=$val."\n";
|
||||
$replace_by .= $val."\n";
|
||||
}
|
||||
$vhost_content=preg_replace($l_regex2, "", $vhost_content, $replacements-1);
|
||||
$vhost_content=preg_replace($l_regex2, "location / {\n\t\t". $replace_by ."\t}\n", $vhost_content);
|
||||
$vhost_content = preg_replace($l_regex2, "", $vhost_content, $replacements-1);
|
||||
$vhost_content = preg_replace($l_regex2, "location / {\n\t\t". $replace_by ."\t}\n", $vhost_content);
|
||||
}
|
||||
}
|
||||
$vhost_content.= '}' . "\n\n";
|
||||
$vhost_content .= '}' . "\n\n";
|
||||
|
||||
return $vhost_content;
|
||||
}
|
||||
|
||||
protected function create_pathOptions($domain) {
|
||||
protected function create_pathOptions($domain)
|
||||
{
|
||||
$has_location = false;
|
||||
|
||||
$query = "SELECT * FROM " . TABLE_PANEL_HTACCESS . " WHERE `path` LIKE '" . $domain['documentroot'] . "%'";
|
||||
@@ -477,13 +436,12 @@ class nginx
|
||||
|
||||
// for each entry in the htaccess table
|
||||
while ($row = $this->db->fetch_array($result)) {
|
||||
|
||||
if (!empty($row['error404path'])) {
|
||||
$defhandler = $row['error404path'];
|
||||
if (!validateUrl($defhandler)) {
|
||||
$defhandler = makeCorrectFile($defhandler);
|
||||
}
|
||||
$path_options.= "\t".'error_page 404 ' . $defhandler . ';' . "\n";
|
||||
$path_options .= "\t".'error_page 404 ' . $defhandler . ';' . "\n";
|
||||
}
|
||||
|
||||
if (!empty($row['error403path'])) {
|
||||
@@ -491,7 +449,7 @@ class nginx
|
||||
if (!validateUrl($defhandler)) {
|
||||
$defhandler = makeCorrectFile($defhandler);
|
||||
}
|
||||
$path_options.= "\t".'error_page 403 ' . $defhandler . ';' . "\n";
|
||||
$path_options .= "\t".'error_page 403 ' . $defhandler . ';' . "\n";
|
||||
}
|
||||
|
||||
if (!empty($row['error500path'])) {
|
||||
@@ -499,21 +457,20 @@ class nginx
|
||||
if (!validateUrl($defhandler)) {
|
||||
$defhandler = makeCorrectFile($defhandler);
|
||||
}
|
||||
$path_options.= "\t".'error_page 500 502 503 504 ' . $defhandler . ';' . "\n";
|
||||
$path_options .= "\t".'error_page 500 502 503 504 ' . $defhandler . ';' . "\n";
|
||||
}
|
||||
|
||||
// if($row['options_indexes'] != '0')
|
||||
// {
|
||||
// if ($row['options_indexes'] != '0') {
|
||||
$path = makeCorrectDir(substr($row['path'], strlen($domain['documentroot']) - 1));
|
||||
|
||||
mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']);
|
||||
|
||||
$path_options.= "\t".'# '.$path."\n";
|
||||
$path_options .= "\t".'# '.$path."\n";
|
||||
if ($path == '/') {
|
||||
$this->vhost_root_autoindex = true;
|
||||
$path_options.= "\t".'location ' . $path . ' {' . "\n";
|
||||
$path_options .= "\t".'location ' . $path . ' {' . "\n";
|
||||
if($this->vhost_root_autoindex) {
|
||||
$path_options.= "\t\t" . 'autoindex on;' . "\n";
|
||||
$path_options .= "\t\t" . 'autoindex on;' . "\n";
|
||||
$this->vhost_root_autoindex = false;
|
||||
}
|
||||
$path_options.= "\t\t" . 'index index.php index.html index.htm;'."\n";
|
||||
@@ -521,38 +478,34 @@ class nginx
|
||||
// check if we have a htpasswd for this path
|
||||
// (damn nginx does not like more than one
|
||||
// 'location'-part with the same path)
|
||||
if(count($htpasswds) > 0)
|
||||
{
|
||||
foreach($htpasswds as $idx => $single)
|
||||
{
|
||||
switch($single['path']){
|
||||
if (count($htpasswds) > 0) {
|
||||
foreach ($htpasswds as $idx => $single) {
|
||||
switch ($single['path']) {
|
||||
case '/awstats/':
|
||||
case '/webalizer/':
|
||||
// no stats-alias in "location /"-context
|
||||
break;
|
||||
default:
|
||||
if ($single['path']=='/'){
|
||||
$path_options.= "\t\t" . 'auth_basic "Restricted Area";' . "\n";
|
||||
$path_options.= "\t\t" . 'auth_basic_user_file ' . makeCorrectFile($single['usrf']) . ';'."\n";
|
||||
if ($single['path'] == '/') {
|
||||
$path_options .= "\t\t" . 'auth_basic "Restricted Area";' . "\n";
|
||||
$path_options .= "\t\t" . 'auth_basic_user_file ' . makeCorrectFile($single['usrf']) . ';'."\n";
|
||||
// remove already used entries so we do not have doubles
|
||||
unset($htpasswds[$idx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$path_options.= "\t".'}' . "\n";
|
||||
$path_options .= "\t".'}' . "\n";
|
||||
|
||||
$this->vhost_root_autoindex = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$path_options.= "\t".'location ' . $path . ' {' . "\n";
|
||||
if($this->vhost_root_autoindex) {
|
||||
$path_options.= "\t\t" . 'autoindex on;' . "\n";
|
||||
} else {
|
||||
$path_options .= "\t".'location ' . $path . ' {' . "\n";
|
||||
if ($this->vhost_root_autoindex) {
|
||||
$path_options .= "\t\t" . 'autoindex on;' . "\n";
|
||||
$this->vhost_root_autoindex = false;
|
||||
}
|
||||
$path_options.= "\t\t" . 'index index.php index.html index.htm;'."\n";
|
||||
$path_options.= "\t".'} ' . "\n";
|
||||
$path_options .= "\t\t" . 'index index.php index.html index.htm;'."\n";
|
||||
$path_options .= "\t".'} ' . "\n";
|
||||
}
|
||||
// }
|
||||
|
||||
@@ -560,22 +513,22 @@ class nginx
|
||||
* Perl support
|
||||
* required the fastCGI wrapper to be running to receive the CGI requests.
|
||||
*/
|
||||
if(customerHasPerlEnabled($domain['customerid'])
|
||||
&& $row['options_cgi'] != '0')
|
||||
{
|
||||
if (customerHasPerlEnabled($domain['customerid'])
|
||||
&& $row['options_cgi'] != '0'
|
||||
) {
|
||||
$path = makeCorrectDir(substr($row['path'], strlen($domain['documentroot']) - 1));
|
||||
mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']);
|
||||
|
||||
// We need to remove the last slash, otherwise the regex wouldn't work
|
||||
if($row['path'] != $domain['documentroot']) {
|
||||
if ($row['path'] != $domain['documentroot']) {
|
||||
$path = substr($path, 0, -1);
|
||||
}
|
||||
$path_options.= "\t" . 'location ~ \(.pl|.cgi)$ {' . "\n";
|
||||
$path_options.= "\t\t" . 'gzip off; #gzip makes scripts feel slower since they have to complete before getting gzipped' . "\n";
|
||||
$path_options.= "\t\t" . 'fastcgi_pass '. $this->settings['system']['perl_server'] . ';' . "\n";
|
||||
$path_options.= "\t\t" . 'fastcgi_index index.cgi;' . "\n";
|
||||
$path_options.= "\t\t" . 'include '.$this->settings['nginx']['fastcgiparams'].';'."\n";
|
||||
$path_options.= "\t" . '}' . "\n";
|
||||
$path_options .= "\t" . 'location ~ \(.pl|.cgi)$ {' . "\n";
|
||||
$path_options .= "\t\t" . 'gzip off; #gzip makes scripts feel slower since they have to complete before getting gzipped' . "\n";
|
||||
$path_options .= "\t\t" . 'fastcgi_pass '. $this->settings['system']['perl_server'] . ';' . "\n";
|
||||
$path_options .= "\t\t" . 'fastcgi_index index.cgi;' . "\n";
|
||||
$path_options .= "\t\t" . 'include '.$this->settings['nginx']['fastcgiparams'].';'."\n";
|
||||
$path_options .= "\t" . '}' . "\n";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -583,24 +536,20 @@ class nginx
|
||||
/*
|
||||
* now the rest of the htpasswds
|
||||
*/
|
||||
if(count($htpasswds) > 0)
|
||||
{
|
||||
foreach($htpasswds as $idx => $single)
|
||||
{
|
||||
//if($single['path'] != "/")
|
||||
//{
|
||||
switch($single['path'])
|
||||
{
|
||||
if (count($htpasswds) > 0) {
|
||||
foreach ($htpasswds as $idx => $single) {
|
||||
//if ($single['path'] != '/') {
|
||||
switch ($single['path']) {
|
||||
case '/awstats/':
|
||||
case '/webalizer/':
|
||||
$path_options.= $this->getStats($domain,$single);
|
||||
$path_options .= $this->getStats($domain,$single);
|
||||
unset($htpasswds[$idx]);
|
||||
break;
|
||||
default:
|
||||
$path_options.= "\t" . 'location ' . makeCorrectDir($single['path']) . ' {' . "\n";
|
||||
$path_options.= "\t\t" . 'auth_basic "Restricted Area";' . "\n";
|
||||
$path_options.= "\t\t" . 'auth_basic_user_file ' . makeCorrectFile($single['usrf']) . ';'."\n";
|
||||
$path_options.= "\t".'}' . "\n";
|
||||
$path_options .= "\t" . 'location ' . makeCorrectDir($single['path']) . ' {' . "\n";
|
||||
$path_options .= "\t\t" . 'auth_basic "Restricted Area";' . "\n";
|
||||
$path_options .= "\t\t" . 'auth_basic_user_file ' . makeCorrectFile($single['usrf']) . ';'."\n";
|
||||
$path_options .= "\t".'}' . "\n";
|
||||
}
|
||||
//}
|
||||
unset($htpasswds[$idx]);
|
||||
@@ -623,7 +572,6 @@ class nginx
|
||||
$returnval = array();
|
||||
$x = 0;
|
||||
while ($row_htpasswds = $this->db->fetch_array($result)) {
|
||||
|
||||
if (count($row_htpasswds) > 0) {
|
||||
$htpasswd_filename = makeCorrectFile($this->settings['system']['apacheconf_htpasswddir'] . '/' . $row_htpasswds['customerid'] . '-' . md5($row_htpasswds['path']) . '.htpasswd');
|
||||
|
||||
@@ -657,8 +605,7 @@ class nginx
|
||||
protected function composePhpOptions($domain, $ssl_vhost = false)
|
||||
{
|
||||
$phpopts = '';
|
||||
if($domain['phpenabled'] == '1')
|
||||
{
|
||||
if ($domain['phpenabled'] == '1') {
|
||||
$phpopts = "\t".'location ~ \.php$ {'."\n";
|
||||
$phpopts.= "\t\t".'try_files $uri =404;'."\n";
|
||||
$phpopts.= "\t\t".'fastcgi_split_path_info ^(.+\.php)(/.+)$;'."\n";
|
||||
@@ -678,38 +625,36 @@ class nginx
|
||||
{
|
||||
$webroot_text = '';
|
||||
|
||||
if($domain['deactivated'] == '1'
|
||||
&& $this->settings['system']['deactivateddocroot'] != '')
|
||||
{
|
||||
$webroot_text.= "\t".'# Using docroot for deactivated users...' . "\n";
|
||||
$webroot_text.= "\t".'root '.makeCorrectDir($this->settings['system']['deactivateddocroot']).';'."\n";
|
||||
if ($domain['deactivated'] == '1'
|
||||
&& $this->settings['system']['deactivateddocroot'] != ''
|
||||
) {
|
||||
$webroot_text .= "\t".'# Using docroot for deactivated users...' . "\n";
|
||||
$webroot_text .= "\t".'root '.makeCorrectDir($this->settings['system']['deactivateddocroot']).';'."\n";
|
||||
$this->_deactivated = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$webroot_text.= "\t".'root '.makeCorrectDir($domain['documentroot']).';'."\n";
|
||||
} else {
|
||||
$webroot_text .= "\t".'root '.makeCorrectDir($domain['documentroot']).';'."\n";
|
||||
$this->_deactivated = false;
|
||||
}
|
||||
|
||||
$webroot_text.= "\n\t".'location / {'."\n";
|
||||
$webroot_text.= "\t\t".'index index.php index.html index.htm;'."\n";
|
||||
$webroot_text.= "\t\t" . 'try_files $uri $uri/ @rewrites;'."\n";
|
||||
$webroot_text .= "\n\t".'location / {'."\n";
|
||||
$webroot_text .= "\t\t".'index index.php index.html index.htm;'."\n";
|
||||
$webroot_text .= "\t\t" . 'try_files $uri $uri/ @rewrites;'."\n";
|
||||
|
||||
if($this->vhost_root_autoindex) {
|
||||
$webroot_text.= "\t\t".'autoindex on;'."\n";
|
||||
if ($this->vhost_root_autoindex) {
|
||||
$webroot_text .= "\t\t".'autoindex on;'."\n";
|
||||
$this->vhost_root_autoindex = false;
|
||||
}
|
||||
|
||||
$webroot_text.= "\t".'}'."\n\n";
|
||||
$webroot_text.= "\tlocation @rewrites {\n";
|
||||
$webroot_text.= "\t\trewrite ^ /index.php last;\n";
|
||||
$webroot_text.= "\t}\n\n";
|
||||
$webroot_text .= "\t".'}'."\n\n";
|
||||
$webroot_text .= "\tlocation @rewrites {\n";
|
||||
$webroot_text .= "\t\trewrite ^ /index.php last;\n";
|
||||
$webroot_text .= "\t}\n\n";
|
||||
|
||||
return $webroot_text;
|
||||
}
|
||||
|
||||
protected function getStats($domain, $single) {
|
||||
|
||||
protected function getStats($domain, $single)
|
||||
{
|
||||
$stats_text = '';
|
||||
|
||||
// define basic path to the stats
|
||||
@@ -728,33 +673,31 @@ class nginx
|
||||
|
||||
if ($this->settings['system']['awstats_enabled'] == '1') {
|
||||
// awstats
|
||||
$stats_text.= "\t" . 'location /awstats {' . "\n";
|
||||
$stats_text .= "\t" . 'location /awstats {' . "\n";
|
||||
} else {
|
||||
// webalizer
|
||||
$stats_text.= "\t" . 'location /webalizer {' . "\n";
|
||||
$stats_text .= "\t" . 'location /webalizer {' . "\n";
|
||||
}
|
||||
|
||||
$stats_text.= "\t\t" . 'alias ' . $alias_dir . ';' . "\n";
|
||||
$stats_text.= "\t\t" . 'auth_basic "Restricted Area";' . "\n";
|
||||
$stats_text.= "\t\t" . 'auth_basic_user_file ' . makeCorrectFile($single['usrf']) . ';'."\n";
|
||||
$stats_text.= "\t" . '}' . "\n\n";
|
||||
$stats_text .= "\t\t" . 'alias ' . $alias_dir . ';' . "\n";
|
||||
$stats_text .= "\t\t" . 'auth_basic "Restricted Area";' . "\n";
|
||||
$stats_text .= "\t\t" . 'auth_basic_user_file ' . makeCorrectFile($single['usrf']) . ';'."\n";
|
||||
$stats_text .= "\t" . '}' . "\n\n";
|
||||
|
||||
return $stats_text;
|
||||
}
|
||||
|
||||
protected function getLogFiles($domain) {
|
||||
|
||||
protected function getLogFiles($domain)
|
||||
{
|
||||
$logfiles_text = '';
|
||||
|
||||
$speciallogfile = '';
|
||||
if ($domain['speciallogfile'] == '1') {
|
||||
|
||||
if ($domain['parentdomainid'] == '0') {
|
||||
$speciallogfile = '-' . $domain['domain'];
|
||||
} else {
|
||||
$speciallogfile = '-' . $domain['parentdomain'];
|
||||
}
|
||||
} else {
|
||||
$speciallogfile = '';
|
||||
}
|
||||
|
||||
// The normal access/error - logging is enabled
|
||||
@@ -770,8 +713,8 @@ class nginx
|
||||
chown($access_log, $this->settings['system']['httpuser']);
|
||||
chgrp($access_log, $this->settings['system']['httpgroup']);
|
||||
|
||||
$logfiles_text.= "\t".'access_log ' . $access_log . ' combined;' . "\n";
|
||||
$logfiles_text.= "\t".'error_log ' . $error_log . ' error;' . "\n";
|
||||
$logfiles_text .= "\t".'access_log ' . $access_log . ' combined;' . "\n";
|
||||
$logfiles_text .= "\t".'error_log ' . $error_log . ' error;' . "\n";
|
||||
|
||||
if ($this->settings['system']['awstats_enabled'] == '1') {
|
||||
if ((int)$domain['parentdomainid'] == 0) {
|
||||
@@ -782,27 +725,24 @@ class nginx
|
||||
OR `parentdomainid` =\''. $domain['id']. '\'');
|
||||
|
||||
while (($alias_domain = $this->db->fetch_array($alias_domains)) !== false) {
|
||||
$server_alias.= ' ' . $alias_domain['domain'] . ' ';
|
||||
$server_alias .= ' ' . $alias_domain['domain'] . ' ';
|
||||
|
||||
if ($alias_domain['iswildcarddomain'] == '1') {
|
||||
$server_alias.= '*.' . $domain['domain'];
|
||||
$server_alias .= '*.' . $domain['domain'];
|
||||
} else {
|
||||
if ($alias_domain['wwwserveralias'] == '1') {
|
||||
$server_alias.= 'www.' . $alias_domain['domain'];
|
||||
$server_alias .= 'www.' . $alias_domain['domain'];
|
||||
} else {
|
||||
$server_alias.= '';
|
||||
$server_alias .= '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$alias = '';
|
||||
if ($domain['iswildcarddomain'] == '1') {
|
||||
$alias = '*.' . $domain['domain'];
|
||||
} else {
|
||||
if ($domain['wwwserveralias'] == '1') {
|
||||
$alias = 'www.' . $domain['domain'];
|
||||
} else {
|
||||
$alias = '';
|
||||
}
|
||||
} elseif ($domain['wwwserveralias'] == '1') {
|
||||
$alias = 'www.' . $domain['domain'];
|
||||
}
|
||||
|
||||
// After inserting the AWStats information,
|
||||
@@ -824,47 +764,29 @@ class nginx
|
||||
{
|
||||
$server_alias = '';
|
||||
|
||||
if($domain['iswildcarddomain'] == '1')
|
||||
{
|
||||
if ($domain['iswildcarddomain'] == '1') {
|
||||
$server_alias = '*.' . $domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($domain['wwwserveralias'] == '1')
|
||||
{
|
||||
$server_alias = 'www.' . $domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$server_alias = '';
|
||||
}
|
||||
} elseif ($domain['wwwserveralias'] == '1') {
|
||||
$server_alias = 'www.' . $domain['domain'];
|
||||
}
|
||||
|
||||
$alias_domains = $this->db->query('SELECT `domain`, `iswildcarddomain`, `wwwserveralias` FROM `' . TABLE_PANEL_DOMAINS . '` WHERE `aliasdomain`=\'' . $domain['id'] . '\'');
|
||||
|
||||
while(($alias_domain = $this->db->fetch_array($alias_domains)) !== false)
|
||||
{
|
||||
$server_alias.= ' ' . $alias_domain['domain'];
|
||||
while (($alias_domain = $this->db->fetch_array($alias_domains)) !== false) {
|
||||
$server_alias .= ' ' . $alias_domain['domain'];
|
||||
|
||||
if($alias_domain['iswildcarddomain'] == '1')
|
||||
{
|
||||
$server_alias.= ' *.' . $alias_domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($alias_domain['wwwserveralias'] == '1')
|
||||
{
|
||||
$server_alias.= ' www.' . $alias_domain['domain'];
|
||||
}
|
||||
if ($alias_domain['iswildcarddomain'] == '1') {
|
||||
$server_alias .= ' *.' . $alias_domain['domain'];
|
||||
} elseif ($alias_domain['wwwserveralias'] == '1') {
|
||||
$server_alias.= ' www.' . $alias_domain['domain'];
|
||||
}
|
||||
}
|
||||
|
||||
$servernames_text = "\t".'server_name '.$domain['domain'];
|
||||
if(trim($server_alias) != '')
|
||||
{
|
||||
$servernames_text.= ' '.$server_alias;
|
||||
if (trim($server_alias) != '') {
|
||||
$servernames_text .= ' '.$server_alias;
|
||||
}
|
||||
$servernames_text.= ';' . "\n";
|
||||
$servernames_text .= ';' . "\n";
|
||||
|
||||
return $servernames_text;
|
||||
}
|
||||
@@ -874,8 +796,7 @@ class nginx
|
||||
fwrite($this->debugHandler, ' nginx::writeConfigs: rebuilding ' . $this->settings['system']['apacheconf_vhost'] . "\n");
|
||||
$this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . $this->settings['system']['apacheconf_vhost']);
|
||||
|
||||
if(!isConfigDir($this->settings['system']['apacheconf_vhost']))
|
||||
{
|
||||
if (!isConfigDir($this->settings['system']['apacheconf_vhost'])) {
|
||||
// Save one big file
|
||||
$vhosts_file = '';
|
||||
|
||||
@@ -885,41 +806,32 @@ class nginx
|
||||
// 3. main-domains
|
||||
ksort($this->nginx_data);
|
||||
|
||||
foreach($this->nginx_data as $vhosts_filename => $vhost_content)
|
||||
{
|
||||
foreach ($this->nginx_data as $vhosts_filename => $vhost_content) {
|
||||
$vhosts_file.= $vhost_content . "\n\n";
|
||||
}
|
||||
|
||||
$vhosts_filename = $this->settings['system']['apacheconf_vhost'];
|
||||
|
||||
// Apply header
|
||||
|
||||
$vhosts_file = '# ' . basename($vhosts_filename) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n" . $vhosts_file;
|
||||
$vhosts_file_handler = fopen($vhosts_filename, 'w');
|
||||
fwrite($vhosts_file_handler, $vhosts_file);
|
||||
fclose($vhosts_file_handler);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!file_exists($this->settings['system']['apacheconf_vhost']))
|
||||
{
|
||||
} else {
|
||||
if (!file_exists($this->settings['system']['apacheconf_vhost'])) {
|
||||
fwrite($this->debugHandler, ' nginx::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'])) . "\n");
|
||||
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'])));
|
||||
safe_exec('mkdir -p ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'])));
|
||||
}
|
||||
|
||||
// Write a single file for every vhost
|
||||
|
||||
foreach($this->nginx_data as $vhosts_filename => $vhosts_file)
|
||||
{
|
||||
foreach ($this->nginx_data as $vhosts_filename => $vhosts_file) {
|
||||
$this->known_filenames[] = basename($vhosts_filename);
|
||||
|
||||
// Apply header
|
||||
|
||||
$vhosts_file = '# ' . basename($vhosts_filename) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n" . $vhosts_file;
|
||||
|
||||
if(!empty($vhosts_filename))
|
||||
{
|
||||
if (!empty($vhosts_filename)) {
|
||||
$vhosts_file_handler = fopen($vhosts_filename, 'w');
|
||||
fwrite($vhosts_file_handler, $vhosts_file);
|
||||
fclose($vhosts_file_handler);
|
||||
@@ -931,26 +843,20 @@ class nginx
|
||||
/*
|
||||
* htaccess stuff
|
||||
*/
|
||||
if(count($this->htpasswds_data) > 0)
|
||||
{
|
||||
if(!file_exists($this->settings['system']['apacheconf_htpasswddir']))
|
||||
{
|
||||
if (count($this->htpasswds_data) > 0) {
|
||||
if (!file_exists($this->settings['system']['apacheconf_htpasswddir'])) {
|
||||
$umask = umask();
|
||||
umask(0000);
|
||||
mkdir($this->settings['system']['apacheconf_htpasswddir'], 0751);
|
||||
umask($umask);
|
||||
}
|
||||
elseif(!is_dir($this->settings['system']['apacheconf_htpasswddir']))
|
||||
{
|
||||
} elseif (!is_dir($this->settings['system']['apacheconf_htpasswddir'])) {
|
||||
fwrite($this->debugHandler, ' cron_tasks: WARNING!!! ' . $this->settings['system']['apacheconf_htpasswddir'] . ' is not a directory. htpasswd directory protection is disabled!!!' . "\n");
|
||||
echo 'WARNING!!! ' . $this->settings['system']['apacheconf_htpasswddir'] . ' is not a directory. htpasswd directory protection is disabled!!!';
|
||||
$this->logger->logAction(CRON_ACTION, LOG_WARNING, 'WARNING!!! ' . $this->settings['system']['apacheconf_htpasswddir'] . ' is not a directory. htpasswd directory protection is disabled!!!');
|
||||
}
|
||||
|
||||
if(is_dir($this->settings['system']['apacheconf_htpasswddir']))
|
||||
{
|
||||
foreach($this->htpasswds_data as $htpasswd_filename => $htpasswd_file)
|
||||
{
|
||||
if (is_dir($this->settings['system']['apacheconf_htpasswddir'])) {
|
||||
foreach ($this->htpasswds_data as $htpasswd_filename => $htpasswd_file) {
|
||||
$this->known_htpasswdsfilenames[] = basename($htpasswd_filename);
|
||||
$htpasswd_file_handler = fopen($htpasswd_filename, 'w');
|
||||
fwrite($htpasswd_file_handler, $htpasswd_file);
|
||||
|
||||
Reference in New Issue
Block a user