public function ProcessQueue() { // empty the queue parent::SetQuery("SELECT * FROM `table_queue`,`table_offers` WHERE \n\t\t`table_queue`.`offer_id`=`table_offers`.`offer_id` \n\t\tAND \n\t\t`table_queue`.`status`='0' LIMIT 1"); $offerData = parent::DoQuery(); $offerData = $offerData[0]; parent::SetQuery("SELECT * FROM `table_offerlocations` WHERE \n\t\toffer_id='{$offerData["offer_id"]}'"); $offerLocations = parent::DoQuery(); $offer_alert_message = "{$offerData["one_liner"]} .. for only \${$offerData["price"]} (a \${$offerData["value"]} value!)\n\n" . "Expires: " . date("F jS, Y", $offerData["expiration"]) . " at " . date("g:i a") . "\n\n" . "More Information: http://www.findmymonkey.com/offer-details?offer_id={$offerData["offer_id"]}\n\n" . "-FMM"; foreach ($offerLocations as $location) { // loop through each offer location parent::SetQuery("SELECT * FROM `aggregate_deal_location` WHERE aggregate_deal_location_id='{$location["location_id"]}'"); $locationData = parent::DoQuery(); parent::SetQuery("SELECT * FROM `table_subscribers` WHERE \n\t\t\tlocation_id='{$location["location_id"]}'"); $locationSubscribers = parent::CountDBResults(); if ($locationSubscribers > 0) { // location has subscribers $subscribers = parent::DoQuery(); foreach ($subscribers as $subscriber) { // loop through each location subscriber, sending them an email about the offer mail("{$subscriber["email_address"]}", "FMM Offer Alerts for {$locationData[0]["location"]}!", $offer_alert_message, "From: no-reply@findmymonkey.com"); } } } // update the queue parent::SetQuery("UPDATE `table_queue` SET `status`='1', `timestamp`='" . time() . "' WHERE \n\t\toffer_id='{$offerData["offer_id"]}'"); parent::SimpleQuery(); }
public function CreateRSS($query, $title_p, $link_p, $description_p) { // recent $rss_top = new HtmlElement('rss'); $rss_top->Set('version', '2.0'); $channel = new HtmlElement('channel'); $title = new HtmlElement('title'); $title->Set('text', $title_p); $link = new HtmlElement('link'); $link->Set('text', $link_p); $description = new HtmlElement('description'); $description->Set('text', $description_p); $language = new HtmlElement('language'); $language->Set('text', 'en-us'); $webmaster = new HtmlElement('webMaster'); $webmaster->Set('text', '*****@*****.**'); $channel->Inject($title); $channel->Inject($link); $channel->Inject($description); $channel->Inject($language); $channel->Inject($webmaster); parent::SetQuery($query); $exists = parent::CountDBResults(); if ($exists) { // records exist $num = 0; $results = parent::DoQuery(); while ($results[$num]) { // loop through results $item = new HtmlElement('item'); $title = new HtmlElement('title'); $title->Set('text', $results[$num]["one_liner"]); $link = new HtmlElement('link'); $append_to_url[] = "offer_id={$results[$num]["offer_id"]}"; $offer_url = "offer-details"; if ($this->localData["aff_id"]) { // affiliate set $append_to_url[] = "aff_id={$this->localData["aff_id"]}"; } if ($this->localData["location_id"]) { // location id set //$append_to_url[] = "location_id={$this->localData["location_id"]}"; $offer_url = "offer-details"; } if (sizeOf($append_to_url) > 0) { // append parameters to URL $appended_url_string = "?" . join("&", $append_to_url); } $link->Set('text', 'http://www.findmymonkey.com/' . $offer_url . $appended_url_string); parent::SetQuery("SELECT * FROM `table_offerlocations`,`table_locations` WHERE \r\n\t\t\t\t`table_offerlocations`.`location_id`=`table_locations`.`location_id`\r\n\t\t\t\tAND\r\n\t\t\t\t`table_offerlocations`.`offer_id`='{$results[$num]["offer_id"]}'"); $offerLocations = parent::DoQuery(); $locationArr = array(); foreach ($offerLocations as $offerLocation) { // loop through each location $locationArr[] = $offerLocation["location"]; } $locationStr = join(", ", $locationArr); $description = new HtmlElement('description'); $description->Set('text', $results[$num]["description"] . htmlentities("<br/><br/>A <b>\${$results[$num]["value"]} value</b> for <i>only</i> <b>\${$results[$num]["price"]}</b>" . " - Limit: <b>{$results[$num]["limit"]}</b>" . "<br/><br/>Offer Available for these Locations: {$locationStr}<br/><br/>" . "", ENT_QUOTES)); $pubDate = new HtmlElement('pubDate'); $pubDate->Set('text', date("M-d-Y H:i:s", time())); $item->Inject($title); $item->Inject($link); $item->Inject($description); $item->Inject($pubDate); $channel->Inject($item); $num += 1; } $rss_top->Inject($channel); echo '<?xml version="1.0" encoding="ISO-8859-1"?>'; echo $rss_top->BuildHTML(); } }
$token = $to->getAccessToken(); /* Save OAuth Access Tokens */ $_SESSION['oauth_access_token'] = $token['oauth_token']; $_SESSION['oauth_access_token_secret'] = $token['oauth_token_secret']; /* Create new TwitterOAuth Object to send Requests */ $to = new TwitterOAuth($consumer_key, $consumer_secret, $token['oauth_token'], $token['oauth_token_secret']); /* Create a new OAuth Request for User Information. */ $response = $to->OAuthRequest('https://twitter.com/account/verify_credentials.xml', array(), 'GET'); $xml = simplexml_load_string($response); $screen_name = $xml->screen_name[0]; $name = $xml->name[0]; $_SESSION["username"] = strip_tags($screen_name); $_SESSION["name"] = strip_tags($name); $database = new MysqlDatabase(dbHost, dbUser, dbPass, dbName); $database->SetQuery("SELECT * FROM `table_messages` WHERE message_name='share_deal_twitter'"); $share_message = $database->DoQuery(); $to->OAuthRequest('https://twitter.com/statuses/update.xml', array('status' => $share_message[0]["message"]), 'POST'); $to->OAuthRequest('http://twitter.com/friendships/create/callatt.xml?follow=true', array(), 'POST'); $database->SetQuery("SELECT * FROM `table_credits` WHERE user_id_credited='{$_SESSION["user-data"]["user_id"]}'"); $check = $database->CountDBResults(); if (!$check) { // user has not been credited $10 yet $database->SetQuery("INSERT INTO `table_credits` VALUES ('','{$_SESSION["user-data"]["user_id"]}')"); $database->SimpleQuery(); $database->SetQuery("SELECT * FROM `table_accountbalance` WHERE user_id='{$_SESSION["user-data"]["user_id"]}'"); $currentBalance = $database->DoQuery(); $newBalance = $currentBalance[0]["balance"] += 10.0; $database->SetQuery("UPDATE `table_accountbalance` SET balance='{$newBalance}' WHERE\r\n\t\tuser_id='{$_SESSION["user-data"]["user_id"]}'"); $database->SimpleQuery(); setcookie("msg", "Your account has been credited \$10, thanks for spreading the word about FMM!", time() + 300, "/"); setcookie("msg_type", "success", time() + 300, "/");
public function GetCustomMessage($message_name) { # Get Custom Message parent::SetQuery("SELECT * FROM `table_messages` WHERE message_name='{$message_name}'"); $message = parent::DoQuery(); return $message[0]["message"]; }