Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <title>LKQ SCANNER</title>
- <?
- //Define SQL Variables
- $hostname = "localhost";
- $database = "";
- $username = "";
- $password = "";
- //CONNECT TO DB
- $mysqli = new mysqli($hostname, $username, $password, $database);
- if ($mysqli->connect_errno) {
- echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
- }
- ?>
- <style>
- body {
- background-color: #B9B9B9;
- }
- h1 {
- margin: 0px;
- font-size: 1em;
- margin-top: 10px;
- margin-bottom: 5px;
- }
- .lot {
- display:inline-block;
- vertical-align:top;
- background-color: #DADADA;
- padding: 5px;
- }
- .search {
- display:inline-block;
- vertical-align:top;
- background-color: #E2E2E2;
- padding: 5px;
- width: 135px;
- }
- .vehicle {
- border:1px solid #B1B1B1;
- padding:3px;
- margin-bottom:3px;
- background-color: #EAEAEA;
- }
- .vehicle img {
- width: 100%;
- }
- </style>
- <div style="text-align:center">
- <h1>LKQ SCANNER</h1>
- <div class="lot">
- <h1><a href="http://www.lkqpickyourpart.com/locations/LKQ_Self_Service_-_Greenville-212/recents/">GREENVILLE LOT</a></h1>
- <div class="search">
- <? finder("240", "1212"); ?>
- </div>
- <div class="search">
- <? finder("G35", "1212"); ?>
- </div>
- <div class="search">
- <? finder("350z", "1212"); ?>
- </div>
- <div class="search">
- <? finder("J30", "1212"); ?>
- </div>
- <div class="search">
- <? finder("9-3", "1212"); ?>
- </div>
- <div class="search">
- <? finder("300zx", "1212"); ?>
- </div>
- </div>
- <div class="lot">
- <h1><a href="http://www.lkqpickyourpart.com/locations/LKQ_Pick_Your_Part_-_Greer-213/recents/">GREER LOT</a></h1>
- <div class="search">
- <? finder("240", "1213"); ?>
- </div>
- <div class="search">
- <? finder("G35", "1213"); ?>
- </div>
- <div class="search">
- <? finder("350z", "1213"); ?>
- </div>
- <div class="search">
- <? finder("J30", "1213"); ?>
- </div>
- <div class="search">
- <? finder("9-3", "1213"); ?>
- </div>
- <div class="search">
- <? finder("300zx", "1213"); ?>
- </div>
- </div>
- </div>
- <?
- function finder($keyword, $lotCode) {
- global $mysqli;
- $link = "http://www.lkqpickyourpart.com/DesktopModules/pyp_vehicleInventory/getVehicleInventory.aspx?filter=$keyword&carbuyYardCode=$lotCode&pageSize=1000";
- echo "<a href='$link' style='font-weight:bold'>$keyword</a>";
- $lot = "Unknown: $lotCode";
- if ($lotCode=="1212") $lot = "Greenville";
- if ($lotCode=="1213") $lot = "Greer";
- $page = file_get_contents($link);
- $pageParts = explode('<a', $page);
- $pageParts = array_slice($pageParts, 1);
- foreach ($pageParts as $vehicle) {
- echo "<div class='vehicle'>";
- $vehicleParts = explode('href="', $vehicle);
- $vehicleParts = explode('?w=800', $vehicleParts[1]);
- $imageURL = $vehicleParts[0];
- echo "<a href='$imageURL'><img src='$imageURL?w=175'></a>";
- echo "<BR>";
- $vehicleParts = explode('" caption="', $vehicle);
- $vehicleParts = explode('<p>', $vehicleParts[1]);
- $vehicleParts = explode('</p>', $vehicleParts[1]);
- $name = $vehicleParts[0];
- echo $name;
- $imageURLcheck = $mysqli->query("SELECT imageURL FROM cars WHERE imageURL='$imageURL' ORDER BY id DESC LIMIT 1")->fetch_object()->imageURL;
- if ($imageURL != $imageURLcheck) {
- echo " (UPDATED)";
- $mysqli->query("INSERT INTO cars SET imageURL='$imageURL'");
- $body = "LKQ SCANNER
- <table>";
- $body .= "<tr><td style='text-align:right;padding:4px;background-color:#d0d0d0;'>Name:</td><td style='font-weight:bold'>$name</td></tr>";
- $body .= "<tr><td style='text-align:right;padding:4px;background-color:#d0d0d0;'>Image:</td><td><img src='$imageURL?w=205'></td></tr>";
- $body .= "<tr><td style='text-align:right;padding:4px;background-color:#d0d0d0;'>Lot:</td><td>$lot Lot</td></tr>
- </table>";
- $headers = "From: LKQ SCANNER <contact@techhut.co>"."\r\n";
- $headers .= "MIME-Version: 1.0" . "\r\n";
- $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
- mail("youremailhere@email.com", $name, $body, $headers);
- }
- echo "</div>";
- }
- }
- mysqli_close($mysqli);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement