Server IP : 198.54.125.146 / Your IP : 18.119.117.236 [ Web Server : LiteSpeed System : Linux business38.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64 User : engixevu ( 716) PHP Version : 8.1.31 Disable Function : NONE Domains : 1 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/engixevu/ilivetracker.com/ |
Upload File : |
<?php // Example usage require_once './config.php'; if (isset($_GET['search']) && isset($_GET['type'])) { $url = $apiEndpoint; $searchFilter = $_GET['search']; $searchFilter = ltrim($searchFilter, '0'); $searchFilter = ltrim($searchFilter, '+92'); $data = array( 'search' => $searchFilter, 'type' => $_GET['type'], ); // Encode data as JSON $jsonData = json_encode($data); // Initialize cURL $ch = curl_init($url); // Set cURL options curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Authorization: Bearer YOUR_TOKEN_HERE', // Replace with your actual token )); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData); // Execute the request $response = curl_exec($ch); // Check for errors if (curl_errno($ch)) { echo 'Error fetching data: ' . curl_error($ch); } else { $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($httpCode == 200) { if (isset($data['type'])) { if ($data['type'] === 'mobile') { mobile($response); exit(); } elseif ($data['type'] === 'vehicle') { vehicle($response); exit(); } elseif ($data['type'] === 'ptcl') { ptcl($response); exit(); } } echo $response; } else { echo 'Error fetching data: HTTP ' . $httpCode; } } // Close cURL session curl_close($ch); } // if (isset($_GET['search']) && isset($_GET['type'])) { // // $url = 'http://localhost/ApiProject/example.php'; // $url = 'https://yorkais.xyz/example.php'; // $searchFilter = $_GET['search']; // $searchFilter = ltrim($searchFilter, '0'); // $searchFilter = ltrim($searchFilter, '+92'); // $data = array( // 'search' => $searchFilter, // 'type' => $_GET['type'], // ); // $queryString = http_build_query($data); // $requestUrl = $url . '?' . $queryString; // // Initialize cURL session // $curl = curl_init($requestUrl); // // Set cURL options // curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2); // // curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // // Execute cURL session and get the response // $response = curl_exec($curl); // // Check for cURL errors // if (curl_errno($curl)) { // echo 'Error fetching data: ' . curl_error($curl); // } else { // // Output the response // echo $response; // // Process the response based on type // if (isset($data['type'])) { // if ($data['type'] === 'mobile') { // mobile($response); // } elseif ($data['type'] === 'vehicle') { // vehicle($response); // } elseif ($data['type'] === 'ptcl') { // ptcl($response); // } // } // } // // Close cURL session // curl_close($curl); // } // API function function sendPostRequest($url, $data, $token) { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => $data, CURLOPT_HTTPHEADER => array( 'Token: ' . $token, ), )); $response = curl_exec($curl); curl_close($curl); return $response; } function mobile($data) { $decodedData = json_decode($data, true); echo '<table> <thead> <tr> <th data-label="Number">Number</th> <th data-label="Name">Name</th> <th data-label="CNIC">CNIC</th> <th data-label="Address">Address</th> </tr> </thead> <tbody>'; foreach ($decodedData as $list) { if (is_array($list)) { echo ' <tr> <td data-label="Number">0' . $list['nbr'] . '</td> <td data-label="Name">' . ucwords(strtolower($list["nam"])) . '</td> <td data-label="CNIC">' . $list["cni"] . '</td> <td data-label="Address">' . ucwords(strtolower($list["adr"])) . '</td> </tr>'; } else { // echo $response; echo '<h4 style="color:green;">Records Not Found..! Contact Whatsapp For Details.'; } } echo ' </tbody> </table>'; } function ptcl($data) { $decodedData = json_decode($data, true); echo '<table> <thead> <tr> <th data-label="Number">Number</th> <th data-label="Name">Name</th> <th data-label="Address">Address</th> <th data-label="CNIC">CNIC</th> </tr> </thead> <tbody>'; $rows = []; if (is_array($decodedData)) { foreach ($decodedData as $list) { echo ' <tr> <td data-label="Number">0' . $list['nbr'] . '</td> <td data-label="Name">' . ucwords(strtolower($list["nam"])) . '</td> <td data-label="Address">' . ucwords(strtolower($list["adr"])) . '</td> <td data-label="CNIC">' . $list["cni"] . '</td> </tr>'; // Collect rows in an array $rows[] = [ 'Number' => '0' . $list['nbr'], 'Name' => ucwords(strtolower($list["nam"])), 'Address' => ucwords(strtolower($list["adr"])), 'CNIC' => $list["cni"], ]; } } else { echo '<tr><td colspan="4">Data is not found!</td></tr>'; } echo ' </tbody> </table>'; return $rows; } function vehicle($data) { $decodedData = json_decode($data, true); echo '<table> <thead> <tr> <th data-label="RegNo">RegNo</th> <th data-label="Eng / Chs No">Eng / Chs No</th> <th data-label="Brand">Brand</th> <th data-label="Owner Name">Owner Name</th> <th data-label="Owner CNIC">Owner CNIC</th> <th data-label="Address">Address</th> <th data-label="Phone No">Phone No</th> <th data-label="Reg Date">Reg Date</th> <th data-label="Tax Paid">Tax Paid</th> </tr> </thead> <tbody>'; if (is_array($decodedData)) { foreach ($decodedData as $list) { echo ' <tr> <td data-label="RegNo">' . $list["reg_no"] . '</td> <td data-label="Eng / Chs No">' . $list["eng_no"] . ' / ' . $list["chs_no"] . '</td> <td data-label="Brand">' . ucwords(strtolower($list["mkr_name"] . ' / ' . $list["yr"] . ' / ' . $list["mak_name"] . ' / ' . $list["clr"])) . '</td> <td data-label="Owner Name">' . ucwords(strtolower($list["own_name"] . ' S/O ' . $list["f_name"])) . '</td> <td data-label="Owner CNIC">' . $list["new_cnic"] . '</td> <td data-label="Address">' . ucwords(strtolower($list["adrs"] . ' / ' . $list["city"])) . '</td> <td data-label="Phone No">' . $list["own_no1"] . ', ' . $list["own_no2"] . '</td> <td data-label="Reg Date">' . $list["reg_dt"] . '</td> <td data-label="Tax Paid">' . $list["tax"] . '</td> </tr>'; } } else { echo '<tr><td colspan="9">Data is not found!</td></tr>'; } echo ' </tbody> </table>'; }