All pastes #943230 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-03-15 01:57 UTC
rendered paste body
<?php
if (!defined('in_tt-admin')) {
	die ("Hacking Attempt!");
}

?>
				<div class="page-block">
					<div class="header">
						<h2>Site Analytics</h2>
					</div>
					<div class="contents">
						<?php
						$result = $db->query("SELECT * FROM `".$config->database['prefix']."browsers` ORDER BY id"); // Query.
						$total = mysql_num_rows($result); // Total rows.
						
						/******************************
						 Browser Statistics
						******************************/
						
						// Define some variables that will do a lot of the math.
						$msie = 0;
						$firefox = 0;
						$opera = 0;
						$other = 0;
						
						// Other string variables
						$msie_string = "MSIE";
						$firefox_string = "Firefox";
						$opera_string = "Opera";
						
						// Here we go ... gotta count up the tally!
						while($user = mysql_fetch_array($result)) {
							$check = strpos($user['agent'], $msie_string);
							if ($check !== false) {
								$msie++;
							} else {
								$check = strpos($user['agent'], $firefox_string);
								if ($check !== false) {
									$firefox++;
								} else {
									$check = strpos($user['agent'], $opera_string);
									if ($check !== false){
										$opera++;
									} else {
										$other++;
									}
								}
							}
						}
						
						// Now we do some tough mathmatical calculations.
						$msiefinal = ceil($msie/$total*100);
						$firefoxfinal = ceil($firefox/$total*100);
						$operafinal = ceil($opera/$total*100);
						$otherfinal = ceil($other/$total*100);
						
						// Now we echo the data!
						echo "<b>".$msiefinal."%</b> of visitors are using Microsoft Internet Explorer 7&nbsp;&nbsp;&nbsp;&nbsp;<i>(".$msie." out of ".$total." visitors)</i><br />";
						echo "<b>".$firefoxfinal."%</b> of visitors are using Mozilla Firefox&nbsp;&nbsp;&nbsp;&nbsp;<i>(".$firefox." out of ".$total." visitors)</i><br />";
						echo "<b>".$operafinal."%</b> of visitors are using Opera&nbsp;&nbsp;&nbsp;&nbsp;<i>(".$opera." out of ".$total." visitors)</i><br />";
						echo "<b>".$otherfinal."%</b> of visitors are using other browsers&nbsp;&nbsp;&nbsp;&nbsp;<i>(".$other." out of ".$total." visitors)</i>";
						
						echo "<br /><br />";
						
						/******************************
						 Operating System Statistics
						******************************/
						// Define some variables that will do a lot of the math.
						$windows = 0;
						$linux = 0;
						$bsd = 0;
						$otheros = 0;
						
						// Other string variables
						$windows_string = "Windows";
						$linux_string = "Linux";
						$bsd_string = "BSD";
						
						// Here we go ... gotta count up the tally!
						while($os = mysql_fetch_array($result)) {
							$check = strpos($os['agent'], $windows_string);
							if ($check !== false) {
								$windows++;
							} else {
								$check = strpos($os['agent'], $linux_string);
								if ($check !== false) {
									$linux++;
								} else {
									$check = strpos($os['agent'], $bsd_string);
									if ($check !== false){
										$bsd++;
									} else {
										$otheros++;
									}
								}
							}
						}
						
						// Now we do some tough mathmatical calculations.
						$windowsfinal = ceil($windows/$total*100);
						$linuxfinal = ceil($linux/$total*100);
						$bsdfinal = ceil($bsd/$total*100);
						$otherosfinal = ceil($otheros/$total*100);
						
						// Now we echo the data!
						echo "<b>".$windowsfinal."%</b> of visitors are using Microsoft Windows&nbsp;&nbsp;&nbsp;&nbsp;<i>(".$windows." out of ".$total." visitors)</i><br />";
						echo "<b>".$linuxfinal."%</b> of visitors are using Linux&nbsp;&nbsp;&nbsp;&nbsp;<i>(".$linux." out of ".$total." visitors)</i><br />";
						echo "<b>".$bsdfinal."%</b> of visitors are using BSD/Unix&nbsp;&nbsp;&nbsp;&nbsp;<i>(".$bsd." out of ".$total." visitors)</i><br />";
						echo "<b>".$otherosfinal."%</b> of visitors are using other operating systems&nbsp;&nbsp;&nbsp;&nbsp;<i>(".$otheros." out of ".$total." visitors)</i>";
						
						
						
						?>
					</div>
				</div>