Update Video Views by Unique IP Hits in Clip-Bucket v2.6


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`)

3. Open ./includes/functions.php

4. Find:

case 'v':
			case 'video':
					$db->update(tbl("video"),array("views","last_viewed"),array("|f|views+1",NOW())," videoid='$id' OR videokey='$id'");

and replace it with:

case 'v':
			case 'video':
			$count = $db->count(tbl('unique_views'),"*","videoid='{$id}' AND ip='{$_SERVER['REMOTE_ADDR']}'");
			if(!$count) {
				$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,


Looking for quality ClipBucket Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , , , , , , , , | Posted under ClipBucket | RSS 2.0

Author Spotlight

Richi González

I started programming when I was 12. I'm a Developer and have been working with the Clip-Bucket script since it came out. I'm the Liaison between Arvixe and Clip-Bucket, so anything you need regarding Clip-Bucket or any particular computer-related subject you need, let me know so I can assist you.

3 Comments on Update Video Views by Unique IP Hits in Clip-Bucket v2.6

  1. luiggy says:

    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?


      • Luiggy says:

        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


Leave a Reply

Your email address will not be published. Required fields are marked *