当前位置: 首页>>代码示例>>PHP>>正文


PHP Ad::all方法代码示例

本文整理汇总了PHP中Ad::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Ad::all方法的具体用法?PHP Ad::all怎么用?PHP Ad::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ad的用法示例。


在下文中一共展示了Ad::all方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: pageController

function pageController()
{
    session_start();
    if (!isset($_SESSION['Loggedinuser'])) {
        $loginstatus = "Members, Log In!";
    } else {
        $loginstatus = $_SESSION['Loggedinuser'] . " is logged in!";
    }
    // Upon arrival at this page, this will load all the ads from the database.
    $adsArray = Ad::all();
    // Upon choosing a category, $clickcategories is set in $_GET. This variable is used to query the database.
    $clickedcategories = Input::has('clickcategory') ? '%' . Input::get('clickcategory') . '%' : '%';
    $adsArray = Ad::findCategories($clickedcategories);
    arsort($adsArray);
    // This portion of code gets all the ads' categories in one array.
    // The categories, which are strings (sometimes with multiple categories in it),
    // are then put into the array by themselves. The array is imploded into a string and then exploded into an
    // array again. This allows us to split the strings with multiple categories in them.
    // The php array_unique removes duplicate category values and sort orders them by first letter.
    $arrayCategories = Ad::showJustCategories();
    $justCategories = [];
    foreach ($arrayCategories as $key => $value) {
        array_push($justCategories, $value['categories']);
    }
    $justCategoriesString = implode(', ', $justCategories);
    $justCategoriesArray = explode(', ', $justCategoriesString);
    $justCategoriesArrayUnique = array_unique($justCategoriesArray);
    sort($justCategoriesArrayUnique);
    // This randomly selects an ad to show in the spotlight spatula box.
    $spotlight = $adsArray[array_rand($adsArray, 1)];
    return array('adsArray' => $adsArray, 'loginstatus' => $loginstatus, 'clickedcategories' => $clickedcategories, 'spotlight' => $spotlight, 'justCategoriesArrayUnique' => $justCategoriesArrayUnique);
}
开发者ID:ztr-adlister,项目名称:adlister,代码行数:32,代码来源:ads.index.php

示例2: minutely

 public static function minutely()
 {
     // process all the campaign which needs processing
     $today = date('Y-m-d');
     $ads = \Ad::all(['meta.processing' => true, 'created' => Db::dateQuery($today, $today)]);
     foreach ($ads as $a) {
         $meta = $a->meta;
         switch ($a->type) {
             case 'video':
                 // download the video and save it
                 $arr = [];
                 $found = false;
                 foreach (['240p', '360p'] as $q) {
                     $vid = Utils::media($a->meta['videoUrl'], 'download', ['type' => 'video', 'quality' => $q]);
                     if (strlen($vid) >= 4) {
                         $found = true;
                         $arr[] = ['file' => $vid, 'quality' => $q];
                     }
                 }
                 if ($found) {
                     unset($meta['processing']);
                 }
                 $meta['videos'] = $arr;
                 $a->meta = $meta;
                 $a->save();
                 break;
         }
     }
 }
开发者ID:vNative,项目名称:vnative,代码行数:29,代码来源:campaign.php

示例3: campaigns

 /**
  * @before _secure
  */
 public function campaigns()
 {
     $this->seo(array("title" => "Campaigns"));
     $view = $this->getActionView();
     $start = RM::get("start", strftime("%Y-%m-%d", strtotime('-7 day')));
     $end = RM::get("end", strftime("%Y-%m-%d", strtotime('now')));
     $limit = RM::get("limit", 20);
     $page = RM::get("page", 1);
     $query = ["user_id" => $this->user->id];
     $ads = \Ad::all($query, ['title', 'image', 'category', '_id', 'live', 'created'], 'created', 'desc', $limit, $page);
     $count = \Ad::count($query);
     $in = Db::convertType(array_keys($ads));
     $query["created"] = Db::dateQuery($start, $end);
     $records = Db::query('Click', ['adid' => ['$in' => $in], 'is_bot' => false, 'created' => $query["created"]], ['adid']);
     $view->set("ads", $ads);
     $view->set("start", $start);
     $view->set("end", $end);
     $view->set(['count' => $count, 'page' => $page, 'limit' => $limit, 'dateQuery' => $query['created'], 'clicks' => Click::classify($records, 'adid')]);
 }
开发者ID:vNative,项目名称:vnative,代码行数:22,代码来源:advertiser.php

示例4: livePerf

 public static function livePerf($user, $s = null, $e = null)
 {
     $start = $end = date('Y-m-d');
     $type = $user->type ?? '';
     if ($s) {
         $start = $s;
     }
     if ($e) {
         $end = $e;
     }
     $perf = new \Performance();
     $match = ['is_bot' => false, 'created' => Db::dateQuery($start, $end)];
     switch ($user->type) {
         case 'publisher':
             $match['pid'] = Db::convertType($user->_id);
             break;
         case 'advertiser':
             $ads = \Ad::all(['user_id' => $user->_id], ['_id']);
             $keys = array_keys($ads);
             $match['adid'] = ['$in' => Db::convertType($keys)];
             break;
         default:
             return $perf;
     }
     $results = $commissions = [];
     $records = self::_livePerfQuery($match);
     foreach ($records as $r) {
         $obj = Utils::toArray($r);
         $adid = Utils::getMongoID($obj['_id']);
         $results[$adid] = $obj;
     }
     $comms = Db::query('Commission', ['ad_id' => ['$in' => array_keys($results)]], ['ad_id', 'rate', 'revenue', 'model', 'coverage']);
     $comms = \Click::classify($comms, 'ad_id');
     foreach ($comms as $adid => $value) {
         $value = array_map(function ($v) {
             $v["ad_id"] = Utils::getMongoID($v["ad_id"]);
             unset($v["_id"]);
             return (object) $v;
         }, Utils::toArray($value));
         $commissions[$adid] = \Commission::filter($value);
     }
     foreach ($results as $adid => $obj) {
         $comms = $commissions[$adid];
         foreach ($obj['countries'] as $value) {
             $country = $value['country'];
             $clicks = $value['count'];
             $commission = \Commission::campaignRate($adid, $comms, $country, ['type' => $type, "{$type}" => $user, 'start' => $start, 'end' => $end, 'commFetched' => true]);
             $updateData = [];
             $earning = \Ad::earning($commission, $clicks);
             AM::copy($earning, $updateData);
             $perf->update($updateData);
         }
     }
     return $perf;
 }
开发者ID:vNative,项目名称:vnative,代码行数:55,代码来源:user.php

示例5: header

<?php

require_once '../bootstrap.php';
if (!Auth::check()) {
    header("Location: login.php");
    exit;
}
$ads = [];
$ads = Ad::all();
if (Input::has('id') && Input::get('id') >= 0) {
    $id = Input::get('id');
} else {
    $id = 0;
}
Ad::isOwner($ads[$id]['user_id']);
Ad::delete($id);
header("Refresh: 3;url=/profile");
?>

<html>
<head>
    <title>Instrument Exchange</title>
    <!-- Bootstrap styling -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <!-- Custom styling for site -->
    <link rel="stylesheet" type="text/css" href="../css/main.css">
</head>
<body>
    <?// include "../views/partials/navbar.php"; ?>

开发者ID:asleepArmadillo,项目名称:Adlister,代码行数:29,代码来源:deletesuccess.php

示例6: platforms

 /**
  * @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]);
 }
开发者ID:vNative,项目名称:vnative,代码行数:45,代码来源:report.php

示例7: session_start

<?php

require '../models/Ad.php';
require '../utils/Auth.php';
session_start();
$ads_list = Ad::all();
?>

<html>
	<?php 
require_once '../views/header.php';
?>
	<?php 
require_once '../views/navbar.php';
?>

<body>
	

	<?php 
require_once '../views/footer.php';
?>
  
</body>
</html>
开发者ID:adlisterproject,项目名称:sketchy-b,代码行数:25,代码来源:results.php

示例8: index

 /**
  * Display a listing of ads
  *
  * @return Response
  */
 public function index()
 {
     $ads = Ad::all();
     return View::make('ads.index', compact('ads'));
 }
开发者ID:jamalots,项目名称:jamalot.dev,代码行数:10,代码来源:AdsController.php

示例9: delete

 public function delete()
 {
     $deleteList = ['Link', 'Platform', 'Ad', 'Performance', 'Invoice', 'Adaccess'];
     $query = ['user_id' => $this->_id];
     $delete = false;
     switch ($this->_type) {
         case 'publisher':
             $clicks = Click::count(['pid' => $this->_id]);
             if ($clicks !== 0) {
                 return false;
             }
             $delete = true;
             $this->removeFields();
             break;
         case 'advertiser':
             $ads = Ad::all(['user_id' => $this->_id], ['_id']);
             if (count($ads) === 0) {
                 $delete = true;
             } else {
                 $in = array_keys($ads);
                 $in = Db::convertType($in, 'id');
                 $clickCount = Click::count(['adid' => ['$in' => $in]]);
                 if ($clickCount === 0) {
                     Commission::deleteAll(['ad_id' => ['$in' => $in]]);
                     $delete = true;
                 }
             }
             break;
     }
     if ($delete) {
         parent::delete();
         foreach ($deleteList as $table) {
             $table::deleteAll($query);
         }
     }
     return $delete;
 }
开发者ID:vNative,项目名称:vnative,代码行数:37,代码来源:user.php

示例10: manage

 /**
  * @before _secure
  */
 public function manage()
 {
     $this->seo(['title' => 'Campaign: List', 'description' => 'Manage campaigns']);
     $view = $this->getActionView();
     $campaigns = [];
     $page = RM::get("page", 1);
     $limit = RM::get("limit", 10);
     $property = RM::get("property");
     $value = RM::get("value");
     switch (RM::get("sort")) {
         case 'trending':
             $start = RM::get("start", date("Y-m-d", strtotime('now')));
             $end = RM::get("end", date("Y-m-d", strtotime('now')));
             $q = ['start' => $start, 'end' => $end];
             $view->set($q);
             // Only find the ads for this organizations
             $allAds = \Ad::all(['org_id' => $this->org->_id], ['_id']);
             $in = Db::convertType(array_keys($allAds));
             $clickCol = Db::collection('Click');
             $match = ['created' => Db::dateQuery($start, $end), 'is_bot' => false, 'adid' => ['$in' => $in]];
             $records = $clickCol->aggregate([['$match' => $match], ['$project' => ['adid' => 1, '_id' => 0]], ['$group' => ['_id' => '$adid', 'count' => ['$sum' => 1]]], ['$sort' => ['count' => -1]], ['$limit' => (int) $limit]]);
             foreach ($records as $r) {
                 $arr = Utils::toArray($r);
                 $id = Utils::getMongoID($arr['_id']);
                 $campaigns[] = Ad::first(["id = ?" => $id]);
             }
             $count = $limit;
             break;
         default:
             $query = ["org_id = ?" => $this->org->id];
             if (in_array($property, ["user_id", "live", "id"])) {
                 $query[$property] = $value;
             } else {
                 if (in_array($property, ["url", "title"])) {
                     $query[$property] = Utils::mongoRegex(preg_quote($value));
                 }
             }
             $campaigns = \Ad::all($query, [], 'created', 'desc', $limit, $page);
             $count = \Ad::count($query);
             break;
     }
     $categories = \Category::all(['org_id' => $this->org->_id], ['_id', 'name']);
     $active = \Ad::count(["org_id = ?" => $this->org->id, "live = ?" => 1]);
     $inactive = \Ad::count(["org_id = ?" => $this->org->id, "live = ?" => 0]);
     $view->set("campaigns", $campaigns)->set("count", $count)->set("active", $active)->set("inactive", $inactive)->set("limit", $limit)->set("page", $page)->set("property", $property)->set("value", $value)->set("categories", $categories);
 }
开发者ID:vNative,项目名称:vnative,代码行数:49,代码来源:campaign.php

示例11: links

 public function links()
 {
     $this->seo(array("title" => "Tracking Links"));
     $view = $this->getActionView();
     $links = Link::all(['user_id' => $this->user->_id], ['ad_id', 'domain', '_id']);
     $in = ArrayMethods::arrayKeys($links, 'ad_id');
     $ads = Ad::all(['_id' => ['$in' => $in]], ['title', '_id']);
     $result = [];
     foreach ($links as $l) {
         $adid = $l->ad_id;
         $result[] = ArrayMethods::toObject(['title' => $ads[$adid]->title, 'url' => $l->getUrl()]);
     }
     $view->set('links', $result);
     if ($this->defaultExtension === "csv") {
         $view->erase('start')->erase('end');
         $this->_org = $this->_user = null;
     }
 }
开发者ID:vNative,项目名称:vnative,代码行数:18,代码来源:publisher.php

示例12: campaign

 /**
  * @before _secure
  * @after _cleanUp
  */
 public function campaign($id = null)
 {
     $view = $this->getActionView();
     $org = $this->_org;
     $active = RequestMethods::get('active', 1);
     $fields = ['_id', 'title', 'description', 'image', 'url', 'device', 'expiry', 'created'];
     $commFields = ['model', 'rate', 'revenue', 'coverage'];
     if ($id) {
         $campaign = Ad::first(['_id' => $id, 'org_id' => $org->_id], $fields);
     } else {
         $campaign = null;
     }
     if ($id && !$campaign) {
         return $this->failure('30');
     }
     $type = RequestMethods::type();
     switch ($type) {
         case 'GET':
             if (!$id) {
                 // display list of campaigns
                 $ads = Ad::all(['org_id' => $org->_id, 'live' => $active], $fields);
                 $ads = Ad::objectArr($ads, $fields);
                 $results = [];
                 foreach ($ads as $id => $a) {
                     $arr = Utils::toArray($a);
                     $comms = Commission::all(['ad_id' => $a->_id], $commFields);
                     $arr['commissions'] = Ad::objectArr($comms, $commFields);
                     $results[$id] = (object) $arr;
                 }
                 $data = ['campaigns' => $results];
                 $view->set('data', $data);
             } else {
                 $ads = Ad::objectArr($campaign, $fields);
                 $campaign = array_shift($ads);
                 $comm = Commission::all(['ad_id' => $campaign->_id], $commFields);
                 $data = ['campaign' => $campaign, 'commissions' => Commission::objectArr($comm, $commFields)];
                 $view->set('data', $data);
             }
             break;
         case 'POST':
             if ($id) {
                 // edit a particular campaign
             } else {
                 // create a new campaign
                 $fields = ['title', 'description', 'url', 'expiry', 'category', 'device', 'user_id'];
                 $img = RequestMethods::post('image');
                 // contains image url
                 $campaign = new Ad(['org_id' => $org->_id, 'type' => 'article', 'image' => Utils::media($img, 'download')]);
                 foreach ($fields as $f) {
                     $campaign->{$f} = RequestMethods::post($f);
                 }
                 $view->set('success', false);
                 $visibility = RequestMethods::post('visibility', 'public');
                 if ($visibility === 'private') {
                     $campaign->getMeta()['private'] = true;
                 }
                 $opts = ['devices' => array_keys(Shared\Markup::devices()), 'advertisers' => $org->users('advertiser', false)];
                 if (true) {
                     // $campaign->save();
                     $arr = ArrayMethods::reArray($_POST['commissions']);
                     var_dump($arr);
                     var_dump($_POST['commissions']);
                     $view->set('success', true);
                 } else {
                     $data = ['errors' => $campaign->errors];
                     $view->set('data', $data);
                 }
             }
             break;
         case 'DELETE':
             $message = $campaign->delete();
             $view->set($message);
             break;
     }
 }
开发者ID:vNative,项目名称:vnative,代码行数:79,代码来源:api.php


注:本文中的Ad::all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。