public static function main() { self::init(); self::query(self::$query_date, self::$from_station_code, self::$to_station_code); }
if (is_numeric($item['gg_num']) && $item['gg_num'] > 0 || is_numeric($item['gr_num']) && $item['gr_num'] > 0 || is_numeric($item['qt_num']) && $item['qt_num'] > 0 || is_numeric($item['rw_num']) && $item['rw_num'] > 0 || is_numeric($item['rz_num']) && $item['rz_num'] > 0 || is_numeric($item['tz_num']) && $item['tz_num'] > 0 || is_numeric($item['wz_num']) && $item['wz_num'] > 0 || is_numeric($item['yb_num']) && $item['yb_num'] > 0 || is_numeric($item['yw_num']) && $item['yw_num'] > 0 || is_numeric($item['yz_num']) && $item['yz_num'] > 0 || is_numeric($item['ze_num']) && $item['ze_num'] > 0 || is_numeric($item['zy_num']) && $item['zy_num'] > 0 || is_numeric($item['swz_num']) && $item['swz_num'] > 0) { $hit = true; self::show($msg); } else { continue; } } if ($hit) { self::waring($msg); } self::$query_num++; $msg = sprintf("\t%s\t%s(%s) => %s(%s)\t\tquery time: %s", self::$query_date, self::$from_station_name, self::$from_station_code, self::$to_station_name, self::$to_station_code, self::$query_num); self::show($msg); } public static function waring($msg) { $os = strtolower(PHP_OS); if ($os == "darwin") { exec('osascript -e \'display notification "' . $msg . '" sound name "Glass.aiff" with title "有票啦"\''); } elseif ($os == "linux") { exec("gnome-terminal -x bash -c \"date;echo 有票啦 {$msg}; read;\""); } exit; } public static function show($msg) { echo "{$msg}\n"; } } train::main();