示例#1
0
/**
 * client_generatePageLists.
 *
 * @param iMSCP_pTemplate $tpl Template engine instance
 * @return void
 */
function client_generatePageLists($tpl)
{
    $domainProperties = get_domain_default_props($_SESSION['user_id']);
    $stmt = exec_query('SELECT created_by FROM admin WHERE admin_id = ?', $_SESSION['user_id']);
    $software_poss = gen_software_list($tpl, $domainProperties['domain_id'], $stmt->fields['created_by']);
    $tpl->assign('TOTAL_SOFTWARE_AVAILABLE', $software_poss);
}
function gen_editalias_page(&$tpl, $edit_id)
{
    global $sql;
    //Get data from sql
    list($domain_id) = get_domain_default_props($sql, $_SESSION['user_id']);
    $res = exec_query($sql, "select * from domain_aliasses where alias_id=? and domain_id = ?", array($edit_id, $domain_id));
    if ($res->RecordCount() <= 0) {
        $_SESSION['aledit'] = '_no_';
        header('Location: manage_domains.php');
        die;
    }
    $data = $res->FetchRow();
    $alias_ip_id = $data['alias_ip_id'];
    // Get ip -data
    $ipres = exec_query($sql, "select * from server_ips where ip_id=?", array($alias_ip_id));
    $ipdat = $ipres->FetchRow();
    $ip_data = $ipdat['ip_number'] . ' (' . $ipdat['ip_alias'] . ')';
    if (isset($_POST['uaction']) && $_POST['uaction'] == 'modify') {
        $url_forward = $_POST['forward'];
    } else {
        $url_forward = $data['url_forward'];
    }
    // Fill in the fileds
    $tpl->assign(array('ALIAS_NAME' => $data['alias_name'], 'DOMAIN_IP' => $ip_data, 'FORWARD' => $url_forward == 'no' ? '' : $url_forward, 'ID' => $edit_id));
}
示例#3
0
/**
 *
 * @param <type> $sql
 * @param <type> $user_id
 */
function check_client_domainalias_counts($sql, $user_id)
{
    $dmn_props = get_domain_default_props($user_id);
    $als_cnt = get_domain_running_als_cnt($sql, $dmn_props['domain_id']);
    if ($dmn_props['domain_alias_limit'] != 0 && $als_cnt >= $dmn_props['domain_alias_limit']) {
        set_page_message(tr('Domain alias limit reached!'), 'warning');
        user_goto('domains_manage.php');
    }
}
示例#4
0
function check_domainalias_permissions($sql, $user_id)
{
    list($dmn_id, $dmn_name, $dmn_gid, $dmn_uid, $dmn_created_id, $dmn_created, $dmn_last_modified, $dmn_mailacc_limit, $dmn_ftpacc_limit, $dmn_traff_limit, $dmn_sqld_limit, $dmn_sqlu_limit, $dmn_status, $dmn_als_limit, $dmn_subd_limit, $dmn_ip_id, $dmn_disk_limit, $dmn_disk_usage, $dmn_php, $dmn_cgi) = get_domain_default_props($sql, $user_id);
    $als_cnt = get_domain_running_als_cnt($sql, $dmn_id);
    if ($dmn_als_limit != 0 && $als_cnt >= $dmn_als_limit) {
        set_page_message(tr('Domain alias limit expired!'));
        header("Location: manage_domains.php");
        die;
    }
}
示例#5
0
/**
 * Generates page
 *
 * @param iMSCP_pTemplate $tpl Template instance engine
 * @param int $domainId Domain unique identifier
 * @return void
 */
function reseller_generatePage($tpl, $domainId)
{
    $stmt = exec_query('
            SELECT
                domain_admin_id
            FROM
                domain
            INNER JOIN
                admin ON(admin_id = domain_admin_id)
            WHERE
                domain_id = ?
            AND
                created_by = ?
        ', array($domainId, $_SESSION['user_id']));
    if (!$stmt->rowCount()) {
        showBadRequestErrorPage();
    }
    $domainAdminId = $stmt->fields['domain_admin_id'];
    $domainProperties = get_domain_default_props($domainAdminId, $_SESSION['user_id']);
    // Domain IP address info
    $stmt = exec_query("SELECT ip_number FROM server_ips WHERE ip_id = ?", $domainProperties['domain_ip_id']);
    if (!$stmt->rowCount()) {
        $domainIpAddr = tr('Not found.');
    } else {
        $domainIpAddr = $stmt->fields['ip_number'];
    }
    $domainStatus = $domainProperties['domain_status'];
    // Domain status
    if ($domainStatus == 'ok' || $domainStatus == 'disabled' || $domainStatus == 'todelete' || $domainStatus == 'toadd' || $domainStatus == 'torestore' || $domainStatus == 'tochange' || $domainStatus == 'toenable' || $domainStatus == 'todisable') {
        $domainStatus = '<span style="color:green">' . tohtml(translate_dmn_status($domainStatus)) . '</span>';
    } else {
        $domainStatus = '<b><font size="3" color="red">' . $domainStatus . "</font></b>";
    }
    // Get total domain traffic usage in bytes
    $query = "\n        SELECT\n            IFNULL(SUM(dtraff_web), 0) AS dtraff_web, IFNULL(SUM(dtraff_ftp), 0) AS dtraff_ftp,\n            IFNULL(SUM(dtraff_mail), 0) AS dtraff_mail, IFNULL(SUM(dtraff_pop), 0) AS dtraff_pop\n        FROM\n            domain_traffic\n        WHERE\n            domain_id = ?\n        AND\n            dtraff_time BETWEEN ? AND ?\n    ";
    $stmt = exec_query($query, array($domainProperties['domain_id'], getFirstDayOfMonth(), getLastDayOfMonth()));
    if ($stmt->rowCount()) {
        $trafficUsageBytes = $stmt->fields['dtraff_web'] + $stmt->fields['dtraff_ftp'] + $stmt->fields['dtraff_mail'] + $stmt->fields['dtraff_pop'];
    } else {
        $trafficUsageBytes = 0;
    }
    // Get limits in bytes
    $trafficLimitBytes = $domainProperties['domain_traffic_limit'] * 1048576;
    $diskspaceLimitBytes = $domainProperties['domain_disk_limit'] * 1048576;
    // Get usages in percent
    $trafficUsagePercent = make_usage_vals($trafficUsageBytes, $trafficLimitBytes);
    $diskspaceUsagePercent = make_usage_vals($domainProperties['domain_disk_usage'], $diskspaceLimitBytes);
    // Get Email quota info
    list($quota, $quotaLimit) = reseller_gen_mail_quota_limit_mgs($domainAdminId);
    # Features
    $trEnabled = '<span style="color:green">' . tr('Enabled') . '</span>';
    $trDisabled = '<span style="color:red">' . tr('Disabled') . '</span>';
    $tpl->assign(array('DOMAIN_ID' => $domainId, 'VL_DOMAIN_NAME' => tohtml(decode_idna($domainProperties['domain_name'])), 'VL_DOMAIN_IP' => tohtml($domainIpAddr), 'VL_STATUS' => $domainStatus, 'VL_PHP_SUPP' => $domainProperties['domain_php'] == 'yes' ? $trEnabled : $trDisabled, 'VL_PHP_EDITOR_SUPP' => $domainProperties['phpini_perm_system'] == 'yes' ? $trEnabled : $trDisabled, 'VL_CGI_SUPP' => $domainProperties['domain_cgi'] == 'yes' ? $trEnabled : $trDisabled, 'VL_DNS_SUPP' => $domainProperties['domain_dns'] == 'yes' ? $trEnabled : $trDisabled, 'VL_EXT_MAIL_SUPP' => $domainProperties['domain_external_mail'] == 'yes' ? $trEnabled : $trDisabled, 'VL_SOFTWARE_SUPP' => $domainProperties['domain_software_allowed'] == 'yes' ? $trEnabled : $trDisabled, 'VL_BACKUP_SUP' => translate_limit_value($domainProperties['allowbackup']), 'VL_TRAFFIC_PERCENT' => $trafficUsagePercent, 'VL_TRAFFIC_USED' => bytesHuman($trafficUsageBytes), 'VL_TRAFFIC_LIMIT' => bytesHuman($trafficLimitBytes), 'VL_DISK_PERCENT' => $diskspaceUsagePercent, 'VL_DISK_USED' => bytesHuman($domainProperties['domain_disk_usage']), 'VL_DISK_LIMIT' => bytesHuman($diskspaceLimitBytes), 'VL_MAIL_ACCOUNTS_USED' => get_domain_running_mail_acc_cnt($domainId), 'VL_MAIL_ACCOUNTS_LIMIT' => translate_limit_value($domainProperties['domain_mailacc_limit']), 'VL_MAIL_QUOTA_USED' => $quota, 'VL_MAIL_QUOTA_LIMIT' => $domainProperties['domain_mailacc_limit'] != '-1' ? $quotaLimit : tr('Disabled'), 'VL_FTP_ACCOUNTS_USED' => get_customer_running_ftp_acc_cnt($domainAdminId), 'VL_FTP_ACCOUNTS_LIMIT' => translate_limit_value($domainProperties['domain_ftpacc_limit']), 'VL_SQL_DB_ACCOUNTS_USED' => get_domain_running_sqld_acc_cnt($domainId), 'VL_SQL_DB_ACCOUNTS_LIMIT' => translate_limit_value($domainProperties['domain_sqld_limit']), 'VL_SQL_USER_ACCOUNTS_USED' => get_domain_running_sqlu_acc_cnt($domainId), 'VL_SQL_USER_ACCOUNTS_LIMIT' => translate_limit_value($domainProperties['domain_sqlu_limit']), 'VL_SUBDOM_ACCOUNTS_USED' => get_domain_running_sub_cnt($domainId), 'VL_SUBDOM_ACCOUNTS_LIMIT' => translate_limit_value($domainProperties['domain_subd_limit']), 'VL_DOMALIAS_ACCOUNTS_USED' => get_domain_running_als_cnt($domainId), 'VL_DOMALIAS_ACCOUNTS_LIMIT' => translate_limit_value($domainProperties['domain_alias_limit'])));
}
示例#6
0
/**
 * Generate Page
 *
 * @param iMSCP_pTemplate $tpl Template engine instance
 * @param int $softwareId Software uique identifier
 * @return int Software unique identifier
 */
function client_generatePage($tpl, $softwareId)
{
    $customerId = $_SESSION['user_id'];
    $domainProperties = get_domain_default_props($customerId);
    $stmt = exec_query('SELECT created_by FROM admin WHERE admin_id = ?', $customerId);
    if ($stmt->rowCount()) {
        $row = $stmt->fetchRow(PDO::FETCH_ASSOC);
        get_software_props_install($tpl, $domainProperties['domain_id'], $softwareId, $row['created_by'], $domainProperties['domain_sqld_limit']);
    } else {
        throw new iMSCP_Exception('An unexpected error occurred. Please contact your reseller.');
    }
}
示例#7
0
/**
 * Get subdomain data
 *
 * @access private
 * @param int $subdomainId Subdomain unique identifier
 * @param string $subdomainType Subdomain Type
 * @return array Subdomain data. If any error occurs FALSE is returned
 */
function _client_getSubdomainData($subdomainId, $subdomainType)
{
    static $subdomainData = null;
    if (null === $subdomainData) {
        $mainDmnProps = get_domain_default_props($_SESSION['user_id']);
        $domainId = $mainDmnProps['domain_id'];
        $domainName = $mainDmnProps['domain_name'];
        if ($subdomainType == 'dmn') {
            $query = '
				SELECT
					`subdomain_name` AS `subdomain_name` , `subdomain_url_forward` AS `forward_url`
				FROM
					`subdomain`
				WHERE
					`subdomain_id` = ?
				AND
					`domain_id` = ?
				AND
					`subdomain_status` = ?
			';
        } else {
            $query = '
				SELECT
					`t1`.`subdomain_alias_name` AS `subdomain_name`, `t1`.`subdomain_alias_url_forward` AS `forward_url`,
					`t2`.`alias_name` `aliasName`
				FROM
					`subdomain_alias` AS `t1`
				INNER JOIN
					`domain_aliasses` AS `t2` USING(`alias_id`)
				WHERE
					`subdomain_alias_id` = ?
				AND
					`t2`.`domain_id` = ?
				AND
					`t1`.`subdomain_alias_status` = ?
			';
        }
        $stmt = exec_query($query, array($subdomainId, $domainId, 'ok'));
        if (!$stmt->rowCount()) {
            return false;
        }
        $subdomainData = $stmt->fetchRow(PDO::FETCH_ASSOC);
        if ($subdomainType == 'dmn') {
            $subdomainData['subdomain_name'] .= '.' . $domainName;
            $subdomainData['subdomain_name_utf8'] = decode_idna($subdomainData['subdomain_name']);
        } else {
            $subdomainData['subdomain_name'] .= '.' . $subdomainData['aliasName'];
            $subdomainData['subdomain_name_utf8'] = decode_idna($subdomainData['subdomain_name']);
        }
    }
    return $subdomainData;
}
示例#8
0
/**
 * Generate page and return software unique identifier.
 *
 * @param iMSCP_pTemplate $tpl Template engine instance
 * @return int software unique identifier
 */
function client_generatePage($tpl)
{
    if (!isset($_GET['id']) || $_GET['id'] === '' || !is_numeric($_GET['id'])) {
        showBadRequestErrorPage();
        exit;
        // Useless but avoid IDE warning about possible undefined variable
    } else {
        $softwareId = intval($_GET['id']);
    }
    $domainProperties = get_domain_default_props($_SESSION['user_id']);
    $stmt = exec_query('SELECT created_by FROM admin WHERE admin_id = ?', $_SESSION['user_id']);
    get_software_props($tpl, $domainProperties['domain_id'], $softwareId, $stmt->fields['created_by'], $domainProperties['domain_sqld_limit']);
    return $softwareId;
}
示例#9
0
/**
 * Check SQL permissions
 *
 * @param iMSCP_pTemplate $tpl
 * @param int $databaseId Database unique identifier
 */
function client_checkSqlUserPermissions($tpl, $databaseId)
{
    $domainProperties = get_domain_default_props($_SESSION['user_id']);
    $domainSqlUsersLimit = $domainProperties['domain_sqlu_limit'];
    $limits = get_domain_running_sql_acc_cnt($domainProperties['domain_id']);
    if ($domainSqlUsersLimit != 0 && $limits[1] >= $domainSqlUsersLimit) {
        $tpl->assign('CREATE_SQLUSER', '');
    }
    $stmt = exec_query('
            SELECT domain_id FROM domain INNER JOIN sql_database USING(domain_id)
            WHERE domain_id = ? AND sqld_id = ? LIMIT 1
        ', array($domainProperties['domain_id'], $databaseId));
    if (!$stmt->rowCount()) {
        showBadRequestErrorPage();
    }
}
示例#10
0
/**
 * Get domain alias data
 *
 * @access private
 * @param int $domainAliasId Subdomain unique identifier
 * @return array Domain alias data. If any error occurs FALSE is returned
 */
function _client_getAliasData($domainAliasId)
{
    static $domainAliasData = null;
    if (null === $domainAliasData) {
        $mainDmnProps = get_domain_default_props($_SESSION['user_id']);
        $domainId = $mainDmnProps['domain_id'];
        $query = "\n\t\t\tSELECT\n\t\t\t\t`alias_name`, `url_forward` AS `forward_url`\n\t\t\tFROM\n\t\t\t\t`domain_aliasses`\n\t\t\tWHERE\n\t\t\t\t`alias_id` = ?\n\t\t\tAND\n\t\t\t\t`domain_id` = ?\n\t\t\tAND\n\t\t\t\t`alias_status` = ?\n\t\t";
        $stmt = exec_query($query, array($domainAliasId, $domainId, 'ok'));
        if (!$stmt->rowCount()) {
            return false;
        }
        $domainAliasData = $stmt->fetchRow(PDO::FETCH_ASSOC);
        $domainAliasData['alias_name_utf8'] = decode_idna($domainAliasData['alias_name']);
    }
    return $domainAliasData;
}
示例#11
0
/**
 * Get domains list
 *
 * @return array Domains list
 */
function getDomainsList()
{
    static $domainsList = null;
    if (null !== $domainsList) {
        return $domainsList;
    }
    $mainDmnProps = get_domain_default_props($_SESSION['user_id']);
    $domainsList = array(array('name' => $mainDmnProps['domain_name'], 'id' => $mainDmnProps['domain_id'], 'type' => 'dmn', 'mount_point' => '/'));
    $stmt = exec_query("\n            SELECT CONCAT(t1.subdomain_name, '.', t2.domain_name) AS name, t1.subdomain_mount AS mount_point\n            FROM subdomain AS t1 INNER JOIN domain AS t2 USING(domain_id)\n            WHERE t1.domain_id = :domain_id AND t1.subdomain_status = :status_ok\n            UNION ALL\n            SELECT alias_name AS name, alias_mount AS mount_point\n            FROM domain_aliasses\n            WHERE domain_id = :domain_id AND alias_status = :status_ok\n            UNION ALL\n            SELECT CONCAT(t1.subdomain_alias_name, '.', t2.alias_name) AS name, t1.subdomain_alias_mount AS mount_point\n            FROM subdomain_alias AS t1 INNER JOIN domain_aliasses AS t2 USING(alias_id)\n            WHERE t2.domain_id = :domain_id AND subdomain_alias_status = :status_ok\n        ", array('domain_id' => $mainDmnProps['domain_id'], 'status_ok' => 'ok'));
    if ($stmt->rowCount()) {
        $domainsList = array_merge($domainsList, $stmt->fetchAll(PDO::FETCH_ASSOC));
        usort($domainsList, function ($a, $b) {
            return strnatcmp(decode_idna($a['name']), decode_idna($b['name']));
        });
    }
    return $domainsList;
}
示例#12
0
/**
 * Returns verified data
 *
 * @access private
 * @param int $itemId Item id (Domain ID or domain alias id)
 * @param string $itemType Item type (normal or alias
 * @return array An array that holds verified data
 */
function _client_getVerifiedData($itemId, $itemType)
{
    $domainProps = get_domain_default_props($_SESSION['user_id']);
    $domainId = $domainProps['domain_id'];
    if ($itemType == 'normal') {
        $stmt = exec_query('
				SELECT
					domain_id, domain_name AS name, external_mail, external_mail_dns_ids
				FROM
					domain WHERE domain_id = ?
			', $domainId);
        if ($stmt->rowCount()) {
            $row = $stmt->fetchRow(PDO::FETCH_ASSOC);
            if ($row['domain_id'] !== $itemId) {
                showBadRequestErrorPage();
                exit;
            }
        } else {
            showBadRequestErrorPage();
            exit;
        }
    } elseif ($itemType == 'alias') {
        $stmt = exec_query('
				SELECT
					domain_id, alias_name AS name, external_mail, external_mail_dns_ids
				FROM
					domain_aliasses
				WHERE
					alias_id = ?
				AND
					domain_id = ?
			', array($itemId, $domainId));
        if ($stmt->rowCount()) {
            $row = $stmt->fetchRow(PDO::FETCH_ASSOC);
        } else {
            showBadRequestErrorPage();
            exit;
        }
    } else {
        showBadRequestErrorPage();
        exit;
    }
    return array('domain_id' => $domainId, 'item_id' => $itemId, 'item_name' => $row['name'], 'item_type' => $itemType, 'external_mail_type' => $row['external_mail'], 'external_mail_dns_ids' => explode(',', $row['external_mail_dns_ids']));
}
示例#13
0
/**
 * @param EasySCP_TemplateEngine $tpl
 * @param EasySCP_Database $sql
 * @param int $user_id
 * @param int $db_id
 * @param bool $sqluser_available
 * @return void
 */
function check_sql_permissions($tpl, $sql, $user_id, $db_id, $sqluser_available)
{
    $dmn_props = get_domain_default_props($user_id);
    list(, $sqlu_acc_cnt) = get_domain_running_sql_acc_cnt($sql, $dmn_props['domain_id']);
    if ($dmn_props['domain_sqlu_limit'] != 0 && $sqlu_acc_cnt >= $dmn_props['domain_sqlu_limit']) {
        if (!$sqluser_available) {
            set_page_message(tr('SQL users limit reached!'), 'warning');
            user_goto('sql_manage.php');
        }
    } else {
        $tpl->assign('CREATE_SQLUSER', true);
    }
    $dmn_name = $_SESSION['user_logged'];
    $query = "\n\t\tSELECT\n\t\t\tt1.`sqld_id`, t2.`domain_id`, t2.`domain_name`\n\t\tFROM\n\t\t\t`sql_database` AS t1,\n\t\t\t`domain` AS t2\n\t\tWHERE\n\t\t\tt1.`sqld_id` = ?\n\t\tAND\n\t\t\tt2.`domain_id` = t1.`domain_id`\n\t\tAND\n\t\t\tt2.`domain_name` = ?\n\t";
    $rs = exec_query($sql, $query, array($db_id, $dmn_name));
    if ($rs->recordCount() == 0) {
        set_page_message(tr('User does not exist or you do not have permission to access this interface!'), 'warning');
        user_goto('sql_manage.php');
    }
}
示例#14
0
/**
 * Returns verified data
 *
 * @access private
 * @param int $itemId Item id (Domain ID or domain alias id)
 * @param string $itemType Item type (normal or alias
 * @return array An array that holds verified data (main domain id and item name)
 */
function _client_getVerifiedData($itemId, $itemType)
{
    $domainProps = get_domain_default_props($_SESSION['user_id']);
    $domainId = $domainProps['domain_id'];
    if ($itemType == 'normal') {
        $stmt = exec_query('SELECT domain_id, domain_name AS name FROM domain WHERE domain_id = ?', $domainId);
        if (!$stmt->rowCount() || $stmt->fields['domain_id'] !== $itemId) {
            showBadRequestErrorPage();
        }
    } elseif ($itemType == 'alias') {
        $stmt = exec_query('SELECT domain_id, alias_name AS name FROM domain_aliasses WHERE alias_id = ? AND domain_id = ?', array($itemId, $domainId));
        if (!$stmt->rowCount()) {
            showBadRequestErrorPage();
        }
    } else {
        showBadRequestErrorPage();
        exit;
        // Only to make some IDE happy
    }
    return array('domain_id' => $domainId, 'item_id' => $itemId, 'item_name' => $stmt->fields['name'], 'item_type' => $itemType);
}
/**
 * Checks that the given mail account is owned by current customer and its responder is not active
 *
 * @param int $mailAccountId Mail account id to check
 * @return bool TRUE if the mail account is owned by the current customer, FALSE otherwise
 */
function client_checkMailAccountOwner($mailAccountId)
{
    $domainProps = get_domain_default_props($_SESSION['user_id']);
    $query = '
		SELECT
			`t1`.*, `t2`.`domain_id`, `t2`.`domain_name`
		FROM
			`mail_users` AS `t1`, `domain` AS `t2`
		WHERE
			`t1`.`mail_id` = ?
		AND
			`t2`.`domain_id` = `t1`.`domain_id`
		AND
			`t2`.`domain_id` = ?
		AND
			`t1`.`mail_auto_respond` = ?
		AND
			`t1`.`status` = ?
    ';
    $stmt = exec_query($query, array($mailAccountId, $domainProps['domain_id'], 0, 'ok'));
    return (bool) $stmt->rowCount();
}
示例#16
0
function check_sql_permissions(&$tpl, $sql, $user_id, $db_id, $sqluser_available)
{
    if (isset($_SESSION['sql_support']) && $_SESSION['sql_support'] == "no") {
        header("Location: index.php");
    }
    list($dmn_id, $dmn_name, $dmn_gid, $dmn_uid, $dmn_created_id, $dmn_created, $dmn_last_modified, $dmn_mailacc_limit, $dmn_ftpacc_limit, $dmn_traff_limit, $dmn_sqld_limit, $dmn_sqlu_limit, $dmn_status, $dmn_als_limit, $dmn_subd_limit, $dmn_ip_id, $dmn_disk_limit, $dmn_disk_usage, $dmn_php, $dmn_cgi) = get_domain_default_props($sql, $user_id);
    list($sqld_acc_cnt, $sqlu_acc_cnt) = get_domain_running_sql_acc_cnt($sql, $dmn_id);
    if ($dmn_sqlu_limit != 0 && $sqlu_acc_cnt >= $dmn_sqlu_limit) {
        if (!$sqluser_available) {
            set_page_message(tr('SQL-user limit expired!'));
            header("Location: manage_sql.php");
            die;
        } else {
            $tpl->assign('CREATE_SQLUSER', '');
        }
    }
    $dmn_name = $_SESSION['user_logged'];
    $query = <<<SQL_QUERY
        select
            t1.sqld_id, t2.domain_id, t2.domain_name
        from
            sql_database as t1,
            domain as t2
        where
            t1.sqld_id = ?
          and
            t2.domain_id = t1.domain_id
          and
            t2.domain_name = ?
SQL_QUERY;
    $rs = exec_query($sql, $query, array($db_id, $dmn_name));
    if ($rs->RecordCount() == 0) {
        set_page_message(tr('User does not exist or you do not have permission to access this interface!'));
        header('Location: manage_sql.php');
        die;
    }
}
示例#17
0
/**
 * Generate page
 *
 * @param iMSCP_pTemplate $tpl
 */
function client_generatePage($tpl)
{
    $mailId = clean_input($_GET['id']);
    $mainDmnProps = get_domain_default_props($_SESSION['user_id']);
    $mailData = client_getEmailAccountData($mailId);
    list($username, $domainName) = explode('@', $mailData['mail_addr']);
    $stmt = exec_query('SELECT SUM(`quota`) AS `quota` FROM `mail_users` WHERE `domain_id` = ? AND `quota` IS NOT NULL', $mainDmnProps['domain_id']);
    $quota = $stmt->fields['quota'];
    /** @var iMSCP_Config_Handler_File $cfg */
    $cfg = iMSCP_Registry::get('config');
    $checked = $cfg->HTML_CHECKED;
    $selected = $cfg->HTML_SELECTED;
    $mailType = '';
    if (!isset($_POST['account_type']) || !in_array($_POST['account_type'], array('1', '2', '3'))) {
        if (preg_match('/_mail/', $mailData['mail_type'])) {
            $mailType = '1';
        }
        if (preg_match('/_forward/', $mailData['mail_type'])) {
            $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));
}
示例#18
0
/**
 * Add new domain alias
 *
 * @return bool
 * @throws Exception
 * @throws iMSCP_Exception
 * @throws iMSCP_Exception_Database
 */
function addDomainAlias()
{
    // Basic check
    if (empty($_POST['customer_id'])) {
        showBadRequestErrorPage();
    }
    $customerId = clean_input($_POST['customer_id']);
    if (empty($_POST['domain_alias_name'])) {
        set_page_message(tr('You must enter a domain alias name.'), 'error');
        return false;
    }
    $domainAliasName = clean_input(strtolower($_POST['domain_alias_name']));
    // Check for domain alias name syntax
    global $dmnNameValidationErrMsg;
    if (!isValidDomainName($domainAliasName)) {
        set_page_message($dmnNameValidationErrMsg, 'error');
        return false;
    }
    // www is considered as an alias of the domain alias
    while (strpos($domainAliasName, 'www.') !== false) {
        $domainAliasName = substr($domainAliasName, 4);
    }
    // Check for domain alias existence
    if (imscp_domain_exists($domainAliasName, $_SESSION['user_id'])) {
        set_page_message(tr('Domain %s is unavailable.', "<strong>{$domainAliasName}</strong>"), 'error');
        return false;
    }
    $domainAliasNameAscii = encode_idna($domainAliasName);
    // Set default mount point
    $mountPoint = "/{$domainAliasNameAscii}";
    // Check for shared mount point option
    if (isset($_POST['shared_mount_point']) && $_POST['shared_mount_point'] == 'yes') {
        if (!isset($_POST['shared_mount_point_domain'])) {
            showBadRequestErrorPage();
        }
        $sharedMountPointDomain = clean_input($_POST['shared_mount_point_domain']);
        $domainList = getDomainsList($customerId);
        // Get shared mount point
        foreach ($domainList as $domain) {
            if ($domain['name'] == $sharedMountPointDomain) {
                $mountPoint = $domain['mount_point'];
            }
        }
    }
    // Check for URL forwarding option
    $forwardUrl = 'no';
    if (isset($_POST['url_forwarding']) && $_POST['url_forwarding'] == 'yes') {
        if (!isset($_POST['forward_url_scheme']) || !isset($_POST['forward_url'])) {
            showBadRequestErrorPage();
        }
        $forwardUrl = clean_input($_POST['forward_url_scheme']) . clean_input($_POST['forward_url']);
        try {
            try {
                $uri = iMSCP_Uri_Redirect::fromString($forwardUrl);
            } catch (Zend_Uri_Exception $e) {
                throw new iMSCP_Exception(tr('Forward URL %s is not valid.', "<strong>{$forwardUrl}</strong>"));
            }
            $uri->setHost(encode_idna($uri->getHost()));
            if ($uri->getHost() == $domainAliasNameAscii && $uri->getPath() == '/') {
                throw new iMSCP_Exception(tr('Forward URL %s is not valid.', "<strong>{$forwardUrl}</strong>") . ' ' . tr('Domain alias %s cannot be forwarded on itself.', "<strong>{$domainAliasName}</strong>"));
            }
            $forwardUrl = $uri->getUri();
        } catch (Exception $e) {
            set_page_message($e->getMessage(), 'error');
            return false;
        }
    }
    $mainDmnProps = get_domain_default_props($customerId, $_SESSION['user_id']);
    $cfg = iMSCP_Registry::get('config');
    $db = iMSCP_Database::getInstance();
    try {
        iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onBeforeAddDomainAlias, array('domainId' => $mainDmnProps['domain_id'], 'domainAliasName' => $domainAliasNameAscii));
        $db->beginTransaction();
        exec_query('
                INSERT INTO domain_aliasses (
                    domain_id, alias_name, alias_mount, alias_status, alias_ip_id, url_forward
                ) VALUES (
                    ?, ?, ?, ?, ?, ?
                )
            ', array($mainDmnProps['domain_id'], $domainAliasNameAscii, $mountPoint, 'toadd', $mainDmnProps['domain_ip_id'], $forwardUrl));
        $id = $db->insertId();
        // Create the phpini entry for that domain alias
        $phpini = iMSCP_PHPini::getInstance();
        $phpini->loadResellerPermissions($_SESSION['user_id']);
        // Load reseller PHP permissions
        $phpini->loadClientPermissions($mainDmnProps['admin_id']);
        // Load client PHP permissions
        $phpini->loadDomainIni($mainDmnProps['admin_id'], $mainDmnProps['domain_id'], 'dmn');
        // Load main domain PHP configuration options
        $phpini->saveDomainIni($mainDmnProps['admin_id'], $id, 'als');
        // Create default email addresses if needed
        if ($cfg['CREATE_DEFAULT_EMAIL_ADDRESSES'] && $mainDmnProps['admin_email'] !== '') {
            client_mail_add_default_accounts($mainDmnProps['domain_id'], $mainDmnProps['admin_email'], $domainAliasNameAscii, 'alias', $id);
        }
        $db->commit();
        iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onAfterAddDomainAlias, array('domainId' => $mainDmnProps['domain_id'], 'domainAliasName' => $domainAliasNameAscii, 'domainAliasId' => $id));
        send_request();
        write_log(sprintf('New domain alias `%s` has been added by %', $domainAliasName, $_SESSION['user_logged']), E_USER_NOTICE);
        set_page_message(tr('Domain alias successfully scheduled for addition.'), 'success');
    } catch (iMSCP_Exception_Database $e) {
        $db->rollBack();
        throw $e;
    }
    return true;
}
示例#19
0
/**
 * @throws EasySCP_Exception_Database
 * @param int $edit_id
 * @return bool
 */
function check_fwd_data($edit_id)
{
    $sql = EasySCP_Registry::get('Db');
    $add_mode = $edit_id === true;
    // unset errors
    $ed_error = '_off_';
    $err = '';
    $_text = '';
    $_type = $_POST['type'];
    $dmn_props = get_domain_default_props($_SESSION['user_id']);
    if ($add_mode) {
        $query = "\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM (\n\t\t\t\tSELECT\n\t\t\t\t\t'0' AS `alias_id`,\n\t\t\t\t\t`domain`.`domain_name` AS `domain_name`\n\t\t\t\tFROM\n\t\t\t\t\t`domain`\n\t\t\t\tWHERE\n\t\t\t\t\t`domain_id` = ?\n\t\t\t\tUNION\n\t\t\t\tSELECT\n\t\t\t\t\t`domain_aliasses`.`alias_id`,\n\t\t\t\t\t`domain_aliasses`.`alias_name`\n\t\t\t\tFROM\n\t\t\t\t\t`domain_aliasses`\n\t\t\t\tWHERE\n\t\t\t\t\t`domain_aliasses`.`domain_id` = ?\n\t\t\t) AS `tbl`\n\t\t\tWHERE\n\t\t\t\tIFNULL(`tbl`.`alias_id`, 0) = ?\n\t\t";
        $res = exec_query($sql, $query, array($dmn_props['domain_id'], $dmn_props['domain_id'], $_POST['alias_id']));
        if ($res->recordCount() <= 0) {
            not_allowed();
        }
        $data = $res->fetchRow();
        $record_domain = $data['domain_name'];
        // if no alias is selected, ID is 0 else the real alias_id
        $alias_id = $data['alias_id'];
        $_dns = $data['domain_name'];
    } else {
        $sql_query = "\n\t\t\t\tSELECT\n\t\t\t\t\td.id,\n\t\t\t\t\td.easyscp_domain_id,\n\t\t\t\t\td.easyscp_domain_alias_id,\n\t\t\t\t\td.name\n\t\t\t\tFROM\n\t\t\t\t\tpowerdns.domains d,\n\t\t\t\t\tpowerdns.records r\n\t\t\t\tWHERE\n\t\t\t\t\tr.id = :record_id\n\t\t\t\tAND\n\t\t\t\t\tr.domain_id = d.id;\n\t\t";
        $sql_param = array('record_id' => $edit_id);
        DB::prepare($sql_query);
        $stmt = DB::execute($sql_param);
        if ($stmt->rowCount() <= 0) {
            not_allowed();
        }
        $data = $stmt->fetch();
        $record_domain = $data['name'];
        $alias_id = $data['easyscp_domain_alias_id'];
        $_dns = $data['name'];
        $domain_id = $data['id'];
    }
    if (!validate_NAME(array('name' => $_POST['dns_name'], 'domain' => $record_domain), $err)) {
        $ed_error = sprintf(tr('Cannot validate %s record. Reason \'%s\'.'), $_POST['type'], $err);
    }
    $_ttl = null;
    $_dns_srv_prio = null;
    switch ($_POST['type']) {
        case 'CNAME':
            if (!validate_CNAME($_POST, $err)) {
                $ed_error = sprintf(tr('Cannot validate %s record. Reason \'%s\'.'), $_POST['type'], $err);
            }
            $_text = $_POST['dns_cname'];
            $_dns = $_POST['dns_name'];
            break;
        case 'A':
            if (!validate_A($_POST, $err)) {
                $ed_error = sprintf(tr('Cannot validate %s record. Reason \'%s\'.'), $_POST['type'], $err);
            }
            if (!check_CNAME_conflict($_POST['dns_name'] . '.' . $record_domain, $err)) {
                $ed_error = sprintf(tr('Cannot validate %s record. Reason \'%s\'.'), $_POST['type'], $err);
            }
            $_text = $_POST['dns_A_address'];
            $_dns = $_POST['dns_name'];
            $_ttl = '7200';
            break;
        case 'AAAA':
            if (!validate_AAAA($_POST, $err)) {
                $ed_error = sprintf(tr('Cannot validate %s record. Reason \'%s\'.'), $_POST['type'], $err);
            }
            if (!check_CNAME_conflict($_POST['dns_name'] . '.' . $record_domain, $err)) {
                $ed_error = sprintf(tr('Cannot validate %s record. Reason \'%s\'.'), $_POST['type'], $err);
            }
            $_text = $_POST['dns_AAAA_address'];
            $_dns = $_POST['dns_name'];
            break;
        case 'SRV':
            if (!validate_SRV($_POST, $err, $_dns, $_text)) {
                $ed_error = sprintf(tr('Cannot validate %s record. Reason \'%s\'.'), $_POST['type'], $err);
            }
            break;
        case 'MX':
            if (!validate_MX($_POST, $err, $_dns_srv_prio, $_text)) {
                $ed_error = sprintf(tr('Cannot validate %s record. Reason \'%s\'.'), $_POST['type'], $err);
            } else {
                // $_dns = $record_domain . '.';
                $_dns = $record_domain;
            }
            break;
        case 'NS':
            if (!validate_NS($_POST, $err)) {
                $ed_error = sprintf(tr('Cannot validate %s record. Reason \'%s\'.'), $_POST['type'], $err);
            }
            $_text = $_POST['dns_ns'];
            $_ttl = '28800';
            break;
        case 'SOA':
            $_ttl = '3600';
            break;
        default:
            $ed_error = sprintf(tr('Unknown zone type %s!'), $_POST['type']);
    }
    if ($ed_error === '_off_') {
        if ($add_mode) {
            if ($alias_id > 0) {
                $sql_param = array('alias_id' => $alias_id);
                $sql_query = "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tid\n\t\t\t\t\tFROM\n\t\t\t\t\t\tpowerdns.domains\n\t\t\t\t\tWHERE\n\t\t\t\t\t\teasyscp_domain_alias_id = :alias_id\n\t\t\t\t";
                DB::prepare($sql_query);
                $data = DB::execute($sql_param, true);
            } else {
                $sql_param = array('domain_id' => $dmn_props['domain_id']);
                $sql_query = "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tid\n\t\t\t\t\tFROM\n\t\t\t\t\t\tpowerdns.domains\n\t\t\t\t\tWHERE\n\t\t\t\t\t\teasyscp_domain_id = :domain_id\n\t\t\t\t";
                DB::prepare($sql_query);
                $data = DB::execute($sql_param, true);
            }
            $sql_param = array('domain_id' => $data['id'], 'name' => $_dns, 'type' => $_type, 'content' => $_text, 'ttl' => $_ttl, 'prio' => $_dns_srv_prio);
            $sql_query = "\n\t\t\t\tINSERT INTO\n\t\t\t\t\tpowerdns.records (domain_id, name, type, content, ttl, prio)\n\t\t\t\tVALUES\n\t\t\t\t\t(:domain_id, :name, :type, :content, :ttl, :prio)\n\t\t\t\tON DUPLICATE KEY UPDATE\n\t\t\t\t\tdomain_id = :domain_id, name = :name, type = :type, content = :content, ttl = :ttl, prio = :prio;\n\t\t\t";
            DB::prepare($sql_query);
            DB::execute($sql_param);
        } else {
            $sql_param = array('domain_id' => $domain_id, 'name' => $_dns, 'type' => $_type, 'content' => $_text, 'ttl' => $_ttl, 'prio' => $_dns_srv_prio, 'record_id' => $edit_id);
            $sql_query = "\n\t\t\t\t\tUPDATE\n\t\t\t\t\t\tpowerdns.records\n\t\t\t\t\tSET\n\t\t\t\t\t\tdomain_id = :domain_id,\n\t\t\t\t\t\tname\t= :name,\n\t\t\t\t\t\ttype = :type,\n\t\t\t\t\t\tcontent = :content,\n\t\t\t\t\t\tttl = :ttl,\n\t\t\t\t\t\tprio = :prio\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tid = :record_id\n\t\t\t";
            DB::prepare($sql_query);
            DB::execute($sql_param);
        }
        $admin_login = $_SESSION['user_logged'];
        write_log("{$admin_login}: " . ($add_mode ? 'add new' : ' modify') . " dns zone record.");
        unset($_SESSION['edit_ID']);
        return true;
    } else {
        set_page_message($ed_error, 'error');
        return false;
    }
}
示例#20
0
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * @link 		http://www.easyscp.net
 * @author 		EasySCP Team
 * @since               1.2.0
 */
require '../../include/easyscp-lib.php';
check_login(__FILE__);
$cfg = EasySCP_Registry::get('Config');
$html_selected = $cfg->HTML_SELECTED;
$tpl = EasySCP_TemplateEngine::getInstance();
$template = 'client/domain_manage_ssl.tpl';
// static page messages.
gen_logged_from($tpl);
check_permissions($tpl);
$dmn_props = get_domain_default_props($_SESSION['user_id']);
if (isset($_SESSION['ssl_configuration_updated']) && $_SESSION['ssl_configuration_updated'] == "_yes_") {
    unset($_POST);
    unset($_SESSION['ssl_configuration_updated']);
}
if (isset($_POST['Submit']) && isset($_POST['uaction']) && $_POST['uaction'] === 'apply') {
    $sslkey = clean_input(filter_input(INPUT_POST, 'ssl_key'));
    $sslcert = clean_input(filter_input(INPUT_POST, 'ssl_cert'));
    $sslcacert = clean_input(filter_input(INPUT_POST, 'ssl_cacert'));
    $sslstatus = clean_input(filter_input(INPUT_POST, 'ssl_status'));
    $rs = EasySSL::storeSSLData($_POST['ssl_domain'], $sslstatus, $sslkey, $sslcert, $sslcacert);
    if ($rs === false) {
        set_page_message(tr("SSL Certificate and key don't match!"), 'error');
    } else {
        if ($rs->rowCount() == 0) {
            set_page_message(tr("SSL configuration unchanged"), 'info');
示例#21
0
/**
 * check user sql permission
 */
function check_sql_permissions($sql, $user_id)
{
    if (isset($_SESSION['sql_support']) && $_SESSION['sql_support'] == "no") {
        header("Location: index.php");
    }
    $dmn_props = get_domain_default_props($user_id);
    list($sqld_acc_cnt) = get_domain_running_sql_acc_cnt($sql, $dmn_props['domain_id']);
    if ($dmn_props['domain_sqld_limit'] != 0 && $sqld_acc_cnt >= $dmn_props['domain_sqld_limit']) {
        set_page_message(tr('SQL accounts limit reached!'), 'warning');
        user_goto('sql_manage.php');
    }
}
示例#22
0
/**
 * Tells whether or not the current customer can access to the given feature(s)
 *
 * @author Laurent Declercq <*****@*****.**>
 * @throws iMSCP_Exception When $featureName is not known
 * @param array|string $featureNames Feature name(s) (insensitive case)
 * @param bool $forceReload If true force data to be reloaded
 * @return bool TRUE if $featureName is available for customer, FALSE otherwise
 */
function customerHasFeature($featureNames, $forceReload = false)
{
    static $availableFeatures = null;
    static $debug = false;
    if (null === $availableFeatures || $forceReload) {
        $cfg = iMSCP_Registry::get('config');
        $debug = (bool) $cfg['DEBUG'];
        $dmnProps = get_domain_default_props($_SESSION['user_id']);
        $availableFeatures = array('external_mail' => $dmnProps['domain_external_mail'] == 'yes' ? true : false, 'php' => $dmnProps['domain_php'] == 'yes' ? true : false, 'php_editor' => $dmnProps['phpini_perm_system'] == 'yes' && $dmnProps['phpini_perm_allow_url_fopen'] == 'yes' || $dmnProps['phpini_perm_display_errors'] == 'yes' || in_array($dmnProps['phpini_perm_disable_functions'], array('yes', 'exec')) ? true : false, 'cgi' => $dmnProps['domain_cgi'] == 'yes' ? true : false, 'ftp' => $dmnProps['domain_ftpacc_limit'] != '-1' ? true : false, 'sql' => $dmnProps['domain_sqld_limit'] != '-1' ? true : false, 'mail' => $dmnProps['domain_mailacc_limit'] != '-1' ? true : false, 'subdomains' => $dmnProps['domain_subd_limit'] != '-1' ? true : false, 'domain_aliases' => $dmnProps['domain_alias_limit'] != '-1' ? true : false, 'custom_dns_records' => $dmnProps['domain_dns'] != 'no' && $cfg['NAMED_SERVER'] != 'external_server' ? true : false, 'webstats' => $cfg['WEBSTATS_PACKAGES'] != 'No' ? true : false, 'backup' => $cfg['BACKUP_DOMAINS'] != 'no' && $dmnProps['allowbackup'] != '' ? true : false, 'protected_areas' => true, 'custom_error_pages' => true, 'aps' => $dmnProps['domain_software_allowed'] != 'no' && $dmnProps['domain_ftpacc_limit'] != '-1' ? true : false, 'ssl' => $cfg['ENABLE_SSL'] ? true : false);
        if ($cfg['IMSCP_SUPPORT_SYSTEM']) {
            $stmt = exec_query('SELECT support_system FROM reseller_props WHERE reseller_id = ?', $_SESSION['user_created_by']);
            $row = $stmt->fetchRow(PDO::FETCH_ASSOC);
            $availableFeatures['support'] = $row['support_system'] == 'yes' ? true : false;
        } else {
            $availableFeatures['support'] = false;
        }
    }
    $canAccess = true;
    foreach ((array) $featureNames as $featureName) {
        $featureName = strtolower($featureName);
        if ($debug && !array_key_exists($featureName, $availableFeatures)) {
            throw new iMSCP_Exception(sprintf("Feature %s is not known by the customerHasFeature() function.", $featureName));
        }
        if (!$availableFeatures[$featureName]) {
            $canAccess = false;
            break;
        }
    }
    return $canAccess;
}
示例#23
0
if (isset($_POST['uaction']) && $_POST['uaction'] === 'save_layout') {
    $user_id = $_SESSION['user_id'];
    $user_layout = $_POST['def_layout'];
    $query = <<<SQL_QUERY
        update
            user_gui_props
        set
            layout = ?
        where
            user_id = ?

SQL_QUERY;
    $rs = exec_query($sql, $query, array($user_layout, $user_id));
    $theme_color = $user_layout;
}
list($dmn_id, $dmn_name, $dmn_gid, $dmn_uid, $dmn_created_id, $dmn_created, $dmn_last_modified, $dmn_mailacc_limit, $dmn_ftpacc_limit, $dmn_traff_limit, $dmn_sqld_limit, $dmn_sqlu_limit, $dmn_status, $dmn_als_limit, $dmn_subd_limit, $dmn_ip_id, $dmn_disk_limit, $dmn_disk_usage, $dmn_php, $dmn_cgi) = get_domain_default_props($sql, $_SESSION['user_id']);
list($sub_cnt, $als_cnt, $mail_acc_cnt, $ftp_acc_cnt, $sqld_acc_cnt, $sqlu_acc_cnt) = get_domain_running_props_cnt($sql, $dmn_id);
// ko ima jump from other user interface neka esik i optica da ostanat tezi na
// ska4ashtijat user
if (!isset($_SESSION['logged_from']) && !isset($_SESSION['logged_from_id'])) {
    list($user_def_lang, $user_def_layout) = get_user_gui_props($sql, $_SESSION['user_id']);
} else {
    $user_def_layout = $_SESSION['user_theme_color'];
    $user_def_lang = $_SESSION['user_def_lang'];
}
gen_def_language($tpl, $sql, $user_def_lang);
gen_def_layout($tpl, $sql, $user_def_layout);
$dtraff_pr = 0;
$dmn_traff_usege = 0;
$dmn_traff_limit = $dmn_traff_limit * 1024 * 1024;
list($dtraff_pr, $dmn_traff_usege) = make_traff_usege($_SESSION['user_id']);
示例#24
0
/**
 * Check SQL permissions
 *
 * @return void
 */
function client_checkSqlDbLimit()
{
    $mainDmnProps = get_domain_default_props($_SESSION['user_id']);
    $mainDmnId = $mainDmnProps['domain_id'];
    $sqlDatabaseLimit = $mainDmnProps['domain_sqld_limit'];
    list($nbSqlDb) = get_domain_running_sql_acc_cnt($mainDmnId);
    if ($sqlDatabaseLimit != 0 && $nbSqlDb >= $sqlDatabaseLimit) {
        set_page_message(tr('SQL database limit reached.'), 'error');
        redirectTo('sql_manage.php');
    }
}
示例#25
0
    if (!$stmt->rowCount()) {
        set_page_message(tr('You do not have databases.'), 'static_info');
        $tpl->assign('SQL_DATABASES_USERS_LIST', '');
    } else {
        while ($row = $stmt->fetchRow(PDO::FETCH_ASSOC)) {
            $tpl->assign(array('DB_ID' => $row['sqld_id'], 'DB_NAME' => tohtml($row['sqld_name']), 'DB_NAME_JS' => tojs($row['sqld_name'])));
            _client_generateDatabaseSqlUserList($tpl, $row['sqld_id']);
            $tpl->parse('SQL_DATABASES_LIST', '.sql_databases_list');
        }
    }
}
/***********************************************************************************************************************
 * Main
 */
require_once 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
check_login('user');
customerHasFeature('sql') or showBadRequestErrorPage();
$domainProperties = get_domain_default_props($_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/sql_manage.tpl', 'page_message' => 'layout', 'sql_databases_users_list' => 'page', 'sql_databases_list' => 'sql_databases_users_list', 'sql_users_list' => 'sql_databases_list'));
$tpl->assign(array('TR_PAGE_TITLE' => tr('Client / Databases / Overview'), 'TR_MANAGE_SQL' => tr('Manage SQL'), 'TR_DELETE' => tr('Delete'), 'TR_DATABASE' => tr('Database Name and Users'), 'TR_CHANGE_PASSWORD' => tr('Update password'), 'TR_ACTIONS' => tr('Actions'), 'TR_PHPMYADMIN' => tr('phpMyAdmin'), 'TR_DATABASE_USERS' => tr('Database users'), 'TR_ADD_USER' => tr('Add SQL user'), 'TR_LOGIN_PMA' => tr('Login into phpMyAdmin'), 'TR_DATABASE_MESSAGE_DELETE' => tr("This database will be permanently deleted. This process cannot be recovered. All users linked to this database will also be deleted if not linked to another database. Are you sure you want to delete the '%s' database?", '%s'), 'TR_USER_MESSAGE_DELETE' => tr("Are you sure you want delete the %s SQL user?", '%s')));
generateNavigation($tpl);
client_databasesList($tpl, $domainProperties['domain_id']);
generatePageMessage($tpl);
$tpl->parse('LAYOUT_CONTENT', 'page');
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptEnd, array('templateEngine' => $tpl));
$tpl->prnt();
unsetMessages();
示例#26
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));
}
示例#27
0
function gen_page_lists(&$tpl, &$sql, $user_id)
{
    list($dmn_id, $dmn_name, $dmn_gid, $dmn_uid, $dmn_created_id, $dmn_created, $dmn_last_modified, $dmn_mailacc_limit, $dmn_ftpacc_limit, $dmn_traff_limit, $dmn_sqld_limit, $dmn_sqlu_limit, $dmn_status, $dmn_als_limit, $dmn_subd_limit, $dmn_ip_id, $dmn_disk_limit, $dmn_disk_usage, $dmn_php, $dmn_cgi) = get_domain_default_props($sql, $user_id);
    gen_page_ftp_list($tpl, $sql, $dmn_id, $dmn_name);
    //return $total_mails;
}
示例#28
0
/**
 * @param EasySCP_TemplateEngine $tpl
 * @param EasySCP_Database $sql
 * @param int $id
 */
function gen_dynamic_page_data($tpl, $sql, $id)
{
    global $domain_id;
    $cfg = EasySCP_Registry::get('Config');
    $dmn_props = get_domain_default_props($_SESSION['user_id']);
    $domain_id = $dmn_props['domain_id'];
    list($mail_acc_cnt) = get_domain_running_mail_acc_cnt($sql, $dmn_props['domain_id']);
    if ($dmn_props['domain_mailacc_limit'] != 0 && $mail_acc_cnt >= $dmn_props['domain_mailacc_limit']) {
        set_page_message(tr('Mail accounts limit reached!'), 'warning');
        user_goto('mail_catchall.php');
    }
    $ok_status = $cfg->ITEM_OK_STATUS;
    $match = array();
    if (preg_match("/(\\d+);(normal|alias|subdom|alssub)/", $id, $match) == 1) {
        $item_id = $match[1];
        $item_type = $match[2];
        if ($item_type === 'normal') {
            $query = "\n\t\t\t\tSELECT\n\t\t\t\t\tt1.`mail_id`, t1.`mail_type`, t2.`domain_name`, t1.`mail_acc`\n\t\t\t\tFROM\n\t\t\t\t\t`mail_users` AS t1,\n\t\t\t\t\t`domain` AS t2\n\t\t\t\tWHERE\n\t\t\t\t\tt1.`domain_id` = ?\n\t\t\t\tAND\n\t\t\t\t\tt2.`domain_id` = ?\n\t\t\t\tAND\n\t\t\t\t\tt1.`sub_id` = '0'\n\t\t\t\tAND\n\t\t\t\t\tt1.`status` = ?\n\t\t\t\tORDER BY\n\t\t\t\t\tt1.`mail_type` DESC, t1.`mail_acc`\n\t\t\t";
            $rs = exec_query($sql, $query, array($item_id, $item_id, $ok_status));
            if ($rs->recordCount() == 0) {
                $tpl->assign(array('FORWARD_MAIL' => $cfg->HTML_CHECKED, 'MAIL_LIST' => '', 'DEFAULT' => 'forward'));
            } else {
                $tpl->assign(array('NORMAL_MAIL' => $cfg->HTML_CHECKED, 'NORMAL_MAIL_CHECK' => 'checked', 'FORWARD_MAIL' => '', 'DEFAULT' => 'normal'));
                while (!$rs->EOF) {
                    $show_mail_acc = decode_idna($rs->fields['mail_acc']);
                    $show_domain_name = decode_idna($rs->fields['domain_name']);
                    $mail_acc = $rs->fields['mail_acc'];
                    $domain_name = $rs->fields['domain_name'];
                    $tpl->append(array('MAIL_ID' => $rs->fields['mail_id'], 'MAIL_ACCOUNT' => tohtml($show_mail_acc . "@" . $show_domain_name), 'MAIL_ACCOUNT_PUNNY' => tohtml($mail_acc . "@" . $domain_name)));
                    $rs->moveNext();
                }
            }
        } else {
            if ($item_type === 'alias') {
                $query = "\n\t\t\t\tSELECT\n\t\t\t\t\tt1.`mail_id`, t1.`mail_type`, t2.`alias_name`, t1.`mail_acc`\n\t\t\t\tFROM\n\t\t\t\t\t`mail_users` AS t1,\n\t\t\t\t\t`domain_aliasses` AS t2\n\t\t\t\tWHERE\n\t\t\t\t\tt1.`sub_id` = t2.`alias_id`\n\t\t\t\tAND\n\t\t\t\t\tt1.`status` = ?\n\t\t\t\tAND\n\t\t\t\t\tt1.`mail_type` LIKE 'alias_%'\n\t\t\t\tAND\n\t\t\t\t\tt2.`alias_id` = ?\n\t\t\t\tORDER BY\n\t\t\t\t\tt1.`mail_type` DESC, t1.`mail_acc`\n\t\t\t";
                $rs = exec_query($sql, $query, array($ok_status, $item_id));
                if ($rs->recordCount() == 0) {
                    $tpl->assign(array('FORWARD_MAIL' => $cfg->HTML_CHECKED, 'MAIL_LIST' => '', 'DEFAULT' => 'forward'));
                } else {
                    $tpl->assign(array('NORMAL_MAIL' => $cfg->HTML_CHECKED, 'NORMAL_MAIL_CHECK' => 'checked', 'FORWARD_MAIL' => '', 'DEFAULT' => 'normal'));
                    while (!$rs->EOF) {
                        $show_mail_acc = decode_idna($rs->fields['mail_acc']);
                        $show_alias_name = decode_idna($rs->fields['alias_name']);
                        $mail_acc = $rs->fields['mail_acc'];
                        $alias_name = $rs->fields['alias_name'];
                        $tpl->append(array('MAIL_ID' => $rs->fields['mail_id'], 'MAIL_ACCOUNT' => tohtml($show_mail_acc . "@" . $show_alias_name), 'MAIL_ACCOUNT_PUNNY' => tohtml($mail_acc . "@" . $alias_name)));
                        $rs->moveNext();
                    }
                }
            } else {
                if ($item_type === 'subdom') {
                    $query = "\n\t\t\t\tSELECT\n\t\t\t\t\tt1.`mail_id`, t1.`mail_type`, CONCAT(t2.`subdomain_name`, '.', t3.`domain_name`) AS subdomain_name, t1.`mail_acc`\n\t\t\t\tFROM\n\t\t\t\t\t`mail_users` AS t1,\n\t\t\t\t\t`subdomain` AS t2,\n\t\t\t\t\t`domain` AS t3\n\t\t\t\tWHERE\n\t\t\t\t\tt1.`sub_id` = t2.`subdomain_id`\n\t\t\t\tAND\n\t\t\t\t\tt2.`domain_id` = t3.`domain_id`\n\t\t\t\tAND\n\t\t\t\t\tt1.`status` = ?\n\t\t\t\tAND\n\t\t\t\t\tt1.`mail_type` LIKE 'subdom_%'\n\t\t\t\tAND\n\t\t\t\t\tt2.`subdomain_id` = ?\n\t\t\t\tORDER BY\n\t\t\t\t\tt1.`mail_type` DESC, t1.`mail_acc`\n\t\t\t";
                    $rs = exec_query($sql, $query, array($ok_status, $item_id));
                    if ($rs->recordCount() == 0) {
                        $tpl->assign(array('FORWARD_MAIL' => $cfg->HTML_CHECKED, 'MAIL_LIST' => '', 'DEFAULT' => 'forward'));
                    } else {
                        $tpl->assign(array('NORMAL_MAIL' => $cfg->HTML_CHECKED, 'NORMAL_MAIL_CHECK' => 'checked', 'FORWARD_MAIL' => '', 'DEFAULT' => 'normal'));
                        while (!$rs->EOF) {
                            $show_mail_acc = decode_idna($rs->fields['mail_acc']);
                            $show_alias_name = decode_idna($rs->fields['subdomain_name']);
                            $mail_acc = $rs->fields['mail_acc'];
                            $alias_name = $rs->fields['subdomain_name'];
                            $tpl->append(array('MAIL_ID' => $rs->fields['mail_id'], 'MAIL_ACCOUNT' => tohtml($show_mail_acc . "@" . $show_alias_name), 'MAIL_ACCOUNT_PUNNY' => tohtml($mail_acc . "@" . $alias_name)));
                            $rs->moveNext();
                        }
                    }
                } else {
                    if ($item_type === 'alssub') {
                        $query = "\n\t\t\t\tSELECT\n\t\t\t\t\tt1.`mail_id`, t1.`mail_type`, CONCAT(t2.`subdomain_alias_name`, '.', t3.`alias_name`) AS subdomain_name, t1.`mail_acc`\n\t\t\t\tFROM\n\t\t\t\t\t`mail_users` AS t1,\n\t\t\t\t\t`subdomain_alias` AS t2,\n\t\t\t\t\t`domain_aliasses` AS t3\n\t\t\t\tWHERE\n\t\t\t\t\tt1.`sub_id` = t2.`subdomain_alias_id`\n\t\t\t\tAND\n\t\t\t\t\tt2.`alias_id` = t3.`alias_id`\n\t\t\t\tAND\n\t\t\t\t\tt1.`status` = ?\n\t\t\t\tAND\n\t\t\t\t\tt1.`mail_type` LIKE 'alssub_%'\n\t\t\t\tAND\n\t\t\t\t\tt2.`subdomain_alias_id` = ?\n\t\t\t\tORDER BY\n\t\t\t\t\tt1.`mail_type` DESC, t1.`mail_acc`\n\t\t\t";
                        $rs = exec_query($sql, $query, array($ok_status, $item_id));
                        if ($rs->recordCount() == 0) {
                            $tpl->assign(array('FORWARD_MAIL' => $cfg->HTML_CHECKED, 'MAIL_LIST' => '', 'DEFAULT' => 'forward'));
                        } else {
                            $tpl->assign(array('NORMAL_MAIL' => $cfg->HTML_CHECKED, 'NORMAL_MAIL_CHECK' => 'checked', 'FORWARD_MAIL' => '', 'DEFAULT' => 'normal'));
                            while (!$rs->EOF) {
                                $show_mail_acc = decode_idna($rs->fields['mail_acc']);
                                $show_alias_name = decode_idna($rs->fields['subdomain_name']);
                                $mail_acc = $rs->fields['mail_acc'];
                                $alias_name = $rs->fields['subdomain_name'];
                                $tpl->append(array('MAIL_ID' => $rs->fields['mail_id'], 'MAIL_ACCOUNT' => tohtml($show_mail_acc . "@" . $show_alias_name), 'MAIL_ACCOUNT_PUNNY' => tohtml($mail_acc . "@" . $alias_name)));
                                $rs->moveNext();
                            }
                        }
                    }
                }
            }
        }
    } else {
        user_goto('mail_catchall.php');
    }
}
示例#29
0
function write_error_page(&$sql, &$user_id, &$eid)
{
    $error = $_POST['error'];
    $eid = $_POST['eid'];
    $eid = "error_" . $eid;
    // let's check if exist error table for this looser
    $query = <<<SQL_QUERY
        select
            user_id
        from
            error_pages
        where
            user_id = ?
SQL_QUERY;
    $rs = exec_query($sql, $query, array($user_id));
    if ($rs->RecordCount() == 0) {
        /// oooo noooo we dont have error table ... i can't believe it ...
        $query = <<<SQL_QUERY
          insert into error_pages
              (user_id, error_401, error_403, error_404, error_500)
          values
               (?, '', '', '', '')
SQL_QUERY;
        $rs = exec_query($sql, $query, array($user_id));
    }
    check_for_lock_file();
    $query = <<<SQL_QUERY
        update
            error_pages
        set
          {$eid} = ?
        where
          user_id = ?
SQL_QUERY;
    $rs = exec_query($sql, $query, array($error, $user_id));
    // now save the file
    // error num (dir) = $eid
    // error text = $error
    list($temp_dmn_id, $temp_dmn_name, $temp_dmn_gid, $temp_dmn_uid, $temp_dmn_created_id, $temp_dmn_created, $temp_dmn_last_modified, $temp_dmn_mailacc_limit, $temp_dmn_ftpacc_limit, $temp_dmn_traff_limit, $temp_dmn_sqld_limit, $temp_dmn_sqlu_limit, $temp_dmn_status, $temp_dmn_als_limit, $temp_dmn_subd_limit, $temp_dmn_ip_id, $temp_dmn_disk_limit, $temp_dmn_disk_usage, $temp_dmn_php, $temp_dmn_cgi) = get_domain_default_props($sql, $_SESSION['user_id']);
    switch ($eid) {
        case 'error_401':
            $e_dir = '401';
            break;
        case 'error_403':
            $e_dir = '403';
            break;
        case 'error_404':
            $e_dir = '404';
            break;
        case 'error_500':
            $e_dir = '500';
            break;
    }
    global $cfg;
    @($file = fopen($cfg['FTP_HOMEDIR'] . '/' . $temp_dmn_name . '/errors/' . $e_dir . '/index.php', 'w'));
    if (!$file) {
        /* cannot open file for writing */
        $error_saving = 1;
        session_register("error_saving");
    } else {
        $content = stripslashes($error);
        fputs($file, $content);
        $saved = 1;
        session_register("saved");
    }
}
示例#30
0
function gen_page_ftp_acc_props($tpl, $sql, $user_id)
{
    $dmn_props = get_domain_default_props($user_id);
    list($ftp_acc_cnt, , , ) = get_domain_running_ftp_acc_cnt($sql, $dmn_props['domain_id']);
    if ($dmn_props['domain_ftpacc_limit'] != 0 && $ftp_acc_cnt >= $dmn_props['domain_ftpacc_limit']) {
        set_page_message(tr('FTP accounts limit reached!'), 'warning');
        user_goto('ftp_accounts.php');
    } else {
        if (!isset($_POST['uaction'])) {
            gen_page_form_data($tpl, $dmn_props['domain_name'], 'no');
            gen_dmn_als_list($tpl, $sql, $dmn_props['domain_id'], 'no');
            gen_dmn_sub_list($tpl, $sql, $dmn_props['domain_id'], $dmn_props['domain_name'], 'no');
            gen_page_js($tpl);
        } else {
            if (isset($_POST['uaction']) && $_POST['uaction'] === 'add_user') {
                gen_page_form_data($tpl, $dmn_props['domain_name'], 'yes');
                gen_dmn_als_list($tpl, $sql, $dmn_props['domain_id'], 'yes');
                gen_dmn_sub_list($tpl, $sql, $dmn_props['domain_id'], $dmn_props['domain_name'], 'yes');
                check_ftp_acc_data($tpl, $sql, $dmn_props['domain_id'], $dmn_props['domain_name']);
            }
        }
    }
}