示例#1
0
 protected function _searchQuery($fields, &$adIds, &$pIds)
 {
     $searchQ = RM::get('query', []);
     $query = $searching = [];
     foreach ($searchQ as $q) {
         if (!in_array($q, $fields)) {
             continue;
         }
         $searching[$q] = RM::get($q);
         switch ($q) {
             case 'adid':
                 $adIdsGet = RM::get($q, []);
                 if (ArrayMethods::inArray($adIds, $adIdsGet)) {
                     $adIds = $adIdsGet;
                 }
                 break;
             case '_id':
             case 'cid':
                 $id = RM::get($q, null);
                 if ($id) {
                     $query[$q] = Db::convertType($id);
                 }
                 break;
             case 'is_bot':
                 $is_bot = RM::get($q, null);
                 if (!is_null($is_bot)) {
                     $query[$q] = (bool) (int) $is_bot;
                 }
                 break;
             case 'pid':
                 $pIdsGet = RM::get($q, []);
                 if (ArrayMethods::inArray($pIds, $pIdsGet)) {
                     $pIds = $pIdsGet;
                 }
                 break;
             case 'device':
             case 'os':
             case 'country':
                 $reqData = RM::get($q, []);
                 if (count($reqData) === 0) {
                     break;
                 }
                 $data = implode("|", $reqData);
                 $query[$q] = Db::convertType($data, 'regex');
                 break;
             case 'referer':
             case 'p1':
             case 'p2':
             case 'cookie':
                 $data = RM::get($q);
                 if ($data) {
                     $query[$q] = Db::convertType($data, 'regex');
                 }
                 break;
             case 'ip':
                 $reqData = RM::get('ip', '');
                 $pieces = explode(",", $reqData);
                 if (count($pieces) === 0) {
                     break;
                 }
                 $data = implode("|", $pieces);
                 $query[$q] = Db::convertType($data, 'regex');
                 break;
         }
     }
     return ['query' => $query, 'searching' => $searching];
 }
示例#2
0
 /**
  * @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));
 }