===== PART 7/12 ===== */ $referer_url = $this->getRefererCookie($link->alias); /** * Check if user disabled earnings */ if ($link->user->disable_earnings) { // Update link hits $this->updateLinkHits($link); $this->addNormalStatisticEntry($link, $ad_type, $data, get_ip(), 13); $content = [ 'status' => 'success', //'message' => 'Go without Earn because User disabled earnings', 'message' => '', 'url' => $link->url, ]; return $content; } /** * Check if earnings are disabled */ if (!(bool)get_option('enable_publisher_earnings', 1)) { // Update link hits $this->updateLinkHits($link); $this->addNormalStatisticEntry($link, $ad_type, $data, get_ip(), 12); $content = [ 'status' => 'success', //'message' => 'Go without Earn because earnings are disabled', 'message' => '', 'url' => $link->url, ]; return $content; } /** * Check if valid country */ if ($data['country'] == 'Others') { // Update link hits $this->updateLinkHits($link); $this->addNormalStatisticEntry($link, $ad_type, $data, get_ip(), 11); $content = [ 'status' => 'success', //'message' => 'Go without Earn because invalid country', 'message' => '', 'url' => $link->url, ]; return $content; } /** * Check if cookie valid */ $cookie = $this->Cookie->read('app_visitor'); if (!is_array($cookie)) { // Update link hits $this->updateLinkHits($link); $this->addNormalStatisticEntry($link, $ad_type, $data, get_ip(), 2); $content = [ 'status' => 'success', //'message' => 'Go without Earn because no cookie', 'message' => '', 'url' => $link->url, ]; return $content; } /** * Check if anonymous user */ if ('anonymous' == $link->user->username) { // Update link hits $this->updateLinkHits($link); $this->addNormalStatisticEntry($link, $ad_type, $data, $cookie['ip'], 3); $content = [ 'status' => 'success', //'message' => 'Go without Earn because anonymous user', 'message' => '', 'url' => $link->url, ]; return $content; } /** * Check if IP changed */ if ($cookie['ip'] != get_ip()) { // Update link hits $this->updateLinkHits($link); $this->addNormalStatisticEntry($link, $ad_type, $data, $cookie['ip'], 6); $content = [ 'status' => 'success', //'message' => 'Go without Earn because IP changed', 'message' => '', 'url' => $link->url, ]; return $content; } /** * Check for Adblock */ if (!isset($_COOKIE['ab']) || in_array($_COOKIE['ab'], [0, 1])) { // Update link hits $this->updateLinkHits($link); $this->addNormalStatisticEntry($link, $ad_type, $data, $cookie['ip'], 4); $content = [ 'status' => 'success', //'message' => 'Go without Earn because Adblock', 'message' => '', 'url' => $link->url, ]; return $content; } /** * Check if blocked referer domain */ if ($this->isRefererBlocked($referer_url)) { // Update link hits $this->updateLinkHits($link); $this->addNormalStatisticEntry($link, $ad_type, $data, get_ip(), 14); $content = [ 'status' => 'success', //'message' => 'Go without Earn because blocked referer', 'message' => '', 'url' => $link->url, ]; return $content; } // Campaign mode checks if ($data['mode'] === 'campaign') { /** * Check Campaign Item weight */ $CampaignItems = TableRegistry::getTableLocator()->get('CampaignItems'); $campaign_item = $CampaignItems->find() ->contain(['Campaigns']) ->where(['CampaignItems.id' => $data['cii']]) ->where(['CampaignItems.weight <=' => 100]) ->where(['CampaignItems.views < (CampaignItems.purchase * 1000)']) ->where(['Campaigns.status' => 1]) ->first(); if (!$campaign_item) { // Update link hits $this->updateLinkHits($link); $this->addNormalStatisticEntry($link, $ad_type, $data, $cookie['ip'], 8); $content = [ 'status' => 'success', //'message' => 'Go without Earn because Campaign Item weight is full.', 'message' => '', 'url' => $link->url, ]; return $content; } /** * Check if default campaign */ if ($campaign_item->campaign->default_campaign) { // Update link hits $this->updateLinkHits($link); $this->addNormalStatisticEntry($link, $ad_type, $data, $cookie['ip'], 9); $content = [ 'status' => 'success', //'message' => 'Go without Earn because Default Campaign.', 'message' => ''