fg - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of fg.php

  1. <?php
  2.  
  3.  
  4. $Cookie = "";
  5.  
  6.  
  7.   $ch = curl_init();
  8.  
  9.  
  10.   curl_setopt($ch, CURLOPT_URL, 'https://arackiralama.egm.gov.tr/frm_arac_iade.aspx?plaka='.strtoupper($_GET["Plate"]).'&id=17d8d0b1-3239-489a-a967-d33a9073d790&tur=1');
  11.  
  12.  
  13.   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  14.  
  15.  
  16.   curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
  17.  
  18.  
  19.   curl_setopt($ch, CURLOPT_HTTPHEADER, [
  20.       'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
  21.       'Accept-Language: en-US,en;q=0.9,tr;q=0.8',
  22.       'Cache-Control: max-age=0',
  23.       'Connection: keep-alive',
  24.       'Sec-Fetch-Dest: document',
  25.       'Sec-Fetch-Mode: navigate',
  26.       'Sec-Fetch-Site: none',
  27.       'Sec-Fetch-User: ?1',
  28.       'Upgrade-Insecure-Requests: 1',
  29.       'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36',
  30.       'sec-ch-ua: "Chromium";v="110", "Not A(Brand";v="24", "Google Chrome";v="110"',
  31.       'sec-ch-ua-mobile: ?0',
  32.       'sec-ch-ua-platform: "Linux"',
  33.       'Accept-Encoding: gzip',
  34.   ]);
  35.  
  36.  
  37.   curl_setopt($ch, CURLOPT_COOKIE, $Cookie);
  38.  
  39.  
  40.   $response = curl_exec($ch);
  41.  
  42.  
  43.   curl_close($ch);
  44.  
  45.  
  46.   $dom = new DOMDocument();
  47.  
  48.  
  49.   @$dom->loadHTML($response);
  50.  
  51.  
  52.   $xpath = new DOMXPath($dom);
  53.  
  54.  
  55.   if($xpath->query('//*[@id="lbl_aracmarka"]/text()')->item(0)->nodeValue == null)
  56.  
  57.  
  58.   {
  59.  
  60.  
  61.       $result = array(
  62.  
  63.  
  64.           "Status" => "false",
  65.  
  66.  
  67.           "Message" => "Işlem başarısız, belirtilen plaka numarasına ait araç bilgisi bulunamadı!"
  68.  
  69.  
  70.       );
  71.  
  72.  
  73.  
  74.  
  75.  
  76.       echo json_encode($result, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
  77.  
  78.  
  79.       return;
  80.  
  81.  
  82.   }
  83.  
  84.  
  85.   $result = array(
  86.  
  87.  
  88.       "Arac" => array(
  89.  
  90.  
  91.           "Marka" => $xpath->query('//*[@id="lbl_aracmarka"]/text()')->item(0)->nodeValue,
  92.  
  93.  
  94.           "Model" => $xpath->query('//*[@id="lbl_aracmodeli"]/text()')->item(0)->nodeValue,
  95.  
  96.  
  97.           "ModelYili" => $xpath->query('//*[@id="lbl_aracmodelyili"]/text()')->item(0)->nodeValue,
  98.  
  99.  
  100.           "Renk" => $xpath->query('//*[@id="lbl_aracrenk"]/text()')->item(0)->nodeValue,
  101.  
  102.  
  103.           "YakitTuru" => $xpath->query('//*[@id="lbl_aracyakit"]/text()')->item(0)->nodeValue,
  104.  
  105.  
  106.       ),
  107.  
  108.  
  109.       "Response" => array(
  110.  
  111.  
  112.           "Instance" => "true",
  113.  
  114.  
  115.           "Message" => "Istenilen araç plakasına ait aracın bilgileri getirilmiştir!",
  116.  
  117.  
  118.           "Limit" => "x"
  119.  
  120.  
  121.       )
  122.  
  123.  
  124.   );
  125.  
  126.  
  127.   echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);                    
  128.  
  129.  
  130.   ?>
File Description
  • fg
  • PHP Code
  • 14 Mar-2024
  • 2.45 Kb
You can Share it: