コード例 #1
0
 /**
  * loads user data for template processing 
  * 
  * @return void
  */
 public function loadAllUserData()
 {
     $userdata = array();
     $alluserdata = zb_UserGetAllStargazerData();
     $tariffspeeds = zb_TariffGetAllSpeeds();
     $tariffprices = zb_TariffGetPricesAll();
     $multinetdata = zb_MultinetGetAllData();
     $allcontracts = zb_UserGetAllContracts();
     $allcontracts = array_flip($allcontracts);
     $contractDates = $this->getContractDatesAll();
     $allphonedata = zb_UserGetAllPhoneData();
     $allrealnames = zb_UserGetAllRealnames();
     $alladdress = zb_AddressGetFulladdresslist();
     $allemails = zb_UserGetAllEmails();
     $allnasdata = zb_NasGetAllData();
     $allcfdata = cf_FieldsGetAll();
     $allpdata = zb_UserPassportDataGetAll();
     $curdate = curdate();
     $lastDocId = $this->getDocumentLastId();
     $newDocId = $lastDocId + 1;
     if ($this->altcfg['OPENPAYZ_REALID']) {
         $allopcustomers = zb_TemplateGetAllOPCustomers();
     }
     if (!empty($alluserdata)) {
         foreach ($alluserdata as $io => $eachuser) {
             $userdata[$eachuser['login']]['LOGIN'] = $eachuser['login'];
             $userdata[$eachuser['login']]['PASSWORD'] = $eachuser['Password'];
             $userdata[$eachuser['login']]['USERHASH'] = crc16($eachuser['login']);
             $userdata[$eachuser['login']]['TARIFF'] = $eachuser['Tariff'];
             @($userdata[$eachuser['login']]['TARIFFPRICE'] = $tariffprices[$eachuser['Tariff']]);
             $userdata[$eachuser['login']]['CASH'] = $eachuser['Cash'];
             $userdata[$eachuser['login']]['CREDIT'] = $eachuser['Credit'];
             $userdata[$eachuser['login']]['DOWN'] = $eachuser['Down'];
             $userdata[$eachuser['login']]['PASSIVE'] = $eachuser['Passive'];
             $userdata[$eachuser['login']]['AO'] = $eachuser['AlwaysOnline'];
             @($userdata[$eachuser['login']]['CONTRACT'] = $allcontracts[$eachuser['login']]);
             @($userdata[$eachuser['login']]['CONTRACTDATE'] = $contractDates[$eachuser['login']]['contractdate']);
             @($userdata[$eachuser['login']]['REALNAME'] = $allrealnames[$eachuser['login']]);
             @($userdata[$eachuser['login']]['ADDRESS'] = $alladdress[$eachuser['login']]);
             @($userdata[$eachuser['login']]['EMAIL'] = $allemails[$eachuser['login']]);
             @($userdata[$eachuser['login']]['PHONE'] = $allphonedata[$eachuser['login']]['phone']);
             @($userdata[$eachuser['login']]['MOBILE'] = $allphonedata[$eachuser['login']]['mobile']);
             //openpayz payment ID
             if ($this->altcfg['OPENPAYZ_REALID']) {
                 @($userdata[$eachuser['login']]['PAYID'] = $allopcustomers[$eachuser['login']]);
             } else {
                 @($userdata[$eachuser['login']]['PAYID'] = ip2int($eachuser['IP']));
             }
             //traffic params
             $userdata[$eachuser['login']]['TRAFFIC'] = $eachuser['D0'] + $eachuser['U0'];
             $userdata[$eachuser['login']]['TRAFFICDOWN'] = $eachuser['D0'];
             $userdata[$eachuser['login']]['TRAFFICUP'] = $eachuser['U0'];
             //net params
             @($userdata[$eachuser['login']]['IP'] = $eachuser['IP']);
             @($userdata[$eachuser['login']]['MAC'] = $multinetdata[$eachuser['IP']]['mac']);
             @($userdata[$eachuser['login']]['NETID'] = $multinetdata[$eachuser['IP']]['netid']);
             @($userdata[$eachuser['login']]['HOSTID'] = $multinetdata[$eachuser['IP']]['id']);
             //nas data
             @($usernas = zb_NasGetParams($multinetdata[$eachuser['IP']]['netid'], $allnasdata));
             @($userdata[$eachuser['login']]['NASID'] = $usernas['id']);
             @($userdata[$eachuser['login']]['NASIP'] = $usernas['nasip']);
             @($userdata[$eachuser['login']]['NASNAME'] = $usernas['nasname']);
             @($userdata[$eachuser['login']]['NASTYPE'] = $usernas['nastype']);
             if (isset($tariffspeeds[$eachuser['Tariff']])) {
                 $userdata[$eachuser['login']]['SPEEDDOWN'] = $tariffspeeds[$eachuser['Tariff']]['speeddown'];
                 $userdata[$eachuser['login']]['SPEEDUP'] = $tariffspeeds[$eachuser['Tariff']]['speedup'];
             } else {
                 //if no tariff speed defined zero speed by default
                 $userdata[$eachuser['login']]['SPEEDDOWN'] = 0;
                 $userdata[$eachuser['login']]['SPEEDUP'] = 0;
             }
             //passport data
             @($userdata[$eachuser['login']]['PBIRTH'] = $allpdata[$eachuser['login']]['birthdate']);
             @($userdata[$eachuser['login']]['PNUM'] = $allpdata[$eachuser['login']]['passportnum']);
             @($userdata[$eachuser['login']]['PDATE'] = $allpdata[$eachuser['login']]['passportdate']);
             @($userdata[$eachuser['login']]['PWHO'] = $allpdata[$eachuser['login']]['passportwho']);
             @($userdata[$eachuser['login']]['PCITY'] = $allpdata[$eachuser['login']]['pcity']);
             @($userdata[$eachuser['login']]['PSTREET'] = $allpdata[$eachuser['login']]['pstreet']);
             @($userdata[$eachuser['login']]['PBUILD'] = $allpdata[$eachuser['login']]['pbuild']);
             @($userdata[$eachuser['login']]['PAPT'] = $allpdata[$eachuser['login']]['papt']);
             //other document data
             @($userdata[$eachuser['login']]['CURDATE'] = $curdate);
             @($userdata[$eachuser['login']]['DOCID'] = $newDocId);
         }
     }
     $this->userData = $userdata;
 }
コード例 #2
0
ファイル: api.userside.php プロジェクト: l1ght13aby/Ubilling
 /**
  * Returns existing users full info
  * 
  * @return array
  */
 protected function getUsersList()
 {
     $result = array();
     $allRealNames = zb_UserGetAllRealnames();
     $allContracts = zb_UserGetAllContracts();
     $allUserTags = $this->getAllUsersTags();
     $allUserNotes = zb_UserGetAllNotes();
     $allPaymentIds = $this->getAllUserPaymentIds();
     $allAddresBindings = $this->getAllAddressList();
     $allAptData = $this->getAllAptList();
     $allPhones = zb_UserGetAllPhoneData();
     $allEmails = zb_UserGetAllEmails();
     $allNethosts = $this->getNethostsData();
     $allNetworks = $this->getNetworksData();
     $allRegData = $this->getUserRegData();
     if (!empty($allContracts)) {
         $allContracts = array_flip($allContracts);
     }
     $allContractDates = zb_UserContractDatesGetAll();
     if (!empty($this->allUserData)) {
         foreach ($this->allUserData as $userLogin => $userData) {
             $result[$userLogin]['id'] = $userLogin;
             $result[$userLogin]['login'] = $userLogin;
             $result[$userLogin]['full_name'] = @$allRealNames[$userLogin];
             $result[$userLogin]['flag_corporate'] = 0;
             if ($userData['TariffChange']) {
                 $curMonth = date('n');
                 $curYear = date('Y');
                 $firstDayNextMonth = $curMonth == 12 ? mktime(0, 0, 0, 0, 0, $curYear + 1) : mktime(0, 0, 0, $curMonth + 1, 1);
                 $firstDayNextMonth = date("Y-m-d", $firstDayNextMonth);
             } else {
                 $firstDayNextMonth = '';
             }
             $result[$userLogin]['tariff']['current'][0]['id'] = $userData['Tariff'];
             if ($firstDayNextMonth) {
                 $result[$userLogin]['tariff']['current'][0]['date_finish'] = $firstDayNextMonth;
             }
             if ($userData['TariffChange']) {
                 $result[$userLogin]['tariff']['new'][0]['id'] = $userData['TariffChange'];
                 $result[$userLogin]['tariff']['new'][0]['date_start'] = $firstDayNextMonth;
             }
             $userContract = @$allContracts[$userLogin];
             if ($userContract) {
                 $result[$userLogin]['agreement'][0]['number'] = $userContract;
                 $contractDate = @$allContractDates[$userContract];
                 if ($contractDate) {
                     $result[$userLogin]['agreement'][0]['date'] = $contractDate;
                 }
             }
             $result[$userLogin]['account_number'] = @$allPaymentIds[$userLogin];
             // yep, this is something like Payment ID
             if (isset($allUserTags[$userLogin])) {
                 foreach ($allUserTags[$userLogin] as $tagIo => $eachTagid) {
                     $result[$userLogin]['group'][$tagIo] = $eachTagid;
                 }
             }
             $userNotes = @$allUserNotes[$userLogin];
             if ($userNotes) {
                 $result[$userLogin]['comment'] = $userNotes;
             }
             $result[$userLogin]['balance'] = $userData['Cash'];
             $result[$userLogin]['credit'] = $userData['Credit'];
             $userState = 5;
             // work
             if ($userData['Cash'] < '-' . $userData['Credit']) {
                 $userState = 1;
                 //nomoney
             }
             if ($userData['Passive'] == 1) {
                 $userState = 2;
                 // pause
             }
             if ($userData['Down'] == 1) {
                 $userState = 3;
                 // disable
             }
             if ($userData['Tariff'] == '*_NO_TARIFF_*') {
                 $userState = 4;
                 // new
             }
             $result[$userLogin]['state_id'] = $userState;
             if (isset($allRegData[$userLogin])) {
                 $result[$userLogin]['date_create'] = $allRegData[$userLogin];
                 $result[$userLogin]['date_connect'] = $allRegData[$userLogin];
             } else {
                 $result[$userLogin]['date_create'] = '';
                 $result[$userLogin]['date_connect'] = '';
             }
             $result[$userLogin]['date_activity'] = date("Y-m-d H:i:s", $userData['LastActivityTime']);
             $result[$userLogin]['traffic']['month']['up'] = $userData['U0'];
             $result[$userLogin]['traffic']['month']['down'] = $userData['D0'];
             $result[$userLogin]['discount'] = 0;
             // TODO: to many discount models at this time
             $userApartmentId = @$allAddresBindings[$userLogin];
             if ($userApartmentId) {
                 $aptData = $allAptData[$userApartmentId];
                 $result[$userLogin]['address'][0]['type'] = 'connect';
                 $result[$userLogin]['address'][0]['house_id'] = $aptData['buildid'];
                 $result[$userLogin]['address'][0]['apartment']['id'] = $userApartmentId;
                 $result[$userLogin]['address'][0]['apartment']['full_name'] = $aptData['apt'];
                 $result[$userLogin]['address'][0]['apartment']['number'] = vf($aptData['apt'], 3);
                 if ($aptData['entrance']) {
                     $result[$userLogin]['address'][0]['entrance'] = $aptData['entrance'];
                 }
                 if ($aptData['floor']) {
                     $result[$userLogin]['address'][0]['floor'] = $aptData['floor'];
                 }
             }
             $userPhoneData = @$allPhones[$userLogin];
             if (!empty($userPhoneData)) {
                 if (isset($userPhoneData['phone'])) {
                     $result[$userLogin]['phone'][0]['number'] = $userPhoneData['phone'];
                     $result[$userLogin]['phone'][0]['flag_main'] = 0;
                 }
                 if (isset($userPhoneData['mobile'])) {
                     $result[$userLogin]['phone'][1]['number'] = $userPhoneData['mobile'];
                     $result[$userLogin]['phone'][1]['flag_main'] = 1;
                 }
             }
             $userEmail = @$allEmails[$userLogin];
             if ($userEmail) {
                 $result[$userLogin]['email'][0]['address'] = $userEmail;
                 $result[$userLogin]['email'][0]['flag_main'] = 1;
             }
             $userIp = $userData['IP'];
             $userIp = ip2int($userIp);
             $result[$userLogin]['ip_mac'][0]['ip'] = $userIp;
             $nethostsData = @$allNethosts[$userData['IP']];
             if (!empty($nethostsData)) {
                 $subnetId = $nethostsData['netid'];
                 $userMac = $nethostsData['mac'];
                 $userMac = str_replace(':', '', $userMac);
                 $userMac = strtolower($userMac);
                 // mac lowercased withot delimiters
                 $result[$userLogin]['ip_mac'][0]['mac'] = $userMac;
                 $result[$userLogin]['ip_mac'][0]['ip_net'] = @$allNetworks[$subnetId]['desc'];
             }
             if (isset($this->allCfData[$userLogin])) {
                 $result[$userLogin]['additional_data'] = $this->allCfData[$userLogin];
             }
             //   die(print_r($result, true));
         }
     }
     return $result;
 }
コード例 #3
0
/**
 *  Returns all data about current userbase
 *  which used for templatizing functions
 * 
 *  @return  array
 */
function zb_TemplateGetAllUserData()
{
    $altcfg = rcms_parse_ini_file(CONFIG_PATH . "alter.ini");
    $userdata = array();
    $alluserdata = zb_UserGetAllStargazerData();
    $tariffspeeds = zb_TariffGetAllSpeeds();
    $tariffprices = zb_TariffGetPricesAll();
    $multinetdata = zb_MultinetGetAllData();
    $allcontracts = zb_UserGetAllContracts();
    $allcontracts = array_flip($allcontracts);
    $allrealnames = zb_UserGetAllRealnames();
    $alladdress = zb_AddressGetFulladdresslist();
    $allemails = zb_UserGetAllEmails();
    $allnasdata = zb_NasGetAllData();
    $allcfdata = cf_FieldsGetAll();
    $allpdata = zb_UserPassportDataGetAll();
    if ($altcfg['OPENPAYZ_REALID']) {
        $allopcustomers = zb_TemplateGetAllOPCustomers();
    }
    if (!empty($alluserdata)) {
        foreach ($alluserdata as $io => $eachuser) {
            $userdata[$eachuser['login']]['login'] = $eachuser['login'];
            $userdata[$eachuser['login']]['password'] = $eachuser['Password'];
            $userdata[$eachuser['login']]['userhash'] = crc16($eachuser['login']);
            $userdata[$eachuser['login']]['tariff'] = $eachuser['Tariff'];
            @($userdata[$eachuser['login']]['tariffprice'] = $tariffprices[$eachuser['Tariff']]);
            $userdata[$eachuser['login']]['cash'] = $eachuser['Cash'];
            $userdata[$eachuser['login']]['credit'] = $eachuser['Credit'];
            $userdata[$eachuser['login']]['down'] = $eachuser['Down'];
            $userdata[$eachuser['login']]['passive'] = $eachuser['Passive'];
            $userdata[$eachuser['login']]['ao'] = $eachuser['AlwaysOnline'];
            @($userdata[$eachuser['login']]['contract'] = $allcontracts[$eachuser['login']]);
            @($userdata[$eachuser['login']]['realname'] = $allrealnames[$eachuser['login']]);
            @($userdata[$eachuser['login']]['address'] = $alladdress[$eachuser['login']]);
            @($userdata[$eachuser['login']]['email'] = $allemails[$eachuser['login']]);
            //openpayz payment ID
            if ($altcfg['OPENPAYZ_REALID']) {
                @($userdata[$eachuser['login']]['payid'] = $allopcustomers[$eachuser['login']]);
            } else {
                @($userdata[$eachuser['login']]['payid'] = ip2int($eachuser['IP']));
            }
            //traffic params
            $userdata[$eachuser['login']]['traffic'] = $eachuser['D0'] + $eachuser['U0'];
            $userdata[$eachuser['login']]['trafficdown'] = $eachuser['D0'];
            $userdata[$eachuser['login']]['trafficup'] = $eachuser['U0'];
            //net params
            $userdata[$eachuser['login']]['ip'] = $eachuser['IP'];
            @($userdata[$eachuser['login']]['mac'] = $multinetdata[$eachuser['IP']]['mac']);
            @($userdata[$eachuser['login']]['netid'] = $multinetdata[$eachuser['IP']]['netid']);
            @($userdata[$eachuser['login']]['hostid'] = $multinetdata[$eachuser['IP']]['id']);
            //nas data
            @($usernas = zb_NasGetParams($multinetdata[$eachuser['IP']]['netid'], $allnasdata));
            @($userdata[$eachuser['login']]['nasid'] = $usernas['id']);
            @($userdata[$eachuser['login']]['nasip'] = $usernas['nasip']);
            @($userdata[$eachuser['login']]['nasname'] = $usernas['nasname']);
            @($userdata[$eachuser['login']]['nastype'] = $usernas['nastype']);
            if (isset($tariffspeeds[$eachuser['Tariff']])) {
                $userdata[$eachuser['login']]['speeddown'] = $tariffspeeds[$eachuser['Tariff']]['speeddown'];
                $userdata[$eachuser['login']]['speedup'] = $tariffspeeds[$eachuser['Tariff']]['speedup'];
            } else {
                //if no tariff speed defined zero speed by default
                $userdata[$eachuser['login']]['speeddown'] = 0;
                $userdata[$eachuser['login']]['speedup'] = 0;
            }
            //CF data
            $usercfdata = zb_cfGetContent($eachuser['login'], $allcfdata);
            if (!empty($usercfdata)) {
                foreach ($usercfdata as $cd => $eachcf) {
                    $userdata[$eachuser['login']]['cf'][$cd] = $eachcf;
                }
            }
            //passport data
            @($userdata[$eachuser['login']]['birthdate'] = $allpdata[$eachuser['login']]['birthdate']);
            @($userdata[$eachuser['login']]['passportnum'] = $allpdata[$eachuser['login']]['passportnum']);
            @($userdata[$eachuser['login']]['passportdate'] = $allpdata[$eachuser['login']]['passportdate']);
            @($userdata[$eachuser['login']]['passportwho'] = $allpdata[$eachuser['login']]['passportwho']);
            @($userdata[$eachuser['login']]['pcity'] = $allpdata[$eachuser['login']]['pcity']);
            @($userdata[$eachuser['login']]['pstreet'] = $allpdata[$eachuser['login']]['pstreet']);
            @($userdata[$eachuser['login']]['pbuild'] = $allpdata[$eachuser['login']]['pbuild']);
            @($userdata[$eachuser['login']]['papt'] = $allpdata[$eachuser['login']]['papt']);
        }
    }
    return $userdata;
}