Lid |
|
Hallo allemaal,
Ik zit met het volgende probleem; ik heb een simpele kijkersteller (waarbij de teller per uur per bezoeker 1x omhoog gaat) gemaakt alleen werkt alleen met 1 video omdat anders de sessions elkaar overscchrijven. Maar dit script is voor meerdere videos bedoeld dus heeft iemand een suggestie hoe ik dit kan realiseren in een niet al te lange tijd?
Scriptje:
<?php session_start(); ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled</title>
</head>
<body>
<?php
require ('query.php');
$time = time();
if($_SESSION['viewed'] == 1) {
if(isset($_SESSION['time'])) {
$diff = $time-$_SESSION['time'];
if($diff >= 3600) {
$views = doquery("SELECT views FROM video WHERE id='1'") + 1;
$new = addquery("UPDATE video SET views='$views' WHERE id='1'");
$count = number_format($views, 0, ',', '.');
print($count);
unset($_SESSION['time']);
$_SESSION['time'] = $time ;
}
else {
$views = doquery("SELECT views FROM video WHERE id='1'");
$count = number_format($views, 0, ',', '.');
print($count);
}
}
else {
$_SESSION['time'] = $time ;
$views = doquery("SELECT views FROM video WHERE id='1'");
$count = number_format($views, 0, ',', '.');
print($count);
}
}
else {
$_SESSION['viewed'] = 1;
$views = doquery("SELECT views FROM video WHERE id='1'") + 1;
$new = addquery("UPDATE video SET views='$views' WHERE id='1'");
$count = number_format($views, 0, ',', '.');
print($count);
}
?>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled</title> </head> <body> <?php require ('query.php'); if($_SESSION['viewed'] == 1) { if(isset($_SESSION['time'])) { $diff = $time-$_SESSION['time']; if($diff >= 3600) { $views = doquery("SELECT views FROM video WHERE id='1'") + 1; $new = addquery("UPDATE video SET views='$views' WHERE id='1'"); unset($_SESSION['time']); $_SESSION['time'] = $time ; } else { $views = doquery("SELECT views FROM video WHERE id='1'"); } } else { $_SESSION['time'] = $time ; $views = doquery("SELECT views FROM video WHERE id='1'"); } } else { $_SESSION['viewed'] = 1; $views = doquery("SELECT views FROM video WHERE id='1'") + 1; $new = addquery("UPDATE video SET views='$views' WHERE id='1'"); } ?> </body> </html>
|