Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.14 KB | None | 0 0
  1. <title>LKQ SCANNER</title>
  2. <?
  3.  
  4.     //Define SQL Variables
  5.     $hostname = "localhost";
  6.     $database = "";
  7.     $username = "";
  8.     $password = "";
  9.    
  10.     //CONNECT TO DB
  11.     $mysqli = new mysqli($hostname, $username, $password, $database);
  12.     if ($mysqli->connect_errno) {
  13.         echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
  14.     }
  15.  
  16.  
  17.    
  18. ?>
  19.  
  20. <style>
  21.     body {
  22.         background-color: #B9B9B9;
  23.     }
  24.    
  25.     h1 {
  26.         margin: 0px;
  27.         font-size: 1em;
  28.         margin-top: 10px;
  29.         margin-bottom: 5px;
  30.     }
  31.    
  32.     .lot {
  33.         display:inline-block;
  34.         vertical-align:top;
  35.         background-color: #DADADA;
  36.         padding: 5px;
  37.     }
  38.    
  39.     .search {
  40.         display:inline-block;
  41.         vertical-align:top;
  42.         background-color: #E2E2E2;
  43.         padding: 5px;
  44.         width: 135px;
  45.     }
  46.    
  47.     .vehicle {
  48.         border:1px solid #B1B1B1;
  49.         padding:3px;
  50.         margin-bottom:3px;
  51.         background-color: #EAEAEA;
  52.     }
  53.     .vehicle img {
  54.         width: 100%;
  55.     }
  56. </style>
  57.  
  58. <div style="text-align:center">
  59.     <h1>LKQ SCANNER</h1>
  60.     <div class="lot">
  61.         <h1><a href="http://www.lkqpickyourpart.com/locations/LKQ_Self_Service_-_Greenville-212/recents/">GREENVILLE LOT</a></h1>
  62.         <div class="search">
  63.             <? finder("240", "1212"); ?>
  64.         </div>
  65.         <div class="search">
  66.             <? finder("G35", "1212"); ?>
  67.         </div>
  68.         <div class="search">
  69.             <? finder("350z", "1212"); ?>
  70.         </div>
  71.         <div class="search">
  72.             <? finder("J30", "1212"); ?>
  73.         </div>
  74.         <div class="search">
  75.             <? finder("9-3", "1212"); ?>
  76.         </div>
  77.         <div class="search">
  78.             <? finder("300zx", "1212"); ?>
  79.         </div>
  80.     </div>
  81.     <div class="lot">
  82.         <h1><a href="http://www.lkqpickyourpart.com/locations/LKQ_Pick_Your_Part_-_Greer-213/recents/">GREER LOT</a></h1>
  83.         <div class="search">
  84.             <? finder("240", "1213"); ?>
  85.         </div>
  86.         <div class="search">
  87.             <? finder("G35", "1213"); ?>
  88.         </div>
  89.         <div class="search">
  90.             <? finder("350z", "1213"); ?>
  91.         </div>
  92.         <div class="search">
  93.             <? finder("J30", "1213"); ?>
  94.         </div>
  95.         <div class="search">
  96.             <? finder("9-3", "1213"); ?>
  97.         </div>
  98.         <div class="search">
  99.             <? finder("300zx", "1213"); ?>
  100.         </div>
  101.     </div>
  102. </div>
  103.  
  104. <?
  105. function finder($keyword, $lotCode) {
  106.     global $mysqli;
  107.    
  108.     $link = "http://www.lkqpickyourpart.com/DesktopModules/pyp_vehicleInventory/getVehicleInventory.aspx?filter=$keyword&carbuyYardCode=$lotCode&pageSize=1000";
  109.     echo "<a href='$link' style='font-weight:bold'>$keyword</a>";
  110.    
  111.     $lot = "Unknown: $lotCode";
  112.     if ($lotCode=="1212") $lot = "Greenville";
  113.     if ($lotCode=="1213") $lot = "Greer";
  114.    
  115.     $page = file_get_contents($link);
  116.     $pageParts = explode('<a', $page);
  117.     $pageParts = array_slice($pageParts, 1);
  118.    
  119.     foreach ($pageParts as $vehicle) {
  120.        
  121.         echo "<div class='vehicle'>";
  122.        
  123.         $vehicleParts = explode('href="', $vehicle);
  124.         $vehicleParts = explode('?w=800', $vehicleParts[1]);
  125.         $imageURL = $vehicleParts[0];
  126.         echo "<a href='$imageURL'><img src='$imageURL?w=175'></a>";
  127.        
  128.         echo "<BR>";
  129.        
  130.         $vehicleParts = explode('" caption="', $vehicle);
  131.  
  132.         $vehicleParts = explode('<p>', $vehicleParts[1]);
  133.         $vehicleParts = explode('</p>', $vehicleParts[1]);
  134.  
  135.         $name = $vehicleParts[0];
  136.        
  137.         echo $name;
  138.        
  139.            
  140.             $imageURLcheck = $mysqli->query("SELECT imageURL FROM cars WHERE imageURL='$imageURL' ORDER BY id DESC LIMIT 1")->fetch_object()->imageURL;
  141.            
  142.             if ($imageURL != $imageURLcheck) {
  143.                 echo " (UPDATED)";
  144.                 $mysqli->query("INSERT INTO cars SET imageURL='$imageURL'");
  145.                
  146.                 $body = "LKQ SCANNER
  147.                         <table>";
  148.                             $body .= "<tr><td style='text-align:right;padding:4px;background-color:#d0d0d0;'>Name:</td><td style='font-weight:bold'>$name</td></tr>";
  149.                             $body .= "<tr><td style='text-align:right;padding:4px;background-color:#d0d0d0;'>Image:</td><td><img src='$imageURL?w=205'></td></tr>";
  150.                             $body .= "<tr><td style='text-align:right;padding:4px;background-color:#d0d0d0;'>Lot:</td><td>$lot Lot</td></tr>
  151.                         </table>";
  152.                
  153.                 $headers  = "From: LKQ SCANNER <contact@techhut.co>"."\r\n";
  154.                 $headers .= "MIME-Version: 1.0" . "\r\n";
  155.                 $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
  156.  
  157.                
  158.                 mail("youremailhere@email.com", $name, $body, $headers);
  159.             }
  160.  
  161.        
  162.         echo "</div>";
  163.     }
  164. }
  165.  
  166. mysqli_close($mysqli);
  167. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement