コード例 #1
0
ファイル: Bootstrap.php プロジェクト: alexanderTsig/arabic
 function onBuildDemo(Am_Event $event)
 {
     $referrers = array('http://example.com/some/url.html', 'http://example.com/some/other/url.html', 'http://example.com/page/offer.html', 'http://example.com/very/very/long/referrer/url.html', 'http://example.com/referrer.html');
     static $banners = null;
     if (is_null($banners)) {
         $banners = $this->getDi()->affBannerTable->findBy();
         array_push($banners, null);
     }
     $user = $event->getUser();
     $user->is_affiliate = 1;
     $user->aff_payout_type = 'check';
     if (rand(0, 10) < 4) {
         $aff_id = $this->getDi()->db->selectCell("SELECT `id`\n                FROM ?_data\n                WHERE `table`='user' AND `key`='demo-id' AND `value`=?\n                LIMIT ?d, 1", $event->getDemoId(), rand(0, $event->getUsersCreated()));
         if ($aff_id) {
             $aff = $this->getDi()->userTable->load($aff_id);
             $banner = $banners[array_rand($banners)];
             $banner_id = $banner ? $banner->pk() : null;
             $user->aff_id = $aff_id;
             $user->aff_added = $user->added;
             $user->data()->set('aff-source', 'cookie');
             $server = $_SERVER;
             $_SERVER['REMOTE_ADDR'] = $user->remote_addr;
             $_SERVER['HTTP_REFERER'] = $referrers[array_rand($referrers)];
             $this->getDi()->setService('time', amstrtotime($user->added) - rand(5 * 60, 3600));
             $aff_click_id = $this->getDi()->affClickTable->log($aff, $banner);
             $this->getDi()->setService('time', amstrtotime($user->added));
             $this->getDi()->affLeadTable->log($aff_id, $banner_id, $user->pk(), $aff_click_id);
             $_SERVER = $server;
             $this->getDi()->setService('time', time());
         }
     }
 }
コード例 #2
0
 function onBuildDemo(Am_Event $event)
 {
     $user = $event->getUser();
     $user->is_affiliate = 1;
     $user->aff_payout_type = 'check';
     if (rand(0, 10) < 4) {
         $user->aff_id = $this->getDi()->db->selectCell("SELECT `id` \n                FROM ?_data \n                WHERE `table`='user' AND `key`='demo-id' AND `value`=?\n                LIMIT ?d, 1", $event->getDemoId(), rand(0, $event->getUsersCreated()));
     }
 }