Hello,
Have you noticed that video views are not incremented on a per IP view basis? Well, that might be an undesired functionality for some out there. Today I will show you how to increment these views by unique IP hits. Tested under v2.6, yet should work on the whole v2 branch and possibly <v2.0 (Share your results).
First let’s create our new table that will store all the IPs that have watched a video.
1. Open phpMyAdmin or any DB Manager
2. Execute the following query to create the table. If you change the table prefix “cb_” during installation, please also change it in the query (tblprefix_unique_views):
CREATE TABLE IF NOT EXISTS `cb_unique_views` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `ip` varchar(200) NOT NULL, `videoid` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
3. Open ./includes/functions.php
4. Find:
case 'v': case 'video': default: { if(!isset($_COOKIE['video_'.$id])){ $db->update(tbl("video"),array("views","last_viewed"),array("|f|views+1",NOW())," videoid='$id' OR videokey='$id'"); setcookie('video_'.$id,'watched',time()+3600); }
and replace it with:
case 'v': case 'video': default: { $count = $db->count(tbl('unique_views'),"*","videoid='{$id}' AND ip='{$_SERVER['REMOTE_ADDR']}'"); if(!$count) { $db->insert(tbl('unique_views'),array('ip','videoid'),array($_SERVER['REMOTE_ADDR'],$id))); $db->update(tbl("video"),array("views","last_viewed"),array("|f|views+1",NOW())," videoid='$id' OR videokey='$id'"); }
5. Save and Upload.
That’s it, it should be working now! If for any reason it doesn’t or you get stuck at any step, please do not hesitate to contact me so I can personally assist you. Any question, comment or suggestion is greatly appreciated.
Best Regards,
Richi
default:
{
Looking for quality ClipBucket Hosting? Look no further than Arvixe Web Hosting!
Hi Richi,
Great info, It’s working on watch video but how about on the editor pick on the homepage. Clip-bucket said the can’t do anything about it, do you know how to fix it. Thank you so much.
Hello,
I can think of adding that code to update the DB every time the page loads, but what if they don’t really click the play button of the Editor’s Pick player? Do the Editor’s Pick videos autostart on your website?
Regards,
Richi
Hi,
I don’t have autostart on my website. I would like increase the video view without leave the homepage on the Editor’s Pick. Thanks
Luiggy