$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, "/");
         header("Location: account");
     } else {
         // user has already completed the offer to receive $10 credit
         setcookie("msg", "You have already received a \$10 credit.", time() + 300, "/");
         setcookie("msg_type", "error", time() + 300, "/");
         header("Location: account");
     }
 }
 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();
 }
Example #3
0
 public function SaveSurvey()
 {
     # Save Survey Data
     $_SESSION["step"] = 3;
     if (isset($this->localData["user"]["survey-btn"])) {
         // save survey
         $interests = array();
         $interests[] = "<interests>";
         foreach ($_POST["user"]["deals"] as $interest_num => $value) {
             // loop through user interested deals
             $interests[] = "<{$interest_num}>{$value}</{$interest_num}>";
         }
         $interests[] = "</interests>";
         $interests = join("\n", $interests);
         // Update Questionnaire
         parent::SetQuery("UPDATE `table_questionnaire` SET\n\t\t\tdob='" . strtotime($_POST["user"]["dob_month"] . " " . $_POST["user"]["dob_day"] . " " . $_POST["user"]["dob_year"]) . "',\n\t\t\tincome_level='{$_POST["user"]["income"]}',\n\t\t\tlocation_city='{$_POST["user"]["city"]}',\n\t\t\tlocation_state='{$_POST["user"]["state"]}',\n\t\t\teducation='{$_POST["user"]["education"]}',\n\t\t\tgender='{$_POST["user"]["gender"]}',\n\t\t\tinterests='{$interests}' WHERE user_id='{$_GET["user_id"]}'");
         parent::SimpleQuery();
         setcookie("user_id", "", time() - 86400, "/");
         $_SESSION["survey_complete"] = 1;
         header("Location: survey?complete=true");
     } else {
         if (isset($this->localData["user"]["skip-btn"])) {
             // skip survey
             setcookie("user_id", "", time() - 86400, "/");
             $_SESSION["survey_complete"] = 1;
             header("Location: survey?skip=true");
         }
     }
 }