Merge pull request #93 from Guite/master

Minor coding-style related changes
This commit is contained in:
Michael Kaufmann
2013-04-27 01:05:30 -07:00
14 changed files with 1071 additions and 1920 deletions

View File

@@ -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,57 +49,37 @@ 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;
}
@@ -118,9 +91,7 @@ if($page == 'cronjobs'
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']);
@@ -136,8 +107,7 @@ if($page == 'cronjobs'
// 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
*/

View File

@@ -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 == '')
{
&& $userinfo['change_serversettings'] == '1'
) {
if ($action == '') {
$fields = array(
'date' => $lng['logger']['date'],
'type' => $lng['logger']['type'],
@@ -47,11 +45,10 @@ if($page == 'log'
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$clog = array();
while($row = $db->fetch_array($result))
{
while ($row = $db->fetch_array($result)) {
if (!isset($clog[$row['action']])
|| !is_array($clog[$row['action']]))
{
|| !is_array($clog[$row['action']])
) {
$clog[$row['action']] = array();
}
@@ -59,12 +56,10 @@ if($page == 'log'
}
if ($paging->sortfield == 'date'
&& $paging->sortorder == 'desc')
{
&& $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')
{
eval("echo \"" . getTemplate('logger/logger') . "\";");
} elseif ($action == 'truncate') {
if (isset($_POST['send'])
&& $_POST['send'] == '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);
}
}

View File

@@ -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')
{
&& $_POST['send'] == 'send'
) {
if ($_POST['receipient'] == 0
&& $userinfo['customers_see_all'] == '1')
{
$log->logAction(ADM_ACTION, LOG_NOTICE, "sending messages to admins");
&& $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") . "\";");
eval("echo \"" . getTemplate('message/message') . "\";");
}
?>

View File

@@ -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");
/**
@@ -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')
{
&& $_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;
@@ -99,26 +92,20 @@ if($page == 'overview')
include_once './install/updates/preconfig.php';
$preconfig = getPreConfig($current_version);
if($preconfig != '')
{
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') . "\";");
}
}
?>

View File

@@ -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') . "\";");

View File

@@ -17,18 +17,14 @@
*
*/
// Required code
define('AREA', 'customer');
require ("./lib/init.php");
require('./lib/init.php');
if ($action == 'add') {
// Create new autoresponder
if($action == "add")
{
if (isset($_POST['send'])
&& $_POST['send'] == '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)
|| 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") . "\";");
}
eval("echo \"" . getTemplate('autoresponder/autoresponder_add') . "\";");
} elseif ($action == 'edit') {
// Edit autoresponder
else
if($action == "edit")
{
if (isset($_POST['send'])
&& $_POST['send'] == '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)
|| 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)
{
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") . "\";");
}
eval("echo \"" . getTemplate('autoresponder/autoresponder_edit') . "\";");
} elseif ($action == 'delete') {
// Delete autoresponder
else
if($action == "delete")
{
if (isset($_POST['send'])
&& $_POST['send'] == '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));
}
} else {
// List existing autoresponders
else
{
$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') . "\";");
}

View File

@@ -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'])
{
&& $result['username'] != $userinfo['loginname']
) {
if (isset($_POST['send'])
&& $_POST['send'] == '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)
{
&& (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')
{
} elseif ($action == 'add') {
if ($userinfo['ftps_used'] < $userinfo['ftps']
|| $userinfo['ftps'] == '-1')
{
|| $userinfo['ftps'] == '-1'
) {
if (isset($_POST['send'])
&& $_POST['send'] == '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,40 +229,32 @@ 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'] != '')
{
&& $result['username'] != ''
) {
if (isset($_POST['send'])
&& $_POST['send'] == '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 . "'");
@@ -321,16 +264,12 @@ elseif($page == 'accounts')
$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,29 +280,22 @@ 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))
{
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') . "\";");
}
}
}
}
?>

View File

@@ -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&amp;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')
{
&& $_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)
{
&& $_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'] != '') {
$default_lang = $userinfo['def_language'];
}
while(list($language_file, $language_name) = each($languages))
{
$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'] != '') {
$default_theme = $userinfo['theme'];
}
$theme_options = '';
$themes_avail = getThemes();
foreach($themes_avail as $t)
{
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') . "\";");
}
}

View File

@@ -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,43 +56,35 @@ 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']]))
{
&& $result['databasename'] != ''
) {
if (!isset($sql_root[$result['dbserver']]) || !is_array($sql_root[$result['dbserver']])) {
$result['dbserver'] = 0;
}
if (isset($_POST['send'])
&& $_POST['send'] == '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') {
@@ -109,8 +93,7 @@ elseif($page == 'mysqls')
}
$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,25 +101,15 @@ 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'].')';
@@ -144,44 +117,31 @@ elseif($page == 'mysqls')
ask_yesno('mysql_reallydelete', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $dbnamedesc);
}
}
}
elseif($action == 'add')
{
} elseif ($action == 'add') {
if ($userinfo['mysqls_used'] < $userinfo['mysqls']
|| $userinfo['mysqls'] == '-1')
{
|| $userinfo['mysqls'] == '-1'
) {
if (isset($_POST['send'])
&& $_POST['send'] == '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']]))
{
&& $result['databasename'] != ''
) {
if (!isset($sql_root[$result['dbserver']]) || !is_array($sql_root[$result['dbserver']])) {
$result['dbserver'] = 0;
}
if (isset($_POST['send'])
&& $_POST['send'] == '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') . "\";");
}
}
}
}
?>

View File

@@ -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']))
{
&& 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,22 +43,16 @@ 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');
}
@@ -67,8 +60,7 @@ elseif (isset($_GET['page'])
}
if (!is_null($month)
&& !is_null($year))
{
&& !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,8 +74,7 @@ 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'];
@@ -91,10 +82,9 @@ if(!is_null($month)
$traffic_complete['http'] += $http;
$traffic_complete['ftp'] += $ftp;
$traffic_complete['mail'] += $mail;
$traf['day'] = $row['day'] . ".";
$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,8 +125,7 @@ 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'];
@@ -157,8 +138,7 @@ else
$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') . "\";");
}
?>

216
index.php
View File

@@ -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 ($action == 'login') {
if (isset($_POST['send'])
&& $_POST['send'] == '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;
}
@@ -130,24 +98,18 @@ 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']))
{
&& $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);
@@ -155,38 +117,28 @@ if($action == 'login')
}
if (isset($userinfo['userid'])
&& $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'] != '') {
$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']) . "'");
}
@@ -204,38 +156,24 @@ if($action == 'login')
$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
{
} else {
$language_options = '';
$language_options .= makeoption($lng['login']['profile_lng'], 'profile', 'profile', true, true);
while(list($language_file, $language_name) = each($languages))
{
while (list($language_file, $language_name) = each($languages)) {
$language_options .= makeoption($language_name, $language_file, 'profile', true);
}
@@ -243,8 +181,7 @@ if($action == 'login')
$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')
{
&& $_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)
{
|| $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) . "'
$passwordTable = $adminchecked ? TABLE_PANEL_ADMINS : TABLE_PANEL_CUSTOMERS;
$db->query("UPDATE `" . $passwordTable . "` 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'] . "'");
}
$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') . "\";");
}

View File

@@ -82,8 +82,7 @@ class apache
private function _createStandardDirectoryEntry()
{
$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']));
@@ -94,17 +93,13 @@ class apache
|| $this->settings['phpfpm']['enabled'] == '1'
) {
// if we use fcgid or php-fpm we don't need this file
if(file_exists($vhosts_filename))
{
if (file_exists($vhosts_filename)) {
fwrite($this->debugHandler, ' apache::_createStandardDirectoryEntry: unlinking ' . basename($vhosts_filename) . "\n");
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'unlinking ' . basename($vhosts_filename));
unlink(makeCorrectFile($vhosts_filename));
}
}
else
{
if(!isset($this->virtualhosts_data[$vhosts_filename]))
{
} else {
if (!isset($this->virtualhosts_data[$vhosts_filename])) {
$this->virtualhosts_data[$vhosts_filename] = '';
}
@@ -132,8 +127,7 @@ class apache
|| $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']));
@@ -141,43 +135,20 @@ class apache
$vhosts_filename = makeCorrectFile($vhosts_folder . '/05_froxlor_default_errorhandler.conf');
if(!isset($this->virtualhosts_data[$vhosts_filename]))
{
if (!isset($this->virtualhosts_data[$vhosts_filename])) {
$this->virtualhosts_data[$vhosts_filename] = '';
}
if ($this->settings['defaultwebsrverrhandler']['err401'] != '') {
$defhandler = $this->settings['defaultwebsrverrhandler']['err401'];
$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->virtualhosts_data[$vhosts_filename].= 'ErrorDocument 401 "' . $defhandler . '"'."\n";
$this->virtualhosts_data[$vhosts_filename] .= 'ErrorDocument ' . $statusCode . ' "' . $defhandler . '"'."\n";
}
if ($this->settings['defaultwebsrverrhandler']['err403'] != '') {
$defhandler = $this->settings['defaultwebsrverrhandler']['err403'];
if (!validateUrl($defhandler)) {
$defhandler = makeCorrectFile($defhandler);
}
$this->virtualhosts_data[$vhosts_filename].= 'ErrorDocument 403 "' . $defhandler . '"' . "\n";
}
if ($this->settings['defaultwebsrverrhandler']['err404'] != '') {
$defhandler = $this->settings['defaultwebsrverrhandler']['err404'];
if (!validateUrl($defhandler)) {
$defhandler = makeCorrectFile($defhandler);
}
$this->virtualhosts_data[$vhosts_filename].= 'ErrorDocument 404 "' . $defhandler . '"' . "\n";
}
if ($this->settings['defaultwebsrverrhandler']['err500'] != '') {
$defhandler = $this->settings['defaultwebsrverrhandler']['err500'];
if (!validateUrl($defhandler)) {
$defhandler = makeCorrectFile($defhandler);
}
$this->virtualhosts_data[$vhosts_filename].= 'ErrorDocument 500 "' . $defhandler . '"' . "\n";
}
}
}
@@ -185,14 +156,10 @@ class apache
{
$result_ipsandports = $this->db->query("SELECT * FROM `" . TABLE_PANEL_IPSANDPORTS . "` ORDER BY `ip` ASC, `port` ASC");
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)) {
$ipport = '[' . $row_ipsandports['ip'] . ']:' . $row_ipsandports['port'];
}
else
{
} else {
$ipport = $row_ipsandports['ip'] . ':' . $row_ipsandports['port'];
}
@@ -200,19 +167,16 @@ class apache
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'creating ip/port settings for ' . $ipport);
$vhosts_filename = makeCorrectFile($this->settings['system']['apacheconf_vhost'] . '/10_froxlor_ipandport_' . trim(str_replace(':', '.', $row_ipsandports['ip']), '.') . '.' . $row_ipsandports['port'] . '.conf');
if(!isset($this->virtualhosts_data[$vhosts_filename]))
{
if (!isset($this->virtualhosts_data[$vhosts_filename])) {
$this->virtualhosts_data[$vhosts_filename] = '';
}
if($row_ipsandports['listen_statement'] == '1')
{
if ($row_ipsandports['listen_statement'] == '1') {
$this->virtualhosts_data[$vhosts_filename] .= 'Listen ' . $ipport . "\n";
$this->logger->logAction(CRON_ACTION, LOG_DEBUG, $ipport . ' :: inserted listen-statement');
}
if($row_ipsandports['namevirtualhost_statement'] == '1')
{
if ($row_ipsandports['namevirtualhost_statement'] == '1') {
// >=apache-2.4 enabled?
if ($this->settings['system']['apache24'] == '1') {
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, $ipport . ' :: namevirtualhost-statement no longer needed for apache-2.4');
@@ -222,52 +186,39 @@ class apache
}
}
if($row_ipsandports['vhostcontainer'] == '1')
{
if ($row_ipsandports['vhostcontainer'] == '1') {
$this->virtualhosts_data[$vhosts_filename] .= '<VirtualHost ' . $ipport . '>' . "\n";
if($row_ipsandports['docroot'] == '')
{
if ($row_ipsandports['docroot'] == '') {
/**
* add 'real'-vhost content here, like doc-root :)
*/
if($this->settings['system']['froxlordirectlyviahostname'])
{
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']);
}
$this->virtualhosts_data[$vhosts_filename] .= 'DocumentRoot "'.$mypath.'"'."\n";
if($row_ipsandports['vhostcontainer_servername_statement'] == '1')
{
if ($row_ipsandports['vhostcontainer_servername_statement'] == '1') {
$this->virtualhosts_data[$vhosts_filename] .= ' ServerName ' . $this->settings['system']['hostname'] . "\n";
}
// create fcgid <Directory>-Part (starter is created in apache_fcgid)
if ($this->settings['system']['mod_fcgid_ownvhost'] == '1'
&& $this->settings['system']['mod_fcgid'] == '1'
)
{
) {
$configdir = makeCorrectDir($this->settings['system']['mod_fcgid_configdir'] . '/froxlor.panel/' . $this->settings['system']['hostname']);
$this->virtualhosts_data[$vhosts_filename] .= ' FcgidIdleTimeout ' . $this->settings['system']['mod_fcgid_idle_timeout'] . "\n";
if((int)$this->settings['system']['mod_fcgid_wrapper'] == 0)
{
if ((int)$this->settings['system']['mod_fcgid_wrapper'] == 0) {
$this->virtualhosts_data[$vhosts_filename] .= ' SuexecUserGroup "' . $this->settings['system']['mod_fcgid_httpuser'] . '" "' . $this->settings['system']['mod_fcgid_httpgroup'] . '"' . "\n";
$this->virtualhosts_data[$vhosts_filename] .= ' ScriptAlias /php/ ' . $configdir . "\n";
}
else
{
} else {
$starter_filename = makeCorrectFile($configdir . '/php-fcgi-starter');
$this->virtualhosts_data[$vhosts_filename] .= ' SuexecUserGroup "' . $this->settings['system']['mod_fcgid_httpuser'] . '" "' . $this->settings['system']['mod_fcgid_httpgroup'] . '"' . "\n";
$this->virtualhosts_data[$vhosts_filename] .= ' <Directory "' . $mypath . '">' . "\n";
@@ -285,8 +236,7 @@ class apache
}
}
// create php-fpm <Directory>-Part (config is created in apache_fcgid)
elseif($this->settings['phpfpm']['enabled'] == '1')
{
elseif ($this->settings['phpfpm']['enabled'] == '1') {
$domain = array(
'id' => 'none',
'domain' => $this->settings['system']['hostname'],
@@ -337,52 +287,42 @@ class apache
* end of dirprotection
*/
if($row_ipsandports['specialsettings'] != '')
{
if ($row_ipsandports['specialsettings'] != '') {
$this->virtualhosts_data[$vhosts_filename] .= $row_ipsandports['specialsettings'] . "\n";
}
if($row_ipsandports['ssl'] == '1' && $this->settings['system']['use_ssl'] == '1')
{
if($row_ipsandports['ssl_cert_file'] == '')
{
if ($row_ipsandports['ssl'] == '1' && $this->settings['system']['use_ssl'] == '1') {
if ($row_ipsandports['ssl_cert_file'] == '') {
$row_ipsandports['ssl_cert_file'] = $this->settings['system']['ssl_cert_file'];
}
if($row_ipsandports['ssl_key_file'] == '')
{
if ($row_ipsandports['ssl_key_file'] == '') {
$row_ipsandports['ssl_key_file'] = $this->settings['system']['ssl_key_file'];
}
if($row_ipsandports['ssl_ca_file'] == '')
{
if ($row_ipsandports['ssl_ca_file'] == '') {
$row_ipsandports['ssl_ca_file'] = $this->settings['system']['ssl_ca_file'];
}
// #418
if($row_ipsandports['ssl_cert_chainfile'] == '')
{
if ($row_ipsandports['ssl_cert_chainfile'] == '') {
$row_ipsandports['ssl_cert_chainfile'] = $this->settings['system']['ssl_cert_chainfile'];
}
if($row_ipsandports['ssl_cert_file'] != '')
{
if ($row_ipsandports['ssl_cert_file'] != '') {
$this->virtualhosts_data[$vhosts_filename] .= ' SSLEngine On' . "\n";
$this->virtualhosts_data[$vhosts_filename] .= ' SSLCertificateFile ' . makeCorrectFile($row_ipsandports['ssl_cert_file']) . "\n";
if($row_ipsandports['ssl_key_file'] != '')
{
if ($row_ipsandports['ssl_key_file'] != '') {
$this->virtualhosts_data[$vhosts_filename] .= ' SSLCertificateKeyFile ' . makeCorrectFile($row_ipsandports['ssl_key_file']) . "\n";
}
if($row_ipsandports['ssl_ca_file'] != '')
{
if ($row_ipsandports['ssl_ca_file'] != '') {
$this->virtualhosts_data[$vhosts_filename] .= ' SSLCACertificateFile ' . makeCorrectFile($row_ipsandports['ssl_ca_file']) . "\n";
}
// #418
if($row_ipsandports['ssl_cert_chainfile'] != '')
{
if ($row_ipsandports['ssl_cert_chainfile'] != '') {
$this->virtualhosts_data[$vhosts_filename] .= ' SSLCertificateChainFile ' . makeCorrectFile($row_ipsandports['ssl_cert_chainfile']) . "\n";
}
}
@@ -413,32 +353,20 @@ class apache
{
$php_options_text = '';
if($domain['phpenabled'] == '1')
{
if ($domain['phpenabled'] == '1') {
// This vHost has PHP enabled and we are using the regular mod_php
if($domain['openbasedir'] == '1')
{
if($domain['openbasedir_path'] == '1' || strstr($domain['documentroot'], ":") !== false)
{
if ($domain['openbasedir'] == '1') {
$_phpappendopenbasedir = appendOpenBasedirPath($domain['customerroot'], true);
}
else
{
$_phpappendopenbasedir = appendOpenBasedirPath($domain['documentroot'], true);
}
$_custom_openbasedir = explode(':', $this->settings['system']['phpappendopenbasedir']);
foreach($_custom_openbasedir as $cobd)
{
foreach ($_custom_openbasedir as $cobd) {
$_phpappendopenbasedir .= appendOpenBasedirPath($cobd);
}
$php_options_text .= ' php_admin_value open_basedir "' . $_phpappendopenbasedir . '"'."\n";
}
}
else
{
} else {
$php_options_text .= ' # PHP is disabled for this vHost' . "\n";
$php_options_text .= ' php_flag engine off' . "\n";
}
@@ -453,47 +381,30 @@ class apache
/*
* We collect all servernames and Aliases
*/
protected function getServerNames($domain)
{
$servernames_text = '';
$servernames_text.= ' ServerName ' . $domain['domain'] . "\n";
$servernames_text = ' ServerName ' . $domain['domain'] . "\n";
if($domain['iswildcarddomain'] == '1')
{
$server_alias = '';
if ($domain['iswildcarddomain'] == '1') {
$server_alias = '*.' . $domain['domain'];
}
else
{
if($domain['wwwserveralias'] == '1')
{
} elseif ($domain['wwwserveralias'] == '1') {
$server_alias = 'www.' . $domain['domain'];
}
else
{
$server_alias = '';
}
}
if(trim($server_alias) != '')
{
if (trim($server_alias) != '') {
$servernames_text .= ' ServerAlias ' . $server_alias . "\n";
}
$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) {
$server_alias = ' ServerAlias ' . $alias_domain['domain'];
if($alias_domain['iswildcarddomain'] == '1')
{
if ($alias_domain['iswildcarddomain'] == '1') {
$server_alias .= ' *.' . $alias_domain['domain'];
}
else
{
if($alias_domain['wwwserveralias'] == '1')
{
} else {
if ($alias_domain['wwwserveralias'] == '1') {
$server_alias .= ' www.' . $alias_domain['domain'];
}
}
@@ -508,7 +419,6 @@ class apache
/*
* Let's get the webroot
*/
protected function getWebroot($domain)
{
$webroot_text = '';
@@ -516,14 +426,12 @@ class apache
$domain['documentroot'] = makeCorrectDir($domain['documentroot']);
if ($domain['deactivated'] == '1'
&& $this->settings['system']['deactivateddocroot'] != '')
{
&& $this->settings['system']['deactivateddocroot'] != ''
) {
$webroot_text .= ' # Using docroot for deactivated users...' . "\n";
$webroot_text .= ' DocumentRoot "' . makeCorrectDir($this->settings['system']['deactivateddocroot']) . "\"\n";
$this->_deactivated = true;
}
else
{
} else {
$webroot_text .= ' DocumentRoot "' . $domain['documentroot'] . "\"\n";
$this->_deactivated = false;
}
@@ -534,29 +442,17 @@ class apache
/*
* Lets set the text part for the stats software
*/
protected function getStats($domain)
{
$stats_text = '';
if ($domain['speciallogfile'] == '1') {
if ($domain['parentdomainid'] == '0') {
$statDomain = ($domain['parentdomainid'] == '0') ? $domain['domain'] : $domain['parentdomain'];
if ($this->settings['system']['awstats_enabled'] == '1') {
$stats_text.= ' Alias /awstats "' . makeCorrectFile($domain['customerroot'] . '/awstats/' . $domain['domain']) . '"' . "\n";
$stats_text .= ' Alias /awstats "' . makeCorrectFile($domain['customerroot'] . '/awstats/' . $statDomain) . '"' . "\n";
$stats_text .= ' Alias /awstats-icon "' . makeCorrectDir($this->settings['system']['awstats_icons']) . '"' . "\n";
} else {
$stats_text.= ' Alias /webalizer "' . makeCorrectFile($domain['customerroot'] . '/webalizer/' . $domain['domain']) . '"' . "\n";
}
} else {
if ($this->settings['system']['awstats_enabled'] == '1') {
$stats_text.= ' Alias /awstats "' . makeCorrectFile($domain['customerroot'] . '/awstats/' . $domain['parentdomain']) . '"' . "\n";
$stats_text.= ' Alias /awstats-icon "' . makeCorrectDir($this->settings['system']['awstats_icons']) . '"' . "\n";
} else {
$stats_text.= ' Alias /webalizer "' . makeCorrectFile($domain['customerroot'] . '/webalizer/' . $domain['parentdomain']) . '"' . "\n";
}
$stats_text .= ' Alias /webalizer "' . makeCorrectFile($domain['customerroot'] . '/webalizer/' . $statDomain) . '"' . "\n";
}
} else {
if ($domain['customerroot'] != $domain['documentroot']) {
@@ -627,23 +523,16 @@ class apache
if ($alias_domain['iswildcarddomain'] == '1') {
$server_alias .= '*.' . $alias_domain['domain'];
} else {
if ($alias_domain['wwwserveralias'] == '1') {
} elseif ($alias_domain['wwwserveralias'] == '1') {
$server_alias .= 'www.' . $alias_domain['domain'];
} else {
$server_alias.= '';
}
}
}
$alias = '';
if ($domain['iswildcarddomain'] == '1') {
$alias = '*.' . $domain['domain'];
} else {
if ($domain['wwwserveralias'] == '1') {
} elseif ($domain['wwwserveralias'] == '1') {
$alias = 'www.' . $domain['domain'];
} else {
$alias = '';
}
}
// After inserting the AWStats information,
@@ -660,7 +549,6 @@ class apache
/*
* Get the filename for the virtualhost
*/
protected function getVhostFilename($domain, $ssl_vhost = false)
{
if ((int)$domain['parentdomainid'] == 0
@@ -669,24 +557,18 @@ class apache
|| domainMainToSubExists($domain['ismainbutsubto']) == false)
) {
$vhost_no = '22';
}
elseif((int)$domain['parentdomainid'] == 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');
}
@@ -696,22 +578,19 @@ class apache
/*
* We compose the virtualhost entry for one domain
*/
protected function getVhostContent($domain, $ssl_vhost = false)
{
if ($ssl_vhost === true
&& $domain['ssl'] != '1')
{
&& $domain['ssl'] != '1'
) {
return '';
}
if ($ssl_vhost === true
&& $domain['ssl'] == '1')
{
&& $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'] . "'";
}
@@ -724,12 +603,9 @@ class apache
// #418
$domain['ssl_cert_chainfile'] = $ipandport['ssl_cert_chainfile'];
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'];
}
@@ -738,61 +614,52 @@ class apache
if ($ssl_vhost == false
&& $domain['ssl'] == '1'
&& $domain['ssl_redirect'] == '1')
{
&& $domain['ssl_redirect'] == '1'
) {
$domain['documentroot'] = 'https://' . $domain['domain'] . '/';
}
if ($ssl_vhost === true
&& $domain['ssl'] == '1'
&& $this->settings['system']['use_ssl'] == '1')
{
if($domain['ssl_cert_file'] == '')
{
&& $this->settings['system']['use_ssl'] == '1'
) {
if ($domain['ssl_cert_file'] == '') {
$domain['ssl_cert_file'] = $this->settings['system']['ssl_cert_file'];
}
if($domain['ssl_key_file'] == '')
{
if ($domain['ssl_key_file'] == '') {
$domain['ssl_key_file'] = $this->settings['system']['ssl_key_file'];
}
if($domain['ssl_ca_file'] == '')
{
if ($domain['ssl_ca_file'] == '') {
$domain['ssl_ca_file'] = $this->settings['system']['ssl_ca_file'];
}
// #418
if($domain['ssl_cert_chainfile'] == '')
{
if ($domain['ssl_cert_chainfile'] == '') {
$domain['ssl_cert_chainfile'] = $this->settings['system']['ssl_cert_chainfile'];
}
if($domain['ssl_cert_file'] != '')
{
if ($domain['ssl_cert_file'] != '') {
$vhost_content .= ' SSLEngine On' . "\n";
$vhost_content .= ' SSLCertificateFile ' . makeCorrectFile($domain['ssl_cert_file']) . "\n";
if($domain['ssl_key_file'] != '')
{
if ($domain['ssl_key_file'] != '') {
$vhost_content .= ' SSLCertificateKeyFile ' . makeCorrectFile($domain['ssl_key_file']) . "\n";
}
if($domain['ssl_ca_file'] != '')
{
if ($domain['ssl_ca_file'] != '') {
$vhost_content .= ' SSLCACertificateFile ' . makeCorrectFile($domain['ssl_ca_file']) . "\n";
}
// #418
if($domain['ssl_cert_chainfile'] != '')
{
if ($domain['ssl_cert_chainfile'] != '') {
$vhost_content .= ' SSLCertificateChainFile ' . makeCorrectFile($domain['ssl_cert_chainfile']) . "\n";
}
}
}
if(preg_match('/^https?\:\/\//', $domain['documentroot']))
{
if (preg_match('/^https?\:\/\//', $domain['documentroot'])) {
$corrected_docroot = $this->idnaConvert->encode($domain['documentroot']);
if (substr($corrected_docroot, -1) == '/') {
$corrected_docroot = substr($corrected_docroot, 0, -1);
@@ -814,9 +681,7 @@ class apache
$code = getDomainRedirectCode($domain['id']);
$vhost_content .= ' Redirect '.$code.' / ' . $this->idnaConvert->encode($domain['documentroot']) . "\n";
}
else
{
} else {
mkDirWithCorrectOwnership($domain['customerroot'], $domain['documentroot'], $domain['guid'], $domain['guid'], true, true);
$vhost_content .= $this->getWebroot($domain);
if ($this->_deactivated == false) {
@@ -845,37 +710,30 @@ class apache
/*
* We compose the virtualhost entries for the domains
*/
public function createVirtualHosts()
{
$result_domains = $this->db->query("SELECT `d`.*, `pd`.`domain` AS `parentdomain`, `c`.`loginname`, `d`.`phpsettingid`, `c`.`adminid`, `c`.`guid`, `c`.`email`, `c`.`documentroot` AS `customerroot`, `c`.`deactivated`, `c`.`phpenabled` AS `phpenabled`, `d`.`mod_fcgid_starter`, `d`.`mod_fcgid_maxrequests` 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`.`aliasdomain` IS NULL AND `d`.`email_only` <> 1 ORDER BY `d`.`parentdomainid` DESC, `d`.`iswildcarddomain`, `d`.`domain` ASC");
while($domain = $this->db->fetch_array($result_domains))
{
while ($domain = $this->db->fetch_array($result_domains)) {
fwrite($this->debugHandler, ' apache::createVirtualHosts: creating vhost container for domain ' . $domain['id'] . ', customer ' . $domain['loginname'] . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'creating vhost container for domain ' . $domain['id'] . ', customer ' . $domain['loginname']);
$vhosts_filename = $this->getVhostFilename($domain);
// Apply header
$this->virtualhosts_data[$vhosts_filename] = '# Domain ID: ' . $domain['id'] . ' - CustomerID: ' . $domain['customerid'] . ' - CustomerLogin: ' . $domain['loginname'] . "\n";
if ($domain['deactivated'] != '1'
|| $this->settings['system']['deactivateddocroot'] != '')
{
|| $this->settings['system']['deactivateddocroot'] != ''
) {
$this->virtualhosts_data[$vhosts_filename].= $this->getVhostContent($domain);
if($domain['ssl'] == '1')
{
if ($domain['ssl'] == '1') {
// Adding ssl stuff if enabled
$vhosts_filename_ssl = $this->getVhostFilename($domain, true);
$this->virtualhosts_data[$vhosts_filename_ssl] = '# Domain ID: ' . $domain['id'] . ' (SSL) - CustomerID: ' . $domain['customerid'] . ' - CustomerLogin: ' . $domain['loginname'] . "\n";
$this->virtualhosts_data[$vhosts_filename_ssl] .= $this->getVhostContent($domain, true);
}
}
else
{
} else {
$this->virtualhosts_data[$vhosts_filename] .= '# Customer deactivated and a docroot for deactivated users hasn\'t been set.' . "\n";
}
}
@@ -884,18 +742,16 @@ class apache
/*
* We compose the diroption entries for the paths
*/
public function createFileDirOptions()
{
$result = $this->db->query('SELECT `htac`.*, `c`.`guid`, `c`.`documentroot` AS `customerroot` FROM `' . TABLE_PANEL_HTACCESS . '` `htac` LEFT JOIN `' . TABLE_PANEL_CUSTOMERS . '` `c` USING (`customerid`) ORDER BY `htac`.`path`');
$diroptions = array();
while($row_diroptions = $this->db->fetch_array($result))
{
while ($row_diroptions = $this->db->fetch_array($result)) {
if ($row_diroptions['customerid'] != 0
&& isset($row_diroptions['customerroot'])
&& $row_diroptions['customerroot'] != '')
{
&& $row_diroptions['customerroot'] != ''
) {
$diroptions[$row_diroptions['path']] = $row_diroptions;
$diroptions[$row_diroptions['path']]['htpasswds'] = array();
}
@@ -903,14 +759,12 @@ class apache
$result = $this->db->query('SELECT `htpw`.*, `c`.`guid`, `c`.`documentroot` AS `customerroot` FROM `' . TABLE_PANEL_HTPASSWDS . '` `htpw` LEFT JOIN `' . TABLE_PANEL_CUSTOMERS . '` `c` USING (`customerid`) ORDER BY `htpw`.`path`, `htpw`.`username`');
while($row_htpasswds = $this->db->fetch_array($result))
{
while ($row_htpasswds = $this->db->fetch_array($result)) {
if ($row_htpasswds['customerid'] != 0
&& isset($row_htpasswds['customerroot'])
&& $row_htpasswds['customerroot'] != '')
{
if(!isset($diroptions[$row_htpasswds['path']]) || !is_array($diroptions[$row_htpasswds['path']]))
{
&& $row_htpasswds['customerroot'] != ''
) {
if (!isset($diroptions[$row_htpasswds['path']]) || !is_array($diroptions[$row_htpasswds['path']])) {
$diroptions[$row_htpasswds['path']] = array();
}
@@ -922,33 +776,30 @@ class apache
}
}
foreach($diroptions as $row_diroptions)
{
foreach ($diroptions as $row_diroptions) {
$row_diroptions['path'] = makeCorrectDir($row_diroptions['path']);
mkDirWithCorrectOwnership($row_diroptions['customerroot'], $row_diroptions['path'], $row_diroptions['guid'], $row_diroptions['guid']);
$diroptions_filename = makeCorrectFile($this->settings['system']['apacheconf_diroptions'] . '/40_froxlor_diroption_' . md5($row_diroptions['path']) . '.conf');
if(!isset($this->diroptions_data[$diroptions_filename]))
{
if (!isset($this->diroptions_data[$diroptions_filename])) {
$this->diroptions_data[$diroptions_filename] = '';
}
if(is_dir($row_diroptions['path']))
{
if (is_dir($row_diroptions['path'])) {
$cperlenabled = customerHasPerlEnabled($row_diroptions['customerid']);
$this->diroptions_data[$diroptions_filename] .= '<Directory "' . $row_diroptions['path'] . '">' . "\n";
if (isset($row_diroptions['options_indexes'])
&& $row_diroptions['options_indexes'] == '1')
{
&& $row_diroptions['options_indexes'] == '1'
) {
$this->diroptions_data[$diroptions_filename] .= ' Options +Indexes';
// add perl options if enabled
if ($cperlenabled
&& isset($row_diroptions['options_cgi'])
&& $row_diroptions['options_cgi'] == '1')
{
&& $row_diroptions['options_cgi'] == '1'
) {
$this->diroptions_data[$diroptions_filename] .= ' ExecCGI -MultiViews +SymLinksIfOwnerMatch +FollowSymLinks'."\n";
} else {
$this->diroptions_data[$diroptions_filename] .= "\n";
@@ -957,15 +808,15 @@ class apache
}
if (isset($row_diroptions['options_indexes'])
&& $row_diroptions['options_indexes'] == '0')
{
&& $row_diroptions['options_indexes'] == '0'
) {
$this->diroptions_data[$diroptions_filename] .= ' Options -Indexes';
// add perl options if enabled
if ($cperlenabled
&& isset($row_diroptions['options_cgi'])
&& $row_diroptions['options_cgi'] == '1')
{
&& $row_diroptions['options_cgi'] == '1'
) {
$this->diroptions_data[$diroptions_filename] .= ' ExecCGI -MultiViews +SymLinksIfOwnerMatch +FollowSymLinks'."\n";
} else {
$this->diroptions_data[$diroptions_filename] .= "\n";
@@ -973,40 +824,23 @@ class apache
fwrite($this->debugHandler, ' cron_tasks: Task3 - Setting Options -Indexes' . "\n");
}
if (isset($row_diroptions['error404path'])
&& $row_diroptions['error404path'] != ''
$statusCodes = array('404', '403', '500');
foreach ($statusCodes as $statusCode) {
if (isset($row_diroptions['error' . $statusCode . 'path'])
&& $row_diroptions['error' . $statusCode . 'path'] != ''
) {
$defhandler = $row_diroptions['error404path'];
$defhandler = $row_diroptions['error' . $statusCode . 'path'];
if (!validateUrl($defhandler)) {
$defhandler = makeCorrectFile($defhandler);
}
$this->diroptions_data[$diroptions_filename].= ' ErrorDocument 404 "' . $defhandler. '"' . "\n";
$this->diroptions_data[$diroptions_filename].= ' ErrorDocument ' . $statusCode . ' "' . $defhandler. '"' . "\n";
}
if (isset($row_diroptions['error403path'])
&& $row_diroptions['error403path'] != ''
) {
$defhandler = $row_diroptions['error403path'];
if (!validateUrl($defhandler)) {
$defhandler = makeCorrectFile($defhandler);
}
$this->diroptions_data[$diroptions_filename].= ' ErrorDocument 403 "' . $defhandler . '"' . "\n";
}
if (isset($row_diroptions['error500path'])
&& $row_diroptions['error500path'] != ''
) {
$defhandler = $row_diroptions['error500path'];
if (!validateUrl($defhandler)) {
$defhandler = makeCorrectFile($defhandler);
}
$this->diroptions_data[$diroptions_filename].= ' ErrorDocument 500 "' . $defhandler . '"' . "\n";
}
if ($cperlenabled
&& isset($row_diroptions['options_cgi'])
&& $row_diroptions['options_cgi'] == '1')
{
&& $row_diroptions['options_cgi'] == '1'
) {
$this->diroptions_data[$diroptions_filename] .= ' AllowOverride None' . "\n";
$this->diroptions_data[$diroptions_filename] .= ' AddHandler cgi-script .cgi .pl' . "\n";
// >=apache-2.4 enabled?
@@ -1019,14 +853,12 @@ class apache
fwrite($this->debugHandler, ' cron_tasks: Task3 - Enabling perl execution' . "\n");
// check for suexec-workaround, #319
if((int)$this->settings['perl']['suexecworkaround'] == 1)
{
if ((int)$this->settings['perl']['suexecworkaround'] == 1) {
// symlink this directory to suexec-safe-path
$loginname = getCustomerDetail($row_diroptions['customerid'], 'loginname');
$suexecpath = makeCorrectDir($this->settings['perl']['suexecpath'].'/'.$loginname.'/'.md5($row_diroptions['path']).'/');
if(!file_exists($suexecpath))
{
if (!file_exists($suexecpath)) {
safe_exec('mkdir -p '.escapeshellarg($suexecpath));
safe_exec('chown -R '.escapeshellarg($row_diroptions['guid']).':'.escapeshellarg($row_diroptions['guid']).' '.escapeshellarg($suexecpath));
}
@@ -1034,47 +866,38 @@ class apache
// symlink to {$givenpath}/cgi-bin
// NOTE: symlinks are FILES, so do not append a / here
$perlsymlink = makeCorrectFile($row_diroptions['path'].'/cgi-bin');
if(!file_exists($perlsymlink))
{
if (!file_exists($perlsymlink)) {
safe_exec('ln -s '.escapeshellarg($suexecpath).' '.escapeshellarg($perlsymlink));
}
safe_exec('chown '.escapeshellarg($row_diroptions['guid']).':'.escapeshellarg($row_diroptions['guid']).' '.escapeshellarg($perlsymlink));
}
}
else
{
} else {
// if no perl-execution is enabled but the workaround is,
// we have to remove the symlink and folder in suexecpath
if((int)$this->settings['perl']['suexecworkaround'] == 1)
{
if ((int)$this->settings['perl']['suexecworkaround'] == 1) {
$loginname = getCustomerDetail($row_diroptions['customerid'], 'loginname');
$suexecpath = makeCorrectDir($this->settings['perl']['suexecpath'].'/'.$loginname.'/'.md5($row_diroptions['path']).'/');
$perlsymlink = makeCorrectFile($row_diroptions['path'].'/cgi-bin');
// remove symlink
if(file_exists($perlsymlink))
{
if (file_exists($perlsymlink)) {
safe_exec('rm -f '.escapeshellarg($perlsymlink));
}
// remove folder in suexec-path
if(file_exists($suexecpath))
{
if (file_exists($suexecpath)) {
safe_exec('rm -rf '.escapeshellarg($suexecpath));
}
}
}
if(count($row_diroptions['htpasswds']) > 0)
{
if (count($row_diroptions['htpasswds']) > 0) {
$htpasswd_filename = makeCorrectFile($this->settings['system']['apacheconf_htpasswddir'] . '/' . $row_diroptions['customerid'] . '-' . md5($row_diroptions['path']) . '.htpasswd');
if(!isset($this->htpasswds_data[$htpasswd_filename]))
{
if (!isset($this->htpasswds_data[$htpasswd_filename])) {
$this->htpasswds_data[$htpasswd_filename] = '';
}
foreach($row_diroptions['htpasswds'] as $row_htpasswd)
{
foreach ($row_diroptions['htpasswds'] as $row_htpasswd) {
$this->htpasswds_data[$htpasswd_filename] .= $row_htpasswd['username'] . ':' . $row_htpasswd['password'] . "\n";
}
@@ -1092,7 +915,6 @@ class apache
/*
* We write the configs
*/
public function writeConfigs()
{
// Write diroptions
@@ -1100,16 +922,13 @@ class apache
fwrite($this->debugHandler, ' apache::writeConfigs: rebuilding ' . $this->settings['system']['apacheconf_diroptions'] . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . $this->settings['system']['apacheconf_diroptions']);
if(count($this->diroptions_data) > 0)
{
if(!isConfigDir($this->settings['system']['apacheconf_diroptions']))
{
if (count($this->diroptions_data) > 0) {
if (!isConfigDir($this->settings['system']['apacheconf_diroptions'])) {
// Save one big file
$diroptions_file = '';
foreach($this->diroptions_data as $diroptions_filename => $diroptions_content)
{
foreach ($this->diroptions_data as $diroptions_filename => $diroptions_content) {
$diroptions_file.= $diroptions_content . "\n\n";
}
@@ -1121,11 +940,8 @@ class apache
$diroptions_file_handler = fopen($diroptions_filename, 'w');
fwrite($diroptions_file_handler, $diroptions_file);
fclose($diroptions_file_handler);
}
else
{
if(!file_exists($this->settings['system']['apacheconf_diroptions']))
{
} else {
if (!file_exists($this->settings['system']['apacheconf_diroptions'])) {
fwrite($this->debugHandler, ' apache::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_diroptions'])) . "\n");
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_diroptions'])));
safe_exec('mkdir ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_diroptions'])));
@@ -1133,12 +949,10 @@ class apache
// Write a single file for every diroption
foreach($this->diroptions_data as $diroptions_filename => $diroptions_file)
{
foreach ($this->diroptions_data as $diroptions_filename => $diroptions_file) {
$this->known_diroptionsfilenames[] = basename($diroptions_filename);
// Apply header
$diroptions_file = '# ' . basename($diroptions_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" . $diroptions_file;
$diroptions_file_handler = fopen($diroptions_filename, 'w');
fwrite($diroptions_file_handler, $diroptions_file);
@@ -1152,28 +966,22 @@ class apache
fwrite($this->debugHandler, ' apache::writeConfigs: rebuilding ' . $this->settings['system']['apacheconf_htpasswddir'] . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . $this->settings['system']['apacheconf_htpasswddir']);
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);
}
if(isConfigDir($this->settings['system']['apacheconf_htpasswddir'], true))
{
foreach($this->htpasswds_data as $htpasswd_filename => $htpasswd_file)
{
if (isConfigDir($this->settings['system']['apacheconf_htpasswddir'], true)) {
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);
fclose($htpasswd_file_handler);
}
}
else
{
} else {
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!!!');
@@ -1185,10 +993,8 @@ class apache
fwrite($this->debugHandler, ' apache::writeConfigs: rebuilding ' . $this->settings['system']['apacheconf_vhost'] . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . $this->settings['system']['apacheconf_vhost']);
if(count($this->virtualhosts_data) > 0)
{
if(!isConfigDir($this->settings['system']['apacheconf_vhost']))
{
if (count($this->virtualhosts_data) > 0) {
if (!isConfigDir($this->settings['system']['apacheconf_vhost'])) {
// Save one big file
$vhosts_file = '';
@@ -1199,44 +1005,35 @@ class apache
// #437
ksort($this->virtualhosts_data);
foreach($this->virtualhosts_data as $vhosts_filename => $vhost_content)
{
foreach ($this->virtualhosts_data as $vhosts_filename => $vhost_content) {
$vhosts_file.= $vhost_content . "\n\n";
}
// Include diroptions file in case it exists
if(file_exists($this->settings['system']['apacheconf_diroptions']))
{
if (file_exists($this->settings['system']['apacheconf_diroptions'])) {
$vhosts_file.= "\n" . 'Include ' . $this->settings['system']['apacheconf_diroptions'] . "\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, ' apache::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->virtualhosts_data as $vhosts_filename => $vhosts_file)
{
foreach ($this->virtualhosts_data as $vhosts_filename => $vhosts_file) {
$this->known_vhostfilenames[] = 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;
$vhosts_file_handler = fopen($vhosts_filename, 'w');
fwrite($vhosts_file_handler, $vhosts_file);

View File

@@ -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,8 +199,7 @@ 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);
@@ -249,8 +227,7 @@ class lighttpd
) {
$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 (!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';
}
@@ -419,12 +384,10 @@ class lighttpd
}
if ($ssl_vhost === true
&& $domain['ssl'] == '1')
{
&& $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 = '';
$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 = '';
@@ -641,15 +590,13 @@ class lighttpd
$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')
{
&& $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))
{
while ($row_htpasswds = $this->db->fetch_array($result)) {
if ($auth_backend_loaded[$domain['ipandport']] != 'yes'
&& $auth_backend_loaded[$domain['ssl_ipandport']] != 'yes')
{
&& $auth_backend_loaded[$domain['ssl_ipandport']] != 'yes'
) {
$filename = $domain['customerid'] . '.htpasswd';
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,66 +668,44 @@ 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)
{
} elseif(sizeof($server_string) - 1 == $i) {
$servernames_text .= $data . ')';
}
else
{
} else {
$servernames_text .= $data . '|';
}
}
else
{
} else {
$servernames_text = $data;
}
}
@@ -807,35 +726,29 @@ class lighttpd
$webroot_text = '';
if ($domain['deactivated'] == '1'
&& $this->settings['system']['deactivateddocroot'] != '')
{
&& $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
{
} else {
if ($ssl === false
&& $domain['ssl_redirect'] == '1')
{
&& $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']));
}

View File

@@ -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']));
@@ -101,8 +99,7 @@ class nginx
|| $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'];
$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 401 ' . $defhandler . ';' . "\n";
$this->nginx_data[$vhosts_filename].= 'error_page ' . $statusCode . ' ' . $defhandler . ';' . "\n";
}
}
}
}
if ($this->settings['defaultwebsrverrhandler']['err403'] != '') {
$defhandler = $this->settings['defaultwebsrverrhandler']['err403'];
if (!validateUrl($defhandler)) {
$defhandler = makeCorrectFile($defhandler);
}
$this->nginx_data[$vhosts_filename].= 'error_page 403 ' . $defhandler . ';' . "\n";
public function createVirtualHosts()
{
}
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 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 {
@@ -268,7 +245,6 @@ class nginx
$php = new phpinterface($this->getDB(), $this->settings, $domain);
$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";
}
@@ -290,27 +266,23 @@ class nginx
$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] = '';
}
@@ -321,15 +293,12 @@ class nginx
$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')
{
|| 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';
}
@@ -348,24 +317,18 @@ class nginx
|| domainMainToSubExists($domain['ismainbutsubto']) == false)
) {
$vhost_no = '22';
}
elseif((int)$domain['parentdomainid'] == 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');
}
@@ -375,18 +338,16 @@ class nginx
protected function getVhostContent($domain, $ssl_vhost = false)
{
if ($ssl_vhost === true
&& $domain['ssl'] != '1')
{
&& $domain['ssl'] != '1'
) {
return '';
}
if ($ssl_vhost === true
&& $domain['ssl'] == '1')
{
&& $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,12 +356,9 @@ 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'];
}
@@ -451,7 +409,7 @@ class nginx
// merge duplicate / sections, #1193
$l_regex1 = "/(location\ \/\ \{)(.*)(\})/smU";
$l_regex2 = "/(location\ \/\ \{.*\})/smU";
$replace_by="";
$replace_by = '';
$replacements = preg_match_all($l_regex1,$vhost_content,$out);
if ($replacements > 1) {
foreach ($out[2] as $val) {
@@ -466,7 +424,8 @@ class nginx
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,7 +436,6 @@ 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)) {
@@ -502,8 +460,7 @@ class nginx
$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']);
@@ -521,10 +478,8 @@ 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)
{
if (count($htpasswds) > 0) {
foreach ($htpasswds as $idx => $single) {
switch ($single['path']) {
case '/awstats/':
case '/webalizer/':
@@ -543,9 +498,7 @@ class nginx
$path_options .= "\t".'}' . "\n";
$this->vhost_root_autoindex = false;
}
else
{
} else {
$path_options .= "\t".'location ' . $path . ' {' . "\n";
if ($this->vhost_root_autoindex) {
$path_options .= "\t\t" . 'autoindex on;' . "\n";
@@ -561,8 +514,8 @@ class nginx
* required the fastCGI wrapper to be running to receive the CGI requests.
*/
if (customerHasPerlEnabled($domain['customerid'])
&& $row['options_cgi'] != '0')
{
&& $row['options_cgi'] != '0'
) {
$path = makeCorrectDir(substr($row['path'], strlen($domain['documentroot']) - 1));
mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']);
@@ -583,14 +536,10 @@ 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);
@@ -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";
@@ -679,14 +626,12 @@ class nginx
$webroot_text = '';
if ($domain['deactivated'] == '1'
&& $this->settings['system']['deactivateddocroot'] != '')
{
&& $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
{
} else {
$webroot_text .= "\t".'root '.makeCorrectDir($domain['documentroot']).';'."\n";
$this->_deactivated = false;
}
@@ -708,8 +653,8 @@ class nginx
return $webroot_text;
}
protected function getStats($domain, $single) {
protected function getStats($domain, $single)
{
$stats_text = '';
// define basic path to the stats
@@ -742,19 +687,17 @@ class nginx
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
@@ -795,14 +738,11 @@ class nginx
}
}
$alias = '';
if ($domain['iswildcarddomain'] == '1') {
$alias = '*.' . $domain['domain'];
} else {
if ($domain['wwwserveralias'] == '1') {
} elseif ($domain['wwwserveralias'] == '1') {
$alias = 'www.' . $domain['domain'];
} else {
$alias = '';
}
}
// After inserting the AWStats information,
@@ -824,44 +764,26 @@ class nginx
{
$server_alias = '';
if($domain['iswildcarddomain'] == '1')
{
if ($domain['iswildcarddomain'] == '1') {
$server_alias = '*.' . $domain['domain'];
}
else
{
if($domain['wwwserveralias'] == '1')
{
} elseif ($domain['wwwserveralias'] == '1') {
$server_alias = 'www.' . $domain['domain'];
}
else
{
$server_alias = '';
}
}
$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) {
$server_alias .= ' ' . $alias_domain['domain'];
if($alias_domain['iswildcarddomain'] == '1')
{
if ($alias_domain['iswildcarddomain'] == '1') {
$server_alias .= ' *.' . $alias_domain['domain'];
}
else
{
if($alias_domain['wwwserveralias'] == '1')
{
} elseif ($alias_domain['wwwserveralias'] == '1') {
$server_alias.= ' www.' . $alias_domain['domain'];
}
}
}
$servernames_text = "\t".'server_name '.$domain['domain'];
if(trim($server_alias) != '')
{
if (trim($server_alias) != '') {
$servernames_text .= ' '.$server_alias;
}
$servernames_text .= ';' . "\n";
@@ -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);