/** * Preloads raw data for searchable user fields and controls caching * * @return void */ protected function loadRawdata($forceCache = false) { $cacheTime = $this->alterConf['GLOBALSEARCH_CACHE']; $cacheTime = time() - $cacheTime * 60; //in minutes //extracting user fields types to load if (!empty($this->alterConf['GLOBALSEARCH_FIELDS'])) { $this->fields = explode(',', $this->alterConf['GLOBALSEARCH_FIELDS']); $this->fields = array_flip($this->fields); } $updateCache = false; if (file_exists(self::CACHE_NAME)) { $updateCache = false; if (filemtime(self::CACHE_NAME) > $cacheTime) { $updateCache = false; } else { $updateCache = true; } } else { $updateCache = true; } //force cache parameter if ($forceCache) { $updateCache = true; } //updating rawdata cache if ($updateCache) { //loading needed fields if (isset($this->fields['realname'])) { $this->rawData = $this->rawData + $this->transformArray(zb_UserGetAllRealnames(), __('Real Name'), 'realname'); } if (isset($this->fields['address'])) { $this->rawData = $this->rawData + $this->transformArray(zb_AddressGetFulladdresslist(), __('Full address'), 'address'); } if (isset($this->fields['contract'])) { $allContracts = zb_UserGetAllContracts(); $allContracts = array_flip($allContracts); $this->rawData = $this->rawData + $this->transformArray($allContracts, __('Contract'), 'contract'); } if (isset($this->fields['phone']) or isset($this->fields['mobile'])) { $allPhonedata = zb_UserGetAllPhoneData(); if (isset($this->fields['phone'])) { if (!empty($allPhonedata)) { $allPhones = array(); foreach ($allPhonedata as $io => $each) { $allPhones[$io] = $each['phone']; } $this->rawData = $this->rawData + $this->transformArray($allPhones, __('Phone'), 'phone'); } } if (isset($this->fields['mobile'])) { if (!empty($allPhonedata)) { $allMobiles = array(); foreach ($allPhonedata as $io => $each) { $allMobiles[$io] = $each['mobile']; } $this->rawData = $this->rawData + $this->transformArray($allMobiles, __('Mobile'), 'mobile'); } } } if (isset($this->fields['ip'])) { $this->rawData = $this->rawData + $this->transformArray(zb_UserGetAllIPs(), __('IP'), 'ip'); } if (isset($this->fields['mac'])) { $this->rawData = $this->rawData + $this->transformArray(zb_UserGetAllIpMACs(), __('MAC address'), 'mac'); } if (isset($this->fields['login'])) { $allLogins = zb_UserGetAllStargazerLogins(); $this->rawData = $this->rawData + $this->transformArray($allLogins, __('Login'), 'login'); } if (isset($this->fields['seal'])) { $conDet = new ConnectionDetails(); $allSeals = $conDet->getAllSeals(); $this->rawData = $this->rawData + $this->transformArray($allSeals, __('Cable seal'), 'seal'); } if (isset($this->fields['paymentid'])) { if ($this->alterConf['OPENPAYZ_REALID']) { $allPayIds_q = "SELECT * from `op_customers`"; $allPayIds = simple_queryall($allPayIds_q); $tmpArrPayids = array(); if (!empty($allPayIds)) { foreach ($allPayIds as $io => $each) { $tmpArrPayids[$each['realid']] = $each['virtualid']; } } $this->rawData = $this->rawData + $this->transformArray($tmpArrPayids, __('Payment ID'), 'payid'); } else { $allPayIds_q = "SELECT `login`,`IP` from `users`"; $allPayIds = simple_queryall($allPayIds_q); $tmpArrPayids = array(); if (!empty($allPayIds)) { foreach ($allPayIds as $io => $each) { $tmpArrPayids[$each['login']] = ip2int($each['IP']); } } $this->rawData = $this->rawData + $this->transformArray($tmpArrPayids, __('Payment ID'), 'payid'); } } file_put_contents(self::CACHE_NAME, serialize($this->rawData)); } else { $this->rawData = file_get_contents(self::CACHE_NAME); $this->rawData = unserialize($this->rawData); } }
/** * Returns all of used by users MAC bindings from database as array login=>mac * * @return array */ function zb_UserGetAllMACs() { $alluserips = zb_UserGetAllIPs(); $alluserips = array_flip($alluserips); $allmac = zb_UserGetAllIpMACs(); $result = array(); //filling mac array if (!empty($allmac)) { foreach ($allmac as $eachip => $eachmac) { if (isset($alluserips[$eachip])) { $result[$alluserips[$eachip]] = $eachmac; } } } return $result; }
//updating build users state cache if ($alterconf['SWYMAP_ENABLED']) { $updateBuilCache = um_MapDrawBuilds(); print 'OK:USERBUILDCACHE'; } die('OK:FULLHOSTSCAN'); } /* * users data cache rebuild for external scripts */ if ($_GET['action'] == 'rebuilduserdatacache') { $cacheAddressArr = zb_AddressGetFulladdresslist(); $cacheAddressArr = serialize($cacheAddressArr); $cacheIpsArr = zb_UserGetAllIPs(); $cacheIpsArr = serialize($cacheIpsArr); $cacheMacArr = zb_UserGetAllIpMACs(); $cacheMacArr = serialize($cacheMacArr); file_put_contents('exports/cache_address', $cacheAddressArr); file_put_contents('exports/cache_ips', $cacheIpsArr); file_put_contents('exports/cache_mac', $cacheMacArr); die('OK:REBUILDUSERDATACACHE'); } /* * auto freezing call */ if ($_GET['action'] == 'autofreeze') { if (isset($alterconf['AUTOFREEZE_CASH_LIMIT'])) { $afCashLimit = $alterconf['AUTOFREEZE_CASH_LIMIT']; $autoFreezeQuery = "SELECT * from `users` WHERE `Passive`='0' AND `Cash`<='" . $afCashLimit . "' AND `Credit`='0';"; $allUsersToFreeze = simple_queryall($autoFreezeQuery); $freezeCount = 0;