Guest User

Untitled

a guest
Feb 11th, 2019
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.05 KB | None | 0 0
  1. $config['gpsies_password'] = "password";
  2. $config['gpsies_login'] = "login";
  3.  
  4. $ckfile = tempnam ("/tmp", "CURLCOOKIE");
  5. $curl=curl_init("http://www.gpsies.com/login.do?username=". $config['gpsies_login'] ."&password=". $config['gpsies_password']);
  6. curl_setopt ($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
  7. curl_setopt ($curl, CURLOPT_HEADER,1);
  8. curl_setopt ($curl, CURLOPT_NOBODY,1);
  9. curl_setopt ($curl, CURLINFO_HEADER_OUT, 1);
  10. curl_setopt ($curl, CURLOPT_COOKIEJAR, $ckfile);
  11. curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
  12. $result = curl_exec_follow($curl);
  13.  
  14. if($result) {
  15. //trigger_error ("Auth OKrn<hr>");
  16. } else {
  17. trigger_error ("Auth Errorrn<hr>");
  18. }
  19. curl_close($curl);
  20.  
  21. $link = 'https://mysite.ru/;
  22. $name = "File_Name";
  23.  
  24. $fields = array(
  25. "language" => 'ru',
  26. "trackAsString" => '',
  27. "maxTrackpoints" => 3000,
  28. // "filename" => sanitize_title_with_translit($name),
  29. "filename" => $name,
  30. "status" => 1,
  31. "fileDescription" => 'Track for: https://mysite.ru/',
  32. "trackTypes" => 'biking',
  33. "websiteUrl" => 'https://mysite.ru/',
  34. //"trackClassifications" => '',
  35. //"trackCharacters" => '',
  36. "trackAttributes" => 'gpsRecorded',
  37. //"trackRoadbeds" => '',
  38. //"trackRoads" => '',
  39. "startpointCountry" => 'RU',
  40. "endpointCountry" => 'RU',
  41. //"viceVersa" => '',
  42. "trackSimplification" => 0,
  43. //"addElevation" => '',
  44. "formFileUrl" => $link,
  45. "uploadButton" => 'save',
  46. );
  47.  
  48. foreach ($fields as $key => $value)
  49. {
  50. $value = urlencode(stripslashes($value));
  51.  
  52. if ($key == 'formFileUrl' && ($value == 'http%3A%2F%2F' || $value == ''))
  53. {
  54. return ;
  55. }
  56. $aQueryStrs[] .= "$key=$value";
  57. }
  58. $query_string = implode('&',$aQueryStrs);
  59.  
  60. $fields_str = http_build_query($fields);
  61.  
  62. if ($curl=curl_init("http://www.gpsies.com/upload.do;l=ru?". $query_string)) {
  63. //curl_setopt ($curl, CURLOPT_URL, "http://www.gpsies.com/upload.do");
  64. curl_setopt ($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
  65. curl_setopt ($curl, CURLOPT_HEADER,1);
  66. curl_setopt ($curl, CURLOPT_NOBODY,0);
  67. curl_setopt ($curl, CURLINFO_HEADER_OUT, 1);
  68. curl_setopt ($curl, CURLOPT_COOKIEFILE, $ckfile);
  69. curl_setopt ($curl, CURLOPT_COOKIEJAR, $ckfile);
  70. curl_setopt ($curl, CURLOPT_RETURNTRANSFER, true);
  71. curl_setopt ($curl, CURLOPT_REFERER, "http://www.gpsies.com/login.do");
  72.  
  73. } else {
  74. trigger_error ("No init CURL");
  75. }
  76.  
  77. if (ini_get('open_basedir') == '' && ini_get('safe_mode' == 'Off'))
  78. {
  79. curl_setopt ($curl, CURLOPT_FOLLOWLOCATION, $l);
  80. $result = curl_exec($curl);
  81. }
  82. else
  83. {
  84. $result = curl_exec_follow($curl);
  85. }
  86.  
  87. if(curl_errno($curl))
  88. {
  89. trigger_error ("Error Occured in Curln<br />Error number: " .curl_errno($curl) ."n == ".curl_error($curl)."n<br>");
  90. }
  91. if($result) {
  92.  
  93. // Info
  94. $header_info = curl_getinfo($curl,CURLINFO_HEADER_OUT);
  95. $header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
  96. $header = substr($result, 0, $header_size);
  97. $body = substr($result, $header_size);
  98. //End Info
  99.  
  100. // DEBUGER +
  101. //$out .= "POST<hr><p>Header Sent: " . $header_info ."</p><hr>
  102. // <p>Header Received: " . $header . "</p><hr>
  103. // <p>Body: ". $body . "</p><hr>";
  104. // END DEBUGER +
  105. } else {
  106. trigger_error ("<hr>FILE ERRORrn<hr>");
  107. }
  108.  
  109. $curl=curl_init("http://www.gpsies.com/login.do?logout=true");
  110. curl_setopt ($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
  111. curl_setopt ($curl, CURLOPT_HEADER,1);
  112. curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
  113. curl_setopt ($curl, CURLOPT_NOBODY,1);
  114. if(curl_exec($curl)) {
  115. //trigger_error ( "EXIT OKrn<hr>");
  116. } else {
  117. trigger_error ("EXIT Errorrn<hr>");
  118. }
  119.  
  120. curl_close($curl);
  121. unlink($ckfile) or die("Can't unlink $ckfile");
Add Comment
Please, Sign In to add comment