public function getView($slug) { $game = $this->getModelFromSlug($slug); $products = $game->products()->orderBy('created_at', 'DESC')->get(); $platforms = Platform::all(); $conditions = Condition::all(); return View::make('site/game/view_game', compact('game', 'products', 'platforms', 'conditions')); }
public static function rssFeeds($org) { $users = \User::all(['org_id' => $org->_id, 'type' => 'advertiser'], ['_id']); $in = []; $result = []; foreach ($users as $u) { $in[] = $u->_id; } $platforms = \Platform::all(['user_id' => ['$in' => $in]], ['_id', 'url', 'user_id', 'meta']); foreach ($platforms as $p) { if (isset($p->meta['rss'])) { $result[Utils::getMongoID($p->_id)] = $p; } } return $result; }
/** * @before _secure */ public function platforms() { $this->seo(array("title" => "List of Platforms")); $view = $this->getActionView(); if (RM::type() === 'POST') { $pid = RM::post('pid'); try { if ($pid) { $p = \Platform::first(['_id = ?' => $pid]); } else { $p = new \Platform(['user_id' => $this->user->_id, 'live' => true]); } $p->url = RM::post('url'); $p->save(); $view->set('message', 'Platform saved successfully!!'); } catch (\Exception $e) { $view->set('message', $e->getMessage()); } } $platforms = \Platform::all(["user_id = ?" => $this->user->_id], ['_id', 'url']); $results = []; $start = RM::get("start", date('Y-m-d', strtotime('-7 day'))); $end = RM::get("end", date('Y-m-d', strtotime('-1 day'))); $dateQuery = Utils::dateQuery(['start' => $start, 'end' => $end]); foreach ($platforms as $p) { $key = Utils::getMongoID($p->_id); } $view->set("platforms", $results)->set("start", $start)->set("end", $end); }
/** * @before _secure * @after _displayData */ public function platforms($id = null) { $this->seo(["title" => "Platform wise click stats"]); $view = $this->getActionView(); $org = $this->org; $clickCol = Registry::get("MongoDB")->clicks; // find the platforms $platforms = \Platform::all(['user_id' => ['$in' => $org->users('advertisers')]], ['_id', 'url']); if (count($platforms) === 0) { return $view->set(['platforms' => [], 'publishers' => []]); } $key = array_rand($platforms); $url = RM::get('link', $platforms[$key]->url); // find ads having this url $ads = \Ad::all(['org_id' => $org->_id], ['_id', 'url']); $in = Utils::mongoObjectId(array_keys($ads)); $matched = []; foreach ($ads as $a) { $regex = preg_quote($url, '.'); if (preg_match('#^' . $regex . '#', $a->url)) { $matched[] = Utils::mongoObjectId($a->_id); } } if (count($matched) === 0) { $query['adid'] = ['$in' => $in]; } else { $query['adid'] = ['$in' => $matched]; } $query['is_bot'] = false; $query['created'] = Db::dateQuery($this->start, $this->end); $records = $clickCol->aggregate([['$match' => $query], ['$projection' => ['_id' => 1, 'pid' => 1]], ['$group' => ['_id' => '$pid', 'count' => ['$sum' => 1]]], ['$sort' => ['count' => -1]]]); $result = []; $publishers = []; foreach ($records as $r) { $obj = (object) $r; $id = Utils::getMongoID($obj->_id); $user = User::first(['_id' => $id], ['_id', 'name']); $result[$id] = (object) ['_id' => $user->_id, 'name' => $user->name, 'clicks' => $obj->count]; } $view->set(['platforms' => $platforms, 'link' => $url, 'publishers' => $result]); }
$pageTitle = 'Report Options'; include 'templates/header.php'; ?> <script type="text/javascript" src="js/reporting.js"></script> <table class="headerTable"> <tr><td> <div class="headerText" style='margin-bottom:9px;'>Publisher / Platform Reporting Administrative Update</div> <b>Directions:</b> Mark the checkboxes to add / remove specific Platforms or Publishers to the default report list.<br />Click 'edit report display name' to change the display name in the reporting system for specific Platforms or Publishers. <br /><br /> <?php $platformObj = new Platform(); $platform = new Platform(); $platformArray = array(); $platformArray = $platformObj->all(); if (count($platformArray) > 0) { echo "Available<br />As Default<br />Report"; echo "<div style='line-height:130%;'>"; foreach ($platformArray as $platform) { if ($platform->reportDropDownInd == '1') { $reportDropDownInd = 'checked'; } else { $reportDropDownInd = ''; } echo "<div id = 'div_platform_" . $platform->platformID . "'>"; echo "<input type='checkbox' id='chk_platform_" . $platform->platformID . "' onclick='javascript:updatePlatformDropDown(" . $platform->platformID . ");' {$reportDropDownInd}>"; echo " <span class='PlatformText'>" . $platform->name . "</span>"; if ($platform->reportDisplayName) { echo " (<i>" . $platform->reportDisplayName . "</i>)"; }
/** * @before _secure */ public function platforms($id = null) { $this->seo(array("title" => "Platforms")); $view = $this->getActionView(); $query['user_id'] = ['$in' => $this->org->users('publisher')]; $limit = RM::get("limit", 20); $page = RM::get("page", 1); $property = RM::get("property", ''); $value = RM::get("value"); if (in_array($property, ["live", "user_id"])) { $query["{$property} = ?"] = $value; } else { if (in_array($property, ["url"])) { $query[$property] = Utils::mongoRegex($value); } } if (RM::type() === 'POST') { $p = \Platform::first(['_id' => $id, 'user_id' => $query['user_id']]); if (!$p) { return $view->set('message', "Invalid Request!!"); } try { $updateAble = ['live', 'user_id', 'url']; foreach ($_POST as $key => $value) { if (in_array($key, $updateAble)) { $p->{$key} = $value; } } $p->save(); return $view->set('message', 'Platform updated!!'); } catch (\Exception $e) { return $view->set('message', "Invalid Request Parameters!!"); } } if (RM::type() === 'DELETE') { $p = \Platform::first(['_id' => $id, 'user_id' => $query['user_id']]); if (!$p) { return $view->set('message', "Invalid Request!!"); } $p->delete(); return $view->set('message', "Platform Removed!!"); } $platforms = Platform::all($query, [], 'created', 'desc', $limit, $page); $count = Platform::count($query); $view->set("platforms", $platforms)->set("count", $count)->set("property", $property)->set("value", $value)->set("limit", $limit)->set("page", $page); }
/** * @before _admin */ public function info($id = null) { $this->seo(array("title" => "Publisher Edit")); $view = $this->getActionView(); $publisher = User::first(["_id = ?" => $id, "type = ?" => "publisher", "org_id = ?" => $this->org->id]); if (!$publisher) { $this->_404(); } $platforms = Platform::all(["user_id = ?" => $publisher->id]); $view->set("platforms", $platforms); $view->set("errors", []); if (RM::type() == 'POST') { $action = RM::post('action', ''); switch ($action) { case 'account': $fields = ['name', 'email', 'phone', 'country', 'currency', 'username']; foreach ($fields as $f) { $publisher->{$f} = RM::post($f); } $publisher->save(); $view->set('message', 'Account Info updated!!'); break; case 'password': $old = RM::post('password'); $new = RM::post('npassword'); $view->set($publisher->updatePassword($old, $new)); break; case 'campaign': $publisher->getMeta()['campaign'] = ['model' => RM::post('model'), 'rate' => $this->currency(RM::post('rate'))]; $publisher->save(); $view->set('message', 'Payout Info Updated!!'); break; case 'trackingDomain': $tdomain = (array) RM::post('tdomain', ''); if ($tdomain && ArrayMethods::inArray($this->org->tdomains, $tdomain)) { $publisher->getMeta()['tdomain'] = $tdomain; $publisher->save(); $view->set('message', 'Added Tracking Domain for publisher'); } else { $view->set('message', 'Invalid Request!!'); } case 'commadd': case 'commedit': $comm_id = RM::post('comm_id'); if ($comm_id) { $comm = Commission::first(['_id' => $comm_id, 'user_id' => $publisher->_id]); } else { $comm = new Commission(['user_id' => $publisher->_id]); } $comm->model = RM::post('model'); $comm->description = RM::post('description'); $comm->rate = $this->currency(RM::post('rate')); $comm->coverage = RM::post('coverage', ['ALL']); $comm->save(); $view->set('message', "Multi Country Payout Saved!!"); break; } } if (RM::type() === 'DELETE') { $action = RM::get("action"); switch ($action) { case 'payoutdel': unset($publisher->getMeta()['campaign']); $publisher->save(); $view->set('message', 'Payout Deleted!!'); break; case 'commDel': $comm = Commission::first(['_id' => RM::get("comm_id"), 'user_id' => $publisher->_id]); if ($comm) { $comm->delete(); $view->set('message', 'Payout Deleted!!'); } else { $view->set('message', 'Invalid Request!!'); } break; case 'afields': $meta = $publisher->meta; $publisher->removeFields(); unset($meta['afields']); Db::updateRaw('users', ['_id' => Db::convertType($publisher->_id, 'id')], ['$set' => ['meta' => $meta]]); $view->set('message', 'Data Removed!!'); break; case 'defaultDomain': unset($publisher->getMeta()['tdomain']); $publisher->save(); $view->set('message', 'Removed tracking domain!!'); break; } } $afields = Meta::search('customField', $this->org); $view->set('afields', $afields)->set("publisher", $publisher)->set("commissions", Commission::all(["user_id = ?" => $publisher->id]))->set("start", strftime("%Y-%m-%d", strtotime('-7 day')))->set("end", strftime("%Y-%m-%d", strtotime('now')))->set("d", Performance::total(['start' => $start ?? $publisher->created->format('Y-m-d'), 'end' => $end ?? date('Y-m-d')], $publisher)); }