Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

95 linhas
2.7 KiB

  1. <?php
  2. /*
  3. Author:QiuSong
  4. Compeny:Spiders Travel
  5. */
  6. define( "QUNAR_AGENT_ID", 234 );
  7. define( "QUNAR_SECRET", 'b54310e21b4747cf8d4b29b394c34b3f' );
  8. define( "QUNAR_OTANAME", 'zhizhu' );
  9. define( "QUNAR_FTP_SERVER", "www.zhizhuchuxing.com" );
  10. define( "QUNAR_FTP_PORT", 11000 );
  11. define( "QUNAR_FTP_USER", "zzcx" );
  12. define( "QUNAR_FTP_PSD", "20160602" );
  13. define( "QUNAR_CHECK_STOCK_URL", "http://api.zhizhuchuxing.com/api1.0/qunar_check_stock.php?source=qunar" );
  14. define( "QUNAR_CHECK_ORDER_URL", "http://coachapi.dev.qunar.com/api/pub/getOrders.do" );
  15. //define( "QUNAR_CHECK_ORDER_URL", "http://train.beta.qunar.com/api/pub/getOrders.do" );
  16. //define( "QUNAR_CHECK_ORDER_URL", "http://coach.trade.qunar.com/api/pub/getOrders.do" );
  17. define( "QUNAR_COMPLETE_ORDER_URL", "http://coachapi.dev.qunar.com/api/pub/tellTicketInfo.do" );
  18. //define( "QUNAR_CHECK_ORDER_URL", "http://train.beta.qunar.com/api/pub/tellTicketInfo.do" );
  19. //define( "QUNAR_CHECK_ORDER_URL", "http://coach.trade.qunar.com/api/pub/tellTicketInfo.do" );
  20. function get_qunar_auth( $param_array ) {
  21. if( is_array($param_array) == false ) {
  22. return false;
  23. }
  24. ksort($param_array);
  25. $new_param_array =$param_array;
  26. $url_param = array();
  27. foreach( $new_param_array as $param_key => $param_value ) {
  28. $url_param[] = "{$param_key}={$param_value}";
  29. }
  30. $url_txt = implode( "&", $url_param);
  31. $url_txt .= QUNAR_SECRET;
  32. return md5($url_txt);
  33. }
  34. function send_post($url, $post_data) {
  35. $postdata = http_build_query($post_data);
  36. $options = array(
  37. 'http' => array(
  38. 'method' => 'POST',
  39. 'header' => 'Content-type:application/x-www-form-urlencoded',
  40. 'content' => $postdata,
  41. 'timeout' => 15 * 60 // 超时时间(单位:s)
  42. )
  43. );
  44. $context = stream_context_create($options);
  45. $result = file_get_contents($url, false, $context);
  46. return $result;
  47. }
  48. function descryption_by_shif( $org_string ) {
  49. $new_string = '';
  50. for($i=0;$i<strlen($org_string);$i++){
  51. $strtoint = ord($org_string[$i]);
  52. $newint = $strtoint - 10;
  53. $new_string .= chr($newint);
  54. }
  55. return $new_string;
  56. }
  57. //上传文件到指定的ftp
  58. function upload_file_to_ftp( $ftp_server, $ftp_port, $ftp_user, $ftp_password, $source_file, $destination_file ) {
  59. $conn_id = ftp_connect($ftp_server, $ftp_port);
  60. $login_result = ftp_login($conn_id, $ftp_user, $ftp_password);
  61. if ((!$conn_id) || (!$login_result)) {
  62. return false;
  63. }
  64. $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
  65. if (!$upload) {
  66. return false;
  67. }
  68. ftp_close($conn_id);
  69. return true;
  70. }
  71. //生成一个zip文件,并把制定的文件加到这个zip包中去
  72. function create_zip_file( $source_file, $zip_file ) {
  73. $zip = new ZipArchive();
  74. if ($zip->open($zip_file, ZIPARCHIVE::CREATE)!==TRUE) {
  75. return false;
  76. }
  77. $zip->addFile($source_file);
  78. $zip->close();
  79. return true;
  80. }