Example #1
0
 public function index_onArchive()
 {
     if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) {
         foreach ($checkedIds as $messageId) {
             if (!($message = Message::find($messageId))) {
                 continue;
             }
             CampaignManager::instance()->archiveCampaign($message);
         }
         Flash::success('Successfully archived these mailings');
     } else {
         Flash::error('There are no mailings selected to archive.');
     }
     return $this->listRefresh();
 }
Example #2
0
 protected function validateCampaignCode($code)
 {
     if (ends_with($code, '.png')) {
         $this->trackingMode = true;
         $code = substr($code, 0, -4);
     }
     $parts = explode('!', base64_decode($code));
     if (count($parts) < 3) {
         throw new ApplicationException('Invalid code');
     }
     list($campaignId, $subscriberId, $hash) = $parts;
     //        echo "campaignId=$campaignId<br>";
     //        echo "subscriberId=$subscriberId<br>";
     //        echo "hash=$hash<br>";
     //        exit;
     /*
      * Render unique content for the subscriber
      */
     $this->campaign = Message::find((int) $campaignId);
     //        var_dump($this->campaign);
     //        echo "<br><br><br><br>";
     //        exit;
     //        $this->subscriber = DB::table('leancode_campaign_subscribers')->where('id', (int) $subscriberId)->first();
     //        var_dump($this->subscriber);
     //        echo "<br><br><br><br>";
     //        exit;
     $this->subscriber = $this->campaign->subscribers()->where('id', (int) $subscriberId)->first();
     if (!$this->subscriber) {
         $this->subscriber = Subscriber::find((int) $subscriberId);
     }
     if (!$this->campaign || !$this->subscriber) {
         throw new ApplicationException('Invalid code');
     }
     /*
      * Verify unique hash
      */
     $verifyValue = $campaignId . '!' . $subscriberId;
     $verifyHash = md5(env('APP_KEY') . $verifyValue . '!' . $this->subscriber->email);
     if ($hash != $verifyHash) {
         throw new ApplicationException('Invalid hash');
     }
 }