本文整理汇总了PHP中iMSCP_Events_Aggregator类的典型用法代码示例。如果您正苦于以下问题:PHP iMSCP_Events_Aggregator类的具体用法?PHP iMSCP_Events_Aggregator怎么用?PHP iMSCP_Events_Aggregator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了iMSCP_Events_Aggregator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getEventManager
/**
* Return an iMSCP_Events_Manager instance
*
* @param iMSCP_Events_Manager_Interface $events
* @return iMSCP_Events_Manager_Interface
*/
public function getEventManager(iMSCP_Events_Manager_Interface $events = null)
{
if (null !== $events) {
$this->eventManager = $events;
} elseif (null === $this->eventManager) {
$this->eventManager = iMSCP_Events_Aggregator::getInstance();
}
return $this->eventManager;
}
开发者ID:svenjantzen,项目名称:imscp,代码行数:15,代码来源:Authentication.php
示例2: client_generateView
/**
* Generates view
*
* @param iMSCP_ptemplate $tpl
* @return void
*/
function client_generateView($tpl)
{
iMSCP_Events_Aggregator::getInstance()->registerListener(iMSCP_Events::onGetJsTranslations, function ($e) {
/** @var iMSCP_Events_Description $e */
$translations = $e->getParam('translations');
$translations['core']['datatable'] = getDataTablesPluginTranslations(false);
$translations['core']['deactivate_message'] = tr("Are you sure you want to deactivate the external mail server(s) for the '%s' domain?", true, '%s');
});
$tpl->assign(array('TR_PAGE_TITLE' => tr('Client / Email / External Mail Server'), 'TR_DOMAIN' => tr('Domain'), 'TR_STATUS' => tr('Status'), 'TR_ACTION' => tr('Action'), 'TR_DEACTIVATE_SELECTED_ITEMS' => tr('Deactivate selected items'), 'TR_CANCEL' => tr('Cancel')));
$domainProps = get_domain_default_props($_SESSION['user_id']);
$domainId = $domainProps['domain_id'];
$domainName = $domainProps['domain_name'];
_client_generateItemList($tpl, $domainId, $domainName);
}
开发者ID:svenjantzen,项目名称:imscp,代码行数:20,代码来源:mail_external.php
示例3: add_user
/**
* @param $tpl iMSCP_pTemplate
* @return void
*/
function add_user($tpl)
{
/** @var $cfg iMSCP_Config_Handler_File */
$cfg = iMSCP_Registry::get('config');
if (isset($_POST['uaction']) && $_POST['uaction'] === 'add_user') {
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onBeforeAddUser);
if (check_user_data()) {
$upass = cryptPasswordWithSalt(clean_input($_POST['password']));
$user_id = $_SESSION['user_id'];
$username = clean_input($_POST['username']);
$fname = clean_input($_POST['fname']);
$lname = clean_input($_POST['lname']);
$gender = clean_input($_POST['gender']);
$firm = clean_input($_POST['firm']);
$zip = clean_input($_POST['zip']);
$city = clean_input($_POST['city']);
$state = clean_input($_POST['state']);
$country = clean_input($_POST['country']);
$email = clean_input($_POST['email']);
$phone = clean_input($_POST['phone']);
$fax = clean_input($_POST['fax']);
$street1 = clean_input($_POST['street1']);
$street2 = clean_input($_POST['street2']);
if (get_gender_by_code($gender, true) === null) {
$gender = '';
}
$query = "\n\t\t\t\tINSERT INTO `admin` (\n\t\t\t\t\t`admin_name`, `admin_pass`, `admin_type`, `domain_created`, `created_by`, `fname`, `lname`, `firm`,\n\t\t\t\t\t`zip`, `city`, `state`, `country`, `email`, `phone`, `fax`, `street1`, `street2`, `gender`\n\t\t\t\t) VALUES (\n\t\t\t\t\t?, ?, 'admin', unix_timestamp(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?\n\t\t\t\t)\n\t\t\t";
exec_query($query, array($username, $upass, $user_id, $fname, $lname, $firm, $zip, $city, $state, $country, $email, $phone, $fax, $street1, $street2, $gender));
/** @var $db iMSCP_Database */
$db = iMSCP_Registry::get('db');
$new_admin_id = $db->insertId();
$user_logged = $_SESSION['user_logged'];
write_log("{$user_logged}: add admin: {$username}", E_USER_WARNING);
$user_def_lang = $cfg->USER_INITIAL_LANG;
$user_theme_color = $cfg->USER_INITIAL_THEME;
$query = "\n\t\t\t\tREPLACE INTO `user_gui_props` (\n\t\t\t\t\t`user_id`, `lang`, `layout`\n\t\t\t\t) VALUES (\n\t\t\t\t\t?, ?, ?\n\t\t\t\t)\n\t\t\t";
exec_query($query, array($new_admin_id, $user_def_lang, $user_theme_color));
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onAfterAddUser);
send_add_user_auto_msg($user_id, clean_input($_POST['username']), clean_input($_POST['password']), clean_input($_POST['email']), clean_input($_POST['fname']), clean_input($_POST['lname']), tr('Administrator'));
//$_SESSION['user_added'] = 1;
set_page_message(tr('Admin account successfully created.'), 'success');
redirectTo('manage_users.php');
} else {
// check user data
$tpl->assign(array('EMAIL' => clean_input($_POST['email'], true), 'USERNAME' => clean_input($_POST['username'], true), 'FIRST_NAME' => clean_input($_POST['fname'], true), 'LAST_NAME' => clean_input($_POST['lname'], true), 'FIRM' => clean_input($_POST['firm'], true), 'ZIP' => clean_input($_POST['zip'], true), 'CITY' => clean_input($_POST['city'], true), 'STATE' => clean_input($_POST['state'], true), 'COUNTRY' => clean_input($_POST['country'], true), 'STREET_1' => clean_input($_POST['street1'], true), 'STREET_2' => clean_input($_POST['street2'], true), 'PHONE' => clean_input($_POST['phone'], true), 'FAX' => clean_input($_POST['fax'], true), 'VL_MALE' => $_POST['gender'] == 'M' ? $cfg->HTML_SELECTED : '', 'VL_FEMALE' => $_POST['gender'] == 'F' ? $cfg->HTML_SELECTED : '', 'VL_UNKNOWN' => $_POST['gender'] == 'U' || empty($_POST['gender']) ? $cfg->HTML_SELECTED : ''));
}
} else {
$tpl->assign(array('EMAIL' => '', 'USERNAME' => '', 'FIRST_NAME' => '', 'LAST_NAME' => '', 'FIRM' => '', 'ZIP' => '', 'CITY' => '', 'STATE' => '', 'COUNTRY' => '', 'STREET_1' => '', 'STREET_2' => '', 'PHONE' => '', 'FAX' => '', 'VL_MALE' => '', 'VL_FEMALE' => '', 'VL_UNKNOWN' => $cfg->HTML_SELECTED));
}
}
开发者ID:svenjantzen,项目名称:imscp,代码行数:54,代码来源:admin_add.php
示例4: admin_updateUserData
/**
* Update user data
*
* @param int $userId Customer unique identifier
* @return void
*/
function admin_updateUserData($userId)
{
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onBeforeEditUser, array('userId' => $userId));
$fname = isset($_POST['fname']) ? clean_input($_POST['fname']) : '';
$lname = isset($_POST['lname']) ? clean_input($_POST['lname']) : '';
$firm = isset($_POST['firm']) ? clean_input($_POST['firm']) : '';
$gender = isset($_POST['gender']) ? clean_input($_POST['gender']) : '';
$zip = isset($_POST['zip']) ? clean_input($_POST['zip']) : '';
$city = isset($_POST['city']) ? clean_input($_POST['city']) : '';
$state = isset($_POST['state']) ? clean_input($_POST['state']) : '';
$country = isset($_POST['country']) ? clean_input($_POST['country']) : '';
$email = isset($_POST['email']) ? clean_input($_POST['email']) : '';
$phone = isset($_POST['phone']) ? clean_input($_POST['phone']) : '';
$fax = isset($_POST['fax']) ? clean_input($_POST['fax']) : '';
$street1 = isset($_POST['street1']) ? clean_input($_POST['street1']) : '';
$street2 = isset($_POST['street2']) ? clean_input($_POST['street2']) : '';
$userName = get_user_name($userId);
if (empty($_POST['password'])) {
$query = "\n\t\t\tUPDATE\n\t\t\t\t`admin`\n\t\t\tSET\n\t\t\t\t`fname` = ?, `lname` = ?, `firm` = ?, `zip` = ?, `city` = ?, `state` = ?, `country` = ?, `email` = ?,\n\t\t\t\t`phone` = ?, `fax` = ?, `street1` = ?, `street2` = ?, `gender` = ?\n\t\t\tWHERE\n\t\t\t\t`admin_id` = ?\n\t\t";
exec_query($query, array($fname, $lname, $firm, $zip, $city, $state, $country, $email, $phone, $fax, $street1, $street2, $gender, $userId));
} else {
$query = "\n\t\t\tUPDATE\n\t\t\t\t`admin`\n\t\t\tSET\n\t\t\t\t`admin_pass` = ?, `fname` = ?, `lname` = ?, `firm` = ?, `zip` = ?, `city` = ?, `state` = ?,\n\t\t\t\t`country` = ?, `email` = ?, `phone` = ?, `fax` = ?, `street1` = ?, `street2` = ?, `gender` = ?\n\t\t\tWHERE\n\t\t\t\t`admin_id` = ?\n\t\t";
exec_query($query, array(cryptPasswordWithSalt($_POST['password']), $fname, $lname, $firm, $zip, $city, $state, $country, $email, $phone, $fax, $street1, $street2, $gender, $userId));
$query = "DELETE FROM `login` WHERE `user_name` = ?";
$stmt = exec_query($query, $userName);
if ($stmt->rowCount()) {
set_page_message(tr('User session successfully killed for password change.'), 'success');
}
}
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onAfterEditUser, array('userId' => $userId));
if (isset($_POST['send_data']) && !empty($_POST['password'])) {
$query = 'SELECT `admin_type` FROM `admin` WHERE `admin_id` = ?';
$stmt = exec_query($query, $userId);
if ($stmt->fields['admin_type'] == 'admin') {
$admin_type = tr('Administrator');
} elseif ($stmt->fields['admin_type'] == 'reseller') {
$admin_type = tr('Reseller');
} else {
$admin_type = tr('Customer');
}
send_add_user_auto_msg($userId, $userName, $_POST['password'], $_POST['email'], $_POST['fname'], $_POST['lname'], $admin_type);
set_page_message(tr('Login data successfully sent to %s.', $userName), 'success');
}
}
开发者ID:svenjantzen,项目名称:imscp,代码行数:50,代码来源:admin_edit.php
示例5: generatePage
/**
* Generate page
*
* @param iMSCP_pTemplate $tpl
* @return void
*/
function generatePage($tpl)
{
$stmt = exec_query('SELECT id, name, status FROM hosting_plans WHERE reseller_id = ? ORDER BY id', $_SESSION['user_id']);
if (!$stmt->rowCount()) {
$tpl->assign('HOSTING_PLANS', '');
set_page_message(tr('No hosting plan available.'), 'static_info');
return;
}
$tpl->assign(array('TR_ID' => tr('Id'), 'TR_NAME' => tr('Name'), 'TR_STATUS' => tr('Status'), 'TR_EDIT' => tr('Edit'), 'TR_ACTION' => tr('Actions'), 'TR_DELETE' => tr('Delete')));
iMSCP_Events_Aggregator::getInstance()->registerListener('onGetJsTranslations', function ($e) {
/** @var iMSCP_Events_Event $e */
$translations = $e->getParam('translations');
$translations['core']['hp_delete_confirmation'] = tr('Are you sure you want to delete this hosting plan?');
});
while ($row = $stmt->fetchRow()) {
$tpl->assign(array('ID' => $row['id'], 'NAME' => tohtml($row['name']), 'STATUS' => $row['status'] ? tr('Available') : tr('Unavailable')));
$tpl->parse('HOSTING_PLAN', '.hosting_plan');
}
}
开发者ID:svenjantzen,项目名称:imscp,代码行数:25,代码来源:hosting_plan.php
示例6: update_reseller_personal_data
/**
* @param $user_id
*/
function update_reseller_personal_data($user_id)
{
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onBeforeEditUser, array('userId' => $user_id));
$fname = clean_input($_POST['fname']);
$lname = clean_input($_POST['lname']);
$gender = $_POST['gender'];
$firm = clean_input($_POST['firm']);
$zip = clean_input($_POST['zip']);
$city = clean_input($_POST['city']);
$state = clean_input($_POST['state']);
$country = clean_input($_POST['country']);
$street1 = clean_input($_POST['street1']);
$street2 = clean_input($_POST['street2']);
$email = clean_input($_POST['email']);
$phone = clean_input($_POST['phone']);
$fax = clean_input($_POST['fax']);
$query = "\n\t\tUPDATE\n\t\t\t`admin`\n\t\tSET\n\t\t\t`fname` = ?,\n\t\t\t`lname` = ?,\n\t\t\t`firm` = ?,\n\t\t\t`zip` = ?,\n\t\t\t`city` = ?,\n\t\t\t`state` = ?,\n\t\t\t`country` = ?,\n\t\t\t`email` = ?,\n\t\t\t`phone` = ?,\n\t\t\t`fax` = ?,\n\t\t\t`street1` = ?,\n\t\t\t`street2` = ?,\n\t\t\t`gender` = ?\n\t\tWHERE\n\t\t\t`admin_id` = ?\n\t";
exec_query($query, array($fname, $lname, $firm, $zip, $city, $state, $country, $email, $phone, $fax, $street1, $street2, $gender, $user_id));
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onAfterEditUser, array('userId' => $user_id));
set_page_message(tr('Personal data successfully updated.'), 'success');
redirectTo('profile.php');
}
开发者ID:svenjantzen,项目名称:imscp,代码行数:25,代码来源:personal_change.php
示例7: client_deleteMailAccount
/**
* Schedule deletion of the given mail account
*
* @throws iMSCP_Exception on error
* @param int $mailId Mail account unique identifier
* @param array $dmnProps Main domain properties
* @return void
*/
function client_deleteMailAccount($mailId, $dmnProps)
{
$stmt = exec_query('SELECT `mail_addr` FROM `mail_users` WHERE `mail_id` = ? AND `domain_id` = ?', array($mailId, $dmnProps['domain_id']));
if ($stmt->rowCount()) {
$mailAddr = $stmt->fields['mail_addr'];
$toDeleteStatus = 'todelete';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onBeforeDeleteMail, array('mailId' => $mailId));
exec_query('UPDATE `mail_users` SET `status` = ? WHERE `mail_id` = ?', array($toDeleteStatus, $mailId));
// Schedule deleltion of all catchall which belong to the mail account
exec_query('
UPDATE
`mail_users`
SET
`status` = ?
WHERE
`mail_acc` = ? OR `mail_acc` LIKE ? OR `mail_acc` LIKE ? OR `mail_acc` LIKE ?
', array($toDeleteStatus, $mailAddr, "{$mailAddr},%", "%,{$mailAddr},%", "%,{$mailAddr}"));
delete_autoreplies_log_entries($mailAddr);
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onAfterDeleteMail, array('mailId' => $mailId));
set_page_message(tr('Mail account %s successfully scheduled for deletion.', '<strong>' . decode_idna($mailAddr) . '</strong>'), 'success');
} else {
throw new iMSCP_Exception('Bad request.', 400);
}
}
开发者ID:svenjantzen,项目名称:imscp,代码行数:32,代码来源:mail_delete.php
示例8: reseller_updatePassword
/**
* Update admin password.
*
* @return void
*/
function reseller_updatePassword()
{
if (!empty($_POST)) {
$userId = $_SESSION['user_id'];
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onBeforeEditUser, array('userId' => $userId));
if (empty($_POST['current_password']) || empty($_POST['password']) || empty($_POST['password_confirmation'])) {
set_page_message(tr('All fields are required.'), 'error');
} else {
if (!_reseller_checkCurrentPassword($_POST['current_password'])) {
set_page_message(tr('Current password is invalid.'), 'error');
} else {
if ($_POST['password'] !== $_POST['password_confirmation']) {
set_page_message(tr("Passwords do not match."), 'error');
} elseif (checkPasswordSyntax($_POST['password'])) {
$query = 'UPDATE `admin` SET `admin_pass` = ? WHERE `admin_id` = ?';
exec_query($query, array(cryptPasswordWithSalt($_POST['password']), $userId));
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onAfterEditUser, array('userId' => $userId));
write_log($_SESSION['user_logged'] . ': updated password.', E_USER_NOTICE);
set_page_message(tr('Password successfully updated.'), 'success');
}
}
}
}
}
开发者ID:svenjantzen,项目名称:imscp,代码行数:29,代码来源:password_update.php
示例9: tr
break;
case "reseller":
$trUserType = tr('Reseller');
break;
case "admin":
$trUserType = tr('Admin');
break;
default:
$trUserType = tr('Unknown user type');
}
$tpl->assign(array('TR_ACCOUNT_SUMMARY' => tr('Account summary'), 'TR_USERNAME' => tr('Username'), 'USERNAME' => tohtml($_SESSION['user_logged']), 'TR_ACCOUNT_TYPE' => tr('Account type'), 'ACCOUNT_TYPE' => $trUserType, 'TR_REGISTRATION_DATE' => tr('Registration date'), 'REGISTRATION_DATE' => $stmt->fields['domain_created'] != 0 ? date($cfg->DATE_FORMAT, $stmt->fields['domain_created']) : tr('Unknown')));
}
/*******************************************************************************
* Main script
*/
// Include core library
require 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
/** @var $cfg iMSCP_Config_Handler_File */
$cfg = iMSCP_Registry::get('config');
check_login('user');
$tpl = new iMSCP_pTemplate();
$tpl->define_dynamic(array('layout' => 'shared/layouts/ui.tpl', 'page' => 'client/profile.tpl', 'page_message' => 'layout'));
$tpl->assign('TR_PAGE_TITLE', tr('Client / Profile / Account Summary'));
generateNavigation($tpl);
client_generatePage($tpl);
generatePageMessage($tpl);
$tpl->parse('LAYOUT_CONTENT', 'page');
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptEnd, array('templateEngine' => $tpl));
$tpl->prnt();
unsetMessages();
开发者ID:svenjantzen,项目名称:imscp,代码行数:31,代码来源:profile.php
示例10: 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');
}
开发者ID:svenjantzen,项目名称:imscp,代码行数:51,代码来源:sql_change_password.php
示例11: tohtml
$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), 'RESELLER_USER_STATISTICS_DETAIL_BLOCK' => ''));
}
}
/***********************************************************************************************************************
* Main
*/
require 'imscp-lib.php';
$eventManager = iMSCP_Events_Aggregator::getInstance();
$eventManager->dispatch(iMSCP_Events::onAdminScriptStart);
check_login('admin');
if (systemHasCustomers()) {
if (isset($_GET['user_id'])) {
$userId = intval($_GET['user_id']);
$_SESSION['stats_user_id'] = $userId;
} elseif (isset($_SESSION['admin_stats_user_id'])) {
redirectTo('reseller_user_statistics_detail.php?user_id=' . $_SESSION['admin_stats_user_id']);
exit;
} else {
showBadRequestErrorPage();
exit;
}
$tpl = new iMSCP_pTemplate();
$tpl->define_dynamic(array('layout' => 'shared/layouts/ui.tpl', 'page' => 'admin/reseller_user_statistics_details.tpl', 'page_message' => 'layout', 'month_list' => 'page', 'year_list' => 'page', 'reseller_user_statistics_detail_block' => 'page', 'traffic_table_item' => 'reseller_user_statistics_detail_block'));
开发者ID:svenjantzen,项目名称:imscp,代码行数:31,代码来源:reseller_user_statistics_details.php
示例12: client_editMailAccount
//.........这里部分代码省略.........
} 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;
}
}
$forwardList = implode(',', array_unique($forwardList));
switch ($domainType) {
case 'normal':
$mailType .= ($mailType != '' ? ',' : '') . MT_NORMAL_FORWARD;
break;
case 'subdom':
$mailType .= ($mailType != '' ? ',' : '') . MT_SUBDOM_FORWARD;
break;
case 'alias':
$mailType .= ($mailType != '' ? ',' : '') . MT_ALIAS_FORWARD;
break;
case 'alssub':
$mailType .= ($mailType != '' ? ',' : '') . MT_ALSSUB_FORWARD;
}
}
// Update mail account into database
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onBeforeEditMail, array('mailId' => $mailData['mail_id']));
$query = '
UPDATE
`mail_users`
SET
`mail_pass` = ?, `mail_forward` = ?, `mail_type` = ?, `status` = ?, `quota` = ?
WHERE
`mail_id` = ?
';
exec_query($query, array($password, $forwardList, $mailType, 'tochange', $quota, $mailData['mail_id']));
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onAfterEditMail, array('mailId' => $mailData['mail_id']));
// Schedule mail account addition
send_request();
write_log("{$_SESSION['user_logged']}: Updated Email account: {$mailAddr}", E_USER_NOTICE);
set_page_message(tr('Email account successfully scheduled for update.'), 'success');
} else {
showBadRequestErrorPage();
}
return true;
}
开发者ID:svenjantzen,项目名称:imscp,代码行数:101,代码来源:mail_edit.php
示例13: exec_query
$row = $stmt->fetchRow(PDO::FETCH_ASSOC);
$name = $row['subdomain_alias_name'];
$stmt = exec_query('SELECT mail_id FROM mail_users WHERE (mail_type LIKE ? OR mail_type = ?) AND sub_id = ? LIMIT 1', array(MT_ALSSUB_MAIL . '%', MT_ALSSUB_FORWARD, $id));
if ($stmt->rowCount()) {
set_page_message(tr('Subdomain you are trying to remove has email accounts. Please remove them first.'), 'error');
redirectTo('domains_manage.php');
}
$stmt = exec_query('SELECT userid FROM ftp_users WHERE userid LIKE ? LIMIT 1', "%@{$name}");
if ($stmt->rowCount()) {
set_page_message(tr('Subdomain alias you are trying to remove has Ftp accounts. Please remove them first.'), 'error');
redirectTo('domains_manage.php');
}
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onBeforeDeleteSubdomain, array('subdomainId' => $id, 'subdomainName' => $name, 'type' => 'alssub'));
$db = iMSCP_Database::getInstance();
try {
$db->beginTransaction();
exec_query('DELETE FROM php_ini WHERE domain_id = ? AND domain_type = ?', array($id, 'subals'));
exec_query('UPDATE subdomain_alias SET subdomain_alias_status = ? WHERE subdomain_alias_id = ?', array('todelete', $id));
exec_query('UPDATE ssl_certs SET status = ? WHERE domain_id = ? AND domain_type = ?', array('todelete', $id, 'alssub'));
$db->commit();
} catch (iMSCP_Exception_Database $e) {
$db->rollBack();
write_log(sprintf('System was unable to remove a subdomain: %s', $e->getMessage()), E_ERROR);
set_page_message('Could not remove subdomain. An unexpected error occurred.', 'error');
redirectTo('domains_manage.php');
}
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onAfterDeleteSubdomain, array('subdomainId' => $id, 'subdomainName' => $name, 'type' => 'alssub'));
send_request();
write_log(sprintf('%s scheduled deletion of the `%s` subdomain alias', decode_idna($_SESSION['user_logged']), $name), E_USER_NOTICE);
set_page_message(tr('Subdomain alias scheduled for deletion.'), 'success');
redirectTo('domains_manage.php');
开发者ID:svenjantzen,项目名称:imscp,代码行数:31,代码来源:alssub_delete.php
示例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;
}
开发者ID:svenjantzen,项目名称:imscp,代码行数:62,代码来源:ftp_edit.php
示例15: admin_deleteUser
/**
* Deletes an admin or reseller user
*
* @throws iMSCP_Exception_Database
* @param int $userId User unique identifier
*/
function admin_deleteUser($userId)
{
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onBeforeDeleteUser, array('userId' => $userId));
$userId = (int) $userId;
/** @var $cfg iMSCP_Config_Handler_File */
$cfg = iMSCP_Registry::get('config');
/** @var $db iMSCP_Database */
$db = iMSCP_Database::getInstance();
$stmt = exec_query('
SELECT
a.admin_type, b.logo
FROM
admin a
LEFT JOIN
user_gui_props b ON (b.user_id = a.admin_id)
WHERE
admin_id = ?
', $userId);
$row = $stmt->fetchRow(PDO::FETCH_ASSOC);
$userType = $row['admin_type'];
if (empty($userType) || $userType == 'user') {
showBadRequestErrorPage();
}
// Users (admins/resellers) common items to delete
$itemsToDelete = array('admin' => 'admin_id = ?', 'email_tpls' => 'owner_id = ?', 'tickets' => 'ticket_from = ? OR ticket_to = ?', 'user_gui_props' => 'user_id = ?');
// Note: Admin can also have they own hosting_plans bug must not be considerated
// as common item since first admin must be never removed
if ($userType == 'reseller') {
// Getting reseller's software packages to remove if any
$stmt = exec_query('SELECT software_id, software_archive FROM web_software WHERE reseller_id = ?', $userId);
$swPackages = $stmt->fetchAll(PDO::FETCH_ASSOC);
// Getting custom reseller isp logo if set
$resellerLogo = $row['logo'];
// Add specific reseller items to remove
$itemsToDelete = array_merge(array('hosting_plans' => 'reseller_id = ?', 'reseller_props' => 'reseller_id = ?', 'web_software' => 'reseller_id = ?'), $itemsToDelete);
}
// We are using transaction to ensure data consistency and prevent any garbage in
// the database. If one query fail, the whole process is reverted.
try {
// Cleanup database
$db->beginTransaction();
foreach ($itemsToDelete as $table => $where) {
// Build the DELETE statement
$query = "DELETE FROM " . quoteIdentifier($table) . ($where ? " WHERE {$where}" : '');
exec_query($query, array_fill(0, substr_count($where, '?'), $userId));
}
$db->commit();
// Cleanup files system
// We are safe here. We don't stop the process even if files cannot be removed. That can result in garbages but
// the sysadmin can easily delete them through ssh.
// Deleting reseller software instaler local repository
if (isset($swPackages) && !empty($swPackages)) {
_admin_deleteResellerSwPackages($userId, $swPackages);
} elseif ($userType == 'reseller' && is_dir($cfg['GUI_APS_DIR'] . '/' . $userId) && @rmdir($cfg['GUI_APS_DIR'] . '/' . $userId) == false) {
write_log('Unable to remove reseller software directory: ' . $cfg['GUI_APS_DIR'] . '/' . $userId, E_USER_ERROR);
}
// Deleting user logo
if (isset($resellerLogo) && !empty($resellerLogo)) {
$logoPath = $cfg['GUI_ROOT_DIR'] . '/data/persistent/ispLogos/' . $resellerLogo;
if (file_exists($logoPath) && @unlink($logoPath) == false) {
write_log('Unable to remove user logo ' . $logoPath, E_USER_ERROR);
}
}
$userTr = $userType == 'reseller' ? tr('Reseller') : tr('Admin');
set_page_message(tr('%s account successfully deleted.', $userTr), 'success');
write_log($_SESSION['user_logged'] . ": deletes user " . $userId, E_USER_NOTICE);
} catch (iMSCP_Exception_Database $e) {
$db->rollBack();
throw $e;
}
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onAfterDeleteUser, array('userId' => $userId));
redirectTo('manage_users.php');
}
开发者ID:svenjantzen,项目名称:imscp,代码行数:79,代码来源:user_delete.php
示例16: check_login
* 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.
*/
/***********************************************************************************************************************
* Main
*/
// Include core library
require_once 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
check_login('user');
customerHasFeature('mail') or showBadRequestErrorPage();
if (isset($_GET['id'])) {
$catchallId = intval($_GET['id']);
$stmt = exec_query('SELECT mail_id FROM mail_users WHERE domain_id = ? AND mail_id = ?', array(get_user_domain_id($_SESSION['user_id']), $catchallId));
if (!$stmt->rowCount()) {
showBadRequestErrorPage();
}
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onBeforeDeleteMailCatchall, array('mailCatchallId' => $catchallId));
exec_query('UPDATE mail_users SET status = ? WHERE mail_id = ?', array('todelete', $catchallId));
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onafterDeleteMailCatchall, array('mailCatchallId' => $catchallId));
send_request();
write_log($_SESSION['user_logged'] . ': deletes email catch all!', E_USER_NOTICE);
set_page_message(tr('Catch all successfully scheduled for deletion.'), 'success');
redirectTo('mail_catchall.php');
}
showBadRequestErrorPage();
开发者ID:svenjantzen,项目名称:imscp,代码行数:31,代码来源:mail_catchall_delete.php
示例17: admin_checkAndCreateResellerAccount
/**
* Create reseller account
*
* @throws Exception
* @throws iMSCP_Exception
* @throws iMSCP_Exception_Database
* @return bool
*/
function admin_checkAndCreateResellerAccount()
{
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onBeforeAddUser);
$cfg = iMSCP_Registry::get('config');
$errFieldsStack = array();
$data =& admin_getData();
/** @var $db iMSCP_Database */
$db = iMSCP_Database::getInstance();
try {
$db->beginTransaction();
// Check for reseller name
$stmt = exec_query('SELECT COUNT(`admin_id`) `usernameExist` FROM `admin` WHERE `admin_name` = ? LIMIT 1', $data['admin_name']);
$row = $stmt->fetchRow(PDO::FETCH_ASSOC);
if ($row['usernameExist']) {
set_page_message(tr("The username %s is not available.", '<b>' . $data['admin_name'] . '</b>'), 'error');
$errFieldsStack[] = 'admin_name';
} elseif (!validates_username($data['admin_name'])) {
set_page_message(tr('Incorrect username length or syntax.'), 'error');
$errFieldsStack[] = 'admin_name';
}
// check for password
if (empty($data['password'])) {
set_page_message(tr('You must provide a password.'), 'error');
$errFieldsStack[] = 'password';
$errFieldsStack[] = 'password_confirmation';
} elseif ($data['password'] != $data['password_confirmation']) {
set_page_message(tr("Passwords do not match."), 'error');
$errFieldsStack[] = 'password';
$errFieldsStack[] = 'password_confirmation';
} elseif (!checkPasswordSyntax($data['password'])) {
$errFieldsStack[] = 'password';
$errFieldsStack[] = 'password_confirmation';
}
// Check for email address
if (!chk_email($data['email'])) {
set_page_message(tr('Incorrect syntax for email address.'), 'error');
$errFieldsStack[] = 'email';
}
// Check for ip addresses - We are safe here
$resellerIps = array();
foreach ($data['server_ips'] as $serverIpData) {
if (in_array($serverIpData['ip_id'], $data['reseller_ips'])) {
$resellerIps[] = $serverIpData['ip_id'];
}
}
sort($resellerIps);
if (empty($resellerIps)) {
set_page_message(tr('You must assign at least one IP to this reseller.'), 'error');
}
// Check for max domains limit
if (!imscp_limit_check($data['max_dmn_cnt'], null)) {
set_page_message(tr('Incorrect limit for %s.', tr('domain')), 'error');
$errFieldsStack[] = 'max_dmn_cnt';
}
// Check for max subdomains limit
if (!imscp_limit_check($data['max_sub_cnt'])) {
set_page_message(tr('Incorrect limit for %s.', tr('subdomains')), 'error');
$errFieldsStack[] = 'max_sub_cnt';
}
// check for max domain aliases limit
if (!imscp_limit_check($data['max_als_cnt'])) {
set_page_message(tr('Incorrect limit for %s.', tr('domain aliases')), 'error');
$errFieldsStack[] = 'max_als_cnt';
}
// Check for max mail accounts limit
if (!imscp_limit_check($data['max_mail_cnt'])) {
set_page_message(tr('Incorrect limit for %s.', tr('email accounts')), 'error');
$errFieldsStack[] = 'max_mail_cnt';
}
// Check for max ftp accounts limit
if (!imscp_limit_check($data['max_ftp_cnt'])) {
set_page_message(tr('Incorrect limit for %s.', tr('Ftp accounts')), 'error');
$errFieldsStack[] = 'max_ftp_cnt';
}
// Check for max Sql databases limit
if (!imscp_limit_check($data['max_sql_db_cnt'])) {
set_page_message(tr('Incorrect limit for %s.', tr('SQL databases')), 'error');
$errFieldsStack[] = 'max_sql_db_cnt';
} elseif ($_POST['max_sql_db_cnt'] == -1 && $_POST['max_sql_user_cnt'] != -1) {
set_page_message(tr('SQL database limit is disabled but SQL user limit is not.'), 'error');
$errFieldsStack[] = 'max_sql_db_cnt';
}
// Check for max Sql users limit
if (!imscp_limit_check($data['max_sql_user_cnt'])) {
set_page_message(tr('Incorrect limit for %s.', tr('SQL users')), 'error');
$errFieldsStack[] = 'max_sql_user_cnt';
} elseif ($_POST['max_sql_user_cnt'] == -1 && $_POST['max_sql_db_cnt'] != -1) {
set_page_message(tr('SQL user limit is disabled but
|
请发表评论