Example #1
0
/**
 * Hide disabled feature.
 *
 * @param iMSCP_pTemplate $tpl Template engine instance
 */
function client_hideDisabledFeatures($tpl)
{
    if (!customerHasFeature('backup')) {
        $tpl->assign('BACKUP_FEATURE', '');
    }
    $webmails = getWebmailList();
    if (!customerHasFeature('mail') || empty($webmails)) {
        $tpl->assign('MAIL_FEATURE', '');
    } else {
        if (in_array('Roundcube', $webmails)) {
            $tpl->assign('WEBMAIL_RPATH', '/webmail');
        } else {
            $tpl->assign('WEBMAIL_RPATH', '/' . strtolower($webmails[0]));
        }
    }
    if (!customerHasFeature('ftp')) {
        $tpl->assign('FTP_FEATURE', '');
    }
    if (!customerHasFeature('aps')) {
        $tpl->assign('APS_FEATURE', '');
    }
    if (!customerHasFeature('webstats')) {
        $tpl->assign('WEBSTATS_FEATURE', '');
    }
}
Example #2
0
/**
 * Generates custom DNS records list
 *
 * @param iMSCP_pTemplate $tpl Template engine
 * @return void
 */
function generateCustomDnsRecordsList($tpl)
{
    $filterCond = '';
    if (!customerHasFeature('custom_dns_records')) {
        $filterCond = "AND owned_by <> 'custom_dns_feature'";
    }
    $stmt = exec_query("\n            SELECT t1.*, IFNULL(t3.alias_name, t2.domain_name) zone_name\n            FROM domain_dns AS t1 LEFT JOIN domain AS t2 USING (domain_id) LEFT JOIN domain_aliasses AS t3 USING (alias_id)\n            WHERE  t1.domain_id = ? {$filterCond} ORDER BY t1.domain_id, t1.alias_id, t1.domain_dns, t1.domain_type\n        ", get_user_domain_id($_SESSION['user_id']));
    if ($stmt->rowCount()) {
        while ($row = $stmt->fetchRow()) {
            list($actionEdit, $actionScriptEdit) = generateCustomDnsRecordAction('edit', $row['owned_by'] === 'custom_dns_feature' ? $row['domain_dns_id'] : ($row['owned_by'] === 'ext_mail_feature' ? $row['alias_id'] ? $row['alias_id'] . ';alias' : $row['domain_id'] . ';normal' : null), $row['domain_dns_status'], $row['owned_by']);
            if ($row['owned_by'] !== 'custom_dns_feature') {
                $tpl->assign('DNS_DELETE_LINK', '');
            } else {
                list($actionDelete, $actionScriptDelete) = generateCustomDnsRecordAction('Delete', $row['domain_dns_id'], $row['domain_dns_status']);
                $tpl->assign(array('DNS_ACTION_SCRIPT_DELETE' => $actionScriptDelete, 'DNS_ACTION_DELETE' => $actionDelete, 'DNS_TYPE_RECORD' => tr("%s record", $row['domain_type'])));
                $tpl->parse('DNS_DELETE_LINK', '.dns_delete_link');
            }
            // Remove TTL part if any
            # FIXME TTL must be in dedicated column
            if (strpos($row['domain_dns'], ' ') !== false) {
                $dnsName = explode(' ', $row['domain_dns']);
                $dnsName = $dnsName[0];
            } else {
                $dnsName = $row['domain_dns'];
            }
            $tpl->assign(array('DNS_DOMAIN' => tohtml(decode_idna($row['zone_name'])), 'DNS_NAME' => tohtml(decode_idna($dnsName)), 'DNS_CLASS' => tohtml($row['domain_class']), 'DNS_TYPE' => tohtml($row['domain_type']), 'LONG_DNS_DATA' => tohtml(wordwrap(decode_idna($row['domain_text']), 80, "\n", true)), 'SHORT_DNS_DATA' => decode_idna(strlen($row['domain_text']) > 20 ? substr($row['domain_text'], 0, 17) . '...' : $row['domain_text']), 'DNS_ACTION_SCRIPT_EDIT' => $actionScriptEdit, 'DNS_ACTION_EDIT' => $actionEdit));
            $tpl->parse('DNS_ITEM', '.dns_item');
            $tpl->assign('DNS_DELETE_LINK', '');
        }
        $tpl->parse('DNS_LIST', 'dns_list');
        $tpl->assign('DNS_MESSAGE', '');
    } else {
        if (customerHasFeature('custom_dns_records')) {
            $tpl->assign(array('DNS_MSG' => tr('You do not have DNS resource records.'), 'DNS_LIST' => ''));
        } else {
            $tpl->assign('CUSTOM_DNS_RECORDS_BLOCK', '');
        }
    }
}
Example #3
0
 * 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-2016 by
 * i-MSCP - internet Multi Server Control Panel. All Rights Reserved.
 */
/***********************************************************************************************************************
 * Main
 */
require_once 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
check_login('user');
if (!customerHasFeature('domain_aliases') || !isset($_GET['id'])) {
    showBadRequestErrorPage();
}
$id = clean_input($_GET['id']);
$stmt = exec_query("\n        SELECT\n            t1.subdomain_alias_id, CONCAT(t1.subdomain_alias_name, '.', t2.alias_name) AS subdomain_alias_name\n        FROM\n            subdomain_alias AS t1\n        INNER JOIN\n            domain_aliasses AS t2 ON (t2.alias_id = t1.alias_id)\n        WHERE\n            t2.domain_id = ?\n        AND\n            t1.subdomain_alias_id = ?\n    ", array(get_user_domain_id($_SESSION['user_id']), $id));
if (!$stmt->rowCount()) {
    showBadRequestErrorPage();
}
$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}");
 * @return void
 */
function client_generatePage($tpl, $mailAccountId)
{
    $query = "SELECT `mail_auto_respond_text`, `mail_acc` FROM `mail_users` WHERE `mail_id` = ?";
    $stmt = exec_query($query, $mailAccountId);
    $tpl->assign('AUTORESPONDER_MESSAGE', tohtml($stmt->fields['mail_auto_respond_text']));
}
/***********************************************************************************************************************
 * Main
 */
// Include core library
require_once 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
check_login('user');
if (customerHasFeature('mail') && (isset($_REQUEST['mail_account_id']) && is_numeric($_REQUEST['mail_account_id']))) {
    $mailAccountId = intval($_REQUEST['mail_account_id']);
    /** @var $cfg iMSCP_Config_Handler_File */
    $cfg = iMSCP_Registry::get('config');
    if (client_checkMailAccountOwner($mailAccountId)) {
        if (!isset($_POST['mail_account_id'])) {
            $tpl = new iMSCP_pTemplate();
            $tpl->define_dynamic(array('layout' => 'shared/layouts/ui.tpl', 'page' => 'client/mail_autoresponder.tpl', 'page_message' => 'layout'));
            $tpl->assign(array('TR_PAGE_TITLE' => tr('Client / Email / Overview / Enable Auto Responder'), 'TR_AUTORESPONDER_MESSAGE' => tr('Please enter your auto-responder message below'), 'TR_ACTION' => tr('Activate'), 'TR_CANCEL' => tr('Cancel'), 'MAIL_ACCOUNT_ID' => $mailAccountId));
            generateNavigation($tpl);
            client_generatePage($tpl, $mailAccountId, !isset($_POST['uaction']));
            generatePageMessage($tpl);
            $tpl->parse('LAYOUT_CONTENT', 'page');
            iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptEnd, array('templateEngine' => $tpl));
            $tpl->prnt();
            unsetMessages();
Example #5
0
            $mailType = $mailType == '1' ? '3' : '2';
        }
    } else {
        $mailType = $_POST['account_type'];
    }
    $tpl->assign(array('MAIL_ID' => tohtml($mailId), 'USERNAME' => tohtml($username), 'NORMAL_CHECKED' => $mailType == '1' ? $checked : '', 'FORWARD_CHECKED' => $mailType == '2' ? $checked : '', 'NORMAL_FORWARD_CHECKED' => $mailType == '3' ? $checked : '', 'PASSWORD' => isset($_POST['password']) ? tohtml($_POST['password']) : '', 'PASSWORD_REP' => isset($_POST['password_rep']) ? tohtml($_POST['password_rep']) : '', 'TR_QUOTA' => $mainDmnProps['mail_quota'] == '0' ? tr('Quota in MiB (0 for unlimited)') : tr('Quota in MiB (Max: %s)', bytesHuman($mainDmnProps['mail_quota'] - ($quota - $mailData['quota']), 'MiB')), 'QUOTA' => isset($_POST['quota']) ? tohtml($_POST['quota']) : ($quota !== NULL ? floor($mailData['quota'] / 1048576) : ''), 'FORWARD_LIST' => isset($_POST['forward_list']) ? tohtml($_POST['forward_list']) : ($mailData['mail_forward'] != '_no_' ? tohtml($mailData['mail_forward']) : '')));
    $tpl->assign(array('DOMAIN_NAME' => tohtml($domainName), 'DOMAIN_NAME_UNICODE' => tohtml(decode_idna($domainName)), 'DOMAIN_NAME_SELECTED' => $selected));
}
/***********************************************************************************************************************
 * Main
 */
// Include core library
require 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
check_login('user');
if (isset($_GET['id']) && customerHasFeature('mail')) {
    if (!empty($_POST)) {
        if (client_editMailAccount()) {
            redirectTo('mail_accounts.php');
        }
    }
    $tpl = new iMSCP_pTemplate();
    $tpl->define_dynamic(array('layout' => 'shared/layouts/ui.tpl', 'page' => 'client/mail_edit.tpl', 'page_message' => 'layout'));
    $tpl->assign(array('TR_PAGE_TITLE' => tr('Client / Email / Edit Email Account'), 'TR_MAIl_ACCOUNT_DATA' => tr('Email account data'), 'TR_USERNAME' => tr('Username'), 'TR_DOMAIN_NAME' => tr('Domain name'), 'TR_MAIL_ACCOUNT_TYPE' => tr('Mail account type'), 'TR_NORMAL_MAIL' => tr('Normal'), 'TR_FORWARD_MAIL' => tr('Forward'), 'TR_FORWARD_NORMAL_MAIL' => tr('Normal + Forward'), 'TR_PASSWORD' => tr('Password'), 'TR_PASSWORD_REPEAT' => tr('Password confirmation'), 'TR_FORWARD_TO' => tr('Forward to'), 'TR_FWD_HELP' => tr('Separate multiple email addresses by comma or a line-break.'), 'TR_UPDATE' => tr('Update'), 'TR_CANCEL' => tr('Cancel')));
    client_generatePage($tpl, $_SESSION['user_id']);
    generateNavigation($tpl);
    generatePageMessage($tpl);
    $tpl->parse('LAYOUT_CONTENT', 'page');
    iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptEnd, array('templateEngine' => $tpl));
    $tpl->prnt();
} else {
Example #6
0
 */
function scheduleBackupRestoration($userId)
{
    exec_query("UPDATE `domain` SET `domain_status` = ? WHERE `domain_admin_id` = ?", array('torestore', $userId));
    send_request();
    write_log($_SESSION['user_logged'] . ": scheduled backup restoration.", E_USER_NOTICE);
    set_page_message(tr('Backup has been successfully scheduled for restoration.'), 'success');
}
/***********************************************************************************************************************
 * Main
 */
// Include core library
require_once 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
check_login('user');
customerHasFeature('backup') or showBadRequestErrorPage();
if (isset($_POST['uaction']) && $_POST['uaction'] == 'bk_restore') {
    scheduleBackupRestoration($_SESSION['user_id']);
}
/** @var $cfg iMSCP_Config_Handler_File */
$cfg = iMSCP_Registry::get('config');
$tpl = new iMSCP_pTemplate();
$tpl->define_dynamic(array('layout' => 'shared/layouts/ui.tpl', 'page' => 'client/backup.tpl', 'page_message' => 'layout'));
if ($cfg->ZIP == 'gzip') {
    $name = '.*-backup-%Y.%m.%d-%H-%M.tar..tar.gz';
} else {
    if ($cfg->ZIP == 'bzip2' || $cfg->ZIP == 'pbzip2') {
        $name = '.*-backup-%Y.%m.%d-%H-%M.tar.tar.bz2';
    } else {
        $name = '.*-backup-%Y.%m.%d-%H-%M.tar.lzma';
    }
Example #7
0
    $context = stream_context_create(array_merge($contextOptions, array('http' => array('method' => 'GET', 'protocol_version' => '1.1', 'header' => array('Host: ' . $_SERVER['SERVER_NAME'] . ($port ? ':' . $port : ''), 'User-Agent: i-MSCP', 'Connection: close')))));
    # Getting secure token
    $secureToken = file_get_contents("{$pydioBaseUrl}/index.php?action=get_secure_token", false, $context);
    $postData = http_build_query(array('get_action' => 'login', 'userid' => $credentials[0], 'login_seed' => '-1', "remember_me" => 'false', 'password' => stripcslashes($credentials[1]), '_method' => 'put'));
    $contextOptions = array_merge($contextOptions, array('http' => array('method' => 'POST', 'protocol_version' => '1.1', 'header' => array('Host: ' . $_SERVER['SERVER_NAME'] . ($port ? ':' . $port : ''), 'Content-Type: application/x-www-form-urlencoded', 'X-Requested-With: XMLHttpRequest', 'Content-Length: ' . strlen($postData), 'User-Agent: i-MSCP', 'Connection: close'), 'content' => $postData)));
    stream_context_set_default($contextOptions);
    # TODO Parse the full response and display error message on authentication failure
    $headers = get_headers("{$pydioBaseUrl}?secure_token={$secureToken}", true);
    _client_pydioCreateCookies($headers['Set-Cookie']);
    redirectTo($pydioBaseUrl);
    exit;
}
/***********************************************************************************************************************
 * Main
 */
// Include core library
require_once 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
check_login('user');
/** @var $cg iMSCP_Config_Handler_File */
$cfg = iMSCP_Registry::get('config');
if (!customerHasFeature('ftp') || !(isset($cfg['FILEMANAGER_PACKAGE']) && $cfg['FILEMANAGER_PACKAGE'] == 'Pydio')) {
    showBadRequestErrorPage();
}
if (isset($_GET['id'])) {
    if (!client_pydioAuth(clean_input($_GET['id']))) {
        redirectTo('ftp_accounts.php');
    }
} else {
    redirectTo('/index.php');
}
Example #8
0
/**
 * Helper function to generate navigation
 *
 * @throws iMSCP_Exception
 * @param iMSCP_pTemplate $tpl iMSCP_pTemplate instance
 * @return void
 */
function generateNavigation($tpl)
{
    iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onBeforeGenerateNavigation, array('templateEngine' => $tpl));
    /** @var $cfg iMSCP_Config_Handler_File */
    $cfg = iMSCP_Registry::get('config');
    $tpl->define_dynamic(array('main_menu' => 'layout', 'main_menu_block' => 'main_menu', 'menu' => 'layout', 'left_menu_block' => 'menu', 'breadcrumbs' => 'layout', 'breadcrumb_block' => 'breadcrumbs'));
    generateLoggedFrom($tpl);
    /** @var $navigation Zend_Navigation */
    $navigation = iMSCP_Registry::get('navigation');
    // Dynamic links (only at customer level)
    if ($_SESSION['user_type'] == 'user') {
        $domainProperties = get_domain_default_props($_SESSION['user_id']);
        $tpl->assign('WEBSTATS_PATH', 'http://' . decode_idna($domainProperties['domain_name']) . '/stats');
        if (customerHasFeature('mail')) {
            $webmails = getWebmailList();
            if (!empty($webmails)) {
                $page1 = $navigation->findOneBy('class', 'email');
                $page2 = $navigation->findOneBy('class', 'webtools');
                foreach ($webmails as $webmail) {
                    $page = array('label' => tr('%s webmail', $webmail), 'uri' => '/' . ($webmail == 'Roundcube' ? 'webmail' : strtolower($webmail)), 'target' => '_blank');
                    $page1->addPage($page);
                    $page2->addPage($page);
                }
            }
        }
    }
    // Dynamic links (All levels)
    $tpl->assign(array('SUPPORT_SYSTEM_PATH' => 'ticket_system.php', 'SUPPORT_SYSTEM_TARGET' => '_self'));
    // Remove support system page if feature is globally disabled
    if (!$cfg['IMSCP_SUPPORT_SYSTEM']) {
        $navigation->removePage($navigation->findOneBy('class', 'support'));
    }
    // Custom menus
    if (null != ($customMenus = getCustomMenus($_SESSION['user_type']))) {
        foreach ($customMenus as $customMenu) {
            $navigation->addPage(array('order' => $customMenu['menu_order'], 'label' => tohtml($customMenu['menu_name']), 'uri' => get_menu_vars($customMenu['menu_link']), 'target' => !empty($customMenu['menu_target']) ? tohtml($customMenu['menu_target']) : '_self', 'class' => 'custom_link'));
        }
    }
    /** @var $activePage Zend_Navigation_Page_Uri */
    foreach ($navigation->findAllBy('uri', $_SERVER['SCRIPT_NAME']) as $activePage) {
        $activePage->setActive();
    }
    if (!empty($_GET)) {
        $query = '?' . http_build_query($_GET);
    } else {
        $query = '';
    }
    /** @var $page Zend_Navigation_Page */
    foreach ($navigation as $page) {
        if (null !== ($callbacks = $page->get('privilege_callback'))) {
            $callbacks = isset($callbacks['name']) ? array($callbacks) : $callbacks;
            foreach ($callbacks as $callback) {
                if (is_callable($callback['name'])) {
                    if (!call_user_func_array($callback['name'], isset($callback['param']) ? (array) $callback['param'] : array())) {
                        continue 2;
                    }
                } else {
                    $name = is_array($callback['name']) ? $callback['name'][1] : $callback['name'];
                    throw new iMSCP_Exception(sprintf('Privileges callback is not callable: %s', $name));
                }
            }
        }
        if ($page->isVisible()) {
            $tpl->assign(array('HREF' => $page->getHref(), 'CLASS' => $page->getClass() . ($_SESSION['show_main_menu_labels'] ? ' show_labels' : ''), 'IS_ACTIVE_CLASS' => $page->isActive(true) ? 'active' : 'dummy', 'TARGET' => $page->getTarget() ? tohtml($page->getTarget()) : '_self', 'MAIN_MENU_LABEL_TOOLTIP' => tohtml($page->getLabel(), 'htmlAttr'), 'MAIN_MENU_LABEL' => $_SESSION['show_main_menu_labels'] ? tohtml($page->getLabel()) : ''));
            // Add page to main menu
            $tpl->parse('MAIN_MENU_BLOCK', '.main_menu_block');
            if ($page->isActive(true)) {
                $tpl->assign(array('TR_SECTION_TITLE' => tohtml($page->getLabel()), 'SECTION_TITLE_CLASS' => $page->getClass()));
                // Add page to breadcrumb
                $tpl->assign('BREADCRUMB_LABEL', tohtml($page->getLabel()));
                $tpl->parse('BREADCRUMB_BLOCK', '.breadcrumb_block');
                if ($page->hasPages()) {
                    $iterator = new RecursiveIteratorIterator($page, RecursiveIteratorIterator::SELF_FIRST);
                    /** @var $subpage Zend_Navigation_Page_Uri */
                    foreach ($iterator as $subpage) {
                        if (null !== ($callbacks = $subpage->get('privilege_callback'))) {
                            $callbacks = isset($callbacks['name']) ? array($callbacks) : $callbacks;
                            foreach ($callbacks as $callback) {
                                if (is_callable($callback['name'])) {
                                    if (!call_user_func_array($callback['name'], isset($callback['param']) ? (array) $callback['param'] : array())) {
                                        continue 2;
                                    }
                                } else {
                                    $name = is_array($callback['name']) ? $callback['name'][1] : $callback['name'];
                                    throw new iMSCP_Exception(sprintf('Privileges callback is not callable: %s', $name));
                                }
                            }
                        }
                        $tpl->assign(array('HREF' => $subpage->getHref(), 'IS_ACTIVE_CLASS' => $subpage->isActive(true) ? 'active' : 'dummy', 'LEFT_MENU_LABEL' => tohtml($subpage->getLabel()), 'TARGET' => $subpage->getTarget() ? $subpage->getTarget() : '_self'));
                        if ($subpage->isVisible()) {
                            // Add subpage to left menu
                            $tpl->parse('LEFT_MENU_BLOCK', '.left_menu_block');
                        }
                        if ($subpage->isActive(true)) {
                            $tpl->assign(array('TR_TITLE' => $subpage->get('dynamic_title') ? $subpage->get('dynamic_title') : tohtml($subpage->getLabel()), 'TITLE_CLASS' => $subpage->get('title_class')));
                            if (!$subpage->hasPages()) {
                                $tpl->assign('HREF', $subpage->getHref() . "{$query}");
                            }
                            // ad subpage to breadcrumbs
                            if (null != ($label = $subpage->get('dynamic_title'))) {
                                $tpl->assign('MENU_LABEL_TOOLTIP', tohtml($label));
                            } else {
                                $tpl->assign('BREADCRUMB_LABEL', tohtml($subpage->getLabel()));
                            }
                            $tpl->parse('BREADCRUMB_BLOCK', '.breadcrumb_block');
                        }
                    }
                    $tpl->parse('MENU', 'menu');
                } else {
                    $tpl->assign('MENU', '');
                }
            }
        }
    }
    $tpl->parse('MAIN_MENU', 'main_menu');
    $tpl->parse('BREADCRUMBS', 'breadcrumbs');
    $tpl->parse('MENU', 'menu');
    // Static variables
    $tpl->assign(array('TR_MENU_LOGOUT' => tr('Logout'), 'VERSION' => isset($cfg['Version']) && $cfg['Version'] != '' ? $cfg['Version'] : tohtml(tr('Unknown')), 'BUILDDATE' => isset($cfg['BuildDate']) && $cfg['BuildDate'] != '' ? $cfg['BuildDate'] : tohtml(tr('Unavailable')), 'CODENAME' => isset($cfg['CodeName']) && $cfg['CodeName'] != '' ? $cfg['CodeName'] : tohtml(tr('Unknown'))));
    iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onAfterGenerateNavigation, array('templateEngine' => $tpl));
}
Example #9
0
/**
 * Generate page
 *
 * @param iMSCP_pTemplate $tpl Reference to the pTemplate object
 * @return void
 */
function client_generatePage($tpl)
{
    if (customerHasFeature('mail')) {
        /** @var $cfg iMSCP_Config_Handler_File */
        $cfg = iMSCP_Registry::get('config');
        $dmnProps = get_domain_default_props($_SESSION['user_id']);
        $mainDmnId = $dmnProps['domain_id'];
        $dmnMailAccLimit = $dmnProps['domain_mailacc_limit'];
        $countedMails = _client_generateMailAccountsList($tpl, $mainDmnId);
        $defaultMails = _client_countDefaultMails($mainDmnId);
        if (!$cfg->COUNT_DEFAULT_EMAIL_ADDRESSES) {
            $countedMails -= $defaultMails;
        }
        $totalMails = tr('Total mails: %s / %s %s', $countedMails, translate_limit_value($dmnMailAccLimit), $defaultMails ? $cfg->COUNT_DEFAULT_EMAIL_ADDRESSES ? '(' . tr('Incl. default mails') . ')' : '(' . tr('Excl. default mails') . ')' : '');
        if ($countedMails || $defaultMails) {
            $tpl->assign('TOTAL_MAIL_ACCOUNTS', $totalMails);
        } else {
            $tpl->assign('MAIL_ITEMS', '');
            set_page_message(tr('Mail accounts list is empty.'), 'static_info');
        }
    } else {
        $tpl->assign('MAIL_FEATURE', '');
        set_page_message(tr('Mail feature is disabled.'), 'static_info');
    }
}
        if ($postRequest) {
            set_page_message(tr('You must select a least one item to deactivate.'), 'warning');
        } else {
            showBadRequestErrorPage();
        }
    }
}
/***********************************************************************************************************************
 * Main
 */
// Include core library
require_once 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
check_login('user');
// If the feature is disabled, redirects in silent way
if (customerHasFeature('external_mail')) {
    if (!empty($_POST)) {
        $items['normal'] = isset($_POST['normal']) ? $_POST['normal'] : null;
        $items['alias'] = isset($_POST['alias']) ? $_POST['alias'] : null;
        $postRequest = true;
    } else {
        if (isset($_GET['item']) && count($item = explode(';', $_GET['item'], 2)) == 2) {
            $items[$item[1]][] = $item[0];
            $postRequest = false;
        } else {
            showBadRequestErrorPage();
            exit;
        }
    }
    client_deleteExternalMailServers($items, $postRequest);
    redirectTo('mail_external.php');
Example #11
0
 *
 * 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_once 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
check_login('user');
customerHasFeature('custom_error_pages') or showBadRequestErrorPage();
/** @var $cfg iMSCP_Config_Handler_File */
$cfg = iMSCP_Registry::get('config');
$tpl = new iMSCP_pTemplate();
$tpl->define_dynamic(array('layout' => 'shared/layouts/ui.tpl', 'page' => 'client/error_pages.tpl', 'page_message' => 'layout'));
// page functions.
/**
 * @param $user_id
 * @param $eid
 * @return bool
 */
function write_error_page($user_id, $eid)
{
    $error = $_POST['error'];
    $file = '/errors/' . $eid . '.html';
    $vfs = new iMSCP_VirtualFileSystem($_SESSION['user_logged']);
Example #12
0
 * 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.
 */
/***********************************************************************************************************************
 * Main
 */
// Include core library
require_once 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
check_login('user');
if (customerHasFeature('ftp') && isset($_GET['id'])) {
    $ftpUserId = clean_input($_GET['id']);
    iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onBeforeDeleteFtp, array('ftpUserId' => $ftpUserId));
    $query = "SELECT `gid` FROM `ftp_users` WHERE `userid` = ? AND `admin_id` = ?";
    $stmt = exec_query($query, array($ftpUserId, $_SESSION['user_id']));
    if (!$stmt->rowCount()) {
        showBadRequestErrorPage();
    }
    $ftpUserGid = $stmt->fields['gid'];
    /** @var $db iMSCP_Database */
    $db = iMSCP_Database::getInstance();
    try {
        $db->beginTransaction();
        $stmt = exec_query("SELECT `groupname`, `members` FROM `ftp_group` WHERE `gid` = ?", $ftpUserGid);
        if ($stmt->rowCount()) {
            $groupName = $stmt->fields['groupname'];
Example #13
0
    // Show directories only
    foreach ($list as $entry) {
        $directory = $path . '/' . $entry['file'];
        if ($entry['type'] != iMSCP_VirtualFileSystem::VFS_TYPE_DIR || ($entry['file'] == '.' || $entry['file'] == '..') || !isAllowedDir(get_user_domain_id($_SESSION['user_id']), $directory)) {
            continue;
        }
        // Create the directory link
        $tpl->assign(array('DIR_NAME' => tohtml($entry['file']), 'CHOOSE_IT' => $directory, 'LINK' => 'ftp_choose_dir.php?cur_dir=' . $directory));
        $tpl->parse('ACTION_LINK', 'action_link');
        $tpl->parse('DIR_ITEM', '.dir_item');
    }
}
/***********************************************************************************************************************
 * Main
 */
// Include core library
require_once 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
check_login('user');
if (!customerHasFeature('ftp') && !customerHasFeature('protected_areas')) {
    showBadRequestErrorPage();
}
$tpl = new iMSCP_pTemplate();
$tpl->define_dynamic(array('layout' => 'shared/layouts/simple.tpl', 'page' => 'client/ftp_choose_dir.tpl', 'page_message' => 'layout', 'ftp_chooser' => 'page', 'dir_item' => 'ftp_chooser', 'list_item' => 'dir_item', 'action_link' => 'list_item'));
$tpl->assign(array('TR_PAGE_TITLE' => tr('Client / Choose Directory'), 'CONTEXT_CLASS' => ' no_header', 'productLongName' => tr('internet Multi Server Control Panel'), 'productLink' => 'http://www.i-mscp.net', 'productCopyright' => tr('© 2010-2015 i-MSCP Team<br/>All Rights Reserved'), 'TR_DIRECTORY_TREE' => tr('Directory tree'), 'TR_DIRECTORIES' => tr('Directories'), 'CHOOSE' => tr('Choose')));
client_generateDirectoriesList($tpl);
generatePageMessage($tpl);
$tpl->parse('LAYOUT_CONTENT', 'page');
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptEnd, array('templateEngine' => $tpl));
$tpl->prnt();
unsetMessages();
Example #14
0
/**
 * Generate view
 *
 * @param array $verifiedData Verified data
 * @param array $data Page data
 * @return void
 */
function client_generateView($verifiedData, $data)
{
    /** @var $tpl iMSCP_pTemplate */
    $tpl = iMSCP_Registry::get('templateEngine');
    /** @var $cfg iMSCP_Config_Handler_File */
    $cfg = iMSCP_Registry::get('config');
    $selectedOption = $cfg['HTML_SELECTED'];
    $idnItemName = $verifiedData['item_name'];
    $entriesCount = isset($data['type']) ? count($data['type']) : 0;
    $mxTypes = array(tr('Domain') => 'domain', tr('wildcard') => 'wildcard');
    if (customerHasFeature('mail')) {
        $mxTypes[tr('Spam Filter')] = 'filter';
    }
    $tpl->assign(array('TR_PAGE_TITLE' => tr('Client / Email / External Mail Server / Edit External Mail Server for {DOMAIN_UTF8}'), 'TR_MX_TYPE' => tr('Type'), 'DOMAIN_UTF8' => decode_idna($idnItemName), 'TR_PRIORITY' => tr('Priority'), 'TR_HOST' => tr('External Mail Host'), 'TR_SELECT_ENTRY_MESSAGE' => tr('Select this entry for deletion.'), 'TR_SELECT_ALL_ENTRIES_MESSAGE' => tr('Select all entries for deletion.'), 'TR_ADD_NEW_ENTRY' => tr('Add new entry'), 'TR_REMOVE_LAST_ENTRY' => tr('Remove last entry'), 'TR_RESET_ENTRIES' => tr('Reset entries'), 'TR_TRIGGER_REMOVE_ALERT' => tr('You cannot remove this entry.'), 'TR_CANCEL' => tr('Cancel'), 'TR_UPDATE' => tr('Update'), 'TR_MX_TYPE_TOOLTIP' => tr('Domain: Setup an external MX host to relay mail of your entire domain.') . '<br><br>' . (customerHasFeature('mail') ? tr('Wildcard: Setup an external MX host to relay mail for inexistent subdomains.') . '<br><br>' : '') . tr('Spam Filter: Setup an external MX host to relay mail of your entire domain but retains our server as final mailhost.') . '<br><br>' . tr("Note: You cannot mix 'Spam Filter' and 'Domain' options"), 'ITEM' => $verifiedData['item_id'] . ';' . $verifiedData['item_type']));
    iMSCP_Events_Aggregator::getInstance()->registerListener('onGetJsTranslations', function ($e) {
        /** @var iMSCP_Events_Event $e */
        $translations = $e->getParam('translations');
        $translations['core']['all_entries_alert'] = tr('Selecting all entries for deletion will cause deactivation of external mail server.');
    });
    for ($index = 0; $index < $entriesCount; $index++) {
        // Generates html option elements for the name
        foreach ($mxTypes as $optionName => $optionValue) {
            $tpl->assign(array('INDEX' => $index, 'OPTION_VALUE' => $optionValue, 'SELECTED' => $optionValue == $data['type'][$index] ? $selectedOption : '', 'OPTION_NAME' => $optionName));
            $tpl->parse('TYPE_OPTIONS', '.type_options');
        }
        // Generates html option elements for the MX priority
        foreach (range(5, 50, 5) as $option) {
            $tpl->assign(array('INDEX' => $index, 'OPTION_VALUE' => $option, 'SELECTED' => $option == $data['priority'][$index] ? $selectedOption : '', 'OPTION_NAME' => $option));
            $tpl->parse('PRIORITY_OPTIONS', '.priority_options');
        }
        $tpl->assign(array('INDEX' => $index, 'HOST' => $data['host'][$index], 'ENTRY_ID' => isset($data['to_update'][$index]) ? $data['to_update'][$index] : ''));
        $tpl->parse('ITEM_ENTRIES', '.item_entries');
        $tpl->assign('TYPE_OPTIONS', '');
        // Reset name options stack for next record
        $tpl->assign('PRIORITY_OPTIONS', '');
        // Reset priority options stack for next record
    }
}
Example #15
0
 *
 * 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_once 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
check_login('user');
customerHasFeature('custom_dns_records') or showBadRequestErrorPage();
if (isset($_GET['id'])) {
    $dnsRecordId = intval($_GET['id']);
    $stmt = exec_query('
			UPDATE
				domain_dns
			INNER JOIN
				domain USING(domain_id)
			SET
				domain_dns_status = ?
			WHERE
				domain_dns_id = ?
			AND
				domain_admin_id = ?
		', array('todelete', $dnsRecordId, $_SESSION['user_id']));
    if ($stmt->rowCount()) {
Example #16
0
 *
 * 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 script
 */
// Include core library
require_once 'imscp-lib.php';
require_once LIBRARY_PATH . '/Functions/Tickets.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
check_login('user');
customerHasFeature('support') or showBadRequestErrorPage();
$userId = $_SESSION['user_id'];
$previousPage = 'ticket_system';
if (isset($_GET['ticket_id']) && !empty($_GET['ticket_id'])) {
    $ticketId = (int) $_GET['ticket_id'];
    $query = "\n\t\tSELECT\n\t\t\t`ticket_status`\n\t\tFROM\n\t\t\t`tickets`\n\t\tWHERE\n\t\t\t`ticket_id` = ?\n\t\tAND\n\t\t\t(`ticket_from` = ? OR `ticket_to` = ?)\n\t";
    $stmt = exec_query($query, array($ticketId, $userId, $userId));
    if ($stmt->rowCount() == 0) {
        set_page_message(tr("Ticket with Id '%d' was not found.", $ticketId), 'error');
        redirectTo($previousPage . '.php');
    }
    // The ticket status was 0 so we come from ticket_closed.php
    if ($stmt->fields['ticket_status'] == 0) {
        $previousPage = 'ticket_closed';
    }
    deleteTicket($ticketId);
Example #17
0
			', 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);
    }
}
/***********************************************************************************************************************
 * Main
 */
// Include core library
require_once 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
check_login('user');
if (customerHasFeature('mail') && isset($_REQUEST['id'])) {
    $mainDmnProps = get_domain_default_props($_SESSION['user_id']);
    $nbDeletedMails = 0;
    $mailIds = (array) $_REQUEST['id'];
    if (!empty($mailIds)) {
        /** @var $db iMSCP_Database */
        $db = iMSCP_Database::getInstance();
        try {
            $db->beginTransaction();
            foreach ($mailIds as $mailId) {
                $mailId = clean_input($mailId);
                client_deleteMailAccount($mailId, $mainDmnProps);
                $nbDeletedMails++;
            }
            $db->commit();
            send_request();
Example #18
0
 *
 * Portions created by the i-MSCP Team are Copyright (C) 2010-2015 by
 * i-MSCP - internet Multi Server Control Panel. All Rights Reserved.
 */
/************************************************************************************
 * Main script
 */
// Include core library
require_once 'imscp-lib.php';
require_once LIBRARY_PATH . '/Functions/Tickets.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
check_login('user');
/** @var $cfg iMSCP_Config_Handler_File */
$cfg = iMSCP_Registry::get('config');
// If the feature is disabled, redirects in silent way
if (!customerHasFeature('support')) {
    showBadRequestErrorPage();
} elseif (isset($_GET['ticket_id']) && !empty($_GET['ticket_id'])) {
    reopenTicket((int) $_GET['ticket_id']);
}
if (isset($_GET['psi'])) {
    $start = $_GET['psi'];
} else {
    $start = 0;
}
$tpl = new iMSCP_pTemplate();
$tpl->define_dynamic('layout', 'shared/layouts/ui.tpl');
$tpl->define_dynamic(array('page' => 'client/ticket_closed.tpl', 'page_message' => 'layout', 'tickets_list' => 'page', 'tickets_item' => 'tickets_list', 'scroll_prev_gray' => 'page', 'scroll_prev' => 'page', 'scroll_next_gray' => 'page', 'scroll_next' => 'page'));
$tpl->assign(array('TR_PAGE_TITLE' => tr('Client / Support / Closed Tickets'), 'TR_TICKET_STATUS' => tr('Status'), 'TR_TICKET_FROM' => tr('From'), 'TR_TICKET_SUBJECT' => tr('Subject'), 'TR_TICKET_URGENCY' => tr('Priority'), 'TR_TICKET_LAST_ANSWER_DATE' => tr('Last reply date'), 'TR_TICKET_ACTION' => tr('Actions'), 'TR_TICKET_DELETE' => tr('Delete'), 'TR_TICKET_READ_LINK' => tr('Read ticket'), 'TR_TICKET_DELETE_LINK' => tr('Delete ticket'), 'TR_TICKET_REOPEN' => tr('Reopen'), 'TR_TICKET_REOPEN_LINK' => tr('Reopen ticket'), 'TR_TICKET_DELETE_ALL' => tr('Delete all tickets'), 'TR_TICKETS_DELETE_MESSAGE' => tr("Are you sure you want to delete the '%s' ticket?", '%s'), 'TR_TICKETS_DELETE_ALL_MESSAGE' => tr('Are you sure you want to delete all closed tickets?'), 'TR_PREVIOUS' => tr('Previous'), 'TR_NEXT' => tr('Next')));
generateNavigation($tpl);
generateTicketList($tpl, $_SESSION['user_id'], $start, $cfg->DOMAIN_ROWS_PER_PAGE, 'client', 'closed');
Example #19
0
 * 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-2016 by
 * i-MSCP - internet Multi Server Control Panel. All Rights Reserved.
 */
/***********************************************************************************************************************
 * Main
 */
require_once 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
check_login('user');
if (!customerHasFeature('subdomains') || !isset($_GET['id'])) {
    showBadRequestErrorPage();
}
$id = clean_input($_GET['id']);
$stmt = exec_query("\n        SELECT\n            t1.subdomain_id, CONCAT(t1.subdomain_name, '.', t2.domain_name) AS subdomain_name\n        FROM\n            subdomain AS t1\n        INNER JOIN\n            domain AS t2 USING(domain_id)\n        WHERE\n            t2.domain_id = ?\n        AND\n            t1.subdomain_id = ?\n    ", array(get_user_domain_id($_SESSION['user_id']), $id));
if (!$stmt->rowCount()) {
    showBadRequestErrorPage();
}
$row = $stmt->fetchRow(PDO::FETCH_ASSOC);
$name = $row['subdomain_name'];
$stmt = exec_query('SELECT mail_id FROM mail_users WHERE (mail_type LIKE ? OR mail_type = ?) AND sub_id = ? LIMIT 1', array($id, MT_SUBDOM_MAIL . '%', MT_SUBDOM_FORWARD));
if ($stmt->rowCount()) {
    set_page_message(tr('Subdomain you are trying to remove has email accounts. Remove them first.'), 'error');
    redirectTo('domains_manage.php');
}
$stmt = exec_query('SELECT userid FROM ftp_users WHERE userid LIKE ? LIMIT 1', "%@{$name}");
Example #20
0
/**
 * Tells whether or not the current customer can access the mail or external mail feature.
 * @return bool
 */
function customerHasMailOrExtMailFeatures()
{
    return customerHasFeature('mail') || customerHasFeature('external_mail');
}
Example #21
0
    }
    if (isset($_POST['uaction']) && $_POST['uaction'] == 'add_user') {
        $htmlChecked = $cfg['HTML_CHECKED'];
        $tpl->assign(array('USER_NAME' => isset($_POST['user_name']) ? tohtml($_POST['user_name'], true) : '', 'USER_HOST' => isset($_POST['user_host']) ? tohtml($_POST['user_host'], true) : '', 'USE_DMN_ID' => isset($_POST['use_dmn_id']) && $_POST['use_dmn_id'] === 'on' ? $htmlChecked : '', 'START_ID_POS_SELECTED' => isset($_POST['id_pos']) && $_POST['id_pos'] !== 'end' ? $htmlChecked : '', 'END_ID_POS_SELECTED' => isset($_POST['id_pos']) && $_POST['id_pos'] === 'end' ? ${$htmlChecked} : ''));
    } else {
        $tpl->assign(array('USER_NAME' => '', 'USER_HOST' => tohtml($cfg['DATABASE_USER_HOST'] == '127.0.0.1' ? 'localhost' : decode_idna($cfg['DATABASE_USER_HOST'])), 'USE_DMN_ID' => '', 'START_ID_POS_SELECTED' => '', 'END_ID_POS_SELECTED' => $cfg['HTML_CHECKED']));
    }
    $tpl->assign('ID', $databaseId);
}
/***********************************************************************************************************************
 * Main
 */
require_once 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
check_login('user');
if (!customerHasFeature('sql') || !isset($_REQUEST['id'])) {
    showBadRequestErrorPage();
}
$databaseId = intval($_REQUEST['id']);
client_addSqlUser($_SESSION['user_id'], $databaseId);
$tpl = new iMSCP_pTemplate();
$tpl->define_dynamic(array('layout' => 'shared/layouts/ui.tpl', 'page' => 'client/sql_user_add.tpl', 'page_message' => 'layout', 'mysql_prefix_no' => 'page', 'mysql_prefix_yes' => 'page', 'mysql_prefix_infront' => 'page', 'mysql_prefix_behind' => 'page', 'mysql_prefix_all' => 'page', 'sqluser_list' => 'page', 'show_sqluser_list' => 'page', 'create_sqluser' => 'page'));
$tpl->assign(array('TR_PAGE_TITLE' => tr('Client / Databases / Overview / Add SQL User'), 'TR_ADD_SQL_USER' => tr('Add SQL user'), 'TR_USER_NAME' => tr('SQL user name'), 'TR_USER_HOST' => tr('SQL user host'), 'TR_USER_HOST_TIP' => tr("This is the host from which this SQL user must be allowed to connect to the SQL server. Enter the %s wildcard character to allow this SQL user to connect from any host.", '%'), 'TR_USE_DMN_ID' => tr('SQL user prefix/suffix'), 'TR_START_ID_POS' => tr('In front'), 'TR_END_ID_POS' => tr('Behind'), 'TR_ADD' => tr('Add'), 'TR_CANCEL' => tr('Cancel'), 'TR_ADD_EXIST' => tr('Assign'), 'TR_PASS' => tr('Password'), 'TR_PASS_REP' => tr('Repeat password'), 'TR_SQL_USER_NAME' => tr('SQL users'), 'TR_ASSIGN_EXISTING_SQL_USER' => tr('Assign existing SQL user'), 'TR_NEW_SQL_USER_DATA' => tr('New SQL user data')));
client_checkSqlUserPermissions($tpl, $databaseId);
client_generateSqlUserList($tpl, $_SESSION['user_id'], $databaseId);
client_generatePage($tpl, $databaseId);
generateNavigation($tpl);
generatePageMessage($tpl);
$tpl->parse('LAYOUT_CONTENT', 'page');
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptEnd, array('templateEngine' => $tpl));
$tpl->prnt();
Example #22
0
 *
 * The Original Code is "VHCS - Virtual Hosting Control System".
 *
 * 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-2016 by
 * i-MSCP - internet Multi Server Control Panel. All Rights Reserved.
 */
/***********************************************************************************************************************
 * Main
 */
require_once 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
check_login('user');
if (!customerHasFeature('sql') || !isset($_GET['id'])) {
    showBadRequestErrorPage();
}
$userId = intval($_GET['id']);
if (!sql_delete_user(get_user_domain_id($_SESSION['user_id']), $userId)) {
    write_log(sprintf('Could not delete SQL user with ID %d. An unexpected error occurred.', $userId), E_USER_ERROR);
    set_page_message(tr('Could not delete SQL user. An unexpected error occurred.'), 'error');
    redirectTo('sql_manage.php');
}
set_page_message(tr('SQL user successfully deleted.'), 'success');
write_log(sprintf('%s deleted SQL user with ID %d', decode_idna($_SESSION['user_logged']), $userId), E_USER_NOTICE);
redirectTo('sql_manage.php');
Example #23
0
/**
 * 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');
        }
    }
}
Example #24
0
                write_log("{$admin_login}: added new htaccess user: {$uname}", E_USER_NOTICE);
                redirectTo('protected_user_manage.php');
            } else {
                set_page_message(tr('This htaccess user already exist.'), 'error');
                return;
            }
        }
    } else {
        return;
    }
}
/******************************************************************************
 * Main script
 */
// Include core library
require_once 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
check_login('user');
customerHasFeature('protected_areas') or showBadRequestErrorPage();
/** @var $cfg iMSCP_Config_Handler_File */
$cfg = iMSCP_Registry::get('config');
$tpl = new iMSCP_pTemplate();
$tpl->define_dynamic(array('layout' => 'shared/layouts/ui.tpl', 'page' => 'client/puser_uadd.tpl', 'page_message' => 'layout', 'usr_msg' => 'page', 'grp_msg' => 'page', 'pusres' => 'page', 'pgroups' => 'page'));
$tpl->assign(array('TR_PAGE_TITLE' => tr('Client / Webtools / Protected Areas / Manage Users and Groups / Add User'), 'TR_HTACCESS_USER' => tr('Htaccess user'), 'TR_USERS' => tr('User'), 'TR_USERNAME' => tr('Username'), 'TR_PASSWORD' => tr('Password'), 'TR_PASSWORD_REPEAT' => tr('Repeat password'), 'TR_ADD_USER' => tr('Add'), 'TR_CANCEL' => tr('Cancel')));
generateNavigation($tpl);
client_addHtaccessUser(get_user_domain_id($_SESSION['user_id']));
generatePageMessage($tpl);
$tpl->parse('LAYOUT_CONTENT', 'page');
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptEnd, array('templateEngine' => $tpl));
$tpl->prnt();
unsetMessages();
Example #25
0
        }
        $disabledFunctions = explode(',', $phpini->getDomainIni('phpiniDisableFunctions'));
        foreach ($disableableFunctions as $function) {
            $tpl->assign($function, in_array(strtolower($function), $disabledFunctions, true) ? ' checked' : '');
        }
        $tpl->assign(array('TR_DISABLE_FUNCTIONS' => tohtml(tr('Disabled functions')), 'DISABLE_EXEC_BLOCK' => ''));
    }
    $tpl->assign(array('TR_PHP_SETTINGS' => tohtml(tr('PHP Settings')), 'TR_YES' => tohtml(tr('Yes')), 'TR_NO' => tohtml(tr('No'))));
}
/***********************************************************************************************************************
 * Main
 */
require_once 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
check_login('user');
customerHasFeature('php_editor') or showBadRequestErrorPage();
$phpini = iMSCP_PHPini::getInstance();
$phpini->loadResellerPermissions($_SESSION['user_created_by']);
// Load reseller PHP permissions
$phpini->loadClientPermissions($_SESSION['user_id']);
// Load client PHP permissions
$config = iMSCP_Registry::get('config');
$confDir = $config['CONF_DIR'];
if ($config['HTTPD_SERVER'] == 'apache_fcgid' || $config['HTTPD_SERVER'] == 'apache_itk') {
    $srvConfig = new iMSCP_Config_Handler_File("{$confDir}/apache/apache.data");
    $configLevel = $srvConfig['INI_LEVEL'];
} else {
    $srvConfig = new iMSCP_Config_Handler_File("{$confDir}/php-fpm/phpfpm.data");
    $configLevel = $srvConfig['PHP_FPM_POOLS_LEVEL'];
}
if (!empty($_POST)) {
Example #26
0
    } 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');
}
/***********************************************************************************************************************
 * Main
 */
require_once 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
check_login('user');
customerHasFeature('sql') or showBadRequestErrorPage();
if (!isset($_REQUEST['id'])) {
    showBadRequestErrorPage();
}
$id = intval($_REQUEST['id']);
if (!check_user_sql_perms($id)) {
    showBadRequestErrorPage();
}
$tpl = new iMSCP_pTemplate();
$tpl->define_dynamic(array('layout' => 'shared/layouts/ui.tpl', 'page' => 'client/sql_change_password.tpl', 'page_message' => 'layout'));
$tpl->assign(array('TR_PAGE_TITLE' => tr('Client / Databases / Overview / Update SQL User Password'), 'TR_DB_USER' => tr('User'), 'TR_PASSWORD' => tr('Password'), 'TR_PASSWORD_CONFIRMATION' => tr('Password confirmation'), 'TR_CHANGE' => tr('Update'), 'TR_CANCEL' => tr('Cancel')));
list($user, $host) = client_generatePage($tpl, $id);
client_updateSqlUserPassword($id, $user, $host);
generateNavigation($tpl);
generatePageMessage($tpl);
$tpl->parse('LAYOUT_CONTENT', 'page');
Example #27
0
        } else {
            showBadRequestErrorPage();
        }
    } else {
        showBadRequestErrorPage();
    }
    return true;
}
/***********************************************************************************************************************
 * Main
 */
// Include core library
require_once 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
check_login('user');
customerHasFeature('subdomains') or showBadRequestErrorPage();
if (!empty($_POST) && client_editSubdomain()) {
    set_page_message(tr('Subdomain successfully scheduled for update'), 'success');
    redirectTo('domains_manage.php');
} else {
    $tpl = new iMSCP_pTemplate();
    $tpl->define_dynamic(array('layout' => 'shared/layouts/ui.tpl', 'page' => 'client/subdomain_edit.tpl', 'page_message' => 'layout'));
    $tpl->assign(array('TR_PAGE_TITLE' => tr('Client / Domains / Edit Subdomain'), 'TR_SUBDOMAIN' => tr('Subdomain'), 'TR_SUBDOMAIN_NAME' => tr('Subdomain name'), 'TR_URL_FORWARDING' => tr('URL forwarding'), 'TR_FORWARD_TO_URL' => tr('Forward to URL'), 'TR_URL_FORWARDING_TOOLTIP' => tr('Allows to forward any request made to this subdomain to a specific URL.'), 'TR_YES' => tr('Yes'), 'TR_NO' => tr('No'), 'TR_HTTP' => 'http://', 'TR_HTTPS' => 'https://', 'TR_FTP' => 'ftp://', 'TR_UPDATE' => tr('Update'), 'TR_CANCEL' => tr('Cancel')));
    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();
}
Example #28
0
        }
    } catch (iMSCP_Exception_Database $e) {
        $db->rollBack();
        write_log(sprintf('System was unable to create the `%s` domain alias: %s', $domainAliasName, $e->getMessage()), E_USER_ERROR);
        set_page_message(tr('Could not create domain alias. An unexpected error occurred.'), 'error');
        return false;
    }
    return true;
}
/***********************************************************************************************************************
 * Main
 */
require_once 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
check_login('user');
customerHasFeature('domain_aliases') or showBadRequestErrorPage();
$mainDmnProps = get_domain_default_props($_SESSION['user_id']);
$domainAliasesCount = get_domain_running_als_cnt($mainDmnProps['domain_id']);
if ($mainDmnProps['domain_alias_limit'] != 0 && $domainAliasesCount >= $mainDmnProps['domain_alias_limit']) {
    set_page_message(tr('You have reached the maximum number of domain aliasses allowed by your subscription.'), 'warning');
    redirectTo('domains_manage.php');
}
if (!empty($_POST) && addDomainAlias()) {
    redirectTo('domains_manage.php');
}
$tpl = new iMSCP_pTemplate();
$tpl->define_dynamic(array('layout' => 'shared/layouts/ui.tpl', 'page' => 'client/alias_add.tpl', 'page_message' => 'layout', 'shared_mount_point_domain' => 'page'));
$tpl->assign(array('TR_PAGE_TITLE' => tr('Client / Domains / Add Domain Alias'), 'TR_DOMAIN_ALIAS' => tr('Domain alias'), 'TR_DOMAIN_ALIAS_NAME' => tr('Domain alias name'), 'TR_DOMAIN_ALIAS_NAME_TOOLTIP' => tr("You must omit 'www'. It will be added automatically."), 'TR_SHARED_MOUNT_POINT' => tr('Shared mount point'), 'TR_SHARED_MOUNT_POINT_TOOLTIP' => tr('Allows to share the mount point of another domain.'), 'TR_URL_FORWARDING' => tr('URL forwarding'), 'TR_URL_FORWARDING_TOOLTIP' => tr('Allows to forward any request made to this domain alias to a specific URL. Be aware that when this option is in use, no Web folder is created for the domain alias.'), 'TR_FORWARD_TO_URL' => tr('Forward to URL'), 'TR_YES' => tr('Yes'), 'TR_NO' => tr('No'), 'TR_HTTP' => 'http://', 'TR_HTTPS' => 'https://', 'TR_FTP' => 'ftp://', 'TR_ADD' => tr('Add'), 'TR_CANCEL' => tr('Cancel')));
generateNavigation($tpl);
generatePage($tpl);
generatePageMessage($tpl);
Example #29
0
/**
 * Generates feature status.
 *
 * @param iMSCP_pTemplate $tpl Template engine
 * @return void
 * @todo hide features that are not available for reseller
 */
function client_generateFeatureStatus($tpl)
{
    $trYes = '<span style="color: green;">' . tr('Enabled') . '</span>';
    $trNo = '<span style="color: red;">' . tr('Disabled') . '</span>';
    $tpl->assign(array('DOMAIN_FEATURE_STATUS' => $trYes, 'PHP_FEATURE_STATUS' => customerHasFeature('php') ? $trYes : $trNo, 'PHP_DIRECTIVES_EDITOR_STATUS' => customerHasFeature('php_editor') ? $trYes : $trNo, 'CGI_FEATURE_STATUS' => customerHasFeature('cgi') ? $trYes : $trNo, 'CUSTOM_DNS_RECORDS_FEATURE_STATUS' => customerHasFeature('custom_dns_records') ? $trYes : $trNo, 'EXTERNAL_MAIL_SERVERS_FEATURE_STATUS' => customerHasFeature('external_mail') ? $trYes : $trNo, 'APP_INSTALLER_FEATURE_STATUS' => customerHasFeature('aps') ? $trYes : $trNo, 'WEBSTATS_FEATURE_STATUS' => customerHasFeature('webstats') ? $trYes : $trNo));
    if (customerHasFeature('backup')) {
        $domainProperties = get_domain_default_props($_SESSION['user_id']);
        // Backup feature for customer can also be disabled by reseller via GUI
        $domainProperties['allowbackup'] = explode('|', $domainProperties['allowbackup']);
        $bkTranslation = array();
        foreach ($domainProperties['allowbackup'] as $bkvalue) {
            switch ($bkvalue) {
                case 'dmn':
                    $bkTranslation[] = tr('domain data');
                    break;
                case 'sql':
                    $bkTranslation[] = tr('SQL databases');
                    break;
                case 'mail':
                    $bkTranslation[] = tr('mail accounts');
                    break;
                default:
            }
        }
        if (count($bkTranslation) > 0) {
            $tpl->assign('BACKUP_FEATURE_STATUS', '<span style="color: green;">' . sprintf(tr('Enabled for: %s'), implode(', ', $bkTranslation)) . '</span>');
        } else {
            $tpl->assign('BACKUP_FEATURE_STATUS', $trNo);
        }
    } else {
        $tpl->assign('BACKUP_FEATURE_STATUS', $trNo);
    }
}