isMobile() ? 'mobile' : 'desktop'; $currentParsed = 'desktop'; $data = ['mobile' => [], 'desktop' => []]; try{ $url = null; while (($line = fgets($file)) !== false){ $line = mb_strtolower(trim($line)); if(strpos($line, 'mobile') === 0) { $currentParsed = 'mobile'; } elseif(strpos($line, 'desktop') === 0) { $currentParsed = 'desktop'; } else { $matches = array(); if(preg_match('/^(?P\d{1,2}):(?P\d{1,2}):(?Phttps?:\/\/.*)$/', $line, $matches)){ $time = 60*$matches['hour'] + $matches['min']; $data[$currentParsed][$time] = $matches['url']; } else if(empty($url) && preg_match('/^https?:\/\/.*$/', $line)){ $data[$currentParsed][0] = $line; } } } if($mode == 'mobile' && !empty($data['mobile']) ){ $data = $data['mobile']; } else { $data = $data['desktop']; } foreach ($data as $data_time => $data_url){ if($currentTime>=$data_time){ $url = $data_url; } } } catch (\Exception $e){ } fclose($file); if(preg_match('/^https?:\/\/.*$/', $url)){ header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); header($_SERVER['SERVER_PROTOCOL'] . ' 302 Found', true, 302); header("Location: ".$url); } else { header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404); }