⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stats_view.php

📁 CMS系统 提供学习研究修改最好了 比流行的一些CMS简单 但是更容易理解 是帮助你学习PHPCMS系统的好东东哦
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/** This program is free software; you can redistribute it and/or modify* it under the terms of the GNU General Public License as published by* the Free Software Foundation; either version 2 of the License, or*  (at your option) any later version.** This program is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the* GNU General Public License for more details.** You should have received a copy of the GNU General Public License* along with this program; if not, write to the Free Software* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.*/if(!defined('TOP_DIR')) { define('TOP_DIR','../..'); }ini_set('include_path', TOP_DIR);	// set in include path because in //db_connect.php isn't TOP_DIR used to include adodb.inc.php!include_once(TOP_DIR.'/header.php');include_once(TOP_DIR.'/include/left_menu.class.php');$menu = new LeftMenuView();$menu->generateTableHead();$menu->buildMenu();$menu->generateTableFooter();/** * Select field options */$array_options = Array(	'all' => 'Date range',	'year_this' => 'This Year',	'year_last' => 'Last Year',	'month_this' => 'This Month',	'month_last' => 'Last Month',	'week_this' => 'This Week',	'week_last' => 'Last Week',	'today' => 'Today',	'yesterday' => 'Yesterday',	'custom' => 'Custom');/*** count images global once (needed for image section and others like imagecache)*/$query = $GLOBALS['db']->Execute("SELECT count(id) FROM ".PREFIX."photos");$data = $query->FetchRow();$nr_total_photos = $data[0];$nr_perm_photos = count_pictures();echo "<td class='mainwindow' colspan='2'>";/** * exit  */if(!read_plugins_config('stats') OR !check_permissions('stats')){	exit_if_not_active('stats');}if(!isset($_REQUEST['mode'])){	$_REQUEST['mode'] = 'image';}/** * calculate date string */if(!isset($_REQUEST['date'])){	$_REQUEST['date'] = 'all';}if(!isset($_REQUEST['date_from'])){	$_REQUEST['date_from'] = '';}if(!isset($_REQUEST['date_to'])){	$_REQUEST['date_to'] = '';}/** * Take good care of XSS in all date select fields */if(!array_key_exists($_REQUEST['date'], $array_options)){	die("FATAL: unknown date range selected");}if(strlen($_REQUEST['date_from']) > '0' || strlen($_REQUEST['date_to']) > '0'){	if(!is_valid_date($_REQUEST['date_from']) || 		!is_valid_date($_REQUEST['date_to']))	{		die("FATAL: wrong date format, expecting yyyy:mm:dd...");	}	}if($_REQUEST['date'] == 'all'){	$timestamp_from = '0';	$timestamp_to = '9999999999';}elseif($_REQUEST['date'] == 'custom'){	$from_year = substr($_REQUEST['date_from'],0,4);	$from_month = substr($_REQUEST['date_from'],5,2);	$from_day = substr($_REQUEST['date_from'],8,2);	$to_year = substr($_REQUEST['date_to'],0,4);	$to_month = substr($_REQUEST['date_to'],5,2);	$to_day = substr($_REQUEST['date_to'],8,2);		$timestamp_from = mktime(0,0,0,$from_month,$from_day,$from_year);	$timestamp_to = mktime(23,59,59,$to_month,$to_day,$to_year);}else{	list($timestamp_from,$timestamp_to) = switch_dates($_REQUEST['date']);}/** * set link */$adress_link = TOP_DIR.'/plugins/stats/stats_view.php?date='.$_REQUEST['date'].'&amp;date_from='.$_REQUEST['date_from'].'&amp;date_to='.$_REQUEST['date_to'];/** * show links */echo '<br />';echo '<div align="center">';echo '<a href="'.$adress_link.'&amp;mode=general"><strong>'.$stats_general_info.'</strong></a> || ';echo '<a href="'.$adress_link.'&amp;mode=image"><strong>'.$stats_image_info.'</strong></a> || ';echo '<a href="'.$adress_link.'&amp;mode=user"><strong>'.$stats_user_info.'</strong></a> || ';echo '<a href="'.$adress_link.'&amp;mode=comment"><strong>'.$stats_comments_info.'</strong></a>';echo '</div>';echo '<br />';/* * show date selection */switch($_REQUEST['mode']){case 'general':break; // end case generalcase 'image':case 'user':case 'comment':?><div style="padding-left: 10px;"><form style="margin-bottom: 0px;" name="date_selection" method="GET" action="<?php echo TOP_DIR.'/plugins/stats/stats_view.php'; ?>"><div id="div_selection" style="float: left;"><select name="date" onchange="formupdate();"><?phpforeach($array_options AS $key=>$value){	if(isset($_REQUEST['date']))	{		if($key == $_REQUEST['date'])		{			$selected = ' selected';		}		else		{			$selected = '';		}	}	else	{		$selected = '';	}		echo '<option value="'.$key.'"'.$selected.'>'.$value.'</option>';}?></select></div><div id="div_date" style="float: left; ">&nbsp;&nbsp;<a href="javascript:void(0);" onclick="var loginWin = window.open('<?php echo TOP_DIR; ?>/actions/calender.php?form=date_selection.date_from&amp;additional_cmd=change_custom()','Calender','height=250,width=300,scrollbars=no,menubar=no,status=no');" target="_top"><?php echo $search_from ?></a> <input type='text' onchange="change_custom()" name='date_from' value='<?php echo @$_REQUEST['date_from']; ?>' style='width:80'> / <a href="javascript:void(0);" onclick="var loginWin = window.open('<?php echo TOP_DIR; ?>/actions/calender.php?form=date_selection.date_to&amp;additional_cmd=change_custom()','Calender','height=250,width=250,scrollbars=no,menubar=no,status=no'); " target="_top"><?php echo $search_to ?></a><input type='text' onchange="change_custom()" name='date_to' value='<?php echo @$_REQUEST['date_to']; ?>' style='width:80'></div>&nbsp;&nbsp;<input type='submit' name='btn_submit' value='Set'><input type='hidden' name='mode' value='<?php echo $_REQUEST['mode']; ?>'></form></div><script language="JavaScript" type='text/javascript'><!--function change_custom(){	document.date_selection.date.value = 'custom';}function formupdate(){	switch(document.date_selection.date.value)	{				<?php		foreach($array_options AS $key=>$value)		{			echo 'case "'.$key.'":'."\n";			if($key == 'custom')			{							} elseif($key=='all')			{				echo 'document.date_selection.date_from.value = "";'."\n";				echo 'document.date_selection.date_to.value = "";'."\n";			}			else			{				list($time_from,$time_to) = switch_dates($key);				echo 'document.date_selection.date_from.value = "'.strftime("%Y:%m:%d",$time_from).'";'."\n";				echo 'document.date_selection.date_to.value = "'.strftime("%Y:%m:%d",$time_to).'";'."\n";			}			echo 'break;'."\n";		}		?>	}}//--></script><br /><br /><?phpbreak;} // end switch date selectionswitch($_REQUEST['mode']){case 'general':	/**	 * calculate total of the album and most view album	 */	$i = 0;	$old_wd = getcwd();	chdir(TOP_DIR);		$array_values[$i]['key'] = $stats_over_albums;	$array_values[$i]['value'] = get_all_albums('albums', 0, "albums", 0);	$i++;		$array_values[$i]['key'] = $stats_over_most_alb_visists;	$array_values[$i]['value'] = get_all_albums('albums', 0, "top_visits", 0);	$i++;		chdir($old_wd);	/**	 * calculate total MB of the images	 */	$query = $GLOBALS['db']->Execute("SELECT  filename, prev_path FROM ".PREFIX."photos");	$size = 0;	while($data = $query->FetchRow())	{		$filename = TOP_DIR.'/'.$data[1].'/'.$data[0];		if(file_exists($filename))		{			$size += filesize($filename);		}	}		$array_values[$i]['key'] = $stats_over_space;	$array_values[$i]['value'] = round( $size/1024/1024 , 2 ).' MB';	$i++;		$array_values[$i]['key'] = $stats_over_visitors;	$array_values[$i]['value'] = read_config('users');	$i++;		?>	<div align="center">	<table class='admintable' cellspacing="0">	<th class='maintable' colspan='2'><?php echo $href_stats; ?></th>	<?php	foreach($array_values AS $entry)	{		?>		<tr>			<td class='admintable'><?php echo $entry['key']; ?></td>			<td class='admintable'><?php echo $entry['value']; ?></td>		</tr>		<?php	}	/**	 * cache info	 */	if(read_plugins_config('cache'))	{		include_once(TOP_DIR.'/plugins/cache/func.cache.php');		if(!isset($nr_total_photos)): $nr_total_photos="0"; endif;		show_cache_stats($nr_total_photos);	}	?>	</div>	</table>	<?phpbreak; // end case generalcase 'image':		/**	 * total image views	 */	$query = $GLOBALS['db']->Execute("SELECT count(id) FROM ".PREFIX."stats WHERE type='view'");	$data = $query->FetchRow();	$nr_total_views = $data[0];	/**	 * total image downloads	 */	$query = $GLOBALS['db']->Execute("SELECT count(id) FROM ".PREFIX."stats WHERE type='download'");	$data = $query->FetchRow();	$nr_total_downloads = $data[0];		/**	 * set query for image views	 */	unset($query);		/**	 * trying to fix this error:	 * mysql error: [1104: The SELECT would examine more than MAX_JOIN_SIZErows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SETSQL_MAX_JOIN_SIZE=# if the SELECT is okay] in EXECUTE("SELECTlinpha_stats.md5sum, count(linpha_stats.id) AS nr_count,max(linpha_stats.stats_time) AS max_time FROM linpha_photos,linpha_first_lev_album, linpha_stats WHERE linpha_photos.prev_path LIKECONCAT(linpha_first_lev_album.path,'%') AND 1=1 AND(linpha_photos.md5sum=linpha_stats.md5sum AND linpha_stats.type = 'view'AND linpha_stats.stats_time >= '0' AND linpha_stats.stats_time <='9999999999' ) GROUP by linpha_stats.md5sum ORDER by nr_count DESC LIMIT0,10") 	--> works on sf.net!!	 */	if(DB_TYPE == "mysql")	{		$GLOBALS['db']->Execute("SET SQL_BIG_SELECTS=1");	}		$sql = sql_query_str(		Array(			PREFIX.'stats.md5sum',			'count('.PREFIX.'stats.id) AS nr_count',			'max('.PREFIX.'stats.stats_time) AS max_time'		),		P.".md5sum=".PREFIX."stats.md5sum ".    	"AND ".PREFIX."stats.type = 'view' ".    	"AND ".PREFIX."stats.stats_time >= '".$timestamp_from."' ".    	"AND ".PREFIX."stats.stats_time <= '".$timestamp_to."' "    	//"AND ".PREFIX."stats.type = 'view'"    	,       	'nr_count DESC, max_time DESC',    	Array("stats"),    	PREFIX.'stats.md5sum'    	);	$query[1] = $GLOBALS['db']->SelectLimit($sql, 10, 0);	/*$query[1] = $GLOBALS['db']->SelectLimit("SELECT md5sum, count(id) AS nr_count, max(stats_time) AS max_time \n" .			"FROM ".PREFIX."stats"."\n" .			"WHERE type = 'view'"."\n" .			"AND stats_time >= '".$timestamp_from."'"."\n".			"AND stats_time <= '".$timestamp_to."'"."\n".			"GROUP by md5sum"."\n" .			"ORDER by nr_count DESC", 10, 0);*/	$nr_selected_views = $query[1]->RecordCount();		/**	 * set query for image downloads	 */	$sql = sql_query_str(		Array(			PREFIX.'stats.md5sum',			'count('.PREFIX.'stats.id) AS nr_count',			'max('.PREFIX.'stats.stats_time) AS max_time'		),		P.".md5sum=".PREFIX."stats.md5sum ".    	"AND ".PREFIX."stats.type = 'download' ".    	"AND ".PREFIX."stats.stats_time >= '".$timestamp_from."' ".    	"AND ".PREFIX."stats.stats_time <= '".$timestamp_to."' "    	//"AND ".PREFIX."stats.type = 'view'"    	,       	'nr_count DESC, max_time DESC',    	Array("stats"),    	PREFIX.'stats.md5sum'    	);	$query[2] = $GLOBALS['db']->SelectLimit($sql, 10, 0);		/*$query[2] = $GLOBALS['db']->SelectLimit("SELECT md5sum, count(id) AS nr_count, max(stats_time) AS max_time \n" .			"FROM ".PREFIX."stats"."\n" .			"WHERE type = 'download'"."\n" .			"AND stats_time >= '".$timestamp_from."'"."\n".			"AND stats_time <= '".$timestamp_to."'"."\n".			"GROUP by md5sum"."\n" .			"ORDER by nr_count DESC", 10, 0);*/	$nr_selected_downloads = $query[2]->RecordCount();	?>	<div style="padding-left: 10px; ">	<strong><?php echo $stats_total_images.":"; ?></strong>		&nbsp;<?php echo $nr_perm_photos; ?><br />	<strong><?php echo $stats_total_img_views.":"; ?></strong>		&nbsp;<?php echo $nr_total_views; ?><br />	<strong><?php echo $stats_total_img_downs.":"; ?></strong>		&nbsp;<?php echo $nr_total_downloads; ?><br />	<strong><?php echo $stats_total_img_selected.":"; ?></strong>		&nbsp;<?php echo $nr_selected_views; ?><br />	<strong><?php echo $stats_total_downs_selected.":"; ?></strong>		&nbsp;<?php echo $nr_selected_downloads; ?><br />	</div>	<br />	<div align="center" >	<table class='admintable' width='95%' border="0">		<tr>			<th class='maintable'><?php echo $stats_rank; ?></th>			<th class='maintable'><?php echo $stats_top_ten; ?></th>			<th class='maintable'><?php echo $stats_head_downs; ?></th>		</tr>	<?php	for($i = 1; $i <= 10; $i++)	{		?>		<tr>			<td align="center" class='admintable'><?php echo $i; ?>.</td>			<?php			for($n = 1; $n <= 2; $n++)			{				echo '<td class="admintable">';				$data = $query[$n]->FetchRow();				if(isset($data) && is_array($data))				{					$query_id = $GLOBALS['db']->Execute("SELECT id, prev_path " .							"FROM ".PREFIX."photos " .							"WHERE md5sum = '".$data[0]."'");					$data_id = $query_id->FetchRow();					?>					<div style="float:left; padding-left:2px;"> 					<?php					print_thumbnail($data_id['id']);					?>					</div>					<span style="padding-top: 5px; padding-left: 3px;">					<?php					($n==2) ? $stats_info = $no_downloads.":": $stats_info = $stats_no_views;					echo $stats_info.' '.$data['nr_count'].'<br />&nbsp;';					echo $thumb_order_date.': '.linpha_strftime('',$data['max_time']).'<br />';								        $stage = get_stage_from_prev_path($data_id['prev_path']);	    			$albid = get_albid($data_id['prev_path'],$stage);	    			build_navigation_view($stage,$albid,$data_id['id']);	    			echo '<br />&nbsp;';	    			print_resized_view($data_id['id'], 0, 0, $i.$n);					?>					</span>					<?php				}				else				{					echo '&nbsp;';				}					unset($data);				echo '</td>';			}				?>		</tr>		<?php	}	?>	</table>	</div>	<?phpbreak; // end case imagecase 'user':	/**	 * get all users	 */	$query = $GLOBALS['db']->Execute("SELECT id, nickname FROM ".PREFIX."users");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -