Pop Ups via mijn site !

Status
Niet open voor verdere reacties.
Wat voor counter is het dan? Gaat het alleen om dat 'Je bent bezoeker X' scriptje? :/

Want dat is toch een scriptje van 3 regels, of vergis ik me nu? :P
 
Nee Frats, die is van mijzelf.
Met Webstats kon ik ook statisieken bijhouden maar goed ik heb er overheen gelezen dus. Stom van mij !!
Hoe dan ook, ik ben er vanaf in ieder geval.
Iedereen bedankt.
 
Deze code heb ik nu in gebruik:
Stats.php
Code:
<strong><br />
			  <?php
 ob_start();

 error_reporting(E_ALL);

 include("config.php");

 mysql_connect($conf['MysqlHost'], $conf['MysqlUser'], $conf['MysqlPass']);
 mysql_select_db($conf['MysqlDb']);
?>
<html>

<head>
<title>Statistieken :: <?php echo $conf['Titel']; ?></title>
<style>
body, td { font-family: Verdana; font-size: x-small; }
</style>
</head>

<body>

<center>
<?php
 if($conf['Totaal']) {
  $query = mysql_query("SELECT * FROM stats GROUP BY ip") or die(mysql_error());
  $uhits = mysql_num_rows($query);

  $hits = mysql_result(mysql_query("SELECT sum(hits) as total FROM stats"), 0, "total");

  $query = mysql_query("SELECT * FROM stats GROUP BY datum") or die(mysql_error());
  $delen = mysql_num_rows($query);

  $total = $uhits + $hits;

  $bar1 = round($hits / $total * 100);
  $bar2 = round($uhits / $total * 100);
?>
<table border="0" cellpadding="5" cellspacing="0" width="100%" style="border: 1px solid #DDDDDD;">
 <tr>
  <td colspan="2" style="border-bottom: 1px dashed #DDDDDD;" bgcolor="#EFEFEF"><b>Totaal</b></td>
 </tr>
 <tr>
  <td width="140">Hits: (<?php echo $hits; ?>)</td>
  <td><img src="bar_line.gif" width="1" height="15"><img src="bar_line.gif" width="1" height="15"><img src="bar_line.gif" width="1" height="15"></td>
 </tr>
 <tr>
  <td width="140" bgcolor="#EFEFEF">Unieke hits: (<?php echo $uhits; ?>)</td>
  <td bgcolor="#EFEFEF"><img src="bar_line.gif" width="1" height="15"><img src="bar_line.gif" width="1" height="15"><img src="bar_line.gif" width="1" height="15"></td>
 </tr>
</table>
<br>
<?php
 }

 $select1 = mysql_query("SELECT * FROM stats GROUP BY datum ORDER BY datum DESC LIMIT 0,".$conf['Limit']) or die (mysql_error());

 while($get = mysql_fetch_object($select1)) {
  $select = mysql_query("SELECT * FROM stats WHERE datum = '".$get->datum."'") or die (mysql_error());
  $uhits = mysql_num_rows($select);

  $hits = mysql_result(mysql_query("SELECT sum(hits) as total FROM stats WHERE datum = '".$get->datum."'"), 0, "total");

  $total = $uhits + $hits;

  $bar1 = $hits / $total * 100;
  $bar2 = $uhits / $total * 100;

  $date = explode("-", $get->datum);
?>
<table border="0" cellpadding="5" cellspacing="0" width="100%" style="border: 1px solid #DDDDDD;">
 <tr>
  <td colspan="2" style="border-bottom: 1px dashed #DDDDDD;" bgcolor="#EFEFEF"><b><?php echo $date[2]."-".$date[1]."-".$date[0]; ?></b></td>
 </tr>
 <tr>
  <td width="140">Hits: (<?php echo $hits; ?>)</td>
  <td><img src="bar_line.gif" width="1" height="15"><img src="bar_line.gif" width="1" height="15"><img src="bar_line.gif" width="1" height="15"></td>
 </tr>
 <tr>
  <td width="140" bgcolor="#EFEFEF">Unieke hits: (<?php echo $uhits; ?>)</td>
  <td bgcolor="#EFEFEF"><img src="bar_line.gif" width="1" height="15"><img src="bar_line.gif" width="1" height="15"><img src="bar_line.gif" width="1" height="15"></td>
 </tr>
</table>
<br>
<?php
 }
?>
dit plaats je in de index.php
Code:
<?php
 include("config.php");

 mysql_connect($conf['MysqlHost'], $conf['MysqlUser'], $conf['MysqlPass']);
 mysql_select_db($conf['MysqlDb']);

 $query = mysql_query("SELECT * FROM stats WHERE ip = '".$_SERVER['REMOTE_ADDR']."' AND datum = '".date("Y-m-d")."'") or die(mysql_error());
 $count = mysql_num_rows($query);

 if($count == 0) {
  $query = "INSERT INTO stats (ip, datum, hits) VALUES ('".$_SERVER['REMOTE_ADDR']."', '".date("Y-m-d")."', '1')";
 } else {
  $obj = mysql_fetch_object($query);
  $hits = $obj->hits + 1;
  $query = "UPDATE stats SET hits = '".$hits."' WHERE ip = '".$_SERVER['REMOTE_ADDR']."' AND datum = '".date("Y-m-d")."'";
 }

 mysql_query($query) or die(mysql_error());
?>

config.php
Code:
<?php
 $conf['MysqlHost'] = "localhost"; // Mysql host (meestal localhost)
 $conf['MysqlUser'] = "***"; // Mysql gebruiker
 $conf['MysqlPass'] = "***"; // Mysql wachtwoord
 $conf['MysqlDb'] = "***"; // Mysql database

 ###########################################

 $conf['Titel'] = "SiteTile.nl"; // Titel van je site
 $conf['Totaal'] = TRUE; // TRUE als hij het totaal moet laten zien en FALSE als dat niet moet
 $conf['Limit'] = 30; // Van hoeveel dagen moet hij de statistieken laten zien
?>

MySQL
Code:
CREATE TABLE `stats` (
  `ip` varchar(20) NOT NULL DEFAULT '',
  `datum` date NOT NULL DEFAULT '0000-00-00',
  `hits` int(10) NOT NULL DEFAULT '1'
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
Voorbeeld:
http://www.opensourceweb.nl/stats.php
De counter staat op http://www.opensourceweb.nl/
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan