本文整理汇总了PHP中iMSCP_Events_Aggregator::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP iMSCP_Events_Aggregator::getInstance方法的具体用法?PHP iMSCP_Events_Aggregator::getInstance怎么用?PHP iMSCP_Events_Aggregator::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iMSCP_Events_Aggregator
的用法示例。
在下文中一共展示了iMSCP_Events_Aggregator::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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));
}
}
示例3: 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);
}
示例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');
}
}
示例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');
}
}
示例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');
}
示例7: 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');
}
}
}
}
}
示例8: 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);
}
}
示例9: 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'));
示例10: getInstance
/**
* Return iMSCP_Events_Aggregator instance
*
* @return iMSCP_Events_Aggregator
* @deprecated 1.1.6 (will be removed in later version
*/
public static function getInstance()
{
return iMSCP_Events_Aggregator::getInstance();
}
示例11: 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;
}
示例12: 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 SQL database limit is not.'), 'error');
$errFieldsStack[] = 'max_sql_user_cnt';
}
// Check for max monthly traffic limit
if (!imscp_limit_check($data['max_traff_amnt'], null)) {
//.........这里部分代码省略.........
示例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');
示例14: redirectTo
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
// Include core library
require 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onAdminScriptStart);
check_login('admin');
if (isset($_GET['id']) and is_numeric($_GET['id'])) {
$query = "\n\t\tSELECT\n\t\t\t`software_id`,\n\t\t\t`software_archive`,\n\t\t\t`reseller_id`\n\t\tFROM\n\t\t\t`web_software`\n\t\tWHERE\n\t\t\t`software_id` = ?\n\t\tAND\n\t\t\t`software_active` = 0\n\t";
$rs = exec_query($query, $_GET['id']);
if ($rs->recordCount() != 1) {
set_page_message(tr('Wrong software id.'), 'error');
redirectTo('software_manage.php');
} else {
$update = "\n\t\t\tUPDATE\n\t\t\t\t`web_software`\n\t\t\tSET\n\t\t\t\t`software_active` = 1\n\t\t\tWHERE\n\t\t\t\t`software_id` = ?\n\t\t";
$res = exec_query($update, $_GET['id']);
$query = "\n\t\t\tSELECT\n\t\t\t\t`software_id`,\n\t\t\t\t`software_name`,\n\t\t\t\t`software_version`,\n\t\t\t\t`software_language`,\n\t\t\t\t`reseller_id`,\n\t\t\t\t`software_archive`\n\t\t\tFROM\n\t\t\t\t`web_software`\n\t\t\tWHERE\n\t\t\t\t`software_id` = ?\n\t\t";
$res = exec_query($query, $_GET['id']);
send_activated_sw($res->fields['reseller_id'], $res->fields['software_archive'] . ".tar.gz", $res->fields['software_id']);
set_page_message(tr('Software was activated.'), 'success');
redirectTo('software_manage.php');
示例15: TemplateEngine
*/
EventManager::getInstance()->dispatch(Events::onAdminScriptStart);
check_login('admin');
$cfg = Registry::get('config');
$tpl = new TemplateEngine();
$tpl->define_dynamic(array('layout' => 'shared/layouts/ui.tpl', 'page' => '../../plugins/Monitorix/themes/default/view/admin/monitorix.tpl', 'page_message' => 'layout', 'monitorix_item' => 'page', 'monitorix_graph_item' => 'page'));
$graphName = isset($_POST['graph_name']) && $_POST['graph_name'] !== '-1' ? clean_input($_POST['graph_name']) : '';
if (isset($_POST['action']) && $_POST['action'] == 'go_show') {
if ($graphName == '') {
$tpl->assign(array('M_HOUR_SELECTED' => $cfg['HTML_SELECTED'], 'M_DAY_SELECTED' => '', 'M_WEEK_SELECTED' => '', 'M_MONTH_SELECTED' => '', 'M_YEAR_SELECTED' => '', 'MONITORIXGRAPH_SELECTED' => '', 'MONITORIXGRAPH_ERROR' => ''));
} else {
selectedGraphic($tpl, $graphName, clean_input($_POST['show_when']));
}
} else {
$tpl->assign(array('M_HOUR_SELECTED' => $cfg['HTML_SELECTED'], 'M_DAY_SELECTED' => '', 'M_WEEK_SELECTED' => '', 'M_MONTH_SELECTED' => '', 'M_YEAR_SELECTED' => '', 'MONITORIXGRAPH_SELECTED' => '', 'MONITORIXGRAPH_ERROR' => ''));
}
/** @var PluginManager $pluginManager */
$pluginManager = Registry::get('pluginManager');
if (Registry::get('config')->DEBUG) {
$assetVersion = time();
} else {
$pluginInfo = $pluginManager->pluginGetInfo('Monitorix');
$assetVersion = strtotime($pluginInfo['date']);
}
$tpl->assign(array('TR_PAGE_TITLE' => tr('Statistics / Monitorix'), 'MONITORIX_ASSET_VERSION' => tohtml($assetVersion), 'MONITORIXGRAPHIC_NOT_EXIST' => tr("The requested graphic doesn't exist."), 'MONITORIXGRAPHIC_NOT_SELECTED' => tr("No monitorix graph selected."), 'TR_MONITORIX_SELECT_NAME_NONE' => tr('Select a graph'), 'M_HOUR' => tr('Hour'), 'M_DAY' => tr('Day'), 'M_WEEK' => tr('Week'), 'M_MONTH' => tr('Month'), 'M_YEAR' => tr('Year'), 'TR_SHOW' => tr('Show graph')));
generateNavigation($tpl);
generatePageMessage($tpl);
generatePage($tpl, substr($graphName, 1));
$tpl->parse('LAYOUT_CONTENT', 'page');
EventManager::getInstance()->dispatch(Events::onAdminScriptEnd, array('templateEngine' => $tpl));
$tpl->prnt();