function ajax_load()
 {
     $ga = new Analytics();
     echo '<div id="stat">
         <span id="today"></span> Today ' . number_format($ga->getToday()) . ' users &nbsp;
         <span id="month"></span> This Month ' . number_format($ga->getMonth()) . ' users &nbsp;
         <span id="all"></span> All ' . number_format($ga->getTotal()) . ' users
     </div>';
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $date = \Carbon\Carbon::now();
     for ($i = 0; $i < 100; $i++) {
         $a = new Analytics();
         $a->visits = rand(1000, 5000);
         $a->save();
         //Analytics::insert(['visits'=>rand(1000,5000)]);
         sleep(1);
     }
 }
 public function testInstantArticleAlmostEmpty()
 {
     $article = InstantArticle::create()->withCanonicalUrl('')->withHeader(Header::create())->addChild(Paragraph::create()->appendText('Some text to be within a paragraph for testing.'))->addChild(Paragraph::create())->addChild(Paragraph::create()->appendText(" \n \t "))->addChild(Image::create())->addChild(Image::create()->withURL(''))->addChild(SlideShow::create()->addImage(Image::create()->withURL('https://jpeg.org/images/jpegls-home.jpg'))->addImage(Image::create()))->addChild(Ad::create())->addChild(Paragraph::create()->appendText('Other text to be within a second paragraph for testing.'))->addChild(Analytics::create())->withFooter(Footer::create());
     $expected = '<!doctype html>' . '<html>' . '<head>' . '<link rel="canonical" href=""/>' . '<meta charset="utf-8"/>' . '<meta property="op:generator" content="facebook-instant-articles-sdk-php"/>' . '<meta property="op:generator:version" content="' . InstantArticle::CURRENT_VERSION . '"/>' . '<meta property="op:markup_version" content="v1.0"/>' . '</head>' . '<body>' . '<article>' . '<p>Some text to be within a paragraph for testing.</p>' . '<figure class="op-slideshow">' . '<figure>' . '<img src="https://jpeg.org/images/jpegls-home.jpg"/>' . '</figure>' . '</figure>' . '<p>Other text to be within a second paragraph for testing.</p>' . '</article>' . '</body>' . '</html>';
     $result = $article->render();
     $this->assertEquals($expected, $result);
 }
Esempio n. 4
0
  /**
   * Initializes the default client to use. Uses the socket consumer by default.
   * @param  string $secret   your project's secret key
   * @param  array  $options  passed straight to the client
   */
  public static function init($secret, $options = array()) {

  	if (!$secret){
  		throw new Exception("Analytics::init Secret parameter is required");
  	}

    self::$client = new Analytics_Client($secret, $options);
  }
 public function testRenderWithGoogleAnalytics()
 {
     $google_analytics = '<!-- Google Analytics -->' . '<script>' . '(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){' . '(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),' . 'm=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)' . '})(window,document,"script","//www.google-analytics.com/analytics.js","ga");' . 'ga("create", "UA-XXXXX-Y", "auto");' . 'ga("send", "pageview");' . '</script>' . '<!-- End Google Analytics -->';
     $analytics = Analytics::create()->withHTML($google_analytics);
     $expected = '<figure class="op-tracker">' . '<iframe>' . $google_analytics . '</iframe>' . '</figure>';
     $rendered = $analytics->render();
     $this->assertEquals($expected, $rendered);
 }
 static function getAll($returned_data)
 {
     try {
         $data = array();
         foreach ($returned_data as $row) {
             $sessions_date = $row[0];
             $sessions = $row[1];
             $analytics_object = new Analytics($sessions_date, $sessions);
             $analytics_object->save();
             array_push($data, $analytics_object);
         }
         print_r($data);
     } catch (Exception $e) {
         echo "Data could not be saved to the database.";
         exit;
     }
 }
Esempio n. 7
0
 public static function singleton()
 {
     $name = __CLASS__;
     if (!self::$instance) {
         self::$instance = new $name();
     }
     return self::$instance;
 }
Esempio n. 8
0
    public function action_getkeywords()
    {
        // Get the graph - for the past 7 days
        $trendingkeywords_params = array("RequestType" => "ContentByChannelOverTime", "Parameters" => array("TimeLimit" => 7));
        $json_encoded_params = json_encode($trendingkeywords_params);
        $trendingkeywords_json = Analytics::analytics_api()->get_analysis($json_encoded_params);
        
        $trendingkeywords = View::factory("parts/trendingkeywordswidget")->set('json', $trendingkeywords_json);

        // Render the graph
        $this->request->response = $trendingkeywords;
    }
Esempio n. 9
0
    public function action_getsources()
    {
        // Get the graph - for the past 7 days
        $activesources_params = array("RequestType" => "SourcesByChannelOverTime", "Parameters" => array("TimeLimit" => 7));
        $json_encoded_params = json_encode($activesources_params);
        $activesources_json = Analytics::analytics_api()->get_analysis($json_encoded_params);
        
        $activesources = View::factory("parts/activesourceswidget")->set('json', $activesources_json);

        // Render the graph
        $this->request->response = $activesources;
    }
Esempio n. 10
0
 public static function track($user_id = 0, $event = '', $props = array())
 {
     // an event is required
     if ($event == '') {
         return;
     }
     if (!$user_id && is_user_logged_in()) {
         $user_id = get_current_user_id();
     }
     // A user is necessary
     if (!$user_id) {
         return;
     }
     self::load_segment_api();
     Analytics::track(array('userId' => $user_id, 'event' => $event, 'properties' => $props));
 }
Esempio n. 11
0
	function init() {
		$return = false;

		$source = $this->input->get('src');
		if( $source && !$this->session->userdata('user_source_id') ) {
			$data = array();
			$data['source_id'] = $source;
			$data['source_sub_id'] = $this->input->get('sub');
			$data['timestamp'] = time();

			$this->db->insert('user_source', $data);
			$user_source_id = $this->db->insert_id();
			
			$this->session->set_userdata('user_source_id', $user_source_id);
			
			$this->load->model('users');
			Analytics::track( $this->users->id(), "Source", array('src' => $source, 'sub' => $this->input->get('sub')) );
			
			$return = true;
		}

		return $return;
	}
Esempio n. 12
0
 /**
  * Call the real time query method on the authenticated client.
  *
  * @param string $metrics
  * @param array  $others
  *
  * @return mixed
  */
 public function performRealTimeQuery($metrics, $others = array())
 {
     return $this->client->performRealTimeQuery($this->siteId, $metrics, $others);
 }
Esempio n. 13
0
<?php

/**
 * Initialize the library
 */
date_default_timezone_set('America/Los_Angeles');
require_once "./analytics/lib/Segment.php";
class_alias('Segment', 'Analytics');
Analytics::init("testsecret", array("debug" => true, "error_handler" => function ($code, $msg) {
    error_log("error_log: " . $code . " " . $msg);
}));
/**
 * Create a random user to identify.
 */
$user = "******" . rand();
Analytics::identify(array("userId" => $user, "traits" => array("name" => "Michael Bolton", "email" => "*****@*****.**")));
echo "User: {$user}";
Esempio n. 14
0
}
if (isset($configArray['Site']['largeLogo'])) {
    $interface->assign('largeLogo', $configArray['Site']['largeLogo']);
}
//Set focus to the search box by default.
$interface->assign('focusElementId', 'lookfor');
//Set footer information
/** @var Location $locationSingleton */
global $locationSingleton;
getGitBranch();
$interface->loadDisplayOptions();
require_once ROOT_DIR . '/sys/Analytics.php';
//Define tracking to be done
global $analytics;
global $active_ip;
$analytics = new Analytics($active_ip, $startTime);
$googleAnalyticsId = isset($configArray['Analytics']['googleAnalyticsId']) ? $configArray['Analytics']['googleAnalyticsId'] : false;
$interface->assign('googleAnalyticsId', $googleAnalyticsId);
if ($googleAnalyticsId) {
    $googleAnalyticsDomainName = isset($configArray['Analytics']['domainName']) ? $configArray['Analytics']['domainName'] : strstr($_SERVER['SERVER_NAME'], '.');
    // check for a config setting, use that if found, otherwise grab domain name  but remove the first subdomain
    $interface->assign('googleAnalyticsDomainName', $googleAnalyticsDomainName);
}
global $library;
//Set System Message
if ($configArray['System']['systemMessage']) {
    $interface->assign('systemMessage', $configArray['System']['systemMessage']);
} else {
    if ($configArray['Catalog']['offline']) {
        $interface->assign('systemMessage', "The circulation system is currently offline.  Access to account information and availability is limited.");
    } else {
Esempio n. 15
0
 /**
  * Track what people are doing on your website.
  * 
  * @param array $track				The array of group data for Segment's \Analytics::track()
  * @param bool $js					Set this to generate the content as JS once you run render()
  * @param array $js_options			The array of options to set for the JS "options" parameter - "integrations"
  * 									options get specified in $track, but may be overridden here.
  * @param string $js_callback		If you want to use a callback function with "track," specify it here.
  * @param bool $noninteraction		Set this variable to true to tell Google Analytics that the event is a
  * 									non-interaction event.
  * 
  * @return mixed True or false depending on if the PHP version succeeded, or the JS code if we compiled the JS code
  */
 public function track(array $track, $js = true, array $js_options = array(), $js_callback = null, $noninteraction = true)
 {
     // Set the userId or anonymousId if userId is missing.
     $this->_set_identity($track);
     // Add the context data.
     $track = \Arr::merge($this->_get_context($js), $track);
     // If we're processing noninteractive calls through Google Analytics...
     if ($noninteraction === true) {
         if (empty($track['properties'])) {
             $track['properties']['nonInteraction'] = 1;
         } else {
             $track['properties'] = \Arr::merge(array('nonInteraction' => 1), $track['properties']);
         }
     }
     if ($js !== true) {
         return \Analytics::track($track);
     } else {
         // Event
         $js_params[] = "'" . $track['event'] . "'";
         // Properties
         $js_params[] = !empty($track['properties']) ? json_encode($track['properties']) : "{}";
         // Integrations and options
         $js_params[] = $this->_set_js_options($js_options, $track);
         // Callback function
         $js_params[] = !empty($js_callback) ? $js_callback : "null";
         // Add it to the queue.
         return $this->_js_scripts['track'][] = "analytics.track(" . implode(',', $js_params) . ");";
     }
 }
Esempio n. 16
0
<?php

/**
 * @link https://github.com/lordcoste/analytics-s2s
 * @author Colao Stefano < *****@*****.** >
 */
const BUNDLE_NAME = 'analytics-s2s';
Autoloader::map(array('Analytics' => Bundle::path(BUNDLE_NAME) . 'Analytics.php', 'AnalyticsService' => Bundle::path(BUNDLE_NAME) . 'AnalyticsService.php', 'Google_Client' => Bundle::path(BUNDLE_NAME) . 'google-api' . DS . 'Google_Client.php', 'Google_AnalyticsService' => Bundle::path(BUNDLE_NAME) . 'google-api' . DS . 'contrib' . DS . 'Google_AnalyticsService.php'));
IoC::singleton('google-analytics', function () {
    $prefix = Bundle::prefix(BUNDLE_NAME);
    if (!File::exists(Config::get($prefix . 'google.certificate_path'))) {
        throw new Exception("Can't find the .p12 certificate in: " . Config::get($prefix . 'google.certificate_path'));
    }
    $config = array('oauth2_client_id' => Config::get($prefix . 'google.client_id'), 'use_objects' => Config::get($prefix . 'google.use_objects'));
    $google = new Google_Client($config);
    $google->setAccessType('offline');
    $google->setAssertionCredentials(new Google_AssertionCredentials(Config::get($prefix . 'google.service_email'), array('https://www.googleapis.com/auth/analytics.readonly'), file_get_contents(Config::get($prefix . 'google.certificate_path'))));
    return new AnalyticsService($google);
});
Analytics::init(IoC::resolve('google-analytics'));
 public function postBusinessAnalytics()
 {
     $startdate = Input::get('startdate');
     $enddate = Input::get('enddate');
     $business_id = Input::get('business_id');
     $analytics = Analytics::getBusinessAnalytics($business_id, strtotime($startdate), strtotime($enddate));
     return json_encode(array('analytics' => $analytics));
 }
Esempio n. 18
0
 public function get_most_returned_items_by_month_post()
 {
     $year = $this->input->post('year');
     $analytics = new Analytics($this->base_model->get_db_instance());
     echo $analytics->get_most_returned_items_by_month($year);
 }
Esempio n. 19
0
 public static function blockUser($ips)
 {
     self::$blockedUsers = array_merge(self::$blockedUsers, (array) $ips);
 }
Esempio n. 20
0
<?php

require 'analytics-php/lib/Analytics.php';
$config = Config::get('analytics');
Analytics::init($config['segmentio-key']);
Esempio n. 21
0
	function player_select($league_id = '', $team_id = ''){
		$this->load->model('tracked_events');
		$this->load->model('events');
		date_default_timezone_set('America/Detroit');
		$this->load->helper(array('form', 'url', 'cookie'));
		$this->load->library('form_validation');
		$this->form_validation->set_error_delimiters('<p class="help-block">', '</p>');
		$this->load->model('teams');
		$data['lang'] = 'english';
		$data['theme'] = $this->options->get('theme');
		$data['title'] = vlang('league_player_select_title');
		$data['user'] = $this->users->get_by_id($this->users->id());
		$data['user_can_edit'] = $user_can_edit = 0;
		$data['ticket_types'] = $this->config->item('ticket_types');
		$data['user_balance'] = $data['balance'] = $this->user_funds->user_balance($this->users->id());
		$existing_league_team = '';
		
		
		if($this->users->is_loggedin() === TRUE) {
			$this->users->auth_check();
		}
		
		if($league_id == ''){
		$data_from_create = unserialize(get_cookie('leaguedata', TRUE));
		$sport = strtolower($data_from_create['sport']);
		}
		
		if( $team_id == 'welcome' || $team_id == '') {
			$team_id = $data['team_id'] = null;
		}else {	
			$data['team_id'] = $team_id;
		}
		
		$edit=false;
		if(!empty($team_id)){
			$this->session->unset_userdata('temp_league_team');
			$edit=true;
		}
		
		if ($data['user']->activation_code == 'mailchimp'){
			$this->load->model('mailchimp');
			$this->config->load('mailchimp');
			$main_list=$this->config->item('mailchimp_main_list');
			$member_info=$this->mailchimp->lists_member_info($main_list,$data['user']->email);
			if(isset($member_info->data[0]->status) && in_array($member_info->data[0]->status,array("subscribed","unsubscribed"))){
				$this->db->where('cid',$data['user']->cid)->update('users',array('activation_code'=>''));
			}
		}
		
		$email_confirmation=$this->options->get('email_confirmation');
		if($edit!=true && !empty($data['user']->activation_code) && $email_confirmation==1){
			$this->session->set_flashdata('error','You must validate your email before you can join any games');
			
			redirect('lobby');
		}
		
		if(!empty($league_id)){
			//either joining or editing
			$league_info=(array)$this->leagues->get_by_id($league_id);
			if(empty($team_id)){
				//if this game is password protected make sure right password has been entered
				$session_pass=$this->session->userdata('league_passwords');
				if((!empty($league_info['password']) && (!isset($session_pass[$league_info['cid']]) || (isset($session_pass[$league_info['cid']]) && $session_pass[$league_info['cid']]!=$league_info['password'])))){
					$this->session->set_flashdata('error','This game is password protected');
					redirect('lobby');
					exit;
				}
			}
			//check if it's okay to start making rosters yet
			//if($league_info !== FALSE && $league_info['first_game_cutoff']>time()+(2*86400)){
			if($league_info !== FALSE && $league_info['early_reg']==1){
				if(!empty($team_id)) {
					$this->session->set_flashdata('error','You are not allowed to set rosters yet.');
					redirect('lobby');
				}
			}
			//no league found - offer user to create one
			if ($league_info === FALSE || (isset($league_info[0]) && $league_info[0] === FALSE)){
				$this->session->set_flashdata('error',vlang('league_player_select_league_not_found'));
				redirect('league/create');
				exit;
			}elseif(isset($league_info['cid'])){
				$league_info['id'] = $league_info['cid'];
			}
			
			if($league_info["finalized"]==1 || ($edit==false && $league_info['first_game_cutoff'] < time())) {
				$this->session->set_flashdata('error',vlang('league_player_select_league_expired'));
				redirect('league/create');
			}
			
			if($league_info["multi_entry"]==1){
				//first try to grab the correct team, if there's no team specified then the user is trying to create a new one
				if(!empty($team_id)) $league_team = $this->leagues->get_league_team(array('user_id' => $this->users->id(),'league_id' => $league_id,"id"=>$team_id));
				else $league_team = false;
			}else{
				//no need to bother with the team id stuff,
				$league_team = $this->leagues->get_league_team(array('user_id' => $this->users->id(),'league_id' => $league_id));
			}
			
			if($league_team!=false) $data['user_can_edit'] = $user_can_edit = 1;
			
			$players=$this->input->post('players');
			
			if(!empty($players)){
				//keep team info in case of error/redirect/exit/etc
				$old_team=$this->session->userdata('temp_league_team');
				if(isset($old_team['temp_id'])) {
				//get rid of users old temp data if exists
				$this->db->delete('league_temp',array('id'=>$old_team['temp_id']));
				}
				//put the new roster into a temp table
				$temp_roster=json_encode($players);
				$created=time();
				$rdata = array('roster'=>$temp_roster,'league_id'=>$league_id,'created'=>$created);
				
				$this->db->insert('league_temp',$rdata);
				$temp_id = $this->db->insert_id();
				$temp_league_team = array(
					"temp_id"=>$temp_id,
					"temp_created"=>$created,
					"temp_league_uri"=>$_SERVER['REQUEST_URI']
				);
				
				//set some session data so this works for both logged in/logged out(invited) users
				$this->session->set_userdata('temp_league_team', $temp_league_team);
			}

			//see if user has a temp league team from error/redirect/whatever
			$temp_team=$this->session->userdata('temp_league_team');

			if(!empty($temp_team) && isset($temp_team['temp_id']) && isset($temp_team['temp_created'])) {
				$this->db->where('id',$temp_team['temp_id']);
				$this->db->where('created',$temp_team['temp_created']);
				$tquery=$this->db->get('league_temp');

				if($tquery->num_rows() > 0) {
					$trow = $tquery->row_object();					
					$temp_team_league = $trow->league_id;
					$temp_team_roster = $trow->roster;
					
					if($temp_team_league == $league_id) {
						if(!empty($temp_team_roster)){					
						    if( ! $league_team ){
    							
								$league_team->roster = $temp_team_roster;
								$data['existing_league_team'] = $existing_league_team = $league_team;
							}
						}
					}
				}
				
			} elseif(empty($temp_team) && $league_id != "" && $team_id != ""){
    			$this->db->where('id',$team_id);
				$this->db->where('league_id',$league_id);
				$this->db->limit(1);
				$tquery=$this->db->get('league_temp');
                
				if($tquery->num_rows() > 0) {
					$trow = $tquery->row_object();					
					$temp_team_league = $trow->league_id;
					$temp_team_roster = $trow->roster;
					
					if($temp_team_league == $league_id) {
						if(!empty($temp_team_roster)){					
						    if( ! $league_team ){
    							
								$league_team->roster = $temp_team_roster;
								$data['existing_league_team'] = $existing_league_team = $league_team;
							}
						}
					}
				}

			}
			
			
			//If user logged in and match is multi-entry
			if ($league_team === FALSE && $this->users->is_loggedin() && $league_info['multi_entry']==1){
				$league_team = new stdClass;
				$league_team->id = 'new';
				$league_team->user_id = $this->users->id();
				$league_team->created = 0;
				$league_team->roster = '{}';
			}

			//If user not logged in (invited) - offer to create a line up first, then require them to register
			if ($league_team === FALSE && $this->users->is_loggedin() === FALSE && $this->session->userdata('is_invite') == 'yes'){
				$league_team = new stdClass;
				$league_team->id = 'new';
				$league_team->user_id = 'new';
				$league_team->created = 0;
				$league_team->roster = '{}';
			}
			
			//If user not logged in (invited) - offer to create a line up first, then require them to register
			if ($league_team === FALSE && $this->users->is_loggedin() === FALSE){
				$league_team = new stdClass;
				$league_team->id = 'new';
				$league_team->user_id = 'new';
				$league_team->created = 0;
				$league_team->roster = '{}';
			}
			
			//If user logged in and invited to private league -- let them in
			if ($this->users->is_loggedin() && $league_team === FALSE && isset($league_info['visibility']) && $league_info['visibility'] == 'private' && $this->session->userdata('is_invite') == 'yes'){
				$league_team = new stdClass;
				$league_team->id = 'new';
				$league_team->user_id = $this->users->id();
				$league_team->created = 0;
				$league_team->roster = '{}';
			}

			//If user not logged in and not invited, boot them to the login screen
/*
			if ($league_team === FALSE && $this->users->is_loggedin() === FALSE && $this->session->userdata('is_invite') != 'yes') {
				$this->session->set_flashdata('error',vlang('league_login_info'));
				$this->users->auth_check();
			}
*/

			//joining an existing public league
			if ($this->users->is_loggedin() && $league_team === FALSE && isset($league_info['visibility']) && $league_info['visibility'] == 'public'){
				$league_team = new stdClass;
				$league_team->id = 'new';
				$league_team->user_id = $this->users->id();
				$league_team->created = 0;
				$league_team->roster = '{}';
			}

			if ($league_team === FALSE){
				//joining a league
				$this->session->set_flashdata('error',vlang('league_player_select_league_not_found'));
				redirect('league/create');
			}else{
				if($league_info['sport'] == 'NHL' && $league_team->id != 'new') {
					$data['goalie_start'] = 'N';
					$event_arr = array();
					$included_events = json_decode($league_info['included_events']);
					foreach($included_events as $ie) {
						$event_arr[] = $ie;
					}
					//find out if goalies are starting or not
					$this->db->where_in('event_id',$event_arr);
					$this->db->where('type','Starter');
					$starters = $this->db->get('sport_event_lineup');
					$start_arr = array();
					foreach($starters->result() as $st) {
						$start_arr[] = $st->player_id;
					}

					$curr_roster = json_decode($league_team->roster,true);

					if(in_array($curr_roster['G']['1']['id'],$start_arr)) {
					$data['goalie_start'] = 'Y';
					}
				}
				//editing an existing team
				$data['existing_league_team'] = $existing_league_team = $league_team;

			}

			$data['entries']=$entries=count($this->leagues->get_teams_by_league($league_id));
			if($data['entries'] < $league_info['size']) {
				$data['entries_text'] = vlang('league_entries_extra_text');
			} else {
				$data['entries_text'] = '';
			}
			$data['leaguecid'] = $league_info['cid'];
			//get all teams in the league
			$sql = 'SELECT * FROM ci_league_team JOIN ci_users on cid = user_id WHERE league_id = "'.$league_id.'" ORDER BY username ASC';
			$entrants=$this->db->query($sql);
			if($entrants->num_rows() > 0) {
				$data['entrants'] = $entrants->result();
			} else {
				$data['entrants'] = '';
			}
		}else{
			$league_info=$this->session->userdata('leaguedata');
			if(empty($league_info)){
				$league_info = unserialize(get_cookie('leaguedata', TRUE));
			}
			$data['entries']=$entries=0;
			$data['entries_text'] = vlang('league_entries_extra_text');
			$data['leaguecid'] = '';
			$data['entrants'] = '';

		}
		

		if($league_info['type'] == 3 || $league_info['type'] == 6) {
			redirect('game/pick5/'.$league_id.'/'.$team_id);
		} elseif($league_info['type'] == 4) {
			redirect('game/over_under/'.$league_id.'/'.$team_id);
		}
		elseif($league_info['type'] == 111) {
			
			if(!isset($league_info['cid'])){
				$league_id = $this->leagues->create($league_info); 
			}
			redirect('game/pick/'.$league_id.'/'.$team_id);
		}
		
		
		$multi_h2h=$this->session->userdata('multi_h2h');
		if($multi_h2h==true){
			$temp_team=$this->session->userdata('temp_league_team');

			if(!empty($temp_team)) {
				$this->db->where('id',$temp_team['temp_id']);
				$this->db->where('created',$temp_team['temp_created']);
				$tquery=$this->db->get('league_temp');
				if($tquery->num_rows() > 0) {
					$trow = $tquery->row();
					$temp_team_league = $trow->league_id;
					$temp_team_roster = $trow->roster;
					if($temp_team_league == $league_id) {
						$league_team->roster = $temp_team_roster;
						$data['existing_league_team'] = $existing_league_team=$league_team;
					}
				}
			}
		}
		
		$data['scoring']= (array) json_decode($this->options->get('scoring'),true);
		
		$data['sport'] = strtolower($league_info['sport']);

		if (isset($league_info['first_game_cutoff']) && ($league_info['first_game_cutoff']) < time()){
			$this->session->set_flashdata('error',vlang('league_player_select_league_expired'));
			redirect('league/create');
		}

		if (isset($league_info['auto_game_id']) && $league_info['auto_game_id']==0 && isset($league_info['size']) && ($league_info['size']) == $data['entries'] && $data['user_can_edit'] == 0){
		$this->session->set_flashdata('error',vlang('league_player_select_league_full'));
		redirect('league/importexport');
		}
		
		

		if (isset($league_info['entry_fee']) && $league_info['entry_fee'] > 0 && $this->session->userdata('is_invite') == 'yes') {
			$this->session->set_flashdata('error',vlang('league_player_select_league_payment'));
		}
		

		//similar thing below also used in view/view_min, should prob go in a function
		$prize_structures_options=$this->leagues->get_prize_structures();

		foreach ($prize_structures_options as $pso) {
			$pid = $pso->id;
			$title=json_decode($pso->title);
			//determine # of winners
			if($pid == $league_info['prize_structure']) {
				//see if we have a custom prize
				$fgd='';
				if(isset($league_info['feat_game_data'])) {
					$fgd=json_decode($league_info['feat_game_data']);
				}
				$company_take = $this->options->get('company_take');
				$prize=(isset($fgd->custom_prize) && $fgd->custom_prize!==false)?$fgd->custom_prize:($league_info['size'] * $league_info['entry_fee']);
				$take=(isset($fgd->custom_rake) && $fgd->custom_rake!==false)?(1-($fgd->custom_rake/100)):(1 - $company_take);

				$prizetotal=$prize*$take;
				if(isset($prizetotal)) {
					switch($league_info['prize_structure']) {
						case 1: //winner take all
						$data['winner_text'] = $title->$data['lang'].' : $'.number_format($prizetotal,2,'.',',');
						break;
						case 2: //top 3
						$data['winner_text'] = $title->$data['lang'].' : $'.number_format($prizetotal*.444,2,'.',',').' / $'.number_format($prizetotal*.333,2,'.',',').' / $'.number_format($prizetotal*.222,2,'.',',');
						break;
						case 3: //top 3rd
						$data['winner_text'] = $title->$data['lang'].' : Each winner $'.number_format($prizetotal/($league_info['size']/3),2,'.',',');
						break;
						case 4: //50/50
						$data['winner_text'] = $title->$data['lang'].' : Each winner $'.number_format($prizetotal/($league_info['size']/2),2,'.',',');
						break;
						case 100: //LFP
							//these numbers are set by the admin
						$data['winner_text'] = $title->$data['lang'].' : Total prizes $'.number_format($prizetotal,2,'.',',').' <a href="#lfp_modal" data-toggle="modal" class="question">Learn More</a>';
							$lfp=json_decode($league_info['winn_perc_data']);
							$data['lfp_modal'] = '';
							if(isset($lfp)) {
								foreach($lfp as $k=>$v){
										if (!in_array(($k % 100),array(11,12,13))){
										  switch ($k % 10) {
											// Handle 1st, 2nd, 3rd
											case 1:  $k = $k.'st';
											break;
											case 2:  $k = $k.'nd';
											break;
											case 3:  $k = $k.'rd';
											break;
											default: $k = $k.'th';
											break;
										  }
										}
									$data['lfp_modal'] .= '<p><strong>'.$k.':</strong> '.$v.'% - $'.number_format($prizetotal*($v/100),2,'.',',').'</p>';
								}
							}
						break;
						default:
						$data['winner_text'] = $title->$data['lang'];
						break;
					}
				} else {
					$data['winner_text'] = $title->$data['lang'];
				}
			}
		}
		//end potential function
		
		$data['league_info']=$league_info;
		$league_info['feat']=0;
		$data['prize_structure']=$this->leagues->get_prize_structure_by_id($league_info['prize_structure']);

		

		$data['sport_data'] = json_decode($this->options->get('sport_data'), true);
		
		//$data['avail_games']=$this->leagues->get_avail_games_by_time_slot($league_info['date'],$league_info['time'],$league_info['sport']);
		if(!empty($league_info['included_events'])){    		
			$data['avail_games'] = $avail_games = $this->leagues->get_avail_games_custom($league_info['included_events'],$league_info['sport']);
		} else { 
			$data['avail_games'] = $avail_games = $this->leagues->get_avail_games_by_time_slot($league_info['date'],$league_info['time'],$league_info['sport']);
		}
		
		if(isset($data['sport']) && $data['sport'] != ""){
			$sport = $data['sport'];
		}
		
		$data['extra_js'] = '<script type="text/javascript">var players = '.$this->get_player_list_json($sport,$avail_games,'ALL').'</script>';
		//determine earliest league play for count-down ticker
		$countdown_until = $this->leagues->get_games_cutoff_time($data['avail_games']);
		$data['extra_js'] .= "<script type='text/javascript'>var cutoff_time = new Date(".date('Y, ', $countdown_until).(date('m', $countdown_until) - 1).", ".date('d, H, i, s', $countdown_until).");</script>";
		$data['extra_js'] .= "<script type='text/javascript' src='".site_url('assets/'.$data['theme'].'/js/player_select.js?v='.$this->config->item('ftd_version'))."'></script>";
		$data['extra_js'] .= "<script type='text/javascript' src='/assets/".$data['theme']."/js/typeahead.js'></script>";
		

		
		if($data['user_can_edit'] == 0) {
			$post_plus_league = $_POST;
				
			$this->session->set_userdata('post_plus_league', $post_plus_league);
			if($this->users->is_loggedin() === TRUE) {
				$this->form_validation->set_rules('leaguedata', '', 'xss_clean|trim|callback_has_enough_money');
			}
		}
		$this->form_validation->set_rules('players[][]', 'Players', 'xss_clean|trim');

		if ($this->form_validation->run() === FALSE){
		}else{
			
			$session_pass=$this->session->userdata('league_passwords');
			if($user_can_edit==1 || ($user_can_edit==0 && (!empty($league_info['password']) && isset($session_pass[$league_info['cid']]) && $session_pass[$league_info['cid']]==$league_info['password']) || empty($league_info['password']))){
				
				if($this->users->is_loggedin()){
    				
    				    				
					$this->leagues->player_select_post($this->input->post(),$team_id,$edit,$league_info,$entries,$existing_league_team,$user_can_edit,$avail_games);
				}else{
				
				$data = array(
	               'roster' => json_encode($_POST['players']),
	               'league_id' => $league_info['cid'],
	               'created' => time(),
	            );
				
				//$this->db->insert('league_temp', $data); 
				$temp_team['temp_id'] = $this->db->insert_id();
				$temp_team['league_uri'] = $_SERVER['REQUEST_URI'];
				$this->session->set_userdata('temp_league_team', $temp_team); 
				 
				$this->session->set_flashdata('warning','Don\'t worry your lineup is safe but lets first register for an account.');
				
				redirect('login');
				
				}
				
			}else{
				$this->session->set_flashdata('error','That league requires a password.');
				redirect('lobby');
			}
		}
		$data["body_sport"]=strtolower($league_info['sport']);
		

		if( $team_id == 'welcome' ) {
			$this->tracked_events->tracked(2, $this->users->id());
			$data['extra_js'] .= <<<HTML
	<!-- Google Code for Account Registration Conversion Page -->
	<script type="text/javascript">
	/* <![CDATA[ */
	var google_conversion_id = 984690397;
	var google_conversion_language = "en";
	var google_conversion_format = "3";
	var google_conversion_color = "ffffff";
	var google_conversion_label = "NNkfCNOvvwYQ3d3E1QM";
	var google_conversion_value = 0;
	var google_remarketing_only = false;
	/* ]]> */
	</script>
	<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
	</script>
	<noscript>
	<div style="display:inline;">
	<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/984690397/?value=0&amp;label=NNkfCNOvvwYQ3d3E1QM&amp;guid=ON&amp;script=0"/>
	</div>
	</noscript>

HTML;
			$data['extra_js'] .= <<<JAVASCRIPT

	<script type=""text/javascript"">
	var fb_param = {};
	fb_param.pixel_id = '6008179574698';
	fb_param.value = '0.00';
	fb_param.currency = 'USD';
	(function(){
	  var fpw = document.createElement('script');
	  fpw.async = true;
	  fpw.src = '//connect.facebook.net/en_US/fp.js';
	  var ref = document.getElementsByTagName('script')[0];
	  ref.parentNode.insertBefore(fpw, ref);
	})();
	</script>
	<noscript><img height=""1"" width=""1"" alt="""" style=""display:none"" src=""https://www.facebook.com/offsite_event.php?id=6008179574698&amp;value=0&amp;currency=USD"" /></noscript>

JAVASCRIPT;
			
		}elseif( ! $this->tracked_events->check(2, $this->users->id()) ) {
			$this->tracked_events->tracked(2, $this->users->id());
			Analytics::track( $this->users->id(), "First time in player select" );
			$data['modal'] = array(
				'title' => 'Pick Your Team!',
				'content' => '
				<ul>
					<li>1.  Pick your team while staying under the $'.number_format($league_info['salary_cap']).' salary cap</li>
					<li>2.  Submit your team and compete against everyone in the contest!</li>
					<li>3.  Win BIG!</li>
				</ul>
				<p style="text-align:center"><a class="btn btn-success btn-large green" href="#" data-dismiss="modal">START DRAFTING</a></p>',
			);
		}

		//$this->load->view($data['theme'].'/league/player_select',$data);
		$this->load->view($data['theme'].'/league/player_select_advanced',$data);
	}
 public function testGetNullItems()
 {
     $this->assertEquals(null, $this->analytics->getProduct());
 }
Esempio n. 23
0
 public function controller_footer($args)
 {
     // Assemble page-level args for Google Analytics --
     global $webapp;
     $analytics = Analytics::singleton();
     $componentmgr = ComponentManager::singleton();
     $args['cobrand'] = $webapp->cobrand;
     $args['store_name'] = $this->sanitizeStrForGA($analytics->store_name);
     if ($webapp->request['referer']['host'] && !stristr($webapp->request['referer']['host'], $webapp->request['host'])) {
         $args['query'] = $this->getQueryFromURL($webapp->request['referrer'], $args['store_name']);
     } else {
         $args['query'] = $this->sanitizeStrForGA(any($analytics->search["input"]["query"], $analytics->qpmreq->query, 'none'));
     }
     $args['bs'] = $componentmgr->pagecfg;
     //testing
     $args['pagegroup'] = $componentmgr->pagecfg['pagegroup'];
     $args['pagetype'] = $componentmgr->pagecfg['pagename'];
     $args['status'] = any($analytics->status, $webapp->response['http_status']);
     $args['total'] = $analytics->total;
     $args['GAenabled'] = $args['pagegroup'] ? any(ConfigManager::get("tracking.googleanalytics.enabled"), $webapp->cfg->servers['tracking']['googleanalytics']['enabled']) : 0;
     $args['GAalerts'] = $webapp->GAalerts;
     $args['trackingcode'] = any(ConfigManager::get("tracking.googleanalytics.trackingcode"), $webapp->cfg->servers['tracking']['googleanalytics']['trackingcode']);
     $args['enable_native_tracking'] = ConfigManager::get("tracking.enable_native_tracking", NULL);
     $args['category'] = any($analytics->category, $analytics->pandora_result['top_category'], $analytics->item->category, $analytics->qpmquery['protocolheaders']['category'], 'none');
     $args['subcategory'] = preg_replace("#\\s#", "_", any($analytics->subcategory, $analytics->pandora_result['top_subcategory'], 'none'));
     $args['city'] = "Mountain View";
     $args['state'] = "CA";
     $args['country'] = "USA";
     if ($analytics->city && $analytics->state) {
         $args['city'] = ucWords($analytics->city);
         $args['state'] = $analytics->state;
         $args['country'] = "USA";
     }
     if (in_array($args['cobrand'], array('paypaluk', 'thefinduk', 'paypalcanada'))) {
         $args['city'] = 'unknown';
         $args['state'] = 'unknown';
         $args['country'] = $args['cobrand'] == 'paypalcanada' ? "Canada" : "UK";
     }
     $args['pagenum'] = any($analytics->pandora_result['page_num'], 1);
     $args['version'] = any(ABTestManager::getVersion(), "unknown");
     $args['filters'] = $analytics->qpmreq->filter['brand'] ? '1' : '0';
     $args['filters'] .= $analytics->qpmreq->filter['color'] ? '1' : '0';
     $args['filters'] .= $analytics->qpmreq->filter['storeswithdeals'] ? '1' : '0';
     //(coupons)
     $args['filters'] .= $analytics->qpmquery['headers']['localshopping'] ? '1' : '0';
     //(local)
     $args['filters'] .= $analytics->qpmquery['headers']['market'] == 'green' ? '1' : '0';
     //(green)
     $args['filters'] .= $analytics->qpmreq->filter['minimall'] ? '1' : '0';
     //(marketplaces)
     $args['filters'] .= $analytics->qpmreq->filter['filter']['price'] ? '1' : '0';
     $args['filters'] .= $analytics->qpmreq->filter['sale'] ? '1' : '0';
     $args['filters'] .= $analytics->qpmreq->filter['store'] ? '1' : '0';
     $args['filters'] .= $analytics->qpmreq->filter['freeshipping'] ? '1' : '0';
     $args['alpha'] = $analytics->alpha;
     $args['browse'] = $analytics->browse;
     $session = SessionManager::singleton();
     $args['is_new_user'] = $session->is_new_user;
     $args['is_new_session'] = $session->is_new_session;
     $user = User::singleton();
     $args['is_logged_in'] = $user->isLoggedIn();
     $args['usertype'] = $user->usertype;
     $args['userid'] = $user->userid;
     $args['useremail'] = $user->email;
     $estimated_birth_year = $user->getUserSetting('estimated_birth_year');
     $gender = $user->gender;
     $user_gender = $gender == 'F' ? 'female' : 'male';
     //if($user->getUserSetting("tracking.user.demographics_dimension") != 1) {
     $args['birth_year'] = $estimated_birth_year;
     $args['user_gender'] = $user_gender;
     $location = $user->GetLocation();
     if ($location['city'] && $location['state']) {
         $args['demo_location'] = $location['city'] . ',' . $location['state'];
     }
     //$user->setUserSetting("tracking.user.demographics_dimension", "1");
     //}
     $args['cfg_cobrand'] = $webapp->cfg->servers["cobrand"];
     $args['request_cobrand'] = $webapp->request["args"]["cobrand"];
     //$args['GAenabled'] = 1; //testing only
     if (empty($this->shown["footer"])) {
         // Only allow footer once per page
         $this->shown["footer"] = true;
         return $this->GetComponentResponse("./footer.tpl", $args);
     }
     return "";
 }
Esempio n. 24
0
// global templating engine, Smarty
require_once 'includes/Group.class.php';
include_once 'includes/Access.php';
require_once 'includes/bbcode.php';
require_once "includes/Mailer.class.php";
require_once "includes/Analytics.class.php";
require_once "includes/TranslationEngine.class.php";
include_once 'includes/cphplib/cphplib.inc';
include_once 'configs/globals.php';
include_once 'includes/GlobalDB.php';
/**
 * The first thing to do can be to call the Analytics
 * class which will output nothing; but only keep
 * statistical information.
 */
$analytics = new Analytics();
/**
 * this can be done on any page
 * we use it without making any check; but it is
 * safe; because the function itself makes the necessary
 * checks
 */
$analytics->registerRefererURL();
$tpl = new Smarty();
$tpl->compile_dir = 'templates/templates_c';
$tpl->config_dir = 'templates/configs';
$tpl->cache_dir = 'templates/cache';
/**
 * Is this an authenticated user
 */
$access_isAuthenticated = isAuthenticated();
Esempio n. 25
0
 public function processPurchase($post, $request, $server, $cookie)
 {
     if (isset($post) && isset($server) && isset($request) && $server['REQUEST_METHOD'] == 'POST') {
         $db = new DBHandler();
         $db->connect();
         $lead = array();
         // Datas
         $u = new Utility();
         $request = array_merge($request, $cookie);
         $coupon = strtoupper($request['coupon_code']);
         $branch = isset($request['tnfbranch']) ? $request['tnfbranch'] : $request['branch'];
         $request['txn_id'] = $u->generateTransactionReceipt($branch, $coupon) . $db->retrieveBuyerLastId();
         $params = $u->processPurchaseData($request);
         $params['couponCode'] = $coupon;
         // Items
         $items = $u->processPurchaseItems($request);
         // End of Datas
         $ss = new SpreadsheetHandler();
         $ss->addPurchaseToDocs($items, $params);
         $db->insertBuyer($coupon, $params, $items);
         $analytics = new Analytics();
         $analytics->ga($params, $items);
         $userfname = isset($request['userfname']) ? $request['userfname'] : "";
         $userlname = isset($request['userlname']) ? $request['userlname'] : "";
         $logparams = array("action" => "Coupon Redemption", "module" => "TNF Microsite " . $branch, "content" => $userfname . " " . $userlname . " from " . $branch . " process a promo coupon redemption with promo code " . $coupon, 'ip' => $server['REMOTE_ADDR']);
         $db->updateLogs(0, $logparams, $userfname, $userlname);
         return $params;
     } else {
         return false;
     }
 }
Esempio n. 26
0
 public static function init($analytics)
 {
     if (is_null(self::$analytics)) {
         self::$analytics = $analytics;
     }
 }
Esempio n. 27
0
<?php

/**
 * @author Jeff Tickle <jtickle at tux dot appstate dot edu>
 */
PHPWS_Core::initModClass('analytics', 'Analytics.php');
Analytics::process();
Esempio n. 28
0
	function process_ajax(){
		$this->load->model('tracked_events');
		$this->load->library('authnet_aim');
		$post_data=$this->input->post();
		$user_id=$this->input->post('user_id');
		if(!empty($post_data)){
			//echo "<pre>".print_R($post_data,true)."</pre>";
			$gateway=$this->payments->get_gateway_by_system_name('authnet');
			$method=$this->payments->get_method_by_gateway_id($gateway->cid);
			$methodx=json_decode($method->data);

			$payment_data=array(
				"x_login"=>$methodx->api_login,
				"x_tran_key"=>$methodx->api_key,
				"x_type"=>"AUTH_CAPTURE",
				"x_amount"=>$this->input->post('amount'),
				"x_card_num"=>str_replace(" ","",$this->input->post('cc_num')),
				"x_exp_date"=>str_replace(" ","",$this->input->post('cc_exp')),
				"x_card_code"=>$this->input->post('cc_security'),
				"x_description"=>"Deposit $".$this->input->post('amount'),				
				"x_first_name"=>$this->input->post('first_name'),
				"x_last_name"=>$this->input->post('last_name'),
				"x_zip"=>$this->input->post('zip'),
			);
			//echo "<pre>".print_R($payment_data,true)."</pre>";
			foreach($payment_data as $k=>$v) $this->authnet_aim->add_field($k,$v);
			//$this->authnet_aim->set_test();
			$response_id=$this->authnet_aim->process();

			if($response_id == 1){
				$response=$this->authnet_aim->response;
				
				//Add transaction to the payment log
				$payment_log=array(
					'user_id'=>$user_id,
					'trans_id'=>$response['Transaction ID'],
					'amount'=>$response['Amount'],
					'type'=>1,
					'status'=>1,
					'approval_code'=>$response['Approval Code'],
					'product_id'=>$this->input->post('item_id'),
					'time'=>time(),
					'method_id'=>$method->cid,
					'raw_return_data'=>json_encode($response)
				);
				
				$this->db->insert('payments',$payment_log);
				$payment_id = $this->db->insert_id();
				
				//integrate with user_funds plugin
				$this->load->model('user_funds');
				//add transaction
				//$product_data=json_decode($product->extradata);
				$this->user_funds->add_payment($user_id, $response['Amount'], $payment_id);
				$this->user_funds->apply_sign_up_promos($user_id, $response['Amount']);
				//add promo code stuff
				$promo_code=$this->input->post('promo_code');
				if(isset($promo_code) && !empty($promo_code)){
					if($debug) $debug_mail.="made it to the model function with ".$user_id.",".$promo_code.",".$response['Amount']."\n\n";
					$this->user_funds->apply_promo($user_id,$promo_code,$response['Amount']);
				}
				
				if( ! $this->tracked_events->check(3, $this->users->id()) ) {
					$this->tracked_events->tracked(3, $this->users->id());
					Analytics::track( $this->users->id(), "First time added funds", array('revenue' => $response['Amount']) );
				}else {
					$this->tracked_events->add(4, $this->users->id());
					Analytics::track( $this->users->id(), "Other time added funds", array('revenue' => $response['Amount']) );
				}
				
				$this->session->set_userdata('amount_deposit', $response['Amount']);
				echo json_encode(array("status"=>"tiptop"));
			}else{
				$response_reason=$this->authnet_aim->get_response_reason_text();
				$this->session->set_flashdata('error',$response_reason);
				echo json_encode(array("status"=>"bogus","message"=>$response_reason));
			}			
		}else{
			$this->session->set_flashdata('error','There was an error proccessing your payment, please try again.');
			echo json_encode(array("status"=>"bogus","message"=>"There was an error proccessing your payment, please try again."));
		}
	}	
Esempio n. 29
0
<?php

include_once 'includes/analyticstracking.php';
$tracker = new Analytics();
?>
<!DOCTYPE html>
<!--[if IE 8]>
<html class="no-js lt-ie9 ie8" lang="en"> <![endif]-->
<!--[if IE 9]>
<html class="ie9" lang="en"> <![endif]-->
<!--[if IE 10]>
<html class="ie10" lang="en"> <![endif]-->
<!--[if (gt IE 10)|!(IE)]>
<html lang="en"> <![endif]-->
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>UBI Group | Luxury Home Financing | Home Loans</title>

    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
          integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

    <!-- Latest compiled and minified JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"
            integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS"
            crossorigin="anonymous"></script>
Esempio n. 30
0
 public function get_most_returned_items_by_month_post()
 {
     $analytics = new Analytics($this->base_model->get_db_instance());
     echo $analytics->get_most_returned_items_by_month(2015);
 }