?> </ul><h2>System Utilities</h2><ul> <?php CheckUtils(); ?> </ul><h2>Misc</h2><ul> <?php CheckMisc(); ?> </ul><h2>Filesystem</h2><ul> <?php CheckFilesystem(); ?> </ul><h2>Test Locations</h2><ul> <?php CheckLocations(); ?> </ul> <?php //phpinfo(); ?> </body> </html> <?php /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ function ShowCheck($label, $pass, $required = true, $value = null) { if ($pass) { $str = 'pass'; } elseif ($required) {
function GetStoreID($SID, $TypeID, $StoreName, $StoreWebsite, $Locations, $CID, $Lat, $Lng, &$DoHist) { GeocodeLocations($Locations, $CID, $Lat, $Lng); $AdrIn = ''; $LocIn = ''; foreach ($Locations as $Location) { if (!is_null($Location[0]) && strlen($Location[0]) > 0) { $AdrIn .= "'" . Pacify($Location[0]) . "',"; } $LocIn .= round((double) $Location[2], 5) . ','; } $AdrIn = rtrim($AdrIn, ','); $LocIn = rtrim($LocIn, ','); if (strlen($LocIn) == 0) { return false; } //Look for store list($QR, $RS, $T) = QuerySet("SELECT S.StoreID, S.TypeID, L.LocationID, D.DealID\n FROM 2000_Stores S\n LEFT JOIN 2200_Store_Locations SL ON SL.StoreID = S.StoreID\n LEFT JOIN 3000_Locations L ON SL.LocationID = L.LocationID AND ((ROUND(L.LocationLongitude,5) IN (" . $LocIn . ")) " . (strlen($AdrIn) > 0 ? " OR (L.LocationAddress IN (" . $AdrIn . "))" : "") . ")\n LEFT JOIN 4000_Deals D ON D.StoreID = S.StoreID AND D.DealSourceID = " . $SID . " AND D.DateEnds > " . date('YmdHis') . "\n WHERE S.StoreName = '" . Pacify($StoreName) . "';"); if ($QR < 0) { return SysLogIt('Error searching for store.', StatusError, ActionSelect); } $StoreID = 0; if ($QR > 0) { while ($DR = mysql_fetch_array($RS)) { $StoreID = $DR['StoreID']; $OldTypeID = $DR['TypeID']; $LocationID = 0; $DealID = 0; if (!is_null($DR['LocationID'])) { $LocationID = $DR['LocationID']; } if (!is_null($DR['DealID'])) { $DealID = $DR['DealID']; } if ($StoreID > 0 && $DealID > 0) { break; } } } if ($StoreID > 0) { $DoHist = true; if ($OldTypeID != $TypeID) { //Update store type if (ExecCommand("UPDATE 2000_Stores SET TypeID = " . $TypeID . " WHERE StoreID = " . $StoreID . ";")) { SysLogIt('Updated store with ID of ' . $StoreID . ' from type ' . $OldTypeID . ' to ' . $TypeID . '.', StatusInfo, ActionUpdate); } else { SysLogIt('Error updating type of store with ID of ' . $StoreID . '.', StatusError, ActionUpdate); } } //Store found and any one location found if ($LocationID > 0) { if ($Lat != -1) { foreach ($Locations as $Location) { if ($Location[1] > 0) { $Dist = GetDistance($Location[1], $Location[2], $Lat, $Lng); if ($Dist > 1000) { return SetToWeb($StoreID, 'location/division mismatch (distance of ' . $Dist . ')'); } } } } //TODO: Check if any new addresses SysLogIt('Store already exists with ID of ' . $StoreID . ' and no need to update.'); return $StoreID; } //Store found, no locations found, but active deal if ($LocationID == 0 && $DealID > 0) { return CheckLocations($Locations, $StoreID, $Lat, $Lng); } } //No store found //or, store found, but no matching locations and no active deal //Prepare Website if (is_null($StoreWebsite) || trim($StoreWebsite) == '') { $Website = 'NULL'; } else { $Website = Pacify($StoreWebsite); if (!(strtolower(substr($Website, 0, 7)) == 'http://' || strtolower(substr($Website, 0, 8)) == 'https://')) { $Website = 'http://' . $Website; } $Website = "'" . $Website . "'"; } //Insert new store if (!ExecCommand("INSERT INTO 2000_Stores (TypeID, StoreName, StoreWebsite, StoreAddDate, StoreLastUpdate)\n VALUES (" . $TypeID . ",'" . Pacify($StoreName) . "'," . $Website . "," . date('YmdHis') . "," . date('YmdHis') . ");")) { return SysLogIt('Error creating new store.', StatusError, ActionInsert); } //Get new store record list($QR, $DR, $T) = QuerySingle("SELECT last_insert_id() AS ID;"); if ($QR < 0) { return SysLogIt('Error retrieving newly inserted store ID.', StatusError, ActionSelect); } $StoreID = $DR['ID']; SysLogIt('Created new store with ID of ' . $StoreID . '.', StatusInfo, ActionInsert); return AddLocationsTo($Locations, $StoreID, $Lat, $Lng); }