VM暫存
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

call_something_daily.php 1.5KB

7 лет назад
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /*
  3. file: call_something_daily.php 每日呼叫匯整
  4. */
  5. require_once '/home/bigbang/apps/coworker/station.config.php';
  6. define('APP_NAME', 'call_something_daily'); // application name
  7. // 發生錯誤時集中在此處理
  8. function error_handler($errno, $errstr, $errfile, $errline, $errcontext)
  9. {
  10. //$str = date('H:i:s')."|{$errstr}|{$errfile}|{$errline}|{$errno}\n";
  11. $str = date('H:i:s')."|{$errstr}\n";
  12. echo $str;
  13. error_log($str, 3, LOG_PATH.APP_NAME . '.' . date('Ymd').'.log.txt'); // 3代表參考後面的檔名
  14. }
  15. set_error_handler('error_handler', E_ALL);
  16. trigger_error('..start..');
  17. // 呼叫
  18. function post_data($url, $data)
  19. {
  20. try
  21. {
  22. $ch = curl_init();
  23. curl_setopt($ch, CURLOPT_URL, $url);
  24. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
  25. curl_setopt($ch, CURLOPT_HEADER, FALSE);
  26. curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  27. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  28. curl_setopt($ch, CURLOPT_POST, FALSE);
  29. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,10);
  30. curl_setopt($ch, CURLOPT_TIMEOUT, 10); //timeout in seconds
  31. $output = curl_exec($ch);
  32. curl_close($ch);
  33. trigger_error(__FUNCTION__ . "|{$url}|{$output}|" . json_encode($data));
  34. }
  35. catch(Exception $e)
  36. {
  37. trigger_error('ERROR: ' . $e->getMessage());
  38. }
  39. sleep(1); // sleep for 3 seconds
  40. }
  41. // 需要排程呼叫的加在這
  42. post_data('http://localhost/carpark.html/station_setting_query/', array('reload' => 1)); // 重新取得場站資訊
  43. trigger_error('..completed..');