Beispiel #1
0
 /**
  * @before _secure
  */
 public function campaign($id)
 {
     $ad = \Ad::first(['_id' => $id, 'org_id' => $this->org->_id]);
     if (!$ad) {
         $this->_404();
     }
     $this->seo(["title" => $ad->title]);
     $view = $this->getActionView();
     if (RM::post("action")) {
         // action value already checked in _postback func
         $this->_postback('add', ['ad' => $ad]);
     }
     if (RM::type() === 'DELETE') {
         $this->_postback('delete');
     }
     $start = RM::get("start", date('Y-m-d', strtotime("-7 day")));
     $end = RM::get("end", date('Y-m-d'));
     $limit = RM::get("limit", 10);
     $page = RM::get("page", 1);
     $query = ['adid' => Db::convertType($id), 'created' => Db::dateQuery($start, $end)];
     $clicks = \Click::all($query, [], 'created', 'desc', $limit, $page);
     $count = \Click::count($query);
     $cf = Utils::getConfig("cf", "cloudflare");
     $view->set("domain", $cf->api->domain)->set("clicks", $clicks)->set("count", $count)->set('advertiser', $this->user);
     $comms = Commission::all(["ad_id = ?" => $id], ['model', 'coverage', 'revenue', 'description']);
     $models = ArrayMethods::arrayKeys($comms, 'model');
     $advertiser = User::first(["id = ?" => $ad->user_id], ['name']);
     $categories = \Category::all(["org_id = ?" => $this->org->_id], ['name', '_id']);
     $this->_postback('show', ['ad' => $ad]);
     $view->set("ad", $ad)->set("comms", $comms)->set("categories", $categories)->set("advertiser", $advertiser)->set('models', $models)->set("start", $start)->set("end", $end);
 }
Beispiel #2
0
 /**
  * @before _secure
  */
 public function campaign($id)
 {
     $ad = \Ad::first(["_id = ?" => $id, 'org_id' => $this->org->_id]);
     if (!$ad) {
         $this->_404();
     }
     $this->seo(array("title" => $ad->title));
     $view = $this->getActionView();
     if (RM::get("action") == "permission" && array_key_exists("permission", $ad->meta)) {
         $search = ["org_id" => $this->org->id, "ad_id" => $id, "user_id" => $this->user->id];
         $access = AdAccess::first($search);
         // Check before saving to prevent duplication of records
         if (!$access) {
             $access = new AdAccess($search);
             $access->save();
         }
     }
     if (RM::post("action")) {
         // action value already checked in _postback func
         $this->_postback('add', ['ad' => $ad]);
     }
     if (RM::type() === 'DELETE') {
         $this->_postback('delete');
     }
     $this->_postback('show', ['ad' => $ad]);
     $start = RM::get("start", date('Y-m-d', strtotime("-7 day")));
     $end = RM::get("end", date('Y-m-d'));
     $limit = RM::get("limit", 10);
     $page = RM::get("page", 1);
     $query = ['adid' => Db::convertType($id), 'created' => Db::dateQuery($start, $end)];
     $clicks = \Click::all($query, [], 'created', 'desc', $limit, $page);
     $count = \Click::count($query);
     $cf = Utils::getConfig('cf', 'cloudflare');
     $view->set("domain", $cf->api->domain)->set("clicks", $clicks)->set("count", $count)->set('advertiser', $this->user);
     $comms = Commission::all(["ad_id = ?" => $id]);
     $models = [];
     foreach ($comms as $comm) {
         $models[] = $comm->model;
     }
     $advertiser = User::first(["id = ?" => $ad->user_id], ['name']);
     $categories = \Category::all(["org_id = ?" => $this->org->_id], ['name', '_id']);
     $view->set("ad", $ad)->set("comms", $comms)->set("categories", $categories)->set("advertiser", $advertiser)->set('models', $models)->set("start", $start)->set("end", $end)->set('tdomains', \Shared\Services\User::trackingLinks($this->user, $this->org));
 }
 public function get_stats()
 {
     //Todo in progress
     $clicks = Click::all();
     $totalcount = $clicks->count();
     //Yes this is really messy.....
     $uniqueclicks = DB::select(DB::raw("SELECT COUNT(DISTINCT ip) FROM clicks"));
     foreach ($uniqueclicks[0] as $uc) {
         break;
     }
     return View::make('console.stats')->with(array("uniqueclicks" => $uc, "count" => $totalcount));
 }