本文整理汇总了PHP中showBadRequestErrorPage函数的典型用法代码示例。如果您正苦于以下问题:PHP showBadRequestErrorPage函数的具体用法?PHP showBadRequestErrorPage怎么用?PHP showBadRequestErrorPage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了showBadRequestErrorPage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reseller_loadUserData
/**
* Load user data
*
* @param int $adminId Customer unique identifier
* @return void
*/
function reseller_loadUserData($adminId)
{
global $adminName, $email, $customerId, $firstName, $lastName, $firm, $zip, $gender, $city, $state, $country, $street1, $street2, $phone, $fax;
$stmt = exec_query('
SELECT
admin_name, created_by, fname, lname, firm, zip, city, state, country, email, phone, fax, street1,
street2, customer_id, gender
FROM
admin
WHERE
admin_id = ?
AND
created_by = ?
', array($adminId, $_SESSION['user_id']));
if ($stmt->rowCount()) {
$data = $stmt->fetchRow();
$adminName = $data['admin_name'];
$email = $data['email'];
$customerId = $data['customer_id'];
$firstName = $data['fname'];
$lastName = $data['lname'];
$gender = $data['gender'];
$firm = $data['firm'];
$zip = $data['zip'];
$city = $data['city'];
$state = $data['state'];
$country = $data['country'];
$street1 = $data['street1'];
$street2 = $data['street2'];
$phone = $data['phone'];
$fax = $data['fax'];
} else {
showBadRequestErrorPage();
}
}
示例2: generatePage
/**
* Generate domain statistics for the given period
*
* @param iMSCP_pTemplate $tpl Template engine instance
* @param int $userId User unique identifier
* @return void
*/
function generatePage($tpl, $userId)
{
$stmt = exec_query('
SELECT
admin_name, domain_id
FROM
admin
INNER JOIN
domain ON(domain_admin_id = admin_id)
WHERE
admin_id = ?
AND
created_by = ?
', array($userId, $_SESSION['user_id']));
if (!$stmt->rowCount()) {
showBadRequestErrorPage();
}
$row = $stmt->fetchRow(PDO::FETCH_ASSOC);
$domainId = $row['domain_id'];
$adminName = decode_idna($row['admin_name']);
if (isset($_POST['month']) && isset($_POST['year'])) {
$year = intval($_POST['year']);
$month = intval($_POST['month']);
} else {
$month = date('m');
$year = date('Y');
}
$stmt = exec_query('SELECT dtraff_time FROM domain_traffic WHERE domain_id = ? ORDER BY dtraff_time ASC LIMIT 1', $domainId);
if ($stmt->rowCount()) {
$row = $stmt->fetchRow(PDO::FETCH_ASSOC);
$numberYears = date('y') - date('y', $row['dtraff_time']);
$numberYears = $numberYears ? $numberYears + 1 : 1;
} else {
$numberYears = 1;
}
generateMonthsAndYearsHtmlList($tpl, $month, $year, $numberYears);
$stmt = exec_query('SELECT domain_id FROM domain_traffic WHERE dtraff_time BETWEEN ? AND ? LIMIT 1', array(getFirstDayOfMonth($month, $year), getLastDayOfMonth($month, $year)));
if ($stmt->rowCount()) {
$requestedPeriod = getLastDayOfMonth($month, $year);
$toDay = $requestedPeriod < time() ? date('j', $requestedPeriod) : date('j');
$all = array_fill(0, 8, 0);
$dateFormat = iMSCP_Registry::get('config')->DATE_FORMAT;
for ($fromDay = 1; $fromDay <= $toDay; $fromDay++) {
$beginTime = mktime(0, 0, 0, $month, $fromDay, $year);
$endTime = mktime(23, 59, 59, $month, $fromDay, $year);
list($webTraffic, $ftpTraffic, $smtpTraffic, $popTraffic) = _getDomainTraffic($domainId, $beginTime, $endTime);
$tpl->assign(array('DATE' => date($dateFormat, strtotime($year . '-' . $month . '-' . $fromDay)), 'WEB_TRAFFIC' => bytesHuman($webTraffic), 'FTP_TRAFFIC' => bytesHuman($ftpTraffic), 'SMTP_TRAFFIC' => bytesHuman($smtpTraffic), 'POP3_TRAFFIC' => bytesHuman($popTraffic), 'ALL_TRAFFIC' => bytesHuman($webTraffic + $ftpTraffic + $smtpTraffic + $popTraffic)));
$all[0] += $webTraffic;
$all[1] += $ftpTraffic;
$all[2] += $smtpTraffic;
$all[3] += $popTraffic;
$tpl->parse('TRAFFIC_TABLE_ITEM', '.traffic_table_item');
}
$tpl->assign(array('USER_ID' => tohtml($userId), 'USERNAME' => tohtml($adminName), 'ALL_WEB_TRAFFIC' => tohtml(bytesHuman($all[0])), 'ALL_FTP_TRAFFIC' => tohtml(bytesHuman($all[1])), 'ALL_SMTP_TRAFFIC' => tohtml(bytesHuman($all[2])), 'ALL_POP3_TRAFFIC' => tohtml(bytesHuman($all[3])), 'ALL_ALL_TRAFFIC' => tohtml(bytesHuman(array_sum($all)))));
} else {
set_page_message(tr('No statistics found for the given period. Try another period.'), 'static_info');
$tpl->assign(array('USERNAME' => tohtml($adminName), 'USER_ID' => tohtml($userId), 'USER_STATISTICS_DETAILS_BLOCK' => ''));
}
}
示例3: reseller_generatePage
/**
* Generates page
*
* @param iMSCP_pTemplate $tpl Template instance engine
* @param int $domainId Domain unique identifier
* @return void
*/
function reseller_generatePage($tpl, $domainId)
{
$stmt = exec_query('
SELECT
domain_admin_id
FROM
domain
INNER JOIN
admin ON(admin_id = domain_admin_id)
WHERE
domain_id = ?
AND
created_by = ?
', array($domainId, $_SESSION['user_id']));
if (!$stmt->rowCount()) {
showBadRequestErrorPage();
}
$domainAdminId = $stmt->fields['domain_admin_id'];
$domainProperties = get_domain_default_props($domainAdminId, $_SESSION['user_id']);
// Domain IP address info
$stmt = exec_query("SELECT ip_number FROM server_ips WHERE ip_id = ?", $domainProperties['domain_ip_id']);
if (!$stmt->rowCount()) {
$domainIpAddr = tr('Not found.');
} else {
$domainIpAddr = $stmt->fields['ip_number'];
}
$domainStatus = $domainProperties['domain_status'];
// Domain status
if ($domainStatus == 'ok' || $domainStatus == 'disabled' || $domainStatus == 'todelete' || $domainStatus == 'toadd' || $domainStatus == 'torestore' || $domainStatus == 'tochange' || $domainStatus == 'toenable' || $domainStatus == 'todisable') {
$domainStatus = '<span style="color:green">' . tohtml(translate_dmn_status($domainStatus)) . '</span>';
} else {
$domainStatus = '<b><font size="3" color="red">' . $domainStatus . "</font></b>";
}
// Get total domain traffic usage in bytes
$query = "\n SELECT\n IFNULL(SUM(dtraff_web), 0) AS dtraff_web, IFNULL(SUM(dtraff_ftp), 0) AS dtraff_ftp,\n IFNULL(SUM(dtraff_mail), 0) AS dtraff_mail, IFNULL(SUM(dtraff_pop), 0) AS dtraff_pop\n FROM\n domain_traffic\n WHERE\n domain_id = ?\n AND\n dtraff_time BETWEEN ? AND ?\n ";
$stmt = exec_query($query, array($domainProperties['domain_id'], getFirstDayOfMonth(), getLastDayOfMonth()));
if ($stmt->rowCount()) {
$trafficUsageBytes = $stmt->fields['dtraff_web'] + $stmt->fields['dtraff_ftp'] + $stmt->fields['dtraff_mail'] + $stmt->fields['dtraff_pop'];
} else {
$trafficUsageBytes = 0;
}
// Get limits in bytes
$trafficLimitBytes = $domainProperties['domain_traffic_limit'] * 1048576;
$diskspaceLimitBytes = $domainProperties['domain_disk_limit'] * 1048576;
// Get usages in percent
$trafficUsagePercent = make_usage_vals($trafficUsageBytes, $trafficLimitBytes);
$diskspaceUsagePercent = make_usage_vals($domainProperties['domain_disk_usage'], $diskspaceLimitBytes);
// Get Email quota info
list($quota, $quotaLimit) = reseller_gen_mail_quota_limit_mgs($domainAdminId);
# Features
$trEnabled = '<span style="color:green">' . tr('Enabled') . '</span>';
$trDisabled = '<span style="color:red">' . tr('Disabled') . '</span>';
$tpl->assign(array('DOMAIN_ID' => $domainId, 'VL_DOMAIN_NAME' => tohtml(decode_idna($domainProperties['domain_name'])), 'VL_DOMAIN_IP' => tohtml($domainIpAddr), 'VL_STATUS' => $domainStatus, 'VL_PHP_SUPP' => $domainProperties['domain_php'] == 'yes' ? $trEnabled : $trDisabled, 'VL_PHP_EDITOR_SUPP' => $domainProperties['phpini_perm_system'] == 'yes' ? $trEnabled : $trDisabled, 'VL_CGI_SUPP' => $domainProperties['domain_cgi'] == 'yes' ? $trEnabled : $trDisabled, 'VL_DNS_SUPP' => $domainProperties['domain_dns'] == 'yes' ? $trEnabled : $trDisabled, 'VL_EXT_MAIL_SUPP' => $domainProperties['domain_external_mail'] == 'yes' ? $trEnabled : $trDisabled, 'VL_SOFTWARE_SUPP' => $domainProperties['domain_software_allowed'] == 'yes' ? $trEnabled : $trDisabled, 'VL_BACKUP_SUP' => translate_limit_value($domainProperties['allowbackup']), 'VL_TRAFFIC_PERCENT' => $trafficUsagePercent, 'VL_TRAFFIC_USED' => bytesHuman($trafficUsageBytes), 'VL_TRAFFIC_LIMIT' => bytesHuman($trafficLimitBytes), 'VL_DISK_PERCENT' => $diskspaceUsagePercent, 'VL_DISK_USED' => bytesHuman($domainProperties['domain_disk_usage']), 'VL_DISK_LIMIT' => bytesHuman($diskspaceLimitBytes), 'VL_MAIL_ACCOUNTS_USED' => get_domain_running_mail_acc_cnt($domainId), 'VL_MAIL_ACCOUNTS_LIMIT' => translate_limit_value($domainProperties['domain_mailacc_limit']), 'VL_MAIL_QUOTA_USED' => $quota, 'VL_MAIL_QUOTA_LIMIT' => $domainProperties['domain_mailacc_limit'] != '-1' ? $quotaLimit : tr('Disabled'), 'VL_FTP_ACCOUNTS_USED' => get_customer_running_ftp_acc_cnt($domainAdminId), 'VL_FTP_ACCOUNTS_LIMIT' => translate_limit_value($domainProperties['domain_ftpacc_limit']), 'VL_SQL_DB_ACCOUNTS_USED' => get_domain_running_sqld_acc_cnt($domainId), 'VL_SQL_DB_ACCOUNTS_LIMIT' => translate_limit_value($domainProperties['domain_sqld_limit']), 'VL_SQL_USER_ACCOUNTS_USED' => get_domain_running_sqlu_acc_cnt($domainId), 'VL_SQL_USER_ACCOUNTS_LIMIT' => translate_limit_value($domainProperties['domain_sqlu_limit']), 'VL_SUBDOM_ACCOUNTS_USED' => get_domain_running_sub_cnt($domainId), 'VL_SUBDOM_ACCOUNTS_LIMIT' => translate_limit_value($domainProperties['domain_subd_limit']), 'VL_DOMALIAS_ACCOUNTS_USED' => get_domain_running_als_cnt($domainId), 'VL_DOMALIAS_ACCOUNTS_LIMIT' => translate_limit_value($domainProperties['domain_alias_limit'])));
}
示例4: opendkim_deactivate
/**
* Deactivate OpenDKIM for the given customer
*
* @param int $customerId Customer unique identifier
* @return void
*/
function opendkim_deactivate($customerId)
{
$stmt = exec_query('SELECT COUNT(admin_id) AS cnt FROM admin WHERE admin_id = ? AND created_by = ? AND admin_status = ?', array($customerId, $_SESSION['user_id'], 'ok'));
$row = $stmt->fetchRow(PDO::FETCH_ASSOC);
if ($row['cnt']) {
exec_query('UPDATE opendkim SET opendkim_status = ? WHERE admin_id = ?', array('todelete', $customerId));
send_request();
set_page_message(tr('OpenDKIM support scheduled for deactivation. This can take few seconds.'), 'success');
} else {
showBadRequestErrorPage();
}
}
示例5: client_generatePage
/**
* Generate page and return software unique identifier.
*
* @param iMSCP_pTemplate $tpl Template engine instance
* @return int software unique identifier
*/
function client_generatePage($tpl)
{
if (!isset($_GET['id']) || $_GET['id'] === '' || !is_numeric($_GET['id'])) {
showBadRequestErrorPage();
exit;
// Useless but avoid IDE warning about possible undefined variable
} else {
$softwareId = intval($_GET['id']);
}
$domainProperties = get_domain_default_props($_SESSION['user_id']);
$stmt = exec_query('SELECT created_by FROM admin WHERE admin_id = ?', $_SESSION['user_id']);
get_software_props($tpl, $domainProperties['domain_id'], $softwareId, $stmt->fields['created_by'], $domainProperties['domain_sqld_limit']);
return $softwareId;
}
示例6: client_addSqlDb
/**
* Add SQL database
*
* @param int $userId
* @return void
*/
function client_addSqlDb($userId)
{
if (!isset($_POST['uaction'])) {
return;
}
if (!isset($_POST['db_name'])) {
showBadRequestErrorPage();
}
$dbName = clean_input($_POST['db_name']);
if ($_POST['db_name'] === '') {
set_page_message(tr('Please type database name.'), 'error');
return;
}
$mainDmnId = get_user_domain_id($userId);
if (isset($_POST['use_dmn_id']) && $_POST['use_dmn_id'] === 'on') {
if (isset($_POST['id_pos']) && $_POST['id_pos'] === 'start') {
$dbName = $mainDmnId . '_' . $dbName;
} elseif (isset($_POST['id_pos']) && $_POST['id_pos'] === 'end') {
$dbName = $dbName . '_' . $mainDmnId;
}
}
if (strlen($dbName) > 64) {
set_page_message(tr('Database name is too long.'), 'error');
return;
}
if ($dbName === 'test' || client_isDatabase($dbName)) {
set_page_message(tr('Database name is unavailable.'), 'error');
return;
}
if (preg_match('/[%|\\?]+/', $dbName)) {
set_page_message(tr("Wildcards such as 's%' and 's%' are not allowed.", '%', '?'), 'error');
return;
}
$responses = iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onBeforeAddSqlDb, array('dbName' => $dbName));
if (!$responses->isStopped()) {
execute_query(sprintf('CREATE DATABASE IF NOT EXISTS %s', quoteIdentifier($dbName)));
exec_query('INSERT INTO sql_database (domain_id, sqld_name) VALUES (?, ?)', array($mainDmnId, $dbName));
set_page_message(tr('SQL database successfully created.'), 'success');
write_log(sprintf('%s added new SQL database: %s', decode_idna($_SESSION['user_logged']), $dbName), E_USER_NOTICE);
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onAfterAddSqlDb, array('dbName' => $dbName));
}
redirectTo('sql_manage.php');
}
示例7: client_updateSqlUserPassword
/**
* Update SQL user password
*
* @param int $id Sql user id
* @param string $user Sql user name
* @param string $host SQL user host
* @çeturn void
*/
function client_updateSqlUserPassword($id, $user, $host)
{
if (!isset($_POST['uaction'])) {
return;
}
if (!isset($_POST['password']) || !isset($_POST['password_confirmation'])) {
showBadRequestErrorPage();
}
$password = clean_input($_POST['password']);
$passwordConf = clean_input($_POST['password_confirmation']);
if ($password === '') {
set_page_message(tr('Password cannot be empty.'), 'error');
return;
}
if ($passwordConf === '') {
set_page_message(tr('Please confirm the password.'), 'error');
return;
}
if ($password !== $passwordConf) {
set_page_message(tr('Passwords do not match.'), 'error');
return;
}
if (!checkPasswordSyntax($password)) {
return;
}
$config = iMSCP_Registry::get('config');
$mysqlConfig = new iMSCP_Config_Handler_File($config['CONF_DIR'] . '/mysql/mysql.data');
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onBeforeEditSqlUser, array('sqlUserId' => $id));
// Here we cannot use transaction due to statements that cause an implicit commit. Thus we execute
// those statements first to let the i-MSCP database in clean state if one of them fails.
// See https://dev.mysql.com/doc/refman/5.7/en/implicit-commit.html for more details
// Update SQL user password in the mysql system tables;
if (strpos('mariadb', $config['SQL_SERVER']) !== false || version_compare($mysqlConfig['SQLD_VERSION'], '5.7.6', '<')) {
exec_query('SET PASSWORD FOR ?@? = PASSWORD(?)', array($user, $host, $password));
} else {
exec_query('ALTER USER ?@? IDENTIFIED BY ? PASSWORD EXPIRE NEVER', array($user, $host, $password));
}
exec_query('UPDATE sql_user SET sqlu_pass = ? WHERE sqlu_name = ? AND sqlu_host = ?', array($password, $user, $host));
set_page_message(tr('SQL user password successfully updated.'), 'success');
write_log(sprintf('%s updated %s@%s SQL user password.', decode_idna($_SESSION['user_logged']), $user, $host), E_USER_NOTICE);
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onAfterEditSqlUser, array('sqlUserId' => $id));
redirectTo('sql_manage.php');
}
示例8: admin_generateCustomerAcountDeletionValidationPage
/**
* Generates customer account deletion validation page.
*
* @param int $userId Customer account unique identifier
* @return iMSCP_pTemplate
*/
function admin_generateCustomerAcountDeletionValidationPage($userId)
{
/** @var $cfg iMSCP_Config_Handler_File */
$cfg = iMSCP_Registry::get('config');
$stmt = exec_query('SELECT admin_name FROM admin WHERE admin_id = ?', $userId);
if (!$stmt->rowCount()) {
showBadRequestErrorPage();
}
$adminName = decode_idna($stmt->fields['admin_name']);
$tpl = new iMSCP_pTemplate();
$tpl->define_dynamic(array('layout' => 'shared/layouts/ui.tpl', 'page' => 'admin/user_delete.tpl', 'page_message' => 'layout', 'mail_list' => 'page', 'mail_item' => 'mail_list', 'ftp_list' => 'page', 'ftp_item' => 'ftp_list', 'dmn_list' => 'page', 'dmn_item' => 'dmn_list', 'als_list' => 'page', 'als_item' => 'als_list', 'sub_list' => 'page', 'sub_item' => 'sub_list', 'db_list' => 'page', 'db_item' => 'db_list'));
$tpl->assign(array('TR_PAGE_TITLE' => tr('Admin / Users / Overview / Delete Customer'), 'TR_ACCOUNT_SUMMARY' => tr('Customer account summary'), 'TR_EMAILS' => tr('Emails'), 'TR_FTP_ACCOUNTS' => tr('Ftp accounts'), 'TR_DOMAINS' => tr('Domains'), 'TR_DOMAIN_ALIASES' => tr('Domain aliases'), 'TR_SUBDOMAINS' => tr('Subdomains'), 'TR_DATABASES' => tr('SQL databases'), 'TR_REALLY_WANT_TO_DELETE_CUSTOMER_ACCOUNT' => tr("Do you really want to delete the entire %s customer account? This operation cannot be undone.", "<strong>{$adminName}</strong>"), 'USER_ID' => $userId, 'TR_YES_DELETE_ACCOUNT' => tr('Yes, delete this account.'), 'TR_DELETE' => tr('Delete'), 'TR_CANCEL' => tr('Cancel')));
generateNavigation($tpl);
// Checks for mail accounts
$stmt = exec_query('
SELECT
mail_type, mail_addr
FROM
mail_users
WHERE
domain_id IN (SELECT domain_id FROM domain WHERE domain_admin_id = ?)
', $userId);
if ($stmt->rowCount()) {
while ($row = $stmt->fetchRow(PDO::FETCH_ASSOC)) {
$mailTypes = explode(',', $row['mail_type']);
$mailTypesdisplayArray = array();
foreach ($mailTypes as $mtype) {
$mailTypesdisplayArray[] = user_trans_mail_type($mtype);
}
$mailTypesdisplayTxt = implode(', ', $mailTypesdisplayArray);
$addr = explode('@', $row['mail_addr']);
$tpl->assign(array('MAIL_ADDR' => tohtml($addr[0] . '@' . decode_idna($addr[1])), 'MAIL_TYPE' => $mailTypesdisplayTxt));
$tpl->parse('MAIL_ITEM', '.mail_item');
}
} else {
$tpl->assign('MAIL_LIST', '');
}
// Checks for FTP accounts
$stmt = exec_query('SELECT userid, homedir FROM ftp_users WHERE admin_id = ?', $userId);
if ($stmt->rowCount()) {
while ($row = $stmt->fetchRow(PDO::FETCH_ASSOC)) {
$username = explode('@', $row['userid']);
$tpl->assign(array('FTP_USER' => tohtml($username[0] . '@' . decode_idna($username[1])), 'FTP_HOME' => tohtml(substr($row['homedir'], strlen($cfg->USER_WEB_DIR)))));
$tpl->parse('FTP_ITEM', '.ftp_item');
}
} else {
$tpl->assign('FTP_LIST', '');
}
// Check for domains
// NOTE: Currently, each customer has only one domain but that will change in near future
$stmt = exec_query('SELECT domain_id, domain_name FROM domain WHERE domain_admin_id = ?', $userId);
$domainId = $stmt->fields['domain_id'];
$domainName = tohtml(decode_idna($stmt->fields['domain_name']));
$tpl->assign('DOMAIN_NAME', $domainName);
$tpl->parse('DMN_ITEM', '.dmn_item');
// Checks for domain's aliases
$aliasIds = array();
$stmt = exec_query('SELECT alias_id, alias_name, alias_mount FROM domain_aliasses WHERE domain_id = ?', $domainId);
if ($stmt->rowCount()) {
while ($data = $stmt->fetchRow(PDO::FETCH_ASSOC)) {
$aliasIds[] = $data['alias_id'];
$tpl->assign(array('ALS_NAME' => tohtml(decode_idna($data['alias_name'])), 'ALS_MNT' => tohtml($data['alias_mount'])));
$tpl->parse('ALS_ITEM', '.als_item');
}
} else {
$tpl->assign('ALS_LIST', '');
}
// Checks for subdomains
$stmt = exec_query('SELECT subdomain_name, subdomain_mount FROM subdomain WHERE domain_id = ?', $domainId);
if ($stmt->rowCount()) {
while ($data = $stmt->fetchRow(PDO::FETCH_ASSOC)) {
$tpl->assign(array('SUB_NAME' => tohtml(decode_idna($data['subdomain_name'])), 'SUB_MNT' => tohtml($data['subdomain_mount'])));
$tpl->parse('SUB_ITEM', '.sub_item');
}
} else {
$tpl->assign('SUB_LIST', '');
}
// Checks subdomain_alias
if (count($aliasIds)) {
$aliasIds = implode(',', $aliasIds);
$stmt = execute_query("SELECT subdomain_alias_name, subdomain_alias_mount FROM subdomain_alias WHERE alias_id IN ({$aliasIds})");
if ($stmt->rowCount()) {
while ($row = $stmt->fetchRow(PDO::FETCH_ASSOC)) {
$tpl->assign(array('SUB_NAME' => tohtml(decode_idna($row['subdomain_alias_name'])), 'SUB_MNT' => tohtml($row['subdomain_alias_mount'])));
$tpl->parse('SUB_ITEM', '.sub_item');
}
}
}
// Checks for databases and SQL users
$stmt = exec_query('SELECT sqld_id, sqld_name FROM sql_database WHERE domain_id = ?', $domainId);
if ($stmt->rowCount()) {
while ($row = $stmt->fetchRow(PDO::FETCH_ASSOC)) {
$stmt2 = exec_query('SELECT sqlu_name FROM sql_user WHERE sqld_id = ?', $row['sqld_id']);
$sqlUsersList = array();
//.........这里部分代码省略.........
示例9: reseller_sendCircular
/**
* Send circular
*
* @return bool TRUE on success, FALSE otherwise
*/
function reseller_sendCircular()
{
if (isset($_POST['sender_name']) && isset($_POST['sender_email']) && isset($_POST['subject']) && isset($_POST['body'])) {
$senderName = clean_input($_POST['sender_name']);
$senderEmail = clean_input($_POST['sender_email']);
$subject = clean_input($_POST['subject'], false);
$body = clean_input($_POST['body'], false);
if (reseller_isValidCircular($senderName, $senderEmail, $subject, $body)) {
$responses = iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onBeforeSendCircular, array('sender_name' => $senderName, 'sender_email' => $senderEmail, 'rcpt_to' => 'customers', 'subject' => $subject, 'body' => $body));
if (!$responses->isStopped()) {
reseller_sendToCustomers($senderName, $senderEmail, $subject, $body);
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onAfterSendCircular, array('sender_name' => $senderName, 'sender_email' => $senderEmail, 'rcpt_to' => 'customers', 'subject' => $subject, 'body' => $body));
set_page_message(tr('Circular successfully sent.'), 'success');
write_log('A circular has been sent by reseller: ' . tohtml("{$senderName} <{$senderEmail}>"), E_USER_NOTICE);
}
} else {
return false;
}
} else {
showBadRequestErrorPage();
}
return true;
}
示例10: doBulkAction
/**
* Do bulk action (activate|deactivate|protect)
*
* @param PluginManager $pluginManager
* @return void
*/
function doBulkAction($pluginManager)
{
$action = clean_input($_POST['bulk_actions']);
if (!in_array($action, array('install', 'uninstall', 'enable', 'disable', 'delete', 'protect'))) {
showBadRequestErrorPage();
} elseif (isset($_POST['checked']) && is_array($_POST['checked']) && !empty($_POST['checked'])) {
foreach ($_POST['checked'] as $pluginName) {
doAction($pluginManager, clean_input($pluginName), $action);
}
} else {
set_page_message(tr('You must select at least one plugin.'), 'error');
}
}
示例11: check_login
*
* The Initial Developer of the Original Code is moleSoftware GmbH.
* Portions created by Initial Developer are Copyright (C) 2001-2006
* by moleSoftware GmbH. All Rights Reserved.
*
* Portions created by the ispCP Team are Copyright (C) 2006-2010 by
* isp Control Panel. All Rights Reserved.
*
* Portions created by the i-MSCP Team are Copyright (C) 2010-2015 by
* i-MSCP - internet Multi Server Control Panel. All Rights Reserved.
*/
// Include core library
require 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onAdminScriptStart);
check_login('admin');
systemHasAntiRootkits() or showBadRequestErrorPage();
$config = iMSCP_Registry::get('config');
$tpl = new iMSCP_pTemplate();
$tpl->define_dynamic(array('layout' => 'shared/layouts/ui.tpl', 'page' => 'admin/rootkit_log.tpl', 'page_message' => 'layout', 'antirootkits_log' => 'page'));
$tpl->assign('TR_PAGE_TITLE', tr('Admin / System Tools / Anti-Rootkits Logs'));
$antiRootkits = array();
if (isset($config['ANTI_ROOTKITS_PACKAGES'])) {
$antiRootkits = explode(',', $config['ANTI_ROOTKITS_PACKAGES']);
}
$antiRootkits[] = 'Other';
$antiRootkitLogFiles = array('Chkrootkit' => 'CHKROOTKIT_LOG', 'Rkhunter' => 'RKHUNTER_LOG', 'Other' => 'OTHER_ROOTKIT_LOG');
foreach ($antiRootkitLogFiles as $antiRootkit => $logVar) {
if (!in_array($antiRootkit, $antiRootkits) || !isset($config[$logVar]) || $config[$logVar] == '') {
unset($antiRootkitLogFiles[$antiRootkit]);
}
}
示例12: client_editExternalMailServerEntries
/**
* Update external mail server entries
*
* Note: In case all entries are marked as to be deleted, the external mail server is deactivated
*
* @throws iMSCP_Exception_Database
* @param array $item Item data (item id and item type)
* @return void
*/
function client_editExternalMailServerEntries($item)
{
$verifiedData = _client_getVerifiedData($item[0], $item[1]);
if (!empty($_POST)) {
// Preparing entries stack
$data['to_update'] = isset($_POST['to_update']) ? $_POST['to_update'] : array();
$data['to_delete'] = isset($_POST['to_delete']) ? $_POST['to_delete'] : array();
$data['type'] = isset($_POST['type']) ? $_POST['type'] : array();
$data['priority'] = isset($_POST['priority']) ? $_POST['priority'] : array();
$data['host'] = isset($_POST['host']) ? $_POST['host'] : array();
$responses = iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onBeforeAddExternalMailServer, array('externalMailServerEntries' => $data));
if (!$responses->isStopped()) {
$entriesCount = count($data['type']);
$error = false;
// Validate all entries
for ($index = 0; $index < $entriesCount; $index++) {
if (isset($data['type'][$index]) && isset($data['priority'][$index]) && isset($data['host'][$index])) {
$data['host'][$index] = strtolower(rtrim($data['host'][$index], '.'));
if (empty($data['to_delete'][$index]) && !_client_validateDnsMxRecord($data['type'][$index], $data['priority'][$index], $data['host'][$index], $verifiedData)) {
$error = true;
}
} else {
// Not all expected data were received
showBadRequestErrorPage();
}
}
// Add entries into database
if (!$error) {
/** @var $db iMSCP_Database */
$db = iMSCP_Database::getInstance();
try {
$db->beginTransaction();
$dnsEntriesIds = '';
# Spam Filter ( filter ) MX type has highter precedence
$spamFilterMX = false;
$wildcardMxOnly = true;
for ($index = 0; $index < $entriesCount; $index++) {
if (!empty($data['to_delete'][$index]) && in_array($data['to_delete'][$index], $verifiedData['external_mail_dns_ids'])) {
// Entry to delete
if (empty($data['to_update']) && empty($data['type'])) {
exec_query('UPDATE domain_dns SET domain_dns_status = ? WHERE domain_dns_id = ?', array('todelete', $data['to_delete'][$index]));
} else {
exec_query('DELETE FROM domain_dns WHERE domain_dns_id = ?', $data['to_delete'][$index]);
}
} elseif (!empty($data['to_update'][$index]) && in_array($data['to_update'][$index], $verifiedData['external_mail_dns_ids'])) {
// Entry to update
if ($data['type'][$index] == 'filter') {
$spamFilterMX = true;
$wildcardMxOnly = false;
} elseif ($data['type'][$index] == 'domain') {
$wildcardMxOnly = false;
}
exec_query('
UPDATE
domain_dns SET domain_dns = ?, domain_text = ?, domain_dns_status = ?
WHERE
domain_dns_id = ?
', array($data['type'][$index] != 'wildcard' ? $verifiedData['item_name'] . '.' : '*.' . $verifiedData['item_name'] . '.', $data['priority'][$index] . "\t" . encode_idna($data['host'][$index]) . '.', 'tochange', $data['to_update'][$index]));
$dnsEntriesIds .= ',' . $data['to_update'][$index];
} else {
// Entry to add
if ($data['type'][$index] == 'filter') {
$spamFilterMX = true;
$wildcardMxOnly = false;
} elseif ($data['type'][$index] == 'domain') {
$wildcardMxOnly = false;
}
exec_query('
INSERT INTO domain_dns (
domain_id, alias_id, domain_dns, domain_class, domain_type, domain_text,
owned_by, domain_dns_status
) VALUES (
?, ?, ?, ?, ?, ?, ?, ?
)
', array($verifiedData['domain_id'], $verifiedData['item_type'] == 'alias' ? $verifiedData['item_id'] : 0, $data['type'][$index] != 'wildcard' ? $verifiedData['item_name'] . '.' : '*.' . $verifiedData['item_name'] . '.', 'IN', 'MX', "{$data['priority'][$index]}\t" . encode_idna($data['host'][$index]) . '.', 'ext_mail_feature', 'toadd'));
$dnsEntriesIds .= ',' . $db->insertId();
}
}
$externalMailServer = $dnsEntriesIds !== '' ? $spamFilterMX ? 'filter' : ($wildcardMxOnly ? 'wildcard' : 'domain') : 'off';
if ($verifiedData['item_type'] == 'normal') {
exec_query('
UPDATE
domain SET external_mail = ?, domain_status = ?, external_mail_dns_ids = ?
WHERE
domain_id = ?
', array($externalMailServer, 'tochange', ltrim($dnsEntriesIds, ','), $verifiedData['item_id']));
} else {
exec_query('
UPDATE
domain_aliasses SET external_mail = ?, alias_status = ?, external_mail_dns_ids = ?
WHERE
//.........这里部分代码省略.........
示例13: client_generatePage
/**
* Generate page
*
* @throws iMSCP_Exception
* @throws iMSCP_Exception_Database
* @param iMSCP_pTemplate $tpl Template engine instance
* @param int $domainId Domain entity unique identifier
* @param string $domainType Domain entity type
* @return void
*/
function client_generatePage($tpl, $domainId, $domainType)
{
$domainName = _client_getDomainName($domainId, $domainType);
if ($domainName === false) {
showBadRequestErrorPage();
}
$stmt = exec_query('SELECT * FROM ssl_certs WHERE domain_id = ? AND domain_type = ?', array($domainId, $domainType));
if ($stmt->rowCount()) {
$row = $stmt->fetchRow(PDO::FETCH_ASSOC);
$dynTitle = customerHasFeature('ssl') && $row['status'] == 'ok' ? tr('Edit SSL certificate') : tr('Show SSL certificate');
$certId = $row['cert_id'];
$privateKey = tohtml($row['private_key']);
$certificate = tohtml($row['certificate']);
$caBundle = tohtml($row['ca_bundle']);
$trAction = tr('Update');
$status = $row['status'];
$tpl->assign('STATUS', translate_dmn_status($status));
} else {
if (customerHasFeature('ssl')) {
$dynTitle = tr('Add SSL certificate');
$trAction = tr('Add');
$certId = '0';
$privateKey = '';
$certificate = '';
$caBundle = '';
$tpl->assign('SSL_CERTIFICATE_STATUS', '');
} else {
set_page_message('SSL feature is currently disabled.', 'static_warning');
redirectTo('domains_manage.php');
return;
}
}
if (customerHasFeature('ssl') && isset($_POST['cert_id']) && isset($_POST['private_key']) && isset($_POST['certificate']) && isset($_POST['ca_bundle'])) {
$certId = $_POST['cert_id'];
$privateKey = $_POST['private_key'];
$certificate = $_POST['certificate'];
$caBundle = $_POST['ca_bundle'];
}
$tpl->assign(array('TR_DYNAMIC_TITLE' => $dynTitle, 'DOMAIN_NAME' => tohtml(encode_idna($domainName)), 'KEY_CERT' => tohtml(trim($privateKey)), 'CERTIFICATE' => tohtml(trim($certificate)), 'CA_BUNDLE' => tohtml(trim($caBundle)), 'CERT_ID' => tohtml(trim($certId)), 'TR_ACTION' => $trAction));
if (!customerHasFeature('ssl') || isset($status) && in_array($status, array('toadd', 'tochange', 'todelete'))) {
$tpl->assign('SSL_CERTIFICATE_ACTIONS', '');
if (!customerHasFeature('ssl')) {
set_page_message(tr('SSL feature is not available. You can only view your certificate.'), 'static_warning');
}
}
}
示例14: updateFtpAccount
/**
* Update Ftp account
*
* @param string $userid Ftp userid
* @param string $mainDomainName Main domain name
* @return bool TRUE on success, FALSE on failure
*/
function updateFtpAccount($userid, $mainDomainName)
{
$ret = true;
if (!empty($_POST['password'])) {
if (empty($_POST['password_repeat']) || $_POST['password'] !== $_POST['password_repeat']) {
set_page_message(tr("Passwords do not match."), 'error');
$ret = false;
}
if (!checkPasswordSyntax($_POST['password'])) {
$ret = false;
}
$rawPassword = $_POST['password'];
$password = cryptPasswordWithSalt($rawPassword);
}
if (isset($_POST['home_dir'])) {
$homeDir = clean_input($_POST['home_dir']);
if ($homeDir != '/' && $homeDir != '') {
// Strip possible double-slashes
$homeDir = str_replace('//', '/', $homeDir);
// Check for updirs '..'
if (strpos($homeDir, '..') !== false) {
set_page_message(tr('Invalid home directory.'), 'error');
$ret = false;
}
if ($ret) {
$vfs = new iMSCP_VirtualFileSystem($mainDomainName);
// Check for directory existence
if (!$vfs->exists($homeDir)) {
set_page_message(tr("Home directory '%s' doesn't exist", $homeDir), 'error');
$ret = false;
}
}
}
} else {
showBadRequestErrorPage();
exit;
}
if ($ret) {
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onBeforeEditFtp, array('ftpUserId' => $userid));
/** @var $cfg iMSCP_Config_Handler_File */
$cfg = iMSCP_Registry::get('config');
$homeDir = rtrim(str_replace('//', '/', $cfg->USER_WEB_DIR . '/' . $mainDomainName . '/' . $homeDir), '/');
if (isset($rawPassword) && isset($password) && isset($homeDir)) {
$query = "UPDATE `ftp_users` SET `passwd` = ?, `rawpasswd` = ?, `homedir` = ? WHERE `userid` = ?";
exec_query($query, array($password, $rawPassword, $homeDir, $userid));
} else {
$query = "UPDATE `ftp_users` SET `homedir` = ? WHERE `userid` = ?";
exec_query($query, array($homeDir, $userid));
}
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onAfterEditFtp, array('ftpUserId' => $userid));
write_log(sprintf("%s updated Ftp account: %s", $_SESSION['user_logged'], $userid), E_USER_NOTICE);
set_page_message(tr('FTP account successfully updated.'), 'success');
}
return $ret;
}
示例15: client_editMailAccount
/**
* Edit mail account
*
* @throws iMSCP_Exception
* @return bool TRUE on success, FALSE otherwise
*/
function client_editMailAccount()
{
if (isset($_POST['password']) && isset($_POST['password_rep']) && isset($_POST['quota']) && isset($_POST['forward_list'])) {
$mailData = client_getEmailAccountData(clean_input($_GET['id']));
$mainDmnProps = get_domain_default_props($_SESSION['user_id']);
$password = $forwardList = '_no_';
$mailType = '';
$quota = null;
if (preg_match('/^(.*?)_(?:mail|forward)/', $mailData['mail_type'], $match)) {
$domainType = $match[1];
} else {
throw new iMSCP_Exception('Unable to determine mail type');
}
$mailTypeNormal = isset($_POST['account_type']) && in_array($_POST['account_type'], array('1', '3'));
$mailTypeForward = isset($_POST['account_type']) && in_array($_POST['account_type'], array('2', '3'));
if (!$mailTypeNormal && !$mailTypeForward) {
showBadRequestErrorPage();
}
$mailAddr = $mailData['mail_addr'];
if ($mailTypeNormal) {
// Check for pasword
$password = clean_input($_POST['password']);
$password_rep = clean_input($_POST['password_rep']);
if ($mailData['mail_pass'] == '_no_' || $password != '' || $password_rep != '') {
if ($password == '') {
set_page_message(tr('Password is missing.'), 'error');
return false;
} elseif ($password_rep == '') {
set_page_message(tr('You must confirm your password.'), 'error');
return false;
} elseif ($password !== $password_rep) {
set_page_message(tr("Passwords do not match."), 'error');
return false;
} elseif (!checkPasswordSyntax($password)) {
return false;
}
} else {
$password = $mailData['mail_pass'];
}
// Check for quota
$quota = clean_input($_POST['quota']);
if (is_number($quota)) {
$quota *= 1048576;
// MiB to Bytes
if ($mainDmnProps['mail_quota'] != '0') {
if ($quota == '0') {
set_page_message(tr('Incorrect Email quota.'), 'error');
return false;
}
$stmt = exec_query('SELECT SUM(`quota`) AS `quota` FROM `mail_users` WHERE `domain_id` = ? AND `quota` IS NOT NULL', $mainDmnProps['domain_id']);
$quotaLimit = floor($mainDmnProps['mail_quota'] - ($stmt->fields['quota'] - $mailData['quota']));
if ($quota > $quotaLimit) {
set_page_message(tr('Email quota cannot be bigger than %s', bytesHuman($quotaLimit, 'MiB')), 'error');
return false;
}
}
} else {
set_page_message(tr('Email quota must be a number.'), 'error');
return false;
}
switch ($domainType) {
case 'normal':
$mailType = MT_NORMAL_MAIL;
break;
case 'subdom':
$mailType = MT_SUBDOM_MAIL;
break;
case 'alias':
$mailType = MT_ALIAS_MAIL;
break;
case 'alssub':
$mailType = MT_ALSSUB_MAIL;
}
}
if ($mailTypeForward) {
// Check forward list
$forwardList = clean_input($_POST['forward_list']);
if ($forwardList == '') {
set_page_message(tr('Forward list is empty.'), 'error');
return false;
}
$forwardList = preg_split("/[\n,]+/", $forwardList);
foreach ($forwardList as $key => &$forwardEmailAddr) {
$forwardEmailAddr = encode_idna(trim($forwardEmailAddr));
if ($forwardEmailAddr == '') {
unset($forwardList[$key]);
} elseif (!chk_email($forwardEmailAddr)) {
set_page_message(tr('Wrong mail syntax in forward list.'), 'error');
return false;
} elseif ($forwardEmailAddr == $mailAddr) {
set_page_message(tr('You cannot forward %s on itself.', $mailAddr), 'error');
return false;
}
}
//.........这里部分代码省略.........