function inpost_get_machine_list($town = '', $paymentavailable = '') { global $inpost_data_dir; if (inpost_cache_is_valid(1) == 0) { inpost_download_machines(); } if ($cache = @file_get_contents("{$inpost_data_dir}/cache1.dat")) { $machineList = unserialize($cache); if (count($machineList)) { if ($town) { foreach ($machineList as $machine) { if ($machine[4] == $town) { $resultList[] = $machine; } } $machineList = $resultList; } if (count($machineList)) { $resultList = array(); $i = 0; foreach ($machineList as $machine) { if (isset($machine[0]) && isset($machine[1]) && isset($machine[2]) && isset($machine[3]) && isset($machine[4])) { if (!$paymentavailable || $paymentavailable == 't' && $machine[7] == 't' || $paymentavailable == 'f' && $machine[7] == 'f') { $resultList[$i]['name'] = $machine[0]; $resultList[$i]['street'] = $machine[1]; $resultList[$i]['buildingnumber'] = $machine[2]; $resultList[$i]['postcode'] = $machine[3]; $resultList[$i]['town'] = $machine[4]; $resultList[$i]['latitude'] = $machine[5]; $resultList[$i]['longitude'] = $machine[6]; if ($machine[7] == 't') { $resultList[$i]['paymentavailable'] = 1; } else { $resultList[$i]['paymentavailable'] = 0; } $resultList[$i]['operatinghours'] = $machine[8]; $resultList[$i]['locationdescription'] = $machine[9]; $resultList[$i]['paymentpointdescr'] = $machine[10]; $resultList[$i]['partnerid'] = $machine[11]; $resultList[$i]['paymenttype'] = $machine[12]; $i++; } } } usort($resultList, 'inpost_machine_sort'); return $resultList; } } } return 0; }
protected function ajax_resetCacheAction() { $dir = PACZKOMATY_PATH . 'inpost/data/'; inpost_download_machines(); inpost_download_pricelist(); $this->simpleJson(true, "Lista paczkomatów oraz cennik zostały zaktualizowane"); }