function generate_user_props($user_id) { global $sql; $query = <<<SQL_QUERY select * from domain where domain_id = ? SQL_QUERY; $rs = exec_query($sql, $query, array($user_id)); if ($rs->RowCount() == 0) { return array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); } $sub_current = records_count('subdomain_id', 'subdomain', 'domain_id', $user_id); $sub_max = $rs->fields['domain_subd_limit']; $als_current = records_count('alias_id', 'domain_aliasses', 'domain_id', $user_id); $als_max = $rs->fields['domain_alias_limit']; $mail_current = records_count('mail_id', 'mail_users', 'domain_id', $user_id); $mail_max = $rs->fields['domain_mailacc_limit']; $ftp_current = sub_records_rlike_count('domain_name', 'domain', 'domain_id', $user_id, 'userid', 'ftp_users', 'userid', '@', ''); $ftp_current += sub_records_rlike_count('subdomain_name', 'subdomain', 'domain_id', $user_id, 'userid', 'ftp_users', 'userid', '@', ''); $ftp_current += sub_records_rlike_count('alias_name', 'domain_aliasses', 'domain_id', $user_id, 'userid', 'ftp_users', 'userid', '@', ''); $ftp_max = $rs->fields['domain_ftpacc_limit']; $sql_db_current = records_count('sqld_id', 'sql_database', 'domain_id', $user_id); $sql_db_max = $rs->fields['domain_sqld_limit']; $sql_user_current = sub_records_count('sqld_id', 'sql_database', 'domain_id', $user_id, 'sqlu_id', 'sql_user', 'sqld_id', '', ''); $sql_user_max = $rs->fields['domain_sqlu_limit']; $traff_max = $rs->fields['domain_traffic_limit']; $disk_max = $rs->fields['domain_disk_limit']; return array($sub_current, $sub_max, $als_current, $als_max, $mail_current, $mail_max, $ftp_current, $ftp_max, $sql_db_current, $sql_db_max, $sql_user_current, $sql_user_max, $traff_max, $disk_max); }
/** * @todo explain or replace the hack */ function generate_user_props($user_id) { $sql = EasySCP_Registry::get('Db'); $query = "\n\t\tSELECT\n\t\t\t*\n\t\tFROM\n\t\t\t`domain`\n\t\tWHERE\n\t\t\t`domain_id` = ?\n\t\t;\n\t"; $rs = exec_query($sql, $query, $user_id); if ($rs->rowCount() == 0) { return array_fill(0, 14, 0); } $sub_current = records_count('subdomain', 'domain_id', $user_id); $sub_max = $rs->fields['domain_subd_limit']; $als_current = records_count('domain_aliasses', 'domain_id', $user_id); $als_max = $rs->fields['domain_alias_limit']; $mail_current = records_count('mail_users', "mail_type NOT RLIKE '_catchall' AND domain_id", $user_id); $mail_max = $rs->fields['domain_mailacc_limit']; $ftp_current = sub_records_rlike_count('domain_name', 'domain', 'domain_id', $user_id, 'userid', 'ftp_users', 'userid', '@', ''); $ftp_current += sub_records_rlike_count('alias_name', 'domain_aliasses', 'domain_id', $user_id, 'userid', 'ftp_users', 'userid', '@', ''); $ftp_max = $rs->fields['domain_ftpacc_limit']; $sql_db_current = records_count('sql_database', 'domain_id', $user_id); $sql_db_max = $rs->fields['domain_sqld_limit']; $sql_user_current = sub_records_count('sqld_id', 'sql_database', 'domain_id', $user_id, 'sqlu_id', 'sql_user', 'sqld_id', 'sqlu_name', ''); $sql_user_max = $rs->fields['domain_sqlu_limit']; $traff_max = $rs->fields['domain_traffic_limit']; $disk_max = $rs->fields['domain_disk_limit']; return array($sub_current, $sub_max, $als_current, $als_max, $mail_current, $mail_max, $ftp_current, $ftp_max, $sql_db_current, $sql_db_max, $sql_user_current, $sql_user_max, $traff_max, $disk_max); }
/** * Get the total number of consumed and max available items for the given customer * * @param int $userId Domain unique identifier * @return array */ function shared_getCustomerProps($userId) { $cfg = iMSCP_Registry::get('config'); $stmt = exec_query("SELECT * FROM domain WHERE domain_admin_id = ?", $userId); if (!$stmt->rowCount()) { return array_fill(0, 14, 0); } $row = $stmt->fetchRow(PDO::FETCH_ASSOC); // Retrieves total number of subdomains already consumed by the customer $subConsumed = records_count('subdomain', 'domain_id', $row['domain_id']); // Retrieves max available number of subdomains for the customer $subMax = $row['domain_subd_limit']; // Retrieves total number of domain aliases already consumed by the customer $alsConsumed = records_count('domain_aliasses', 'domain_id', $row['domain_id']); // Retrieves max available number of domain aliases for the customer $alsMax = $row['domain_alias_limit']; // Retrieves total number of mail accounts already consumed by the customer // This works with the admin option (Count default email addresses) if ($cfg['COUNT_DEFAULT_EMAIL_ADDRESSES']) { $mailConsumed = records_count('mail_users', "mail_type NOT RLIKE '_catchall' AND domain_id", $row['domain_id']); } else { $where = "\n\t\t\t\t`mail_acc` != 'abuse'\n\t\t\tAND\n\t\t\t\t`mail_acc` != 'postmaster'\n\t\t\tAND\n\t\t\t\t`mail_acc` != 'webmaster'\n\t\t\tAND\n\t\t\t\t`mail_type` NOT RLIKE '_catchall'\n\t\t\tAND\n\t\t\t\t`domain_id`\n\t\t"; $mailConsumed = records_count('mail_users', $where, $row['domain_id']); } // Retrieves max available number of mail accounts for the customer $mailMax = $row['domain_mailacc_limit']; // Retrieve total number of ftp accounts already consumed by the customer $ftpConsumed = sub_records_rlike_count('domain_name', 'domain', 'domain_id', $row['domain_id'], 'userid', 'ftp_users', 'userid', '@', ''); $ftpConsumed += sub_records_rlike_count('alias_name', 'domain_aliasses', 'domain_id', $row['domain_id'], 'userid', 'ftp_users', 'userid', '@', ''); // Retrieves max available number of mail accounts for the customer $ftpMax = $row['domain_ftpacc_limit']; // Retrieves total number of SQL databases already consumed by the customer $sqlDbConsumed = records_count('sql_database', 'domain_id', $row['domain_id']); // Retrieves max available number of SQL databases for the customer $sqlDbMax = $row['domain_sqld_limit']; // Retrieves total number of SQL user already consumed by the customer $sqlUserConsumed = sub_records_count('sqld_id', 'sql_database', 'domain_id', $row['domain_id'], 'sqlu_id', 'sql_user', 'sqld_id', 'sqlu_name', ''); // Retrieves max number of SQL user for the customer $sqlUserMax = $row['domain_sqlu_limit']; // Retrieves max available montly traffic volume for the customer $trafficMax = $row['domain_traffic_limit']; // Retrieve max available diskspace limit for the customer $diskMax = $row['domain_disk_limit']; return array($subConsumed, $subMax, $alsConsumed, $alsMax, $mailConsumed, $mailMax, $ftpConsumed, $ftpMax, $sqlDbConsumed, $sqlDbMax, $sqlUserConsumed, $sqlUserMax, $trafficMax, $diskMax); }