TOP 30 Referrer

@param	integer	$VisitorsID	ID des Zählers
@return	array
174081
protected function getReferrerTop($VisitorsID)
	{
		$topNo = 30;
		$VisitorsReferrerTop = array();
		if ($VisitorsID) 
		{
			//Version
    		$objVisitorsReferrerTop = \Database::getInstance()
    		        ->prepare("SELECT 
                                    `visitors_referrer_dns`, 
                                    count(`id`) AS SUMRT
                                FROM 
                                    tl_visitors_referrer
                                WHERE 
                                    vid=?
                                GROUP BY `visitors_referrer_dns`
                                ORDER BY SUMRT DESC, visitors_referrer_dns ASC")
                    ->limit($topNo)
                    ->execute($VisitorsID);
    	    if ($objVisitorsReferrerTop->numRows > 0) 
    	    {
    		    while ($objVisitorsReferrerTop->next()) 
    		    {
    		    	if ($objVisitorsReferrerTop->visitors_referrer_dns !== '-') 
    		    	{
    		    		$VisitorsReferrerTop[] = array($objVisitorsReferrerTop->visitors_referrer_dns, $objVisitorsReferrerTop->SUMRT, $VisitorsID);
    		    	} 
    		    	else 
    		    	{
    		    		$VisitorsReferrerTop[] = array('- ('.$GLOBALS['TL_LANG']['MSC']['tl_visitors_stat']['referrer_direct'].')', $objVisitorsReferrerTop->SUMRT, 0);
    		    	}
    		    	
    		    }
    	    }
		}
		return $VisitorsReferrerTop;
	}
644802
public function getVisitorCountForViewReference($viewReferenceId)
    {
        $viewCount = $this->entityManager->getRepository('Victoire\Bundle\AnalyticsBundle\Entity\BrowseEvent')
            ->getNumberOfEventForViewReferenceId($viewReferenceId)
            ->getQuery()
            ->getSingleScalarResult();

        return $viewCount;
    }
1010581
public function getRedirectList($siteId)
    {
        try {
            $result = $this->getQuery($siteId)->getResult();
        } catch (NoResultException $e) {
            $result = [];
        }

        return $result;
    }
329646
public function getReferers( $skip )
	{
		$referers		= array();
		foreach( $this->data as $entry )
		{
			if( $entry['remote_addr'] != $this->skip )
			{
				if( $entry['referer_uri'] && !preg_match( "#.*".$skip.".*#si", $entry['referer_uri'] ) )
				{
					if( isset( $referers[$entry['referer_uri']] ) )
						$referers[$entry['referer_uri']] ++;
					else
						$referers[$entry['referer_uri']]	= 1;
				}
			}
		}
		arsort( $referers );
		foreach( $referers as $referer => $count )
			$lines[]	= "<tr><td>".$referer."</td><td>".$count."</td></tr>";
		$lines	= implode( "\n\t", $lines );
		$content	= "<table>".$lines."</table>";
		return $content;
	}
520538
protected function isUserInVisitorStatGroups($visitors_stat_groups, $visitors_stat_protected)
	{
	    if ( true === $this->User->isAdmin )
	    {
	        //Debug log_message('Ich bin Admin', 'visitors_debug.log');
	        return true; // Admin darf immer
	    }
	    //wenn  Schutz nicht aktiviert ist, darf jeder
	    if (false === $visitors_stat_protected) 
	    {
	        //Debug log_message('Schutz nicht aktiviert', 'visitors_debug.log');
	    	return true; 
	    }
	    
	    //Schutz aktiviert, Einschränkungen vorhanden?
	    if (0 == strlen($visitors_stat_groups))
	    {
	        //Debug log_message('visitor_stat_groups ist leer', 'visitors_debug.log');
	        return false; // nicht gefiltert, also darf keiner außer Admin
	    }
	     
	    //mit isMemberOf ermitteln, ob user Member einer der Cat Groups ist
	    foreach (deserialize($visitors_stat_groups) as $id => $groupid)
	    {
	        if ( true === $this->User->isMemberOf($groupid) )
	        {
	            //Debug log_message('Ich bin in der richtigen Gruppe', 'visitors_debug.log');
	            return true; // User is Member of visitor_stat_group
	        }
	    }
	    //Debug log_message('Ich bin in der falschen Gruppe', 'visitors_debug.log');
	    return false;
	}
1164610
public function getVisitors()
	{
		if( !$this->_open )
		{
			trigger_error( "Log File not read", E_USER_ERROR );
			return 0;
		}
		$remote_addrs	= array();	
		$counter	= 0;
		foreach( $this->data as $entry )
		{
			if( $entry['remote_addr'] != $this->skip )
			{
				if( isset( $remote_addrs[$entry['remote_addr']] ) )
				{
					if( $remote_addrs[$entry['remote_addr']] < $entry['timestamp'] - 30 * 60 )
						$counter ++;
					$remote_addrs[$entry['remote_addr']]	= $entry['timestamp'];
				}
				else
				{
					$counter ++;
					$remote_addrs[$entry['remote_addr']]	= $entry['timestamp'];
				}
			}
		}
		return $counter;
	}
842833
public function visitor($visitorId = null)
  {
    if($visitorId === null)
    {
      $visitorId = $this->getVisitorIdCookie();
    }
    return Visitor::newInstance($this)
      ->setVisitorId($visitorId);
  }
731454
public function parseUrl($referer)
    {
        if (is_null($referer)) return null;

        $parsed = parse_url($referer);
        $parts  = explode('.', $parsed['host']);
        $domain = array_pop($parts);

        if (count($parts) > 0)
            $domain = array_pop($parts).'.'.$domain;

        return [
            'url'    => $referer,
            'domain' => $domain,
            'host'   => $parsed['host'],
        ];
    }
748250
protected function getMonth($VisitorsID)
	{
	    $LastMonthVisits    = 0;
	    $LastMonthHits      = 0;
	    $CurrentMonthVisits = 0;
	    $CurrentMonthHits   = 0;
	    $YearCurrentMonth   = date('Y-m-d');
	    $YearLastMonth      = date('Y-m-d' ,mktime(0, 0, 0, date("m")-1, 1, date("Y")));
	    $CurrentMonth   	= (int)date('m');
	    $LastMonth			= (int)date('m',mktime(0, 0, 0, date("m")-1, 1, date("Y")));
	    $ORDER = ($CurrentMonth > $LastMonth) ? 'DESC' : 'ASC'; // damit immer eine absteigene Monatsreihenfolge kommt
		if ($VisitorsID) 
		{
		    $sqlMonth = 'SELECT 
                                EXTRACT( MONTH FROM visitors_date ) AS M, 
                                SUM( visitors_visit ) AS SUMV , 
                                SUM( visitors_hit ) AS SUMH 
                            FROM 
                                tl_visitors_counter 
                            WHERE 
                                vid=? AND visitors_date BETWEEN ? AND ?
                            GROUP BY M
                            ORDER BY M %s';
		    $sqlMonth = sprintf($sqlMonth, $ORDER);
		    
			//Total je Monat (aktueller und letzter)
			$objVisitorsToMo = \Database::getInstance()
            			        ->prepare($sqlMonth)
                                ->limit(2)
                                ->execute($VisitorsID, $YearLastMonth, $YearCurrentMonth);
			$intRows = $objVisitorsToMo->numRows;
			if ($intRows>0) 
			{ 
			    $objVisitorsToMo->next();
			    if ( (int)$objVisitorsToMo->M == (int)date('m') ) 
			    {
			    	$CurrentMonthVisits = $objVisitorsToMo->SUMV;
			    	$CurrentMonthHits   = $objVisitorsToMo->SUMH;
			    }
			    if ( (int)$objVisitorsToMo->M == (int)date('m',mktime(0, 0, 0, date("m")-1, 1, date("Y"))) ) 
			    {
		            $LastMonthVisits = $objVisitorsToMo->SUMV;
		            $LastMonthHits   = $objVisitorsToMo->SUMH;
	            }
			    if ($intRows==2) 
			    {
	                $objVisitorsToMo->next();
	                if ( (int)$objVisitorsToMo->M == (int)date('m',mktime(0, 0, 0, date("m")-1, 1, date("Y"))) ) 
	                {
		        	    $LastMonthVisits = $objVisitorsToMo->SUMV;
		                $LastMonthHits   = $objVisitorsToMo->SUMH;
	                }
			    }
			}
		}
		return array('LastMonthVisits'    => $this->getFormattedNumber($LastMonthVisits,0),
		             'LastMonthHits'      => $this->getFormattedNumber($LastMonthHits,0),
		             'CurrentMonthVisits' => $this->getFormattedNumber($CurrentMonthVisits,0),
		             'CurrentMonthHits'   => $this->getFormattedNumber($CurrentMonthHits,0)
		             );

	}
813813
private function getAuthenticatedVisitorsRatio($visitors)
    {
        $ratio = [
            'authenticated' => 0,
            'guest'         => 0,
        ];

        foreach ($visitors as $visitor) {
            $visitor->hasUser() ? $ratio['authenticated'] += 1 : $ratio['guest'] += 1;
        }

        return collect($ratio)->transform(function ($count, $key) {
            return [
                'name'  => trans("tracker::visitors.$key"),
                'count' => $count,
            ];
        });
    }
21428
public function getVisitors()
    {
        $data = $this->memcache->get(self::MEMCACHE_VISITOR_KEY);
        if (!$data) {
            $data = array();
        }
        return (array)$data;
    }
384784
public function participantsUserIds($userId = null)
    {
        $users = $this->participants()->lists('user_id');

        if ($userId) {
            $users[] = $userId;
        }

        return $users;
    }
367788
public function customer($customerFid = null, $visitorId = null)
  {
    if($visitorId === null)
    {
      $visitorId = $this->getVisitorIdCookie();
    }

    return Customer::newInstance($this)
      ->setVisitorId($visitorId)
      ->setCustomerFid($customerFid);
  }
460358
protected function getBestDay($VisitorsID)
	{
		$objVisitorsBestday = \Database::getInstance()
		        ->prepare("SELECT 
                                visitors_date, 
                                visitors_visit, 
                                visitors_hit
                            FROM 
                                tl_visitors_counter
                            WHERE 
                                vid=?
                            ORDER BY visitors_visit DESC,visitors_hit DESC")
                ->limit(1)
                ->execute($VisitorsID);
		if ($objVisitorsBestday->numRows > 0) 
		{
        	$objVisitorsBestday->next();
        	$visitors_date   = $this->parseDateVisitors($GLOBALS['TL_LANGUAGE'],strtotime($objVisitorsBestday->visitors_date));
        	$visitors_visits = $this->getFormattedNumber($objVisitorsBestday->visitors_visit,0);
        	$visitors_hits   = $this->getFormattedNumber($objVisitorsBestday->visitors_hit,0);
		} 
		else 
		{
			$visitors_date   = '';
			$visitors_visits = 0;
			$visitors_hits   = 0;
		}
		return array('VisitorsBestDayDate'   => $visitors_date,
					 'VisitorsBestDayVisits' => $visitors_visits,
					 'VisitorsBestDayHits'   => $visitors_hits
					);
	}
679178
public function hours($venueId)
    {

        $resource = '/venues/' . $venueId . '/hours';
        $response = $this->makeApiRequest($resource);

        return $response->hours;

    }
1104263
public function listMonetaryAccounts($userId)
    {
        $monetaryAccounts = $this->client->get($this->getResourceEndpoint($userId));

        return $monetaryAccounts;
    }
1240
public function generateNewsVisitHitTop($VisitorsID, $limit = 10, $parse = true)
    {
        $arrNewsStatCount = false;
        
        //News Tables exists?
        if (true === $this->getNewstableexists())
        {
            $objNewsStatCount = \Database::getInstance()
                            ->prepare("SELECT 
                                            visitors_page_id,
                                            visitors_page_lang,
                                            SUM(visitors_page_visit) AS visitors_page_visits,
                                            SUM(visitors_page_hit)   AS visitors_page_hits
                                        FROM
                                            tl_visitors_pages
                                        WHERE
                                            vid = ?
                                        AND visitors_page_type = ?
                                        GROUP BY 
                                            visitors_page_id, 
                                            visitors_page_lang
                                        ORDER BY 
                                            visitors_page_visits DESC,
                                            visitors_page_hits DESC,
                                            visitors_page_id,
                                            visitors_page_lang
                                    ")
                            ->limit($limit)
                            ->execute($VisitorsID, self::PAGE_TYPE_NEWS);
            
            while ($objNewsStatCount->next())
            {
        	    $alias   = false;
        	    $aliases = $this->getNewsAliases($objNewsStatCount->visitors_page_id);
        	    if (false !== $aliases['PageAlias'])
        	    {
        	       $alias = $aliases['PageAlias'] .'/'. $aliases['NewsAlias'];
        	    }
                
                if (false !== $alias) 
                {
                    $arrNewsStatCount[] = array
                    (
                        'title'         => $aliases['NewsArchivTitle'],
                        'alias'         => $alias,
                        'lang'          => $objNewsStatCount->visitors_page_lang,
                        'visits'        => $objNewsStatCount->visitors_page_visits,
                        'hits'          => $objNewsStatCount->visitors_page_hits
                    );
                }
            }
            if ($parse === true)
            {
                /* @var $TemplatePartial Template */
                $TemplatePartial = new \BackendTemplate('mod_visitors_be_stat_partial_newsvisithittop');
                $TemplatePartial->NewsVisitHitTop = $arrNewsStatCount;
                return $TemplatePartial->parse();
            }
            return $arrNewsStatCount;
        }
        return false;
    }