/** * Forward Tracker * * @return void */ private function forwardTrackingTask() { //get reqest vars $token = Request::getVar('t', ''); //parse mailing token $recipient = Helper::parseMailingToken($token); //if we found an object lets track it if (is_object($recipient) && $recipient->id) { //new mailing recipient action objec $newsletterMailingRecipientAction = new MailingRecipientAction($this->database); //create object holding our vars to store action $action = new stdClass(); $action->mailingid = $recipient->mid; $action->action = 'forward'; $action->action_vars = null; $action->email = $recipient->email; $action->ip = $_SERVER['REMOTE_ADDR']; $action->user_agent = $_SERVER['HTTP_USER_AGENT']; $action->date = \Date::toSql(); //save action $newsletterMailingRecipientAction->save($action); } }
/** * Get Opens and Return as JSON * * @param [type] $mailingId [description] * @return [type] [description] */ public function getOpensGeoTask($mailingId = null) { //are we getting through ajax $no_html = Request::getInt('no_html', 0); //get the mailing id if (is_null($mailingId)) { $mailingId = Request::getVar('mailingid', 0); } $states = array("alabama" => 'al', "alaska" => 'ak', "arizona" => 'az', "arkansas" => 'ar', "california" => 'ca', "colorado" => 'co', "connecticut" => 'ct', "delaware" => 'de', "florida" => 'fl', "georgia" => 'ga', "hawaii" => 'hi', "idaho" => 'id', "illinois" => 'il', "indiana" => 'in', "iowa" => 'ia', "kansas" => 'ks', "kentucky" => 'ky', "louisiana" => 'la', "maine" => 'me', "maryland" => 'md', "massachusetts" => ' ma', "michigan" => 'mi', "minnesota" => 'mn', "mississippi" => 'ms', "missouri" => 'mo', "montana" => 'mt', "nebraska" => 'ne', "nevada" => 'nv', "new hampshire" => 'nh', "new jersey" => 'nj', "new mexico" => 'nm', "new york" => 'ny', "north carolina" => 'nc', "north dakota" => 'nd', "ohio" => 'oh', "oklahoma" => 'ok', "oregon" => 'or', "pennsylvania" => 'pa', "rhode island" => 'ri', "south carolina" => 'sc', "south dakota" => 'sd', "tennessee" => 'tn', "texas" => 'tx', "utah" => 'ut', "vermont" => 'vt', "virginia" => 'va', "washington" => 'wa', "west virginia" => 'wv', "wisconsin" => 'wi', "wyoming" => 'wy'); //new mailing recipient action object $newsletterMailingRecipientAction = new MailingRecipientAction($this->database); //get opens $opens = $newsletterMailingRecipientAction->getMailingActions($mailingId, 'open'); //get country and state data $countryGeo = array(); $statesGeo = array(); foreach ($opens as $open) { $country = $open->countrySHORT ? strtolower($open->countrySHORT) : 'undetermined'; $state = $open->ipREGION ? 'us-' . strtolower($states[strtolower($open->ipREGION)]) : 'undetermined'; $countryGeo[$country] = isset($countryGeo[$country]) ? $countryGeo[$country] + 1 : 1; $statesGeo[$state] = isset($statesGeo[$state]) ? $statesGeo[$state] + 1 : 1; } //build return object $geo = array('country' => $countryGeo, 'state' => $statesGeo); //return if ($no_html) { echo json_encode($geo); exit; } else { return $geo; } }