public function get_click($id) { //Are we even working with a number? if (!is_numeric($id)) { //Yikes let's get the hell out of here App::abort(404, 'Invalid click link'); } //Now to pull our VA record or fail $va = User::find($id); if (empty($va)) { return Redirect::to('/')->with('topmessage', 'Sorry, that VA URL could not be located. Please try again and open a ticket if you continue experiencing the same issue.'); } //Great a VA exists, let's make sure to add one to their clicks if this IP hasn't added a click within the last minute. $existingClick = Click::where('ip', '=', Request::getClientIp())->orderBy('created_at', 'DESC')->first(); if (!empty($existingClick)) { $lastClickByIp = strtotime($existingClick->created_at); if (time() - $lastClickByIp > 60) { //No click found by the same IP in the last 60 seconds thus we should add this one $click = new Click(); $click->vid = $id; $click->ip = Request::getClientIp(); $click->save(); } } else { //No click found by that same IP at all. Let's insert into the DB $click = new Click(); $click->vid = $id; $click->ip = Request::getClientIp(); $click->save(); } //Finally redirect the user to the VA URL return Redirect::to($va->url); }
/** * @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); }
public function bounceRate() { $this->willRenderLayoutView = $this->willRenderActionView = false; $output = function () { $name = APP_PATH . '/public/assets/img/_blue.gif'; $fp = fopen($name, 'rb'); header("Content-Type: image/gif"); header("Content-Length: " . filesize($name)); fpassthru($fp); exit; }; $clickId = RequestMethods::get('ckid'); $link = base64_decode(RequestMethods::get('link', '')); $ref = RequestMethods::get('ref'); if (!$clickId || $link === false) { return $output(); } // Find cookie from DB $click = Click::first(['_id' => $clickId], ['adid', 'cookie', 'pid']); if (!$click) { return $output(); } $search = ['cookie' => $click->cookie, 'url' => $link, 'adid' => $click->adid, 'pid' => $click->pid]; $pageView = PageView::first($search); if (!$pageView) { $pageView = new PageView($search); $pageView->view = 0; } $pageView->view++; $pageView->save(); $output(); }
public function index() { $vin = Input::get('vin', ''); $vehicle = Vehicle::where('vin', '=', $vin)->first(); $dealer = Dealer::where('id', '=', $vehicle->dealer)->first(); $click = new Click(); $click->vin = $vehicle->vin; $click->dealer = $dealer->dealer; $click->state = $vehicle->state; $click->datetime = date("Y-m-d H:i:s"); $click->ip = $_SERVER['REMOTE_ADDR']; $click->paid = $vehicle->paid; $click->save(); $dealer->current_clicks = $dealer->current_clicks + 1; if ($vehicle->paid > 0) { $dealer->paid_clicks = $dealer->paid_clicks + 1; } if ($dealer->active == 1 && $dealer->monthly_clicks <= $dealer->paid_clicks) { $dealer->active = 0; DB::table('vehicle')->where('dealer', $dealer->id)->update(array('paid' => 0, 'modified' => 1)); } $dealer->save(); return Redirect::to($vehicle->url); }
public function clicked() { try { $inputs = []; foreach (Input::all() as $key => $value) { $inputs[strtolower($key)] = Input::get($key); } $apicall_id = explode('@', $inputs['message-id'])[0]; if ($inputs['tag'] != 'Password Recovery') { $analytic = Analytic::whereRecipient($inputs['recipient'])->whereApicallId($apicall_id)->first(); $click = Click::whereEmailId($analytic->email_id)->whereSubscriberId($analytic->subscriber_id)->whereUrl($inputs['url'])->count(); if (!$click) { $click = new Click(); $click->email_id = $analytic->email_id; $click->subscriber_id = $analytic->subscriber_id; $click->url = $inputs['url']; $click->save(); if ($analytic->client_name == NULL) { $analytic->ip = $inputs['ip']; $analytic->country = $inputs['country']; $analytic->city = $inputs['city']; $analytic->client_name = $inputs['client-name']; $analytic->client_type = $inputs['client-type']; $analytic->client_os = $inputs['client-os']; $analytic->device_type = $inputs['device-type']; $analytic->reason = "disabled images"; $analytic->save(); } } } return Response::json(['success'], 200); } catch (Exception $e) { Log::error($e); return Response::json(['error'], 406); } }
public function get_va() { //Pull our users VA data $record = User::where('cid', '=', Auth::user()->get()->cid)->first(); // //Figure out what the last 4 months are and append -1 for the first day of the month // $month = date('Y-m'); // $month .= '-1'; // $month1before = date('Y-m', strtotime('-1 month')); // $month1before .= '-1'; // $month2before = date('Y-m', strtotime('-2 month')); // $month2before .= '-1'; // $month3before = date('Y-m', strtotime('-3 month')); // $month3before .= '-1'; // //Convert to unix time stamps to compare with the DB // $month = strtotime($month); // $month1before = strtotime($month1before); // $month2before = strtotime($month2before); // $month3before = strtotime($month3before); // // //Now let's store our month names in an array // $clicks = array(); // $clicks['month_name'] = date("F", $month); // $clicks['month1before_name'] = date("F", $month1before); // $clicks['month2before_name'] = date("F", $month2before); // $clicks['month3before_name'] = date("F", $month3before); // // // //Count the data in the DB // //Where data is greater than the first of this month and is associated with our logged in user. // $month = Click::where('created_at', '>=', $month)->where('vid', '=', Auth::user()->get()->cid)->count(); // //Where data is greater than the first of last month, but less than the first of this month and is associated with our logged in user. // $month1before = Click::where('created_at', '>=', $month1before)->where('created_at', '<', $month)->where('vid', '=', Auth::user()->get()->cid)->count(); // //You get the point :) // $month2before = Click::where('created_at', '>=', $month2before)->where('created_at', '<', $month1before)->where('vid', '=', Auth::user()->get()->cid)->count(); // $month3before = Click::where('created_at', '>=', $month3before)->where('created_at', '<', $month2before)->where('vid', '=', Auth::user()->get()->cid)->count(); // //Add to our clicks array. // $clicks['month'] = $month; // $clicks['month1before'] = $month1before; // $clicks['month2before'] = $month2before; // $clicks['month3before'] = $month3before; //Let's just keep it simple for now and get the total number of clicks $clicks = Click::where('vid', '=', Auth::user()->get()->cid)->count(); //Pull our ticket information $opentickets = Ticket::where('vid', '=', Auth::user()->get()->cid)->where('status', '=', '1')->orderBy('created_at', 'DESC')->get(); $openticketscount = count($opentickets); $closedtickets = Ticket::where('vid', '=', Auth::user()->get()->cid)->where('status', '=', '0')->orderBy('created_at', 'DESC')->get(); $closedticketscount = count($closedtickets); //Create our array $tickets = array(); $tickets['opentickets'] = $opentickets; $tickets['opentickets_count'] = $openticketscount; $tickets['closedtickets'] = $closedtickets; $tickets['closedtickets_count'] = $closedticketscount; //Pull our replies $tickets_request = Ticket::where('vid', '=', Auth::user()->get()->cid)->get(); $tids = array(); foreach ($tickets_request as $ticket_request) { $tid = $ticket_request->id; $tids[$tid] = $tid; } if (!empty($tids)) { $replies = TicketReply::whereIn('tid', $tids)->orderBy('created_at', 'ASC')->get(); } else { $replies = ''; } $tickets['replies'] = $replies; //Pull our Category data $categories = Category::where('hidden', '!=', 1)->get(); //Check to see if there is a banner if so provide the source for it if ($record->banner) { $banner = User::getBannerUrl(Auth::user()->get()->cid); } else { //No banner we will set this as false so the views no not to try and display it. $banner = FALSE; } //Get our news $news = News::orderBy("updated_at", "DESC")->get(); //Create our view with the VA, clicks, categories and tickets data. return View::make('va')->with(array('news' => $news, 'record' => $record, 'clicks' => $clicks, 'tickets' => $tickets, 'categories' => $categories, 'banner' => $banner)); }
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; }
private function _reportspub($query, $start, $end, $limit, $page) { $view = $this->getActionView(); $dateQuery = Utils::dateQuery(['start' => $start, 'end' => $end]); $links = \Link::all($query, [], 'created', 'desc', $limit, $page); $count = \Link::count($query); $query["created"] = Db::dateQuery($start, $end); $performances = \Performance::all($query, ['created', 'clicks', 'revenue'], 'created', 'desc'); $in = []; foreach ($links as $l) { // only find clicks for the ads whose links are created $in[] = Utils::mongoObjectId($l->ad_id); } // find clicks $clickCol = Registry::get("MongoDB")->clicks; $records = Db::query('Click', ['adid' => ['$in' => $in], 'is_bot' => false, 'pid' => $query['user_id'], 'created' => $query['created']], ['adid', 'country']); $view->set(['limit' => $limit, 'page' => $page, 'count' => $count, 'start' => $start, 'end' => $end, 'links' => $links, 'performances' => $performances, 'clicks' => Click::classify($records, 'adid'), 'commission' => $this->user->commission(), 'dq' => $query['created']]); }
function exportAction() { // make sure we have a valid ID $id = AF::get($this->params, 'id', FALSE); if (!$id) { throw new AFHttpException(0, 'no_id'); } $connectionModel = new Fulfillment(); $connectionModel->findByPk($id); $model0 = new FulfillmentField(); $model1 = new FulfillmentFields('FulfillmentField'); $model2 = new Order(); $model3 = new Payment(); $model4 = new Click(); // grab fields assigned to fulfillment_id $assignedFields = $model1->getFulfillmentFieldsByFulfillmentId($id); $assignColumns = array(); $assignedOColumns = array(); $assignedPColumns = array(); $assignedCColumns = array(); foreach ($assignedFields as $af) { $assignColumns[] = $af['fulfillment_field_column']; if ($af['fulfillment_field_model'] == 'order') { $assignedOColumns[] = $af['fulfillment_field_column']; } else { if ($af['fulfillment_field_model'] == 'payment') { $assignedPColumns[] = $af['fulfillment_field_column']; } else { if ($af['fulfillment_field_model'] == 'click') { $assignedCColumns[] = $af['fulfillment_field_column']; } } } } // build fieldsArray to be used in the "default" export columns selection. don't include fields that are already assigned $fields = $model1->getFulfillmentFieldsByFulfillmentId(0); $fieldsArray = array(); $parentsArray = array(); foreach ($fields as $field) { if ($field['fulfillment_field_model'] == 'parent') { $parentsArray[] = array("fulfillment_field_column" => $field['fulfillment_field_column'], "fulfillment_field_name" => $field['fulfillment_field_name'], "fulfillment_field_model" => $field['fulfillment_field_model'], "checked" => false, "fulfillment_field_rank" => '', "fulfillment_field_static" => ''); } else { if (!in_array($field['fulfillment_field_column'], $assignColumns)) { $fieldsArray[] = array("fulfillment_field_column" => $field['fulfillment_field_column'], "fulfillment_field_name" => $field['fulfillment_field_name'], "fulfillment_field_model" => $field['fulfillment_field_model'], "checked" => false, "fulfillment_field_rank" => '', "fulfillment_field_static" => ''); } } // , "rank"=>$idex++ } // build orderFieldsArray to be used in the "additional order" export columns selection. don't include fields that are already assigned $oFields = $model2->attributeLabels(); $oKeys = array_keys($oFields); $oFieldsArray = array(); foreach ($oKeys as $field) { if (!in_array($field, $assignedOColumns)) { $oFieldsArray[] = array("fulfillment_field_column" => $field, "fulfillment_field_name" => $oFields[$field], "fulfillment_field_model" => 'order', "checked" => false, "fulfillment_field_rank" => '', "fulfillment_field_static" => ''); } // , "rank"=>$idex++ } // build paymentFieldsArray to be used in the "additional payment" export columns selection. don't include fields that are already assigned $pFields = $model3->attributeLabels(); $pKeys = array_keys($pFields); $pFieldsArray = array(); foreach ($pKeys as $field) { if (!in_array($field, $assignedPColumns)) { $pFieldsArray[] = array("fulfillment_field_column" => $field, "fulfillment_field_name" => $pFields[$field], "fulfillment_field_model" => 'payment', "checked" => false, "fulfillment_field_rank" => '', "fulfillment_field_static" => ''); } // , "rank"=>$idex++ } // build cFieldsArray to be used in the "additional click" export columns selection. don't include fields that are already assigned $cFields = $model4->attributeLabels(); $cKeys = array_keys($cFields); $cFieldsArray = array(); foreach ($cKeys as $field) { if (!in_array($field, $assignedCColumns)) { $cFieldsArray[] = array("fulfillment_field_column" => $field, "fulfillment_field_name" => $cFields[$field], "fulfillment_field_model" => 'click', "checked" => false, "fulfillment_field_rank" => '', "fulfillment_field_static" => ''); } // , "rank"=>$idex++ } // preload the JQX assets Assets::css('jqwidgets/jqx.base'); Assets::js('jqwidgets/jqxcore'); Assets::js('jqwidgets/jqxdata'); Assets::js('jqwidgets/jqxbuttons'); Assets::js('jqwidgets/jqxscrollbar'); Assets::js('jqwidgets/jqxmenu'); Assets::js('jqwidgets/jqxcheckbox'); Assets::js('jqwidgets/jqxlistbox'); Assets::js('jqwidgets/jqxdropdownlist'); Assets::js('jqwidgets/jqxgrid'); Assets::js('jqwidgets/jqxgrid.edit'); Assets::js('jqwidgets/jqxgrid.selection'); Assets::js('jqwidgets/jqxdata.export'); Assets::js('jqwidgets/jqxgrid.export'); Assets::js('jqwidgets/jqxgrid.columnsresize'); Assets::js('jqwidgets/jqxdropdownbutton'); $this->render('export', array('model' => $model0, 'connectionModel' => $connectionModel, 'defaultFields' => $fieldsArray, 'assignedFields' => $assignedFields, 'orderFields' => $oFieldsArray, 'paymentCCFields' => $pFieldsArray, 'clickFields' => $cFieldsArray, 'parentFields' => $parentsArray)); }
private function buildClick($cid = null) { $this->click = new Click(); // if a click id is already present, check the details against the post if ($cid && $this->click->fillFromDbPk($cid)) { if (isset($this->post['hit_id']) && $this->click->hit_id != $this->post['hit_id']) { $this->click = new Click(); } } // is there a click id? if (!empty($this->post['click_id']) && is_numeric($this->post['click_id'])) { // is there a click record? if ($this->click->fillFromDbPk($this->post['click_id'])) { // check to see if click camp details match if ($this->campaign->campaign_id != $this->click->campaign_id) { // reset click and continue $this->click = new Click(); $this->post['hit_id'] = $this->post['click_id']; $this->post['click_id'] = ''; //$this->apiError('error5 - Invalid campaign/click info'); } } else { // there's a click_id, but it does not belong to LJ3. disregard info $this->post['hit_id'] = $this->post['click_id']; $this->post['click_id'] = ''; } } // is click empty? if (!$this->click->getPkValue()) { $this->click->fillFromArray($this->post); $this->click->fillIpAddress($this->post['user_ip']); $this->click->created = $this->click->updated = 'NOW():sql'; //date("Y-m-d H:i:s"); // check validity of // HOW TO HANDLE 3rd Party AFIDs? is the afid called something different if (isset($this->post['AFID']) && strlen($this->post['AFID']) && !isset($this->post['aff_id'])) { $this->click->getAffId($this->post['AFID']); // did it work? remove AFID then if ($this->click->aff_id) { $this->click->AFID = ''; } } $cookie_name = 's' . $this->click->campaign_id; $expire = time() + 3600 * 24 * 100; if (isset($this->cookie[$cookie_name])) { $old_click_id = $this->cookie[$cookie_name]; // check the ID $c = new Click(); $c->fillFromDbPk($old_click_id); if ($c->getPkValue()) { // is this click from a different affiliate? if so, don't use the old cookie click if ($c->aff_id == $this->click->aff_id) { $this->click->fillFromDbPk($old_click_id); unset($c); setcookie($cookie_name, $old_click_id, $expire, "/"); return; } unset($c); } } if (!$this->click->save()) { $this->apiError('click error ' . $this->click->geterrors2string()); } setcookie($cookie_name, $this->click->click_id, $expire, "/"); } }
/** * Overrides the parent delete method to check for clicks on the * ad before deleting it */ public function delete() { $id = Utils::mongoObjectId($this->_id); $count = \Click::count(['adid' => $id]); if ($count !== 0) { return ['message' => 'Can not delete!! Campaign contain clicks', 'success' => false]; } $this->_removeMedia(); parent::delete(); \Commission::deleteAll(['ad_id' => $id]); \Link::deleteAll(['ad_id' => $id]); return ['message' => 'Campaign removed successfully!!', 'success' => true]; }
protected function perf($clicks, $arr, $dq = []) { $perf = new Performance(); $commissions = []; $classify = \Click::classify($clicks, 'adid'); foreach ($classify as $key => $value) { $countryWise = \Click::classify($value, 'country'); foreach ($countryWise as $country => $records) { $adClicks = count($records); $updateData = []; $extra = array_merge($arr, $dq); $info = \Commission::campaignRate($key, $commissions, $country, $extra); $earning = \Ad::earning($info, $adClicks); \Framework\ArrayMethods::copy($earning, $updateData); $perf->update($updateData); } } return $perf; }
protected function _performance($date = null) { if (!$date) { $date = date('Y-m-d', strtotime('-1 day')); } $date = date('Y-m-d', strtotime('-1 day')); // find the publishers $publishers = \User::all(['type = ?' => 'publisher', 'live = ?' => true], ['_id', 'email', 'meta', 'org_id']); $dq = ['start' => $date, 'end' => $date]; $dateQuery = Utils::dateQuery($dq); $start = $dateQuery['start']; $end = $dateQuery['end']; // store AD commission info $commInfo = []; $orgs = []; $advPerfs = []; $advertisers = []; $adsInfo = []; foreach ($publishers as $p) { $org = \Organization::find($orgs, $p->org_id); // find the clicks for the publisher $clicks = Db::query('Click', ['pid' => $p->_id, 'is_bot' => false, 'created' => Db::dateQuery($date, $date)], ['adid', 'country', 'device', 'os', 'referer']); $perf = Performance::exists($p, $date); // classify the clicks according to AD ID $classify = \Click::classify($clicks, 'adid'); $countryWise = $deviceWise = $osWise = $refWise = []; foreach ($classify as $key => $value) { $ad = \Ad::find($adsInfo, $key, ['user_id', 'url']); $advert = Usr::find($advertisers, $ad->user_id, ['_id', 'meta', 'email', 'org_id']); $advertPerf = Usr::findPerf($advPerfs, $advert, $date); $countries = \Click::classify($value, 'country'); foreach ($countries as $country => $records) { $updateData = []; $adClicks = count($records); ArrayMethods::counter($countryWise, $country, $adClicks); $pComm = \Commission::campaignRate($key, $commInfo, $country, array_merge(['type' => 'both', 'publisher' => $p], $dq)); $earning = \Ad::earning($pComm, $adClicks); ArrayMethods::copy($earning, $updateData); $updateData['profit'] = $updateData['revenue'] - $updateData['payout']; $updateData['revenue'] = $updateData['payout']; $perf->update($updateData); $aComm = \Commission::campaignRate($key, $commInfo, $country, array_merge(['type' => 'advertiser'], $dq)); $updateData = []; $earning = \Ad::earning($aComm, $adClicks); ArrayMethods::copy($earning, $updateData); $advertPerf->update($updateData); } $deviceWise = Click::classifyInfo(['clicks' => $value, 'type' => 'device', 'arr' => $deviceWise]); $osWise = Click::classifyInfo(['clicks' => $value, 'type' => 'os', 'arr' => $osWise]); $refWise = Click::classifyInfo(['clicks' => $value, 'type' => 'referer', 'arr' => $refWise]); } $msg = 'Performance saved for user: '******' with clicks: ' . $perf->clicks . ' impressions: ' . $perf->impressions; $this->log($msg); $splitCountry = ArrayMethods::topValues($countryWise); $splitCountry['rest'] = array_sum($countryWise) - array_sum($splitCountry); $meta = ['country' => $splitCountry, 'device' => ArrayMethods::topValues($deviceWise, count($deviceWise)), 'os' => ArrayMethods::topValues($osWise, count($osWise)), 'referer' => ArrayMethods::topValues($refWise, count($refWise))]; $perf->meta = $meta; $perf->save(); } foreach ($advPerfs as $key => $perf) { $msg = 'Saving performance for advertiser: ' . $key . ' with clicks: ' . $perf->clicks . ' earning: ' . $perf->revenue . ' impressions: ' . $perf->impressions; $this->log($msg); $perf->save(); } }
public function savexi() { $data = Input::all(); $data['openid'] = Session::get('openid') ? Session::get('openid') : null; $save = array('openid' => $data['openid'], 'score' => $data['sub'], 'time' => $data['score']); if ($data['openid'] != null) { $num = Click::where('openid', '=', $data['openid'])->count(); if ($num != 0) { $info = Click::where('openid', '=', $data['openid'])->first(); if ($save['score'] > $info['score']) { Click::where('openid', '=', $data['openid'])->update($save); $id = Click::where('openid', '=', $data['openid'])->first(); } elseif ($save['score'] == $info['score'] && $save['time'] < $info['time']) { Click::where('openid', '=', $data['openid'])->update($save); $id = Click::where('openid', '=', $data['openid'])->first(); } else { $id = Click::create($save); $uid = $id['id']; $paiming = DB::select("SELECT rowno as list FROM (SELECT id,score,time,(@rowno:=@rowno+1) as rowno FROM `click`, (SELECT (@rowno:=0)) a ORDER BY score DESC, time ASC )b WHERE id = {$uid} limit 1"); Click::destroy($uid); return $paiming; } } else { $id = Click::create($save); } } else { $id = Click::create($save); } $uid = $id['id']; $paiming = DB::select("SELECT rowno as list FROM (SELECT id,score,time,(@rowno:=@rowno+1) as rowno FROM `click`, (SELECT (@rowno:=0)) a ORDER BY score DESC, time ASC )b WHERE id = {$uid} limit 1"); return $paiming; }
if (!$Login->is_user_logged_in("logged_in")) { //if user is not logged in then show login, register, and recover_password options //link to search bar echo "<a href=\"search/search.php\"> Search on this site </a> </br>"; echo "<a href='login_user/login.php'> Login </a> </br>"; echo "<a href='register_account/register.php'> Register new account </a> </br>"; echo "<a href='recover_password/recover_password.php'> Recover password </a> </br>"; } if ($Login->is_user_logged_in("logged_in")) { //greet user echo "<p style=\"display:inline\">Hello</p> <p style=\"display:inline\" class='thread_by'> {$_SESSION["logged_in"]} </p> </br>"; //link to search bar echo "<a href=\"search/search.php\"> Search on this site </a> </br>"; echo "<a href=\"login_user/logout.php\"> Logout </a> </br>"; echo "<a href=\"user_profile.php\"> My profile </a> </br>"; echo "<a href=\"chatbox/chat_box.php\"> Join chat </a> </br>"; //If user is logged in(session exists), we're going to check if user is admin. //..checks if user is admin if ($Login->is_user_admin()) { echo "<a href=\"admin/admin_cp.php\"> Admin control panel </a> </br>"; } } //Shows categories and other things. $Data_display->show_categories(); //instantiating Click class. $click_tracker = new Click($conn); //Calling store_clicks(); $click_tracker->store_clicks(); //Calling show_hits_amount(), this shows the amount your site has been hit. $click_tracker->show_hits_amount(); echo "</br> </br> </br> </br> </br> <p style='background-color:yellow; color:black; width:300px'>Forum script by <a href='https://github.com/phpdevsami/samforum'> samforum S. Samiuddin</a> </p>";
public function getOrderDetails() { $shippingAddress = new FullAddress(); $shippingAddress->fillFromDbPk($this->address_id); $billingAddress = new FullAddress(); $billingAddress->fillFromDbPk($this->billing_address_id); $customer = new Customer(); $customer->fillFromDbPk($this->customer_id); $click = new Click(); $click->fillFromDbPk($this->click_id); $click->allFIelds = true; $click->loadConnections(); $date = new DateTime(); // DateTime($this->created); return array('orderId' => $this->order_id, 'billFirst' => $billingAddress->fname, 'billLast' => $billingAddress->lname, 'billAddress1' => $billingAddress->address1, 'billAddress2' => $billingAddress->address2, 'billCity' => $billingAddress->city, 'billState' => $billingAddress->state_name, 'billZip' => $billingAddress->zip, 'billCountry' => $billingAddress->country_name, 'billPhone' => $billingAddress->phone, 'billEmail' => $customer->email, 'shipFirst' => $shippingAddress->fname, 'shipLast' => $shippingAddress->lname, 'shipAddress1' => $shippingAddress->address1, 'shipAddress2' => $shippingAddress->address2, 'shipCity' => $shippingAddress->city, 'shipState' => $shippingAddress->state_name, 'shipZip' => $shippingAddress->zip, 'shipCountry' => $shippingAddress->country_name, 'shipPhone' => $shippingAddress->phone, 'shipEmail' => $customer->email, 'orderTotal' => sprintf("%.2f", $this->amount_product + $this->amount_shipping), 'dateOfSale' => $date->format('Y-m-d'), 'timeOfSale' => $date->format('H:i:s'), 'ipAddress' => $this->getip_formatted(), 'aff_id' => $click->aff_id === NULL ? '' : $click->aff_id, 'AFID' => $click->aff_ref === NULL ? $click->AFID : $click->aff_ref, 'SID' => $click->SID === NULL ? '' : $click->SID, 'c1' => $click->c1 === NULL ? '' : $click->c1, 'c2' => $click->c2 === NULL ? '' : $click->c2, 'c3' => $click->c3 === NULL ? '' : $click->c3, 'click_id' => $click->click_id, 'hit_id' => $click->hit_id); }
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; }
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)); }