/** * Making users props */ function generate_reseller_user_props($reseller_id) { $sql = EasySCP_Registry::get('Db'); // Init with empty variables $rdmn_current = 0; $rdmn_max = 0; $rdmn_uf = '_off_'; $rsub_current = 0; $rsub_max = 0; $rsub_uf = '_off_'; $rals_current = 0; $rals_max = 0; $rals_uf = '_off_'; $rmail_current = 0; $rmail_max = 0; $rmail_uf = '_off_'; $rftp_current = 0; $rftp_max = 0; $rftp_uf = '_off_'; $rsql_db_current = 0; $rsql_db_max = 0; $rsql_db_uf = '_off_'; $rsql_user_current = 0; $rsql_user_max = 0; $rsql_user_uf = '_off_'; $rtraff_current = 0; $rtraff_max = 0; $rtraff_uf = '_off_'; $rdisk_current = 0; $rdisk_max = 0; $rdisk_uf = '_off_'; $query = "\n\t\tSELECT\n\t\t\t`admin_id`\n\t\tFROM\n\t\t\t`admin`\n\t\tWHERE\n\t\t\t`created_by` = ?\n\t"; $res = exec_query($sql, $query, $reseller_id); if ($res->rowCount() == 0) { return array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); } // Process all users of this group while ($data = $res->fetchRow()) { $admin_id = $data['admin_id']; $query = "\n\t\t\tSELECT\n\t\t\t\t`domain_id`\n\t\t\tFROM\n\t\t\t\t`domain`\n\t\t\tWHERE\n\t\t\t\t`domain_admin_id` = ?\n\t\t"; $dres = exec_query($sql, $query, $admin_id); $ddata = $dres->fetchRow(); $user_id = $ddata['domain_id']; list($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_user_props($user_id); list(, , , , , , $traff_current, $disk_current) = generate_user_traffic($user_id); $rdmn_current += 1; if ($sub_max != -1) { if ($sub_max == 0) { $rsub_uf = '_on_'; } $rsub_current += $sub_current; $rsub_max += $sub_max; } // We always have to count aliases, because a reseller can add aliase for an user wheter the alias function for the user is disabled - TheCry /*if ($als_max != -1) { if ($als_max == 0) $rals_uf = '_on_'; $rals_current += $als_current; $rals_max += $als_max; }*/ if ($als_max == 0) { $rals_uf = '_on_'; } $rals_current += $als_current; $rals_max += $als_max; if ($mail_max != -1) { if ($mail_max == 0) { $rmail_uf = '_on_'; } $rmail_current += $mail_current; $rmail_max += $mail_max; } if ($ftp_max != -1) { if ($ftp_max == 0) { $rftp_uf = '_on_'; } $rftp_current += $ftp_current; $rftp_max += $ftp_max; } if ($sql_db_max != -1) { if ($sql_db_max == 0) { $rsql_db_uf = '_on_'; } $rsql_db_current += $sql_db_current; $rsql_db_max += $sql_db_max; } if ($sql_user_max != -1) { if ($sql_user_max == 0) { $rsql_user_uf = '_on_'; } $rsql_user_current += $sql_user_current; $rsql_user_max += $sql_user_max; } if ($traff_max == 0) { $rtraff_uf = '_on_'; } $rtraff_current += $traff_current; $rtraff_max += $traff_max; if ($disk_max == 0) { $rdisk_uf = '_on_'; } $rdisk_current += $disk_current; $rdisk_max += $disk_max; } return array($rdmn_current, $rdmn_max, $rdmn_uf, $rsub_current, $rsub_max, $rsub_uf, $rals_current, $rals_max, $rals_uf, $rmail_current, $rmail_max, $rmail_uf, $rftp_current, $rftp_max, $rftp_uf, $rsql_db_current, $rsql_db_max, $rsql_db_uf, $rsql_user_current, $rsql_user_max, $rsql_user_uf, $rtraff_current, $rtraff_max, $rtraff_uf, $rdisk_current, $rdisk_max, $rdisk_uf); }
/** * Generates user's properties * * @param int $resellerId Reseller unique identifier * @return array An array that contains user's properties */ function generate_reseller_user_props($resellerId) { $rdmnCurrent = $rdmnMax = $rsubCurrent = $rsubMax = $ralsCurrent = $ralsMax = $rmailCurrent = $rmailMax = $rftpCurrent = $rftpMax = $rsqlDbCurrent = $rsqlDbMax = $rsqlUserCurrent = $rsqlUserMax = $rtraffCurrent = $rtraffMax = $rdiskCurrent = $rdiskMax = 0; $rdmnUf = $rsubUf = $ralsUf = $rmailUf = $rftpUf = $rsqlDbUf = $rsqlUserUf = $rtraffUf = $rdiskUf = '_off_'; $stmt = exec_query(' SELECT admin_id, domain_id FROM admin INNER JOIN domain ON(domain_admin_id = admin_id) WHERE created_by = ? ', $resellerId); if (!$stmt->rowCount()) { return array_fill(0, 27, 0); } while ($data = $stmt->fetchRow()) { $adminId = $data['admin_id']; list($subCurrent, $subMax, $alsCurrent, $alsMax, $mailCurrent, $mailMax, $ftpCurrent, $ftpMax, $sqlDbCurrent, $sqlDbMax, $sqlUserCurrent, $sqlUserMax, $traffMax, $diskMax) = get_user_props($adminId); list(, , , , , , $traffCurrent, $diskCurrent) = shared_getCustomerStats($adminId); $rdmnCurrent += 1; if ($subMax != -1) { if ($subMax == 0) { $rsubUf = '_on_'; } $rsubCurrent += $subCurrent; $rsubMax += $subMax; } if ($alsMax == 0) { $ralsUf = '_on_'; } $ralsCurrent += $alsCurrent; $ralsMax += $alsMax; if ($mailMax != -1) { if ($mailMax == 0) { $rmailUf = '_on_'; } $rmailCurrent += $mailCurrent; $rmailMax += $mailMax; } if ($ftpMax != -1) { if ($ftpMax == 0) { $rftpUf = '_on_'; } $rftpCurrent += $ftpCurrent; $rftpMax += $ftpMax; } if ($sqlDbMax != -1) { if ($sqlDbMax == 0) { $rsqlDbUf = '_on_'; } $rsqlDbCurrent += $sqlDbCurrent; $rsqlDbMax += $sqlDbMax; } if ($sqlUserMax != -1) { if ($sqlUserMax == 0) { $rsqlUserUf = '_on_'; } $rsqlUserCurrent += $sqlUserCurrent; $rsqlUserMax += $sqlUserMax; } if ($traffMax == 0) { $rtraffUf = '_on_'; } $rtraffCurrent += $traffCurrent; $rtraffMax += $traffMax; if ($diskMax == 0) { $rdiskUf = '_on_'; } $rdiskCurrent += $diskCurrent; $rdiskMax += $diskMax; } return array($rdmnCurrent, $rdmnMax, $rdmnUf, $rsubCurrent, $rsubMax, $rsubUf, $ralsCurrent, $ralsMax, $ralsUf, $rmailCurrent, $rmailMax, $rmailUf, $rftpCurrent, $rftpMax, $rftpUf, $rsqlDbCurrent, $rsqlDbMax, $rsqlDbUf, $rsqlUserCurrent, $rsqlUserMax, $rsqlUserUf, $rtraffCurrent, $rtraffMax, $rtraffUf, $rdiskCurrent, $rdiskMax, $rdiskUf); }
function generate_reseller_user_props($reseller_id) { global $sql; // Init with empty variables $rdmn_current = 0; $rdmn_max = 0; $rdmn_uf = '_off_'; $rsub_current = 0; $rsub_max = 0; $rsub_uf = '_off_'; $rals_current = 0; $rals_max = 0; $rals_uf = '_off_'; $rmail_current = 0; $rmail_max = 0; $rmail_uf = '_off_'; $rftp_current = 0; $rftp_max = 0; $rftp_uf = '_off_'; $rsql_db_current = 0; $rsql_db_max = 0; $rsql_db_uf = '_off_'; $rsql_user_current = 0; $rsql_user_max = 0; $rsql_user_uf = '_off_'; $rtraff_current = 0; $rtraff_max = 0; $rtraff_uf = '_off_'; $rdisk_current = 0; $rdisk_max = 0; $rdisk_uf = '_off_'; $ResArray = array($rdmn_current, $rdmn_max, $rdmn_uf, $rsub_current, $rsub_max, $rsub_uf, $rals_current, $rals_max, $rals_uf, $rmail_current, $rmail_max, $rmail_uf, $rftp_current, $rftp_max, $rftp_uf, $rsql_db_current, $rsql_db_max, $rsql_db_uf, $rsql_user_current, $rsql_user_max, $rsql_user_uf, $rtraff_current, $rtraff_max, $rtraff_uf, $rdisk_current, $rdisk_max, $rdisk_uf); $query = <<<SQL_QUERY select admin_id from admin where created_by = ? SQL_QUERY; $res = exec_query($sql, $query, array($reseller_id)); if ($res->RowCount() == 0) { return array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); } // Process all users of this group while ($data = $res->FetchRow()) { $admin_id = $data['admin_id']; $query = <<<SQL_QUERY select domain_id from domain where domain_admin_id = ? SQL_QUERY; $dres = exec_query($sql, $query, array($admin_id)); $ddata = $dres->FetchRow(); $user_id = $ddata['domain_id']; list($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_user_props($user_id); list($tmpval1, $tmpval2, $tmpval3, $tmpval4, $tmpval5, $tmpval16, $traff_current, $disk_current, $tmpval7, $tmpval8) = generate_user_traffic($user_id); $rdmn_current += 1; if ($sub_max != -1) { if ($sub_max == 0) { $rsub_uf = '_on_'; } $rsub_current += $sub_current; $rsub_max += $sub_max; } if ($als_max != -1) { if ($als_max == 0) { $rals_uf = '_on_'; } $rals_current += $als_current; $rals_max += $als_max; } if ($mail_max == 0) { $rmail_uf = '_on_'; } $rmail_current += $mail_current; $rmail_max += $mail_max; if ($ftp_max == 0) { $rftp_uf = '_on_'; } $rftp_current += $ftp_current; $rftp_max += $ftp_max; if ($sql_db_max != -1) { if ($sql_db_max == 0) { $rsql_db_uf = '_on_'; } $rsql_db_current += $sql_db_current; $rsql_db_max += $sql_db_max; } if ($sql_user_max != -1) { if ($sql_user_max == 0) { $rsql_user_uf = '_on_'; } $rsql_user_current += $sql_user_current; $rsql_user_max += $sql_user_max; } if ($traff_max == 0) { $rtraff_uf = '_on_'; } $rtraff_current += $traff_current; $rtraff_max += $traff_max; //print $rtraff_current."<br>"; //- debug shit if ($disk_max == 0) { $rdisk_uf = '_on_'; } $rdisk_current += $disk_current; $rdisk_max += $disk_max; //print $rdisk_current."<br>"; //- debug shit } $ResArray = array($rdmn_current, $rdmn_max, $rdmn_uf, $rsub_current, $rsub_max, $rsub_uf, $rals_current, $rals_max, $rals_uf, $rmail_current, $rmail_max, $rmail_uf, $rftp_current, $rftp_max, $rftp_uf, $rsql_db_current, $rsql_db_max, $rsql_db_uf, $rsql_user_current, $rsql_user_max, $rsql_user_uf, $rtraff_current, $rtraff_max, $rtraff_uf, $rdisk_current, $rdisk_max, $rdisk_uf); return $ResArray; }