2010-01-20 16:55:27 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2010-01-25 10:06:34 +00:00
|
|
|
* This file is part of the Froxlor project.
|
2010-01-20 16:55:27 +00:00
|
|
|
* Copyright (c) 2003-2009 the SysCP Team (see authors).
|
2010-01-25 10:06:34 +00:00
|
|
|
* Copyright (c) 2010 the Froxlor Team (see authors).
|
2010-01-20 16:55:27 +00:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the COPYING
|
|
|
|
* file that was distributed with this source code. You can also view the
|
2010-01-25 10:06:34 +00:00
|
|
|
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
2010-01-20 16:55:27 +00:00
|
|
|
*
|
|
|
|
* @copyright (c) the authors
|
2010-01-25 10:06:34 +00:00
|
|
|
* @author Florian Lippert <flo@syscp.org> (2003-2009)
|
|
|
|
* @author Froxlor team <team@froxlor.org> (2010-)
|
|
|
|
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
2010-01-20 16:55:27 +00:00
|
|
|
* @package Panel
|
2011-05-04 09:59:20 +00:00
|
|
|
*
|
2010-01-20 16:55:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
define('AREA', 'admin');
|
2013-11-18 11:53:33 +00:00
|
|
|
require './lib/init.php';
|
2010-01-20 16:55:27 +00:00
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['id'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$id = intval($_POST['id']);
|
2013-11-06 07:46:45 +00:00
|
|
|
} elseif(isset($_GET['id'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$id = intval($_GET['id']);
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($page == 'customers'
|
|
|
|
&& $userinfo['customers'] != '0'
|
|
|
|
) {
|
|
|
|
if ($action == '') {
|
2011-03-19 12:43:01 +00:00
|
|
|
// clear request data
|
|
|
|
unset($_SESSION['requestData']);
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2010-01-20 16:55:27 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_customers");
|
|
|
|
$fields = array(
|
|
|
|
'c.loginname' => $lng['login']['username'],
|
|
|
|
'a.loginname' => $lng['admin']['admin'],
|
|
|
|
'c.name' => $lng['customer']['name'],
|
2012-10-16 23:06:29 +00:00
|
|
|
'c.email' => $lng['customer']['email'],
|
2010-01-20 16:55:27 +00:00
|
|
|
'c.firstname' => $lng['customer']['firstname'],
|
|
|
|
'c.company' => $lng['customer']['company'],
|
|
|
|
'c.diskspace' => $lng['customer']['diskspace'],
|
|
|
|
'c.diskspace_used' => $lng['customer']['diskspace'] . ' (' . $lng['panel']['used'] . ')',
|
|
|
|
'c.traffic' => $lng['customer']['traffic'],
|
2013-02-25 10:18:12 +00:00
|
|
|
'c.traffic_used' => $lng['customer']['traffic'] . ' (' . $lng['panel']['used'] . ')'
|
2010-01-20 16:55:27 +00:00
|
|
|
);
|
|
|
|
|
2013-12-15 10:47:23 +00:00
|
|
|
$paging = new paging($userinfo, TABLE_PANEL_CUSTOMERS, $fields);
|
2010-01-20 16:55:27 +00:00
|
|
|
$customers = '';
|
2013-11-06 07:46:45 +00:00
|
|
|
$result_stmt = Database::prepare("
|
|
|
|
SELECT `c`.*, `a`.`loginname` AS `adminname`
|
|
|
|
FROM `" . TABLE_PANEL_CUSTOMERS . "` `c`, `" . TABLE_PANEL_ADMINS . "` `a`
|
|
|
|
WHERE " .
|
|
|
|
($userinfo['customers_see_all'] ? '' : " `c`.`adminid` = :adminid AND ") . "
|
|
|
|
`c`.`adminid` = `a`.`adminid` " .
|
|
|
|
$paging->getSqlWhere(true) . " " .
|
2013-12-15 10:47:23 +00:00
|
|
|
$paging->getSqlOrderBy() . " " .
|
2013-11-06 07:46:45 +00:00
|
|
|
$paging->getSqlLimit()
|
|
|
|
);
|
|
|
|
Database::pexecute($result_stmt, array('adminid' => $userinfo['adminid']));
|
|
|
|
$num_rows = Database::num_rows();
|
|
|
|
$paging->setEntries($num_rows);
|
2010-01-20 16:55:27 +00:00
|
|
|
$sortcode = $paging->getHtmlSortCode($lng, true);
|
|
|
|
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
|
|
|
$searchcode = $paging->getHtmlSearchCode($lng);
|
|
|
|
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
|
|
|
$i = 0;
|
|
|
|
$count = 0;
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
|
|
|
|
|
|
if ($paging->checkDisplay($i)) {
|
|
|
|
|
|
|
|
$domains_stmt = Database::prepare("
|
|
|
|
SELECT COUNT(`id`) AS `domains`
|
|
|
|
FROM `" . TABLE_PANEL_DOMAINS . "`
|
|
|
|
WHERE `customerid` = :cid
|
|
|
|
AND `parentdomainid` = '0'
|
|
|
|
AND `id`<> :stdd"
|
|
|
|
);
|
|
|
|
Database::pexecute($domains_stmt, array('cid' => $row['customerid'], 'stdd' => $row['standardsubdomain']));
|
|
|
|
$domains = $domains_stmt->fetch(PDO::FETCH_ASSOC);
|
2010-01-20 16:55:27 +00:00
|
|
|
$row['domains'] = intval($domains['domains']);
|
2013-12-15 10:47:23 +00:00
|
|
|
$dec_places = Settings::Get('panel.decimal_places');
|
|
|
|
$row['traffic_used'] = round($row['traffic_used'] / (1024 * 1024), $dec_places);
|
|
|
|
$row['traffic'] = round($row['traffic'] / (1024 * 1024), $dec_places);
|
|
|
|
$row['diskspace_used'] = round($row['diskspace_used'] / 1024, $dec_places);
|
|
|
|
$row['diskspace'] = round($row['diskspace'] / 1024, $dec_places);
|
2010-04-15 10:39:47 +00:00
|
|
|
$last_login = ((int)$row['lastlogin_succ'] == 0) ? $lng['panel']['neverloggedin'] : date('d.m.Y', $row['lastlogin_succ']);
|
2010-04-15 11:00:27 +00:00
|
|
|
|
2011-02-08 11:53:24 +00:00
|
|
|
/**
|
|
|
|
* percent-values for progressbar
|
|
|
|
*/
|
2011-10-04 09:21:38 +00:00
|
|
|
//For Disk usage
|
2011-02-08 11:53:24 +00:00
|
|
|
if ($row['diskspace'] > 0) {
|
2011-10-04 09:21:38 +00:00
|
|
|
$disk_percent = round(($row['diskspace_used']*100)/$row['diskspace'], 2);
|
|
|
|
$disk_doublepercent = round($disk_percent*2, 2);
|
2011-02-08 11:53:24 +00:00
|
|
|
} else {
|
2011-10-04 09:21:38 +00:00
|
|
|
$disk_percent = 0;
|
|
|
|
$disk_doublepercent = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($row['traffic'] > 0) {
|
|
|
|
$traffic_percent = round(($row['traffic_used']*100)/$row['traffic'], 2);
|
|
|
|
$traffic_doublepercent = round($traffic_percent*2, 2);
|
|
|
|
} else {
|
|
|
|
$traffic_percent = 0;
|
|
|
|
$traffic_doublepercent = 0;
|
2011-02-08 11:53:24 +00:00
|
|
|
}
|
|
|
|
|
2013-10-05 18:06:23 +00:00
|
|
|
$islocked = 0;
|
2013-12-15 10:47:23 +00:00
|
|
|
if ($row['loginfail_count'] >= Settings::Get('login.maxloginattempts')
|
|
|
|
&& $row['lastlogin_fail'] > (time() - Settings::Get('login.deactivatetime'))
|
2010-04-15 11:00:27 +00:00
|
|
|
) {
|
2013-10-05 18:06:23 +00:00
|
|
|
$islocked = 1;
|
2010-04-15 11:00:27 +00:00
|
|
|
}
|
|
|
|
|
2013-12-05 07:37:58 +00:00
|
|
|
$row = str_replace_array('-1', 'UL', $row, 'diskspace traffic mysqls emails email_accounts email_forwarders ftps tickets subdomains');
|
2010-01-20 16:55:27 +00:00
|
|
|
$row = htmlentities_array($row);
|
|
|
|
eval("\$customers.=\"" . getTemplate("customers/customers_customer") . "\";");
|
|
|
|
$count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
$customercount = $num_rows;
|
2010-01-20 16:55:27 +00:00
|
|
|
eval("echo \"" . getTemplate("customers/customers") . "\";");
|
2013-11-06 07:46:45 +00:00
|
|
|
|
|
|
|
} elseif($action == 'su'
|
|
|
|
&& $id != 0
|
|
|
|
) {
|
|
|
|
$result_stmt = Database::prepare("
|
|
|
|
SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "`
|
|
|
|
WHERE `customerid` = :id" .
|
|
|
|
($userinfo['customers_see_all'] ? '' : " AND `adminid` = :adminid")
|
|
|
|
);
|
2013-11-08 08:31:51 +00:00
|
|
|
$params = array('id' => $id);
|
|
|
|
if ($userinfo['customers_see_all'] == '0') {
|
|
|
|
$params['adminid'] = $userinfo['adminid'];
|
|
|
|
}
|
|
|
|
$result = Database::pexecute_first($result_stmt, $params);
|
2013-11-06 07:46:45 +00:00
|
|
|
|
2010-01-20 16:55:27 +00:00
|
|
|
$destination_user = $result['loginname'];
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($destination_user != '') {
|
|
|
|
|
2013-03-23 07:59:20 +00:00
|
|
|
if ($result['deactivated'] == '1') {
|
|
|
|
standard_error("usercurrentlydeactivated", $destination_user);
|
|
|
|
}
|
2013-11-06 07:46:45 +00:00
|
|
|
$result_stmt = Database::prepare("
|
|
|
|
SELECT * FROM `" . TABLE_PANEL_SESSIONS . "`
|
|
|
|
WHERE `userid` = :id
|
|
|
|
AND `hash` = :hash"
|
|
|
|
);
|
2013-11-08 08:31:51 +00:00
|
|
|
$result = Database::pexecute_first($result_stmt, array('id' => $userinfo['userid'], 'hash' => $s));
|
|
|
|
|
2010-01-20 16:55:27 +00:00
|
|
|
$s = md5(uniqid(microtime(), 1));
|
2013-11-06 07:46:45 +00:00
|
|
|
$insert = Database::prepare("
|
|
|
|
INSERT INTO `" . TABLE_PANEL_SESSIONS . "` SET
|
|
|
|
`hash` = :hash,
|
|
|
|
`userid` = :id,
|
|
|
|
`ipaddress` = :ip,
|
|
|
|
`useragent` = :ua,
|
|
|
|
`lastactivity` = :lastact,
|
|
|
|
`language` = :lang,
|
|
|
|
`adminsession` = '0'"
|
|
|
|
);
|
2013-11-08 08:31:51 +00:00
|
|
|
Database::pexecute($insert, array(
|
2013-11-06 07:46:45 +00:00
|
|
|
'hash' => $s,
|
|
|
|
'id' => $id,
|
|
|
|
'ip' => $result['ipaddress'],
|
|
|
|
'ua' => $result['useragent'],
|
|
|
|
'lastact' => time(),
|
|
|
|
'lang' => $result['language']
|
|
|
|
));
|
2010-01-20 16:55:27 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_INFO, "switched user and is now '" . $destination_user . "'");
|
2013-11-11 08:59:03 +00:00
|
|
|
|
|
|
|
$target = (isset($_GET['target']) ? $_GET['target'] : 'index');
|
|
|
|
$redirect = "customer_".$target.".php";
|
|
|
|
if (!file_exists(FROXLOR_INSTALL_DIR."/".$redirect)) {
|
|
|
|
$redirect = "customer_index.php";
|
|
|
|
}
|
|
|
|
redirectTo($redirect, array('s' => $s), true);
|
2013-11-06 07:46:45 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
redirectTo('index.php', array('action' => 'login'));
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2013-11-06 07:46:45 +00:00
|
|
|
|
|
|
|
} elseif($action == 'unlock'
|
|
|
|
&& $id != 0
|
|
|
|
) {
|
|
|
|
$result_stmt = Database::prepare("
|
|
|
|
SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "`
|
|
|
|
WHERE `customerid` = :id" .
|
|
|
|
($userinfo['customers_see_all'] ? '' : " AND `adminid` = :adminid")
|
|
|
|
);
|
2013-12-26 12:34:03 +00:00
|
|
|
$result_data = array('id' => $id);
|
|
|
|
if ($userinfo['customers_see_all'] == '0') {
|
|
|
|
$result_data['adminid'] = $userinfo['adminid'];
|
|
|
|
}
|
|
|
|
$result = Database::pexecute_first($result_stmt, $result_data);
|
2013-11-06 07:46:45 +00:00
|
|
|
|
|
|
|
if ($result['loginname'] != '') {
|
|
|
|
|
|
|
|
if (isset($_POST['send'])
|
|
|
|
&& $_POST['send'] == 'send'
|
|
|
|
) {
|
|
|
|
$result_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET
|
2011-06-18 17:48:16 +00:00
|
|
|
`loginfail_count` = '0'
|
2013-11-06 07:46:45 +00:00
|
|
|
WHERE `customerid`= :id"
|
2010-11-09 09:32:52 +00:00
|
|
|
);
|
2013-11-06 07:46:45 +00:00
|
|
|
Database::pexecute($result_stmt, array('id' => $id));
|
|
|
|
redirectTo($filename, array('page' => $page, 's' => $s));
|
|
|
|
|
|
|
|
} else {
|
2010-11-09 09:32:52 +00:00
|
|
|
ask_yesno('customer_reallyunlock', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $result['loginname']);
|
|
|
|
}
|
|
|
|
}
|
2013-11-06 07:46:45 +00:00
|
|
|
|
|
|
|
} elseif ($action == 'delete'
|
|
|
|
&& $id != 0
|
|
|
|
) {
|
|
|
|
$result_stmt = Database::prepare("
|
|
|
|
SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "`
|
|
|
|
WHERE `customerid` = :id" .
|
|
|
|
($userinfo['customers_see_all'] ? '' : " AND `adminid` = :adminid")
|
|
|
|
);
|
2013-11-08 08:31:51 +00:00
|
|
|
$params = array('id' => $id);
|
|
|
|
if ($userinfo['customers_see_all'] == '0') {
|
|
|
|
$params['adminid'] = $userinfo['adminid'];
|
|
|
|
}
|
|
|
|
$result = Database::pexecute_first($result_stmt, $params);
|
2013-11-06 07:46:45 +00:00
|
|
|
|
|
|
|
if ($result['loginname'] != '') {
|
|
|
|
|
|
|
|
if (isset($_POST['send'])
|
|
|
|
&& $_POST['send'] == 'send'
|
|
|
|
) {
|
|
|
|
$databases_stmt = Database::prepare("
|
|
|
|
SELECT * FROM `" . TABLE_PANEL_DATABASES . "`
|
|
|
|
WHERE `customerid` = :id ORDER BY `dbserver`"
|
|
|
|
);
|
|
|
|
Database::pexecute($databases_stmt, array('id' => $id));
|
|
|
|
Database::needRoot(true);
|
2010-01-20 16:55:27 +00:00
|
|
|
$last_dbserver = 0;
|
|
|
|
|
2013-12-15 10:47:23 +00:00
|
|
|
$dbm = new DbManager($log);
|
2013-12-05 12:55:01 +00:00
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
while ($row_database = $databases_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
|
|
|
|
|
|
if ($last_dbserver != $row_database['dbserver']) {
|
|
|
|
Database::needRoot(true, $row_database['dbserver']);
|
2013-12-05 12:55:01 +00:00
|
|
|
$dbm->getManager()->flushPrivileges();
|
2010-01-20 16:55:27 +00:00
|
|
|
$last_dbserver = $row_database['dbserver'];
|
|
|
|
}
|
|
|
|
|
2013-12-05 12:55:01 +00:00
|
|
|
$dbm->getManager()->deleteDatabase($row_database['databasename']);
|
2013-11-06 07:46:45 +00:00
|
|
|
}
|
|
|
|
|
2013-12-05 12:55:01 +00:00
|
|
|
$dbm->getManager()->flushPrivileges();
|
2013-11-06 07:46:45 +00:00
|
|
|
Database::needRoot(false);
|
|
|
|
$stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `customerid` = :id");
|
|
|
|
Database::pexecute($stmt, array('id' => $id));
|
|
|
|
$stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_DATABASES . "` WHERE `customerid` = :id");
|
|
|
|
Database::pexecute($stmt, array('id' => $id));
|
2014-05-15 12:18:39 +00:00
|
|
|
// first gather all domain-id's to clean up panel_domaintoip accordingly
|
|
|
|
$did_stmt = Database::prepare("SELECT `id` FROM `".TABLE_PANEL_DOMAINS."` WHERE `customerid` = :id");
|
|
|
|
Database::pexecute($did_stmt, array('id' => $id));
|
|
|
|
while ($row = $did_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
|
|
$stmt = Database::prepare("DELETE FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_domain` = :did");
|
|
|
|
Database::pexecute($stmt, array('did' => $row['id']));
|
|
|
|
}
|
2013-11-06 07:46:45 +00:00
|
|
|
$stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `customerid` = :id");
|
|
|
|
Database::pexecute($stmt, array('id' => $id));
|
|
|
|
$domains_deleted = $stmt->rowCount();
|
2013-11-29 17:22:50 +00:00
|
|
|
$stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_HTPASSWDS . "` WHERE `customerid` = :id");
|
2013-11-06 07:46:45 +00:00
|
|
|
Database::pexecute($stmt, array('id' => $id));
|
2013-11-29 17:22:50 +00:00
|
|
|
$stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_HTACCESS . "` WHERE `customerid` = :id");
|
2013-11-06 07:46:45 +00:00
|
|
|
Database::pexecute($stmt, array('id' => $id));
|
2013-12-09 17:16:47 +00:00
|
|
|
$stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_SESSIONS . "` WHERE `userid` = :id AND `adminsession` = '0'");
|
2013-11-06 07:46:45 +00:00
|
|
|
Database::pexecute($stmt, array('id' => $id));
|
|
|
|
$stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_TRAFFIC . "` WHERE `customerid` = :id");
|
|
|
|
Database::pexecute($stmt, array('id' => $id));
|
|
|
|
$stmt = Database::prepare("DELETE FROM `" . TABLE_MAIL_USERS . "` WHERE `customerid` = :id");
|
|
|
|
Database::pexecute($stmt, array('id' => $id));
|
|
|
|
$stmt = Database::prepare("DELETE FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE `customerid` = :id");
|
|
|
|
Database::pexecute($stmt, array('id' => $id));
|
|
|
|
$result2_stmt = Database::prepare("SELECT `username` FROM `" . TABLE_FTP_USERS . "` WHERE `customerid` = :id");
|
|
|
|
Database::pexecute($result2_stmt, array('id' => $id));
|
|
|
|
while ($row = $result2_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
|
|
$stmt = Database::prepare("DELETE FROM `" . TABLE_FTP_QUOTATALLIES . "` WHERE `name` = :name");
|
|
|
|
Database::pexecute($stmt, array('name' => $row['username']));
|
|
|
|
}
|
|
|
|
$stmt = Database::prepare("DELETE FROM `" . TABLE_FTP_GROUPS . "` WHERE `customerid` = :id");
|
|
|
|
Database::pexecute($stmt, array('id' => $id));
|
|
|
|
$stmt = Database::prepare("DELETE FROM `" . TABLE_FTP_USERS . "` WHERE `customerid` = :id");
|
|
|
|
Database::pexecute($stmt, array('id' => $id));
|
2010-05-10 08:42:50 +00:00
|
|
|
|
2010-06-16 12:28:32 +00:00
|
|
|
// Delete all waiting "create user" -tasks for this user, #276
|
|
|
|
// Note: the WHERE selects part of a serialized array, but it should be safe this way
|
2013-11-06 07:46:45 +00:00
|
|
|
$del_stmt = Database::prepare("
|
|
|
|
DELETE FROM `" . TABLE_PANEL_TASKS . "`
|
|
|
|
WHERE `type` = '2' AND `data` LIKE :loginname"
|
|
|
|
);
|
2013-12-13 07:07:52 +00:00
|
|
|
Database::pexecute($del_stmt, array('loginname' => "%:{$result['loginname']};%"));
|
2010-06-16 12:28:32 +00:00
|
|
|
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query = "UPDATE `" . TABLE_PANEL_ADMINS . "` SET `customers_used` = `customers_used` - 1 ";
|
|
|
|
$admin_update_query.= ", `domains_used` = `domains_used` - 0" . (int)($domains_deleted - $result['subdomains_used']);
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($result['mysqls'] != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `mysqls_used` = `mysqls_used` - 0" . (int)$result['mysqls'];
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($result['emails'] != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `emails_used` = `emails_used` - 0" . (int)$result['emails'];
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($result['email_accounts'] != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `email_accounts_used` = `email_accounts_used` - 0" . (int)$result['email_accounts'];
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($result['email_forwarders'] != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `email_forwarders_used` = `email_forwarders_used` - 0" . (int)$result['email_forwarders'];
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($result['email_quota'] != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `email_quota_used` = `email_quota_used` - 0" . (int)$result['email_quota'];
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($result['subdomains'] != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `subdomains_used` = `subdomains_used` - 0" . (int)$result['subdomains'];
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($result['ftps'] != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `ftps_used` = `ftps_used` - 0" . (int)$result['ftps'];
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($result['tickets'] != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `tickets_used` = `tickets_used` - 0" . (int)$result['tickets'];
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if (($result['diskspace'] / 1024) != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `diskspace_used` = `diskspace_used` - 0" . (int)$result['diskspace'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$admin_update_query.= " WHERE `adminid` = '" . (int)$result['adminid'] . "'";
|
2013-11-06 07:46:45 +00:00
|
|
|
Database::query($admin_update_query);
|
2010-01-20 16:55:27 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_INFO, "deleted user '" . $result['loginname'] . "'");
|
2010-10-23 10:20:23 +00:00
|
|
|
inserttask('1');
|
2011-12-06 14:43:34 +00:00
|
|
|
|
2013-03-29 19:10:37 +00:00
|
|
|
// Using nameserver, insert a task which rebuilds the server config
|
|
|
|
inserttask('4');
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2013-03-29 19:10:37 +00:00
|
|
|
if (isset($_POST['delete_userfiles'])
|
|
|
|
&& (int)$_POST['delete_userfiles'] == 1
|
|
|
|
) {
|
2010-10-23 10:20:23 +00:00
|
|
|
inserttask('6', $result['loginname']);
|
2010-01-24 11:30:15 +00:00
|
|
|
}
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2013-03-29 19:10:37 +00:00
|
|
|
// Using filesystem - quota, insert a task which cleans the filesystem - quota
|
|
|
|
inserttask('10');
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2010-01-30 15:30:47 +00:00
|
|
|
/*
|
|
|
|
* move old tickets to archive
|
|
|
|
*/
|
2013-11-06 10:08:48 +00:00
|
|
|
$tickets = ticket::customerHasTickets($id);
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($tickets !== false && isset($tickets[0])) {
|
|
|
|
foreach ($tickets as $ticket) {
|
2010-01-30 15:30:47 +00:00
|
|
|
$now = time();
|
2013-12-15 14:37:07 +00:00
|
|
|
$mainticket = ticket::getInstanceOf($userinfo, (int)$ticket);
|
2010-01-30 15:30:47 +00:00
|
|
|
$mainticket->Set('lastchange', $now, true, true);
|
|
|
|
$mainticket->Set('lastreplier', '1', true, true);
|
|
|
|
$mainticket->Set('status', '3', true, true);
|
|
|
|
$mainticket->Update();
|
|
|
|
$mainticket->Archive();
|
|
|
|
$log->logAction(ADM_ACTION, LOG_NOTICE, "archived ticket '" . $mainticket->Get('subject') . "'");
|
|
|
|
}
|
2011-06-18 17:48:16 +00:00
|
|
|
}
|
2013-11-06 07:46:45 +00:00
|
|
|
redirectTo($filename, array('page' => $page, 's' => $s));
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
} else {
|
2010-01-24 11:30:15 +00:00
|
|
|
ask_yesno_withcheckbox('admin_customer_reallydelete', 'admin_customer_alsoremovefiles', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $result['loginname']);
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
}
|
2013-11-06 07:46:45 +00:00
|
|
|
|
|
|
|
} elseif($action == 'add') {
|
|
|
|
|
|
|
|
if ($userinfo['customers_used'] < $userinfo['customers']
|
|
|
|
|| $userinfo['customers'] == '-1'
|
|
|
|
) {
|
|
|
|
if (isset($_POST['send'])
|
|
|
|
&& $_POST['send'] == 'send'
|
|
|
|
) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$name = validate($_POST['name'], 'name');
|
|
|
|
$firstname = validate($_POST['firstname'], 'first name');
|
|
|
|
$company = validate($_POST['company'], 'company');
|
|
|
|
$street = validate($_POST['street'], 'street');
|
|
|
|
$zipcode = validate($_POST['zipcode'], 'zipcode', '/^[0-9 \-A-Z]*$/');
|
|
|
|
$city = validate($_POST['city'], 'city');
|
|
|
|
$phone = validate($_POST['phone'], 'phone', '/^[0-9\- \+\(\)\/]*$/');
|
|
|
|
$fax = validate($_POST['fax'], 'fax', '/^[0-9\- \+\(\)\/]*$/');
|
|
|
|
$email = $idna_convert->encode(validate($_POST['email'], 'email'));
|
|
|
|
$customernumber = validate($_POST['customernumber'], 'customer number', '/^[A-Za-z0-9 \-]*$/Di');
|
|
|
|
$def_language = validate($_POST['def_language'], 'default language');
|
2011-05-12 16:58:01 +00:00
|
|
|
$gender = intval_ressource($_POST['gender']);
|
2010-01-20 16:55:27 +00:00
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
$diskspace = intval_ressource($_POST['diskspace']);
|
|
|
|
if (isset($_POST['diskspace_ul'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$diskspace = - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$traffic = doubleval_ressource($_POST['traffic']);
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['traffic_ul'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$traffic = - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$subdomains = intval_ressource($_POST['subdomains']);
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['subdomains_ul'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$subdomains = - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$emails = intval_ressource($_POST['emails']);
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['emails_ul'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$emails = - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$email_accounts = intval_ressource($_POST['email_accounts']);
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['email_accounts_ul'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$email_accounts = - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$email_forwarders = intval_ressource($_POST['email_forwarders']);
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['email_forwarders_ul'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$email_forwarders = - 1;
|
|
|
|
}
|
|
|
|
|
2013-12-15 10:47:23 +00:00
|
|
|
if (Settings::Get('system.mail_quota_enabled') == '1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$email_quota = validate($_POST['email_quota'], 'email_quota', '/^\d+$/', 'vmailquotawrong', array('0', ''));
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['email_quota_ul'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$email_quota = - 1;
|
|
|
|
}
|
2013-11-06 07:46:45 +00:00
|
|
|
} else {
|
2010-01-20 16:55:27 +00:00
|
|
|
$email_quota = - 1;
|
|
|
|
}
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2011-03-30 12:37:57 +00:00
|
|
|
$email_imap = 0;
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['email_imap'])) {
|
2011-03-30 12:37:57 +00:00
|
|
|
$email_imap = intval_ressource($_POST['email_imap']);
|
2013-11-06 07:46:45 +00:00
|
|
|
}
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2011-03-30 12:37:57 +00:00
|
|
|
$email_pop3 = 0;
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['email_pop3'])) {
|
2011-03-30 12:37:57 +00:00
|
|
|
$email_pop3 = intval_ressource($_POST['email_pop3']);
|
2013-11-06 07:46:45 +00:00
|
|
|
}
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2011-03-30 12:37:57 +00:00
|
|
|
$ftps = 0;
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['ftps'])) {
|
2011-03-30 12:37:57 +00:00
|
|
|
$ftps = intval_ressource($_POST['ftps']);
|
2013-11-06 07:46:45 +00:00
|
|
|
}
|
|
|
|
if (isset($_POST['ftps_ul'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$ftps = - 1;
|
|
|
|
}
|
|
|
|
|
2013-12-15 10:47:23 +00:00
|
|
|
$tickets = (Settings::Get('ticket.enabled') == 1 ? intval_ressource($_POST['tickets']) : 0);
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['tickets_ul'])
|
2013-12-15 10:47:23 +00:00
|
|
|
&& Settings::Get('ticket.enabled') == '1'
|
2013-11-06 07:46:45 +00:00
|
|
|
) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$tickets = - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$mysqls = intval_ressource($_POST['mysqls']);
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['mysqls_ul'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$mysqls = - 1;
|
|
|
|
}
|
|
|
|
|
2011-03-30 12:37:57 +00:00
|
|
|
$createstdsubdomain = 0;
|
2013-11-06 07:46:45 +00:00
|
|
|
if(isset($_POST['createstdsubdomain'])) {
|
2011-03-30 12:37:57 +00:00
|
|
|
$createstdsubdomain = intval($_POST['createstdsubdomain']);
|
2013-11-06 07:46:45 +00:00
|
|
|
}
|
|
|
|
|
2010-05-11 06:19:44 +00:00
|
|
|
$password = validate($_POST['new_customer_password'], 'password');
|
2010-12-02 09:52:56 +00:00
|
|
|
// only check if not empty,
|
|
|
|
// cause empty == generate password automatically
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($password != '') {
|
2010-12-02 09:52:56 +00:00
|
|
|
$password = validatePassword($password);
|
|
|
|
}
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2011-05-12 16:58:01 +00:00
|
|
|
// gender out of range? [0,2]
|
|
|
|
if ($gender < 0 || $gender > 2) {
|
|
|
|
$gender = 0;
|
|
|
|
}
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2011-03-30 12:37:57 +00:00
|
|
|
$sendpassword = 0;
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['sendpassword'])) {
|
2011-03-30 12:37:57 +00:00
|
|
|
$sendpassword = intval($_POST['sendpassword']);
|
2013-11-06 07:46:45 +00:00
|
|
|
}
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2011-03-30 12:37:57 +00:00
|
|
|
$phpenabled = 0;
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['phpenabled'])) {
|
2011-03-30 12:37:57 +00:00
|
|
|
$phpenabled = intval($_POST['phpenabled']);
|
2013-11-06 07:46:45 +00:00
|
|
|
}
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2011-03-30 12:37:57 +00:00
|
|
|
$perlenabled = 0;
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['perlenabled'])) {
|
2011-03-30 12:37:57 +00:00
|
|
|
$perlenabled = intval($_POST['perlenabled']);
|
2013-11-06 07:46:45 +00:00
|
|
|
}
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2011-03-30 12:37:57 +00:00
|
|
|
$store_defaultindex = 0;
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['store_defaultindex'])) {
|
2011-03-30 12:37:57 +00:00
|
|
|
$store_defaultindex = intval($_POST['store_defaultindex']);
|
2013-11-06 07:46:45 +00:00
|
|
|
}
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2010-01-20 16:55:27 +00:00
|
|
|
$diskspace = $diskspace * 1024;
|
|
|
|
$traffic = $traffic * 1024 * 1024;
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if (((($userinfo['diskspace_used'] + $diskspace) > $userinfo['diskspace']) && ($userinfo['diskspace'] / 1024) != '-1')
|
2010-01-20 16:55:27 +00:00
|
|
|
|| ((($userinfo['mysqls_used'] + $mysqls) > $userinfo['mysqls']) && $userinfo['mysqls'] != '-1')
|
|
|
|
|| ((($userinfo['emails_used'] + $emails) > $userinfo['emails']) && $userinfo['emails'] != '-1')
|
|
|
|
|| ((($userinfo['email_accounts_used'] + $email_accounts) > $userinfo['email_accounts']) && $userinfo['email_accounts'] != '-1')
|
|
|
|
|| ((($userinfo['email_forwarders_used'] + $email_forwarders) > $userinfo['email_forwarders']) && $userinfo['email_forwarders'] != '-1')
|
2013-12-15 10:47:23 +00:00
|
|
|
|| ((($userinfo['email_quota_used'] + $email_quota) > $userinfo['email_quota']) && $userinfo['email_quota'] != '-1' && Settings::Get('system.mail_quota_enabled') == '1')
|
2010-01-20 16:55:27 +00:00
|
|
|
|| ((($userinfo['ftps_used'] + $ftps) > $userinfo['ftps']) && $userinfo['ftps'] != '-1')
|
|
|
|
|| ((($userinfo['tickets_used'] + $tickets) > $userinfo['tickets']) && $userinfo['tickets'] != '-1')
|
|
|
|
|| ((($userinfo['subdomains_used'] + $subdomains) > $userinfo['subdomains']) && $userinfo['subdomains'] != '-1')
|
|
|
|
|| (($diskspace / 1024) == '-1' && ($userinfo['diskspace'] / 1024) != '-1')
|
|
|
|
|| ($mysqls == '-1' && $userinfo['mysqls'] != '-1')
|
|
|
|
|| ($emails == '-1' && $userinfo['emails'] != '-1')
|
|
|
|
|| ($email_accounts == '-1' && $userinfo['email_accounts'] != '-1')
|
|
|
|
|| ($email_forwarders == '-1' && $userinfo['email_forwarders'] != '-1')
|
2013-12-15 10:47:23 +00:00
|
|
|
|| ($email_quota == '-1' && $userinfo['email_quota'] != '-1' && Settings::Get('system.mail_quota_enabled') == '1')
|
2010-01-20 16:55:27 +00:00
|
|
|
|| ($ftps == '-1' && $userinfo['ftps'] != '-1')
|
|
|
|
|| ($tickets == '-1' && $userinfo['tickets'] != '-1')
|
|
|
|
|| ($subdomains == '-1' && $userinfo['subdomains'] != '-1')
|
2013-11-06 07:46:45 +00:00
|
|
|
) {
|
2010-01-20 16:55:27 +00:00
|
|
|
standard_error('youcantallocatemorethanyouhave');
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Either $name and $firstname or the $company must be inserted
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($name == '' && $company == '') {
|
2010-01-20 16:55:27 +00:00
|
|
|
standard_error(array('stringisempty', 'myname'));
|
2013-11-06 07:46:45 +00:00
|
|
|
|
|
|
|
} elseif($firstname == '' && $company == '') {
|
2010-01-20 16:55:27 +00:00
|
|
|
standard_error(array('stringisempty', 'myfirstname'));
|
2013-11-06 07:46:45 +00:00
|
|
|
|
|
|
|
} elseif($email == '') {
|
2010-01-20 16:55:27 +00:00
|
|
|
standard_error(array('stringisempty', 'emailadd'));
|
2013-11-06 07:46:45 +00:00
|
|
|
|
|
|
|
} elseif(!validateEmail($email)) {
|
2010-01-20 16:55:27 +00:00
|
|
|
standard_error('emailiswrong', $email);
|
2013-11-06 07:46:45 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (isset($_POST['new_loginname'])
|
|
|
|
&& $_POST['new_loginname'] != ''
|
|
|
|
) {
|
2013-12-15 10:47:23 +00:00
|
|
|
$accountnumber = intval(Settings::Get('system.lastaccountnumber'));
|
2013-12-02 09:57:12 +00:00
|
|
|
$loginname = validate($_POST['new_loginname'], 'loginname', '/^[a-z][a-z0-9\-_]+$/i');
|
2010-01-20 16:55:27 +00:00
|
|
|
|
|
|
|
// Accounts which match systemaccounts are not allowed, filtering them
|
2013-12-15 10:47:23 +00:00
|
|
|
if (preg_match('/^' . preg_quote(Settings::Get('customer.accountprefix'), '/') . '([0-9]+)/', $loginname)) {
|
|
|
|
standard_error('loginnameissystemaccount', Settings::Get('customer.accountprefix'));
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2013-11-06 07:46:45 +00:00
|
|
|
|
|
|
|
// Additional filtering for Bug #962
|
|
|
|
if (function_exists('posix_getpwnam')
|
|
|
|
&& !in_array("posix_getpwnam", explode(",", ini_get('disable_functions')))
|
|
|
|
&& posix_getpwnam($loginname)
|
|
|
|
) {
|
2013-12-15 10:47:23 +00:00
|
|
|
standard_error('loginnameissystemaccount', Settings::Get('customer.accountprefix'));
|
2011-12-06 15:04:35 +00:00
|
|
|
}
|
2013-11-06 07:46:45 +00:00
|
|
|
|
|
|
|
} else {
|
2013-12-15 10:47:23 +00:00
|
|
|
$accountnumber = intval(Settings::Get('system.lastaccountnumber')) + 1;
|
|
|
|
$loginname = Settings::Get('customer.accountprefix') . $accountnumber;
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the account already exists
|
2013-11-06 07:46:45 +00:00
|
|
|
$loginname_check_stmt = Database::prepare("
|
|
|
|
SELECT `loginname` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `loginname` = :loginname"
|
|
|
|
);
|
2013-11-08 08:31:51 +00:00
|
|
|
$loginname_check = Database::pexecute_first($loginname_check_stmt, array('loginname' => $loginname));
|
2010-01-20 16:55:27 +00:00
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
$loginname_check_admin_stmt = Database::prepare("
|
|
|
|
SELECT `loginname` FROM `" . TABLE_PANEL_ADMINS . "` WHERE `loginname` = :loginname"
|
|
|
|
);
|
2013-11-08 08:31:51 +00:00
|
|
|
$loginname_check_admin = Database::pexecute_first($loginname_check_admin_stmt, array('loginname' => $loginname));
|
2010-01-20 16:55:27 +00:00
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if (strtolower($loginname_check['loginname']) == strtolower($loginname)
|
|
|
|
|| strtolower($loginname_check_admin['loginname']) == strtolower($loginname)
|
|
|
|
) {
|
2010-01-20 16:55:27 +00:00
|
|
|
standard_error('loginnameexists', $loginname);
|
2013-11-06 07:46:45 +00:00
|
|
|
|
2013-12-15 10:47:23 +00:00
|
|
|
} elseif (!validateUsername($loginname, Settings::Get('panel.unix_names'), 14 - strlen(Settings::Get('customer.mysqlprefix')))) {
|
|
|
|
if (strlen($loginname) > 14 - strlen(Settings::Get('customer.mysqlprefix'))) {
|
|
|
|
standard_error('loginnameiswrong2', 14 - strlen(Settings::Get('customer.mysqlprefix')));
|
2013-12-03 17:57:17 +00:00
|
|
|
} else {
|
|
|
|
standard_error('loginnameiswrong', $loginname);
|
|
|
|
}
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
|
2013-12-15 10:47:23 +00:00
|
|
|
$guid = intval(Settings::Get('system.lastguid')) + 1;
|
|
|
|
$documentroot = makeCorrectDir(Settings::Get('system.documentroot_prefix') . '/' . $loginname);
|
2010-01-20 16:55:27 +00:00
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if (file_exists($documentroot)) {
|
2010-01-20 16:55:27 +00:00
|
|
|
standard_error('documentrootexists', $documentroot);
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($createstdsubdomain != '1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$createstdsubdomain = '0';
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($phpenabled != '0') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$phpenabled = '1';
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($perlenabled != '0') {
|
2010-07-22 06:02:38 +00:00
|
|
|
$perlenabled = '1';
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($password == '') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$password = substr(md5(uniqid(microtime(), 1)), 12, 6);
|
|
|
|
}
|
|
|
|
|
2013-12-15 10:47:23 +00:00
|
|
|
$_theme = Settings::Get('panel.default_theme');
|
2011-02-08 11:53:24 +00:00
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
$ins_data = array(
|
|
|
|
'adminid' => $userinfo['adminid'],
|
|
|
|
'loginname' => $loginname,
|
|
|
|
'passwd' => md5($password),
|
|
|
|
'name' => $name,
|
|
|
|
'firstname' => $firstname,
|
|
|
|
'gender' => $gender,
|
|
|
|
'company' => $company,
|
|
|
|
'street' => $street,
|
|
|
|
'zipcode' => $zipcode,
|
|
|
|
'city' => $city,
|
|
|
|
'phone' => $phone,
|
|
|
|
'fax' => $fax,
|
|
|
|
'email' => $email,
|
|
|
|
'customerno' => $customernumber,
|
|
|
|
'lang' => $def_language,
|
|
|
|
'docroot' => $documentroot,
|
|
|
|
'guid' => $guid,
|
|
|
|
'diskspace' => $diskspace,
|
|
|
|
'traffic' => $traffic,
|
|
|
|
'subdomains' => $subdomains,
|
|
|
|
'emails' => $emails,
|
|
|
|
'email_accounts' => $email_accounts,
|
|
|
|
'email_forwarders' => $email_forwarders,
|
|
|
|
'email_quota' => $email_quota,
|
|
|
|
'ftps' => $ftps,
|
|
|
|
'tickets' => $tickets,
|
|
|
|
'mysqls' => $mysqls,
|
|
|
|
'phpenabled' => $phpenabled,
|
|
|
|
'imap' => $email_imap,
|
|
|
|
'pop3' => $email_pop3,
|
|
|
|
'perlenabled' => $perlenabled,
|
2014-03-05 06:59:32 +00:00
|
|
|
'theme' => $_theme
|
2013-11-06 07:46:45 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$ins_stmt = Database::prepare("
|
|
|
|
INSERT INTO `" . TABLE_PANEL_CUSTOMERS . "` SET
|
|
|
|
`adminid` = :adminid,
|
|
|
|
`loginname` = :loginname,
|
|
|
|
`password` = :passwd,
|
|
|
|
`name` = :name,
|
|
|
|
`firstname` = :firstname,
|
|
|
|
`gender` = :gender,
|
|
|
|
`company` = :company,
|
|
|
|
`street` = :street,
|
|
|
|
`zipcode` = :zipcode,
|
|
|
|
`city` = :city,
|
|
|
|
`phone` = :phone,
|
|
|
|
`fax` = :fax,
|
|
|
|
`email` = :email,
|
|
|
|
`customernumber` = :customerno,
|
|
|
|
`def_language` = :lang,
|
|
|
|
`documentroot` = :docroot,
|
|
|
|
`guid` = :guid,
|
|
|
|
`diskspace` = :diskspace,
|
|
|
|
`traffic` = :traffic,
|
|
|
|
`subdomains` = :subdomains,
|
|
|
|
`emails` = :emails,
|
|
|
|
`email_accounts` = :email_accounts,
|
|
|
|
`email_forwarders` = :email_forwarders,
|
|
|
|
`email_quota` = :email_quota,
|
|
|
|
`ftps` = :ftps,
|
|
|
|
`tickets` = :tickets,
|
2013-11-06 10:29:40 +00:00
|
|
|
`mysqls` = :mysqls,
|
2011-06-18 17:48:16 +00:00
|
|
|
`standardsubdomain` = '0',
|
2013-11-06 07:46:45 +00:00
|
|
|
`phpenabled` = :phpenabled,
|
|
|
|
`imap` = :imap,
|
|
|
|
`pop3` = :pop3,
|
|
|
|
`perlenabled` = :perlenabled,
|
|
|
|
`theme` = :theme"
|
2011-02-08 11:53:24 +00:00
|
|
|
);
|
2013-11-06 07:46:45 +00:00
|
|
|
Database::pexecute($ins_stmt, $ins_data);
|
|
|
|
|
|
|
|
$customerid = Database::lastInsertId();
|
|
|
|
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query = "UPDATE `" . TABLE_PANEL_ADMINS . "` SET `customers_used` = `customers_used` + 1";
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($mysqls != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `mysqls_used` = `mysqls_used` + 0" . (int)$mysqls;
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($emails != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `emails_used` = `emails_used` + 0" . (int)$emails;
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($email_accounts != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `email_accounts_used` = `email_accounts_used` + 0" . (int)$email_accounts;
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($email_forwarders != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `email_forwarders_used` = `email_forwarders_used` + 0" . (int)$email_forwarders;
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($email_quota != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `email_quota_used` = `email_quota_used` + 0" . (int)$email_quota;
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($subdomains != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `subdomains_used` = `subdomains_used` + 0" . (int)$subdomains;
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($ftps != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `ftps_used` = `ftps_used` + 0" . (int)$ftps;
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($tickets != '-1'
|
2013-12-15 10:47:23 +00:00
|
|
|
&& Settings::Get('ticket.enabled') == 1
|
2013-11-06 07:46:45 +00:00
|
|
|
) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `tickets_used` = `tickets_used` + 0" . (int)$tickets;
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if (($diskspace / 1024) != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `diskspace_used` = `diskspace_used` + 0" . (int)$diskspace;
|
|
|
|
}
|
|
|
|
|
|
|
|
$admin_update_query.= " WHERE `adminid` = '" . (int)$userinfo['adminid'] . "'";
|
2013-11-06 07:46:45 +00:00
|
|
|
Database::query($admin_update_query);
|
2010-01-20 16:55:27 +00:00
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
$upd_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_SETTINGS . "` SET
|
|
|
|
`value` = :guid
|
|
|
|
WHERE `settinggroup` = 'system' AND `varname` = 'lastguid'"
|
|
|
|
);
|
|
|
|
Database::pexecute($upd_stmt, array('guid' => $guid));
|
|
|
|
|
2013-12-15 10:47:23 +00:00
|
|
|
if ($accountnumber != intval(Settings::Get('system.lastaccountnumber'))) {
|
2013-11-06 07:46:45 +00:00
|
|
|
$upd_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_SETTINGS . "` SET
|
|
|
|
`value` = :accno
|
|
|
|
WHERE `settinggroup` = 'system' AND `varname` = 'lastaccountnumber'"
|
|
|
|
);
|
|
|
|
Database::pexecute($upd_stmt, array('accno' => $accountnumber));
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$log->logAction(ADM_ACTION, LOG_INFO, "added user '" . $loginname . "'");
|
2010-10-23 10:20:23 +00:00
|
|
|
inserttask('2', $loginname, $guid, $guid, $store_defaultindex);
|
2010-01-20 16:55:27 +00:00
|
|
|
|
2013-03-29 19:10:37 +00:00
|
|
|
// Using filesystem - quota, insert a task which cleans the filesystem - quota
|
|
|
|
inserttask('10');
|
2010-01-20 16:55:27 +00:00
|
|
|
|
2013-03-29 19:10:37 +00:00
|
|
|
// Add htpasswd for the webalizer stats
|
2013-11-06 07:46:45 +00:00
|
|
|
if (CRYPT_STD_DES == 1) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$saltfordescrypt = substr(md5(uniqid(microtime(), 1)), 4, 2);
|
|
|
|
$htpasswdPassword = crypt($password, $saltfordescrypt);
|
2013-11-06 07:46:45 +00:00
|
|
|
} else {
|
2010-01-20 16:55:27 +00:00
|
|
|
$htpasswdPassword = crypt($password);
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
$ins_stmt = Database::prepare("
|
|
|
|
INSERT INTO `" . TABLE_PANEL_HTPASSWDS . "` SET
|
|
|
|
`customerid` = :customerid,
|
|
|
|
`username` = :username,
|
|
|
|
`password` = :passwd,
|
|
|
|
`path` = :path"
|
|
|
|
);
|
|
|
|
$ins_data = array(
|
|
|
|
'customerid' => $customerid,
|
|
|
|
'username' => $loginname,
|
|
|
|
'passwd' => $htpasswdPassword
|
|
|
|
);
|
|
|
|
|
2013-12-15 10:47:23 +00:00
|
|
|
if (Settings::Get('system.awstats_enabled') == '1') {
|
2013-11-06 07:46:45 +00:00
|
|
|
$ins_data['path'] = makeCorrectDir($documentroot . '/awstats/');
|
2010-01-20 16:55:27 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_NOTICE, "automatically added awstats htpasswd for user '" . $loginname . "'");
|
2013-11-06 07:46:45 +00:00
|
|
|
} else {
|
|
|
|
$ins_data['path'] = makeCorrectDir($documentroot . '/webalizer/');
|
2010-03-22 12:36:59 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_NOTICE, "automatically added webalizer htpasswd for user '" . $loginname . "'");
|
|
|
|
}
|
2013-11-06 07:46:45 +00:00
|
|
|
Database::pexecute($ins_stmt, $ins_data);
|
2010-01-20 16:55:27 +00:00
|
|
|
|
2010-10-23 10:20:23 +00:00
|
|
|
inserttask('1');
|
2013-04-14 16:41:21 +00:00
|
|
|
$cryptPassword = makeCryptPassword($password);
|
2013-11-06 07:46:45 +00:00
|
|
|
// FTP-User
|
|
|
|
$ins_stmt = Database::prepare("
|
2014-01-02 21:45:30 +00:00
|
|
|
INSERT INTO `" . TABLE_FTP_USERS . "` SET `customerid` = :customerid, `username` = :username, `description` = :desc,
|
2013-11-06 07:46:45 +00:00
|
|
|
`password` = :passwd, `homedir` = :homedir, `login_enabled` = 'y', `uid` = :guid, `gid` = :guid"
|
|
|
|
);
|
|
|
|
$ins_data = array(
|
|
|
|
'customerid' => $customerid,
|
|
|
|
'username' => $loginname,
|
|
|
|
'passwd' => $cryptPassword,
|
|
|
|
'homedir' => $documentroot,
|
2014-01-02 21:45:30 +00:00
|
|
|
'guid' => $guid,
|
|
|
|
'desc' => "Default"
|
2013-11-06 07:46:45 +00:00
|
|
|
);
|
|
|
|
Database::pexecute($ins_stmt, $ins_data);
|
|
|
|
// FTP-Group
|
|
|
|
$ins_stmt = Database::prepare("
|
|
|
|
INSERT INTO `" . TABLE_FTP_GROUPS . "` SET `customerid` = :customerid, `groupname` = :groupname, `gid` = :guid, `members` = :members"
|
|
|
|
);
|
|
|
|
$ins_data = array(
|
|
|
|
'customerid' => $customerid,
|
|
|
|
'groupname' => $loginname,
|
|
|
|
'guid' => $guid,
|
2013-12-15 10:47:23 +00:00
|
|
|
'members' => $loginname.','.Settings::Get('system.httpuser')
|
2013-11-06 07:46:45 +00:00
|
|
|
);
|
|
|
|
Database::pexecute($ins_stmt, $ins_data);
|
|
|
|
// FTP-Quotatallies
|
|
|
|
$ins_stmt = Database::prepare("
|
|
|
|
INSERT INTO `" . TABLE_FTP_QUOTATALLIES . "` SET `name` = :name, `quota_type` = 'user', `bytes_in_used` = '0',
|
|
|
|
`bytes_out_used` = '0', `bytes_xfer_used` = '0', `files_in_used` = '0', `files_out_used` = '0', `files_xfer_used` = '0'"
|
|
|
|
);
|
|
|
|
Database::pexecute($ins_stmt, array('name' => $loginname));
|
2010-01-20 16:55:27 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_NOTICE, "automatically added ftp-account for user '" . $loginname . "'");
|
|
|
|
|
2013-12-05 10:50:49 +00:00
|
|
|
$_stdsubdomain = '';
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($createstdsubdomain == '1') {
|
|
|
|
|
2013-12-15 10:47:23 +00:00
|
|
|
if (Settings::Get('system.stdsubdomain') !== null
|
|
|
|
&& Settings::Get('system.stdsubdomain') != ''
|
2010-04-02 13:51:25 +00:00
|
|
|
) {
|
2013-12-15 10:47:23 +00:00
|
|
|
$_stdsubdomain = $loginname . '.' . Settings::Get('system.stdsubdomain');
|
2013-11-06 07:46:45 +00:00
|
|
|
} else {
|
2013-12-15 10:47:23 +00:00
|
|
|
$_stdsubdomain = $loginname . '.' . Settings::Get('system.hostname');
|
2010-04-02 13:51:25 +00:00
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
$ins_data = array(
|
|
|
|
'domain' => $_stdsubdomain,
|
|
|
|
'customerid' => $customerid,
|
|
|
|
'adminid' => $userinfo['adminid'],
|
|
|
|
'docroot' => $documentroot,
|
|
|
|
'adddate' => date('Y-m-d')
|
|
|
|
);
|
|
|
|
$ins_stmt = Database::prepare("
|
|
|
|
INSERT INTO `" . TABLE_PANEL_DOMAINS . "` SET
|
|
|
|
`domain` = :domain,
|
|
|
|
`customerid` = :customerid,
|
|
|
|
`adminid` = :adminid,
|
|
|
|
`parentdomainid` = '-1',
|
|
|
|
`documentroot` = :docroot,
|
|
|
|
`zonefile` = '',
|
|
|
|
`isemaildomain` = '0',
|
|
|
|
`caneditdomain` = '0',
|
|
|
|
`openbasedir` = '1',
|
|
|
|
`speciallogfile` = '0',
|
2013-11-07 09:26:54 +00:00
|
|
|
`specialsettings` = '',
|
2014-03-05 07:11:56 +00:00
|
|
|
`dkim_id` = '0',
|
|
|
|
`dkim_privkey` = '',
|
|
|
|
`dkim_pubkey` = '',
|
2013-11-06 07:46:45 +00:00
|
|
|
`add_date` = :adddate"
|
|
|
|
);
|
|
|
|
Database::pexecute($ins_stmt, $ins_data);
|
|
|
|
$domainid = Database::lastInsertId();
|
|
|
|
|
2013-09-24 15:32:40 +00:00
|
|
|
// set ip <-> domain connection
|
2013-11-06 07:46:45 +00:00
|
|
|
$ins_stmt = Database::prepare("
|
2013-11-09 12:56:27 +00:00
|
|
|
INSERT INTO `".TABLE_DOMAINTOIP."` SET `id_domain` = :domainid, `id_ipandports` = :ipid"
|
2013-09-24 15:32:40 +00:00
|
|
|
);
|
2013-12-15 10:47:23 +00:00
|
|
|
Database::pexecute($ins_stmt, array('domainid' => $domainid, 'ipid' => Settings::Get('system.defaultip')));
|
2013-09-24 15:32:40 +00:00
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
$upd_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `standardsubdomain` = :domainid WHERE `customerid` = :customerid"
|
|
|
|
);
|
|
|
|
Database::pexecute($upd_stmt, array('domainid' => $domainid, 'customerid' => $customerid));
|
2010-01-20 16:55:27 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_NOTICE, "automatically added standardsubdomain for user '" . $loginname . "'");
|
2010-10-23 10:20:23 +00:00
|
|
|
inserttask('1');
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($sendpassword == '1') {
|
|
|
|
|
2013-12-15 10:47:23 +00:00
|
|
|
$srv_hostname = Settings::Get('system.hostname');
|
|
|
|
if (Settings::Get('system.froxlordirectlyviahostname') == '0') {
|
2013-12-05 10:50:49 +00:00
|
|
|
$srv_hostname .= '/froxlor';
|
|
|
|
}
|
|
|
|
|
|
|
|
$srv_ip_stmt = Database::prepare("
|
|
|
|
SELECT ip, port FROM `".TABLE_PANEL_IPSANDPORTS."`
|
|
|
|
WHERE `id` = :defaultip
|
|
|
|
");
|
2013-12-15 10:47:23 +00:00
|
|
|
$srv_ip = Database::pexecute_first($srv_ip_stmt, array('defaultip' => Settings::Get('system.defaultip')));
|
2013-12-05 10:50:49 +00:00
|
|
|
|
2010-01-20 16:55:27 +00:00
|
|
|
$replace_arr = array(
|
|
|
|
'FIRSTNAME' => $firstname,
|
|
|
|
'NAME' => $name,
|
|
|
|
'COMPANY' => $company,
|
|
|
|
'SALUTATION' => getCorrectUserSalutation(array('firstname' => $firstname, 'name' => $name, 'company' => $company)),
|
|
|
|
'USERNAME' => $loginname,
|
2013-12-05 10:50:49 +00:00
|
|
|
'PASSWORD' => $password,
|
|
|
|
'SERVER_HOSTNAME' => $srv_hostname,
|
|
|
|
'SERVER_IP' => isset($srv_ip['ip']) ? $srv_ip['ip'] : '',
|
|
|
|
'SERVER_PORT' => isset($srv_ip['port']) ? $srv_ip['port'] : '',
|
|
|
|
'DOMAINNAME' => $_stdsubdomain
|
2010-01-20 16:55:27 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// Get mail templates from database; the ones from 'admin' are fetched for fallback
|
2013-11-06 07:46:45 +00:00
|
|
|
$result_stmt = Database::prepare("
|
|
|
|
SELECT `value` FROM `" . TABLE_PANEL_TEMPLATES . "`
|
|
|
|
WHERE `adminid` = :adminid AND `language` = :deflang AND `templategroup` = 'mails' AND `varname` = 'createcustomer_subject'"
|
|
|
|
);
|
2013-11-08 08:31:51 +00:00
|
|
|
$result = Database::pexecute_first($result_stmt, array('adminid' => $userinfo['adminid'], 'deflang' => $def_language));
|
2010-01-20 16:55:27 +00:00
|
|
|
$mail_subject = html_entity_decode(replace_variables((($result['value'] != '') ? $result['value'] : $lng['mails']['createcustomer']['subject']), $replace_arr));
|
2013-11-06 07:46:45 +00:00
|
|
|
|
|
|
|
$result_stmt = Database::prepare("
|
|
|
|
SELECT `value` FROM `" . TABLE_PANEL_TEMPLATES . "`
|
|
|
|
WHERE `adminid` = :adminid AND `language` = :deflang AND `templategroup` = 'mails' AND `varname` = 'createcustomer_mailbody'"
|
|
|
|
);
|
2013-11-08 08:31:51 +00:00
|
|
|
$result = Database::pexecute_first($result_stmt, array('adminid' => $userinfo['adminid'], 'deflang' => $def_language));
|
2010-01-20 16:55:27 +00:00
|
|
|
$mail_body = html_entity_decode(replace_variables((($result['value'] != '') ? $result['value'] : $lng['mails']['createcustomer']['mailbody']), $replace_arr));
|
|
|
|
|
2010-03-03 08:51:13 +00:00
|
|
|
$_mailerror = false;
|
|
|
|
try {
|
|
|
|
$mail->Subject = $mail_subject;
|
|
|
|
$mail->AltBody = $mail_body;
|
2010-03-05 07:13:00 +00:00
|
|
|
$mail->MsgHTML(str_replace("\n", "<br />", $mail_body));
|
2010-03-03 08:51:13 +00:00
|
|
|
$mail->AddAddress($email, getCorrectUserSalutation(array('firstname' => $firstname, 'name' => $name, 'company' => $company)));
|
|
|
|
$mail->Send();
|
|
|
|
} catch(phpmailerException $e) {
|
|
|
|
$mailerr_msg = $e->errorMessage();
|
|
|
|
$_mailerror = true;
|
|
|
|
} catch (Exception $e) {
|
|
|
|
$mailerr_msg = $e->getMessage();
|
|
|
|
$_mailerror = true;
|
|
|
|
}
|
2010-01-20 16:55:27 +00:00
|
|
|
|
2010-03-03 08:51:13 +00:00
|
|
|
if ($_mailerror) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg);
|
|
|
|
standard_error('errorsendingmail', $email);
|
|
|
|
}
|
|
|
|
|
|
|
|
$mail->ClearAddresses();
|
|
|
|
$log->logAction(ADM_ACTION, LOG_NOTICE, "automatically sent password to user '" . $loginname . "'");
|
|
|
|
}
|
2013-11-11 08:59:03 +00:00
|
|
|
redirectTo($filename, array('page' => $page, 's' => $s));
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2013-11-06 07:46:45 +00:00
|
|
|
|
|
|
|
} else {
|
2010-01-20 16:55:27 +00:00
|
|
|
$language_options = '';
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
while (list($language_file, $language_name) = each($languages)) {
|
2013-12-15 10:47:23 +00:00
|
|
|
$language_options.= makeoption($language_name, $language_file, Settings::Get('panel.standardlanguage'), true);
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$diskspace_ul = makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
|
|
|
|
$traffic_ul = makecheckbox('traffic_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
|
|
|
|
$subdomains_ul = makecheckbox('subdomains_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
|
|
|
|
$emails_ul = makecheckbox('emails_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
|
|
|
|
$email_accounts_ul = makecheckbox('email_accounts_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
|
|
|
|
$email_forwarders_ul = makecheckbox('email_forwarders_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
|
|
|
|
$email_quota_ul = makecheckbox('email_quota_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
|
|
|
|
$ftps_ul = makecheckbox('ftps_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
|
|
|
|
$tickets_ul = makecheckbox('tickets_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
|
|
|
|
$mysqls_ul = makecheckbox('mysqls_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2011-05-12 16:58:01 +00:00
|
|
|
$gender_options = makeoption($lng['gender']['undef'], 0, true, true, true);
|
|
|
|
$gender_options .= makeoption($lng['gender']['male'], 1, null, true, true);
|
|
|
|
$gender_options .= makeoption($lng['gender']['female'], 2, null, true, true);
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2011-02-08 11:53:24 +00:00
|
|
|
$customer_add_data = include_once dirname(__FILE__).'/lib/formfields/admin/customer/formfield.customer_add.php';
|
|
|
|
$customer_add_form = htmlform::genHTMLForm($customer_add_data);
|
|
|
|
|
|
|
|
$title = $customer_add_data['customer_add']['title'];
|
|
|
|
$image = $customer_add_data['customer_add']['image'];
|
|
|
|
|
2010-01-20 16:55:27 +00:00
|
|
|
eval("echo \"" . getTemplate("customers/customers_add") . "\";");
|
|
|
|
}
|
|
|
|
}
|
2013-11-06 07:46:45 +00:00
|
|
|
|
|
|
|
} elseif($action == 'edit'
|
|
|
|
&& $id != 0
|
|
|
|
) {
|
|
|
|
|
2013-11-06 10:29:40 +00:00
|
|
|
$result_data = array('id' => $id);
|
2013-11-06 07:46:45 +00:00
|
|
|
$result_stmt = Database::prepare("
|
|
|
|
SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "`
|
2013-11-06 10:29:40 +00:00
|
|
|
WHERE `customerid` = :id" . ($userinfo['customers_see_all'] ? '' : " AND `adminid` = :adminid")
|
2013-11-06 07:46:45 +00:00
|
|
|
);
|
2013-11-06 10:29:40 +00:00
|
|
|
if ($userinfo['customers_see_all'] == '0') {
|
|
|
|
$result_data['adminid'] = $userinfo['adminid'];
|
|
|
|
}
|
|
|
|
$result = Database::pexecute_first($result_stmt, $result_data);
|
2013-11-06 07:46:45 +00:00
|
|
|
|
|
|
|
if ($result['loginname'] != '') {
|
|
|
|
|
|
|
|
if (isset($_POST['send'])
|
|
|
|
&& $_POST['send'] == 'send'
|
|
|
|
) {
|
|
|
|
|
2010-01-20 16:55:27 +00:00
|
|
|
$name = validate($_POST['name'], 'name');
|
|
|
|
$firstname = validate($_POST['firstname'], 'first name');
|
|
|
|
$company = validate($_POST['company'], 'company');
|
|
|
|
$street = validate($_POST['street'], 'street');
|
|
|
|
$zipcode = validate($_POST['zipcode'], 'zipcode', '/^[0-9 \-A-Z]*$/');
|
|
|
|
$city = validate($_POST['city'], 'city');
|
|
|
|
$phone = validate($_POST['phone'], 'phone', '/^[0-9\- \+\(\)\/]*$/');
|
|
|
|
$fax = validate($_POST['fax'], 'fax', '/^[0-9\- \+\(\)\/]*$/');
|
|
|
|
$email = $idna_convert->encode(validate($_POST['email'], 'email'));
|
|
|
|
$customernumber = validate($_POST['customernumber'], 'customer number', '/^[A-Za-z0-9 \-]*$/Di');
|
|
|
|
$def_language = validate($_POST['def_language'], 'default language');
|
2010-05-11 06:19:44 +00:00
|
|
|
$password = validate($_POST['new_customer_password'], 'new password');
|
2011-05-18 11:56:18 +00:00
|
|
|
$gender = intval_ressource($_POST['gender']);
|
2010-01-20 16:55:27 +00:00
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
$diskspace = intval_ressource($_POST['diskspace']);
|
|
|
|
if (isset($_POST['diskspace_ul'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$diskspace = - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$traffic = doubleval_ressource($_POST['traffic']);
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['traffic_ul'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$traffic = - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$subdomains = intval_ressource($_POST['subdomains']);
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['subdomains_ul'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$subdomains = - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$emails = intval_ressource($_POST['emails']);
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['emails_ul'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$emails = - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$email_accounts = intval_ressource($_POST['email_accounts']);
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['email_accounts_ul'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$email_accounts = - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$email_forwarders = intval_ressource($_POST['email_forwarders']);
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['email_forwarders_ul'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$email_forwarders = - 1;
|
|
|
|
}
|
|
|
|
|
2013-12-15 10:47:23 +00:00
|
|
|
if (Settings::Get('system.mail_quota_enabled') == '1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$email_quota = validate($_POST['email_quota'], 'email_quota', '/^\d+$/', 'vmailquotawrong', array('0', ''));
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['email_quota_ul'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$email_quota = - 1;
|
|
|
|
}
|
2013-11-06 07:46:45 +00:00
|
|
|
} else {
|
2010-01-20 16:55:27 +00:00
|
|
|
$email_quota = - 1;
|
|
|
|
}
|
|
|
|
|
2011-03-30 12:37:57 +00:00
|
|
|
$email_imap = 0;
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['email_imap'])) {
|
2011-03-30 12:37:57 +00:00
|
|
|
$email_imap = intval_ressource($_POST['email_imap']);
|
2013-11-06 07:46:45 +00:00
|
|
|
}
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2011-03-30 12:37:57 +00:00
|
|
|
$email_pop3 = 0;
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['email_pop3'])) {
|
2011-03-30 12:37:57 +00:00
|
|
|
$email_pop3 = intval_ressource($_POST['email_pop3']);
|
2013-11-06 07:46:45 +00:00
|
|
|
}
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2011-03-30 12:37:57 +00:00
|
|
|
$ftps = 0;
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['ftps'])) {
|
2011-03-30 12:37:57 +00:00
|
|
|
$ftps = intval_ressource($_POST['ftps']);
|
2013-11-06 07:46:45 +00:00
|
|
|
}
|
|
|
|
if (isset($_POST['ftps_ul'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$ftps = - 1;
|
|
|
|
}
|
|
|
|
|
2013-12-15 10:47:23 +00:00
|
|
|
$tickets = (Settings::Get('ticket.enabled') == 1 ? intval_ressource($_POST['tickets']) : 0);
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['tickets_ul'])
|
2013-12-15 10:47:23 +00:00
|
|
|
&& Settings::Get('ticket.enabled') == '1'
|
2013-11-06 07:46:45 +00:00
|
|
|
) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$tickets = - 1;
|
|
|
|
}
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2011-05-12 16:58:01 +00:00
|
|
|
// gender out of range? [0,2]
|
|
|
|
if ($gender < 0 || $gender > 2) {
|
|
|
|
$gender = 0;
|
|
|
|
}
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2011-03-30 12:37:57 +00:00
|
|
|
$mysqls = 0;
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['mysqls'])) {
|
2011-03-30 12:37:57 +00:00
|
|
|
$mysqls = intval_ressource($_POST['mysqls']);
|
2013-11-06 07:46:45 +00:00
|
|
|
}
|
|
|
|
if (isset($_POST['mysqls_ul'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$mysqls = - 1;
|
|
|
|
}
|
|
|
|
|
2011-03-30 12:37:57 +00:00
|
|
|
$createstdsubdomain = 0;
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['createstdsubdomain'])) {
|
2011-03-30 12:37:57 +00:00
|
|
|
$createstdsubdomain = intval($_POST['createstdsubdomain']);
|
2013-11-06 07:46:45 +00:00
|
|
|
}
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2011-03-30 12:37:57 +00:00
|
|
|
$deactivated = 0;
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['deactivated'])) {
|
2011-03-30 12:37:57 +00:00
|
|
|
$deactivated = intval($_POST['deactivated']);
|
2013-11-06 07:46:45 +00:00
|
|
|
}
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2011-03-30 12:37:57 +00:00
|
|
|
$phpenabled = 0;
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['phpenabled'])) {
|
2011-03-30 12:37:57 +00:00
|
|
|
$phpenabled = intval($_POST['phpenabled']);
|
2013-11-06 07:46:45 +00:00
|
|
|
}
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2011-03-30 12:37:57 +00:00
|
|
|
$perlenabled = 0;
|
2013-11-06 07:46:45 +00:00
|
|
|
if (isset($_POST['perlenabled'])) {
|
2011-03-30 12:37:57 +00:00
|
|
|
$perlenabled = intval($_POST['perlenabled']);
|
2013-11-06 07:46:45 +00:00
|
|
|
}
|
|
|
|
|
2010-01-20 16:55:27 +00:00
|
|
|
$diskspace = $diskspace * 1024;
|
|
|
|
$traffic = $traffic * 1024 * 1024;
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if (((($userinfo['diskspace_used'] + $diskspace - $result['diskspace']) > $userinfo['diskspace']) && ($userinfo['diskspace'] / 1024) != '-1')
|
2010-01-20 16:55:27 +00:00
|
|
|
|| ((($userinfo['mysqls_used'] + $mysqls - $result['mysqls']) > $userinfo['mysqls']) && $userinfo['mysqls'] != '-1')
|
|
|
|
|| ((($userinfo['emails_used'] + $emails - $result['emails']) > $userinfo['emails']) && $userinfo['emails'] != '-1')
|
|
|
|
|| ((($userinfo['email_accounts_used'] + $email_accounts - $result['email_accounts']) > $userinfo['email_accounts']) && $userinfo['email_accounts'] != '-1')
|
|
|
|
|| ((($userinfo['email_forwarders_used'] + $email_forwarders - $result['email_forwarders']) > $userinfo['email_forwarders']) && $userinfo['email_forwarders'] != '-1')
|
2013-12-15 10:47:23 +00:00
|
|
|
|| ((($userinfo['email_quota_used'] + $email_quota - $result['email_quota']) > $userinfo['email_quota']) && $userinfo['email_quota'] != '-1' && Settings::Get('system.mail_quota_enabled') == '1')
|
2010-01-20 16:55:27 +00:00
|
|
|
|| ((($userinfo['ftps_used'] + $ftps - $result['ftps']) > $userinfo['ftps']) && $userinfo['ftps'] != '-1')
|
|
|
|
|| ((($userinfo['tickets_used'] + $tickets - $result['tickets']) > $userinfo['tickets']) && $userinfo['tickets'] != '-1')
|
|
|
|
|| ((($userinfo['subdomains_used'] + $subdomains - $result['subdomains']) > $userinfo['subdomains']) && $userinfo['subdomains'] != '-1')
|
|
|
|
|| (($diskspace / 1024) == '-1' && ($userinfo['diskspace'] / 1024) != '-1')
|
|
|
|
|| ($mysqls == '-1' && $userinfo['mysqls'] != '-1')
|
|
|
|
|| ($emails == '-1' && $userinfo['emails'] != '-1')
|
|
|
|
|| ($email_accounts == '-1' && $userinfo['email_accounts'] != '-1')
|
|
|
|
|| ($email_forwarders == '-1' && $userinfo['email_forwarders'] != '-1')
|
2013-12-15 10:47:23 +00:00
|
|
|
|| ($email_quota == '-1' && $userinfo['email_quota'] != '-1' && Settings::Get('system.mail_quota_enabled') == '1')
|
2010-01-20 16:55:27 +00:00
|
|
|
|| ($ftps == '-1' && $userinfo['ftps'] != '-1')
|
|
|
|
|| ($tickets == '-1' && $userinfo['tickets'] != '-1')
|
|
|
|
|| ($subdomains == '-1' && $userinfo['subdomains'] != '-1')
|
2013-11-06 07:46:45 +00:00
|
|
|
) {
|
2010-01-20 16:55:27 +00:00
|
|
|
standard_error('youcantallocatemorethanyouhave');
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Either $name and $firstname or the $company must be inserted
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($name == '' && $company == '') {
|
2010-01-20 16:55:27 +00:00
|
|
|
standard_error(array('stringisempty', 'myname'));
|
2013-11-06 07:46:45 +00:00
|
|
|
|
|
|
|
} elseif($firstname == '' && $company == '') {
|
2010-01-20 16:55:27 +00:00
|
|
|
standard_error(array('stringisempty', 'myfirstname'));
|
2013-11-06 07:46:45 +00:00
|
|
|
|
|
|
|
} elseif($email == '') {
|
2010-01-20 16:55:27 +00:00
|
|
|
standard_error(array('stringisempty', 'emailadd'));
|
2013-11-06 07:46:45 +00:00
|
|
|
|
|
|
|
} elseif(!validateEmail($email)) {
|
2010-01-20 16:55:27 +00:00
|
|
|
standard_error('emailiswrong', $email);
|
2013-11-06 07:46:45 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if ($password != '') {
|
2010-03-17 07:51:16 +00:00
|
|
|
$password = validatePassword($password);
|
2010-01-20 16:55:27 +00:00
|
|
|
$password = md5($password);
|
2013-11-06 07:46:45 +00:00
|
|
|
} else {
|
2010-01-20 16:55:27 +00:00
|
|
|
$password = $result['password'];
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($createstdsubdomain != '1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$createstdsubdomain = '0';
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($createstdsubdomain == '1'
|
|
|
|
&& $result['standardsubdomain'] == '0'
|
|
|
|
) {
|
|
|
|
|
2013-12-15 10:47:23 +00:00
|
|
|
if (Settings::Get('system.stdsubdomain') !== null
|
|
|
|
&& Settings::Get('system.stdsubdomain') != ''
|
2010-04-02 13:51:25 +00:00
|
|
|
) {
|
2013-12-15 10:47:23 +00:00
|
|
|
$_stdsubdomain = $result['loginname'] . '.' . Settings::Get('system.stdsubdomain');
|
2013-11-06 07:46:45 +00:00
|
|
|
} else {
|
2013-12-15 10:47:23 +00:00
|
|
|
$_stdsubdomain = $result['loginname'] . '.' . Settings::Get('system.hostname');
|
2010-04-02 13:51:25 +00:00
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
$ins_data = array(
|
|
|
|
'domain' => $_stdsubdomain,
|
|
|
|
'customerid' => $result['customerid'],
|
|
|
|
'adminid' => $userinfo['adminid'],
|
|
|
|
'docroot' => $result['documentroot'],
|
|
|
|
'adddate' => date('Y-m-d')
|
|
|
|
);
|
|
|
|
$ins_stmt = Database::prepare("
|
|
|
|
INSERT INTO `" . TABLE_PANEL_DOMAINS . "` SET
|
|
|
|
`domain` = :domain,
|
|
|
|
`customerid` = :customerid,
|
|
|
|
`adminid` = :adminid,
|
2013-09-24 15:32:40 +00:00
|
|
|
`parentdomainid` = '-1',
|
2013-11-06 07:46:45 +00:00
|
|
|
`documentroot` = :docroot,
|
2013-09-24 15:32:40 +00:00
|
|
|
`zonefile` = '',
|
|
|
|
`isemaildomain` = '0',
|
|
|
|
`caneditdomain` = '0',
|
|
|
|
`openbasedir` = '1',
|
|
|
|
`speciallogfile` = '0',
|
2013-11-07 09:26:54 +00:00
|
|
|
`specialsettings` = '',
|
2013-11-06 07:46:45 +00:00
|
|
|
`add_date` = :adddate"
|
2013-09-24 15:32:40 +00:00
|
|
|
);
|
2013-11-06 07:46:45 +00:00
|
|
|
Database::pexecute($ins_stmt, $ins_data);
|
|
|
|
$domainid = Database::lastInsertId();
|
|
|
|
|
2013-09-24 15:32:40 +00:00
|
|
|
// set ip <-> domain connection
|
2013-11-06 07:46:45 +00:00
|
|
|
$ins_stmt = Database::prepare("
|
2013-12-13 06:15:13 +00:00
|
|
|
INSERT INTO `".TABLE_DOMAINTOIP."` SET `id_domain` = :domainid, `id_ipandports` = :ipid"
|
2013-09-24 15:32:40 +00:00
|
|
|
);
|
2013-12-15 10:47:23 +00:00
|
|
|
Database::pexecute($ins_stmt, array('domainid' => $domainid, 'ipid' => Settings::Get('system.defaultip')));
|
2013-11-06 07:46:45 +00:00
|
|
|
|
|
|
|
$upd_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `standardsubdomain` = :domainid WHERE `customerid` = :customerid"
|
2013-09-24 15:32:40 +00:00
|
|
|
);
|
2013-11-06 07:46:45 +00:00
|
|
|
Database::pexecute($upd_stmt, array('domainid' => $domainid, 'customerid' => $result['customerid']));
|
2010-01-20 16:55:27 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_NOTICE, "automatically added standardsubdomain for user '" . $result['loginname'] . "'");
|
2010-10-23 10:20:23 +00:00
|
|
|
inserttask('1');
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($createstdsubdomain == '0'
|
|
|
|
&& $result['standardsubdomain'] != '0'
|
|
|
|
) {
|
|
|
|
|
|
|
|
$del_stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `id` = :stdsub");
|
|
|
|
Database::pexecute($del_stmt, array('stdsub' => $result['standardsubdomain']));
|
|
|
|
$del_stmt = Database::prepare("DELETE FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_domain` = :stdsub");
|
|
|
|
Database::pexecute($del_stmt, array('stdsub' => $result['standardsubdomain']));
|
|
|
|
$del_stmt = Database::prepare("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `standardsubdomain`= '0' WHERE `customerid` = :customerid");
|
|
|
|
Database::pexecute($del_stmt, array('customerid' => $result['customerid']));
|
2010-01-20 16:55:27 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_NOTICE, "automatically deleted standardsubdomain for user '" . $result['loginname'] . "'");
|
2010-10-23 10:20:23 +00:00
|
|
|
inserttask('1');
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($deactivated != '1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$deactivated = '0';
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($phpenabled != '0') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$phpenabled = '1';
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($perlenabled != '0') {
|
2010-07-22 06:02:38 +00:00
|
|
|
$perlenabled = '1';
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($phpenabled != $result['phpenabled']
|
|
|
|
|| $perlenabled != $result['perlenabled']
|
|
|
|
) {
|
2010-10-23 10:20:23 +00:00
|
|
|
inserttask('1');
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
// activate/deactivate customer services
|
|
|
|
if ($deactivated != $result['deactivated']) {
|
|
|
|
|
|
|
|
$yesno = (($deactivated) ? 'N' : 'Y');
|
|
|
|
$pop3 = (($deactivated) ? '0' : (int)$result['pop3']);
|
|
|
|
$imap = (($deactivated) ? '0' : (int)$result['imap']);
|
|
|
|
|
|
|
|
$upd_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_MAIL_USERS . "` SET `postfix`= :yesno, `pop3` = :pop3, `imap` = :imap WHERE `customerid` = :customerid"
|
|
|
|
);
|
|
|
|
Database::pexecute($upd_stmt, array('yesno' => $yesno, 'pop3' => $pop3, 'imap' => $imap, 'customerid' => $id));
|
|
|
|
|
|
|
|
$upd_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_FTP_USERS . "` SET `login_enabled` = :yesno WHERE `customerid` = :customerid"
|
|
|
|
);
|
|
|
|
Database::pexecute($upd_stmt, array('yesno' => $yesno, 'customerid' => $id));
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
$upd_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_DOMAINS . "` SET `deactivated`= :deactivated WHERE `customerid` = :customerid"
|
|
|
|
);
|
|
|
|
Database::pexecute($upd_stmt, array('deactivated' => $deactivated, 'customerid' => $id));
|
|
|
|
|
|
|
|
// Retrieve customer's databases
|
|
|
|
$databases_stmt = Database::prepare("SELECT * FROM " . TABLE_PANEL_DATABASES . " WHERE customerid = :customerid ORDER BY `dbserver`");
|
|
|
|
Database::pexecute($databases_stmt, array('customerid' => $id));
|
|
|
|
|
|
|
|
Database::needRoot(true);
|
2011-03-18 15:14:12 +00:00
|
|
|
$last_dbserver = 0;
|
2013-12-05 12:55:01 +00:00
|
|
|
|
2013-12-15 10:47:23 +00:00
|
|
|
$dbm = new DbManager($log);
|
2013-12-05 12:55:01 +00:00
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
// For each of them
|
|
|
|
while ($row_database = $databases_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2011-03-18 15:14:12 +00:00
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($last_dbserver != $row_database['dbserver']) {
|
2013-12-05 12:55:01 +00:00
|
|
|
$dbm->getManager()->flushPrivileges();
|
2013-11-06 07:46:45 +00:00
|
|
|
Database::needRoot(true, $row_database['dbserver']);
|
2011-03-18 15:14:12 +00:00
|
|
|
$last_dbserver = $row_database['dbserver'];
|
|
|
|
}
|
|
|
|
|
2013-12-15 10:47:23 +00:00
|
|
|
foreach (array_unique(explode(',', Settings::Get('system.mysql_access_host'))) as $mysql_access_host) {
|
2011-03-18 15:14:12 +00:00
|
|
|
$mysql_access_host = trim($mysql_access_host);
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
// Prevent access, if deactivated
|
|
|
|
if ($deactivated) {
|
2012-11-19 18:22:21 +00:00
|
|
|
// failsafe if user has been deleted manually (requires MySQL 4.1.2+)
|
2013-12-05 12:55:01 +00:00
|
|
|
$dbm->getManager()->disableUser($row_database['databasename'], $mysql_access_host);
|
2013-11-06 07:46:45 +00:00
|
|
|
} else {
|
|
|
|
// Otherwise grant access
|
2013-12-05 12:55:01 +00:00
|
|
|
$dbm->getManager()->enableUser($row_database['databasename'], $mysql_access_host);
|
2011-03-18 15:14:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-05 12:55:01 +00:00
|
|
|
// At last flush the new privileges
|
|
|
|
$dbm->getManager()->flushPrivileges();
|
2013-11-06 07:46:45 +00:00
|
|
|
Database::needRoot(false);
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2010-01-20 16:55:27 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_INFO, "deactivated user '" . $result['loginname'] . "'");
|
2010-10-23 10:20:23 +00:00
|
|
|
inserttask('1');
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Disable or enable POP3 Login for customers Mail Accounts
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($email_pop3 != $result['pop3']) {
|
|
|
|
$upd_stmt = Database::prepare("UPDATE `" . TABLE_MAIL_USERS . "` SET `pop3` = :pop3 WHERE `customerid` = :customerid");
|
|
|
|
Database::pexecute($upd_stmt, array('pop3' => $email_pop3, 'customerid' => $id));
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Disable or enable IMAP Login for customers Mail Accounts
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($email_imap != $result['imap']) {
|
|
|
|
$upd_stmt = Database::prepare("UPDATE `" . TABLE_MAIL_USERS . "` SET `imap` = :imap WHERE `customerid` = :customerid");
|
2013-11-30 15:07:23 +00:00
|
|
|
Database::pexecute($upd_stmt, array('imap' => $email_imap, 'customerid' => $id));
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
$upd_data = array(
|
|
|
|
'customerid' => $id,
|
|
|
|
'passwd' => $password,
|
|
|
|
'name' => $name,
|
|
|
|
'firstname' => $firstname,
|
|
|
|
'gender' => $gender,
|
|
|
|
'company' => $company,
|
|
|
|
'street' => $street,
|
|
|
|
'zipcode' => $zipcode,
|
|
|
|
'city' => $city,
|
|
|
|
'phone' => $phone,
|
|
|
|
'fax' => $fax,
|
|
|
|
'email' => $email,
|
|
|
|
'customerno' => $customernumber,
|
|
|
|
'lang' => $def_language,
|
|
|
|
'diskspace' => $diskspace,
|
|
|
|
'traffic' => $traffic,
|
|
|
|
'subdomains' => $subdomains,
|
|
|
|
'emails' => $emails,
|
|
|
|
'email_accounts' => $email_accounts,
|
|
|
|
'email_forwarders' => $email_forwarders,
|
|
|
|
'email_quota' => $email_quota,
|
|
|
|
'ftps' => $ftps,
|
|
|
|
'tickets' => $tickets,
|
|
|
|
'mysqls' => $mysqls,
|
|
|
|
'deactivated' => $deactivated,
|
|
|
|
'phpenabled' => $phpenabled,
|
|
|
|
'imap' => $email_imap,
|
|
|
|
'pop3' => $email_pop3,
|
2013-12-05 07:37:58 +00:00
|
|
|
'perlenabled' => $perlenabled
|
2013-11-06 07:46:45 +00:00
|
|
|
);
|
|
|
|
$upd_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET
|
|
|
|
`name` = :name,
|
|
|
|
`firstname` = :firstname,
|
|
|
|
`gender` = :gender,
|
|
|
|
`company` = :company,
|
|
|
|
`street` = :street,
|
|
|
|
`zipcode` = :zipcode,
|
|
|
|
`city` = :city,
|
|
|
|
`phone` = :phone,
|
|
|
|
`fax` = :fax,
|
|
|
|
`email` = :email,
|
|
|
|
`customernumber` = :customerno,
|
|
|
|
`def_language` = :lang,
|
|
|
|
`password` = :passwd,
|
|
|
|
`diskspace` = :diskspace,
|
|
|
|
`traffic` = :traffic,
|
|
|
|
`subdomains` = :subdomains,
|
|
|
|
`emails` = :emails,
|
|
|
|
`email_accounts` = :email_accounts,
|
|
|
|
`email_forwarders` = :email_forwarders,
|
|
|
|
`ftps` = :ftps,
|
|
|
|
`tickets` = :tickets,
|
2013-11-06 10:29:40 +00:00
|
|
|
`mysqls` = :mysqls,
|
2013-11-06 07:46:45 +00:00
|
|
|
`deactivated` = :deactivated,
|
|
|
|
`phpenabled` = :phpenabled,
|
|
|
|
`email_quota` = :email_quota,
|
|
|
|
`imap` = :imap,
|
|
|
|
`pop3` = :pop3,
|
2013-12-05 07:37:58 +00:00
|
|
|
`perlenabled` = :perlenabled
|
2013-11-06 07:46:45 +00:00
|
|
|
WHERE `customerid` = :customerid"
|
|
|
|
);
|
|
|
|
Database::pexecute($upd_stmt, $upd_data);
|
2010-01-20 16:55:27 +00:00
|
|
|
|
2013-03-29 19:10:37 +00:00
|
|
|
// Using filesystem - quota, insert a task which cleans the filesystem - quota
|
|
|
|
inserttask('10');
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
$admin_update_query = "UPDATE `" . TABLE_PANEL_ADMINS . "` SET `customers_used` = `customers_used` ";
|
|
|
|
|
|
|
|
if ($mysqls != '-1' || $result['mysqls'] != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `mysqls_used` = `mysqls_used` ";
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($mysqls != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= " + 0" . (int)$mysqls . " ";
|
|
|
|
}
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($result['mysqls'] != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= " - 0" . (int)$result['mysqls'] . " ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if($emails != '-1' || $result['emails'] != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `emails_used` = `emails_used` ";
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($emails != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= " + 0" . (int)$emails . " ";
|
|
|
|
}
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($result['emails'] != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= " - 0" . (int)$result['emails'] . " ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($email_accounts != '-1' || $result['email_accounts'] != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `email_accounts_used` = `email_accounts_used` ";
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($email_accounts != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= " + 0" . (int)$email_accounts . " ";
|
|
|
|
}
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($result['email_accounts'] != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= " - 0" . (int)$result['email_accounts'] . " ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($email_forwarders != '-1' || $result['email_forwarders'] != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `email_forwarders_used` = `email_forwarders_used` ";
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($email_forwarders != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= " + 0" . (int)$email_forwarders . " ";
|
|
|
|
}
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($result['email_forwarders'] != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= " - 0" . (int)$result['email_forwarders'] . " ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($email_quota != '-1' || $result['email_quota'] != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `email_quota_used` = `email_quota_used` ";
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($email_quota != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= " + 0" . (int)$email_quota . " ";
|
|
|
|
}
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($result['email_quota'] != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= " - 0" . (int)$result['email_quota'] . " ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($subdomains != '-1' || $result['subdomains'] != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `subdomains_used` = `subdomains_used` ";
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($subdomains != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= " + 0" . (int)$subdomains . " ";
|
|
|
|
}
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($result['subdomains'] != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= " - 0" . (int)$result['subdomains'] . " ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($ftps != '-1' || $result['ftps'] != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `ftps_used` = `ftps_used` ";
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($ftps != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= " + 0" . (int)$ftps . " ";
|
|
|
|
}
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($result['ftps'] != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= " - 0" . (int)$result['ftps'] . " ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($tickets != '-1' || $result['tickets'] != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `tickets_used` = `tickets_used` ";
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($tickets != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= " + 0" . (int)$tickets . " ";
|
|
|
|
}
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($result['tickets'] != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= " - 0" . (int)$result['tickets'] . " ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if (($diskspace / 1024) != '-1' || ($result['diskspace'] / 1024) != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= ", `diskspace_used` = `diskspace_used` ";
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
if (($diskspace / 1024) != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= " + 0" . (int)$diskspace . " ";
|
|
|
|
}
|
2013-11-06 07:46:45 +00:00
|
|
|
if (($result['diskspace'] / 1024) != '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$admin_update_query.= " - 0" . (int)$result['diskspace'] . " ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$admin_update_query.= " WHERE `adminid` = '" . (int)$result['adminid'] . "'";
|
2013-11-06 07:46:45 +00:00
|
|
|
Database::query($admin_update_query);
|
2010-01-20 16:55:27 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_INFO, "edited user '" . $result['loginname'] . "'");
|
|
|
|
$redirect_props = Array(
|
|
|
|
'page' => $page,
|
|
|
|
's' => $s
|
|
|
|
);
|
|
|
|
|
|
|
|
redirectTo($filename, $redirect_props);
|
|
|
|
}
|
2013-11-06 07:46:45 +00:00
|
|
|
|
|
|
|
} else {
|
2010-01-20 16:55:27 +00:00
|
|
|
$language_options = '';
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
while (list($language_file, $language_name) = each($languages)) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$language_options.= makeoption($language_name, $language_file, $result['def_language'], true);
|
|
|
|
}
|
|
|
|
|
2013-12-15 10:47:23 +00:00
|
|
|
$dec_places = Settings::Get('panel.decimal_places');
|
|
|
|
$result['traffic'] = round($result['traffic'] / (1024 * 1024), $dec_places);
|
|
|
|
$result['diskspace'] = round($result['diskspace'] / 1024, $dec_places);
|
2010-01-20 16:55:27 +00:00
|
|
|
$result['email'] = $idna_convert->decode($result['email']);
|
|
|
|
|
2013-11-06 07:46:45 +00:00
|
|
|
$diskspace_ul = makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, $result['diskspace'], true, true);
|
|
|
|
if ($result['diskspace'] == '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$result['diskspace'] = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
$traffic_ul = makecheckbox('traffic_ul', $lng['customer']['unlimited'], '-1', false, $result['traffic'], true, true);
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($result['traffic'] == '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$result['traffic'] = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
$subdomains_ul = makecheckbox('subdomains_ul', $lng['customer']['unlimited'], '-1', false, $result['subdomains'], true, true);
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($result['subdomains'] == '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$result['subdomains'] = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
$emails_ul = makecheckbox('emails_ul', $lng['customer']['unlimited'], '-1', false, $result['emails'], true, true);
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($result['emails'] == '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$result['emails'] = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
$email_accounts_ul = makecheckbox('email_accounts_ul', $lng['customer']['unlimited'], '-1', false, $result['email_accounts'], true, true);
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($result['email_accounts'] == '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$result['email_accounts'] = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
$email_forwarders_ul = makecheckbox('email_forwarders_ul', $lng['customer']['unlimited'], '-1', false, $result['email_forwarders'], true, true);
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($result['email_forwarders'] == '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$result['email_forwarders'] = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
$email_quota_ul = makecheckbox('email_quota_ul', $lng['customer']['unlimited'], '-1', false, $result['email_quota'], true, true);
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($result['email_quota'] == '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$result['email_quota'] = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
$ftps_ul = makecheckbox('ftps_ul', $lng['customer']['unlimited'], '-1', false, $result['ftps'], true, true);
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($result['ftps'] == '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$result['ftps'] = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
$tickets_ul = makecheckbox('tickets_ul', $lng['customer']['unlimited'], '-1', false, $result['tickets'], true, true);
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($result['tickets'] == '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$result['tickets'] = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
$mysqls_ul = makecheckbox('mysqls_ul', $lng['customer']['unlimited'], '-1', false, $result['mysqls'], true, true);
|
2013-11-06 07:46:45 +00:00
|
|
|
if ($result['mysqls'] == '-1') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$result['mysqls'] = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
$result = htmlentities_array($result);
|
2011-02-08 11:53:24 +00:00
|
|
|
|
2011-05-12 16:58:01 +00:00
|
|
|
$gender_options = makeoption($lng['gender']['undef'], 0, ($result['gender'] == '0' ? true : false), true, true);
|
|
|
|
$gender_options .= makeoption($lng['gender']['male'], 1, ($result['gender'] == '1' ? true : false), true, true);
|
|
|
|
$gender_options .= makeoption($lng['gender']['female'], 2, ($result['gender'] == '2' ? true : false), true, true);
|
2011-06-18 17:48:16 +00:00
|
|
|
|
2011-02-08 11:53:24 +00:00
|
|
|
$customer_edit_data = include_once dirname(__FILE__).'/lib/formfields/admin/customer/formfield.customer_edit.php';
|
|
|
|
$customer_edit_form = htmlform::genHTMLForm($customer_edit_data);
|
|
|
|
|
|
|
|
$title = $customer_edit_data['customer_edit']['title'];
|
|
|
|
$image = $customer_edit_data['customer_edit']['image'];
|
|
|
|
|
2010-01-20 16:55:27 +00:00
|
|
|
eval("echo \"" . getTemplate("customers/customers_edit") . "\";");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|