<?php
class Mstats extends Model
{
    function __construct()
	{
		parent::Model();
	}

	function get_links_old($filter)
	{
		$links = array(
            'hun' 	=> '/stats/old_stats/hun',
            'ita' 	=> '/stats/old_stats/ita',
            'aus' 	=> '/stats/old_stats/aus',
            'eun' 	=> '/stats/old_stats/eun',
            'usa' 	=> '/stats/old_stats/usa',
            'ger' 	=> '/stats/old_stats/ger',
            'cz' 	=> '/stats/old_stats/cz',
            'ukr' 	=> '/stats/old_stats/ukr',
            'swi' 	=> '/stats/old_stats/swi',
            'blg' 	=> '/stats/old_stats/blg',
            'sk' 	=> '/stats/old_stats/sk',
            'out' 	=> '/stats/old_stats/out',
            'grp' 	=> '/stats/old_stats/grp'
		);

        foreach($links as $k => $l)
        {
			if(in_array($k, $filter))
			{
				foreach($links as $k2 => $l2)
				{
					$k2==$k ? $links[$k2] = str_replace('/' . $k, '', $links[$k2]) : $links[$k2] .= '/' . $k;
				}
			}
        }

		return $links;
	}

	
	function get_links_new2013($filter)
	{
		$links = array(
            'hun' => '/stats/new_stats_2013/hun',
            'ita' => '/stats/new_stats_2013/ita',
            'pol' => '/stats/new_stats_2013/pol',
            'eun' => '/stats/new_stats_2013/eun',
            'ger' => '/stats/new_stats_2013/ger',
            'ukd' => '/stats/new_stats_2013/ukd',
            'out' => '/stats/new_stats_2013/out',
            'grp' => '/stats/new_stats_2013/grp',
            'temp' => '/stats/new_stats_2013/temp',
            'intbase' => '/stats/new_stats_2013/intbase',
            'apprentice' => '/stats/new_stats_2013/apprentice',
            'smpbase' => '/stats/new_stats_2013/smpbase',
            'studio' => '/stats/new_stats_2013/studio',
            'stand' => '/stats/new_stats_2013/stand',
            'prof' => '/stats/new_stats_2013/prof',
            'intpro' => '/stats/new_stats_2013/intpro',
            'free95' => '/stats/new_stats_2013/free95'
		);

		foreach($links as $k => $l)
        {
			if(in_array($k, $filter))
			{
				foreach($links as $k2 => $l2)
				{
					$k2==$k ? $links[$k2] = str_replace('/' . $k, '', $links[$k2]) : $links[$k2] .= '/' . $k;
				}
			}
        }

		return $links;
	}
    
	
	
	 function get_links_new2012($filter)
	{
		$links = array(
            'hun' => '/stats/new_stats_2012/hun',
            'ita' => '/stats/new_stats_2012/ita',
            'pol' => '/stats/new_stats_2012/pol',
            'eun' => '/stats/new_stats_2012/eun',
            'ger' => '/stats/new_stats_2012/ger',
            'out' => '/stats/new_stats_2012/out',
            'grp' => '/stats/new_stats_2012/grp',
            'temp' => '/stats/new_stats_2012/temp',
            'intbase' => '/stats/new_stats_2012/intbase',
            'lt_drafthw' => '/stats/new_stats_2012/lt_drafthw',
            'draftsoft' => '/stats/new_stats_2012/draftsoft',
            'smpbase' => '/stats/new_stats_2012/smpbase',
            'studio' => '/stats/new_stats_2012/studio',
            'stand' => '/stats/new_stats_2012/stand',
            'prof' => '/stats/new_stats_2012/prof',
            'intpro' => '/stats/new_stats_2012/intpro',
            'free95' => '/stats/new_stats_2012/free95'
		);

		foreach($links as $k => $l)
        {
			if(in_array($k, $filter))
			{
				foreach($links as $k2 => $l2)
				{
					$k2==$k ? $links[$k2] = str_replace('/' . $k, '', $links[$k2]) : $links[$k2] .= '/' . $k;
				}
			}
        }

		return $links;
	}
    
	
	
	
    function get_links_new2011($filter)
	{
		$links = array(
            'hun' => '/stats/new_stats_2011/hun',
            'ita' => '/stats/new_stats_2011/ita',
            'pol' => '/stats/new_stats_2011/pol',
            'eun' => '/stats/new_stats_2011/eun',
            'ger' => '/stats/new_stats_2011/ger',
            'out' => '/stats/new_stats_2011/out',
            'grp' => '/stats/new_stats_2011/grp',
            'temp' => '/stats/new_stats_2011/temp',
            'intbase' => '/stats/new_stats_2011/intbase',
            'lt_drafthw' => '/stats/new_stats_2011/lt_drafthw',
            'draftsoft' => '/stats/new_stats_2011/draftsoft',
            'smpbase' => '/stats/new_stats_2011/smpbase',
            'studio' => '/stats/new_stats_2011/studio',
            'stand' => '/stats/new_stats_2011/stand',
            'prof' => '/stats/new_stats_2011/prof',
            'intpro' => '/stats/new_stats_2011/intpro',
            'free95' => '/stats/new_stats_2011/free95'
		);

		foreach($links as $k => $l)
        {
			if(in_array($k, $filter))
			{
				foreach($links as $k2 => $l2)
				{
					$k2==$k ? $links[$k2] = str_replace('/' . $k, '', $links[$k2]) : $links[$k2] .= '/' . $k;
				}
			}
        }

		return $links;
	}
    
    function get_links_new($filter)
	{
		$links = array(
            'hun' => '/stats/new_stats/hun',
            'ita' => '/stats/new_stats/ita',
            'pol' => '/stats/new_stats/pol',
            'eun' => '/stats/new_stats/eun',
            'ger' => '/stats/new_stats/ger',
            'out' => '/stats/new_stats/out',
            'grp' => '/stats/new_stats/grp',
            'temp' => '/stats/new_stats/temp',
            'intbase' => '/stats/new_stats/intbase',
            'lt_drafthw' => '/stats/new_stats/lt_drafthw',
            'draftsoft' => '/stats/new_stats/draftsoft',
            'smpbase' => '/stats/new_stats/smpbase',
            'studio' => '/stats/new_stats/studio',
            'stand' => '/stats/new_stats/stand',
            'prof' => '/stats/new_stats/prof',
            'intpro' => '/stats/new_stats/intpro',
            'free95' => '/stats/new_stats/free95'
		);

		foreach($links as $k => $l)
        {
			if(in_array($k, $filter))
			{
				foreach($links as $k2 => $l2)
				{
					$k2==$k ? $links[$k2] = str_replace('/' . $k, '', $links[$k2]) : $links[$k2] .= '/' . $k;
				}
			}
        }

		return $links;
	}

	function get_typeFromPwd($pwd)
	{
		if(substr($pwd, 7, 2)>29)
			$typeNames = array('', 'Temporary', 'Interior', 'LT', 'Apprentice Software Key', 'Base', 'Studio', 'Standard', 'Professional', 'Interior Prof');
		else
			$typeNames = array('', 'Temporary', 'Interior', 'LT', 'Draft software key', 'Base', 'Studio', 'Standard', 'Professional', 'Interior Prof');
		
		return $typeNames[substr($pwd, 6, 1)];
	}
	
	function get_imageChart($size, $imgType, $percents, $counts, $allcount, $labels, $alt, $percents2 = false, $allcount_out = false, $counts2 = false)
	{
		$chartStr = '<img src="http://chart.apis.google.com/chart?';
		$chartStr .= 'chs=' . $size;
		$chartStr .= '&amp;chd=t:' . implode(',', $percents);
		
		if($percents2 && $allcount_out)
		{
            $chartStr .= '|' . implode(',', $percents2);
            $chartStr .= '&amp;chdl=Cadline-nal: ' . $allcount . '|Cadline-on kívül: ' . $allcount_out;
		}
		else
		{
            $chartStr .= '&amp;chdl=Cadline-on kívül: ' . $allcount;
		}
		
		$chartStr .= '&amp;chdlp=t';
		$chartStr .= '&amp;chm=';
		
		for($i=0; $i<count($percents); $i++)
		{
			$i!=0 ? $chartStr .= '|' : '';
			$chartStr .= 't' . $percents[$i] . '(' . $counts[$i] . '),000000,0,' . $i . ',10';
		}
		
		if($percents2)
		{
            for($i=0; $i<count($percents2); $i++)
			{
				$chartStr .= '|t' . $percents2[$i] . '(' . $counts2[$i] . '),000000,1,' . $i . ',10';
			}
		}
		
		$chartStr .= '&amp;cht=' . $imgType;
		$chartStr .= '&amp;chbh=a';
		$chartStr .= '&amp;chco=ffa51d,ffdfaf';
		$chartStr .= '&amp;chxt=y';
		$chartStr .= '&amp;chl=' . implode('|', $labels);
		$chartStr .= '"';
		$chartStr .= ' alt="' . $alt . '"';
		$chartStr .= ' class="stats"';
		$chartStr .= ' />';
		
		return $chartStr;
	}
	
	function get_imageChart_line($size, $counts, $months, $allcount, $alt)
	{
		$chartStr = '<img src="http://chart.apis.google.com/chart?';
		$chartStr .= 'chs=' . $size;
		$chartStr .= '&amp;cht=lc';
		$chartStr .= '&amp;chdlp=t';
		$chartStr .= '&amp;chxt=x,y';
		$chartStr .= '&amp;chxl=0:|' . implode('|', $months);
		$chartStr .= '|1:';

		for($i = 0; $i <= 10; $i++)
            $chartStr .= '|' . round(($allcount / 10) * $i);

		$chartStr .= '&amp;chd=t:' . implode(',', $counts);
		$chartStr .= '&amp;chdl=Cadline-on kívül: ' . $allcount;
		$chartStr .= '"';
		$chartStr .= ' alt="' . $alt . '"';
		$chartStr .= ' class="stats"';
		$chartStr .= ' />';

		return $chartStr;
	}
}
?>