Whilst collaborating with CrazyElk on their game to include the Video feature Crazyelk wanted it so when Videos where viewed they didnt continuously count up when same user viewed same video so 1 view 1 count per user makes sense...
I was going to add this to the database so when a user views that video their ID is stored so the count wont continue to rise However it dawned on me why not just use a TXT file with the user details of any video they watch the video ID is placed into the TXT file
so heres how I did this...
<?PHP
$_GET['view'] = array_key_exists('view', $_GET) && in_array($_GET['view'], ['videoID', 'uid', 'artist', 'tracktitle', 'genre', 'videourl', 'thumbs', 'playerswflink', 'switch', 'allowaccess', 'width', 'height', 'autostart']) ? $_GET['view'] : 'videoID';
// Increment the views
if (isset($_GET['id'])) {
$videoID = $_GET['id'];
$path = "videovotes/views/" . $User->id . "/";
mkdir($path, 0777, true);
/* end the txt data */
if ( file_exists("videovotes/views/" . $User->id . "/$videoID.txt") ) {
}
else {
if ( file_exists("videovotes/views/" . $User->id . "/$videoID.txt") ) {
}
$omit = fopen("videovotes/views/" . $User->id . "/$videoID.txt", "w");
fwrite($omit, "
");
fclose($omit);
$DBO->query("UPDATE `user_videos` SET views = views + 1 WHERE videoID = '$videoID'");
}
}
The script above adds a folder to the videovotes/views/ folder for the user whos watching a video when a video is watched it leaves a TXT file behind with the video ID on it so if the user views the video again it will track the folder for the user and if the Video is there it wont update the Views..
Ive used the same method for LIKES and DISLIKES of a video you can also use the same method to ban videos example below for ban and unban
<?PHP
if ($_GET['b'] == 'ban') {
if ( file_exists("videovotes/banned/".$VideoID->id.".txt") ) {
}
$omit = fopen("videovotes/banned/$videoID.txt", "w");
chmod("videovotes/banned/$videoID.txt", 0755);
fwrite($omit, "<?php
echo'<center>BANNED '".$VideoID->tracktitle."' {$row['tracktitle']} $tracktitle $videoID</center>';
?>");
fclose($omit);
}
if ($_GET['u'] == 'unban') {
$path = $_SERVER['DOCUMENT_ROOT'].'/videovotes/banned/"'.$videoID.'".txt';
unlink($path);
unlink('videovotes/banned/"'.$videoID.'".txt');
}
Hope this helps someone in someway...