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'); 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']); $id = intval($_POST['id']);
} } elseif(isset($_GET['id'])) {
elseif(isset($_GET['id']))
{
$id = intval($_GET['id']); $id = intval($_GET['id']);
} }
if($page == 'cronjobs' if ($page == 'cronjobs' || $page == 'overview') {
|| $page == 'overview') if ($action == '') {
{ $log->logAction(ADM_ACTION, LOG_NOTICE, 'viewed admin_cronjobs');
if($action == '')
{
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_cronjobs");
$fields = array( $fields = array(
'c.lastrun' => $lng['cron']['lastrun'], 'c.lastrun' => $lng['cron']['lastrun'],
@@ -56,57 +49,37 @@ if($page == 'cronjobs'
$i = 0; $i = 0;
$count = 0; $count = 0;
while($row = $db->fetch_array($result)) while ($row = $db->fetch_array($result)) {
{ if ($paging->checkDisplay($i)) {
if($paging->checkDisplay($i))
{
$row = htmlentities_array($row); $row = htmlentities_array($row);
$row['lastrun'] = date('d.m.Y H:i', $row['lastrun']); $row['lastrun'] = date('d.m.Y H:i', $row['lastrun']);
$row['isactive'] = ((int)$row['isactive'] == 1) ? $lng['panel']['yes'] : $lng['panel']['no'];
if((int)$row['isactive'] == 1)
{
$row['isactive'] = $lng['panel']['yes'];
}
else
{
$row['isactive'] = $lng['panel']['no'];
}
$description = $lng['crondesc'][$row['desc_lng_key']]; $description = $lng['crondesc'][$row['desc_lng_key']];
eval("\$crons.=\"" . getTemplate("cronjobs/cronjobs_cronjob") . "\";"); eval("\$crons.=\"" . getTemplate('cronjobs/cronjobs_cronjob') . "\";");
$count++; $count++;
} }
$i++; $i++;
} }
eval("echo \"" . getTemplate("cronjobs/cronjobs") . "\";"); eval("echo \"" . getTemplate('cronjobs/cronjobs') . "\";");
} } elseif ($action == 'new') {
elseif($action == 'new')
{
/* /*
* @TODO later * @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 . "'"); $result = $db->query_first("SELECT * FROM `" . TABLE_PANEL_CRONRUNS . "` WHERE `id`='" . (int)$id . "'");
if ($result['cronfile'] != '') {
if ($result['cronfile'] != '') if (isset($_POST['send']) && $_POST['send'] == 'send') {
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$isactive = isset($_POST['isactive']) ? 1 : 0; $isactive = isset($_POST['isactive']) ? 1 : 0;
$interval_value = validate($_POST['interval_value'], 'interval_value', '/^([0-9]+)$/Di', 'stringisempty'); $interval_value = validate($_POST['interval_value'], 'interval_value', '/^([0-9]+)$/Di', 'stringisempty');
$interval_interval = validate($_POST['interval_interval'], 'interval_interval'); $interval_interval = validate($_POST['interval_interval'], 'interval_interval');
if($isactive != 1) if ($isactive != 1) {
{
$isactive = 0; $isactive = 0;
} }
@@ -118,9 +91,7 @@ if($page == 'cronjobs'
WHERE `id` = '" . (int)$id . "'"); WHERE `id` = '" . (int)$id . "'");
redirectTo($filename, Array('page' => $page, 's' => $s)); redirectTo($filename, Array('page' => $page, 's' => $s));
} } else {
else
{
//$isactive = makeyesno('isactive', '1', '0', $result['isactive']); //$isactive = makeyesno('isactive', '1', '0', $result['isactive']);
// interval // interval
$interval_nfo = explode(' ', $result['interval']); $interval_nfo = explode(' ', $result['interval']);
@@ -136,8 +107,7 @@ if($page == 'cronjobs'
// end of interval // end of interval
$change_cronfile = false; $change_cronfile = false;
if (substr($result['module'], 0, strpos($result['module'], '/')) != 'froxlor') if (substr($result['module'], 0, strpos($result['module'], '/')) != 'froxlor') {
{
$change_cronfile = true; $change_cronfile = true;
} }
@@ -147,13 +117,11 @@ if($page == 'cronjobs'
$title = $cronjobs_edit_data['cronjobs_edit']['title']; $title = $cronjobs_edit_data['cronjobs_edit']['title'];
$image = $cronjobs_edit_data['cronjobs_edit']['image']; $image = $cronjobs_edit_data['cronjobs_edit']['image'];
eval("echo \"" . getTemplate("cronjobs/cronjob_edit") . "\";"); eval("echo \"" . getTemplate('cronjobs/cronjob_edit') . "\";");
} }
} }
} }
elseif($action == 'delete' elseif ($action == 'delete' && $id != 0) {
&& $id != 0)
{
/* /*
* @TODO later * @TODO later
*/ */

View File

@@ -22,14 +22,12 @@ define('AREA', 'admin');
/** /**
* Include our init.php, which manages Sessions, Language etc. * Include our init.php, which manages Sessions, Language etc.
*/ */
require('./lib/init.php');
require ("./lib/init.php");
if ($page == 'log' if ($page == 'log'
&& $userinfo['change_serversettings'] == '1') && $userinfo['change_serversettings'] == '1'
{ ) {
if($action == '') if ($action == '') {
{
$fields = array( $fields = array(
'date' => $lng['logger']['date'], 'date' => $lng['logger']['date'],
'type' => $lng['logger']['type'], 'type' => $lng['logger']['type'],
@@ -47,11 +45,10 @@ if($page == 'log'
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s); $pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$clog = array(); $clog = array();
while($row = $db->fetch_array($result)) while ($row = $db->fetch_array($result)) {
{
if (!isset($clog[$row['action']]) if (!isset($clog[$row['action']])
|| !is_array($clog[$row['action']])) || !is_array($clog[$row['action']])
{ ) {
$clog[$row['action']] = array(); $clog[$row['action']] = array();
} }
@@ -59,12 +56,10 @@ if($page == 'log'
} }
if ($paging->sortfield == 'date' if ($paging->sortfield == 'date'
&& $paging->sortorder == 'desc') && $paging->sortorder == 'desc'
{ ) {
krsort($clog); krsort($clog);
} } else {
else
{
ksort($clog); ksort($clog);
} }
@@ -72,20 +67,15 @@ if($page == 'log'
$count = 0; $count = 0;
$log_count = 0; $log_count = 0;
$log = ''; $log = '';
foreach($clog as $action => $logrows) foreach ($clog as $action => $logrows) {
{
$_action = 0; $_action = 0;
foreach($logrows as $row) foreach ($logrows as $row) {
{ if ($paging->checkDisplay($i)) {
if($paging->checkDisplay($i))
{
$row = htmlentities_array($row); $row = htmlentities_array($row);
$row['date'] = date("d.m.y H:i:s", $row['date']); $row['date'] = date("d.m.y H:i:s", $row['date']);
if($_action != $action) if ($_action != $action) {
{ switch ($action) {
switch($action)
{
case USR_ACTION: case USR_ACTION:
$_action = $lng['admin']['customer']; $_action = $lng['admin']['customer'];
break; break;
@@ -107,15 +97,14 @@ if($page == 'log'
} }
$row['action'] = $_action; $row['action'] = $_action;
eval("\$log.=\"" . getTemplate("logger/logger_action") . "\";"); eval("\$log.=\"" . getTemplate('logger/logger_action') . "\";");
} }
$log_count++; $log_count++;
$type = $row['type']; $type = $row['type'];
$_type = 'unknown'; $_type = 'unknown';
switch($type) switch ($type) {
{
case LOG_INFO: case LOG_INFO:
$_type = 'Information'; $_type = 'Information';
break; break;
@@ -137,32 +126,27 @@ if($page == 'log'
} }
$row['type'] = $_type; $row['type'] = $_type;
eval("\$log.=\"" . getTemplate("logger/logger_log") . "\";"); eval("\$log.=\"" . getTemplate('logger/logger_log') . "\";");
$count++; $count++;
$_action = $action; $_action = $action;
} }
} }
$i++; $i++;
} }
eval("echo \"" . getTemplate("logger/logger") . "\";"); eval("echo \"" . getTemplate('logger/logger') . "\";");
} } elseif ($action == 'truncate') {
elseif($action == 'truncate')
{
if (isset($_POST['send']) if (isset($_POST['send'])
&& $_POST['send'] == 'send') && $_POST['send'] == 'send'
{ ) {
$yesterday = time() - (60 * 10); $yesterday = time() - (60 * 10);
/* (60*60*24); */ /* (60*60*24); */
$db->query("DELETE FROM `" . TABLE_PANEL_LOG . "` WHERE `date` < '" . $yesterday . "'"); $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)); redirectTo($filename, Array('page' => $page, 's' => $s));
} } else {
else
{
ask_yesno('logger_reallytruncate', $filename, array('page' => $page, 'action' => $action), TABLE_PANEL_LOG); 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. * 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']); $id = intval($_POST['id']);
} } elseif (isset($_GET['id'])) {
elseif(isset($_GET['id']))
{
$id = intval($_GET['id']); $id = intval($_GET['id']);
} }
if($page == 'message') if ($page == 'message') {
{ if ($action == '') {
if($action == '') $log->logAction(ADM_ACTION, LOG_NOTICE, 'viewed panel_message');
{
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed panel_message");
if (isset($_POST['send']) if (isset($_POST['send'])
&& $_POST['send'] == 'send') && $_POST['send'] == 'send'
{ ) {
if ($_POST['receipient'] == 0 if ($_POST['receipient'] == 0
&& $userinfo['customers_see_all'] == '1') && $userinfo['customers_see_all'] == '1'
{ ) {
$log->logAction(ADM_ACTION, LOG_NOTICE, "sending messages to admins"); $log->logAction(ADM_ACTION, LOG_NOTICE, 'sending messages to admins');
$result = $db->query('SELECT `name`, `email` FROM `' . TABLE_PANEL_ADMINS . "`"); $result = $db->query('SELECT `name`, `email` FROM `' . TABLE_PANEL_ADMINS . "`");
} } elseif ($_POST['receipient'] == 1) {
elseif($_POST['receipient'] == 1) if ($userinfo['customers_see_all'] == '1') {
{ $log->logAction(ADM_ACTION, LOG_NOTICE, 'sending messages to ALL customers');
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 . "`"); $result = $db->query('SELECT `firstname`, `name`, `email` FROM `' . TABLE_PANEL_CUSTOMERS . "`");
} } else {
else $log->logAction(ADM_ACTION, LOG_NOTICE, 'sending messages to customers');
{
$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'] . "'"); $result = $db->query('SELECT `firstname`, `name`, `email` FROM `' . TABLE_PANEL_CUSTOMERS . "` WHERE `adminid`='" . $userinfo['adminid'] . "'");
} }
} } else {
else
{
standard_error('noreceipientsgiven'); standard_error('noreceipientsgiven');
} }
$subject = $_POST['subject']; $subject = $_POST['subject'];
$message = wordwrap($_POST['message'], 70); $message = wordwrap($_POST['message'], 70);
if(!empty($message)) if (!empty($message)) {
{
$mailcounter = 0; $mailcounter = 0;
$mail->Body = $message; $mail->Body = $message;
$mail->Subject = $subject; $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->AddAddress($row['email'], (isset($row['firstname']) ? $row['firstname'] . ' ' : '') . $row['name']);
$mail->From = $userinfo['email']; $mail->From = $userinfo['email'];
$mail->FromName = (isset($userinfo['firstname']) ? $userinfo['firstname'] . ' ' : '') . $userinfo['name']; $mail->FromName = (isset($userinfo['firstname']) ? $userinfo['firstname'] . ' ' : '') . $userinfo['name'];
if(!$mail->Send()) if (!$mail->Send()) {
{ if ($mail->ErrorInfo != '') {
if($mail->ErrorInfo != '')
{
$mailerr_msg = $mail->ErrorInfo; $mailerr_msg = $mail->ErrorInfo;
} } else {
else $mailerr_msg = $row['email'];
{
$mailerr_msg = $row["email"];
} }
$log->logAction(ADM_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg); $log->logAction(ADM_ACTION, LOG_ERR, 'Error sending mail: ' . $mailerr_msg);
standard_error('errorsendingmail', $row["email"]); standard_error('errorsendingmail', $row['email']);
} }
$mailcounter++; $mailcounter++;
@@ -102,47 +83,34 @@ if($page == 'message')
} }
redirectTo($filename, Array('page' => $page, 's' => $s, 'action' => 'showsuccess', 'sentitems' => $mailcounter)); redirectTo($filename, Array('page' => $page, 's' => $s, 'action' => 'showsuccess', 'sentitems' => $mailcounter));
} } else {
else
{
standard_error('nomessagetosend'); standard_error('nomessagetosend');
} }
} }
} }
if($action == 'showsuccess') if ($action == 'showsuccess') {
{
$success = 1; $success = 1;
$sentitems = isset($_GET['sentitems']) ? (int)$_GET['sentitems'] : 0; $sentitems = isset($_GET['sentitems']) ? (int)$_GET['sentitems'] : 0;
if($sentitems == 0) if ($sentitems == 0) {
{
$successmessage = $lng['message']['noreceipients']; $successmessage = $lng['message']['noreceipients'];
} } else {
else
{
$successmessage = str_replace('%s', $sentitems, $lng['message']['success']); $successmessage = str_replace('%s', $sentitems, $lng['message']['success']);
} }
} else {
$action = '';
}
else
{
$success = 0; $success = 0;
$sentitems = 0; $sentitems = 0;
$successmessage = ''; $successmessage = '';
$action = '';
} }
$action = '';
$receipients = ''; $receipients = '';
if($userinfo['customers_see_all'] == "1") if ($userinfo['customers_see_all'] == '1') {
{
$receipients.= makeoption($lng['panel']['reseller'], 0); $receipients.= makeoption($lng['panel']['reseller'], 0);
} }
$receipients .= makeoption($lng['panel']['customer'], 1); $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'); 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"); $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 * and the svn-version has its value in the database
* -> bug #54 * -> bug #54
*/ */
$result = $db->query_first("SELECT `value` FROM `" . TABLE_PANEL_SETTINGS . "` WHERE `varname` = 'dbversion'"); $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']; $settings['system']['dbversion'] = (int)$result['value'];
} else { } else {
$settings['system']['dbversion'] = 0; $settings['system']['dbversion'] = 0;
@@ -55,40 +52,36 @@ if($page == 'overview')
} }
} }
if(hasUpdates($version)) if (hasUpdates($version)) {
{
$successful_update = false; $successful_update = false;
$message = ''; $message = '';
if (isset($_POST['send']) if (isset($_POST['send'])
&& $_POST['send'] == 'send') && $_POST['send'] == 'send'
{ ) {
if ((isset($_POST['update_preconfig']) if ((isset($_POST['update_preconfig'])
&& isset($_POST['update_changesagreed']) && isset($_POST['update_changesagreed'])
&& intval($_POST['update_changesagreed']) != 0) && intval($_POST['update_changesagreed']) != 0)
|| !isset($_POST['update_preconfig']) || !isset($_POST['update_preconfig'])
) { ) {
eval("echo \"" . getTemplate("update/update_start") . "\";"); eval("echo \"" . getTemplate('update/update_start') . "\";");
include_once './install/updatesql.php'; include_once './install/updatesql.php';
$redirect_url = 'admin_index.php?s=' . $s; $redirect_url = 'admin_index.php?s=' . $s;
eval("echo \"" . getTemplate("update/update_end") . "\";"); eval("echo \"" . getTemplate('update/update_end') . "\";");
updateCounters(); updateCounters();
inserttask('1'); inserttask('1');
@chmod('./lib/userdata.inc.php', 0440); @chmod('./lib/userdata.inc.php', 0440);
$successful_update = true; $successful_update = true;
} } else {
else $message = '<br /><strong style="color: red">You have to agree that you have read the update notifications.</strong>';
{
$message = '<br /><strong style="color:#ff0000;">You have to agree that you have read the update notifications.</strong>';
} }
} }
if(!$successful_update) if (!$successful_update) {
{
$current_version = $settings['panel']['version']; $current_version = $settings['panel']['version'];
$new_version = $version; $new_version = $version;
@@ -99,26 +92,20 @@ if($page == 'overview')
include_once './install/updates/preconfig.php'; include_once './install/updates/preconfig.php';
$preconfig = getPreConfig($current_version); $preconfig = getPreConfig($current_version);
if($preconfig != '') if ($preconfig != '') {
{
$update_information .= '<br />' . $preconfig . $message; $update_information .= '<br />' . $preconfig . $message;
} }
$update_information .= $lng['update']['update_information']['part_b']; $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 * @TODO version-webcheck check here
*/ */
$success_message = $lng['update']['noupdatesavail']; $success_message = $lng['update']['noupdatesavail'];
$redirect_url = 'admin_index.php?s=' . $s; $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'); define('AREA', 'customer');
require ("./lib/init.php"); require ('./lib/init.php');
$Id = 0; $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']; eval("echo \"" . getTemplate('aps/header') . "\";");
if(isset($_POST['id']))$Id = (int)$_POST['id'];
eval("echo \"" . getTemplate("aps/header") . "\";");
$Aps = new ApsParser($userinfo, $settings, $db); $Aps = new ApsParser($userinfo, $settings, $db);
$Aps->MainHandler($action); $Aps->MainHandler($action);
eval("echo \"" . getTemplate("aps/footer") . "\";"); eval("echo \"" . getTemplate('aps/footer') . "\";");
?>

View File

@@ -17,18 +17,14 @@
* *
*/ */
// Required code
define('AREA', 'customer'); define('AREA', 'customer');
require ("./lib/init.php"); require('./lib/init.php');
if ($action == 'add') {
// Create new autoresponder // Create new autoresponder
if($action == "add")
{
if (isset($_POST['send']) if (isset($_POST['send'])
&& $_POST['send'] == 'send') && $_POST['send'] == 'send'
{ ) {
$account = trim($_POST['account']); $account = trim($_POST['account']);
$subject = trim($_POST['subject']); $subject = trim($_POST['subject']);
$message = trim($_POST['message']); $message = trim($_POST['message']);
@@ -42,39 +38,31 @@ if($action == "add")
$ts_from = -1; $ts_from = -1;
$ts_until = -1; $ts_until = -1;
if($date_from_off > -1) if ($date_from_off > -1) {
{
$date_from = $_POST['date_from']; $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)); $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']; $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)); $ts_until = mktime(0, 0, 0, substr($date_until, 3, 2), substr($date_until, 0, 2), substr($date_until, 6, 4));
} }
if (empty($account) if (empty($account)
|| empty($subject) || empty($subject)
|| empty($message)) || empty($message)
{ ) {
standard_error('missingfields'); standard_error('missingfields');
} }
// Does account exist? // 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"); $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'); standard_error('accountnotexisting');
} }
// Does autoresponder exist? // 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"); $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'); standard_error('autoresponderalreadyexists');
} }
@@ -92,19 +80,14 @@ if($action == "add")
} }
// Get accounts // 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"); $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'); standard_error('noemailaccount');
} }
$accounts = ''; $accounts = '';
while ($row = $db->fetch_array($result)) {
while($row = $db->fetch_array($result)) $accounts .= '<option value="' . $row['email'] . '">' . $row['email'] . '</option>';
{
$accounts.= "<option value=\"" . $row['email'] . "\">" . $row['email'] . "</option>";
} }
$date_from_off = makecheckbox('date_from_off', $lng['panel']['not_activated'], '-1', false, '-1', true, true); $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']; $title = $autoresponder_add_data['autoresponder_add']['title'];
$image = $autoresponder_add_data['autoresponder_add']['image']; $image = $autoresponder_add_data['autoresponder_add']['image'];
eval("echo \"" . getTemplate("autoresponder/autoresponder_add") . "\";"); eval("echo \"" . getTemplate('autoresponder/autoresponder_add') . "\";");
} } elseif ($action == 'edit') {
// Edit autoresponder // Edit autoresponder
else
if($action == "edit")
{
if (isset($_POST['send']) if (isset($_POST['send'])
&& $_POST['send'] == 'send') && $_POST['send'] == 'send'
{ ) {
$account = trim($_POST['account']); $account = trim($_POST['account']);
$subject = trim($_POST['subject']); $subject = trim($_POST['subject']);
$message = trim($_POST['message']); $message = trim($_POST['message']);
@@ -143,49 +120,36 @@ if($action == "edit")
$ts_from = -1; $ts_from = -1;
$ts_until = -1; $ts_until = -1;
if($date_from_off > -1) if ($date_from_off > -1) {
{
$date_from = $_POST['date_from']; $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)); $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']; $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)); $ts_until = mktime(0, 0, 0, substr($date_until, 3, 2), substr($date_until, 0, 2), substr($date_until, 6, 4));
} }
if (empty($account) if (empty($account)
|| empty($subject) || empty($subject)
|| empty($message)) || empty($message)
{ ) {
standard_error('missingfields'); standard_error('missingfields');
} }
// Does account exist? // 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"); $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'); standard_error('accountnotexisting');
} }
// Does autoresponder exist? // 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"); $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'); standard_error('invalidautoresponder');
} }
$ResponderActive = 0; $ResponderActive = (isset($_POST['active']) && $_POST['active'] == '1') ? 1 : 0;
if(isset($_POST['active'])
&& $_POST['active'] == '1')
{
$ResponderActive = 1;
}
$db->query("UPDATE `" . TABLE_MAIL_AUTORESPONDER . "` $db->query("UPDATE `" . TABLE_MAIL_AUTORESPONDER . "`
SET `message` = '" . $db->escape($message) . "', SET `message` = '" . $db->escape($message) . "',
@@ -202,11 +166,8 @@ if($action == "edit")
$email = trim(htmlspecialchars($_GET['email'])); $email = trim(htmlspecialchars($_GET['email']));
// Get account data // Get account data
$result = $db->query("SELECT * FROM `" . TABLE_MAIL_AUTORESPONDER . "` WHERE `customerid` = '" . (int)$userinfo['customerid'] . "' AND `email` = '" . $db->escape($email) . "' LIMIT 0,1"); $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'); standard_error('invalidautoresponder');
} }
@@ -217,25 +178,19 @@ if($action == "edit")
$date_from = (int)$row['date_from']; $date_from = (int)$row['date_from'];
$date_until = (int)$row['date_until']; $date_until = (int)$row['date_until'];
if($date_from == -1) if ($date_from == -1) {
{
$deactivated = '-1'; $deactivated = '-1';
$date_from = ''; $date_from = '';
} } else {
else
{
$deactivated = '0'; $deactivated = '0';
$date_from = date('d-m-Y', $date_from); $date_from = date('d-m-Y', $date_from);
} }
$date_from_off = makecheckbox('date_from_off', $lng['panel']['not_activated'], '-1', false, $deactivated, true, true); $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'; $deactivated = '-1';
$date_until = ''; $date_until = '';
} } else {
else
{
$deactivated = '0'; $deactivated = '0';
$date_until = date('d-m-Y', $date_until); $date_until = date('d-m-Y', $date_until);
} }
@@ -249,26 +204,17 @@ if($action == "edit")
$title = $autoresponder_edit_data['autoresponder_edit']['title']; $title = $autoresponder_edit_data['autoresponder_edit']['title'];
$image = $autoresponder_edit_data['autoresponder_edit']['image']; $image = $autoresponder_edit_data['autoresponder_edit']['image'];
eval("echo \"" . getTemplate("autoresponder/autoresponder_edit") . "\";"); eval("echo \"" . getTemplate('autoresponder/autoresponder_edit') . "\";");
} } elseif ($action == 'delete') {
// Delete autoresponder // Delete autoresponder
else
if($action == "delete")
{
if (isset($_POST['send']) if (isset($_POST['send'])
&& $_POST['send'] == 'send') && $_POST['send'] == 'send'
{ ) {
$account = trim($_POST['account']); $account = trim($_POST['account']);
// Does autoresponder exist? // 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"); $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'); standard_error('invalidautoresponder');
} }
@@ -282,37 +228,25 @@ if($action == "delete")
$email = trim(htmlspecialchars($_GET['email'])); $email = trim(htmlspecialchars($_GET['email']));
ask_yesno('autoresponderdelete', $filename, array('action' => $action, 'account' => $email)); ask_yesno('autoresponderdelete', $filename, array('action' => $action, 'account' => $email));
} } else {
// List existing autoresponders // List existing autoresponders
else
{
$autoresponder = ''; $autoresponder = '';
$count = 0; $count = 0;
$result = $db->query("SELECT * FROM `" . TABLE_MAIL_AUTORESPONDER . "` WHERE `customerid` = '" . (int)$userinfo['customerid'] . "' ORDER BY email ASC"); $result = $db->query("SELECT * FROM `" . TABLE_MAIL_AUTORESPONDER . "` WHERE `customerid` = '" . (int)$userinfo['customerid'] . "' ORDER BY email ASC");
while($row = $db->fetch_array($result)) while ($row = $db->fetch_array($result)) {
{ if ($row['date_from'] == -1 && $row['date_until'] == -1) {
if($row['date_from'] == -1 && $row['date_until'] == -1)
{
$activated_date = $lng['panel']['not_activated']; $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']); $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']); $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']); $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++; $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. * Include our init.php, which manages Sessions, Language etc.
*/ */
require('./lib/init.php');
require ("./lib/init.php"); $id = 0;
if (isset($_POST['id'])) {
if(isset($_POST['id']))
{
$id = intval($_POST['id']); $id = intval($_POST['id']);
} } elseif(isset($_GET['id'])) {
elseif(isset($_GET['id']))
{
$id = intval($_GET['id']); $id = intval($_GET['id']);
} }
if($page == 'overview') if ($page == 'overview') {
{
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_ftp"); $log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_ftp");
eval("echo \"" . getTemplate("ftp/ftp") . "\";"); eval("echo \"" . getTemplate('ftp/ftp') . "\";");
} } elseif ($page == 'accounts') {
elseif($page == 'accounts') if ($action == '') {
{
if($action == '')
{
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_ftp::accounts"); $log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_ftp::accounts");
$fields = array( $fields = array(
'username' => $lng['login']['username'], 'username' => $lng['login']['username'],
@@ -59,23 +52,18 @@ elseif($page == 'accounts')
$count = 0; $count = 0;
$accounts = ''; $accounts = '';
while($row = $db->fetch_array($result)) while ($row = $db->fetch_array($result)) {
{ if ($paging->checkDisplay($i)) {
if($paging->checkDisplay($i)) if (strpos($row['homedir'], $userinfo['documentroot']) === 0) {
{
if(strpos($row['homedir'], $userinfo['documentroot']) === 0)
{
$row['documentroot'] = substr($row['homedir'], strlen($userinfo['documentroot'])); $row['documentroot'] = substr($row['homedir'], strlen($userinfo['documentroot']));
} } else {
else
{
$row['documentroot'] = $row['homedir']; $row['documentroot'] = $row['homedir'];
} }
$row['documentroot'] = makeCorrectDir($row['documentroot']); $row['documentroot'] = makeCorrectDir($row['documentroot']);
$row = htmlentities_array($row); $row = htmlentities_array($row);
eval("\$accounts.=\"" . getTemplate("ftp/accounts_account") . "\";"); eval("\$accounts.=\"" . getTemplate('ftp/accounts_account') . "\";");
$count++; $count++;
} }
@@ -83,19 +71,16 @@ elseif($page == 'accounts')
} }
$ftps_count = $db->num_rows($result); $ftps_count = $db->num_rows($result);
eval("echo \"" . getTemplate("ftp/accounts") . "\";"); eval("echo \"" . getTemplate('ftp/accounts') . "\";");
} } elseif ($action == 'delete' && $id != 0) {
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 . "'"); $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']) if (isset($result['username'])
&& $result['username'] != $userinfo['loginname']) && $result['username'] != $userinfo['loginname']
{ ) {
if (isset($_POST['send']) 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']) . "'"); $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 . "'"); $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']) . "'"); $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'] . "'"); $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'] . "'"); $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 = ($userinfo['ftps_used'] == '1') ? " , `ftp_lastaccountnumber`='0'" : '';
{
$resetaccnumber = " , `ftp_lastaccountnumber`='0'";
}
else
{
$resetaccnumber = '';
}
// refs #293 // refs #293
if (isset($_POST['delete_userfiles']) if (isset($_POST['delete_userfiles'])
&& (int)$_POST['delete_userfiles'] == 1) && (int)$_POST['delete_userfiles'] == 1
{ ) {
inserttask('8', $userinfo['loginname'], $result['homedir']); 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'] . "'"); $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)); 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']); ask_yesno_withcheckbox('ftp_reallydelete', 'admin_customer_alsoremoveftphomedir', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $result['username']);
} }
} } else {
else
{
standard_error('ftp_cantdeletemainaccount'); standard_error('ftp_cantdeletemainaccount');
} }
} } elseif ($action == 'add') {
elseif($action == 'add')
{
if ($userinfo['ftps_used'] < $userinfo['ftps'] if ($userinfo['ftps_used'] < $userinfo['ftps']
|| $userinfo['ftps'] == '-1') || $userinfo['ftps'] == '-1'
{ ) {
if (isset($_POST['send']) if (isset($_POST['send'])
&& $_POST['send'] == 'send') && $_POST['send'] == 'send'
{ ) {
$path = validate($_POST['path'], 'path'); $path = validate($_POST['path'], 'path');
$password = validate($_POST['ftp_password'], 'password'); $password = validate($_POST['ftp_password'], 'password');
$password = validatePassword($password); $password = validatePassword($password);
$sendinfomail = isset($_POST['sendinfomail']) ? 1 : 0; $sendinfomail = isset($_POST['sendinfomail']) ? 1 : 0;
if($sendinfomail != 1) if ($sendinfomail != 1) {
{
$sendinfomail = 0; $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\-_]+\$?$/'); $ftpusername = validate($_POST['ftp_username'], 'username', '/^[a-zA-Z0-9][a-zA-Z0-9\-_]+\$?$/');
if($ftpusername == '') if ($ftpusername == '') {
{
standard_error(array('stringisempty', 'username')); standard_error(array('stringisempty', 'username'));
} }
$ftpdomain = $idna_convert->encode(validate($_POST['ftp_domain'], 'domain')); $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'] . "'"); $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); standard_error('maindomainnonexist', $domain);
} }
$username = $ftpusername . "@" . $ftpdomain; $username = $ftpusername . "@" . $ftpdomain;
} } else {
else
{
$username = $userinfo['loginname'] . $settings['customer']['ftpprefix'] . (intval($userinfo['ftp_lastaccountnumber']) + 1); $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) . '\''); $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); standard_error('usernamealreadyexists', $username);
} } elseif ($password == '') {
elseif($password == '')
{
standard_error(array('stringisempty', 'mypassword')); standard_error(array('stringisempty', 'mypassword'));
} } elseif ($path == '') {
elseif($path == '')
{
standard_error('patherror'); standard_error('patherror');
} } else {
else
{
$path = makeCorrectDir($userinfo['documentroot'] . '/' . $path); $path = makeCorrectDir($userinfo['documentroot'] . '/' . $path);
$cryptPassword = makeCryptPassword($password); $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'] . "')"); $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'] . "'"); $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("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'] . "'"); $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 . ")'"); $log->logAction(USR_ACTION, LOG_INFO, "added ftp-account '" . $username . " (" . $path . ")'");
inserttask(5); inserttask(5);
if($sendinfomail == 1) if ($sendinfomail == 1) {
{
$replace_arr = array( $replace_arr = array(
'SALUTATION' => getCorrectUserSalutation($userinfo), 'SALUTATION' => getCorrectUserSalutation($userinfo),
'CUST_NAME' => getCorrectUserSalutation($userinfo), // < keep this for compatibility 'CUST_NAME' => getCorrectUserSalutation($userinfo), // < keep this for compatibility
@@ -242,29 +199,23 @@ elseif($page == 'accounts')
redirectTo($filename, Array('page' => $page, 's' => $s)); redirectTo($filename, Array('page' => $page, 's' => $s));
} }
} } else {
else
{
$pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $settings['panel']['pathedit'], '/'); $pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $settings['panel']['pathedit'], '/');
if($settings['customer']['ftpatdomain'] == '1') if ($settings['customer']['ftpatdomain'] == '1') {
{
$domainlist = array(); $domainlist = array();
$domains = ''; $domains = '';
$result_domains = $db->query("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "'"); $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']; $domainlist[] = $row_domain['domain'];
} }
sort($domainlist); sort($domainlist);
if(isset($domainlist[0]) && $domainlist[0] != '') if (isset($domainlist[0]) && $domainlist[0] != '') {
{ foreach ($domainlist as $dom) {
foreach($domainlist as $dom)
{
$domains .= makeoption($idna_convert->decode($dom), $dom); $domains .= makeoption($idna_convert->decode($dom), $dom);
} }
} }
@@ -278,40 +229,32 @@ elseif($page == 'accounts')
$title = $ftp_add_data['ftp_add']['title']; $title = $ftp_add_data['ftp_add']['title'];
$image = $ftp_add_data['ftp_add']['image']; $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 . "'"); $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']) if (isset($result['username'])
&& $result['username'] != '') && $result['username'] != ''
{ ) {
if (isset($_POST['send']) if (isset($_POST['send'])
&& $_POST['send'] == 'send') && $_POST['send'] == 'send'
{ ) {
$path = validate($_POST['path'], 'path'); $path = validate($_POST['path'], 'path');
$_setnewpass = false; $_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 = validate($_POST['ftp_password'], 'password');
$password = validatePassword($password); $password = validatePassword($password);
$_setnewpass = true; $_setnewpass = true;
} }
if($_setnewpass) if ($_setnewpass) {
{ if ($password == '') {
if($password == '')
{
standard_error(array('stringisempty', 'mypassword')); standard_error(array('stringisempty', 'mypassword'));
exit; exit;
} }
else
{
$log->logAction(USR_ACTION, LOG_INFO, "updated ftp-account password for '" . $result['username'] . "'"); $log->logAction(USR_ACTION, LOG_INFO, "updated ftp-account password for '" . $result['username'] . "'");
$cryptPassword = makeCryptPassword($password); $cryptPassword = makeCryptPassword($password);
$db->query("UPDATE `" . TABLE_FTP_USERS . "` SET `password`='" . $db->escape($cryptPassword) . "' WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'"); $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'"); $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); $path = makeCorrectDir($userinfo['documentroot'] . '/' . $path);
if($path != $result['homedir']) if ($path != $result['homedir']) {
{ if (!file_exists($path)) {
if(!file_exists($path))
{
mkDirWithCorrectOwnership($userinfo['documentroot'], $path, $result['uid'], $result['gid']); mkDirWithCorrectOwnership($userinfo['documentroot'], $path, $result['uid'], $result['gid']);
inserttask(5); /* Let the cronjob do the rest */ inserttask(5); /* Let the cronjob do the rest */
} }
@@ -341,29 +280,22 @@ elseif($page == 'accounts')
} }
redirectTo($filename, Array('page' => $page, 's' => $s)); redirectTo($filename, Array('page' => $page, 's' => $s));
} } else {
else if (strpos($result['homedir'], $userinfo['documentroot']) === 0) {
{
if(strpos($result['homedir'], $userinfo['documentroot']) === 0)
{
$homedir = substr($result['homedir'], strlen($userinfo['documentroot'])); $homedir = substr($result['homedir'], strlen($userinfo['documentroot']));
} } else {
else
{
$homedir = $result['homedir']; $homedir = $result['homedir'];
} }
$homedir = makeCorrectDir($homedir); $homedir = makeCorrectDir($homedir);
$pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $settings['panel']['pathedit'], $homedir); $pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $settings['panel']['pathedit'], $homedir);
if($settings['customer']['ftpatdomain'] == '1') if ($settings['customer']['ftpatdomain'] == '1') {
{
$domains = ''; $domains = '';
$result_domains = $db->query("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "'"); $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']); $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']; $title = $ftp_edit_data['ftp_edit']['title'];
$image = $ftp_edit_data['ftp_edit']['image']; $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. * 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') $query = "DELETE FROM `" . TABLE_PANEL_SESSIONS . "` WHERE `userid` = '" . (int)$userinfo['customerid'] . "' AND `adminsession` = '0'";
{ if ($settings['session']['allow_multiple_login'] == '1') {
$log->logAction(USR_ACTION, LOG_NOTICE, "logged out"); $query .= " AND `hash` = '" . $s . "'";
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 . "'");
} }
else $db->query($query);
{
$db->query("DELETE FROM `" . TABLE_PANEL_SESSIONS . "` WHERE `userid` = '" . (int)$userinfo['customerid'] . "' AND `adminsession` = '0'");
}
redirectTo('index.php'); redirectTo('index.php');
exit; exit;
} }
if($page == 'overview') if ($page == 'overview') {
{
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_index"); $log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_index");
$domains = ''; $domains = '';
$result = $db->query("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `parentdomainid`='0' AND `id` <> '" . (int)$userinfo['standardsubdomain'] . "' "); $result = $db->query("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `parentdomainid`='0' AND `id` <> '" . (int)$userinfo['standardsubdomain'] . "' ");
$domainArray = array(); $domainArray = array();
while($row = $db->fetch_array($result)) while ($row = $db->fetch_array($result)) {
{
$domainArray[] = $idna_convert->decode($row['domain']); $domainArray[] = $idna_convert->decode($row['domain']);
} }
@@ -77,22 +69,15 @@ if($page == 'overview')
$awaitingtickets = $opentickets['count']; $awaitingtickets = $opentickets['count'];
$awaitingtickets_text = ''; $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>')); $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") . "\";"); eval("echo \"" . getTemplate('index/index') . "\";");
} } elseif ($page == 'change_password') {
elseif($page == 'change_password') if (isset($_POST['send']) && $_POST['send'] == 'send') {
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$old_password = validate($_POST['old_password'], 'old password'); $old_password = validate($_POST['old_password'], 'old password');
if (md5($old_password) != $userinfo['password']) {
if(md5($old_password) != $userinfo['password'])
{
standard_error('oldpasswordnotcorrect'); standard_error('oldpasswordnotcorrect');
exit; exit;
} }
@@ -100,45 +85,33 @@ elseif($page == 'change_password')
$new_password = validatePassword($_POST['new_password'], 'new password'); $new_password = validatePassword($_POST['new_password'], 'new password');
$new_password_confirm = validatePassword($_POST['new_password_confirm'], 'new password confirm'); $new_password_confirm = validatePassword($_POST['new_password_confirm'], 'new password confirm');
if($old_password == '') if ($old_password == '') {
{
standard_error(array('stringisempty', 'oldpassword')); standard_error(array('stringisempty', 'oldpassword'));
} } elseif($new_password == '') {
elseif($new_password == '')
{
standard_error(array('stringisempty', 'newpassword')); standard_error(array('stringisempty', 'newpassword'));
} } elseif($new_password_confirm == '') {
elseif($new_password_confirm == '')
{
standard_error(array('stringisempty', 'newpasswordconfirm')); standard_error(array('stringisempty', 'newpasswordconfirm'));
} } elseif($new_password != $new_password_confirm) {
elseif($new_password != $new_password_confirm)
{
standard_error('newpasswordconfirmerror'); 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) . "'"); $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'); $log->logAction(USR_ACTION, LOG_NOTICE, 'changed password');
if (isset($_POST['change_main_ftp']) if (isset($_POST['change_main_ftp'])
&& $_POST['change_main_ftp'] == 'true') && $_POST['change_main_ftp'] == 'true'
{ ) {
$cryptPassword = makeCryptPassword($new_password); $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']) . "'"); $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'); $log->logAction(USR_ACTION, LOG_NOTICE, 'changed main ftp password');
} }
if (isset($_POST['change_webalizer']) if (isset($_POST['change_webalizer'])
&& $_POST['change_webalizer'] == 'true') && $_POST['change_webalizer'] == 'true'
{ ) {
if(CRYPT_STD_DES == 1) if (CRYPT_STD_DES == 1) {
{
$saltfordescrypt = substr(md5(uniqid(microtime(), 1)), 4, 2); $saltfordescrypt = substr(md5(uniqid(microtime(), 1)), 4, 2);
$new_webalizer_password = crypt($new_password, $saltfordescrypt); $new_webalizer_password = crypt($new_password, $saltfordescrypt);
} } else {
else
{
$new_webalizer_password = crypt($new_password); $new_webalizer_password = crypt($new_password);
} }
@@ -147,72 +120,52 @@ elseif($page == 'change_password')
redirectTo($filename, Array('s' => $s)); redirectTo($filename, Array('s' => $s));
} }
} else {
eval("echo \"" . getTemplate('index/change_password') . "\";");
} }
else } elseif ($page == 'change_language') {
{ if (isset($_POST['send']) && $_POST['send'] == 'send') {
eval("echo \"" . getTemplate("index/change_password") . "\";");
}
}
elseif($page == 'change_language')
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$def_language = validate($_POST['def_language'], 'default language'); $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_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) . "'"); $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 . "'"); $log->logAction(USR_ACTION, LOG_NOTICE, "changed default language to '" . $def_language . "'");
} }
redirectTo($filename, Array('s' => $s)); redirectTo($filename, Array('s' => $s));
} } else {
else
{
$language_options = '';
$default_lang = $settings['panel']['standardlanguage']; $default_lang = $settings['panel']['standardlanguage'];
if ($userinfo['def_language'] != '') { if ($userinfo['def_language'] != '') {
$default_lang = $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); $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') {
elseif($page == 'change_theme') if (isset($_POST['send']) && $_POST['send'] == 'send') {
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
$theme = validate($_POST['theme'], 'theme'); $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_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) . "'"); $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 . "'"); $log->logAction(USR_ACTION, LOG_NOTICE, "changed default theme to '" . $theme . "'");
redirectTo($filename, Array('s' => $s)); redirectTo($filename, Array('s' => $s));
} } else {
else
{
$theme_options = '';
$default_theme = $settings['panel']['default_theme']; $default_theme = $settings['panel']['default_theme'];
if ($userinfo['theme'] != '') { if ($userinfo['theme'] != '') {
$default_theme = $userinfo['theme']; $default_theme = $userinfo['theme'];
} }
$theme_options = '';
$themes_avail = getThemes(); $themes_avail = getThemes();
foreach($themes_avail as $t) foreach ($themes_avail as $t) {
{
$theme_options .= makeoption($t, $t, $default_theme, true); $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. * Include our init.php, which manages Sessions, Language etc.
*/ */
$need_db_sql_data = true; $need_db_sql_data = true;
$need_root_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']); $id = intval($_POST['id']);
} } elseif(isset($_GET['id'])) {
elseif(isset($_GET['id']))
{
$id = intval($_GET['id']); $id = intval($_GET['id']);
} }
if($page == 'overview') if ($page == 'overview') {
{
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_mysql"); $log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_mysql");
$lng['mysql']['description'] = str_replace('<SQL_HOST>', $sql['host'], $lng['mysql']['description']); $lng['mysql']['description'] = str_replace('<SQL_HOST>', $sql['host'], $lng['mysql']['description']);
eval("echo \"" . getTemplate("mysql/mysql") . "\";"); eval("echo \"" . getTemplate('mysql/mysql') . "\";");
} } elseif($page == 'mysqls') {
elseif($page == 'mysqls') if ($action == '') {
{
if($action == '')
{
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_mysql::mysqls"); $log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_mysql::mysqls");
$fields = array( $fields = array(
'databasename' => $lng['mysql']['databasename'], 'databasename' => $lng['mysql']['databasename'],
@@ -64,43 +56,35 @@ elseif($page == 'mysqls')
// Begin root-session // Begin root-session
$db_root = new db($sql_root[0]['host'], $sql_root[0]['user'], $sql_root[0]['password'], ''); $db_root = new db($sql_root[0]['host'], $sql_root[0]['user'], $sql_root[0]['password'], '');
while($row = $db->fetch_array($result)) while ($row = $db->fetch_array($result)) {
{ if ($paging->checkDisplay($i)) {
if($paging->checkDisplay($i))
{
$row = htmlentities_array($row); $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 ;"); $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, '.', ''); $row['size'] = number_format($mbdata['MB'], 3, '.', '');
eval("\$mysqls.=\"" . getTemplate("mysql/mysqls_database") . "\";"); eval("\$mysqls.=\"" . getTemplate('mysql/mysqls_database') . "\";");
$count++; $count++;
} }
$i++; $i++;
} }
$db_root->close(); $db_root->close();
// End root-session // End root-session
$mysqls_count = $db->num_rows($result); $mysqls_count = $db->num_rows($result);
eval("echo \"" . getTemplate("mysql/mysqls") . "\";"); eval("echo \"" . getTemplate('mysql/mysqls') . "\";");
} } elseif($action == 'delete' && $id != 0) {
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 . '"'); $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']) if (isset($result['databasename'])
&& $result['databasename'] != '') && $result['databasename'] != ''
{ ) {
if(!isset($sql_root[$result['dbserver']]) || !is_array($sql_root[$result['dbserver']])) if (!isset($sql_root[$result['dbserver']]) || !is_array($sql_root[$result['dbserver']])) {
{
$result['dbserver'] = 0; $result['dbserver'] = 0;
} }
if (isset($_POST['send']) if (isset($_POST['send'])
&& $_POST['send'] == 'send') && $_POST['send'] == 'send'
{ ) {
// Begin root-session // Begin root-session
$db_root = new db($sql_root[$result['dbserver']]['host'], $sql_root[$result['dbserver']]['user'], $sql_root[$result['dbserver']]['password'], ''); $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'] . "'"); $log->logAction(USR_ACTION, LOG_INFO, "deleted database '" . $result['databasename'] . "'");
if (mysql_get_server_info() < '5.0.2') { if (mysql_get_server_info() < '5.0.2') {
@@ -109,8 +93,7 @@ elseif($page == 'mysqls')
} }
$host_res = $db_root->query("SELECT `Host` FROM `mysql`.`user` WHERE `User`='" . $db_root->escape($result['databasename']) . "'"); $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+) // 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); $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('DROP DATABASE IF EXISTS `' . $db_root->escape($result['databasename']) . '`');
$db_root->query('FLUSH PRIVILEGES'); $db_root->query('FLUSH PRIVILEGES');
$db_root->close(); $db_root->close();
// End root-session // End root-session
$db->query('DELETE FROM `' . TABLE_PANEL_DATABASES . '` WHERE `customerid`="' . (int)$userinfo['customerid'] . '" AND `id`="' . (int)$id . '"'); $db->query('DELETE FROM `' . TABLE_PANEL_DATABASES . '` WHERE `customerid`="' . (int)$userinfo['customerid'] . '" AND `id`="' . (int)$id . '"');
if($userinfo['mysqls_used'] == '1') $resetaccnumber = ($userinfo['mysqls_used'] == '1') ? " , `mysql_lastaccountnumber`='0' " : '';
{
$resetaccnumber = " , `mysql_lastaccountnumber`='0' ";
}
else
{
$resetaccnumber = '';
}
$result = $db->query('UPDATE `' . TABLE_PANEL_CUSTOMERS . '` SET `mysqls_used`=`mysqls_used`-1 ' . $resetaccnumber . 'WHERE `customerid`="' . (int)$userinfo['customerid'] . '"'); $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)); redirectTo($filename, Array('page' => $page, 's' => $s));
} } else {
else
{
$dbnamedesc = $result['databasename']; $dbnamedesc = $result['databasename'];
if (isset($result['description']) && $result['description'] != '') { if (isset($result['description']) && $result['description'] != '') {
$dbnamedesc .= ' ('.$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); 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'] if ($userinfo['mysqls_used'] < $userinfo['mysqls']
|| $userinfo['mysqls'] == '-1') || $userinfo['mysqls'] == '-1'
{ ) {
if (isset($_POST['send']) if (isset($_POST['send'])
&& $_POST['send'] == 'send') && $_POST['send'] == 'send'
{ ) {
$password = validate($_POST['mysql_password'], 'password'); $password = validate($_POST['mysql_password'], 'password');
$password = validatePassword($password); $password = validatePassword($password);
$sendinfomail = isset($_POST['sendinfomail']) ? 1 : 0; $sendinfomail = isset($_POST['sendinfomail']) ? 1 : 0;
if($sendinfomail != 1) if ($sendinfomail != 1) {
{
$sendinfomail = 0; $sendinfomail = 0;
} }
if($password == '') if ($password == '') {
{
standard_error(array('stringisempty', 'mypassword')); standard_error(array('stringisempty', 'mypassword'));
} } else {
else $dbserver = 0;
{ if (count($sql_root) > 1) {
if(count($sql_root) > 1)
{
$dbserver = validate($_POST['mysql_server'], html_entity_decode($lng['mysql']['mysql_server']), '', '', 0); $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; $dbserver = 0;
} }
} }
else
{
$dbserver = 0;
}
// validate description before actual adding the database, #1052 // validate description before actual adding the database, #1052
$databasedescription = validate(trim($_POST['description']), 'description'); $databasedescription = validate(trim($_POST['description']), 'description');
@@ -189,13 +149,13 @@ elseif($page == 'mysqls')
// Begin root-session // Begin root-session
$db_root = new db($sql_root[$dbserver]['host'], $sql_root[$dbserver]['user'], $sql_root[$dbserver]['password'], ''); $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'); $result = $db_root->query('SELECT `User` FROM mysql.user');
while ($row = $db_root->fetch_array($result)) { while ($row = $db_root->fetch_array($result)) {
$allsqlusers[] = $row[User]; $allsqlusers[] = $row[User];
} }
$username = $userinfo['loginname'] . '-' . substr(md5(uniqid(microtime(), 1)), 20, 3); $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); $username = $userinfo['loginname'] . '-' . substr(md5(uniqid(microtime(), 1)), 20, 3);
} }
} else { } else {
@@ -204,8 +164,7 @@ elseif($page == 'mysqls')
$db_root->query('CREATE DATABASE `' . $db_root->escape($username) . '`'); $db_root->query('CREATE DATABASE `' . $db_root->escape($username) . '`');
$log->logAction(USR_ACTION, LOG_INFO, "created database '" . $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('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) . '\')'); $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 . "'"); $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->query('FLUSH PRIVILEGES');
$db_root->close(); $db_root->close();
// End root-session // 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('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'] . '"'); $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']; $pma = $lng['admin']['notgiven'];
if($settings['panel']['phpmyadmin_url'] != '') if ($settings['panel']['phpmyadmin_url'] != '') {
{
$pma = $settings['panel']['phpmyadmin_url']; $pma = $settings['panel']['phpmyadmin_url'];
} }
@@ -268,13 +225,10 @@ elseif($page == 'mysqls')
redirectTo($filename, Array('page' => $page, 's' => $s)); redirectTo($filename, Array('page' => $page, 's' => $s));
} }
} } else {
else
{
$mysql_servers = ''; $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); $mysql_servers .= makeoption($mysql_server_details['caption'], $mysql_server);
} }
@@ -286,44 +240,36 @@ elseif($page == 'mysqls')
$title = $mysql_add_data['mysql_add']['title']; $title = $mysql_add_data['mysql_add']['title'];
$image = $mysql_add_data['mysql_add']['image']; $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 . '"'); $result = $db->query_first('SELECT `id`, `databasename`, `description`, `dbserver` FROM `' . TABLE_PANEL_DATABASES . '` WHERE `customerid`="' . $userinfo['customerid'] . '" AND `id`="' . $id . '"');
if (isset($result['databasename']) if (isset($result['databasename'])
&& $result['databasename'] != '') && $result['databasename'] != ''
{ ) {
if(!isset($sql_root[$result['dbserver']]) || !is_array($sql_root[$result['dbserver']])) if (!isset($sql_root[$result['dbserver']]) || !is_array($sql_root[$result['dbserver']])) {
{
$result['dbserver'] = 0; $result['dbserver'] = 0;
} }
if (isset($_POST['send']) 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 // Only change Password if it is set, do nothing if it is empty! -- PH 2004-11-29
$password = validate($_POST['mysql_password'], 'password'); $password = validate($_POST['mysql_password'], 'password');
if ($password != '') {
if($password != '')
{
// validate password // validate password
$password = validatePassword($password); $password = validatePassword($password);
// Begin root-session // Begin root-session
$db_root = new db($sql_root[$result['dbserver']]['host'], $sql_root[$result['dbserver']]['user'], $sql_root[$result['dbserver']]['password'], ''); $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('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->query('FLUSH PRIVILEGES');
$db_root->close(); $db_root->close();
// End root-session // End root-session
} }
@@ -332,19 +278,15 @@ elseif($page == 'mysqls')
$databasedescription = validate($_POST['description'], 'description'); $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 . '"'); $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)); 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_data = include_once dirname(__FILE__).'/lib/formfields/customer/mysql/formfield.mysql_edit.php';
$mysql_edit_form = htmlform::genHTMLForm($mysql_edit_data); $mysql_edit_form = htmlform::genHTMLForm($mysql_edit_data);
$title = $mysql_edit_data['mysql_edit']['title']; $title = $mysql_edit_data['mysql_edit']['title'];
$image = $mysql_edit_data['mysql_edit']['image']; $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. * Include our init.php, which manages Sessions, Language etc.
*/ */
$intrafficpage = 1; $intrafficpage = 1;
require ("./lib/init.php"); require('./lib/init.php');
$traffic = ''; $traffic = '';
$month = null; $month = null;
$year = null; $year = null;
if (isset($_POST['month']) if (isset($_POST['month'])
&& isset($_POST['year'])) && isset($_POST['year'])
{ ) {
$month = intval($_POST['month']); $month = intval($_POST['month']);
$year = intval($_POST['year']); $year = intval($_POST['year']);
} } elseif (isset($_GET['month'])
elseif(isset($_GET['month']) && isset($_GET['year'])
&& isset($_GET['year'])) ) {
{
$month = intval($_GET['month']); $month = intval($_GET['month']);
$year = intval($_GET['year']); $year = intval($_GET['year']);
} }
@@ -44,22 +43,16 @@ elseif(isset($_GET['month'])
//BAM! $_GET??? //BAM! $_GET???
elseif (isset($_GET['page']) elseif (isset($_GET['page'])
&& $_GET['page'] == "current") && $_GET['page'] == 'current'
{ ) {
if(date('d') != '01') if (date('d') != '01') {
{
$month = date('m'); $month = date('m');
$year = date('Y'); $year = date('Y');
} } else {
else if (date('m') == '01') {
{
if(date('m') == '01')
{
$month = 12; $month = 12;
$year = date('Y') - 1; $year = date('Y') - 1;
} } else {
else
{
$month = date('m') - 1; $month = date('m') - 1;
$year = date('Y'); $year = date('Y');
} }
@@ -67,8 +60,7 @@ elseif (isset($_GET['page'])
} }
if (!is_null($month) if (!is_null($month)
&& !is_null($year)) && !is_null($year)) {
{
$traf['byte'] = 0; $traf['byte'] = 0;
$result = $db->query("SELECT $result = $db->query("SELECT
SUM(`http`) as 'http', SUM(`ftp_up`) AS 'ftp_up', SUM(`ftp_down`) as 'ftp_down', SUM(`mail`) as 'mail', 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; $traffic_complete['mail'] = 0;
$show = ''; $show = '';
while($row = $db->fetch_array($result)) while ($row = $db->fetch_array($result)) {
{
$http = $row['http']; $http = $row['http'];
$ftp = $row['ftp_up'] + $row['ftp_down']; $ftp = $row['ftp_up'] + $row['ftp_down'];
$mail = $row['mail']; $mail = $row['mail'];
@@ -91,10 +82,9 @@ if(!is_null($month)
$traffic_complete['http'] += $http; $traffic_complete['http'] += $http;
$traffic_complete['ftp'] += $ftp; $traffic_complete['ftp'] += $ftp;
$traffic_complete['mail'] += $mail; $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['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['httptext'] = bcdiv($http, 1024, $settings['panel']['decimal_places']) . " MB (HTTP)";
$traf['mailtext'] = bcdiv($mail, 1024, $settings['panel']['decimal_places']) . " MB (Mail)"; $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['http'] = bcdiv($http, 1024, $settings['panel']['decimal_places']);
$traf['mail'] = bcdiv($mail, 1024, $settings['panel']['decimal_places']); $traf['mail'] = bcdiv($mail, 1024, $settings['panel']['decimal_places']);
$traf['byte'] = bcdiv($traf['byte'], 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['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['httptext'] = round($http / 1024, $settings['panel']['decimal_places']) . " MB (HTTP)";
$traf['mailtext'] = round($mail / 1024, $settings['panel']['decimal_places']) . " MB (Mail)"; $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']); $traf['byte'] = round($traf['byte'] / 1024, $settings['panel']['decimal_places']);
} }
eval("\$traffic.=\"" . getTemplate("traffic/traffic_month") . "\";"); eval("\$traffic.=\"" . getTemplate('traffic/traffic_month') . "\";");
$show = $lng['traffic']['months'][intval($row['month'])] . " " . $row['year']; $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['http'] = bcdiv($traffic_complete['http'], 1024, $settings['panel']['decimal_places']);
$traffic_complete['ftp'] = bcdiv($traffic_complete['ftp'], 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']); $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['http'] = round($traffic_complete['http'] / 1024, $settings['panel']['decimal_places']);
$traffic_complete['ftp'] = round($traffic_complete['ftp'] / 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']); $traffic_complete['mail'] = round($traffic_complete['mail'] / 1024, $settings['panel']['decimal_places']);
} }
eval("echo \"" . getTemplate("traffic/traffic_details") . "\";"); eval("echo \"" . getTemplate('traffic/traffic_details') . "\";");
} } else {
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 $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'] . "' FROM `" . TABLE_PANEL_TRAFFIC . "` WHERE `customerid` = '" . $userinfo['customerid'] . "'
GROUP BY CONCAT(`year`,`month`) ORDER BY CONCAT(`year`,`month`) DESC LIMIT 12"); GROUP BY CONCAT(`year`,`month`) ORDER BY CONCAT(`year`,`month`) DESC LIMIT 12");
@@ -143,8 +125,7 @@ else
$traffic_complete['ftp'] = 0; $traffic_complete['ftp'] = 0;
$traffic_complete['mail'] = 0; $traffic_complete['mail'] = 0;
while($row = $db->fetch_array($result)) while ($row = $db->fetch_array($result)) {
{
$http = $row['http']; $http = $row['http'];
$ftp_up = $row['ftp_up']; $ftp_up = $row['ftp_up'];
$ftp_down = $row['ftp_down']; $ftp_down = $row['ftp_down'];
@@ -157,8 +138,7 @@ else
$traf['monthname'] = $lng['traffic']['months'][intval($row['month'])] . " " . $row['year']; $traf['monthname'] = $lng['traffic']['months'][intval($row['month'])] . " " . $row['year'];
$traf['byte'] = $http + $ftp_up + $ftp_down + $mail; $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['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['httptext'] = bcdiv($http, 1024, $settings['panel']['decimal_places']) . " MB (HTTP)";
$traf['mailtext'] = bcdiv($mail, 1024, $settings['panel']['decimal_places']) . " MB (Mail)"; $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['http'] = bcdiv($http, 1024, $settings['panel']['decimal_places']);
$traf['mail'] = bcdiv($mail, 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']); $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['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['httptext'] = round($http / 1024, $settings['panel']['decimal_places']) . " MB (HTTP)";
$traf['mailtext'] = round($mail / 1024, $settings['panel']['decimal_places']) . " MB (Mail)"; $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']); $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['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['ftp'] = bcdiv($traffic_complete['ftp'], 1024 * 1024, $settings['panel']['decimal_places']);
$traffic_complete['mail'] = bcdiv($traffic_complete['mail'], 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['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['ftp'] = round($traffic_complete['ftp'] / (1024 * 1024), $settings['panel']['decimal_places']);
$traffic_complete['mail'] = round($traffic_complete['mail'] / (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. * Include our init.php, which manages Sessions, Language etc.
*/ */
require ('./lib/init.php');
require ("./lib/init.php"); if ($action == '') {
if($action == '')
{
$action = 'login'; $action = 'login';
} }
if($action == 'login') if ($action == 'login') {
{
if (isset($_POST['send']) if (isset($_POST['send'])
&& $_POST['send'] == 'send') && $_POST['send'] == 'send'
{ ) {
$loginname = validate($_POST['loginname'], 'loginname'); $loginname = validate($_POST['loginname'], 'loginname');
$password = validate($_POST['password'], 'password'); $password = validate($_POST['password'], 'password');
$row = $db->query_first("SELECT `loginname` AS `customer` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `loginname`='" . $db->escape($loginname) . "'"); $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 . "`"; $table = "`" . TABLE_PANEL_CUSTOMERS . "`";
$uid = 'customerid'; $uid = 'customerid';
$adminsession = '0'; $adminsession = '0';
$is_admin = false; $is_admin = false;
} } else {
else $is_admin = true;
{ if ((int)$settings['login']['domain_login'] == 1) {
if((int)$settings['login']['domain_login'] == 1)
{
/** /**
* check if the customer tries to login with a domain, #374 * check if the customer tries to login with a domain, #374
*/ */
$domainname = $idna_convert->encode(preg_replace(Array('/\:(\d)+$/', '/^https?\:\/\//'), '', $loginname)); $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)."'"); $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'); $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) . "'"); $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 . "`"; $table = "`" . TABLE_PANEL_CUSTOMERS . "`";
$uid = 'customerid'; $uid = 'customerid';
$adminsession = '0'; $adminsession = '0';
$is_admin = false; $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'); redirectTo('index.php');
exit; exit;
} }
if($is_admin) if ($is_admin) {
{ if (hasUpdates($version)) {
if(hasUpdates($version))
{
$row = $db->query_first("SELECT `loginname` AS `admin` FROM `" . TABLE_PANEL_ADMINS . "` WHERE `loginname`='" . $db->escape($loginname) . "' AND `change_serversettings` = '1'"); $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 * not an admin who can see updates
*/ */
if(!isset($row['admin'])) if (!isset($row['admin'])) {
{
redirectTo('index.php'); redirectTo('index.php');
exit; exit;
} }
} } else {
else
{
$row = $db->query_first("SELECT `loginname` AS `admin` FROM `" . TABLE_PANEL_ADMINS . "` WHERE `loginname`='" . $db->escape($loginname) . "'"); $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 . "`"; $table = "`" . TABLE_PANEL_ADMINS . "`";
$uid = 'adminid'; $uid = 'adminid';
$adminsession = '1'; $adminsession = '1';
} } else {
else
{
redirectTo('index.php', Array('showmessage' => '2'), true); redirectTo('index.php', Array('showmessage' => '2'), true);
exit; exit;
} }
@@ -130,24 +98,18 @@ if($action == 'login')
$userinfo = $db->query_first("SELECT * FROM $table WHERE `loginname`='" . $db->escape($loginname) . "'"); $userinfo = $db->query_first("SELECT * FROM $table WHERE `loginname`='" . $db->escape($loginname) . "'");
if ($userinfo['loginfail_count'] >= $settings['login']['maxloginattempts'] 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); redirectTo('index.php', Array('showmessage' => '3'), true);
exit; exit;
} } elseif($userinfo['password'] == md5($password)) {
elseif($userinfo['password'] == md5($password))
{
// login correct // login correct
// reset loginfail_counter, set lastlogin_succ // reset loginfail_counter, set lastlogin_succ
$db->query("UPDATE $table SET `lastlogin_succ`='" . time() . "', `loginfail_count`='0' WHERE `$uid`='" . (int)$userinfo[$uid] . "'"); $db->query("UPDATE $table SET `lastlogin_succ`='" . time() . "', `loginfail_count`='0' WHERE `$uid`='" . (int)$userinfo[$uid] . "'");
$userinfo['userid'] = $userinfo[$uid]; $userinfo['userid'] = $userinfo[$uid];
$userinfo['adminsession'] = $adminsession; $userinfo['adminsession'] = $adminsession;
} } else {
else
{
// login incorrect // login incorrect
$db->query("UPDATE $table SET `lastlogin_fail`='" . time() . "', `loginfail_count`=`loginfail_count`+1 WHERE `$uid`='" . (int)$userinfo[$uid] . "'"); $db->query("UPDATE $table SET `lastlogin_fail`='" . time() . "', `loginfail_count`=`loginfail_count`+1 WHERE `$uid`='" . (int)$userinfo[$uid] . "'");
unset($userinfo); unset($userinfo);
redirectTo('index.php', Array('showmessage' => '2'), true); redirectTo('index.php', Array('showmessage' => '2'), true);
@@ -155,38 +117,28 @@ if($action == 'login')
} }
if (isset($userinfo['userid']) if (isset($userinfo['userid'])
&& $userinfo['userid'] != '') && $userinfo['userid'] != ''
{ ) {
$s = md5(uniqid(microtime(), 1)); $s = md5(uniqid(microtime(), 1));
if(isset($_POST['language'])) if (isset($_POST['language'])) {
{
$language = validate($_POST['language'], 'language'); $language = validate($_POST['language'], 'language');
if ($language == 'profile') {
if($language == 'profile')
{
$language = $userinfo['def_language']; $language = $userinfo['def_language'];
} } elseif(!isset($languages[$language])) {
elseif(!isset($languages[$language]))
{
$language = $settings['panel']['standardlanguage']; $language = $settings['panel']['standardlanguage'];
} }
} } else {
else
{
$language = $settings['panel']['standardlanguage']; $language = $settings['panel']['standardlanguage'];
} }
if (isset($userinfo['theme']) && $userinfo['theme'] != '') { if (isset($userinfo['theme']) && $userinfo['theme'] != '') {
$theme = $userinfo['theme']; $theme = $userinfo['theme'];
} } else {
else
{
$theme = $settings['panel']['default_theme']; $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']) . "'"); $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) . "')"); $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 ($userinfo['adminsession'] == '1') {
{ if (hasUpdates($version)) {
if(hasUpdates($version))
{
redirectTo('admin_updates.php', Array('s' => $s), true); redirectTo('admin_updates.php', Array('s' => $s), true);
exit; } else {
}
else
{
redirectTo('admin_index.php', Array('s' => $s), true); redirectTo('admin_index.php', Array('s' => $s), true);
exit;
} }
} } else {
else
{
redirectTo('customer_index.php', Array('s' => $s), true); redirectTo('customer_index.php', Array('s' => $s), true);
exit;
} }
} } else {
else
{
redirectTo('index.php', Array('showmessage' => '2'), true); redirectTo('index.php', Array('showmessage' => '2'), true);
}
exit; exit;
} } else {
}
else
{
$language_options = ''; $language_options = '';
$language_options .= makeoption($lng['login']['profile_lng'], 'profile', 'profile', true, true); $language_options .= makeoption($lng['login']['profile_lng'], 'profile', 'profile', true, true);
while(list($language_file, $language_name) = each($languages)) while (list($language_file, $language_name) = each($languages)) {
{
$language_options .= makeoption($language_name, $language_file, 'profile', true); $language_options .= makeoption($language_name, $language_file, 'profile', true);
} }
@@ -243,8 +181,7 @@ if($action == 'login')
$message = ''; $message = '';
$successmessage = ''; $successmessage = '';
switch($smessage) switch ($smessage) {
{
case 1: case 1:
$successmessage = $lng['pwdreminder']['success']; $successmessage = $lng['pwdreminder']['success'];
break; break;
@@ -264,23 +201,21 @@ if($action == 'login')
} }
$update_in_progress = ''; $update_in_progress = '';
if(hasUpdates($version)) if (hasUpdates($version)) {
{
$update_in_progress = $lng['update']['updateinprogress_onlyadmincanlogin']; $update_in_progress = $lng['update']['updateinprogress_onlyadmincanlogin'];
} }
eval("echo \"" . getTemplate("login") . "\";"); eval("echo \"" . getTemplate('login') . "\";");
} }
} }
if($action == 'forgotpwd') if ($action == 'forgotpwd') {
{
$adminchecked = false; $adminchecked = false;
$message = ''; $message = '';
if (isset($_POST['send']) if (isset($_POST['send'])
&& $_POST['send'] == 'send') && $_POST['send'] == 'send'
{ ) {
$loginname = validate($_POST['loginname'], 'loginname'); $loginname = validate($_POST['loginname'], 'loginname');
$email = validateEmail($_POST['loginemail'], 'email'); $email = validateEmail($_POST['loginemail'], 'email');
$sql = "SELECT `adminid`, `customerid`, `firstname`, `name`, `company`, `email`, `loginname`, `def_language`, `deactivated` FROM `" . TABLE_PANEL_CUSTOMERS . "` $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) . "'"; AND `email`='" . $db->escape($email) . "'";
$result = $db->query($sql); $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 . "` $sql = "SELECT `adminid`, `name`, `email`, `loginname`, `def_language` FROM `" . TABLE_PANEL_ADMINS . "`
WHERE `loginname`='" . $db->escape($loginname) . "' WHERE `loginname`='" . $db->escape($loginname) . "'
AND `email`='" . $db->escape($email) . "'"; AND `email`='" . $db->escape($email) . "'";
$result = $db->query($sql); $result = $db->query($sql);
if($db->num_rows() > 0) if ($db->num_rows() > 0) {
{
$adminchecked = true; $adminchecked = true;
} } else {
else
{
$result = null; $result = null;
} }
} }
if($result !== null) if ($result !== null) {
{
$user = $db->fetch_array($result); $user = $db->fetch_array($result);
/* Check whether user is banned */ /* Check whether user is banned */
if($user['deactivated']) if ($user['deactivated']) {
{
$message = $lng['pwdreminder']['notallowed']; $message = $lng['pwdreminder']['notallowed'];
redirectTo('index.php', Array('showmessage' => '5'), true); redirectTo('index.php', Array('showmessage' => '5'), true);
} }
if (($adminchecked && $settings['panel']['allow_preset_admin'] == '1') if (($adminchecked && $settings['panel']['allow_preset_admin'] == '1')
|| $adminchecked == false) || $adminchecked == false
{ ) {
if($user !== false) if ($user !== false) {
{
if ($settings['panel']['password_min_length'] <= 6) { if ($settings['panel']['password_min_length'] <= 6) {
$password = substr(md5(uniqid(microtime(), 1)), 12, 6); $password = substr(md5(uniqid(microtime(), 1)), 12, 6);
} else { } else {
// make it two times larger than password_min_length // make it two times larger than password_min_length
$rnd = ''; $rnd = '';
$minlength = $settings['panel']['password_min_length']; $minlength = $settings['panel']['password_min_length'];
while (strlen($rnd) < ($minlength * 2)) while (strlen($rnd) < ($minlength * 2)) {
{
$rnd .= md5(uniqid(microtime(), 1)); $rnd .= md5(uniqid(microtime(), 1));
} }
$password = substr($rnd, (int)($minlength / 2), $minlength); $password = substr($rnd, (int)($minlength / 2), $minlength);
} }
if($adminchecked) $passwordTable = $adminchecked ? TABLE_PANEL_ADMINS : TABLE_PANEL_CUSTOMERS;
{ $db->query("UPDATE `" . $passwordTable . "` SET `password`='" . md5($password) . "'
$db->query("UPDATE `" . TABLE_PANEL_ADMINS . "` SET `password`='" . md5($password) . "'
WHERE `loginname`='" . $user['loginname'] . "' WHERE `loginname`='" . $user['loginname'] . "'
AND `email`='" . $user['email'] . "'"); 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 = FroxlorLogger::getInstanceOf(array('loginname' => 'password_reset'), $db, $settings);
$rstlog->logAction(USR_ACTION, LOG_WARNING, "Password for user '" . $user['loginname'] . "' has been reset!"); $rstlog->logAction(USR_ACTION, LOG_WARNING, "Password for user '" . $user['loginname'] . "' has been reset!");
@@ -389,9 +308,7 @@ if($action == 'forgotpwd')
$mail->ClearAddresses(); $mail->ClearAddresses();
redirectTo('index.php', Array('showmessage' => '1'), true); redirectTo('index.php', Array('showmessage' => '1'), true);
exit; exit;
} } else {
else
{
$rstlog = FroxlorLogger::getInstanceOf(array('loginname' => 'password_reset'), $db, $settings); $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!"); $rstlog->logAction(USR_ACTION, LOG_WARNING, "User '" . $loginname . "' tried to reset pwd but wasn't found in database!");
$message = $lng['login']['combination_not_found']; $message = $lng['login']['combination_not_found'];
@@ -399,28 +316,21 @@ if($action == 'forgotpwd')
unset($user); unset($user);
} }
} } else {
else
{
$message = $lng['login']['usernotfound']; $message = $lng['login']['usernotfound'];
} }
} }
if($adminchecked) if ($adminchecked) {
{ if ($settings['panel']['allow_preset_admin'] != '1') {
if($settings['panel']['allow_preset_admin'] != '1')
{
$message = $lng['pwdreminder']['notallowed']; $message = $lng['pwdreminder']['notallowed'];
unset ($adminchecked); unset ($adminchecked);
} }
} } else {
else if ($settings['panel']['allow_preset'] != '1') {
{
if($settings['panel']['allow_preset'] != '1')
{
$message = $lng['pwdreminder']['notallowed']; $message = $lng['pwdreminder']['notallowed'];
} }
} }
eval("echo \"" . getTemplate("fpwd") . "\";"); eval("echo \"" . getTemplate('fpwd') . "\";");
} }

View File

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

View File

@@ -68,8 +68,7 @@ class lighttpd
public function reload() 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"); fwrite($this->debugHandler, ' lighttpd::reload: reloading php-fpm' . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading php-fpm'); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading php-fpm');
safe_exec(escapeshellcmd($this->settings['phpfpm']['reload'])); 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"; $query = "SELECT * FROM `" . TABLE_PANEL_IPSANDPORTS . "` ORDER BY `ip` ASC, `port` ASC";
$result_ipsandports = $this->db->query($query); $result_ipsandports = $this->db->query($query);
while($row_ipsandports = $this->db->fetch_array($result_ipsandports)) while ($row_ipsandports = $this->db->fetch_array($result_ipsandports)) {
{ if (filter_var($row_ipsandports['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
if(filter_var($row_ipsandports['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6))
{
$ip = '[' . $row_ipsandports['ip'] . ']'; $ip = '[' . $row_ipsandports['ip'] . ']';
$port = $row_ipsandports['port']; $port = $row_ipsandports['port'];
$ipv6 = 'server.use-ipv6 = "enable"'."\n"; $ipv6 = 'server.use-ipv6 = "enable"'."\n";
} } else {
else
{
$ip = $row_ipsandports['ip']; $ip = $row_ipsandports['ip'];
$port = $row_ipsandports['port']; $port = $row_ipsandports['port'];
$ipv6 = ''; $ipv6 = '';
@@ -103,39 +98,30 @@ class lighttpd
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'creating ip/port settings for ' . $ip . ":" . $port); $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'); $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] = '';
} }
$this->lighttpd_data[$vhost_filename].= '$SERVER["socket"] == "' . $ip . ':' . $port . '" {' . "\n"; $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.port = ' . $port . "\n";
$this->lighttpd_data[$vhost_filename].= 'server.bind = "' . $ip . '"' . "\n"; $this->lighttpd_data[$vhost_filename].= 'server.bind = "' . $ip . '"' . "\n";
$this->lighttpd_data[$vhost_filename].= $ipv6; $this->lighttpd_data[$vhost_filename].= $ipv6;
} }
if($row_ipsandports['vhostcontainer'] == '1') if ($row_ipsandports['vhostcontainer'] == '1') {
{
$myhost = str_replace('.', '\.', $this->settings['system']['hostname']); $myhost = str_replace('.', '\.', $this->settings['system']['hostname']);
$this->lighttpd_data[$vhost_filename].= '# Froxlor default vhost' . "\n"; $this->lighttpd_data[$vhost_filename].= '# Froxlor default vhost' . "\n";
$this->lighttpd_data[$vhost_filename].= '$HTTP["host"] =~ "^(?:www\.|)' . $myhost . '$" {' . "\n"; $this->lighttpd_data[$vhost_filename].= '$HTTP["host"] =~ "^(?:www\.|)' . $myhost . '$" {' . "\n";
if($row_ipsandports['docroot'] == '') if ($row_ipsandports['docroot'] == '') {
{ if ($this->settings['system']['froxlordirectlyviahostname']) {
if($this->settings['system']['froxlordirectlyviahostname'])
{
$mypath = makeCorrectDir(dirname(dirname(dirname(__FILE__)))); $mypath = makeCorrectDir(dirname(dirname(dirname(__FILE__))));
} } else {
else
{
$mypath = makeCorrectDir(dirname(dirname(dirname(dirname(__FILE__))))); $mypath = makeCorrectDir(dirname(dirname(dirname(dirname(__FILE__)))));
} }
} } else {
else
{
// user-defined docroot, #417 // user-defined docroot, #417
$mypath = makeCorrectDir($row_ipsandports['docroot']); $mypath = makeCorrectDir($row_ipsandports['docroot']);
} }
@@ -154,8 +140,7 @@ class lighttpd
/** /**
* own php-fpm vhost * own php-fpm vhost
*/ */
if((int)$this->settings['phpfpm']['enabled'] == 1) if ((int)$this->settings['phpfpm']['enabled'] == 1) {
{
$domain = array( $domain = array(
'id' => 'none', 'id' => 'none',
'domain' => $this->settings['system']['hostname'], 'domain' => $this->settings['system']['hostname'],
@@ -182,33 +167,27 @@ class lighttpd
$this->lighttpd_data[$vhost_filename].= ' )'."\n"; $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].= $row_ipsandports['specialsettings'] . "\n";
} }
$this->lighttpd_data[$vhost_filename].= '}' . "\n"; $this->lighttpd_data[$vhost_filename].= '}' . "\n";
} }
if($row_ipsandports['ssl'] == '1') if ($row_ipsandports['ssl'] == '1') {
{ if ($row_ipsandports['ssl_cert_file'] == '') {
if($row_ipsandports['ssl_cert_file'] == '')
{
$row_ipsandports['ssl_cert_file'] = $this->settings['system']['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']; $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.engine = "enable"' . "\n";
$this->lighttpd_data[$vhost_filename].= 'ssl.pemfile = "' . makeCorrectFile($row_ipsandports['ssl_cert_file']) . '"' . "\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"; $this->lighttpd_data[$vhost_filename].= 'ssl.ca-file = "' . makeCorrectFile($row_ipsandports['ssl_ca_file']) . '"' . "\n";
} }
} }
@@ -220,8 +199,7 @@ class lighttpd
* refs #70 * refs #70
*/ */
$vhosts = $this->createLighttpdHosts($row_ipsandports['ip'], $row_ipsandports['port'], $row_ipsandports['ssl'], $vhost_filename); $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 by number (subdomains first!)
sort($vhosts); sort($vhosts);
@@ -249,8 +227,7 @@ class lighttpd
) { ) {
$vhost_filename = makeCorrectFile($this->settings['system']['apacheconf_vhost'] . '/05_froxlor_default_errorhandler.conf'); $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] = ''; $this->lighttpd_data[$vhost_filename] = '';
} }
@@ -269,21 +246,18 @@ class lighttpd
$result_htpasswds = $this->db->query($htpasswd_query); $result_htpasswds = $this->db->query($htpasswd_query);
$htaccess_text = ''; $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']); $row_htpasswds['path'] = makeCorrectDir($row_htpasswds['path']);
mkDirWithCorrectOwnership($domain['documentroot'], $row_htpasswds['path'], $domain['guid'], $domain['guid']); mkDirWithCorrectOwnership($domain['documentroot'], $row_htpasswds['path'], $domain['guid'], $domain['guid']);
$filename = $row_htpasswds['customerid'] . '-' . md5($row_htpasswds['path']) . '.htpasswd'; $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])) { if (!isset($this->needed_htpasswds[$filename])) {
$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"; $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 . "'"; $query = "SELECT * FROM " . TABLE_PANEL_IPSANDPORTS . " WHERE `ip`='" . $ip . "' AND `port`='" . $port . "'";
$ipandport = $this->db->query_first($query); $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"; $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"; $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(); $included_vhosts = array();
$result_domains = $this->db->query($query2); $result_domains = $this->db->query($query2);
while($domain = $this->db->fetch_array($result_domains)) while ($domain = $this->db->fetch_array($result_domains)) {
{ if (is_dir($this->settings['system']['apacheconf_vhost'])) {
if (is_dir($this->settings['system']['apacheconf_vhost']))
{
safe_exec('mkdir -p '.escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'].'/vhosts/'))); safe_exec('mkdir -p '.escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'].'/vhosts/')));
// determine correct include-path: // determine correct include-path:
@@ -392,13 +360,10 @@ class lighttpd
&& !is_dir($this->settings['system']['apacheconf_vhost'])) && !is_dir($this->settings['system']['apacheconf_vhost']))
|| is_dir($this->settings['system']['apacheconf_vhost']) || is_dir($this->settings['system']['apacheconf_vhost'])
) { ) {
if($ssl == '1') if ($ssl == '1') {
{
$ssl_vhost = true; $ssl_vhost = true;
$ips_and_ports_index = 'ssl_ipandport'; $ips_and_ports_index = 'ssl_ipandport';
} } else {
else
{
$ssl_vhost = false; $ssl_vhost = false;
$ips_and_ports_index = 'ipandport'; $ips_and_ports_index = 'ipandport';
} }
@@ -419,12 +384,10 @@ class lighttpd
} }
if ($ssl_vhost === true if ($ssl_vhost === true
&& $domain['ssl'] == '1') && $domain['ssl'] == '1'
{ ) {
$query = "SELECT * FROM " . TABLE_PANEL_IPSANDPORTS . " WHERE `id`='" . $domain['ssl_ipandport'] . "'"; $query = "SELECT * FROM " . TABLE_PANEL_IPSANDPORTS . " WHERE `id`='" . $domain['ssl_ipandport'] . "'";
} } else {
else
{
$query = "SELECT * FROM " . TABLE_PANEL_IPSANDPORTS . " WHERE `id`='" . $domain['ipandport'] . "'"; $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_cert_file'] = $ipandport['ssl_cert_file'];
$domain['ssl_ca_file'] = $ipandport['ssl_ca_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']; $ipport = '[' . $domain['ip'] . ']:' . $domain['port'];
} } else {
else
{
$ipport = $domain['ip'] . ':' . $domain['port']; $ipport = $domain['ip'] . ':' . $domain['port'];
} }
@@ -454,14 +414,11 @@ class lighttpd
$domain['documentroot'] = 'https://' . $domain['domain'] . '/'; $domain['documentroot'] = 'https://' . $domain['domain'] . '/';
} }
if(preg_match('/^https?\:\/\//', $domain['documentroot'])) if (preg_match('/^https?\:\/\//', $domain['documentroot'])) {
{
$vhost_content.= ' url.redirect = (' . "\n"; $vhost_content.= ' url.redirect = (' . "\n";
$vhost_content.= ' "^/(.*)$" => "'. $this->idnaConvert->encode($domain['documentroot']) . '$1"'. "\n"; $vhost_content.= ' "^/(.*)$" => "'. $this->idnaConvert->encode($domain['documentroot']) . '$1"'. "\n";
$vhost_content.= ' )' . "\n"; $vhost_content.= ' )' . "\n";
} } else {
else
{
mkDirWithCorrectOwnership($domain['customerroot'], $domain['documentroot'], $domain['guid'], $domain['guid'], true, true); mkDirWithCorrectOwnership($domain['customerroot'], $domain['documentroot'], $domain['guid'], $domain['guid'], true, true);
$only_webroot = false; $only_webroot = false;
@@ -508,23 +465,19 @@ class lighttpd
&& $domain['ssl'] == '1' && $domain['ssl'] == '1'
&& (int)$this->settings['system']['use_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']; $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']; $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.engine = "enable"' . "\n";
$ssl_settings.= 'ssl.pemfile = "' . makeCorrectFile($domain['ssl_cert_file']) . '"' . "\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"; $ssl_settings.= 'ssl.ca-file = "' . makeCorrectFile($domain['ssl_ca_file']) . '"' . "\n";
} }
} }
@@ -536,15 +489,13 @@ class lighttpd
$logfiles_text = ''; $logfiles_text = '';
$speciallogfile = '';
if ($domain['speciallogfile'] == '1') { if ($domain['speciallogfile'] == '1') {
if ($domain['parentdomainid'] == '0') { if ($domain['parentdomainid'] == '0') {
$speciallogfile = '-' . $domain['domain']; $speciallogfile = '-' . $domain['domain'];
} else { } else {
$speciallogfile = '-' . $domain['parentdomain']; $speciallogfile = '-' . $domain['parentdomain'];
} }
} else {
$speciallogfile = '';
} }
// The normal access/error - logging is enabled // The normal access/error - logging is enabled
@@ -622,10 +573,8 @@ class lighttpd
$error_string.= ' server.error-handler-404 = "' . $defhandler . '"' . "\n\n"; $error_string.= ' server.error-handler-404 = "' . $defhandler . '"' . "\n\n";
} }
if($row['options_indexes'] != '0') if ($row['options_indexes'] != '0') {
{ if (!empty($error_string)) {
if(!empty($error_string))
{
$path_options.= $error_string; $path_options.= $error_string;
// reset $error_string here to prevent duplicate entries // reset $error_string here to prevent duplicate entries
$error_string = ''; $error_string = '';
@@ -641,15 +590,13 @@ class lighttpd
$path_options.= ' $HTTP["url"] =~ "^' . $path . '($|/)" {' . "\n"; $path_options.= ' $HTTP["url"] =~ "^' . $path . '($|/)" {' . "\n";
$path_options.= "\t" . 'dir-listing.activate = "enable"' . "\n"; $path_options.= "\t" . 'dir-listing.activate = "enable"' . "\n";
$path_options.= ' }' . "\n\n"; $path_options.= ' }' . "\n\n";
} } else {
else
{
$path_options = $error_string; $path_options = $error_string;
} }
if (customerHasPerlEnabled($domain['customerid']) if (customerHasPerlEnabled($domain['customerid'])
&& $row['options_cgi'] != '0') && $row['options_cgi'] != '0'
{ ) {
$path = makeCorrectDir(substr($row['path'], strlen($domain['documentroot']) - 1)); $path = makeCorrectDir(substr($row['path'], strlen($domain['documentroot']) - 1));
mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']); 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'] . "'"; $query = "SELECT * FROM " . TABLE_PANEL_HTPASSWDS . " WHERE `customerid`='" . $domain['customerid'] . "'";
$result = $this->db->query($query); $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' 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'; $filename = $domain['customerid'] . '.htpasswd';
if ($this->auth_backend_loaded[$domain['ipandport']] != 'yes') if ($this->auth_backend_loaded[$domain['ipandport']] != 'yes')
{
$auth_backend_loaded[$domain['ipandport']] = 'yes'; $auth_backend_loaded[$domain['ipandport']] = 'yes';
$diroption_text.= 'auth.backend = "htpasswd"' . "\n"; $diroption_text.= 'auth.backend = "htpasswd"' . "\n";
$diroption_text.= 'auth.backend.htpasswd.userfile = "' . makeCorrectFile($this->settings['system']['apacheconf_htpasswddir'] . '/' . $filename) . '"' . "\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"; $this->needed_htpasswds[$filename] = $row_htpasswds['username'] . ':' . $row_htpasswds['password'] . "\n";
$diroption_text.= 'auth.require = ( ' . "\n"; $diroption_text.= 'auth.require = ( ' . "\n";
$previous_domain_id = '1'; $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'; $auth_backend_loaded[$domain['ssl_ipandport']] = 'yes';
$diroption_text.= 'auth.backend= "htpasswd"' . "\n"; $diroption_text.= 'auth.backend= "htpasswd"' . "\n";
$diroption_text.= 'auth.backend.htpasswd.userfile = "' . makeCorrectFile($this->settings['system']['apacheconf_htpasswddir'] . '/' . $filename) . '"' . "\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.= ' "require" => "valid-user"' . "\n";
$diroption_text.= ')' . "\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; $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; $this->needed_htpasswds[$domain['ipandport']].= $diroption_text;
} }
} }
@@ -727,66 +668,44 @@ class lighttpd
$server_string = array(); $server_string = array();
$domain_name = str_replace('.', '\.', $domain['domain']); $domain_name = str_replace('.', '\.', $domain['domain']);
if($domain['iswildcarddomain'] == '1') if ($domain['iswildcarddomain'] == '1') {
{
$server_string[] = '(?:^|\.)' . $domain_name . '$'; $server_string[] = '(?:^|\.)' . $domain_name . '$';
} } else {
else if ($domain['wwwserveralias'] == '1') {
{
if($domain['wwwserveralias'] == '1')
{
$server_string[] = '^(?:www\.|)' . $domain_name . '$'; $server_string[] = '^(?:www\.|)' . $domain_name . '$';
} } else {
else
{
$server_string[] = '^'.$domain_name.'$'; $server_string[] = '^'.$domain_name.'$';
} }
} }
$alias_domains = $this->db->query('SELECT `domain`, `iswildcarddomain`, `wwwserveralias` FROM `' . TABLE_PANEL_DOMAINS . '` WHERE `aliasdomain`=\'' . $domain['id'] . '\''); $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']); $alias_domain_name = ereg_replace('\.', '\.', $alias_domain['domain']);
if($alias_domain['iswildcarddomain'] == '1') if ($alias_domain['iswildcarddomain'] == '1') {
{
$server_string[] = '(?:^|\.)' . $alias_domain_name . '$'; $server_string[] = '(?:^|\.)' . $alias_domain_name . '$';
} } else {
else if ($alias_domain['wwwserveralias'] == '1') {
{
if($alias_domain['wwwserveralias'] == '1')
{
$server_string[] = '^(?:www\.|)' . $alias_domain_name . '$'; $server_string[] = '^(?:www\.|)' . $alias_domain_name . '$';
} } else {
else
{
$server_string[] = '^'.$alias_domain_name . '$'; $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]; $data = $server_string[$i];
if(sizeof($server_string) > 1) if (sizeof($server_string) > 1) {
{ if ($i == 0) {
if($i == 0)
{
$servernames_text = '(' . $data . '|'; $servernames_text = '(' . $data . '|';
} } elseif(sizeof($server_string) - 1 == $i) {
elseif(sizeof($server_string) - 1 == $i)
{
$servernames_text .= $data . ')'; $servernames_text .= $data . ')';
} } else {
else
{
$servernames_text .= $data . '|'; $servernames_text .= $data . '|';
} }
} } else {
else
{
$servernames_text = $data; $servernames_text = $data;
} }
} }
@@ -807,35 +726,29 @@ class lighttpd
$webroot_text = ''; $webroot_text = '';
if ($domain['deactivated'] == '1' if ($domain['deactivated'] == '1'
&& $this->settings['system']['deactivateddocroot'] != '') && $this->settings['system']['deactivateddocroot'] != ''
{ ) {
$webroot_text.= ' # Using docroot for deactivated users...' . "\n"; $webroot_text.= ' # Using docroot for deactivated users...' . "\n";
$webroot_text.= ' server.document-root = "' . makeCorrectDir($this->settings['system']['deactivateddocroot']) . "\"\n"; $webroot_text.= ' server.document-root = "' . makeCorrectDir($this->settings['system']['deactivateddocroot']) . "\"\n";
$this->_deactivated = true; $this->_deactivated = true;
} } else {
else
{
if ($ssl === false if ($ssl === false
&& $domain['ssl_redirect'] == '1') && $domain['ssl_redirect'] == '1'
{ ) {
$redirect_domain = $this->idnaConvert->encode('https://' . $domain['domain']); $redirect_domain = $this->idnaConvert->encode('https://' . $domain['domain']);
$webroot_text.= ' url.redirect = ('."\n"; $webroot_text.= ' url.redirect = ('."\n";
$webroot_text.= "\t" . '"^/(.*)" => "' . $redirect_domain . '/$1",' . "\n"; $webroot_text.= "\t" . '"^/(.*)" => "' . $redirect_domain . '/$1",' . "\n";
$webroot_text.= "\t" . '"" => "' . $redirect_domain . '",' . "\n"; $webroot_text.= "\t" . '"" => "' . $redirect_domain . '",' . "\n";
$webroot_text.= "\t" . '"/" => "' . $redirect_domain . '"' . "\n"; $webroot_text.= "\t" . '"/" => "' . $redirect_domain . '"' . "\n";
$webroot_text.= ' )'."\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']); $redirect_domain = $this->idnaConvert->encode($domain['documentroot']);
$webroot_text.= ' url.redirect = ('."\n"; $webroot_text.= ' url.redirect = ('."\n";
$webroot_text.= "\t" . '"^/(.*)" => "' . $redirect_domain . '/$1",' . "\n"; $webroot_text.= "\t" . '"^/(.*)" => "' . $redirect_domain . '/$1",' . "\n";
$webroot_text.= "\t" . '"" => "' . $redirect_domain . '",' . "\n"; $webroot_text.= "\t" . '"" => "' . $redirect_domain . '",' . "\n";
$webroot_text.= "\t" . '"/" => "' . $redirect_domain . '"' . "\n"; $webroot_text.= "\t" . '"/" => "' . $redirect_domain . '"' . "\n";
$webroot_text.= ' )'."\n"; $webroot_text.= ' )'."\n";
} } else {
else
{
$webroot_text.= ' server.document-root = "' . makeCorrectDir($domain['documentroot']) . "\"\n"; $webroot_text.= ' server.document-root = "' . makeCorrectDir($domain['documentroot']) . "\"\n";
} }
$this->_deactivated = false; $this->_deactivated = false;
@@ -848,12 +761,11 @@ class lighttpd
* Lets set the text part for the stats software * Lets set the text part for the stats software
*/ */
protected function getStats($domain) { protected function getStats($domain)
{
$stats_text = ''; $stats_text = '';
if ($domain['speciallogfile'] == '1') { if ($domain['speciallogfile'] == '1') {
if ($domain['parentdomainid'] == '0') { if ($domain['parentdomainid'] == '0') {
if ($this->settings['system']['awstats_enabled'] == '1') { if ($this->settings['system']['awstats_enabled'] == '1') {
$stats_text.= ' alias.url = ( "/awstats/" => "'.makeCorrectFile($domain['customerroot'] . '/awstats/' . $domain['domain']).'" )' . "\n"; $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"); 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']); $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 // Save one big file
$vhosts_file = ''; $vhosts_file = '';
@@ -908,41 +819,32 @@ class lighttpd
// (former #437) - #833 (the numbering is done in createLighttpdHosts()) // (former #437) - #833 (the numbering is done in createLighttpdHosts())
ksort($this->lighttpd_data); 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_file.= $vhost_content . "\n\n";
} }
$vhosts_filename = $this->settings['system']['apacheconf_vhost']; $vhosts_filename = $this->settings['system']['apacheconf_vhost'];
// Apply header // 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 = '# ' . 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'); $vhosts_file_handler = fopen($vhosts_filename, 'w');
fwrite($vhosts_file_handler, $vhosts_file); fwrite($vhosts_file_handler, $vhosts_file);
fclose($vhosts_file_handler); fclose($vhosts_file_handler);
} } else {
else if (!file_exists($this->settings['system']['apacheconf_vhost'])) {
{
if(!file_exists($this->settings['system']['apacheconf_vhost']))
{
fwrite($this->debugHandler, ' lighttpd::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'])) . "\n"); 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']))); $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']))); safe_exec('mkdir ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'])));
} }
// Write a single file for every 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); $this->known_filenames[] = basename($vhosts_filename);
// Apply header // 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 = '# ' . 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'); $vhosts_file_handler = fopen($vhosts_filename, 'w');
fwrite($vhosts_file_handler, $vhosts_file); fwrite($vhosts_file_handler, $vhosts_file);
fclose($vhosts_file_handler); fclose($vhosts_file_handler);
@@ -952,12 +854,9 @@ class lighttpd
// Write the diroptions // Write the diroptions
if(isConfigDir($this->settings['system']['apacheconf_htpasswddir'])) if (isConfigDir($this->settings['system']['apacheconf_htpasswddir'])) {
{ foreach ($this->needed_htpasswds as $key => $data) {
foreach($this->needed_htpasswds as $key => $data) if (!is_dir($this->settings['system']['apacheconf_htpasswddir'])) {
{
if(!is_dir($this->settings['system']['apacheconf_htpasswddir']))
{
mkdir(makeCorrectDir($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 $auth_backend_loaded = false;
protected $htpasswds_data = array(); protected $htpasswds_data = array();
protected $known_htpasswdsfilenames = array(); protected $known_htpasswdsfilenames = array();
protected $mod_accesslog_loaded = "0"; protected $mod_accesslog_loaded = '0';
protected $vhost_root_autoindex = false; protected $vhost_root_autoindex = false;
protected $known_vhostfilenames = array(); protected $known_vhostfilenames = array();
/** /**
@@ -79,9 +79,7 @@ class nginx
fwrite($this->debugHandler, ' nginx::reload: restarting php processes' . "\n"); fwrite($this->debugHandler, ' nginx::reload: restarting php processes' . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'restarting php processes'); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'restarting php processes');
safe_exec($this->settings['system']['phpreload_command']); 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"); fwrite($this->debugHandler, ' nginx::reload: reloading php-fpm' . "\n");
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading php-fpm'); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading php-fpm');
safe_exec(escapeshellcmd($this->settings['phpfpm']['reload'])); safe_exec(escapeshellcmd($this->settings['phpfpm']['reload']));
@@ -101,8 +99,7 @@ class nginx
|| $this->settings['defaultwebsrverrhandler']['err500'] != '') || $this->settings['defaultwebsrverrhandler']['err500'] != '')
) { ) {
$vhosts_folder = ''; $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']); $vhosts_folder = makeCorrectDir($this->settings['system']['apacheconf_vhost']);
} else { } else {
$vhosts_folder = makeCorrectDir(dirname($this->settings['system']['apacheconf_vhost'])); $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'); $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] = ''; $this->nginx_data[$vhosts_filename] = '';
} }
if ($this->settings['defaultwebsrverrhandler']['err401'] != '') { $statusCodes = array('401', '403', '404', '500');
$defhandler = $this->settings['defaultwebsrverrhandler']['err401']; foreach ($statusCodes as $statusCode) {
if ($this->settings['defaultwebsrverrhandler']['err' . $statusCode] != '') {
$defhandler = $this->settings['defaultwebsrverrhandler']['err' . $statusCode];
if (!validateUrl($defhandler)) { if (!validateUrl($defhandler)) {
$defhandler = makeCorrectFile($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'] != '') { public function createVirtualHosts()
$defhandler = $this->settings['defaultwebsrverrhandler']['err403']; {
if (!validateUrl($defhandler)) {
$defhandler = makeCorrectFile($defhandler);
}
$this->nginx_data[$vhosts_filename].= 'error_page 403 ' . $defhandler . ';' . "\n";
} }
if ($this->settings['defaultwebsrverrhandler']['err404'] != '') { public function createFileDirOptions()
$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 createIpPort() public function createIpPort()
@@ -160,7 +138,6 @@ class nginx
$result_ipsandports = $this->db->query($query); $result_ipsandports = $this->db->query($query);
while ($row_ipsandports = $this->db->fetch_array($result_ipsandports)) { while ($row_ipsandports = $this->db->fetch_array($result_ipsandports)) {
if (filter_var($row_ipsandports['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { if (filter_var($row_ipsandports['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
$ip = '[' . $row_ipsandports['ip'] . ']'; $ip = '[' . $row_ipsandports['ip'] . ']';
} else { } else {
@@ -268,7 +245,6 @@ class nginx
$php = new phpinterface($this->getDB(), $this->settings, $domain); $php = new phpinterface($this->getDB(), $this->settings, $domain);
$this->nginx_data[$vhost_filename] .= "\t\t".'fastcgi_pass unix:' . $php->getInterface()->getSocketFile() . ';' . "\n"; $this->nginx_data[$vhost_filename] .= "\t\t".'fastcgi_pass unix:' . $php->getInterface()->getSocketFile() . ';' . "\n";
} else { } else {
$this->nginx_data[$vhost_filename] .= "\t\t".'fastcgi_pass ' . $this->settings['system']['nginx_php_backend'] . ';' . "\n"; $this->nginx_data[$vhost_filename] .= "\t\t".'fastcgi_pass ' . $this->settings['system']['nginx_php_backend'] . ';' . "\n";
} }
@@ -290,27 +266,23 @@ class nginx
$query = "SELECT * FROM " . TABLE_PANEL_IPSANDPORTS . " WHERE `ip` = '" . $ip . "' AND `port` = '" . $port . "'"; $query = "SELECT * FROM " . TABLE_PANEL_IPSANDPORTS . " WHERE `ip` = '" . $ip . "' AND `port` = '" . $port . "'";
$ipandport = $this->db->query_first($query); $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`) ";
{ 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"; $query2 .= "WHERE `d`.`ipandport` = '" . $ipandport['id'] . "' ";
} } else {
else $query2 .= "WHERE `d`.`ssl_ipandport` = '" . $ipandport['id'] . "' ";
{
$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 .= "AND `d`.`aliasdomain` IS NULL AND `d`.`email_only` <> 1 ORDER BY `d`.`iswildcarddomain`, `d`.`domain` ASC";
$included_vhosts = array(); $included_vhosts = array();
$result_domains = $this->db->query($query2); $result_domains = $this->db->query($query2);
while($domain = $this->db->fetch_array($result_domains)) while ($domain = $this->db->fetch_array($result_domains)) {
{ if (is_dir($this->settings['system']['apacheconf_vhost'])) {
if (is_dir($this->settings['system']['apacheconf_vhost']))
{
safe_exec('mkdir -p '.escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost']))); safe_exec('mkdir -p '.escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'])));
$vhost_filename = $this->getVhostFilename($domain); $vhost_filename = $this->getVhostFilename($domain);
} }
if(!isset($this->nginx_data[$vhost_filename])) if (!isset($this->nginx_data[$vhost_filename])) {
{
$this->nginx_data[$vhost_filename] = ''; $this->nginx_data[$vhost_filename] = '';
} }
@@ -321,15 +293,12 @@ class nginx
$domain['ssl_cert_file'] = $ipandport['ssl_cert_file']; $domain['ssl_cert_file'] = $ipandport['ssl_cert_file'];
if ((!empty($this->nginx_data[$vhost_filename]) && !is_dir($this->settings['system']['apacheconf_vhost'])) if ((!empty($this->nginx_data[$vhost_filename]) && !is_dir($this->settings['system']['apacheconf_vhost']))
|| is_dir($this->settings['system']['apacheconf_vhost'])) || is_dir($this->settings['system']['apacheconf_vhost'])
{ ) {
if($ssl == '1') if ($ssl == '1') {
{
$ssl_vhost = true; $ssl_vhost = true;
$ips_and_ports_index = 'ssl_ipandport'; $ips_and_ports_index = 'ssl_ipandport';
} } else {
else
{
$ssl_vhost = false; $ssl_vhost = false;
$ips_and_ports_index = 'ipandport'; $ips_and_ports_index = 'ipandport';
} }
@@ -348,24 +317,18 @@ class nginx
|| domainMainToSubExists($domain['ismainbutsubto']) == false) || domainMainToSubExists($domain['ismainbutsubto']) == false)
) { ) {
$vhost_no = '22'; $vhost_no = '22';
} } elseif ((int)$domain['parentdomainid'] == 0
elseif((int)$domain['parentdomainid'] == 0
&& isCustomerStdSubdomain((int)$domain['id']) == false && isCustomerStdSubdomain((int)$domain['id']) == false
&& (int)$domain['ismainbutsubto'] > 0 && (int)$domain['ismainbutsubto'] > 0
) { ) {
$vhost_no = '21'; $vhost_no = '21';
} } else {
else
{
$vhost_no = '20'; $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'); $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'); $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) protected function getVhostContent($domain, $ssl_vhost = false)
{ {
if ($ssl_vhost === true if ($ssl_vhost === true
&& $domain['ssl'] != '1') && $domain['ssl'] != '1'
{ ) {
return ''; return '';
} }
if ($ssl_vhost === true if ($ssl_vhost === true
&& $domain['ssl'] == '1') && $domain['ssl'] == '1'
{ ) {
$query = "SELECT * FROM " . TABLE_PANEL_IPSANDPORTS . " WHERE `id`='" . $domain['ssl_ipandport'] . "'"; $query = "SELECT * FROM " . TABLE_PANEL_IPSANDPORTS . " WHERE `id`='" . $domain['ssl_ipandport'] . "'";
} } else {
else
{
$query = "SELECT * FROM " . TABLE_PANEL_IPSANDPORTS . " WHERE `id`='" . $domain['ipandport'] . "'"; $query = "SELECT * FROM " . TABLE_PANEL_IPSANDPORTS . " WHERE `id`='" . $domain['ipandport'] . "'";
} }
@@ -395,12 +356,9 @@ class nginx
$domain['port'] = $ipandport['port']; $domain['port'] = $ipandport['port'];
$domain['ssl_cert_file'] = $ipandport['ssl_cert_file']; $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']; $ipport = '[' . $domain['ip'] . ']:' . $domain['port'];
} } else {
else
{
$ipport = $domain['ip'] . ':' . $domain['port']; $ipport = $domain['ip'] . ':' . $domain['port'];
} }
@@ -451,7 +409,7 @@ class nginx
// merge duplicate / sections, #1193 // merge duplicate / sections, #1193
$l_regex1 = "/(location\ \/\ \{)(.*)(\})/smU"; $l_regex1 = "/(location\ \/\ \{)(.*)(\})/smU";
$l_regex2 = "/(location\ \/\ \{.*\})/smU"; $l_regex2 = "/(location\ \/\ \{.*\})/smU";
$replace_by=""; $replace_by = '';
$replacements = preg_match_all($l_regex1,$vhost_content,$out); $replacements = preg_match_all($l_regex1,$vhost_content,$out);
if ($replacements > 1) { if ($replacements > 1) {
foreach ($out[2] as $val) { foreach ($out[2] as $val) {
@@ -466,7 +424,8 @@ class nginx
return $vhost_content; return $vhost_content;
} }
protected function create_pathOptions($domain) { protected function create_pathOptions($domain)
{
$has_location = false; $has_location = false;
$query = "SELECT * FROM " . TABLE_PANEL_HTACCESS . " WHERE `path` LIKE '" . $domain['documentroot'] . "%'"; $query = "SELECT * FROM " . TABLE_PANEL_HTACCESS . " WHERE `path` LIKE '" . $domain['documentroot'] . "%'";
@@ -477,7 +436,6 @@ class nginx
// for each entry in the htaccess table // for each entry in the htaccess table
while ($row = $this->db->fetch_array($result)) { while ($row = $this->db->fetch_array($result)) {
if (!empty($row['error404path'])) { if (!empty($row['error404path'])) {
$defhandler = $row['error404path']; $defhandler = $row['error404path'];
if (!validateUrl($defhandler)) { if (!validateUrl($defhandler)) {
@@ -502,8 +460,7 @@ class nginx
$path_options .= "\t".'error_page 500 502 503 504 ' . $defhandler . ';' . "\n"; $path_options .= "\t".'error_page 500 502 503 504 ' . $defhandler . ';' . "\n";
} }
// if($row['options_indexes'] != '0') // if ($row['options_indexes'] != '0') {
// {
$path = makeCorrectDir(substr($row['path'], strlen($domain['documentroot']) - 1)); $path = makeCorrectDir(substr($row['path'], strlen($domain['documentroot']) - 1));
mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']); mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']);
@@ -521,10 +478,8 @@ class nginx
// check if we have a htpasswd for this path // check if we have a htpasswd for this path
// (damn nginx does not like more than one // (damn nginx does not like more than one
// 'location'-part with the same path) // 'location'-part with the same path)
if(count($htpasswds) > 0) if (count($htpasswds) > 0) {
{ foreach ($htpasswds as $idx => $single) {
foreach($htpasswds as $idx => $single)
{
switch ($single['path']) { switch ($single['path']) {
case '/awstats/': case '/awstats/':
case '/webalizer/': case '/webalizer/':
@@ -543,9 +498,7 @@ class nginx
$path_options .= "\t".'}' . "\n"; $path_options .= "\t".'}' . "\n";
$this->vhost_root_autoindex = false; $this->vhost_root_autoindex = false;
} } else {
else
{
$path_options .= "\t".'location ' . $path . ' {' . "\n"; $path_options .= "\t".'location ' . $path . ' {' . "\n";
if ($this->vhost_root_autoindex) { if ($this->vhost_root_autoindex) {
$path_options .= "\t\t" . 'autoindex on;' . "\n"; $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. * required the fastCGI wrapper to be running to receive the CGI requests.
*/ */
if (customerHasPerlEnabled($domain['customerid']) if (customerHasPerlEnabled($domain['customerid'])
&& $row['options_cgi'] != '0') && $row['options_cgi'] != '0'
{ ) {
$path = makeCorrectDir(substr($row['path'], strlen($domain['documentroot']) - 1)); $path = makeCorrectDir(substr($row['path'], strlen($domain['documentroot']) - 1));
mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']); mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']);
@@ -583,14 +536,10 @@ class nginx
/* /*
* now the rest of the htpasswds * now the rest of the htpasswds
*/ */
if(count($htpasswds) > 0) if (count($htpasswds) > 0) {
{ foreach ($htpasswds as $idx => $single) {
foreach($htpasswds as $idx => $single) //if ($single['path'] != '/') {
{ switch ($single['path']) {
//if($single['path'] != "/")
//{
switch($single['path'])
{
case '/awstats/': case '/awstats/':
case '/webalizer/': case '/webalizer/':
$path_options .= $this->getStats($domain,$single); $path_options .= $this->getStats($domain,$single);
@@ -623,7 +572,6 @@ class nginx
$returnval = array(); $returnval = array();
$x = 0; $x = 0;
while ($row_htpasswds = $this->db->fetch_array($result)) { while ($row_htpasswds = $this->db->fetch_array($result)) {
if (count($row_htpasswds) > 0) { if (count($row_htpasswds) > 0) {
$htpasswd_filename = makeCorrectFile($this->settings['system']['apacheconf_htpasswddir'] . '/' . $row_htpasswds['customerid'] . '-' . md5($row_htpasswds['path']) . '.htpasswd'); $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) protected function composePhpOptions($domain, $ssl_vhost = false)
{ {
$phpopts = ''; $phpopts = '';
if($domain['phpenabled'] == '1') if ($domain['phpenabled'] == '1') {
{
$phpopts = "\t".'location ~ \.php$ {'."\n"; $phpopts = "\t".'location ~ \.php$ {'."\n";
$phpopts.= "\t\t".'try_files $uri =404;'."\n"; $phpopts.= "\t\t".'try_files $uri =404;'."\n";
$phpopts.= "\t\t".'fastcgi_split_path_info ^(.+\.php)(/.+)$;'."\n"; $phpopts.= "\t\t".'fastcgi_split_path_info ^(.+\.php)(/.+)$;'."\n";
@@ -679,14 +626,12 @@ class nginx
$webroot_text = ''; $webroot_text = '';
if ($domain['deactivated'] == '1' if ($domain['deactivated'] == '1'
&& $this->settings['system']['deactivateddocroot'] != '') && $this->settings['system']['deactivateddocroot'] != ''
{ ) {
$webroot_text .= "\t".'# Using docroot for deactivated users...' . "\n"; $webroot_text .= "\t".'# Using docroot for deactivated users...' . "\n";
$webroot_text .= "\t".'root '.makeCorrectDir($this->settings['system']['deactivateddocroot']).';'."\n"; $webroot_text .= "\t".'root '.makeCorrectDir($this->settings['system']['deactivateddocroot']).';'."\n";
$this->_deactivated = true; $this->_deactivated = true;
} } else {
else
{
$webroot_text .= "\t".'root '.makeCorrectDir($domain['documentroot']).';'."\n"; $webroot_text .= "\t".'root '.makeCorrectDir($domain['documentroot']).';'."\n";
$this->_deactivated = false; $this->_deactivated = false;
} }
@@ -708,8 +653,8 @@ class nginx
return $webroot_text; return $webroot_text;
} }
protected function getStats($domain, $single) { protected function getStats($domain, $single)
{
$stats_text = ''; $stats_text = '';
// define basic path to the stats // define basic path to the stats
@@ -742,19 +687,17 @@ class nginx
return $stats_text; return $stats_text;
} }
protected function getLogFiles($domain) { protected function getLogFiles($domain)
{
$logfiles_text = ''; $logfiles_text = '';
$speciallogfile = '';
if ($domain['speciallogfile'] == '1') { if ($domain['speciallogfile'] == '1') {
if ($domain['parentdomainid'] == '0') { if ($domain['parentdomainid'] == '0') {
$speciallogfile = '-' . $domain['domain']; $speciallogfile = '-' . $domain['domain'];
} else { } else {
$speciallogfile = '-' . $domain['parentdomain']; $speciallogfile = '-' . $domain['parentdomain'];
} }
} else {
$speciallogfile = '';
} }
// The normal access/error - logging is enabled // The normal access/error - logging is enabled
@@ -795,14 +738,11 @@ class nginx
} }
} }
$alias = '';
if ($domain['iswildcarddomain'] == '1') { if ($domain['iswildcarddomain'] == '1') {
$alias = '*.' . $domain['domain']; $alias = '*.' . $domain['domain'];
} else { } elseif ($domain['wwwserveralias'] == '1') {
if ($domain['wwwserveralias'] == '1') {
$alias = 'www.' . $domain['domain']; $alias = 'www.' . $domain['domain'];
} else {
$alias = '';
}
} }
// After inserting the AWStats information, // After inserting the AWStats information,
@@ -824,44 +764,26 @@ class nginx
{ {
$server_alias = ''; $server_alias = '';
if($domain['iswildcarddomain'] == '1') if ($domain['iswildcarddomain'] == '1') {
{
$server_alias = '*.' . $domain['domain']; $server_alias = '*.' . $domain['domain'];
} } elseif ($domain['wwwserveralias'] == '1') {
else
{
if($domain['wwwserveralias'] == '1')
{
$server_alias = 'www.' . $domain['domain']; $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'] . '\''); $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']; $server_alias .= ' ' . $alias_domain['domain'];
if($alias_domain['iswildcarddomain'] == '1') if ($alias_domain['iswildcarddomain'] == '1') {
{
$server_alias .= ' *.' . $alias_domain['domain']; $server_alias .= ' *.' . $alias_domain['domain'];
} } elseif ($alias_domain['wwwserveralias'] == '1') {
else
{
if($alias_domain['wwwserveralias'] == '1')
{
$server_alias.= ' www.' . $alias_domain['domain']; $server_alias.= ' www.' . $alias_domain['domain'];
} }
} }
}
$servernames_text = "\t".'server_name '.$domain['domain']; $servernames_text = "\t".'server_name '.$domain['domain'];
if(trim($server_alias) != '') if (trim($server_alias) != '') {
{
$servernames_text .= ' '.$server_alias; $servernames_text .= ' '.$server_alias;
} }
$servernames_text .= ';' . "\n"; $servernames_text .= ';' . "\n";
@@ -874,8 +796,7 @@ class nginx
fwrite($this->debugHandler, ' nginx::writeConfigs: rebuilding ' . $this->settings['system']['apacheconf_vhost'] . "\n"); 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']); $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 // Save one big file
$vhosts_file = ''; $vhosts_file = '';
@@ -885,41 +806,32 @@ class nginx
// 3. main-domains // 3. main-domains
ksort($this->nginx_data); 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_file.= $vhost_content . "\n\n";
} }
$vhosts_filename = $this->settings['system']['apacheconf_vhost']; $vhosts_filename = $this->settings['system']['apacheconf_vhost'];
// Apply header // 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 = '# ' . 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'); $vhosts_file_handler = fopen($vhosts_filename, 'w');
fwrite($vhosts_file_handler, $vhosts_file); fwrite($vhosts_file_handler, $vhosts_file);
fclose($vhosts_file_handler); fclose($vhosts_file_handler);
} } else {
else if (!file_exists($this->settings['system']['apacheconf_vhost'])) {
{
if(!file_exists($this->settings['system']['apacheconf_vhost']))
{
fwrite($this->debugHandler, ' nginx::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'])) . "\n"); 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']))); $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']))); safe_exec('mkdir -p ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'])));
} }
// Write a single file for every 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); $this->known_filenames[] = basename($vhosts_filename);
// Apply header // 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 = '# ' . 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'); $vhosts_file_handler = fopen($vhosts_filename, 'w');
fwrite($vhosts_file_handler, $vhosts_file); fwrite($vhosts_file_handler, $vhosts_file);
fclose($vhosts_file_handler); fclose($vhosts_file_handler);
@@ -931,26 +843,20 @@ class nginx
/* /*
* htaccess stuff * htaccess stuff
*/ */
if(count($this->htpasswds_data) > 0) if (count($this->htpasswds_data) > 0) {
{ if (!file_exists($this->settings['system']['apacheconf_htpasswddir'])) {
if(!file_exists($this->settings['system']['apacheconf_htpasswddir']))
{
$umask = umask(); $umask = umask();
umask(0000); umask(0000);
mkdir($this->settings['system']['apacheconf_htpasswddir'], 0751); mkdir($this->settings['system']['apacheconf_htpasswddir'], 0751);
umask($umask); 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"); 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!!!'; 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!!!'); $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'])) if (is_dir($this->settings['system']['apacheconf_htpasswddir'])) {
{ foreach ($this->htpasswds_data as $htpasswd_filename => $htpasswd_file) {
foreach($this->htpasswds_data as $htpasswd_filename => $htpasswd_file)
{
$this->known_htpasswdsfilenames[] = basename($htpasswd_filename); $this->known_htpasswdsfilenames[] = basename($htpasswd_filename);
$htpasswd_file_handler = fopen($htpasswd_filename, 'w'); $htpasswd_file_handler = fopen($htpasswd_filename, 'w');
fwrite($htpasswd_file_handler, $htpasswd_file); fwrite($htpasswd_file_handler, $htpasswd_file);