示例#1
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));
 }
示例#2
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));
 }
示例#3
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));
 }
示例#4
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));
 }
示例#5
0
 public function GetDivisionData($SRID, $URL, $LID, $TZ, $Sub = false, $WebD = false)
 {
     global $DebugMode;
     list($Data, $DURL) = GetWebData('http://www.dealathons.com/?city=' . $URL);
     if ($Data === false) {
         return array(SysLogIt('Error getting web data.', StatusError), null);
     }
     if ($DebugMode) {
         file_put_contents("Dealathons.txt", $Data);
     }
     if (stripos($Data, '/checkout/') === false || stripos($Data, 'Dealathons Is Coming') !== false || stripos($Data, 'No Deal Available') !== false) {
         return array(true, false);
     }
     $NewDeal = array("ID" => array(0, '/checkout/', '/product/', '/', true), "Title" => array('', 'class="cont_top_cntr"', '<p>', '</p>', false), "PriceSale" => array(0, 'class="price_value"', '$', '<', true), "PriceReg" => array(0, '>Value<', '$', '<', true), "Description" => array('', 'class="highlights"', '>', '<!', false), "Coords" => array('', 'maps.google.ca', ';ll=', '&', false, true), "StartDate" => array('', 'var startdate =', '"', '";', false), "EndDate" => array('', 'var targetdate =', '"', '";', false));
     if (!GetNewDealData($Data, $NewDeal)) {
         return array(SysLogIt('Error finding key deal information.', StatusError), null);
     }
     $StartDate = strtotime($NewDeal['StartDate'][0]);
     $EndDate = strtotime($NewDeal['EndDate'][0]);
     if ($EndDate <= time()) {
         return array(SysLogIt('Could not determine deal end date.', StatusError), null);
     }
     $VExpiry = FindSubData($Data, '"bottom_description"', 'Expires ', '<', false);
     if ($VExpiry !== false) {
         $VExpiry = strtotime($VExpiry);
     }
     if ($VExpiry === false) {
         $VExpiry = 0;
     }
     $Address = array();
     $AdrBlock = FindData($Data, '<address>', '</address>', 9, 0, false, 0, false);
     if ($AdrBlock !== false) {
         if (stripos($AdrBlock, '<p>&nbsp;</p>') === false) {
             if (stripos($AdrBlock, '<br />') !== false) {
                 $AdrBlock = substr($AdrBlock, stripos($AdrBlock, '<br />') + 6);
             } elseif (stripos($AdrBlock, '</p>') !== false) {
                 $AdrBlock = substr($AdrBlock, stripos($AdrBlock, '</p>') + 6);
             }
             $AdrBlock = array($AdrBlock);
         } else {
             $AdrBlock = explode('<p>&nbsp;</p>', $AdrBlock);
         }
         foreach ($AdrBlock as &$Adr) {
             $Adr = CleanHTML($Adr);
             if ($Adr != '') {
                 $Address[] = $Adr;
             }
         }
     }
     if (count($Address) == 0) {
         $Address[] = null;
     }
     $Locations = array();
     if (count($Address) == 1) {
         if ($NewDeal['Coords'][0] !== false) {
             $Coords = explode(',', $NewDeal['Coords'][0]);
             if ($Coords === false || count($Coords) != 2) {
                 $Coords = array(0, 0);
             }
         } else {
             $Coords = array(0, 0);
         }
         $Locations[] = array($Address[0], $Coords[0], $Coords[1]);
     } else {
         foreach ($Address as $Adr) {
             $Locations[] = array($Adr, 0, 0);
         }
     }
     if (count($Locations) == 0) {
         return array(SysLogIt("Could not decipher addresses for division with ID of " . $SRID . ".", StatusError), null);
     }
     $StoreName = false;
     if (stripos($Data, 'pp-headline-address') !== false) {
         $StoreName = FindSubData($Data, 'pp-headline-address', '>', '<', false);
     } elseif (stripos($Data, '<address>') !== false) {
         $StoreName = FindData($Data, '<address>', '</address>', 9, 0, false, 0, false);
         if ($StoreName !== false) {
             if (stripos($StoreName, '<span') === false) {
                 $StoreName = false;
             } else {
                 $StoreName = FindData($StoreName, '<span', '</span>', 5, 0, false, 0, false);
                 if ($StoreName !== false) {
                     $StoreName = substr($StoreName, stripos($StoreName, '>') + 1);
                     $StoreName = CleanHTML($StoreName);
                 }
             }
         }
     }
     if ($StoreName === false) {
         return array(SysLogIt("Could not determine store name for division with ID of " . $SRID . ".", StatusError), null);
     }
     $RData = array();
     $RData['DRID'] = $NewDeal['ID'][0];
     $RData['Title'] = $NewDeal['Title'][0];
     $RData['Descr'] = $NewDeal['Description'][0];
     $RData['URL'] = 'http://www.dealathons.com/?city=' . $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'] = null;
     $RData['Locations'] = $Locations;
     return array(true, array($RData));
 }
示例#6
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));
 }
示例#7
0
function SendDigests($ST)
{
    if ((int) date('G') >= 18) {
        $TimeOfDay = 4;
    } elseif ((int) date('G') >= 12) {
        $TimeOfDay = 2;
    } elseif ((int) date('G') >= 7) {
        $TimeOfDay = 1;
    } else {
        return true;
    }
    //Read users
    list($QR, $RS, $T) = QuerySet('SELECT UN.NotificationID AS NID, UN.UserID, UN.DealID, UN.Settings, UN.CancelKey, U.LanguageID AS LID, U.UserEmail
                                      FROM 1400_User_Notifications UN
                                     INNER JOIN 1000_Users U ON UN.UserID = U.UserID
                                     WHERE UN.SentDate < ' . date('YmdHis', mktime(date('H') - 12, date('i'), date('s'), date('n'), date('j'), date('Y'))) . '
                                       AND ((UN.Settings & ' . $TimeOfDay . ') = ' . $TimeOfDay . ')
                                       AND ((U.UserFlags & ' . UserActive . ') = ' . UserActive . ')
                                       AND (U.UserEmailVerified = 1);');
    if ($QR < 0) {
        return SysLogIt('Error searching for user notification settings.', StatusError, ActionSelect);
    }
    if ($QR > 0) {
        SysLogIt('Sending daily digests (' . $QR . ' pending)', StatusInfo, ActionNotSpecified, 1);
        $Strings = array();
        list($QR, $SRS, $T) = QuerySet("SELECT LanguageID FROM 0000_Languages WHERE LanguageActive = 1;");
        while ($SDR = mysql_fetch_array($SRS)) {
            $Strings[$SDR['LanguageID']] = GSA('2100,2101,2102,2103,2104,2105,2106,2107,2108,2109,2110,2111,2113,2114,2115', $SDR['LanguageID'], false, true);
        }
        while ($DR = mysql_fetch_array($RS)) {
            if (time() - $ST > 300) {
                return SysLogIt('Sending of digests has exceeded 5 minutes; stopping until next cycle.', StatusInfo, ActionNotSpecified, -1);
            }
            $MaxDealID = 0;
            if (($DR['Settings'] & 16) == 16) {
                $Output = '<html><head><title>Dealplotter - ' . $Strings[$DR['LID']][2100] . ' - ' . date('Y-m-d') . '</title><meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /><style type="text/css">A { text-decoration: none; } A:hover { border-bottom: 1px solid #0179ff; } TD EM { font-style: normal; }</style></head><body bgcolor="#FFFFFF" style="font-family: Calibri, sans-serif; font-size: 13px;"><table style="border: 1px solid #E0E0E0; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; background-color: #F8F8F8;" WIDTH="100%"><tr><td width="210"><a href="http://www.dealplotter.com"><img src="http://www.dealplotter.com/IF/LogoXS.png" border=0></a></td><td><h2 style="font-size: 18px;"><b>' . $Strings[$DR['LID']][2100] . '<br />' . date('Y-m-d') . '</b></h2></tr></tr></table><table border=0 cellpadding=3 style="font-size: 13px;">';
            } else {
                $Output = 'Dealplotter - ' . $Strings[$DR['LID']][2100] . ' - ' . date('Y-m-d') . chr(13) . chr(10) . chr(13) . chr(10);
            }
            list($QR, $SRS, $T) = QuerySet('SELECT L.LocationID, L.LocationLatitude AS Lat, L.LocationLongitude AS Lng, L.CountryID AS CID, UL.UserLocationName AS UName, C.CountryCurrency AS CurS,
            COALESCE(GROUP_CONCAT(UFT.FilterSourceID),0) AS TFilt, COALESCE(GROUP_CONCAT(UFD.FilterSourceID),0) AS DFilt,
            GROUP_CONCAT(CONCAT_WS(",", UFC.FilterSourceID, UFC.FilterValue) SEPARATOR "|") AS CFilt
             FROM 1000_Users U
            INNER JOIN 1100_User_Locations UL ON U.UserID = UL.UserID
            INNER JOIN 3000_Locations L ON L.LocationID = UL.LocationID
            INNER JOIN 3100_Countries C ON C.CountryID = L.CountryID
             LEFT JOIN 1110_User_Filters UFC ON UFC.UserLocationID = UL.UserLocationID AND UFC.FilterType = ' . FilterCategory . '
             LEFT JOIN 1110_User_Filters UFT ON UFT.UserLocationID = UL.UserLocationID AND UFT.FilterType = ' . FilterType . '
             LEFT JOIN (
               SELECT UF.UserLocationID, UF.FilterSourceID
                 FROM 1110_User_Filters UF
                INNER JOIN 4000_Deals D ON UF.FilterSourceID = D.DealID
                WHERE UF.FilterType = ' . FilterDeal . '
                  AND D.DateEnds > ' . date('YmdHis') . '
                  AND UF.FilterValue = 1
             ) UFD ON UFD.UserLocationID = UL.LocationID
            WHERE U.UserID = ' . $DR['UserID'] . '
            GROUP BY UL.UserLocationID;');
            if ($QR < 0) {
                return SysLogIt('Error searching for user location settings.', StatusError, ActionSelect);
            }
            if ($QR > 0) {
                while ($SDR = mysql_fetch_array($SRS)) {
                    if ($SDR['CFilt'] == '') {
                        $Categories = array();
                    } else {
                        $Categories = explode("|", $SDR['CFilt']);
                        foreach ($Categories as $Key => $Category) {
                            $Categories[$Key] = explode(',', $Category);
                        }
                    }
                    if (($DR['Settings'] & 16) == 16) {
                        $Output .= '<tr><td colspan=3><h2 style="font-size: 18px;"><b><br />' . $Strings[$DR['LID']][2101] . ' ' . StringAdjust($SDR['UName']) . '';
                    } else {
                        $Output .= chr(13) . chr(10) . $Strings[$DR['LID']][2101] . ' ' . StringAdjust($SDR['UName']);
                    }
                    list($QR, $SSRS, $T) = QuerySet('SELECT D.DealID, UNIX_TIMESTAMP(D.DateEnds) AS DateEnds, COALESCE(LSDa.StringText, LSDb.StringText) AS Descr, D.DealPrice AS SPrice, D.DealValue AS RPrice,
                  COALESCE(STy.Icon, SC.Icon, "Blank") AS Icon, LD.LocationLatitude AS Lat,
                  GetDistance(' . $SDR['Lat'] . ', ' . $SDR['Lng'] . ', LD.LocationLatitude, LD.LocationLongitude) AS Dist,
                  COALESCE(STy.CategoryID, 0) AS CAID
                 FROM 4000_Deals D
                 LEFT JOIN 0200_Language_Strings LSDa ON D.StringID = LSDa.StringID AND LSDa.LanguageID = ' . $DR['LID'] . '
                 LEFT JOIN 0200_Language_Strings LSDb ON D.StringID = LSDb.StringID AND LSDb.LanguageID = 1
                INNER JOIN 2000_Stores ST ON D.StoreID = St.StoreID
                INNER JOIN 2200_Store_Locations SL ON SL.StoreID = ST.StoreID
                INNER JOIN 3000_Locations LD ON LD.LocationID = SL.LocationID
                 LEFT JOIN 2110_Store_Types STy ON ST.TypeID = STy.TypeID
                 LEFT JOIN 2100_Store_Categories SC ON STy.CategoryID = SC.CategoryID
                WHERE D.DateEnds > ' . date('YmdHis') . '
                  AND (GetDistance(' . $SDR['Lat'] . ', ' . $SDR['Lng'] . ', LD.LocationLatitude, LD.LocationLongitude) <= 100
                   OR (LD.LocationLatitude = -1 AND LD.LocationLongitude = -1 AND (LD.CountryID = ' . $SDR['CID'] . ' OR LD.CountryID = 0)))
                  AND (ST.TypeID NOT IN (' . $SDR['TFilt'] . '))
                  AND (D.DealID NOT IN (' . $SDR['DFilt'] . '))
                  AND (D.DealID > ' . $DR['DealID'] . ')
                GROUP BY D.DealID
                ORDER BY Dist;');
                    if ($QR == 0) {
                        if (($DR['Settings'] & 16) == 16) {
                            $Output .= '<hr style="border: 0; height: 1px; background-color: #C0C0C0;"></b></h2></td></tr><tr><td colspan=3><div style="color: #FF0000; font-weight: bold; font-size: 14px;">' . $Strings[$DR['LID']][2102] . '</div>' . $Strings[$DR['LID']][2103] . '</td></tr>';
                        } else {
                            $Output .= chr(13) . chr(10) . '-------------------------------------------------' . chr(13) . chr(10) . chr(13) . chr(10) . $Strings[$DR['LID']][2102] . chr(13) . chr(10) . $Strings[$DR['LID']][2103] . chr(13) . chr(10) . chr(13) . chr(10);
                        }
                    } elseif ($QR > 0) {
                        $Total = 0;
                        $SubOut = '';
                        while ($SSDR = mysql_fetch_array($SSRS)) {
                            if ($SSDR['DealID'] > $MaxDealID) {
                                $MaxDealID = $SSDR['DealID'];
                            }
                            $Match = true;
                            if ($SSDR['Lat'] != -1) {
                                foreach ($Categories as $Category) {
                                    if ($Category[0] == $SSDR['CAID']) {
                                        if ($SSDR['Dist'] > $Category[1]) {
                                            $Match = false;
                                            break;
                                        }
                                    }
                                }
                            }
                            if ($Match) {
                                if ($SSDR['Lat'] == -1) {
                                    $Dist = 'Web';
                                } else {
                                    $Dist = $SSDR['Dist'] . ' km';
                                }
                                $Days = (int) (($SSDR['DateEnds'] - time()) / 60 / 60 / 24);
                                if ($Days == 0) {
                                    $When = $Strings[$DR['LID']][2104];
                                } elseif ($Days == 1) {
                                    $When = $Strings[$DR['LID']][2105];
                                } else {
                                    $When = str_ireplace('%a', $Days, $Strings[$DR['LID']][2106]);
                                }
                                if (($DR['Settings'] & 16) == 16) {
                                    $SubOut .= '<tr valign="top"><td><a href="http://www.dealplotter.com/?' . $SSDR['DealID'] . '"><img src="http://www.dealplotter.com/IF/Marker-' . $SSDR['Icon'] . '.png" border=0></a></td><td style="padding-top: 8px;"><a style="color: #000080;" href="http://www.dealplotter.com/out.php?' . $SSDR['DealID'] . '"><em>' . $SSDR['Descr'] . '</em></a><div style="padding-top: 8px; font-size: 11px;"><a href="http://www.dealplotter.com/?' . $SSDR['DealID'] . '"><em>' . $Strings[$DR['LID']][2107] . '</em></a></div></td><td><table style="width: 90px; text-align: center; border: 1px solid #E0E0E0; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; font-weight: bold; color: #000080;" cellspacing=0><tr><td style="font-size: 15px; color: #00C000;"><span style="text-decoration: line-through; color: #404040; font-size: 12px;"><span style="color: #C0C0C0;"><del>' . number_format($SSDR['RPrice']) . '</del></span></span> ' . $SDR['CurS'] . number_format($SSDR['SPrice']) . '</td></tr><tr><td style="font-size: 14px;">' . $Dist . '</td></tr><tr><td><h6 style="font-size: 11px;">' . $When . '</h6></td></tr></table></td></tr>';
                                } else {
                                    $SubOut .= $SSDR['Descr'] . chr(13) . chr(10) . '- ' . $Strings[$DR['LID']][2113] . ': ' . $SDR['CurS'] . number_format($SSDR['RPrice']) . chr(13) . chr(10) . '- ' . $Strings[$DR['LID']][2114] . ': ' . $SDR['CurS'] . number_format($SSDR['SPrice']) . chr(13) . chr(10) . '- ' . $Strings[$DR['LID']][2115] . ': http://www.dealplotter.com/out.php?' . $SSDR['DealID'] . chr(13) . chr(10) . '- ' . $Strings[$DR['LID']][2107] . ': http://www.dealplotter.com/?' . $SSDR['DealID'] . chr(13) . chr(10) . chr(13) . chr(10);
                                }
                                $Total++;
                            }
                        }
                        if ($Total == 0) {
                            if (($DR['Settings'] & 16) == 16) {
                                $Output .= '<hr style="border: 0; height: 1px; background-color: #C0C0C0;"></td></tr><tr><td colspan=3><div style="color: #FF0000; font-weight: bold; font-size: 14px;">' . $Strings[$DR['LID']][2102] . '</div>' . $Strings[$DR['LID']][2103] . '</td></tr>';
                            } else {
                                $Output .= chr(13) . chr(10) . '-------------------------------------------------' . chr(13) . chr(10) . chr(13) . chr(10) . $Strings[$DR['LID']][2102] . chr(13) . chr(10) . $Strings[$DR['LID']][2103] . chr(13) . chr(10) . chr(13) . chr(10);
                            }
                        } else {
                            if (($DR['Settings'] & 16) == 16) {
                                $Output .= ' <span style="color: #000080;">(' . $Total . ')</span><hr style="border: 0; height: 1px; background-color: #C0C0C0;"></td></tr>';
                            } else {
                                $Output .= ' (' . $Total . ')' . chr(13) . chr(10) . '-------------------------------------------------' . chr(13) . chr(10) . chr(13) . chr(10);
                            }
                            if ($Total > 15) {
                                if (($DR['Settings'] & 16) == 16) {
                                    $Output .= '<tr><td colspan=3><table cellpadding=8 style="border: 1px solid #E0E0E0; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; background-color: #F8F8F8;"><tr><td width=20><img src="http://www.dealplotter.com/IF/Icon-Info.png"></td><td>' . $Strings[$DR['LID']][2111] . ' ' . $Strings[$DR['LID']][2103] . '</td></tr></table></td></tr>';
                                } else {
                                    $Output .= $Strings[$DR['LID']][2111] . ' ' . $Strings[$DR['LID']][2103] . chr(13) . chr(10) . chr(13) . chr(10);
                                }
                            }
                            $Output .= $SubOut;
                        }
                    }
                }
            }
            if (($DR['Settings'] & 16) == 16) {
                $Output .= '</table><br /><table style="font-size: 13px; border: 1px solid #E0E0E0; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; background-color: #F8F8F8;" cellpadding=8><tr><td>' . $Strings[$DR['LID']][2108] . ' <b><a href="http://www.dealplotter.com/?Shaddap&Key=' . $DR['CancelKey'] . '">' . $Strings[$DR['LID']][2109] . '</a></b> ' . $Strings[$DR['LID']][2110] . '</td></tr></table></body></html>';
            } else {
                $Output .= CleanHTML($Strings[$DR['LID']][2108]) . ': http://www.dealplotter.com/?Shaddap&Key=' . $DR['CancelKey'] . ' ' . CleanHTML(str_ireplace('<br />', chr(13) . chr(10), $Strings[$DR['LID']][2110]), false);
            }
            if (SendMail($Output, $Strings[$DR['LID']][2100] . ' - ' . date('Y-m-d'), $DR['UserEmail'])) {
                SysLogIt('Successfully sent digest for user with ID of ' . $DR['UserID'] . '.', StatusInfo, ActionNotSpecified, 0);
                if (!ExecCommand("UPDATE 1400_User_Notifications SET SentDate = " . date('YmdHis') . ", DealID = " . $MaxDealID . " WHERE NotificationID = " . $DR['NID'] . ";")) {
                    SysLogIt('Error updating notification entry with ID of ' . $DR['NID'] . '.', StatusError, ActionNotSpecified, 0);
                }
            } else {
                SysLogIt('Error sending digest for user with ID of ' . $DR['UserID'] . '.', StatusError);
            }
            //file_put_contents("Mail.html", $Output);
        }
        SysLogIt('Finished sending digests.', StatusInfo, ActionNotSpecified, 0);
    }
    return true;
}
示例#8
0
function CleanAll(&$Array)
{
    foreach ($Array as &$ArrItem) {
        if (!is_numeric($ArrItem) && !is_array($ArrItem)) {
            $ArrItem = CleanHTML($ArrItem);
        }
    }
}
示例#9
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));
     }
 }
示例#10
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));
 }
示例#11
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));
 }
示例#12
0
 public function GetDivisionData($SRID, $URL, $LID, $TZ, $Sub = false, $WebD = false)
 {
     global $DebugMode;
     list($Data, $DURL) = GetWebData('http://www.tuango.ca/en/deal/' . $URL);
     if ($Data === false) {
         return array(SysLogIt('Error getting web data.', StatusError), null);
     }
     if ($DebugMode) {
         file_put_contents("Tuango.txt", 'http://www.tuango.ca/en/deal/' . $URL . chr(13) . chr(10) . chr(13) . chr(10) . $Data);
     }
     if ($Sub) {
         if (stripos($Data, 'purchase?') === false) {
             return array(true, false);
         }
         $NewDeal = array("ID" => array('', 'class="dealName"', '/en/', '"', false), "Title" => array('', 'class="dealName"', '>', '</p>', false), "PriceSale" => array(0, 'class="dealPrice"', '$', '<', true), "PriceReg" => array(0, 'class="infoNumbers"', '$', '<', true), "StoreName" => array('', 'companyName', '<h2>', '</h2>', false), "Address" => array('', 'companyName', '</h2>', '<', false, true), "Website" => array('', 'companyName', 'href="', '"', false, true), "Description" => array('', 'companyDetails', '<p>', '</div>', false), "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]);
         if ($EndDate === false) {
             return array(SysLogIt('Could not determine deal end date.', StatusError), null);
         }
         $VExpiry = FindSubData($Data, '/ Ends', ' ', '<', false);
         if ($VExpiry !== false) {
             $VExpiry = strtotime($VExpiry);
         }
         if ($VExpiry === false) {
             $VExpiry = 0;
         }
         $Website = null;
         if ($NewDeal['Website'][0] !== false) {
             $Website = $NewDeal['Website'][0];
         }
         $Locations = array();
         $Address = null;
         if ($NewDeal['Address'][0] !== false) {
             $Address = $NewDeal['Address'][0];
         }
         if (stripos($Address, 'website') !== false) {
             $Locations[] = array(null, -1, -1);
         } else {
             $Locations[] = array($Address, 0, 0);
         }
         $TitleFR = false;
         list($Data, $DURL) = GetWebData('http://www.tuango.ca/fr/' . $NewDeal['ID'][0]);
         if ($Data !== false) {
             $TitleFR = FindSubData($Data, 'class="dealName"', '</span>', '</p>', false);
             if ($TitleFR !== false) {
                 $TitleFR = CleanHTML($TitleFR);
             }
         }
         $RData = array();
         $RData['DRID'] = $NewDeal['ID'][0];
         $RData['Title'] = CleanHTML(str_ireplace("Today's Deal:", "", $NewDeal['Title'][0]));
         if ($TitleFR !== false && $TitleFR != '') {
             $RData['Title-fr'] = $TitleFR;
         }
         $RData['Descr'] = $NewDeal['Description'][0];
         $RData['URL'] = 'http://www.tuango.ca/en/' . $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;
         return array(true, array($RData));
     } else {
         $RData = array();
         $RData['GW'] = true;
         $RData['EDate'] = 0;
         $MoreDeals = array();
         $Start = stripos($Data, 'class="gbItemInfo"');
         while ($Start !== false) {
             $ID = FindData($Data, "div", "href='/en/deal", "'", false, $Start, false);
             if ($ID !== false) {
                 $MoreDeals[] = $ID;
             }
             $Start = stripos($Data, 'class="gbItemInfo"', $Start + 20);
         }
         if (count($MoreDeals) > 0) {
             $RData['Deals'] = $MoreDeals;
         }
         return array(true, array($RData));
     }
 }
示例#13
0
 public function GetDivisionData($SRID, $URL, $LID, $TZ, $Sub = false, $WebD = false)
 {
     global $DebugMode;
     if ($Sub) {
         list($Data, $DURL) = GetWebData('http://www.maddeal.com' . $URL);
     } else {
         list($Data, $DURL) = GetWebData('http://www.maddeal.com' . $URL . '/');
     }
     if ($Data === false) {
         return array(SysLogIt('Error getting web data.', StatusError), null);
     }
     if ($DebugMode) {
         file_put_contents("Maddeal.txt", "http://www.maddeal.com" . $URL . chr(13) . chr(10) . chr(13) . chr(10) . $Data);
     }
     if (stripos($Data, 'NoDeal.jpg') !== false) {
         return array(true, false);
     }
     $NewDeal = array("ID" => array(0, '?did', '=', '"', true), "Title" => array('', 'class="boldheaderarial"', '>', '<', false), "Website" => array('', 'id="ctl00_cphBody_busWebsite"', 'href="', '"', false, true), "PriceSale" => array(0, 'id="ctl00_cphBody_dealPrice"', '>', '<', true), "PriceReg" => array('', 'id="ctl00_cphBody_dealValue"', '>', '<', false), "StoreName" => array('', 'id="ctl00_cphBody_busName"', '>', '<', false), "Description" => array('', 'id="ctl00_cphBody_decription"', '<p>', '<br />', false), "Address" => array('', 'id="ctl00_cphBody_busLocation"><a', '>', '</a>', false, true), "Coords" => array('', 'id="ctl00_cphBody_busLocation"', '(', ')', false, true), "EndDate" => array('', 'id="ctl00_cphBody_remaining"', '>', '<', false));
     if (!GetNewDealData($Data, $NewDeal)) {
         return array(SysLogIt('Error finding key deal information.', StatusError), null);
     }
     $StartDate = time();
     $EndDate = time();
     //Comming in HH:MM:SS
     list($hours, $minutes, $seconds) = explode(':', $NewDeal['EndDate'][0]);
     $EndDate += (int) $hours * 60 * 60;
     //Hours
     $EndDate += (int) $minutes * 60;
     //Minutes
     $EndDate += (int) $seconds;
     //Seconds
     if ($EndDate <= time()) {
         return array(SysLogIt('Could not determine deal end date.', StatusError), null);
     }
     $VExpiry = FindData($Data, chr(9) . chr(9) . 'Expires', '<', 9, 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];
     }
     $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="ctl00_cphBodyLeft_divLeft"');
     while ($Start !== false) {
         $ID = FindData($Data, "document.location.href='", "'", 24, 0, false, $Start, false);
         if ($ID !== false) {
             $MoreDeals[] = $ID;
         }
         $Start = stripos($Data, 'id="ctl00_cphBodyLeft_divLeft"', $Start + 20);
     }
     $RData = array();
     $RData['DRID'] = (int) $NewDeal['ID'][0];
     $RData['Title'] = $NewDeal['Title'][0];
     $RData['Descr'] = $NewDeal['Description'][0];
     if ($Sub) {
         $RData['URL'] = 'http://www.maddeal.com' . $URL . '&q=P22932';
     } else {
         $RData['URL'] = 'http://www.maddeal.com' . $URL . '?did=' . $NewDeal['ID'][0] . '&q=P22932';
         //http://www.maddeal.com/Canada/ON/Toronto/?did=216
     }
     $RData['Price'] = (double) $NewDeal['PriceSale'][0];
     $RData['Value'] = (double) substr($NewDeal['PriceReg'][0], 1);
     $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));
 }
示例#14
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));
 }
示例#15
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));
 }
示例#16
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));
 }
示例#17
0
function showexcerpt($content, $maxchars, $openWindow, $stripAll, $thisLink, $adjustImageSize, $float, $noFollow, $mediaImage, $catID = 0, $stripSome = 0, $feedHomePage = Null, $noProcess = 0, $useMediaImage = 0)
{
    $content = rssmi_strip_read_more($content);
    global $ftp;
    global $morestyle;
    $content = CleanHTML($content, $thisLink);
    if ($noProcess == 0) {
        if ($stripAll == 1) {
            $content = strip_tags(html_entity_decode($content));
            $content = limitwords($maxchars, $content);
        } else {
            if ($ftp == 1) {
                //	$content=html_entity_decode(pre_esc_html($content));
                $content = html_entity_decode(pre_esc_html($content), ENT_QUOTES, 'UTF-8');
                //	$content=pre_esc_html($content);
            } else {
                if ($maxchars != 99) {
                    $content = strip_tags(html_entity_decode($content), '<a><img><p><br>');
                }
            }
            $content = findalignImage($maxchars, $content, $adjustImageSize, $float, $openWindow, $mediaImage, $thisLink, $noFollow, $catID, $thisLink, $stripSome, $useMediaImage);
        }
    }
    $content = str_replace("<a ", "<a  " . $openWindow . ' ' . ($noFollow == 1 ? 'rel="nofollow"  ' : ''), $content);
    if ($ftp != 1 && $morestyle != '' || $ftp == 1 && $morestyle != "NONE") {
        $content = str_replace($morestyle, "<a href=\"" . $thisLink . "\" " . $openWindow . ' ' . ($noFollow == 1 ? 'rel="nofollow"' : '') . " id=\"rssmi_more\">" . $morestyle . "</a>", $content);
    }
    if ($noFollow == 1) {
        $content = dont_follow_links($content);
    }
    return $content;
}
示例#18
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));
 }
function showexcerpt($content, $maxchars, $openWindow, $stripAll, $thisLink, $adjustImageSize, $float, $noFollow, $mediaImage, $catID = 0, $stripSome = 0)
{
    global $ftp;
    global $morestyle;
    $content = CleanHTML($content);
    if ($stripAll == 1) {
        $content = strip_tags(html_entity_decode($content));
        $content = limitwords($maxchars, $content);
    } else {
        if ($ftp == 1) {
            $content = html_entity_decode(pre_esc_html($content));
        } else {
            if ($maxchars != 99) {
                $content = strip_tags(html_entity_decode($content), '<a><img><p>');
            }
        }
        if ($maxchars != 99) {
            $content = findalignImage($maxchars, $content, $adjustImageSize, $float, $openWindow, $mediaImage, $thisLink, $noFollow, $catID, $stripSome);
        }
    }
    $content = str_replace("<a ", "<a  " . $openWindow . ' ' . ($noFollow == 1 ? 'rel="nofollow"  ' : ''), $content);
    $content = str_replace($morestyle, "<a href=\"" . $thisLink . "\" " . $openWindow . ' ' . ($noFollow == 1 ? 'rel="nofollow"' : '') . " id=\"rssmore\">" . $morestyle . "</a>", $content);
    return $content;
}
示例#20
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));
 }
示例#21
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));
 }
示例#22
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);
 }
示例#23
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));
 }
示例#24
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));
 }
示例#25
0
 public function GetDivisionData($SRID, $URL, $LID, $TZ, $Sub = false, $WebD = false)
 {
     global $DebugMode;
     list($Data, $DURL) = GetWebData('http://www.livingsocial.com/cities/' . $URL, null, 'seen-roadblock=1');
     if ($Data === false) {
         return array(SysLogIt('Error getting web data.', StatusError), null);
     }
     if ($DebugMode) {
         file_put_contents("LivingSocial.txt", "http://www.livingsocial.com/cities/" . $URL . chr(13) . chr(10) . chr(13) . chr(10) . $Data);
     }
     if (stripos($Data, 'More Cities - LivingSocial') !== false) {
         return array(true, false);
     }
     $NewDeal = array("ID" => array(0, 'og:url', '/deals/', '-', true), "Title" => array('', 'class="deal-title"', '<p>', '</p>', false), "Website" => array('', 'id="sfwt_full_1"', 'href="', '"', false), "PriceSale" => array('', 'class="deal-price', '</span>', '</div>', false), "PercOff" => array(0, 'id="percentage"', '>', '%', true), "StoreName" => array('', 'class="deal-title"', '<h1>', '</h1>', false), "Description" => array('', 'id="sfwt_full_1"', '<p>', '</p>', false), "Address" => array('', '<span class="street_1"', '>', '|', false, true), "Phone" => array('', 'class="phone"', '>', '<', false, true));
     if (!GetNewDealData($Data, $NewDeal)) {
         return array(SysLogIt('Error finding key deal information.', StatusError), null);
     }
     $StartDate = time();
     $VExpiry = FindData($Data, 'expires on ', '</p>', 11, 3, false, 0, false);
     $VExpiry = $VExpiry === false ? 0 : strtotime($VExpiry);
     if ($VExpiry === false) {
         $VExpiry = 0;
     }
     $Expiry = FindData($Data, '<div id="countdown">', '</div>', 20, 0, false, 0, false);
     if ($Expiry === false) {
         SysLogIt('No countdown timer found. Switching to secondary detection.');
         $Days = FindSubData($Data, '<li class="last">', '<div class="value">', 'day', true);
         if ($Days === false) {
             $Days = 0;
         }
         $EndDate = mktime(5 - ($TZ + 5), 0, 0, date('n'), date('j') + (date('H') > 5 - ($TZ + 5) ? 1 : 0) + $Days, date('Y'));
     } else {
         $ExpParts = explode('<span class="colon">:</span>', $Expiry);
         foreach ($ExpParts as &$ExpPart) {
             $ExpPart = FindData($ExpPart, '<span class="num">', '</span>', 18, 0, true);
         }
         if ($ExpParts[0] === false || $ExpParts[1] === false || $ExpParts[2] === false) {
             $EndDate = mktime(5 - ($TZ + 5), 0, 0, date('n'), date('j') + (date('H') > 5 - ($TZ + 5)) ? 1 : 0, date('Y'));
         } else {
             $EndDate = mktime(date('H') + $ExpParts[0], date('i') + $ExpParts[1], date('s') + $ExpParts[2], date('n'), date('j'), date('Y'));
         }
     }
     $Address = null;
     if ($NewDeal['Address'][0] !== false) {
         $Address = CleanHTML($NewDeal['Address'][0]);
     }
     //if ($NewDeal['Phone'][0] !== false) $Address .= $NewDeal['Phone'][0];
     if ($Address == '') {
         $Address = null;
     }
     $Coords = FindData($Data, 'maps?q=', '"', 7, 0, false, 0, false);
     if ($Coords !== false) {
         $Coords = explode(',', $Coords);
         if ($Coords === false || count($Coords) != 2) {
             $Coords = array(0, 0);
         }
     } else {
         $Coords = array(0, 0);
     }
     $RData = array();
     $RData['DRID'] = $NewDeal['ID'][0];
     $RData['Title'] = $NewDeal['Title'][0] . ' - ' . $NewDeal['StoreName'][0];
     $RData['Descr'] = $NewDeal['Description'][0];
     $RData['URL'] = 'http://www.livingsocial.com/deals/' . $NewDeal['ID'][0];
     $RData['Price'] = (double) $NewDeal['PriceSale'][0];
     $RData['Value'] = (double) ($NewDeal['PriceSale'][0] / (1 - $NewDeal['PercOff'][0] / 100));
     $RData['Status'] = 0;
     $RData['SDate'] = $StartDate;
     $RData['EDate'] = $EndDate;
     $RData['VDate'] = $VExpiry;
     $RData['StoreName'] = $NewDeal['StoreName'][0];
     $RData['Website'] = $NewDeal['Website'][0];
     $RData['Locations'] = array(array($Address, $Coords[0], $Coords[1]));
     return array(true, array($RData));
 }