Jump to content

SUBIECTE NOI
« 1 / 5 »
RSS
Tehnologia DSL la Orange?

conectare navigație auto la ...

Care e pretul corect pe mp?!

Auto 200-250km/zi autostrada, fia...
 Idei noi? Ce verificam la o masin...

Încarcare acumulatori LiPo de 1,5v...

cel mai ieftin generator trifazic

Iti place sa mananci iute?
 cum il cheama pe acest SSD?

Trec ITP-ul daca am montat alt mo...

Problema mesaj supraincalzire tel...

Recuperare Cont Yahoo mail
 Legislatie ambiguua/incompatibili...

Radio Argon 1 se aude foarte incet

Nu gasesc optiunea de a afisa(nu ...

Glafuri interioare mozaic
 

Mersul Trenurilor

* - - - - 1 votes
  • Please log in to reply
7 replies to this topic

#1
phpguru

phpguru

    Junior Member

  • Grup: Members
  • Posts: 97
  • Înscris: 12.07.2012
Salutare,

De ceva timp, SNCFR S.A. a modificat/actualizat platforma online pt. mersul trenurilor http://mersultrenuri....ro/Itineraries
Nu stiu ce imi scapa sau ce imi lipseste din scriptul meu pt. ca imi returneaza eroare 404 (doar rezultatul)

<?php
error_reporting( E_ALL ) ;
function string( $string, $start, $end )
{
  $sub = substr( $string, strpos( $string, $start ) + strlen( $start ), strlen( $string ) ) ;
  return substr( $sub, 0, strpos( $sub, $end ) ) ;
}
$curl = file_get_contents( "https://mersultrenurilor.infofer.ro/Itineraries" ) ;
$DepartureStationName = "Craiova" ;
$ArrivalStationName = "Oradea" ;
$DepartureDate = "27.06.2018" ;
$ConnectionsTypeId = "0" ;
$OrderingTypeId = "0" ;
$__RequestVerificationToken = string ( $curl, '__RequestVerificationToken" type="hidden" value="', '"' ) ;
function cfri( $DepartureStationName, $ArrivalStationName, $DepartureDate, $ConnectionsTypeId, $OrderingTypeId, $__RequestVerificationToken )
{
  $ch = @curl_init() ;
  $header[] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" ;
  $header[] = "Cache-Control: max-age=0" ;
  $header[] = "Connection: keep-alive" ;
  $header[] = "Accept-Language: ro-RO,ro;q=0.8,en-US;q=0.6,en-GB;q=0.4,en;q=0.2" ;
  $header[] = "Pragma: no-cache" ;
  $header[] = "Content-Type: application/x-www-form-urlencoded" ;
  $header[] = "Upgrade-Insecure-Requests: 1" ;
  @curl_setopt( $ch, CURLOPT_URL, "https://mersultrenurilor.infofer.ro/Itineraries" ) ;
  @curl_setopt( $ch, CURLOPT_HEADER, false ) ;
  @curl_setopt( $ch, CURLOPT_HTTPHEADER, $header ) ;
  @curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)" ) ;
  @curl_setopt( $ch, CURLOPT_ENCODING, "gzip,deflate" ) ;
  @curl_setopt( $ch, CURLOPT_REFERER, "https://www.google.com" ) ;
  @curl_setopt( $ch, CURLOPT_AUTOREFERER, true ) ;
  @curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ) ;
  @curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true ) ;
  @curl_setopt( $ch, CURLOPT_NOBODY, true ) ;
  @curl_setopt( $ch, CURLOPT_VERBOSE, true ) ;
  @curl_setopt( $ch, CURLOPT_HTTPGET, true ) ;
  @curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 5 ) ;
  @curl_setopt( $ch, CURLOPT_TIMEOUT, 10 ) ;
  @curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "POST" ) ;
  @curl_setopt( $ch, CURLOPT_POSTFIELDS, "POSTDATA=DepartureStationName=" . $DepartureStationName . "&ArrivalStationName=" .
   $ArrivalStationName . "&DepartureDate=" . $DepartureDate .
   "&TimeSelectionId=0&MinutesInDay=0&ChangeStationName=&DepartureTrainRunningNumber=&ArrivalTrainRunningNumber=&ConnectionsTypeId=" .
   $ConnectionsTypeId . "&OrderingTypeId=" . $OrderingTypeId . "&__RequestVerificationToken=" . $__RequestVerificationToken ) ;
  $result = @curl_exec( $ch ) ;
  @curl_close( $ch ) ;
  return $result ;
}
$cfri = cfri( $DepartureStationName, $ArrivalStationName, $DepartureDate, $ConnectionsTypeId, $OrderingTypeId, $__RequestVerificationToken ) ;
echo $cfri ;
?>



#2
pupama

pupama

    Senior Member

  • Grup: Senior Members
  • Posts: 2,524
  • Înscris: 15.05.2010
adica tu repostezi site-ul cfr?

#3
phpguru

phpguru

    Junior Member

  • Grup: Members
  • Posts: 97
  • Înscris: 12.07.2012

View Postpupama, on 27 iunie 2018 - 20:00, said:

adica tu repostezi site-ul cfr?
Adica da. Scutesc incarcarea inceata a rezultatului pt. cei care folosesc mobile si optimizez rezultatul.

#4
sceptic_schizo

sceptic_schizo

    Member

  • Grup: Members
  • Posts: 638
  • Înscris: 23.02.2009
@curl_setopt( $ch, CURLOPT_NOBODY, true ) ; ???

@curl_setopt( $ch, CURLOPT_HTTPGET, true ) ; ???</br> @curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "POST" ) ;   ???

Edited by sceptic_schizo, 27 June 2018 - 20:27.


#5
Onan_Barbaru

Onan_Barbaru

    Active Member

  • Grup: Banned
  • Posts: 1,169
  • Înscris: 21.08.2017

View Postphpguru, on 27 iunie 2018 - 20:02, said:

Scutesc incarcarea inceata
Si de unde stii tu ca e inceata?

#6
sceptic_schizo

sceptic_schizo

    Member

  • Grup: Members
  • Posts: 638
  • Înscris: 23.02.2009
Uita-te la cookie-uir, gen .AspNetCore.Antiforgery.1dDny83OZBY

#7
phpguru

phpguru

    Junior Member

  • Grup: Members
  • Posts: 97
  • Înscris: 12.07.2012

View Postsceptic_schizo, on 27 iunie 2018 - 20:26, said:

@curl_setopt( $ch, CURLOPT_NOBODY, true ) ; ???

@curl_setopt( $ch, CURLOPT_HTTPGET, true ) ; ???</br> @curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "POST" ) ;   ???
M-am documentat pe google/forumuri si anumite functii din cod gen NOBODY/VERBOSE/HTTPGET, spun ca ar rezolva eroarea 404, dar nu s-a intamplat. Preluarea este POST.

#8
alx42

alx42

    Senior Member

  • Grup: Senior Members
  • Posts: 2,802
  • Înscris: 26.06.2014
functie cu nume "string" ?  Posted Image

trebuie sa faci prima data un GET ca sa obtii acel AntiForgery cookie.
apoi trimiti valoarea lui in POST

Anunturi

Bun venit pe Forumul Softpedia!

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Forumul Softpedia foloseste "cookies" pentru a imbunatati experienta utilizatorilor Accept
Pentru detalii si optiuni legate de cookies si datele personale, consultati Politica de utilizare cookies si Politica de confidentialitate