Example #1
0
function SaveMessage($Type, $From, $Sub, $Body)
{
    if (mysql_query("INSERT INTO 0800_Messages (MessageType, MessageFrom, MessageSubject, MessageBody) VALUES (" . $Type . ",'" . Pacify($From) . "','" . Pacify($Sub) . "','" . Pacify($Body) . "');") == false) {
        return SysLogIt('Error creating message.', StatusError, ActionInsert);
    }
    return true;
}
Example #2
0
 public function GetDivisionData($SRID, $URL, $LID, $TZ, $Sub = false, $WebD = false)
 {
     global $DebugMode;
     list($Data, $DURL) = GetWebData('http://www.dealicious.ca/' . $URL);
     if ($Data === false) {
         return array(SysLogIt('Error getting web data.', StatusError), null);
     }
     if ($DebugMode) {
         file_put_contents("Dealicious.txt", "http://www.dealicious.ca/" . $URL . chr(13) . chr(10) . chr(13) . chr(10) . $Data);
     }
     if (stripos($Data, 'manageDeal1') === false) {
         return array(true, false);
     }
     $NewDeal = array("ID" => array('', '?dealId', '=', '"', false), "Title" => array('', 'class="OfferTitle_Homepage"', '</span>', '</div>', false), "Website" => array('', 'class="maplocation"', 'href="', '"', false, true), "PriceSale" => array(0, 'class="pricebox-left"', '<span>', '<', true), "PriceReg" => array(0, 'class="value"', '$', '<', true), "StoreName" => array('', 'class="maplocation"', '<h2>', '</h2>', false), "Description" => array('', '<!-- Company details', '<p>', '</p>', false), "Address" => array('', 'class="maplocation"', '</h2>', '</div>', false, true), "EndY" => array(0, "'year'", ':', ',', true), "EndM" => array(0, "'month'", ':', ',', true), "EndD" => array(0, "'day'", ':', ',', true), "EndH" => array(0, "'hour'", ':', ',', true), "EndN" => array(0, "'min'", ':', ',', true), "EndS" => array(0, "'sec'", ':', '}', true));
     if (!GetNewDealData($Data, $NewDeal)) {
         return array(SysLogIt('Error finding key deal information.', StatusError), null);
     }
     $StartDate = time();
     $EndDate = mktime((int) $NewDeal['EndH'][0], (int) $NewDeal['EndN'][0], (int) $NewDeal['EndS'][0], (int) $NewDeal['EndM'][0], (int) $NewDeal['EndD'][0], (int) $NewDeal['EndY'][0]);
     if ($EndDate <= time()) {
         return array(SysLogIt('Could not determine deal end date.', StatusError), null);
     }
     $VExpiry = FindSubData($Data, 'Expires on', '</strong>', '</div>', false);
     if ($VExpiry !== false) {
         $VExpiry = strtotime($VExpiry);
     }
     if ($VExpiry === false) {
         $VExpiry = 0;
     }
     $Website = null;
     if ($NewDeal['Website'][0] !== false) {
         $Website = $NewDeal['Website'][0];
     }
     $Address = null;
     if ($NewDeal['Address'][0] !== false) {
         $Address = CleanHTML($NewDeal['Address'][0]);
     }
     if ($Address == '') {
         $Address = null;
     }
     $RData = array();
     $RData['DRID'] = $NewDeal['ID'][0];
     $RData['Title'] = CleanHTML(str_ireplace("Today's Deal:", "", $NewDeal['Title'][0]));
     $RData['Descr'] = $NewDeal['Description'][0];
     $RData['URL'] = 'http://www.dealicious.ca/index.php?deal=' . $NewDeal['ID'][0];
     $RData['Price'] = (double) $NewDeal['PriceSale'][0];
     $RData['Value'] = (double) $NewDeal['PriceReg'][0];
     $RData['Status'] = 0;
     $RData['SDate'] = $StartDate;
     $RData['EDate'] = $EndDate;
     $RData['VDate'] = $VExpiry;
     $RData['StoreName'] = $NewDeal['StoreName'][0];
     $RData['Website'] = $Website;
     $RData['Locations'] = array(array($Address, 0, 0));
     return array(true, array($RData));
 }
Example #3
0
 public function GetDivisionData($SRID, $URL, $LID, $TZ, $Sub = false, $WebD = false)
 {
     global $DebugMode;
     list($Data, $DURL) = GetWebData('http://www.groupon.com/' . $URL, null, 'visited=true');
     if ($Data === false) {
         return array(SysLogIt('Error getting web data.', StatusError), null);
     }
     if ($DebugMode) {
         file_put_contents("Groupon.txt", 'http://www.groupon.com/' . $URL . chr(13) . chr(10) . chr(13) . chr(10) . $Data);
     }
     if (stripos($Data, 'pledge_id') === false) {
         return array(true, false);
     }
     $NewDeal = array("ID" => array('', 'Groupon.currentDeal.permalink', '"', '"', false), "Title" => array('', 'Groupon.currentDeal.title', '"', '"', false), "Website" => array('', "class='company_links", 'href="', '"', false, true), "PriceSale" => array(0, 'id="amount"', '$', '<', true), "PriceReg" => array(0, "id='deal_discount'", '$', '<', true), "StoreName" => array('', "class='name'", '>', '<', false), "Description" => array('', "class='pitch_content'", ">", '</div>', false), "Address" => array('', "class='address'", '<p>', '<a', false, true), "EndDate" => array(0, 'data-deadline=', "'", "'", true));
     if (!GetNewDealData($Data, $NewDeal)) {
         return array(SysLogIt('Error finding key deal information.', StatusError), null);
     }
     $StartDate = time();
     $EndDate = $NewDeal['EndDate'][0];
     if ($EndDate === false || $EndDate <= time()) {
         return array(SysLogIt('Could not determine deal end date.', StatusError), null);
     }
     $VExpiry = FindSubData($Data, '<li>Expires', ' ', '<', false);
     if ($VExpiry !== false) {
         $VExpiry = strtotime($VExpiry);
     }
     if ($VExpiry === false) {
         $VExpiry = 0;
     }
     $Website = null;
     if ($NewDeal['Website'][0] !== false) {
         $Website = $NewDeal['Website'][0];
     }
     $Address = null;
     if ($NewDeal['Address'][0] !== false) {
         $Address = CleanHTML($NewDeal['Address'][0]);
     }
     if ($Address == '') {
         $Address = null;
     }
     $RData = array();
     $RData['DRID'] = $NewDeal['ID'][0];
     $RData['Title'] = CleanHTML(str_ireplace("Today's Deal:", "", $NewDeal['Title'][0]));
     $RData['Descr'] = $NewDeal['Description'][0];
     $RData['URL'] = 'http://www.groupon.com/deals/' . $NewDeal['ID'][0];
     $RData['Price'] = (double) $NewDeal['PriceSale'][0];
     $RData['Value'] = (double) $NewDeal['PriceReg'][0];
     $RData['Status'] = 0;
     $RData['SDate'] = $StartDate;
     $RData['EDate'] = $EndDate;
     $RData['VDate'] = $VExpiry;
     $RData['StoreName'] = $NewDeal['StoreName'][0];
     $RData['Website'] = $Website;
     $RData['Locations'] = array(array($Address, 0, 0));
     return array(true, array($RData));
 }
Example #4
0
function FlushSessions()
{
    //Delete old sessions
    if (!ExecCommand("DELETE FROM 0700_Sessions\n                        WHERE (SessionAccessDate < " . date('YmdHis', mktime(date('H'), date('i'), date('s'), date('n'), date('j') - 90, date('Y'))) . ")\n                           OR (SessionAccessDate < " . date('YmdHis', mktime(date('H') - 3, date('i'), date('s'), date('n'), date('j'), date('Y'))) . " AND SessionPort = 0);")) {
        SysLogIt('Error deleting old sessions.', StatusError, ActionDelete);
    }
    //Delete old logs
    if (!ExecCommand("DELETE FROM 0500_System_Log\n                        WHERE EntryTimestamp < " . date('YmdHis', mktime(date('H'), date('i'), date('s'), date('n'), date('j') - 14, date('Y'))) . "\n                          AND EntryIP = '';")) {
        SysLogIt('Error deleting old system log entries.', StatusError, ActionDelete);
    }
    if (!ExecCommand("DELETE FROM 0500_System_Log\n                        WHERE EntryTimestamp < " . date('YmdHis', mktime(date('H'), date('i'), date('s'), date('n'), date('j') - 90, date('Y'))) . ";")) {
        SysLogIt('Error deleting old log entries.', StatusError, ActionDelete);
    }
}
Example #5
0
function FlushSession($UserID = 0)
{
    /*/////////////////////////////////////////////////////////////
           Author: Plottery
          Created: v1.0.0 - 2010-12-09
        Revisions: None
          Purpose: Delete sessions and cookies for user
          Returns: True if successful, or false
      */
    /////////////////////////////////////////////////////////////
    global $SessionID;
    setcookie('SKEY', '', time() - 3600);
    setcookie('LID', '', time() - 3600);
    if ($SessionID > 0) {
        if (!ExecCommand("DELETE FROM 0700_Sessions WHERE SessionID = " . (int) $SessionID . ";")) {
            return SysLogIt('Could not delete session with ID of ' . (int) $SessionID . '.', StatusError, ActionDelete);
        }
    }
    if ($UserID > 0) {
        if (!ExecCommand("DELETE FROM 0700_Sessions WHERE UserID = " . (int) $UserID . ";")) {
            return SysLogIt('Could not delete session(s) for user with ID of ' . (int) $UserID . '.', StatusError, ActionDelete);
        }
    }
    return true;
}
Example #6
0
 public function GetDivisionData($SRID, $URL, $LID, $TZ, $Sub = false, $WebD = false)
 {
     global $DebugMode;
     if ($Sub) {
         list($Data, $DURL) = GetWebData('http://www.teambuy.ca/' . $URL, null, 'language=english');
     } else {
         list($Data, $DURL) = GetWebData('http://www.teambuy.ca/' . $URL . '/all-buys/local', null, 'language=english');
     }
     if ($Data === false) {
         return array(SysLogIt('Error getting web data.', StatusError), null);
     }
     if ($DebugMode) {
         file_put_contents("Teambuy.txt", $Data);
     }
     if ($Sub) {
         //if (stripos($Data, '/buy/') === false) return array(true, false);
         $Prices = FindSubData($Data, 'PRICE:', 'class="ddValues">', '<', false);
         if ($Prices == 'Varies') {
             return array(SysLogIt('Deal has variable pricing. Skipping...', StatusInfo), false);
         }
         $NewDeal = array("City" => array('', 'og:url', 'content="http://www.teambuy.ca/', '/', false), "ID" => array(0, 'og:url" content="http://www.teambuy.ca/', '/', '/', true), "Title" => array('', '<title>', '| ', '<', false), "PriceSale" => array(0, 'PRICE:', '$', '<', true), "PriceReg" => array(0, 'VALUE:', '$', '<', true), "StoreName" => array('', 'id="companyName"', '>', '<', false), "Website" => array('', 'id="companyWebsite"', 'href="', '"', false, true), "Description" => array('', 'id="writeUpContent"', '<p>', '</p>', false), "EndDate" => array('', 'var futuredate', '"timercontainer", "', '")', false));
         if (!GetNewDealData($Data, $NewDeal)) {
             return array(SysLogIt('Error finding key deal information.', StatusError), null);
         }
         $StartDate = time();
         $EndDate = strtotime($NewDeal['EndDate'][0] . ' 12:00 AM');
         if ($EndDate === false) {
             return array(SysLogIt('Could not determine deal end date.', StatusError), null);
         }
         //$EndDate += -(((int)$TZ + 5) * 60 * 60);
         //All teambuys seem to finish at 12AM EST
         $VExpiry = FindData($Data, 'id="dealExpiryWide">Expires: ', '<', 29, 0, false, 0, false);
         $VExpiry = $VExpiry === false ? 0 : strtotime($VExpiry);
         if ($VExpiry === false) {
             $VExpiry = 0;
         }
         $Locations = array();
         $Start = stripos($Data, '&geocode');
         while ($Start !== false) {
             $New = FindData($Data, "&hnear=", '&', 7, 0, false, $Start, false);
             if ($New !== false) {
                 $Locations[] = array(CleanHTML(urldecode($New)), 0, 0);
             }
             $Start = stripos($Data, "&geocode", $Start + 20);
         }
         if (count($Locations) == 0) {
             $Locations[] = array(null, 0, 0);
         }
         $RData = array();
         $RData['DRID'] = (int) $NewDeal['ID'][0];
         $RData['Title'] = $NewDeal['Title'][0];
         $RData['Descr'] = $NewDeal['Description'][0];
         $RData['URL'] = 'http://www.teambuy.ca/' . $NewDeal['City'][0] . '/referral/92yyby6y/' . (int) $NewDeal['ID'][0] . '/';
         $RData['Price'] = (double) $NewDeal['PriceSale'][0];
         $RData['Value'] = (double) $NewDeal['PriceReg'][0];
         $RData['Status'] = 0;
         $RData['SDate'] = $StartDate;
         $RData['EDate'] = $EndDate;
         $RData['VDate'] = $VExpiry;
         $RData['StoreName'] = $NewDeal['StoreName'][0];
         $RData['Website'] = $NewDeal['Website'][0];
         $RData['Locations'] = $Locations;
         return array(true, array($RData));
     } else {
         $RData = array();
         $RData['GW'] = true;
         $RData['EDate'] = 0;
         $MoreDeals = array();
         $Last = '';
         $Start = stripos($Data, 'deal_id-');
         while ($Start !== false) {
             $New = FindSubData($Data, 'deal_id-', 'href="http://www.teambuy.ca', '"', false, $Start, false);
             if ($New !== false && $New != $Last) {
                 $MoreDeals[] = $New;
                 $Last = $New;
             }
             $Start = stripos($Data, 'deal_id-', $Start + 20);
         }
         if (count($MoreDeals) > 0) {
             $RData['Deals'] = $MoreDeals;
         }
         return array(true, array($RData));
     }
 }
Example #7
0
 public function GetDivisionData($SRID, $URL, $LID, $TZ, $Sub = false, $WebD = false)
 {
     global $DebugMode;
     if ($Sub) {
         list($Data, $DURL) = GetWebData('http://www.ilovemtl.ca/en/' . $URL);
     } else {
         list($Data, $DURL) = GetWebData('http://www.ilovemtl.ca/en/');
     }
     if ($Data === false) {
         return array(SysLogIt('Error getting web data.', StatusError), null);
     }
     if ($DebugMode) {
         file_put_contents("ILoveMTL.txt", $Data);
     }
     if (stripos($Data, 'og:url') === false) {
         return array(true, false);
     }
     if ($WebD) {
         $NewDeal = array("ID" => array('', 'og:url', 'content="http://www.ilovemtl.ca/en/escapes/', '"', false), "Title" => array('', 'og:title', 'content="', '"', false), "PriceSale" => array(0, 'id="escape-promo-price"', '<span>', '$', true), "PriceReg" => array(0, 'id="escape-promo-regprice"', ':', '$', true), "StoreName" => array('', 'class="location-name', '>', '<', false), "Description" => array('', 'line-height:1.45em;', '>', '<!-- Fine print -->', false), "EndDate" => array('', 'var endtime =', 'new Date(', ')', false));
     } else {
         $NewDeal = array("ID" => array('', 'og:url', 'content="http://www.ilovemtl.ca/en/deal/', '"', false), "Title" => array('', '"promo-title"', '</span>', '</div>', false), "PriceSale" => array(0, 'id="promo-price"', '<span>', '$', true), "PriceReg" => array(0, 'class="price-details', '>Value', '$', true), "StoreName" => array('', 'class="location-name', '>', '<', false), "Description" => array('', 'About this deal', '<p>', '</div>', false), "EndDate" => array('', 'var endtime =', 'new Date(', ')', false), "Address" => array('', 'class="location-addr"', '>', '<a', false, true), "Website" => array('', 'class="location-addr"', '<a href="', '"', false, true));
     }
     if (!GetNewDealData($Data, $NewDeal)) {
         return array(SysLogIt('Error finding key deal information.', StatusError), null);
     }
     //Start, end dates
     $StartDate = time();
     $EndDate = 0;
     $DateParts = explode(',', $NewDeal['EndDate'][0]);
     if ($DateParts !== false) {
         $EndDate = mktime((int) trim($DateParts[3]), (int) trim($DateParts[4]), (int) trim($DateParts[5]), (int) trim($DateParts[1]) + 1, (int) trim($DateParts[2]), (int) trim($DateParts[0]));
     }
     if ($EndDate === false) {
         $EndDate = 0;
     }
     if ($EndDate <= time()) {
         return array(SysLogIt('Could not determine deal end date.', StatusError), null);
     }
     //Expiry Date
     $VExpiry = FindSubData($Data, '<li>Valid', ' to ', '</li>', false, 0, false);
     if (stripos($VExpiry, '.') !== false) {
         $VExpiry = substr($VExpiry, 0, stripos($VExpiry, '.'));
     }
     if ($VExpiry !== false) {
         $VExpiry = strtotime($VExpiry);
     }
     if ($VExpiry === false) {
         $VExpiry = 0;
     }
     $Website = null;
     if ($NewDeal['Website'][0] !== false) {
         $Website = $NewDeal['Website'][0];
     }
     //Address(es)
     $Locations = array();
     if ($NewDeal['Address'][0] !== false) {
         $Locations[] = array(CleanHTML($NewDeal['Address'][0]), 0, 0);
     } else {
         $Locations[] = array(null, 0, 0);
     }
     /*
     $Start = stripos($Data, '&markers=');
     while ($Start !== false) {
     
       $Coords = FindData($Data, '&markers=', ',greena', 9, 0, false, $Start, false);
       if ($Coords !== false) $Coords = explode(',', $Coords);
       
       $Adr = FindData($Data, '&q=', '&ie=', 3, 0, false, $Start, false);
       $Adr = ($Adr === false)?null:urldecode($Adr);
       
       if (count($Coords) == 2) $Locations[] = array($Adr, $Coords[0], $Coords[1]);
     
       $Start = stripos($Data, '&markers=', $Start + 20);
     }
     */
     //Side deals
     $MoreDeals = array();
     if (!$Sub) {
         $Last = '';
         $Start = stripos($Data, 'class="sidedeal-img"');
         while ($Start !== false) {
             $New = FindData($Data, 'href="http://www.ilovemtl.ca/en/', '"', 32, 0, false, $Start, false);
             if ($New !== false && $New != $Last) {
                 $MoreDeals[] = array($New, stripos($New, 'escapes') !== false);
                 $Last = $New;
             }
             $Start = stripos($Data, 'class="sidedeal-img"', $Start + 20);
         }
     }
     //French title
     if ($WebD) {
         $TitleFR = '';
         list($Data, $DURL) = GetWebData('http://www.ilovemtl.ca/fr/escapades/' . $NewDeal['ID'][0]);
         if ($Data !== false) {
             $TitleFR = FindSubData($Data, 'og:title', 'content="', '"', false, 0, false);
             if ($TitleFR !== false) {
                 $TitleFR = CleanHTML($TitleFR);
             }
         }
     } else {
         $TitleFR = '';
         list($Data, $DURL) = GetWebData('http://www.ilovemtl.ca/fr/deal/' . $NewDeal['ID'][0]);
         if ($Data !== false) {
             $TitleFR = FindSubData($Data, '"promo-title"', '</span>', '</div>', false, 0, false);
             if ($TitleFR !== false) {
                 $TitleFR = CleanHTML($TitleFR);
             }
         }
     }
     //Save
     $RData = array();
     $RData['DRID'] = $NewDeal['ID'][0];
     $RData['Title'] = CleanHTML($NewDeal['Title'][0]);
     if ($TitleFR !== false && $TitleFR != '') {
         $RData['Title-fr'] = $TitleFR;
     }
     $RData['Descr'] = $NewDeal['Description'][0];
     if ($WebD) {
         $RData['URL'] = 'http://www.ilovemtl.ca/en/escapes/' . $NewDeal['ID'][0];
     } else {
         $RData['URL'] = 'http://www.ilovemtl.ca/en/deal/' . $NewDeal['ID'][0];
     }
     $RData['Price'] = (double) $NewDeal['PriceSale'][0];
     $RData['Value'] = (double) $NewDeal['PriceReg'][0];
     $RData['Status'] = 0;
     $RData['SDate'] = $StartDate;
     $RData['EDate'] = $EndDate;
     $RData['VDate'] = $VExpiry;
     $RData['StoreName'] = $NewDeal['StoreName'][0];
     $RData['Website'] = $Website;
     $RData['Locations'] = $Locations;
     if (count($MoreDeals) > 0) {
         $RData['Deals'] = $MoreDeals;
     }
     return array(true, array($RData));
 }
Example #8
0
 public function GetDivisionData($SRID, $URL, $LID, $TZ, $Sub = false, $WebD = false)
 {
     global $DebugMode;
     list($Data, $DURL) = GetWebData('http://www.dealfind.com/' . $URL);
     if ($Data === false) {
         return array(SysLogIt('Error getting web data.', StatusError), null);
     }
     if ($DebugMode) {
         file_put_contents("DealFind.txt", $Data);
     }
     if (stripos($Data, 'insanely monstrous') !== false) {
         return array(true, false);
     }
     $NewDeal = array("ID" => array(0, 'var DealID', '=', ';', true), "Title" => array('', 'var DealName', '"', '"', false), "URL" => array('', 'var AffiliateLinkURL', '"', '"', false), "PriceReg" => array(0, 'var RegularPriceHTML', "'\$", "'", true), "PriceSale" => array(0, 'var OurPriceHTML', "'\$", "'", true), "DealTime" => array(0, 'DealSeconds_Total', '=', ';', true), "DealElapsed" => array(0, 'DealSeconds_Elapsed', '=', ';', true), "DealStart" => array('', 'The deal went live', 'on', '<', false), "StoreName" => array('', 'itemprop="name"', '>', '<', false), "Description" => array('', 'class="dealText"', '>', '<div', false), "Website" => array('', 'itemprop="url"', 'href="', '"', false, true), "Address" => array('', 'itemprop="name"', 'itemprop="description">', chr(9) . '</div>', false, true), "Coords" => array('', 'point = new GLatLng', '(', ')', false, true));
     if (!GetNewDealData($Data, $NewDeal)) {
         return array(SysLogIt('Error finding key deal information.', StatusError), null);
     }
     $StartDate = time() - $NewDeal['DealElapsed'][0];
     $EndDate = $StartDate + $NewDeal['DealTime'][0];
     //Time measured in seconds, so no need for timezone adjustments
     $VExpiry = FindData($Data, 'Expires on', '.', 11, 0, false, 0, false);
     $VExpiry = $VExpiry === false ? 0 : strtotime($VExpiry);
     if ($VExpiry === false) {
         $VExpiry = 0;
     }
     $Coords = array(0, 0);
     if ($NewDeal['Coords'][0] !== false) {
         $Coords = explode(',', $NewDeal['Coords'][0]);
     }
     if ($Coords === false || count($Coords) != 2) {
         $Coords = array(0, 0);
     }
     $Address = null;
     if ($NewDeal['Address'][0] !== false) {
         $Address = CleanHTML($NewDeal['Address'][0]);
     }
     if ($Address == '') {
         $Address = null;
     }
     if (stripos($Address, 'map it') !== false) {
         $Address = trim(substr($Address, 0, stripos($Address, 'map it')));
     }
     if (stripos($Address, 'n/a') !== false) {
         $Address = trim(substr($Address, 0, stripos($Address, 'n/a')));
     }
     if (stripos($Address, 'redeem online') !== false || stripos($Address, 'redeem by phone') !== false || stripos($Address, 'mobile service') !== false) {
         $Address = null;
         $Coords = array(-1, -1);
     }
     //$Website = FindData($NewDeal['MoreData'][0], 'a href="', '"', 8, 0, false, 0, false);
     //if ($Website === false) $Website = '';
     $Website = null;
     if ($NewDeal['Website'][0] !== false) {
         $Website = $NewDeal['Website'][0];
     }
     if (trim($Website) == '') {
         $Website = null;
     }
     $MoreDeals = array();
     $Start = stripos($Data, 'class="side-deal');
     while ($Start !== false) {
         $ID = FindData($Data, 'href="', '"', 6, 0, false, $Start, false);
         if ($ID !== false) {
             $MoreDeals[] = $ID;
         }
         $Start = stripos($Data, 'class="side-deal', $Start + 20);
     }
     /*
     //Parse address
     $Address = $NewDeal['MoreData'][0];
     $Address = str_ireplace('<br/>', ', ', $Address);
     $Address = str_ireplace('website', '', $Address);
     $Address = str_ireplace('map it', '', $Address);
     $Address = substr(trim(CleanHTML($Address)), 2);
     */
     /*
     $AddressArray = explode(chr(13).chr(10), $NewDeal['MoreData'][0]);
     foreach ($AddressArray as $AddressItem) {
       if (stripos($AddressItem, '                ') !== false && stripos($AddressItem, '                  ') === false) {
         $Address = trim(substr($AddressItem, 0, stripos($AddressItem, '<br><a')));
         $Address = CleanHTML($Address);
         break;
       }
     }
     */
     $RData = array();
     $RData['DRID'] = (int) $NewDeal['ID'][0];
     $RData['Title'] = $NewDeal['Title'][0];
     $RData['Descr'] = $NewDeal['Description'][0];
     $RData['URL'] = $NewDeal['URL'][0];
     $RData['Price'] = (double) $NewDeal['PriceSale'][0];
     $RData['Value'] = (double) $NewDeal['PriceReg'][0];
     $RData['Status'] = 0;
     $RData['SDate'] = $StartDate;
     $RData['EDate'] = $EndDate;
     $RData['VDate'] = $VExpiry;
     $RData['StoreName'] = $NewDeal['StoreName'][0];
     $RData['Website'] = $Website;
     $RData['Locations'] = array(array($Address, $Coords[0], $Coords[1]));
     if (count($MoreDeals) > 0) {
         $RData['Deals'] = $MoreDeals;
     }
     return array(true, array($RData));
 }
Example #9
0
function DeleteAccessKey($InKey)
{
    if (!ExecCommand("DELETE FROM 0600_Access_Keys WHERE KeyID = " . $InKey . ";")) {
        return SysLogIt('Error deleting access key with ID of ' . $InKey . '.', StatusError, ActionDelete);
    }
    return true;
}
Example #10
0
function GetStatus()
{
    /*/////////////////////////////////////////////////////////////
           Author: Plottery Corp.
          Created: v1.0.0 - 2011-04-09
        Revisions: None
          Purpose: Display status
          Returns: Nothing
      */
    /////////////////////////////////////////////////////////////
    global $Response;
    $Response->J = 'F5();';
    if ($RandomKey = GetNewAccessKey()) {
        list($QR, $RS, $T) = QuerySet('
          SELECT DS.DealSourceName AS Name, COALESCE(Dx.DCnt, 0) AS DCount, COALESCE(Dy.ACnt, 0) AS ACount
            FROM 4100_Deal_Sources DS
            LEFT JOIN (SELECT D.DealSourceID, COUNT(D.DealID) AS DCnt FROM 4000_Deals D WHERE D.DateEnds > ' . date('YmdHis') . ' GROUP BY D.DealSourceID) Dx ON DS.DealSourceID = Dx.DealSourceID
            LEFT JOIN (SELECT D.DealSourceID, ROUND(COUNT(D.DealID)/30, 0) AS ACnt FROM 4000_Deals D WHERE D.DateListed > ' . date('YmdHis', mktime(date('H'), date('i'), date('s'), date('n'), date('j') - 30, date('Y'))) . ' GROUP BY D.DealSourceID) Dy ON DS.DealSourceID = Dy.DealSourceID
           WHERE DS.DealSourceStatus & 1 = 1
           GROUP BY DS.DealSourceID
           ORDER BY DS.DealSourceName ASC;');
        if ($QR < 0) {
            SysLogIt('Error searching for source deal counts.', StatusError, ActionSelect);
        } else {
            $Response->S = true;
            $Response->R = '<DIV CLASS="ttlw">Status<INPUT TYPE="hidden" ID="Key" VALUE="' . $RandomKey . '"><HR></DIV><DIV ID="SttDiv" CLASS="abs fulls flwa algc"><TABLE CELLPADDING=1 CELLSPACING=0 BORDER=0 ID="SttTbl" CLASS="fra rbrds mgrx"><TBODY><TR><TD COLSPAN=3 CLASS="b padbs algc">Deal Counts<HR></TD></TR><TR CLASS="sz10 b algc"><TD CLASS="padls algl">Name</TD><TD>Cur.</TD><TD>Avg.</TD></TR>';
            if ($QR > 0) {
                $Entries = 0;
                while ($DR = mysql_fetch_array($RS)) {
                    $Entries++;
                    $RowClass = 'sz14';
                    if ($Entries % 2 == 0) {
                        $RowClass .= ' row';
                    }
                    $Response->R .= '<TR CLASS="sz14 ' . $RowClass . '">
                               <TD CLASS="padrs padls" NOWRAP><DIV>' . $DR['Name'] . '</DIV></TD>
                               <TD CLASS="padrs padls algc" NOWRAP><DIV>' . $DR['DCount'] . '</DIV></TD>
                               <TD CLASS="padrs padls algc" NOWRAP><DIV>' . $DR['ACount'] . '</DIV></TD>
                            </TR>';
                }
            }
            $Response->R .= '</TBODY></TABLE></DIV>';
            $Response->J = '';
        }
    }
    $Response->Send();
}
Example #11
0
function CheckUnsubscribe()
{
    /*/////////////////////////////////////////////////////////////
           Author: Plottery Corp.
          Created: v1.0.0 - 2011-08-14
        Revisions: None
          Purpose: Unsubscribes a user from all notifications
          Returns: Nothing
      */
    /////////////////////////////////////////////////////////////
    if (isset($_GET['Key'])) {
        list($QR, $DR, $T) = QuerySingle("SELECT UN.NotificationID AS NID, UN.UserID AS UID\n             FROM 1400_User_Notifications UN\n            WHERE UN.CancelKey = '" . Pacify($_GET['Key']) . "';");
        if ($QR < 0) {
            SysLogIt('Error searching for cancel key ' . Pacify($_GET['Key']) . '.', StatusError, ActionSelect);
        } else {
            $Strings = GSA('2112');
            if ($QR > 0) {
                if (ExecCommand("UPDATE 1000_Users SET UserFlags = (UserFlags & ~" . UserReminders . ") WHERE UserID = " . $DR['UID'] . ";")) {
                    SysLogIt('Successfully disabled reminders for user with ID of ' . $DR['UID'] . '.', StatusInfo);
                    if (ExecCommand("UPDATE 1400_User_Notifications SET Settings = 0 WHERE NotificationID = " . $DR['NID'] . ";")) {
                        SysLogIt('Successfully disabled digests for user with ID of ' . $DR['UID'] . '.', StatusInfo);
                        return DisplayMainScreen("SetBackMap(); PopC('" . Pacify(Pacify($Strings[2112]), true) . "','GH();');");
                    } else {
                        SysLogIt('Could not disable digests for user with ID of ' . $UID . '.', StatusError, ActionInsert);
                    }
                } else {
                    SysLogIt('Could not disable reminders for user with ID of ' . $UID . '.', StatusError, ActionInsert);
                }
            }
        }
    }
    return DisplayMainScreen('PopErr();');
}
Example #12
0
function InsertNewString($SQL, $ID)
{
    if (!ExecCommand($SQL)) {
        return SysLogIt('Error creating new string header.', StatusError, ActionInsert);
    }
    SysLogIt('Created new string header with ID of ' . $ID . '.', StatusInfo, ActionInsert);
    return $ID;
}
Example #13
0
function DoHistoryGraph($SID)
{
    $Filepath = dirname(__FILE__) . '/../Hist/';
    list($QR, $DR, $T) = QuerySingle("SELECT SH.HistoryID AS HID, SH.Filename AS FName, COUNT(D.DealID) AS Deals, MAX(GREATEST(D.DealPrice, D.DealValue)) AS MaxVal,\n            AVG(D.DealValue) AS AvgVal, AVG(D.DealPrice) AS AvgPrc\n           FROM 4000_Deals D\n           LEFT JOIN 2600_Store_History SH ON D.StoreID = SH.StoreID\n          WHERE D.StoreID = " . $SID . "\n          GROUP BY D.StoreID;");
    if ($QR < 0) {
        return SysLogIt('Error searching deals for history.', StatusError, ActionSelect);
    }
    if ($QR > 0) {
        list($QR, $SDR, $T) = QuerySingle('SELECT GROUP_CONCAT(X.DealID) AS DIDs, GROUP_CONCAT(X.DealPrice) AS DPrcs, GROUP_CONCAT(X.DealValue) AS DVals, GROUP_CONCAT(X.DealSourceName) AS SNams, GROUP_CONCAT(X.DEnd) AS DEnds
             FROM (
               SELECT D.StoreID, D.DealID, D.DealPrice, D.DealValue, DS.DealSourceName, UNIX_TIMESTAMP(D.DateEnds) AS DEnd
                 FROM 4000_Deals D
                INNER JOIN 4100_Deal_Sources DS ON D.DealSourceID = DS.DealSourceID
                WHERE D.StoreID = ' . $SID . '
                ORDER BY D.DateEnds
             ) X
             GROUP BY X.StoreID;');
        if ($QR < 0) {
            return SysLogIt('Error searching deal details for history.', StatusError, ActionSelect);
        }
        if ($QR > 0) {
            if ($DR['Deals'] <= 1) {
                return false;
            }
            if (!is_null($DR['FName'])) {
                if (file_exists($Filepath . $DR['FName'])) {
                    unlink($Filepath . $DR['FName']);
                }
            }
            $Filename = md5($SID . time()) . '.svg';
            $LMarg = 15;
            $RMarg = 30;
            $TMarg = 25;
            $VHeight = 80;
            $HSpacing = (int) ((400 - $LMarg - $RMarg) / ($DR['Deals'] - 1));
            $DPrcs = explode(',', $SDR['DPrcs']);
            $DVals = explode(',', $SDR['DVals']);
            $SNams = explode(',', $SDR['SNams']);
            $DEnds = explode(',', $SDR['DEnds']);
            $LPrc = 0;
            $MSav = 0;
            $MSvP = 0;
            for ($x = 0; $x < $DR['Deals']; $x++) {
                if ((int) $DPrcs[$x] < $LPrc || $LPrc == 0) {
                    $LPrc = (int) $DPrcs[$x];
                }
                if ((int) $DVals[$x] - (int) $DPrcs[$x] > $MSav) {
                    $MSav = (int) $DVals[$x] - (int) $DPrcs[$x];
                }
                if ((int) (100 - $DPrcs[$x] / $DVals[$x] * 100) > $MSvP) {
                    $MSvP = (int) (100 - $DPrcs[$x] / $DVals[$x] * 100);
                }
            }
            $Output = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="400" height="' . ($TMarg + $VHeight + 20 + ($DR['Deals'] * 20 + 10) + 10 + 30) . '">';
            //Grid
            for ($x = 0; $x < $DR['Deals']; $x++) {
                $Output .= '<path d="M' . $LMarg . ',' . ($TMarg + ($VHeight - (int) ($DPrcs[$x] / $DR['MaxVal'] * $VHeight))) . ' L' . ($LMarg + ($DR['Deals'] - 1) * $HSpacing) . ',' . ($TMarg + ($VHeight - (int) ($DPrcs[$x] / $DR['MaxVal'] * $VHeight))) . '" style="stroke: #C0C0C0; stroke-width: 1; fill: none;"/>';
                $Output .= '<path d="M' . $LMarg . ',' . ($TMarg + ($VHeight - (int) ($DVals[$x] / $DR['MaxVal'] * $VHeight))) . ' L' . ($LMarg + ($DR['Deals'] - 1) * $HSpacing) . ',' . ($TMarg + ($VHeight - (int) ($DVals[$x] / $DR['MaxVal'] * $VHeight))) . '" style="stroke: #C0C0C0; stroke-width: 1; fill: none;"/>';
                $Output .= '<path d="M' . $LMarg . ',' . ($TMarg + ($VHeight - (int) (($DVals[$x] - $DPrcs[$x]) / $DR['MaxVal'] * $VHeight))) . ' L' . ($LMarg + ($DR['Deals'] - 1) * $HSpacing) . ',' . ($TMarg + ($VHeight - (int) (($DVals[$x] - $DPrcs[$x]) / $DR['MaxVal'] * $VHeight))) . '" style="stroke: #C0C0C0; stroke-width: 1; fill: none;"/>';
            }
            $Output .= '<path d="M' . $LMarg . ',' . $TMarg . ' L' . ($LMarg + ($DR['Deals'] - 1) * $HSpacing) . ',' . $TMarg . '" style="stroke: #607080; stroke-width: 1; fill: none;"/>';
            $Output .= '<text x="' . ($LMarg + (400 - $RMarg) - 10) . '" y="' . ($TMarg + 5) . '" style="font-family: Arial; font-size:12px; stroke: #607080;">' . $DR['MaxVal'] . '</text>';
            $Output .= '<path d="M' . $LMarg . ',' . ($TMarg + $VHeight) . ' L' . ($LMarg + ($DR['Deals'] - 1) * $HSpacing) . ',' . ($TMarg + $VHeight) . '" style="stroke: #607080; stroke-width: 1; fill: none;"/>';
            $Output .= '<text x="' . ($LMarg + (400 - $RMarg) - 10) . '" y="' . ($TMarg + $VHeight + 5) . '" style="font-family: Arial; font-size:12px; stroke: #607080;">0</text>';
            for ($x = 0; $x < $DR['Deals']; $x++) {
                $Output .= '<path d="M' . ($LMarg + $x * $HSpacing) . ',' . $TMarg . ' L' . ($LMarg + $x * $HSpacing) . ',' . ($TMarg + $VHeight) . '" style="stroke: #607080; stroke-width: 1; fill: none;"/>';
            }
            //Text
            for ($x = 0; $x < $DR['Deals']; $x++) {
                $Output .= '<circle cx="' . ($LMarg + $x * $HSpacing) . '" cy="' . ($TMarg - 15) . '" r="8" style="fill:#000000"/>';
                $Output .= '<text x="' . ($LMarg + $x * $HSpacing) . '" y="' . ($TMarg - 11) . '" style="font-family: Arial; font-size:10px; fill: #FFFFFF; stroke: #FFFFFF;" text-anchor="middle">' . ($x + 1) . '</text>';
            }
            /*
            for ($x=0; $x<$DR['Deals']; $x++) {
              $Output .= '<text x="'.($LMarg+0+($x*$HSpacing)).'" y="'.($TMarg-10).'" transform="rotate(270 '.($LMarg+0+($x*$HSpacing)).','.($TMarg-10).')" style="font-family: Arial; font-size:12px;">'.date('Y.m.d', $DEnds[$x]).'</text>';
              $Output .= '<text x="'.($LMarg+10+($x*$HSpacing)).'" y="'.($TMarg-10).'" transform="rotate(270 '.($LMarg+10+($x*$HSpacing)).','.($TMarg-10).')" style="font-family: Arial; font-size:12px;">'.$SNams[$x].'</text>';
            }
            */
            //Values
            $Output .= '<path d="';
            for ($x = 0; $x < $DR['Deals']; $x++) {
                $Output .= ($x == 0 ? 'M' : 'L') . ($LMarg + $x * $HSpacing) . ',' . ($TMarg + ($VHeight - (int) ($DVals[$x] / $DR['MaxVal'] * $VHeight))) . ' ';
            }
            $Output .= '" style="stroke: #974d57; stroke-width: 2; fill: none;"/>';
            for ($x = 0; $x < $DR['Deals']; $x++) {
                $Output .= '<circle cx="' . ($LMarg + $x * $HSpacing) . '" cy="' . ($TMarg + ($VHeight - (int) ($DVals[$x] / $DR['MaxVal'] * $VHeight))) . '" r="4" style="fill:#974d57"/>';
            }
            //Prices
            $Output .= '<path d="';
            for ($x = 0; $x < $DR['Deals']; $x++) {
                $Output .= ($x == 0 ? 'M' : 'L') . ($LMarg + $x * $HSpacing) . ',' . ($TMarg + ($VHeight - (int) ($DPrcs[$x] / $DR['MaxVal'] * $VHeight))) . ' ';
            }
            $Output .= '" style="stroke: #448541; stroke-width: 2; fill: none;"/>';
            for ($x = 0; $x < $DR['Deals']; $x++) {
                $Output .= '<circle cx="' . ($LMarg + $x * $HSpacing) . '" cy="' . ($TMarg + ($VHeight - (int) ($DPrcs[$x] / $DR['MaxVal'] * $VHeight))) . '" r="4" style="fill:#448541"/>';
            }
            //Savings
            $Output .= '<path d="';
            for ($x = 0; $x < $DR['Deals']; $x++) {
                $Output .= ($x == 0 ? 'M' : 'L') . ($LMarg + $x * $HSpacing) . ',' . ($TMarg + ($VHeight - (int) (($DVals[$x] - $DPrcs[$x]) / $DR['MaxVal'] * $VHeight))) . ' ';
            }
            $Output .= '" style="stroke: #0000FF; stroke-width: 2; fill: none;"/>';
            for ($x = 0; $x < $DR['Deals']; $x++) {
                $Output .= '<circle cx="' . ($LMarg + $x * $HSpacing) . '" cy="' . ($TMarg + ($VHeight - (int) (($DVals[$x] - $DPrcs[$x]) / $DR['MaxVal'] * $VHeight))) . '" r="4" style="fill:#0000FF"/>';
                //$Output .= '<text x="'.($LMarg+3+($x*$HSpacing)).'" y="'.(($TMarg+($VHeight-((int)(($DVals[$x] - $DPrcs[$x]) / $DR['MaxVal'] * $VHeight))))-5).'" style="font-family: Arial; font-size:10px; fill: #0000FF;">'.(int)($DPrcs[$x] / $DVals[$x] * 100).'%</text>';
            }
            //Tables
            for ($x = 0; $x < $DR['Deals']; $x++) {
                if ($x % 2 != 0) {
                    $Output .= '<rect x="0" y="' . ($TMarg + $VHeight + 25 + $x * 20) . '" width="400" height="20" style="stroke-width: 0; fill: #F0F0F0;" />';
                }
            }
            $Output .= '<rect x="0" y="' . ($TMarg + $VHeight + 20) . '" rx="10" ry="10" width="400" height="' . (($DR['Deals'] + 1) * 20 + 20) . '" style="stroke: #C0C0C0; fill: none;" />';
            for ($x = 0; $x < $DR['Deals']; $x++) {
                if ((int) $DPrcs[$x] == $LPrc) {
                    $Output .= '<rect x="298" y="' . ($TMarg + $VHeight + 25 + $x * 20) . '" rx="5" ry="5" width="40" height="20" style="stroke: #009900; stroke-width: 1; fill: none;" />';
                }
                if ((int) $DVals[$x] - (int) $DPrcs[$x] == $MSav) {
                    $Output .= '<rect x="248" y="' . ($TMarg + $VHeight + 25 + $x * 20) . '" rx="5" ry="5" width="40" height="20" style="stroke: #009900; stroke-width: 1; fill: none;" />';
                }
                if ((int) (100 - $DPrcs[$x] / $DVals[$x] * 100) == $MSvP) {
                    $Output .= '<rect x="348" y="' . ($TMarg + $VHeight + 25 + $x * 20) . '" rx="5" ry="5" width="40" height="20" style="stroke: #009900; stroke-width: 1; fill: none;" />';
                }
                $Output .= '<text x="0" y="' . ($TMarg + $VHeight + 40 + $x * 20) . '" style="font-family: Arial; font-size:12px;">';
                $Output .= '<tspan x="5" style="font-weight: bold;">' . ($x + 1) . '.</tspan>';
                $Output .= '<tspan x="22">' . date('Y.m.d', $DEnds[$x]) . '</tspan>';
                $Output .= '<tspan x="90">' . $SNams[$x] . '</tspan>';
                $Output .= '<tspan x="200" style="fill: #974d57">' . $DVals[$x] . '</tspan>';
                $Output .= '<tspan x="240">-</tspan>';
                $Output .= '<tspan x="250" style="fill: #0000FF">' . ($DVals[$x] - $DPrcs[$x]) . '</tspan>';
                $Output .= '<tspan x="290">=</tspan>';
                $Output .= '<tspan x="300" style="fill: #448541">' . $DPrcs[$x] . '</tspan>';
                $Output .= '<tspan x="350" style="fill: #0000FF">(' . (int) (100 - $DPrcs[$x] / $DVals[$x] * 100) . '%)</tspan>';
                $Output .= '</text>';
            }
            $Output .= '<line x1="0" y1="' . ($TMarg + $VHeight + 20 + ($DR['Deals'] * 20 + 10)) . '" x2="400" y2="' . ($TMarg + $VHeight + 20 + ($DR['Deals'] * 20 + 10)) . '" style="stroke: #C0C0C0;" />';
            $Output .= '<text x="0" y="' . ($TMarg + $VHeight + 20 + ($DR['Deals'] * 20 + 10) + 20) . '" style="font-family: Arial; font-size:12px; font-weight: bold;">';
            $Output .= '<tspan x="20" style="font-weight: bold;">=</tspan>';
            $Output .= '<tspan x="200" style="fill: #974d57">' . (int) $DR['AvgVal'] . '</tspan>';
            $Output .= '<tspan x="240">-</tspan>';
            $Output .= '<tspan x="250" style="fill: #0000FF">' . ((int) $DR['AvgVal'] - (int) $DR['AvgPrc']) . '</tspan>';
            $Output .= '<tspan x="290">=</tspan>';
            $Output .= '<tspan x="300" style="fill: #448541">' . (int) $DR['AvgPrc'] . '</tspan>';
            $Output .= '<tspan x="350" style="fill: #0000FF">(' . (int) (100 - (int) $DR['AvgPrc'] / (int) $DR['AvgVal'] * 100) . '%)</tspan>';
            $Output .= '</text>';
            $Output .= '<image width="11" height="12" x="5" y="' . ($TMarg + $VHeight + 20 + ($DR['Deals'] * 20 + 10) + 8) . '" xlink:href="/IF/Avg.png" />';
            $Output .= '</svg>';
            $File = fopen($Filepath . $Filename, 'x');
            if ($File === false) {
                return SysLogIt('Error opening history graph for output.', StatusError);
            }
            fwrite($File, $Output);
            fclose($File);
            if (file_exists($Filepath . $Filename)) {
                if (is_null($DR['HID'])) {
                    if (!ExecCommand("INSERT INTO 2600_Store_History (StoreID, Filename, LastUpdated) VALUES (" . $SID . ", '" . Pacify($Filename) . "', " . date('YmdHis') . ");")) {
                        return SysLogIt('Error adding history graph for store with ID of ' . $SID . '. File ' . $Filename . ' is orphaned.', StatusError, ActionInsert);
                    }
                } else {
                    if (!ExecCommand("UPDATE 2600_Store_History SET Filename = '" . Pacify($Filename) . "', LastUpdated = " . date('YmdHis') . " WHERE HistoryID = " . $DR['HID'] . ";")) {
                        return SysLogIt('Error updating history graph for store with ID of ' . $SID . '. File ' . $Filename . ' is orphaned.', StatusError, ActionUpdate);
                    }
                }
                SysLogIt('Created history graph for store with ID of ' . $SID . '.', StatusInfo);
                return $Filename;
            }
            SysLogIt('Could not find generated history file for store with ID of ' . $SID . '.', StatusError);
            unlink($Filepath . $Filename);
        }
    } else {
        return SysLogIt('Could not find deals for history.', StatusError, ActionSelect);
    }
    return false;
}
Example #14
0
 public function GetDivisionData($SRID, $URL, $LID, $TZ, $Sub = false, $WebD = false)
 {
     global $DebugMode;
     list($Data, $DURL) = GetWebData('http://www.everybodybuys.com/deals.xml', null, null, 180);
     if ($Data === false) {
         return array(SysLogIt('Error getting XML data.', StatusError), null);
     }
     if ($DebugMode) {
         file_put_contents("EverybodyBuys.txt", $Data);
     }
     //Convert XML to string and then decode into array
     $XMLArray = json_decode(json_encode((array) simplexml_load_string($Data)), true);
     if (array_key_exists("item", $XMLArray) === false) {
         return array(SysLogIt('XML data structure not as anticipated.', StatusError), null);
     }
     //Create deals array
     $RData = array();
     foreach ($XMLArray["item"] as $ItemEntry) {
         //Reset flag and reinitialize array
         $Webdeal = false;
         $ADeal = array();
         //Save basic data
         $ADeal['DRID'] = $ItemEntry["id"];
         $ADeal['Title'] = $ItemEntry["title"];
         $ADeal['Descr'] = $ItemEntry["description"];
         $ADeal['URL'] = $ItemEntry["url"];
         $ADeal['Country'] = $ItemEntry["market_country"];
         $ADeal['Price'] = (double) $ItemEntry["price"];
         $ADeal['Value'] = (double) $ItemEntry["value"];
         $ADeal['Status'] = 0;
         $ADeal['SDate'] = strtotime($ItemEntry["starting_time"]);
         $ADeal['EDate'] = strtotime($ItemEntry["ending_time"]);
         $ADeal['VDate'] = 0;
         if (array_key_exists("restrictions", $ItemEntry)) {
             if (stripos($ItemEntry["restrictions"], 'Expires') !== false) {
                 $VDate = FindSubData($ItemEntry["restrictions"], 'Expires', ' ', '|', false);
                 if ($VDate !== false) {
                     $VDate = strtotime($VDate);
                     if ($VDate !== false) {
                         $ADeal['VDate'] = $VDate;
                     }
                 }
             }
         }
         $ADeal['StoreName'] = $ItemEntry["merchant"];
         //Ensure URL is present
         if (array_key_exists("merchant_url", $ItemEntry)) {
             $ADeal['Website'] = $ItemEntry["merchant_url"];
         } else {
             $ADeal['Website'] = null;
         }
         /*
         //If more than 10 regions, likely web deal
         if (count($ItemEntry["regionAvailability"]) > 10) $Webdeal = true;
         
         //Check if USA is listed in regions, but source is Canada
         foreach ($ItemEntry["regionAvailability"] as $Region) {
           if (($Region == 'USA') && ($ItemEntry["market_country"] == 'Canada')) {
             //Set as webdeal
             $Webdeal = true;
             //Set country to none (available anywhere)
             $ADeal['Country'] = false;
             break;
           }
         }
         */
         $Locations = array();
         if (count($ItemEntry["locations"]) == 0) {
             //No locations, treat as address-less webdeal
             $Locations[] = array(null, -1, -1);
         } else {
             //Add each address to the locations array
             foreach ($ItemEntry["locations"] as $Location) {
                 //Piece together address bits
                 $Address = '';
                 if (array_key_exists("address", $Location)) {
                     if ($Location["address"] != 'N/A') {
                         $Address .= $Location["address"] . ', ';
                     }
                 }
                 if (array_key_exists("city", $Location)) {
                     if ($Location["city"] != 'N/A') {
                         $Address .= $Location["city"] . ', ';
                     }
                 }
                 if (array_key_exists("state", $Location)) {
                     if ($Location["state"] != 'N/A') {
                         $Address .= $Location["state"] . ', ';
                     }
                 }
                 if (array_key_exists("zip", $Location)) {
                     if ($Location["zip"] != 'N/A') {
                         $Address .= $Location["zip"] . ', ';
                     }
                 }
                 if (array_key_exists("phone", $Location)) {
                     if ($Location["phone"] != 'N/A') {
                         $Address .= $Location["phone"] . ', ';
                     }
                 }
                 //Remove trailing comma and space
                 if ($Address == '') {
                     $Address = null;
                 } else {
                     $Address = substr($Address, 0, -2);
                 }
                 //$Address = str_ireplace(', Array', '', $Address);
                 if ($Webdeal) {
                     //If previously flagged as webdeal, put -1, -1 as coordinates
                     $Locations[] = array($Address, -1, -1);
                 } elseif (array_key_exists("latitude", $Location) && array_key_exists("longitude", $Location)) {
                     //Check if coordinates are listed
                     $Locations[] = array($Address, (double) $Location["latitude"], (double) $Location["longitude"]);
                 } else {
                     //Otherwise, put 0, 0 to trigger geolocation
                     $Locations[] = array($Address, 0, 0);
                 }
             }
         }
         //Save locations
         $ADeal['Locations'] = $Locations;
         //Add deal to array
         $RData[] = $ADeal;
     }
     return array(true, $RData);
 }
 public function GetDivisionData($SRID, $URL, $LID, $TZ, $Sub = false, $WebD = false)
 {
     global $DebugMode;
     list($Data, $DURL) = GetWebData('http://dealoftheday.redflagdeals.com/deal/' . $URL, null, 'dealoftheday.redflagdeals.com_splashIgnored=0');
     if ($Data === false) {
         return array(SysLogIt('Error getting web data.', StatusError), null);
     }
     if ($DebugMode) {
         file_put_contents("RedFlagDeals.txt", $Data);
     }
     $NewDeal = array("Title" => array('', 'og:title', 'content="', '"', false), "URL" => array('', 'data-url=', '"http://dealoftheday.redflagdeals.com', '?', false), "StoreName1" => array('', 'merchantAddress_192', '<b>', '</b>', false, true), "StoreName2" => array('', 'name="keywords" content=', '"', ',', false, true), "Website" => array('', 'merchantAddress_192', 'href="', '"', false, true), "PriceSale" => array(0, 'detailsPageDealInfoPrice', '"wrappedPriceValue">', '<', true), "PriceReg" => array(0, 'origPriceValue', '$', '<', true), "Description" => array('', 'prodDescriptionText', '>', '</div>', false), "Address" => array('', 'addresses.push(', '"', '"', false, true), "TimeL" => array('', ' DealTimeClass', '(', ')', false), "Expiry" => array('', 'expires', ' ', '<', false, true));
     if (!GetNewDealData($Data, $NewDeal)) {
         return array(SysLogIt('Error finding key deal information.', StatusError), null);
     }
     $StartDate = time();
     $EndDate = time();
     $DateParts = explode(',', $NewDeal['TimeL'][0]);
     if ($DateParts === false) {
         return array(SysLogIt('Could not determine deal end date.', StatusError), null);
     }
     if (trim($DateParts[0]) != 'null') {
         $EndDate += (int) substr(trim($DateParts[0]), 1, strlen(trim($DateParts[0])) - 2) * 24 * 60 * 60;
     }
     if (trim($DateParts[1]) != 'null') {
         $EndDate += (int) substr(trim($DateParts[1]), 1, strlen(trim($DateParts[1])) - 2) * 60 * 60;
     }
     if (trim($DateParts[2]) != 'null') {
         $EndDate += (int) substr(trim($DateParts[2]), 1, strlen(trim($DateParts[2])) - 2) * 60;
     }
     if (trim($DateParts[3]) != 'null') {
         $EndDate += (int) substr(trim($DateParts[3]), 1, strlen(trim($DateParts[3])) - 2);
     }
     if ($EndDate <= time()) {
         return array(SysLogIt('Could not determine deal end date.', StatusError), null);
     }
     $StoreName = '';
     if ($StoreName == '' && $NewDeal['StoreName1'][0] !== false) {
         $StoreName = $NewDeal['StoreName1'][0];
     }
     if ($StoreName == '' && $NewDeal['StoreName2'][0] !== false) {
         $StoreName = $NewDeal['StoreName2'][0];
     }
     if ($StoreName == '') {
         return array(SysLogIt('Could not determine store name.', StatusError), null);
     }
     $VExpiry = false;
     if ($NewDeal['Expiry'][0] !== false) {
         $VExpiry = $NewDeal['Expiry'][0];
         if (stripos($VExpiry, '(') !== false) {
             $VExpiry = substr($VExpiry, 0, stripos($VExpiry, '('));
         }
         $VExpiry = strtotime($VExpiry);
     }
     if ($VExpiry === false) {
         $VExpiry = 0;
     }
     //Initialize location array
     $Locations = array();
     //Look for first instance of addresses.push
     $Start = stripos($Data, 'addresses.push"');
     while ($Start !== false) {
         //Get first content between parenthesis immediately after addresses.push
         $New = FindData($Data, '("', '")', 2, 0, false, $Start, false);
         //If found, add to locations array
         if ($New !== false) {
             $Locations[] = array($New, 0, 0);
         }
         //Check for next instance, starting at previous location + 20
         $Start = stripos($Data, 'addresses.push', $Start + 20);
     }
     //If no addresses were found, add null address
     if (count($Locations) == 0) {
         $Locations[] = array(null, 0, 0);
     }
     $Website = null;
     if ($NewDeal['Website'][0] !== false) {
         $Website = $NewDeal['Website'][0];
     }
     $MoreDeals = array();
     $Start = stripos($Data, 'id="sideDealsSection"');
     while ($Start !== false) {
         $New = FindData($Data, 'http://dealoftheday.redflagdeals.com/deal/', '"', 42, 0, false, $Start, false);
         if ($New !== false) {
             $MoreDeals[] = $New;
         }
         $Start = stripos($Data, 'id="sideDealsSection"', $Start + 20);
     }
     $RData = array();
     $RData['DRID'] = $URL;
     $RData['Title'] = $NewDeal['Title'][0];
     $RData['Descr'] = $NewDeal['Description'][0];
     $RData['URL'] = 'http://dealoftheday.redflagdeals.com' . $NewDeal['URL'][0];
     $RData['Price'] = (double) $NewDeal['PriceSale'][0];
     $RData['Value'] = (double) $NewDeal['PriceReg'][0];
     $RData['Status'] = 0;
     $RData['SDate'] = $StartDate;
     $RData['EDate'] = $EndDate;
     $RData['VDate'] = $VExpiry;
     $RData['StoreName'] = $StoreName;
     $RData['Website'] = $Website;
     $RData['Locations'] = $Locations;
     if (count($MoreDeals) > 0) {
         $RData['Deals'] = $MoreDeals;
     }
     return array(true, array($RData));
 }
Example #16
0
$UserName = '';
$UserSort = 0;
$UserFlags = 0;
$SessionID = 0;
$SessionCoords = array();
$LanguageID = 0;
require_once './Code/Cookies.php';
require_once './Code/DB.php';
require_once './Code/Logging.php';
require_once './Code/Validator.php';
ReadCookies();
if (!empty($_GET)) {
    if (is_array($_GET)) {
        foreach ($_GET as $ID => $Value) {
            if (is_numeric($ID)) {
                OpenDB();
                list($QR, $DR, $T) = QuerySingle("SELECT D.DealURL, DS.DealSourceRefCode\n                                                FROM 4000_Deals D\n                                               INNER JOIN 4100_Deal_Sources DS ON DS.DealSourceID = D.DealSourceID\n                                               WHERE D.DealID = " . (int) $ID . ";");
                if ($QR > 0) {
                    if (!ExecCommand("INSERT INTO 4200_Deal_Clickthroughs (DealID, UserID, ClickDate) VALUES (" . (int) $ID . "," . $UserID . "," . date('YmdHis') . ");")) {
                        SysLogIt('Error inserting clickthrough data.', StatusError, ActionInsert);
                    }
                    header('Location: ' . $DR['DealURL'] . $DR['DealSourceRefCode']);
                    exit;
                }
                CloseDB();
                break;
            }
        }
    }
}
header('Location: /index.php');
Example #17
0
 public function GetDivisionData($SRID, $URL, $LID, $TZ, $Sub = false, $WebD = false)
 {
     global $DebugMode;
     //There is an automatic forward to NYC, http://www.dealon.com/new-york/deal/today/
     //What does $Sub look like, and $URL
     //I am still having issues with chr(13) etc. Ask Jonathan
     //Lets go over the date conversion, +1 with JavaScript needs checking
     if ($Sub) {
         list($Data, $DURL) = GetWebData('http://www.dealon.com/' . $URL);
     } else {
         list($Data, $DURL) = GetWebData('http://www.dealon.com/' . $URL . '/deal/today');
     }
     if ($Data === false) {
         return array(SysLogIt('Error getting web data.', StatusError), null);
     }
     if ($DebugMode) {
         file_put_contents("DealOn.txt", "http://www.dealon.com/" . $URL . chr(13) . chr(10) . chr(13) . chr(10) . $Data);
     }
     if (stripos($Data, 'class="page-title"') !== false) {
         return array(true, false);
     }
     $NewDeal = array("ID" => array('', 'class="deal-meter-buy"', 'href="/user/buy', '"', false), "Title" => array('', 'id="deal-title"', '>', '<', false), "Website" => array('', 'class="deal-details-right-column"', 'href="', '"', false, true), "PriceSale" => array(0, 'class="deal-meter-buy"', '$', '<', true), "PriceReg" => array(0, 'class="deal-discount"', '$', '<', true), "StoreName" => array('', '<h2>Company Information</h2>', '>', '<', false), "Description" => array('', '<h2>About This Deal</h2>', '<p>', '</div>', false), "Address" => array('', '<h2>Company Information</h2>', '<br/>', '<a', false, true), "EndDate" => array('', "('#countdown')", 'UTCDate(', ')', false));
     if (!GetNewDealData($Data, $NewDeal)) {
         return array(SysLogIt('Error finding key deal information.', StatusError), null);
     }
     $StartDate = time();
     list($DateO, $DateY, $DateM, $DateD, $DateH, $DateN, $DateS, $DateI) = explode(',', $NewDeal['EndDate'][0]);
     $EndDate = mktime((int) $DateH + (-5 - (int) $DateO), (int) $DateN, (int) $DateS, (int) $DateM + 1, (int) $DateD, (int) $DateY);
     //Need to Add + 1, because JavaScript counts 0 to 11
     //Based on their plugin usage http://keith-wood.name/countdown.html
     if ($EndDate <= time()) {
         return array(SysLogIt('Could not determine deal end date.', StatusError), null);
     }
     $VExpiry = FindData($Data, 'Expiration Date:', '<', 17, 0, false, 0, false);
     $VExpiry = $VExpiry === false ? 0 : strtotime($VExpiry);
     if ($VExpiry === false) {
         $VExpiry = 0;
     }
     $Website = null;
     if ($NewDeal['Website'][0] !== false) {
         $Website = $NewDeal['Website'][0];
     }
     if ($Website == '') {
         $Website = null;
     }
     $Coords = array(0, 0);
     $Address = null;
     if ($NewDeal['Address'][0] !== false) {
         $Address = CleanHTML($NewDeal['Address'][0]);
     }
     if ($Address == '') {
         $Address = null;
     }
     if ($Address == 'Visit Online:') {
         $Address = null;
         $Coords = array(-1, -1);
     }
     $MoreDeals = array();
     $Start = stripos($Data, 'class="bonus-deals"');
     while ($Start !== false) {
         $ID = FindData($Data, 'href="', '"', 6, 0, false, $Start, false);
         //What is 24, 0 for??
         if ($ID !== false) {
             $MoreDeals[] = $ID;
         }
         $Start = stripos($Data, '											<h3>', $Start + 20);
     }
     $RData = array();
     $RData['DRID'] = $NewDeal['ID'][0];
     $RData['Title'] = $NewDeal['Title'][0];
     $RData['Descr'] = $NewDeal['Description'][0];
     if ($Sub) {
         $RData['URL'] = 'http://www.dealon.com' . $URL;
     } else {
         $RData['URL'] = 'http://www.dealon.com/' . $URL . $NewDeal['ID'][0];
     }
     $RData['Price'] = (double) $NewDeal['PriceSale'][0];
     $RData['Value'] = (double) $NewDeal['PriceReg'][0];
     $RData['Status'] = 0;
     $RData['SDate'] = $StartDate;
     $RData['EDate'] = $EndDate;
     $RData['VDate'] = $VExpiry;
     $RData['StoreName'] = $NewDeal['StoreName'][0];
     $RData['Website'] = $Website;
     $RData['Locations'] = array(array($Address, $Coords[0], $Coords[1]));
     if (count($MoreDeals) > 0) {
         $RData['Deals'] = $MoreDeals;
     }
     return array(true, array($RData));
 }
Example #18
0
 public function GetDivisionData($SRID, $URL, $LID, $TZ, $Sub = false, $WebD = false)
 {
     global $DebugMode;
     list($Data, $DURL) = GetWebData('http://www.dealsnoop.com' . $URL);
     if ($Data === false) {
         return array(SysLogIt('Error getting web data.', StatusError), null);
     }
     if ($DebugMode) {
         file_put_contents("Dealsnoop.txt", 'http://www.dealsnoop.com' . $URL . chr(13) . chr(10) . chr(13) . chr(10) . $Data);
     }
     if (stripos($Data, 'coming soon to your city') !== false) {
         return array(true, false);
     }
     $NewDeal = array("ID" => array(0, 'id="deal_id"', 'value="', '"', true), "Title" => array('', 'og:title', 'content="', '"', false), "Website" => array('', 'id="deal-address"', 'href="', '"', false, true), "PriceSale" => array(0, 'id="deal-price"', '$', '<', true), "PriceReg" => array(0, 'id="treat-deal-value"', '$', '<', true), "StoreName" => array('', 'class="caps"', '>', '<', false), "Description" => array('', 'id="about-this-deal"', '>', '</p>', false), "Address" => array('', 'id="googlemap"', 'value="', '"', false, true), "EndY" => array(0, 'id="deal-expyear"', 'value="', '"', true), "EndM" => array(0, 'id="deal-expmonth"', 'value="', '"', true), "EndD" => array(0, 'id="deal-expday"', 'value="', '"', true), "EndH" => array(0, 'id="deal-exphour"', 'value="', '"', true), "EndN" => array(0, 'id="deal-expmin"', 'value="', '"', true), "EndS" => array(0, 'id="deal-expsec"', 'value="', '"', true));
     if (!GetNewDealData($Data, $NewDeal)) {
         return array(SysLogIt('Error finding key deal information.', StatusError), null);
     }
     $StartDate = time();
     $EndDate = mktime((int) $NewDeal['EndH'][0], (int) $NewDeal['EndN'][0], (int) $NewDeal['EndS'][0], (int) $NewDeal['EndM'][0] + 1, (int) $NewDeal['EndD'][0], (int) $NewDeal['EndY'][0]);
     if ($EndDate <= time()) {
         return array(SysLogIt('Could not determine deal end date.', StatusError), null);
     }
     $VExpiry = FindSubData($Data, 'id="deal-fp-description"', '<p>', 'expiry', false);
     if ($VExpiry !== false) {
         if (strripos($VExpiry, '.') !== false) {
             $VExpiry = trim(substr($VExpiry, strripos($VExpiry, '.') + 1));
         }
         if ($VExpiry !== false) {
             $VExpiry = strtotime('+' . $VExpiry);
         }
     }
     if ($VExpiry === false) {
         $VExpiry = 0;
     }
     $Website = null;
     if ($NewDeal['Website'][0] !== false) {
         $Website = $NewDeal['Website'][0];
     }
     $Address = null;
     if ($NewDeal['Address'][0] !== false) {
         $Address = $NewDeal['Address'][0];
     }
     $Locations = array();
     $Locations[] = array($Address, 0, 0);
     $MoreDeals = array();
     $Start = stripos($Data, 'class="more-deals-link"');
     while ($Start !== false) {
         $ID = FindData($Data, '../treats/?dsdeal=', "'", 18, 0, true, $Start, false);
         if ($ID !== false) {
             $MoreDeals[] = '/treats/?dsdeal=' . $ID;
         }
         $Start = stripos($Data, 'class="more-deals-link"', $Start + 20);
     }
     $RData = array();
     $RData['DRID'] = (int) $NewDeal['ID'][0];
     $RData['Title'] = $NewDeal['Title'][0];
     $RData['Descr'] = $NewDeal['Description'][0];
     $RData['URL'] = 'http://www.dealsnoop.com/treats/?dsdeal=' . (int) $NewDeal['ID'][0];
     $RData['Price'] = (double) $NewDeal['PriceSale'][0];
     $RData['Value'] = (double) $NewDeal['PriceReg'][0];
     $RData['Status'] = 0;
     $RData['SDate'] = $StartDate;
     $RData['EDate'] = $EndDate;
     $RData['VDate'] = $VExpiry;
     $RData['StoreName'] = $NewDeal['StoreName'][0];
     $RData['Website'] = $Website;
     $RData['Locations'] = $Locations;
     if (count($MoreDeals) > 0) {
         $RData['Deals'] = $MoreDeals;
     }
     return array(true, array($RData));
 }
Example #19
0
 public function GetDivisionData($SRID, $URL, $LID, $TZ, $Sub = false, $WebD = false)
 {
     global $DebugMode;
     list($Data, $DURL) = GetWebData('http://www.stealthedeal.com/' . $URL);
     if ($Data === false) {
         return array(SysLogIt('Error getting web data.', StatusError), null);
     }
     if ($DebugMode) {
         file_put_contents("StealTheDeal.txt", $Data);
     }
     if (stripos($Data, 'og:url') === false) {
         return array(true, false);
     }
     $NewDeal = array("ID" => array(0, 'og:url', 'stealthedeal.com/deal/', '"', true), "Title" => array('', 'og:title', 'content="', '"', false), "PriceSale" => array(0, 'dealPrice', '$', '<', true), "PriceReg" => array(0, '"valueTitle"', '$', '<', true), "Website" => array('', 'Merchant website:', 'href="', '"', false, true), "Description" => array('', 'DescriptionHtml Start', '>', '<!', false), "Address" => array('', 'maps.google', ';q=', '&', false, true), "Coords" => array('', 'maps.google', ';ll=', '&', false, true), "Address2" => array('', 'DetailsHtml', '</li>', '</ul>', false, true), "TZone" => array(0, 'TzOffset', '=', ';', true), "EndDate" => array('', 'TargetDate =', '"', '"', false));
     if (!GetNewDealData($Data, $NewDeal)) {
         return array(SysLogIt('Error finding key deal information.', StatusError), null);
     }
     $StartDate = time();
     $EndDate = strtotime($NewDeal['EndDate'][0]);
     $EndDate += -(((int) $NewDeal['TZone'][0] + 5) * 60 * 60);
     if ($EndDate <= time()) {
         return array(SysLogIt('Could not determine deal end date.', StatusError), null);
     }
     $StoreName = '';
     if (stripos($NewDeal['Title'][0], ' from ') !== false) {
         $StoreName = substr($NewDeal['Title'][0], stripos($NewDeal['Title'][0], ' from ') + 6);
     } elseif (stripos($NewDeal['Title'][0], ' at ') !== false) {
         $StoreName = substr($NewDeal['Title'][0], stripos($NewDeal['Title'][0], ' at ') + 4);
     } elseif (stripos($NewDeal['Title'][0], ' by ') !== false) {
         $StoreName = substr($NewDeal['Title'][0], stripos($NewDeal['Title'][0], ' by ') + 4);
     } elseif (stripos($NewDeal['Title'][0], ' to ') !== false) {
         $StoreName = substr($NewDeal['Title'][0], stripos($NewDeal['Title'][0], ' to ') + 4);
     } elseif (stripos($NewDeal['Title'][0], 'for a') !== false && stripos($NewDeal['Title'][0], 'voucher') !== false) {
         $StoreName = substr($NewDeal['Title'][0], stripos($NewDeal['Title'][0], 'for a') + 5);
         $StoreName = trim(substr($StoreName, 0, stripos($NewDeal['Title'][0], 'voucher')));
         if (substr($StoreName, 0, 2) == 'n ') {
             $StoreName = trim(substr($StoreName, 2));
         }
     } elseif (stripos($NewDeal['Title'][0], ' with ') !== false) {
         $StoreName = substr($NewDeal['Title'][0], stripos($NewDeal['Title'][0], ' with ') + 6);
     }
     if (stripos($StoreName, '(') !== false) {
         $StoreName = trim(substr($StoreName, 0, stripos($StoreName, '(') - 1));
     }
     if ($StoreName == '') {
         return array(SysLogIt('Could not determine store name.', StatusError), null);
     }
     $VExpiry = 0;
     if (stripos($Data, 'Please use within') !== false) {
         $VExpiry = FindData($Data, 'Please use within', 'of', 17, 0, false, 0, false);
         if ($VExpiry !== false) {
             $VExpiry = strtotime('+' . $VExpiry);
         }
     } elseif (stripos($Data, 'Expires on') !== false) {
         $VExpiry = FindData($Data, 'Expires on', '<', 10, 0, false, 0, false);
         if ($VExpiry !== false) {
             $VExpiry = strtotime($VExpiry);
         }
     }
     if ($VExpiry === false) {
         $VExpiry = 0;
     }
     $Address = $NewDeal['Address'][0] === false ? null : str_ireplace('+', ' ', $NewDeal['Address'][0]);
     if (is_null($Address) && $NewDeal['Address2'][0] !== false) {
         $Address = CleanHTML(str_ireplace('map it', '', $NewDeal['Address2'][0]));
     }
     if ($Address == '') {
         $Address = null;
     }
     $Coords = array(0, 0);
     if ($NewDeal['Coords'][0] !== false) {
         $Coords = explode(',', $NewDeal['Coords'][0]);
     }
     if ($Coords === false || count($Coords) != 2) {
         $Coords = array(0, 0);
     }
     $Last = (int) $NewDeal['ID'][0];
     $MoreDeals = array();
     $Start = stripos($Data, 'class="sideBox sideDeal"');
     if ($Start !== false) {
         $Start = stripos($Data, '/Deal/', $Start);
     }
     while ($Start !== false) {
         $New = FindData($Data, "/Deal/", '"', 6, 0, true, $Start, false);
         if ($New !== false && $New > 0 && $New != $Last) {
             $MoreDeals[] = '/' . $URL . '/Deal/' . $New;
             $Last = $New;
         }
         $Start = stripos($Data, "/Deal/", $Start + 20);
     }
     $RData = array();
     $RData['DRID'] = (int) $NewDeal['ID'][0];
     $RData['Title'] = $NewDeal['Title'][0];
     $RData['Descr'] = $NewDeal['Description'][0];
     $RData['URL'] = 'http://www.stealthedeal.com/' . $URL;
     $RData['Price'] = (double) $NewDeal['PriceSale'][0];
     $RData['Value'] = (double) $NewDeal['PriceReg'][0];
     $RData['Status'] = 0;
     $RData['SDate'] = $StartDate;
     $RData['EDate'] = $EndDate;
     $RData['VDate'] = $VExpiry;
     $RData['StoreName'] = $StoreName;
     $RData['Website'] = $NewDeal['Website'][0];
     $RData['Locations'] = array(array($Address, $Coords[0], $Coords[1]));
     if (count($MoreDeals) > 0) {
         $RData['Deals'] = $MoreDeals;
     }
     return array(true, array($RData));
 }
Example #20
0
 public function GetDivisionData($SRID, $URL, $LID, $TZ, $Sub = false, $WebD = false)
 {
     global $DebugMode;
     list($Data, $DURL) = GetWebData('http://www.kijijideals.ca/deals/' . $URL);
     if ($Data === false) {
         return array(SysLogIt('Error getting web data.', StatusError), null);
     }
     if ($DebugMode) {
         file_put_contents("Kijiji.txt", "http://www.kijijideals.ca/deals/" . $URL . chr(13) . chr(10) . chr(13) . chr(10) . $Data);
     }
     if (stripos($Data, '/buy"') === false) {
         return array(true, false);
     }
     $NewDeal = array("ID" => array('', 'id="toDeal"', 'kijijideals.ca/deals/', '"', false), "Title" => array('', 'id="toDeal">', '>', '</a>', false), "Website" => array('', 'class="location_box"', 'href="', '"', false, true), "PriceSale" => array(0, 'class="price"', '$', '<', true), "PriceReg" => array(0, 'class="value"', '$', '<', true), "StoreName" => array('', 'class="location_box"', '<p>', '<', false), "Description" => array('', 'About this deal', '<p>', '</p>', false), "Address" => array('', 'maps.google.com', '?q=', '"', false, true), "EndDate" => array('', 'ready(function()', 'setCountdown("', '"', false));
     if (!GetNewDealData($Data, $NewDeal)) {
         return array(SysLogIt('Error finding key deal information.', StatusError), null);
     }
     $StartDate = time();
     $EndDate = strtotime($NewDeal['EndDate'][0]);
     if ($EndDate === false) {
         return array(SysLogIt('Could not determine deal end date.', StatusError), null);
     }
     if ($EndDate < time()) {
         return array(true, false);
     }
     $VExpiry = FindData($Data, '<p>Expires', 'from', 11, 0, false, 0, false);
     if ($VExpiry !== false) {
         $VExpiry = strtotime('+' . $VExpiry);
     }
     if ($VExpiry === false) {
         $VExpiry = 0;
     }
     $Website = null;
     if ($NewDeal['Website'][0] !== false) {
         $Website = $NewDeal['Website'][0];
     }
     $Address = null;
     if ($NewDeal['Address'][0] !== false) {
         $Address = CleanHTML($NewDeal['Address'][0]);
     }
     if ($Address == '') {
         $Address = null;
     }
     $MoreDeals = array();
     $Start = stripos($Data, 'class="dealBox ');
     while ($Start !== false) {
         $ID = FindData($Data, 'href="http://www.kijijideals.ca/deals/', '"', 38, 0, false, $Start, false);
         if ($ID !== false) {
             $MoreDeals[] = $ID;
         }
         $Start = stripos($Data, 'class="dealBox ', $Start + 20);
     }
     $RData = array();
     $RData['DRID'] = $NewDeal['ID'][0];
     $RData['Title'] = CleanHTML(str_ireplace("Today's Deal:", "", $NewDeal['Title'][0]));
     $RData['Descr'] = $NewDeal['Description'][0];
     $RData['URL'] = 'http://www.kijijideals.ca/deals/' . $NewDeal['ID'][0];
     $RData['Price'] = (double) $NewDeal['PriceSale'][0];
     $RData['Value'] = (double) $NewDeal['PriceReg'][0];
     $RData['Status'] = 0;
     $RData['SDate'] = $StartDate;
     $RData['EDate'] = $EndDate;
     $RData['VDate'] = $VExpiry;
     $RData['StoreName'] = $NewDeal['StoreName'][0];
     $RData['Website'] = $Website;
     $RData['Locations'] = array(array($Address, 0, 0));
     if (count($MoreDeals) > 0) {
         $RData['Deals'] = $MoreDeals;
     }
     return array(true, array($RData));
 }
Example #21
0
 public function GetDivisionData($SRID, $URL, $LID, $TZ, $Sub = false, $WebD = false)
 {
     global $DebugMode;
     if ($Sub) {
         list($Data, $DURL) = GetWebData('http://www.swarmjam.com/waf.srv/sj/sj/cn/auction_ActionProdDet?ONSUCCESS=swarmofferdet.jsp&PRODID=' . $URL);
     } else {
         list($Data, $DURL) = GetWebData('http://www.swarmjam.com/waf.srv/sj/sj/cn/auction_ActionProdCat?ONSUCCESS=home.jsp&ONERR1=home.jsp&ONERR2=home.jsp&CATID=' . $URL . '#');
     }
     if ($Data === false) {
         return array(SysLogIt('Error getting web data.', StatusError), null);
     }
     if ($DebugMode) {
         file_put_contents("SwarmJam.txt", $Data);
     }
     if (stripos($Data, 'href="https://') === false) {
         return array(true, false);
     }
     $NewDeal = array("ID" => array(0, 'href="https://', '&PRODID=', '"', true), "Title" => array('', 'class="offerTitle"', '>', '</div>', false), "VendorID" => array(0, 'venddet.jsp', '&ONERR2=venddet.jsp&VENDID=', '"', true), "Website" => array('', '<p><a href="http:', '//', '"', false, true), "PriceSale" => array(0, '>Buy', '$', '<', true), "PriceReg" => array(0, '>Value:', '$', '<', true, true), "Savings" => array(0, '>Buy', '(', '%', true, true), "Description" => array('', 'More About This Deal', '<p>', '</p>', false), "AdrA" => array('', chr(9) . 'v_address =', '"', '"', false, true), "AdrC" => array('', chr(9) . 'v_city =', '"', '"', false, true), "AdrS" => array('', chr(9) . 'v_state =', '"', '"', false, true), "AdrP" => array('', chr(9) . 'v_state =', '</script>', '</p>', false, true), "EndD" => array(0, 'id="cx-cnt-int-day"', '>', '<', true, true), "EndH" => array(0, 'id="cx-cnt-int-hou"', '>', '<', true, true), "EndM" => array(0, 'id="cx-cnt-int-min"', '>', '<', true, true), "EndS" => array(0, 'id="cx-cnt-int-sec"', '>', '<', true, true), "Expiry" => array('', 'Expiry Date:', 'document.write("', '")', false, true));
     if (!GetNewDealData($Data, $NewDeal)) {
         return array(SysLogIt('Error finding key deal information.', StatusError), null);
     }
     list($SubData, $DURL) = GetWebData('http://www.swarmjam.com/waf.srv/sj/sj/cn/auction_ActionProdVend?ONSUCCESS=venddet.jsp&ONERR2=venddet.jsp&VENDID=' . (int) $NewDeal['VendorID'][0]);
     if ($SubData === false) {
         return array(SysLogIt('Error retrieving vendor information.', StatusError), null);
     }
     $StoreName = FindSubData($SubData, 'id="ctyx-content"', 'About ', '<');
     if ($StoreName === false) {
         return array(SysLogIt('Error finding vendor information.', StatusError), null);
     }
     if ($NewDeal['PriceReg'][0] !== false) {
         $PriceReg = (double) $NewDeal['PriceReg'][0];
     } elseif ($NewDeal['Savings'][0] !== false) {
         $PriceReg = $NewDeal['PriceSale'][0] / ((100 - $NewDeal['Savings'][0]) / 100);
     } else {
         return array(SysLogIt('Error determining regular price.', StatusError), null);
     }
     $StartDate = time();
     $EndDate = time();
     if ($NewDeal['EndD'][0] !== false) {
         $EndDate += (int) $NewDeal['EndD'][0] * 24 * 60 * 60;
     }
     if ($NewDeal['EndH'][0] !== false) {
         $EndDate += (int) $NewDeal['EndH'][0] * 60 * 60;
     }
     if ($NewDeal['EndM'][0] !== false) {
         $EndDate += (int) $NewDeal['EndM'][0] * 60;
     }
     if ($NewDeal['EndS'][0] !== false) {
         $EndDate += (int) $NewDeal['EndS'][0];
     }
     if ($EndDate <= time()) {
         return array(SysLogIt('Could not determine deal end date.', StatusError), null);
     }
     $VExpiry = false;
     if ($NewDeal['Expiry'][0] !== false) {
         $VExpiry = strtotime(str_ireplace('at', '', $NewDeal['Expiry'][0]));
     }
     if ($VExpiry === false) {
         $VExpiry = 0;
     }
     $Coords = array(0, 0);
     $Locations = array();
     $Address = null;
     $LocURL = FindSubData($Data, 'Participating Locations', '>', 'Click to view locations', false);
     if ($LocURL !== false) {
         $LocURL = FindSubData($LocURL, 'href=', '"', '"', false);
         if ($LocURL !== false) {
             list($SubData, $DURL) = GetWebData($LocURL);
             if ($SubData !== false) {
                 $Start = stripos($SubData, 'class="location"');
                 while ($Start !== false) {
                     $NewAdr = FindData($SubData, chr(9) . 'v_address = "', '"', 14, 0, false, $Start, false);
                     $NewCty = FindData($SubData, chr(9) . 'v_city = "', '"', 11, 0, false, $Start, false);
                     $NewPro = FindData($SubData, chr(9) . 'v_state = "', '"', 12, 0, false, $Start, false);
                     $Address = '';
                     if ($NewAdr !== false) {
                         $Address .= $NewAdr . ', ';
                     }
                     if ($NewCty !== false) {
                         $Address .= $NewCty . ', ';
                     }
                     if ($NewPro !== false) {
                         $Address .= $NewPro . ', ';
                     }
                     $Address = rtrim(trim($Address), ',');
                     $Address = CleanHTML($Address);
                     if ($Address !== '') {
                         $Locations[] = array($Address, 0, 0);
                     }
                     $Start = stripos($SubData, 'class="location"', $Start + 20);
                 }
             }
         }
     } else {
         $Address = '';
         if ($NewDeal['AdrA'][0] !== false) {
             $Address .= $NewDeal['AdrA'][0] . ', ';
             if ($NewDeal['AdrA'][0] == 'Online Vendor') {
                 $Coords = array(-1, -1);
             }
         }
         if ($NewDeal['AdrC'][0] !== false) {
             $Address .= $NewDeal['AdrC'][0] . ', ';
         }
         if ($NewDeal['AdrS'][0] !== false) {
             $Address .= $NewDeal['AdrS'][0] . ', ';
         }
         if ($NewDeal['AdrP'][0] !== false) {
             $Address .= $NewDeal['AdrP'][0] . ', ';
         }
         $Address = rtrim(trim($Address), ',');
         $Address = CleanHTML($Address);
         if ($Address == '') {
             $Address = null;
         }
     }
     if (count($Locations) == 0) {
         $Locations[] = array($Address, $Coords[0], $Coords[1]);
     }
     $Website = null;
     if ($NewDeal['Website'][0] !== false) {
         $Website = 'http://' . $NewDeal['Website'][0];
     }
     $MoreDeals = array();
     $Start = stripos($Data, 'class="side-details"');
     while ($Start !== false) {
         $New = FindData($Data, "&PRODID=", '"', 8, 0, true, $Start, false);
         if ($New !== false && $New > 0) {
             $MoreDeals[] = $New;
         }
         $Start = stripos($Data, 'class="side-details"', $Start + 20);
     }
     $RData = array();
     $RData['DRID'] = $NewDeal['ID'][0];
     $RData['Title'] = $NewDeal['Title'][0];
     $RData['Descr'] = $NewDeal['Description'][0];
     $RData['URL'] = 'http://www.swarmjam.com/waf.srv/sj/sj/cn/auction_ActionProdDet?ONSUCCESS=swarmofferdet.jsp&PRODID=' . $NewDeal['ID'][0];
     $RData['Price'] = (double) $NewDeal['PriceSale'][0];
     $RData['Value'] = $PriceReg;
     $RData['Status'] = 0;
     $RData['SDate'] = $StartDate;
     $RData['EDate'] = $EndDate;
     $RData['VDate'] = $VExpiry;
     $RData['StoreName'] = $StoreName;
     $RData['Website'] = $Website;
     $RData['Locations'] = $Locations;
     if (count($MoreDeals) > 0) {
         $RData['Deals'] = $MoreDeals;
     }
     return array(true, array($RData));
 }
Example #22
0
 public function GetDivisionData($SRID, $URL, $LID, $TZ, $Sub = false, $WebD = false)
 {
     global $DebugMode;
     if ($Sub) {
         list($Data, $DURL) = GetWebData('https://www.webpiggy.com/deals/side_deal/' . $URL, null);
     } else {
         list($Data, $DURL) = GetWebData('https://www.webpiggy.com/' . $URL, null);
     }
     if ($Data === false) {
         return array(SysLogIt('Error getting web data.', StatusError), null);
     }
     if ($DebugMode) {
         file_put_contents("WebPiggy.txt", $Data);
     }
     if (stripos($Data, 'id="deal_action"') === false) {
         return array(true, false);
     }
     $NewDeal = array("ID" => array(0, 'id="deal_action"', '/deals/buy/', '"', true), "Title" => array('', 'id="centre_title">', '">', '<', false), "Website1" => array('', 'deal_desc_col2', '<br/><a href="http://', '"', false, true), "Website2" => array('', 'deal_desc_col2', '<a href="', '"target="_blank"', false, true), "PriceSale" => array(0, 'id="deal_price"', '$', '<', true), "PriceReg" => array(0, '<li>Value', '$', '<', true), "StoreName1" => array('', '<br/><a href="http://', '>', '<', false, true), "StoreName2" => array('', 'id="deal_desc_col2"', '"_blank">', '<', false, true), "Description" => array('', 'deal_desc_col2', '<p>', '</p>', false), "Ends" => array('', '<p>', 'var dthen = new Date("', '");', false), "Address2" => array('', 'maps.google.ca', '&hnear=', '&', false, true), "Address1" => array('', 'maps.google.ca', '&q=', '&', false, true));
     if (!GetNewDealData($Data, $NewDeal)) {
         return array(SysLogIt('Error finding key deal information.', StatusError), null);
     }
     $StartDate = time();
     $EndDate = strtotime($NewDeal['Ends'][0]);
     if ($EndDate <= time()) {
         return array(SysLogIt('Could not determine deal end date.', StatusError), null);
     }
     $VExpiry = FindData($Data, 'Expiry ', '.', 7, 0, false, 0, false);
     if ($VExpiry !== false) {
         $VExpiry = strtotime($VExpiry);
     }
     if ($VExpiry === false) {
         $VExpiry = 0;
     }
     $Address = '';
     if ($NewDeal['Address1'][0] !== false) {
         $Address = CleanHTML(str_replace('+', ' ', $NewDeal['Address1'][0]));
     }
     if ($Address == '' && $NewDeal['Address2'][0] !== false) {
         $Address = CleanHTML(str_replace('+', ' ', $NewDeal['Address2'][0]));
     }
     if ($Address == '') {
         $Address = null;
     }
     $Website = null;
     if ($NewDeal['Website1'][0] !== false) {
         $Website = 'http://' . $NewDeal['Website1'][0];
     } elseif ($NewDeal['Website2'][0] !== false) {
         $Website = 'http://' . $NewDeal['Website2'][0];
     }
     if ($Website == '') {
         $Website = null;
     }
     $StoreName = '';
     if ($NewDeal['StoreName1'][0] !== false) {
         $StoreName = 'http://' . $NewDeal['StoreName1'][0];
     } elseif ($NewDeal['StoreName2'][0] !== false) {
         $StoreName = 'http://' . $NewDeal['StoreName2'][0];
     }
     if ($StoreName == '') {
         return array(SysLogIt('Could not determine store name.', StatusError), null);
     }
     $MoreDeals = array();
     $Start = stripos($Data, 'id="side_deal"');
     if ($Start !== false) {
         $Start = stripos($Data, 'class="deal_talk_content"', $Start);
         while ($Start !== false) {
             $New = FindData($Data, 'href="/deals/side_deal/', '"', 23, 0, true, $Start, false);
             if ($New !== false && $New > 0) {
                 $MoreDeals[] = $New;
             }
             $Start = stripos($Data, 'class="deal_talk_content"', $Start + 20);
         }
     }
     $RData = array();
     $RData['DRID'] = $NewDeal['ID'][0];
     $RData['Title'] = $NewDeal['Title'][0];
     $RData['Descr'] = $NewDeal['Description'][0];
     $RData['URL'] = 'https://www.webpiggy.com/deals/side_deal/' . $NewDeal['ID'][0];
     $RData['Price'] = (double) $NewDeal['PriceSale'][0];
     $RData['Value'] = (double) $NewDeal['PriceReg'][0];
     $RData['Status'] = 0;
     $RData['SDate'] = $StartDate;
     $RData['EDate'] = $EndDate;
     $RData['VDate'] = $VExpiry;
     $RData['StoreName'] = $StoreName;
     $RData['Website'] = $Website;
     $RData['Locations'] = array(array($Address, 0, 0));
     if (count($MoreDeals) > 0) {
         $RData['Deals'] = $MoreDeals;
     }
     return array(true, array($RData));
 }
Example #23
0
 public function GetDivisionData($SRID, $URL, $LID, $TZ, $Sub = false, $WebD = false)
 {
     global $DebugMode;
     list($Data, $DURL) = GetWebData('http://www.pricedodger.com' . $URL);
     if ($Data === false) {
         return array(SysLogIt('Error getting web data.', StatusError), null);
     }
     if ($DebugMode) {
         file_put_contents("PriceDodger.txt", 'http://www.pricedodger.com' . $URL . chr(13) . chr(10) . chr(13) . chr(10) . $Data);
     }
     if (stripos($Data, 'id="deal_intro"') === false || stripos($Data, 'deal ended at') !== false) {
         return array(true, false);
     }
     $NewDeal = array("ID" => array('', 'id="deal_intro"', '/deal/', '"', false), "URL" => array('', 'id="deal_intro"', 'a href="', '"', false), "Title" => array('', 'id="deal_intro"', 'title="', '"', false), "Website" => array('', 'class="company_link', 'href="', '"', false, true), "PriceSale" => array(0, 'class="price">$', '>', '<', true), "PriceReg" => array(0, 'class="value">$', '>', '<', true), "StoreName" => array('', 'class="company_link', '<span ', '</span>', false), "Description" => array('', 'id="deal_desc"', '>', 'class="company', false), "Address" => array('', 'id="deal_desc"', '</u>', '</span>' . chr(9) . chr(9), false, true), "Coords" => array('', 'maps.google.com', '?center=', '&', false, true), "EndDate" => array('', 'id="time_left"', '                        ', '<div>', false));
     if (!GetNewDealData($Data, $NewDeal)) {
         return array(SysLogIt('Error finding key deal information.', StatusError), null);
     }
     $StartDate = time();
     $EndDate = time();
     if (stripos($NewDeal['EndDate'][0], 'days') !== false) {
         $EndDate += 60 * 60 * 24 * (int) substr($NewDeal['EndDate'][0], 0, stripos($NewDeal['EndDate'][0], 'days') - 1);
         $EndDate += (int) FindData($NewDeal['EndDate'][0], '&nbsp;', 'H', 6, 0, false) * 60 * 60;
     } else {
         $EndDate += (int) substr($NewDeal['EndDate'][0], 0, stripos($NewDeal['EndDate'][0], 'H')) * 60 * 60;
     }
     $EndDate += (int) FindData($NewDeal['EndDate'][0], ';:&nbsp;', 'M', 8, 0, false) * 60;
     if ($EndDate <= time()) {
         return array(SysLogIt('Could not determine deal end date.', StatusError), null);
     }
     $VExpiry = FindData($Data, '>Expires', '<', 9, 0, false, 0, false);
     if ($VExpiry !== false) {
         $VExpiry = strtotime($VExpiry);
     }
     if ($VExpiry === false) {
         $VExpiry = 0;
     }
     $StoreName = $NewDeal['StoreName'][0];
     $StoreName = trim(str_replace('class="c">', ' ', $StoreName));
     $StoreName = trim(str_replace('class="c1">', ' ', $StoreName));
     $Address = null;
     if ($NewDeal['Address'][0] !== false) {
         $Address = CleanHTML($NewDeal['Address'][0]);
     }
     if ($Address == '') {
         $Address = null;
     }
     $Coords = array(0, 0);
     if ($NewDeal['Coords'][0] !== false) {
         $Coords = explode(',', $NewDeal['Coords'][0]);
     }
     if ($Coords === false || count($Coords) != 2) {
         $Coords = array(0, 0);
     }
     $MoreDeals = array();
     $Start = stripos($Data, 'id="side_deal"');
     while ($Start !== false) {
         $New = FindData($Data, 'http://pricedodger.com/deal/', '"', 28, 0, false, $Start, false);
         if ($New !== false) {
             $MoreDeals[] = '/deal/' . $New;
         }
         $Start = stripos($Data, 'id="side_deal"', $Start + 20);
     }
     $RData = array();
     $RData['DRID'] = $NewDeal['ID'][0];
     $RData['Title'] = $NewDeal['Title'][0];
     $RData['Descr'] = $NewDeal['Description'][0];
     $RData['URL'] = 'http://www.pricedodger.com' . $NewDeal['URL'][0];
     $RData['Price'] = (double) $NewDeal['PriceSale'][0];
     $RData['Value'] = (double) $NewDeal['PriceReg'][0];
     $RData['Status'] = 0;
     $RData['SDate'] = $StartDate;
     $RData['EDate'] = $EndDate;
     $RData['VDate'] = $VExpiry;
     $RData['StoreName'] = $StoreName;
     $RData['Website'] = $NewDeal['Website'][0];
     $RData['Locations'] = array(array($Address, $Coords[0], $Coords[1]));
     if (count($MoreDeals) > 0) {
         $RData['Deals'] = $MoreDeals;
     }
     return array(true, array($RData));
 }
Example #24
0
 public function GetDivisionData($SRID, $URL, $LID, $TZ, $Sub = false, $WebD = false)
 {
     global $DebugMode;
     if ($Sub) {
         list($Data, $DURL) = GetWebData('http://www.citylinked.com/todays-deal.php?' . $URL);
     } else {
         list($Data, $DURL) = GetWebData('http://www.citylinked.com/todays-deal.php?city=' . $URL);
     }
     if ($Data === false) {
         return array(SysLogIt('Error getting web data.', StatusError), null);
     }
     if ($DebugMode) {
         file_put_contents("Vieurbaine.txt", $Data);
     }
     if (stripos($Data, 'og:url') === false) {
         return array(true, false);
     }
     $NewDeal = array("ID" => array(0, 'og:url', '?deal=', '&', true), "Title" => array('', 'og:title', 'content="', '"/', false), "PriceSale" => array(0, 'itemprop="price"', '>', '$', true), "PriceReg" => array(0, 'line-through', '>', '$', true), "StoreName" => array('', 'var marker = createMarker(', 'point,"', '"', false), "Address" => array('', 'div id=\\"gmapmarker\\"', '<br \\/>', '<\\/div>', false), "Coords" => array('', 'var point = new GLatLng', '(', ')', false), "Website" => array('', 'itemprop="url"', 'href="', '"', false, true), "Description" => array('', 'og:description', 'content="', '"/>', false), "EndH" => array(0, 'id="hours"', '>', '<', true, true), "EndM" => array(0, 'id="mins"', '>', '<', true, true), "EndS" => array(0, 'id="secs"', '>', '<', true, true));
     if (!GetNewDealData($Data, $NewDeal)) {
         return array(SysLogIt('Error finding key deal information.', StatusError), null);
     }
     //Start, end dates
     $StartDate = time();
     $EndDate = time();
     if ($NewDeal['EndH'][0] !== false) {
         $EndDate += (int) $NewDeal['EndH'][0] * 60 * 60;
     }
     if ($NewDeal['EndM'][0] !== false) {
         $EndDate += (int) $NewDeal['EndM'][0] * 60;
     }
     if ($NewDeal['EndS'][0] !== false) {
         $EndDate += (int) $NewDeal['EndS'][0];
     }
     if ($EndDate <= time()) {
         return array(SysLogIt('Could not determine deal end date.', StatusError), null);
     }
     //Expiry Date
     $VExpiry = FindData($Data, 'Promotional value expires', '</p>', 26, 0, false, 0, false);
     if ($VExpiry !== false) {
         if (stripos($VExpiry, ',') !== false) {
             $VExpiry = substr($VExpiry, 0, stripos($VExpiry, ','));
         }
         $VExpiry = strtotime(CleanHTML($VExpiry));
     }
     if ($VExpiry === false) {
         $VExpiry = 0;
     }
     //Website
     $Website = null;
     if ($NewDeal['Website'][0] !== false) {
         $Website = $NewDeal['Website'][0];
     }
     //Address
     $Address = $NewDeal['Coords'][0];
     if (stripos($Address, ',') !== false) {
         $Address = explode(',', $Address);
     }
     if ($Address === false || count($Address) != 2) {
         $Address = array(0, 0);
     }
     $Locations = array();
     $Locations[] = array(CleanHTML($NewDeal['Address'][0]), $Address[0], $Address[1]);
     $MoreDeals = array();
     if (stripos($Data, '?pagetype=sidedeal') !== false) {
         $MoreDeals[] = "pagetype=sidedeal";
     }
     $TitleFR = false;
     list($Data, $DURL) = GetWebData('http://www.vieurbaine.com/offre-du-jour.php?deal=' . (int) $NewDeal['ID'][0]);
     if ($Data !== false) {
         $TitleFR = FindSubData($Data, 'og:title', 'content="', '"', false);
         if ($TitleFR !== false) {
             $TitleFR = ucfirst(strtolower(CleanHTML($TitleFR)));
         }
     }
     //Save
     $RData = array();
     $RData['DRID'] = (int) $NewDeal['ID'][0];
     $RData['Title'] = ucfirst(strtolower(CleanHTML($NewDeal['Title'][0])));
     if ($TitleFR !== false && $TitleFR != '') {
         $RData['Title-fr'] = $TitleFR;
     }
     $RData['Descr'] = $NewDeal['Description'][0];
     $RData['URL'] = 'http://www.citylinked.com/todays-deal.php?deal=' . (int) $NewDeal['ID'][0];
     $RData['Price'] = (double) $NewDeal['PriceSale'][0];
     $RData['Value'] = (double) $NewDeal['PriceReg'][0];
     $RData['Status'] = 0;
     $RData['SDate'] = $StartDate;
     $RData['EDate'] = $EndDate;
     $RData['VDate'] = $VExpiry;
     $RData['StoreName'] = $NewDeal['StoreName'][0];
     $RData['Website'] = $Website;
     $RData['Locations'] = $Locations;
     if (count($MoreDeals) > 0) {
         $RData['Deals'] = $MoreDeals;
     }
     return array(true, array($RData));
 }
Example #25
0
 public function GetDivisionData($SRID, $URL, $LID, $TZ, $Sub = false, $WebD = false)
 {
     global $DebugMode;
     list($Data, $DURL) = GetWebData('http://www.everybodybuys.com/' . $URL);
     if ($Data === false) {
         return array(SysLogIt('Error getting web data.', StatusError), null);
     }
     if ($DebugMode) {
         file_put_contents("EverybodyBuys.txt", $Data);
     }
     if (stripos($Data, 'class="subscriptions-content-form round-10 clearfix"') !== false) {
         return array(true, false);
     }
     //IF there is no deal, return false
     $NewDeal = array("ID" => array('', 'class="title"', 'href="', '"', false), "Title" => array('', 'class="title"', 'title="', '"', false), "Website" => array('', chr(13) . chr(10) . '                        <span class="ak-subtitle"', 'href="', '"', false, true), "Address" => array('', 'id="map_adress"', '>', '<br />', false), "PriceReg" => array('', 'class="ak-small-info ak-reg"', '$', '<', false), "PriceSale" => array(0, 'class="ak-value ak-num"', '>', '<', true), "StoreName" => array('', chr(13) . chr(10) . '                      <div class="ak-subside2">', 'class="ak-subtitle">', "<", false), "EndDate" => array(0, 'ak-value ak-time-left', 'js-time hide">', '<', true), "Description" => array('', 'Daily Write Up', '<p>', 'clear: left', false));
     if (!GetNewDealData($Data, $NewDeal)) {
         return array(SysLogIt('Error finding key deal information.', StatusError), null);
     }
     if ((int) $NewDeal['EndDate'][0] <= 0) {
         return array(true, false);
     }
     $StartDate = time();
     $EndDate = $StartDate + (int) $NewDeal['EndDate'][0];
     if ($EndDate <= time()) {
         return array(SysLogIt('Could not determine deal end date.', StatusError), null);
     }
     //Only operating in TO, so timezone always EST
     //$DateParts = explode(',', $DateEnds);
     //$EndDate = mktime((int)$DateParts[2], (int)$DateParts[3], (int)$DateParts[4], (int)$DateParts[0], (int)$DateParts[1], (int)date('Y'));
     //No Expiry, it will return 0 anyway
     $VExpiry = FindData($Data, 'Expiries', '</span>', 8, 0, false, 0, false);
     $VExpiry = $VExpiry === false ? 0 : strtotime($VExpiry);
     if ($VExpiry === false) {
         $VExpiry = 0;
     }
     $Address = null;
     if ($NewDeal['Address'][0] !== false) {
         $Address = CleanHTML($NewDeal['Address'][0]);
     }
     if ($Address == '') {
         $Address = null;
     }
     $Website = null;
     if ($NewDeal['Website'][0] !== false) {
         $Website = $NewDeal['Website'][0];
     }
     //Need function prototype, would like to know what the function does with the needle.
     $MoreDeals = array();
     $Start = stripos($Data, "<div style='position: relative;'>");
     while ($Start !== false) {
         $ID = FindData($Data, 'href="/', '"', 6, 0, false, $Start, false);
         if ($ID !== false) {
             $MoreDeals[] = $ID;
         }
         $Start = stripos($Data, "<div style='position: relative;'>", $Start + 20);
         //Not sure if I need an 'offset' here??
     }
     $RData = array();
     $RData['DRID'] = $NewDeal['ID'][0];
     $RData['Title'] = $NewDeal['Title'][0];
     $RData['Descr'] = $NewDeal['Description'][0];
     $RData['URL'] = 'http://www.everybodybuys.com' . $NewDeal['ID'][0];
     $RData['Price'] = (double) str_ireplace(',', '', $NewDeal['PriceSale'][0]);
     $RData['Value'] = (double) str_ireplace(',', '', $NewDeal['PriceReg'][0]);
     $RData['Status'] = 0;
     $RData['SDate'] = $StartDate;
     $RData['EDate'] = $EndDate;
     $RData['VDate'] = $VExpiry;
     $RData['StoreName'] = $NewDeal['StoreName'][0];
     $RData['Website'] = $Website;
     $RData['Locations'] = array(array($Address, 0, 0));
     if (count($MoreDeals) > 0) {
         $RData['Deals'] = $MoreDeals;
     }
     return array(true, $RData);
 }
Example #26
0
 public function GetDivisionData($SRID, $URL, $LID, $TZ, $Sub = false, $WebD = false)
 {
     global $DebugMode;
     list($Data, $DURL) = GetWebData('http://www.dealticker.com' . $URL);
     if ($Data === false) {
         return array(SysLogIt('Error getting web data.', StatusError), null);
     }
     if ($DebugMode) {
         file_put_contents("DealTicker.txt", 'http://www.dealticker.com' . $URL . chr(13) . chr(10) . chr(13) . chr(10) . $Data);
     }
     if (stripos($Data, "id='newsletter_form'") !== false || stripos($Data, 'We will be coming to your city soon') !== false || stripos($Data, 'No Longer Available') !== false) {
         return array(true, false);
     }
     $NewDeal = array("ID" => array(0, 'product_id:', '"', '"', true), "Title" => array('', 'meta name="description"', 'content="', '"', false), "Website" => array('', 'auto; " >', 'href="', '"', false, true), "PriceSale" => array(0, '<td class="price"', '$', '<', true), "PriceReg" => array(0, 'You Save', '$', '<', true), "StoreName" => array('', 'div style="padding: 0 15px;"', '>', '</b>', false), "Description" => array('', 'id="description"', '>', '</div>', false), "Address" => array('', 'div style="padding: 0 15px;"', '<br>', '</div>', false, true), "EndD" => array(0, '"r_dd"', '>', '<', true, true), "EndH" => array(0, '"r_hh"', '>', '<', true, true), "EndM" => array(0, '"r_mm"', '>', '<', true, true), "EndS" => array(0, '"r_ss"', '>', '<', true, true));
     if (!GetNewDealData($Data, $NewDeal)) {
         return array(SysLogIt('Error finding key deal information.', StatusError), null);
     }
     $StartDate = time();
     $EndDate = time();
     if ($NewDeal['EndD'][0] !== false) {
         $EndDate += (int) $NewDeal['EndD'][0] * 24 * 60 * 60;
     }
     if ($NewDeal['EndH'][0] !== false) {
         $EndDate += (int) $NewDeal['EndH'][0] * 60 * 60;
     }
     if ($NewDeal['EndM'][0] !== false) {
         $EndDate += (int) $NewDeal['EndM'][0] * 60;
     }
     if ($NewDeal['EndS'][0] !== false) {
         $EndDate += (int) $NewDeal['EndS'][0];
     }
     if ($EndDate <= time()) {
         return array(SysLogIt('Could not determine deal end date.', StatusError), null);
     }
     $VExpiry = FindData($Data, 'Expires:', ')', 9, 0, false, 0, false);
     $VExpiry = $VExpiry === false ? 0 : strtotime($VExpiry);
     if ($VExpiry === false) {
         $VExpiry = 0;
     }
     $Address = array();
     if ($NewDeal['Address'][0] !== false && $NewDeal['Address'][0] != '') {
         if (stripos($NewDeal['Address'][0], 'located in') === false) {
             $Address = $NewDeal['Address'][0];
             $Address = trim(str_ireplace('<td>', ' ', $Address));
             $Address = trim(str_ireplace('</td>', ' ', $Address));
             $Address = trim(str_ireplace('<tr>', ' ', $Address));
             $Address = trim(str_ireplace('</tr>', ' ', $Address));
             $Address = trim(str_ireplace('&nbsp;', ' ', $Address));
             $Address = trim(str_ireplace('<br>', ' ', $Address));
             $Address = trim(str_ireplace(chr(9), ' ', $Address));
             $Address = trim(str_ireplace(chr(10), ' ', $Address));
             $Address = trim(str_ireplace(chr(13), ' ', $Address));
             while (stripos($Address, '  ')) {
                 $Address = trim(str_ireplace('  ', ' ', $Address));
             }
             if (stripos($Address, '</span>') === false) {
                 $Address = array($Address);
             } else {
                 $Lines = explode('</span>', $Address);
                 $Address = array();
                 foreach ($Lines as &$Line) {
                     if (stripos($Line, 'locations') === false) {
                         if (substr($Line, 0, 5) == '<span') {
                             $Line = trim(substr($Line, stripos($Line, '>') + 1));
                         } elseif (stripos($Line, '<span') !== false) {
                             $Line = trim(substr($Line, 0, stripos($Line, '<span')));
                         }
                         if (is_numeric(substr($Line, 0, stripos($Line, ' '))) && strlen($Line) >= 25) {
                             $Address[] = $Line;
                         }
                     }
                 }
             }
         }
     }
     $Locations = array();
     if (count($Address) > 0) {
         foreach ($Address as $Adr) {
             $Locations[] = array(CleanHTML($Adr), 0, 0);
         }
     } else {
         $Locations[] = array(null, 0, 0);
     }
     $Last = 0;
     $MoreDeals = array();
     $Start = stripos($Data, 'More Great DealTickers');
     while ($Start !== false) {
         $New = FindData($Data, '/product.php/product_id/', '"', 24, 0, true, $Start, false);
         if ($New !== false && $New > 0 && $New != $Last) {
             $MoreDeals[] = '/product.php/product_id/' . $New;
             $Last = $New;
         }
         $Start = stripos($Data, " <!-- Today's Side Deal -->", $Start + 20);
     }
     $RData = array();
     $RData['DRID'] = '/product.php/product_id/' . $NewDeal['ID'][0];
     $RData['Title'] = $NewDeal['Title'][0];
     $RData['Descr'] = $NewDeal['Description'][0];
     $RData['URL'] = 'http://www.dealticker.com/product.php/product_id/' . $NewDeal['ID'][0];
     //$RDate['URL'] = 'http://www.DealTicker.com'.$URL.'/users/refer/4458/499/5fa1c87e50f3bef60631853dec007bc1';
     $RData['Price'] = (double) $NewDeal['PriceSale'][0];
     $RData['Value'] = (double) $NewDeal['PriceReg'][0];
     $RData['Status'] = 0;
     $RData['SDate'] = $StartDate;
     $RData['EDate'] = $EndDate;
     $RData['VDate'] = $VExpiry;
     $RData['StoreName'] = $NewDeal['StoreName'][0];
     $RData['Website'] = $NewDeal['Website'][0];
     $RData['Locations'] = $Locations;
     if (count($MoreDeals) > 0) {
         $RData['Deals'] = $MoreDeals;
     }
     return array(true, array($RData));
 }
Example #27
0
 public function GetDivisionData($SRID, $URL, $LID, $TZ, $Sub = false, $WebD = false)
 {
     global $DebugMode;
     list($Data, $DURL) = GetWebData('http://www.groupon.ca/' . $URL, null, 'user_locale=en_CA');
     //fr_CA
     if ($Data === false) {
         return array(SysLogIt('Error getting web data.', StatusError), null);
     }
     if ($DebugMode) {
         file_put_contents("GrouponCA.txt", $Data);
     }
     if (stripos($Data, '/payment') === false) {
         return array(true, false);
     }
     $NewDeal = array("ID" => array('', 'http://www.facebook.com/share.php', '?u=http://www.groupon.ca', '"', false), "Title" => array('', 'id="contentDealTitle"', '<h1>', '</h1>', false), "PriceSale" => array(0, 'class="price"', 'C$', '<', true), "Savings" => array(0, 'class="row2"', 'C$', '<', true), "StoreName" => array('', 'class="merchantContact"', '">', '<', false), "Website" => array('', 'class="merchantContact"', 'href="', '"', false, true), "Description" => array('', 'class="merchantContact"', '<p><p>', '<p class="outset"', false), "EndDate" => array('', 'id="currentTimeLeft"', 'value="', '"', false));
     if (!GetNewDealData($Data, $NewDeal)) {
         return array(SysLogIt('Error finding key deal information.', StatusError), null);
     }
     //Start, end dates
     $StartDate = time();
     $EndDate = time();
     $EndDate += (int) $NewDeal['EndDate'][0] / 1000;
     if ($EndDate <= time()) {
         return array(SysLogIt('Could not determine deal end date.', StatusError), null);
     }
     //Store name
     $StoreName = CleanHTML($NewDeal['StoreName'][0]);
     //Expiry Date
     $VExpiry = FindData($Data, '<li>Expires', '<', 11, 0, false, 0, false);
     if ($VExpiry !== false) {
         $VExpiry = strtotime($VExpiry);
     }
     if ($VExpiry === false) {
         $VExpiry = 0;
     }
     $Website = null;
     if ($NewDeal['Website'][0] !== false) {
         $Website = $NewDeal['Website'][0];
     }
     //Address(es)
     if (stripos($Data, '<strong>Locations') === false && stripos($Data, 'locations:</strong>') === false) {
         $Addresses = FindSubData($Data, 'class="merchantContact"', '</h', '<br />', false, 0, false);
         if ($Addresses !== false) {
             $Addresses = array($Addresses);
         }
         if ($Addresses === false) {
             $Addresses = array();
         }
     } else {
         $Addresses = FindSubData($Data, '<strong>Locations', '</strong>', '<p', false, 0, false);
         if ($Addresses === false) {
             $Addresses = FindSubData($Data, 'locations:</strong>', '</p>', '<p', false, 0, false);
         }
         if ($Addresses !== false) {
             $Addresses = explode('<br /><br />', $Addresses);
         }
         if ($Addresses === false) {
             $Addresses = array();
         }
     }
     $Locations = array();
     foreach ($Addresses as &$Adr) {
         if (!is_null($Adr) && $Adr != '') {
             $Locations[] = array(CleanHTML($Adr), 0, 0);
         }
     }
     if (count($Locations) == 0) {
         $Locations[] = array(null, 0, 0);
     }
     //Side deals
     $Last = $NewDeal['ID'][0];
     $MoreDeals = array();
     $Start = stripos($Data, '"/deals/');
     while ($Start !== false) {
         $New = FindData($Data, '"/deals/', '"', 1, 0, false, $Start, false);
         if ($New !== false && $New != $Last) {
             $MoreDeals[] = $New;
             $Last = $New;
         }
         $Start = stripos($Data, '"/deals/', $Start + 20);
     }
     $TitleFR = '';
     list($Data, $DURL) = GetWebData('http://www.groupon.ca/' . $URL, null, 'user_locale=fr_CA');
     if ($Data !== false) {
         $TitleFR = FindSubData($Data, 'id="contentDealTitle"', '<h1>', '</h1>', false, 0, false);
         if ($TitleFR !== false) {
             $TitleFR = CleanHTML($TitleFR);
         }
     }
     //Save
     $RData = array();
     $RData['DRID'] = $NewDeal['ID'][0];
     $RData['Title'] = CleanHTML($NewDeal['Title'][0]);
     if ($TitleFR !== false && $TitleFR != '') {
         $RData['Title-fr'] = $TitleFR;
     }
     $RData['Descr'] = $NewDeal['Description'][0];
     $RData['URL'] = 'http://www.groupon.ca' . $NewDeal['ID'][0];
     $RData['Price'] = (double) $NewDeal['PriceSale'][0];
     $RData['Value'] = (double) $NewDeal['PriceSale'][0] + (double) $NewDeal['Savings'][0];
     $RData['Status'] = 0;
     $RData['SDate'] = $StartDate;
     $RData['EDate'] = $EndDate;
     $RData['VDate'] = $VExpiry;
     $RData['StoreName'] = $StoreName;
     $RData['Website'] = $Website;
     $RData['Locations'] = $Locations;
     if (count($MoreDeals) > 0) {
         $RData['Deals'] = $MoreDeals;
     }
     return array(true, array($RData));
 }
Example #28
0
 public function GetDivisionData($SRID, $URL, $LID, $TZ, $Sub = false, $WebD = false)
 {
     global $DebugMode;
     //$TrueURL = (is_numeric($URL)?'?_page=home&city='.$URL:$URL);
     list($Data, $DURL) = GetWebData('http://www.wagjag.com' . $URL);
     if ($Data === false) {
         return array(SysLogIt('Error getting web data.', StatusError), null);
     }
     if ($DebugMode) {
         file_put_contents("WagJag.txt", "http://www.wagjag.com/" . $URL . chr(13) . chr(10) . chr(13) . chr(10) . $Data);
     }
     if (stripos($Data, 'id="js_wagjag_id"') === false || stripos($Data, 'error with that wagjag') !== false) {
         return array(true, false);
     }
     $NewDeal = array("ID" => array(0, 'id="js_wagjag_id"', 'value="', '"', true), "Title" => array('', 'id="deal_headline"', '>', '</span>', false), "Website" => array('', '<br /><br /></p>', 'href="', '"', false, true), "PriceReg" => array(0, 'Regular Price:', '$', '<', true), "PriceSale" => array(0, 'Buy For', '$', '<', true), "StoreName" => array('', '<!-- <h1>About', ' ', '<', false), "Description" => array('', '<!-- Deal Highlights -->', 'Highlights</span>', '<!-- End Deal Information -->', false), "Addresses" => array('', 'var sites =', '[[', ']]', false, true), "EndDate" => array('', 'TargetDate = ', '"', 'GMT', false));
     if (!GetNewDealData($Data, $NewDeal)) {
         return array(SysLogIt('Error finding key deal information.', StatusError), null);
     }
     $StartDate = time();
     $EndDate = strtotime($NewDeal['EndDate'][0]);
     if ($EndDate === false) {
         return array(SysLogIt('Could not determine deal end date.', StatusError), null);
     }
     //Wagjags all seem to finish at midnight EST
     $VExpiry = FindData($Data, '<li>Expires', '</li>', 11, 0, false, 0, false);
     if (substr($VExpiry, 0, 3) == 'in ') {
         $VExpiry = strtotime(str_ireplace('in ', '+', $VExpiry));
     } else {
         $VExpiry = $VExpiry === false ? 0 : strtotime($VExpiry);
     }
     if ($VExpiry === false) {
         $VExpiry = 0;
     }
     $Title = CleanHTML($NewDeal['Title'][0]);
     $Locations = array();
     if ($NewDeal['Addresses'][0] !== false) {
         $Addresses = explode('],[', $NewDeal['Addresses'][0]);
         foreach ($Addresses as $Address) {
             $AdrName = FindData($Address, ', "', '"', 3, 0, false, 0, false);
             if ($AdrName !== false) {
                 $Coords = FindData($Address, '",', ', ', 2, 0, false, 0, false);
                 if ($Coords !== false && stripos($Coords, ',') !== false) {
                     $Coords = explode(',', $Coords);
                     $Locations[] = array(CleanHTML($AdrName), $Coords[0], $Coords[1]);
                 } else {
                     $Locations[] = array(CleanHTML($AdrName), 0, 0);
                 }
             }
         }
     }
     if (count($Locations) == 0) {
         $Locations[] = array(null, 0, 0);
     }
     $MoreDeals = array();
     $Start = stripos($Data, "/?wagjag=");
     while ($Start !== false) {
         $ID = FindData($Data, '/?wagjag=', "'", 9, 0, true, $Start, false);
         if ($ID !== false) {
             $MoreDeals[] = '/?wagjag=' . $ID;
         }
         $Start = stripos($Data, "/?wagjag=", $Start + 20);
     }
     $Website = null;
     if ($NewDeal['Website'][0] !== false) {
         $Website = trim($NewDeal['Website'][0]);
     }
     if ($Website == '') {
         $Website = null;
     }
     $RData = array();
     $RData['DRID'] = (int) $NewDeal['ID'][0];
     $RData['Title'] = $Title;
     $RData['Descr'] = $NewDeal['Description'][0];
     $RData['URL'] = 'http://www.wagjag.com/index.php?_page=home&wagjag=' . (int) $NewDeal['ID'][0];
     $RData['Price'] = (double) $NewDeal['PriceSale'][0];
     $RData['Value'] = (double) $NewDeal['PriceReg'][0];
     $RData['Status'] = 0;
     $RData['SDate'] = $StartDate;
     $RData['EDate'] = $EndDate;
     $RData['VDate'] = $VExpiry;
     $RData['StoreName'] = $NewDeal['StoreName'][0];
     $RData['Website'] = $Website;
     $RData['Locations'] = $Locations;
     if (count($MoreDeals) > 0) {
         $RData['Deals'] = $MoreDeals;
     }
     return array(true, array($RData));
 }
Example #29
0
function GetDetails()
{
    global $LanguageID;
    global $Response;
    global $UserID;
    $Strings = GSA('1000,1329,1330,1331,1332,1334,1339,1350,1367,1650,1651,1652,1653,1654,1655,1656,1657,1658,1659,1660,1661,1662,1663,1664,1665,1666,1667,1669,1670,1671,1672,1673', $LanguageID, false, true);
    if (isset($_POST['DID'])) {
        if (is_numeric($_POST['DID'])) {
            list($QR, $DR, $T) = QuerySingle("SELECT COALESCE(LSDa.StringText, LSDb.StringText) AS DText, D.DealPrice AS DPrice, D.DealQR AS QR, DC.MPrice, COALESCE(DC.DCount, 1) AS DCount,\n                COALESCE(UR.RAvg, 0) AS RAvg, COALESCE(UR.RCount, 0) AS RCount, COALESCE(DCT.CCount, 0) AS CCount, COALESCE(URx.Score, 0) AS MyScore,\n                S.StoreID, S.StoreName AS SName, S.StoreWebsite AS SWeb, L.LocationAddress AS Adr, DS.DealSourceName AS DSName, DS.DealSourceFileName AS FName,\n                UNIX_TIMESTAMP(D.DateExpiry) AS ExpDate, COUNT(L.LocationID) AS LCount, UF.FavoriteID AS FavID, L.LocationLatitude AS Lat, L.LocationLongitude AS Lng, DSU.URLID\n               FROM 4000_Deals D\n              INNER JOIN 4100_Deal_Sources DS ON DS.DealSourceID = D.DealSourceID\n              INNER JOIN 2000_Stores S ON D.StoreID = S.StoreID\n               LEFT JOIN (SELECT StoreID, AVG(Score) AS RAvg, COUNT(ReviewID) AS RCount FROM 1300_User_Reviews WHERE Status = 1 GROUP BY StoreID) UR ON UR.StoreID = S.StoreID\n               LEFT JOIN (SELECT StoreID, UserID, Score FROM 1300_User_Reviews) URx ON URx.UserID = " . $UserID . " AND URx.StoreID = S.StoreID\n               LEFT JOIN 2200_Store_Locations SL ON SL.StoreID = S.StoreID\n               LEFT JOIN 3000_Locations L ON SL.LocationID = L.LocationID AND L.LocationLatitude != -1\n               LEFT JOIN 0200_Language_Strings LSDa ON D.StringID = LSDa.StringID AND LSDa.LanguageID = " . $LanguageID . "\n               LEFT JOIN 0200_Language_Strings LSDb ON D.StringID = LSDb.StringID AND LSDb.LanguageID = 1\n               LEFT JOIN (SELECT StoreID, COUNT(DealID) AS DCount, MIN(DealPrice) AS MPrice FROM 4000_Deals GROUP BY StoreID) DC ON DC.StoreID = S.StoreID\n               LEFT JOIN (SELECT DealID, COUNT(ClickID) AS CCount FROM 4200_Deal_Clickthroughs WHERE DealID = " . (int) $_POST['DID'] . " GROUP BY DealID) DCT ON DCT.DealID = D.DealID\n               LEFT JOIN 1200_User_Favorites UF ON UF.DealID = D.DealID AND UF.UserID = " . $UserID . "\n               LEFT JOIN (SELECT URLID, Latitude, Longitude FROM 4110_Deal_Source_URLs GROUP BY Latitude, Longitude) DSU ON DSU.Latitude = L.LocationLatitude AND DSU.Longitude = L.LocationLongitude\n              WHERE D.DealID = " . (int) $_POST['DID'] . "\n              GROUP BY D.DealID;");
            if ($QR < 0) {
                SysLogIt('Error finding deal with ID of ' . (int) $_POST['DID'] . '.', StatusError, ActionSelect);
            } elseif ($QR > 0) {
                $Response->S = true;
                $Response->C = (int) $_POST['DID'];
                $Response->R = array();
                $Response->R[2] = 0;
                $Response->R[3] = 0;
                //Do header
                //-------------------
                $Response->R[0] = '';
                if (!isset($_POST['SM'])) {
                    $Response->R[0] = ' <DIV CLASS="cls z3" onClick="HPanR();">' . Pacify($Strings[1000]) . '</DIV>';
                }
                $Response->R[0] .= '<DIV CLASS="b sz18 padr w100p nowr flwh">' . $DR['SName'] . '</DIV>
                            <DIV CLASS="sz13">';
                if (!(is_null($DR['SWeb']) || trim($DR['SWeb']) == '')) {
                    $Response->R[0] .= '<DIV><A HREF="' . $DR['SWeb'] . '" TARGET="_blank">' . $Strings[1650] . '</A></DIV><DIV>';
                }
                if ($DR['LCount'] > 0) {
                    $Response->R[0] .= '   <DIV>' . ($DR['LCount'] == 1 ? $DR['Adr'] : str_replace('%a', $DR['LCount'], $Strings[1665]));
                }
                $Response->R[0] .= '</DIV><HR>';
                //Do buttons
                //-------------------
                $Response->R[0] .= '<DIV CLASS="sz14 w100p nowr flwh h30" ID="DetB">
                             <DIV CLASS="din butt dtb tibu mgrrxs" onClick="Buy(' . (int) $_POST['DID'] . ')" onMouseOver="DoHlp(this,1305);" onMouseOut="KlHlp();"><DIV CLASS="padlm">' . $Strings[1330] . '</DIV></DIV>';
                if (!isset($_POST['SM'])) {
                    //if (($UserID > 0) && (is_null($DR['FavID']))) $Response->R[0] .= ' <DIV CLASS="din butt dtb tisv mgrrxs" onClick="TogSav(1,'.(int)$_POST['DID'].'); RstDet('.(int)$_POST['DID'].');" onMouseOver="DoHlp(this,1306);" onMouseOut="KlHlp();"><DIV CLASS="padlm">'.$Strings[1331].'</DIV></DIV>';
                    if ($UserID > 0) {
                        if (is_null($DR['FavID'])) {
                            $Response->R[0] .= ' <DIV CLASS="din butt dtb tisv mgrrxs" onClick="TogSav(1,' . (int) $_POST['DID'] . ',1);" onMouseOver="DoHlp(this,1306);" onMouseOut="KlHlp();"><DIV CLASS="padlm">' . $Strings[1331] . '</DIV></DIV>';
                        } else {
                            $Response->R[0] .= ' <DIV CLASS="din dbutt dtb tisvd mgrrxs"><DIV CLASS="padlm">' . $Strings[1367] . '</DIV></DIV>';
                        }
                    } else {
                        $Response->R[0] .= ' <DIV CLASS="din dbutt dtb tidsv mgrrxs" onMouseOver="DoHlp(this,1334,1);" onMouseOut="KlHlp();"><DIV CLASS="padlm">' . $Strings[1331] . '</DIV></DIV>';
                    }
                    if (is_null($DR['FavID'])) {
                        $Response->R[0] .= '  <DIV CLASS="din butt dtb tihi mgrrxs" onClick="KlD(' . (int) $_POST['DID'] . '); HPanR();" onMouseOver="DoHlp(this,1307);" onMouseOut="KlHlp();"><DIV CLASS="padlm">' . $Strings[1332] . '</DIV></DIV>';
                    } else {
                        $Response->R[0] .= '  <DIV CLASS="din butt dtb tihi mgrrxs" onClick="TogSav(0,' . (int) $_POST['DID'] . ',1);" onMouseOver="DoHlp(this,1352);" onMouseOut="KlHlp();"><DIV CLASS="padlm">' . $Strings[1339] . '</DIV></DIV>';
                    }
                }
                $Response->R[0] .= '   <DIV CLASS="din butt dtb tish mgrrxs" onClick="Share(' . (int) $_POST['DID'] . ')" onMouseOver="DoHlp(this,1351);" onMouseOut="KlHlp();"><DIV CLASS="padlm">' . $Strings[1350] . '</DIV></DIV>
                               </DIV>';
                $Response->R[0] .= '</DIV>';
                //Do content
                //-------------------
                $Response->D .= '<DIV CLASS="sz13 dkbl" ID="DetC">
                             <DIV CLASS="sech"><IMG SRC="/IF/H-Des.png" WIDTH=20 HEIGHT=20 ALT="" CLASS="valgm padrxs"><B>' . $Strings[1651] . '</B></DIV>
                             <DIV CLASS="padls">' . $DR['DText'] . '</DIV>
                             <DIV CLASS="padls">
                               <UL>';
                if ($DR['ExpDate'] > 0 && date('Y', $DR['ExpDate']) > 1969) {
                    if ($DR['ExpDate'] < time()) {
                        $DLeft = $Strings[1329];
                    } else {
                        $DLeft = round(($DR['ExpDate'] - time()) / 60 / 60 / 24);
                        if ($DLeft < 180) {
                            $DLeft = '<span class="red">' . $DLeft . '</span>';
                        }
                        $DLeft = $DLeft . ' ' . $Strings[1653];
                    }
                    $Response->D .= '<LI>' . $Strings[1652] . ' ' . date('Y-m-d', $DR['ExpDate']) . ' (' . $DLeft . ')</LI>';
                }
                $Response->D .= '     <LI>' . $Strings[1667] . ' <SPAN CLASS="fklnk" onClick="Buy(' . (int) $_POST['DID'] . ')" onMouseOver="DoHlp(this,1305);" onMouseOut="KlHlp();">' . $DR['DSName'] . '</SPAN>.</LI>
                              </UL>
                            </DIV>
                             <DIV CLASS="sech padts"><IMG SRC="/IF/H-Stat.png" WIDTH=20 HEIGHT=20 ALT="" CLASS="valgm padrxs"><B>' . $Strings[1654] . '</B></DIV>
                             <DIV CLASS="padls">
                               <UL>
                                 <LI>' . str_replace('%a', $DR['DCount'] > 1 ? '<DIV CLASS="nbutt" onClick="DHist(' . (int) $_POST['DID'] . ');" onMouseOver="DoHlp(this,1144);" onMouseOut="KlHlp();">' . $DR['DCount'] . ' ' . $Strings[1672] . '</DIV>' : '<B>' . $DR['DCount'] . '</B> ' . $Strings[1673], $Strings[1655]) . '</LI>
                                 <LI>';
                $Response->D .= is_null($DR['MPrice']) || $DR['DPrice'] <= $DR['MPrice'] ? $Strings[1656] : $Strings[1657];
                $Response->D .= '     </LI>';
                if ($DR['CCount'] > 0) {
                    $Response->D .= '<LI>' . str_replace('%a', $DR['CCount'], $Strings[1658]) . '</LI>';
                }
                $Response->D .= '   </UL>
                            </DIV>
                             <DIV CLASS="sech"><IMG SRC="/IF/H-Rev.png" WIDTH=20 HEIGHT=20 ALT="" CLASS="valgm padrxs"><B>' . $Strings[1659] . '</B></DIV>
                             <DIV CLASS="padls"><SPAN CLASS="fll sz24 mgrrxs dkgray fra algc"><B>' . ($DR['RAvg'] == 0 ? '--' : number_format($DR['RAvg'], 1)) . '</B></SPAN>' . str_replace('%a', $DR['RCount'], $Strings[1660]) . '<BR />';
                if ($DR['RCount'] > 0) {
                    $Response->D .= '<DIV CLASS="nbutt" onClick="GetRvw(' . (int) $_POST['DID'] . ',0)">' . $Strings[1661] . '</DIV> &bull; ';
                }
                if ($UserID > 0) {
                    $Response->D .= (int) $DR['MyScore'] == 0 ? '<DIV CLASS="nbutt" onClick="AddRvw(' . (int) $_POST['DID'] . ');">' . $Strings[1662] . '</DIV>' : '<SPAN>' . str_replace('%a', (int) $DR['MyScore'], $Strings[1663]) . '</SPAN>';
                } else {
                    $Response->D .= '<SPAN CLASS="fklnk" onClick="NewAcct();">' . $Strings[1664] . '</SPAN>';
                }
                $Response->D .= '   <DIV CLASS="clr"></DIV>
                           </DIV>';
                if ($DR['LCount'] > 1) {
                    $Response->D .= '<DIV CLASS="sech padts"><IMG SRC="/IF/H-Adr.png" WIDTH=20 HEIGHT=20 ALT="" CLASS="valgm padrxs"><B>' . $Strings[1666] . '</B></DIV><DIV CLASS="padls"><UL>';
                    list($SQR, $SRS, $T) = QuerySet('SELECT LD.LocationID, LD.LocationAddress AS Adr
                 FROM 2200_Store_Locations SL
                INNER JOIN 3000_Locations LD ON LD.LocationID = SL.LocationID
                WHERE SL.StoreID = ' . $DR['StoreID'] . ';');
                    if ($SQR > 0) {
                        while ($SDR = mysql_fetch_array($SRS)) {
                            $Response->D .= '<LI>' . $SDR['Adr'] . '</LI>';
                        }
                    } elseif ($SQR < 0) {
                        SysLogIt('Error searching for saved deal\'s store locations.', StatusError, ActionSelect);
                        $Response->S = false;
                        $Response->Send();
                    }
                    $Response->D .= '</UL>
                           </DIV>';
                } elseif (is_null($DR['URLID'])) {
                    if ($DR['LCount'] > 0) {
                        $Response->D .= '<DIV CLASS="sech padt"><IMG SRC="/IF/H-Eye.png" WIDTH=20 HEIGHT=20 ALT="" CLASS="valgm padrxs"><B>' . $Strings[1669] . '</B></DIV>
                               <DIV ID="GSVDIV" CLASS="mrgls gsv"></DIV>';
                        $Response->R[2] = $DR['Lat'];
                        $Response->R[3] = $DR['Lng'];
                    }
                }
                if (!is_null($DR['QR'])) {
                    $Response->D .= '<DIV CLASS="sech padt"><IMG SRC="/IF/H-Pho.png" WIDTH=20 HEIGHT=20 ALT="" CLASS="valgm padrxs"><B>' . $Strings[1670] . '</B></DIV>
                             <DIV CLASS="mrgl padbxs">' . $Strings['1671'] . '</DIV>
                             <DIV CLASS="mrgls algc"><IMG SRC="/QR/' . $DR['QR'] . '" CLASS="rbrds fra padaxs" WIDTH=150 HEIGHT=150 ALT=""></DIV>';
                }
                $Response->D .= '</DIV>';
                if (isset($_POST['ULID'])) {
                    if (is_numeric($_POST['ULID'])) {
                        if ((int) $_POST['ULID'] > 0) {
                            SetFilter((int) $_POST['ULID'], FilterDeal, (int) $_POST['DID'], 0, -1, false);
                        }
                    }
                }
                $Response->Send();
            }
        }
    }
    $Response->S = false;
    $Response->Send();
}
Example #30
0
 public function GetDivisionData($SRID, $URL, $LID, $TZ, $Sub = false, $WebD = false)
 {
     global $DebugMode;
     list($Data, $DURL) = GetWebData('http://toronto.fabfind.com/' . $URL, null, 'Preferences=Town=M2');
     if ($Data === false) {
         return array(SysLogIt('Error getting web data.', StatusError), null);
     }
     if ($DebugMode) {
         file_put_contents("FabFind.txt", $Data);
     }
     if (stripos($Data, 'Chatter.aspx?dealid=') === false) {
         return array(true, false);
     }
     $NewDeal = array("ID" => array(0, 'Chatter.aspx?dealid', '=', '"', true), "Title" => array('', 'id="ctl00_contentTop_lblTitle"', '>', '</span', false), "PriceSale" => array(0, 'ctl00_contentTop_lblPrice', '>', '<', true), "PriceReg" => array(0, 'ctl00_contentTop_lblValue', '$', '<', true), "StoreName" => array('', 'ctl00_contentMain_lblBusinessName', '>', '<', false), "Website" => array('', 'linkBusinessWebsite', 'href="', '"', false, true), "Phone" => array('', 'ctl00_contentMain_lblPhone', 'Phone: ', '<', false, true), "Address" => array('', 'ctl00_contentMain_lblAddress', '>', '</span', false, true), "Description" => array('', 'ctl00_contentMain_lblDescription', '>', '</span>', false), "Coords" => array('', 'GMaps', 'GLatLng(', ')', false, true), "EndDate" => array(0, 'DealSecLeft', '+', "'", true));
     if (!GetNewDealData($Data, $NewDeal)) {
         return array(SysLogIt('Error finding key deal information.', StatusError), null);
     }
     $StartDate = time();
     $EndDate = time() + $NewDeal['EndDate'][0];
     //End date uses seconds left, so no Timezone calculations needed
     $VExpiry = FindSubData($Data, 'Certificate expires', '(', ')', false);
     if ($VExpiry === false) {
         $VExpiry = FindSubData($Data, '<li>Expires', ' ', '<', false);
     }
     $VExpiry = $VExpiry === false ? 0 : strtotime($VExpiry);
     if ($VExpiry === false) {
         $VExpiry = 0;
     }
     $Address = $NewDeal['Address'][0] === false ? '' : trim(str_ireplace('<br />', ', ', $NewDeal['Address'][0]));
     if (stripos($Address, 'several locations') !== false) {
         $Address = array();
         $Start = stripos($Data, '&hnear=');
         while ($Start !== false) {
             $New = FindData($Data, '&hnear=', '&', 7, 0, false, $Start, false);
             if ($New !== false) {
                 $Address[] = array(str_ireplace('+', ' ', $New), 0, 0);
             }
             $Start = stripos($Data, '&hnear=', $Start + 20);
         }
     }
     if (!is_array($Address)) {
         $Address = array(array($Address, 0, 0));
     }
     foreach ($Address as &$Adr) {
         if ($NewDeal['Phone'][0] !== false) {
             $Adr[0] .= $NewDeal['Phone'][0];
         }
         if ($Adr[0] == '') {
             $Adr[0] = null;
         }
     }
     /*
     $Coords = array(0, 0);
     if ($NewDeal['Coords'][0] !== false) $Coords = explode(',', $NewDeal['Coords'][0]);
     if (($Coords === false) || (count($Coords) != 2)) $Coords = array(0, 0);
     */
     $MoreDeals = array();
     $Start = stripos($Data, 'href="deal/');
     while ($Start !== false) {
         $New = FindData($Data, 'href="deal/', '"', 11, 0, false, $Start, false);
         if ($New !== false) {
             $MoreDeals[] = '/deal/' . $New;
         }
         $Start = stripos($Data, 'href="deal/', $Start + 20);
     }
     $Title = CleanHTML($NewDeal['Title'][0]);
     $RData = array();
     $RData['DRID'] = (int) $NewDeal['ID'][0];
     $RData['Title'] = $Title;
     $RData['Descr'] = $NewDeal['Description'][0];
     $RData['URL'] = 'http://toronto.fabfind.com/Default.aspx?DealID=' . (int) $NewDeal['ID'][0];
     $RData['Price'] = (double) $NewDeal['PriceSale'][0];
     $RData['Value'] = (double) $NewDeal['PriceReg'][0];
     $RData['Status'] = 0;
     $RData['SDate'] = $StartDate;
     $RData['EDate'] = $EndDate;
     $RData['VDate'] = $VExpiry;
     $RData['StoreName'] = $NewDeal['StoreName'][0];
     $RData['Website'] = $NewDeal['Website'][0];
     $RData['Locations'] = $Address;
     if (count($MoreDeals) > 0) {
         $RData['Deals'] = $MoreDeals;
     }
     return array(true, array($RData));
 }