Location: PHPKode > projects > phpCAMALEO > common/contents/stat_visitpage.inc
<?php
if(function_exists('stat_visitpage'))	return;

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# version: 19 September 2006
#
function stat_visitpage($from,$to)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
	global $opt_sel_clus, $tot_value; 
	#
	$args="SELECT date, stat_page_page, stat_page_unique, stat_page_reload, stat_page_visitors,

				SUM(g_stat_page.stat_page_unique) AS stat_page_unique,
				SUM(g_stat_page.stat_page_reload) AS stat_page_reload,
				SUM(g_stat_page.stat_page_visitors) AS stat_page_visitors

				FROM g_stat_page
				WHERE g_stat_page.stat_page_skin='".$_SESSION[misc][skin]."' AND g_stat_page.stat_page_date>='$from' AND g_stat_page.stat_page_date<='$to' ";
	#
	switch($opt_sel_clus)
	{
		case 1:	$args=eregi_replace('SELECT date,', 'SELECT SUBSTRING(stat_page_date,1,4),', $args);
				$args.=' GROUP BY SUBSTRING(stat_page_date,1,4), stat_page_page ';
				break;

		case 2:	$args=eregi_replace('SELECT date,', 'SELECT SUBSTRING(stat_page_date,1,7),', $args);
				$args.=' GROUP BY SUBSTRING(stat_page_date,1,7), stat_page_page ';
				break;

		case 3:	$args=eregi_replace('SELECT date,', 'SELECT YEARWEEK(stat_page_date,1),', $args);
				$args.=' GROUP BY YEARWEEK(stat_page_date,1), stat_page_page ';
				break;

		case 4:	$args=eregi_replace('SELECT date,', 'SELECT stat_page_date,', $args);
				$args.=' GROUP BY SUBSTRING(stat_page_date,1,10), stat_page_page ';
				break;

		case 5:	$args=eregi_replace('SELECT date,', 'SELECT SUBSTRING(stat_page_date,1,1),', $args);
				$args.=' GROUP BY SUBSTRING(stat_page_date,1,1), stat_page_page ';
				break;
	}
	#
	switch($_SESSION[sort])
	{
		case SS_P1:	$args.=' ORDER BY stat_page_page ASC, stat_page_date ASC ';	break;# page
		case SS_P2:	$args.=' ORDER BY stat_page_unique DESC ';					break;# unique
		case SS_P3:	$args.=' ORDER BY stat_page_reload DESC ';					break;# reloaded
		case SS_23:	$args.=' ORDER BY stat_page_visitors DESC ';				break;# visits
	}
	$sth=db_query($args);
	#
	if($sth[1]>0)
	{
		$rows=db_fetch($sth[0]); $labels=array(); $table_field=array(); $fields_record=LoadArrayData($rows,$labels,$table_field);
		switch ($opt_sel_clus)
		{
			case 1:	$data_label[0]=_YEAR;
					$data_label[1]=SS_P1;
					$data_label[2]=SS_P2.'@r';
					$data_label[3]=SS_P3.'@r';
					$data_label[4]=SS_23.'@r';
					OrganizeData('',$data_label,$labels,$table_field,$fields_record,'','page');
					$bar=bar_graph(4,$fields_record,$table_field);
					break;

			case 2:	$data_label[0]=_MONTH;
					$data_label[1]=SS_P1;
					$data_label[2]=SS_P2.'@r';
					$data_label[3]=SS_P3.'@r';
					$data_label[4]=SS_23.'@r';
					OrganizeData('',$data_label,$labels,$table_field,$fields_record,'','page');
					$bar=bar_graph(4,$fields_record,$table_field);
					break;

			case 3:	$data_label[0]=_WEEK;
					$data_label[1]=SS_P1;
					$data_label[2]=SS_P2.'@r';
					$data_label[3]=SS_P3.'@r';
					$data_label[4]=SS_23.'@r';
					OrganizeData('W',$data_label,$labels,$table_field,$fields_record,'','page');
					$bar=bar_graph(4,$fields_record,$table_field);
					break;

			case 4:	$data_label[0]=_DAY;
					$data_label[1]=SS_P1;
					$data_label[2]=SS_P2.'@r';
					$data_label[3]=SS_P3.'@r';
					$data_label[4]=SS_23.'@r';
					OrganizeData('',$data_label,$labels,$table_field,$fields_record,'','page');
					$bar=bar_graph(4,$fields_record,$table_field);
					break;

			case 5:	$data_label[0]=_NA;
					$data_label[1]=SS_P1;
					$data_label[2]=SS_P2.'@r';
					$data_label[3]=SS_P3.'@r';
					$data_label[4]=SS_23.'@r';
					OrganizeData('*',$data_label,$labels,$table_field,$fields_record,'','page');
					$bar=bar_graph(4,$fields_record,$table_field);
					break;
		}
		?><br />
		<fieldset class="sstat"><legend class="sstat" align="center">&nbsp;<?=SS_14?>&nbsp;</legend><?php ShowTable($labels,$table_field,$fields_record,'100%','','','H',$bar,'Y'); ?></fieldset>
		<div align="center"><h6><?=SS_19?></h6></div>
		<?php
		return(true);
	}
	else
	{
		?><div align="center"><h3><?=SS_22?></h3></div><?php
		return(false);
	}
}
?>
Return current item: phpCAMALEO