The following is a guide to install the script dependancies CentOS 6 and 7. This will install all required dependancies - so ffmpeg, mp4box, yamdi, x264, imagemagick and youtube-dl. It does not install ioncube, apache, php, mysql, memcached, pecl-memcache, nor any php extensions as the installation process of these is system dependent.

The following must be run as root.

yum -y install epel-release
yum -y update
yum -y install mesa-libGL-devel mesa-libGLU-devel libXi-devel libXmu-devel freeglut-devel SDL-devel alsa-lib-devel freetype-devel giflib gsm gsm-devel imlib2 imlib2-devel libICE-devel libSM-devel libX11-devel libXau-devel libXdmcp-devel libXext-devel libXrandr-devel libXrender-devel libXt-devel libid3tag libogg-devel libvorbis-devel mesa-libGL-devel mesa-libGLU-devel xorg-x11-proto-devel zlib-devel libtheora libtheora-devel glibc gcc gcc-c++ autoconf automake libtool subversion ncurses-devel libdc1394 libdc1394-devel yasm nasm curl libjpeg-turbo-devel
## EOF ##

cd ~
tar -xvf ffmpeg-release-64bit-static.tar.xz
cd ffmpeg-3.1.2-64bit-static/
cp ff* /usr/bin/
cp ff* /usr/local/bin/
cp qt-faststart /usr/bin/
cp qt-faststart /usr/local/bin/
## EOF ##

yum localinstall --nogpgcheck
yum -y install gpac

sudo yum localinstall --nogpgcheck
yum -y install gpac
## EOF ##

cd ~
tar -xzvf ImageMagick.tar.gz
cd ImageMagick-7.0.2-9
./configure && make && make install
## EOF ##

curl -L -o /usr/local/bin/youtube-dl
chmod a+rx /usr/local/bin/youtube-dl
## EOF ##

We recommend setting the following php.ini variables as general security settings on all servers. These are not specific to any mechbunny software, but rather general security guidelines.

disable_functions = eval,exec,passthru,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source,phpinfo
display_errors = off
expose_php = off

In httpd.conf (on apache):

- TraceEnable Off
- Install and enabled mod_security

1) Upload all script files to target directory
2) Chmod the following directories to 777 *recursively* (so the directories and everything contained within them)
3) Import provided database structure to your database via ssh or phpmyadmin (schema.sql)
4) Open admin/config.php in your favorite code editor (we recommend notepad++, please avoid using notepad, wordpad, ms word and so forth as they may add strange characters to the files cause parse errors in php)
In there, you must edit the following variables with your server information:
$dbserver = ''; //your mysql database server ip or hostname
$dbname = ''; //your mysql database name
$dbuser = ''; //your mysql database username
$dbpass = ''; //your mysql database password
$licenseKey = ""; //license key for the domain you are working on, provided by support
$admin_username = ''; //admin area username
$admin_password = ''; //admin area password
$sitename = ''; //The name of your website as it appears on the title tag on the front end
$basepath = '/full/linux/path'; //base absolute linux path to your installation, no trailing slash
$mediadomain = ''; //base url where media is located, no trailing slash

There are other variables here, but it is unlikely you will need to edit them.

The following dependencies must be met for the tube script to run properly:

- PHP 5.6 - 7.4 (highest available as of the date of this article) installed as DSO or PHP-FPM. Do not install as FastCGI.
- Ioncube loader, newest version available (make sure it is installed into both PHP running on HTTP and PHP running on CLI. Some systems have separate php.ini files for each of these)
- php-mbstring
- php-mysqli
- php-xml
- FFMPEG with x264 support 
- ImageMagick with jpg/png support
- MP4Box (part of GPAC)
- Apache or NGINX
- MySQL 5.6.14 or higher is recommended (or equivalent Percona/MariaDB)
- Youtube-dl (required for tube scraper to work)
- Jpegoptim (recommended, optimizes thumbnails)

- short_open_tag = On
- Disable open_basedir (or make sure all above dependancy locations are listed in it)
- allow_url_fopen = On
- Make sure shell_exec is not on disabled functions list

A guide to install the dependancies under CentOS is available here:

This guide may also assist in installing under Ubuntu/Debian.

Please make sure that the .htaccess file is in place in the root of your domain (sometimes your ftp client might not upload this file).

If it is there and hasn't been tampered with, please have your host make sure that "AllowOverrides All" is set in your apache config file.

To setup ccbill user management, you must do the following after logging into the CCBill merchant admin.

1) Select Account Info->Subaccount Admin from top navigation.

2) Select Subaccount of site in question

3) Select User Management

4) User Management URL should be (or whatever you renamed this to) You must use the end url, so if you are redirecting www to no www, you must enter no-www because a 301 or 302 redirect breaks the postback.
5) Encryption type None. 

Approval Post URL and Denial Post URL should be blank under “Advanced” in the left column

Please be sure to enable ccbill postback in the tube script admin area settings under paysite settings as well.

1) Upload all script files to target directory
2) Chmod the following directories to 777 *recursively* (so the directories and everything contained within them)
3) Import provided database structure to your database via ssh or phpmyadmin (schema.sql)
4) Open admin/config.php in your favorite code editor (we recommend notepad++, please avoid using notepad, wordpad, ms word and so forth as they may add strange characters to the files cause parse errors in php)
In there, you must edit the following variables with your server information:
$dbserver = ''; //your mysql database server ip or hostname
$dbname = ''; //your mysql database name
$dbuser = ''; //your mysql database username
$dbpass = ''; //your mysql database password
$licenseKey = ""; //license key for the domain you are working on, provided by support
$admin_username = ''; //admin area username
$admin_password = ''; //admin area password
$sitename = ''; //The name of your website as it appears on the title tag on the front end
$basepath = '/full/linux/path'; //base absolute linux path to your installation, no trailing slash
$mediadomain = ''; //base url where media is located, no trailing slash

If you want automated screenshots to work, you must install google chrome onto your server. You do not need to install xfree86 or any other window manager, just 'google chrome' as in the browser. We use it's CLI functionality to generate screenshots.

We provide updates to the script free of charge, and always provide an update procedure. You can learn about updates in your admin area's homepage in the news box.

If you want us to perform an update for you, we charge for the labour. The exact cost is dependant on what version you have and the scope of the update in question.

To add a watermark to your actual video files, please add the following to your ffmpeg command lines for desktop and mobile.

Top left
-vf "movie=/full/linux/path/to/watermark.png [watermark]; [in][watermark] overlay=10:10 [out]"

Top right
vf "movie=/full/linux/path/to/watermark.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:10 [out]"

Bottom left
-vf "movie=/full/linux/path/to/watermark.png [watermark]; [in][watermark] overlay=10:main_h-overlay_h-10 [out]"

Bottom right
-vf "movie=/full/linux/path/to/watermark.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:main_h-overlay_h-10 [out]"

-vf "movie=/full/linux/path/to/watermark.png [watermark]; [in][watermark] overlay=main_w/2-overlay_w/2:main_h/2-overlay_h/2 [out]"

watermark.png should be a transparent PNG file with your site's logo.

If you load your website and see "error 28 from storage engine", it means your server has run out of disk space on the partition that mysql stores it's databases on. Please contact your host regarding this issue, not us, as we cannot do anything about it.

Please use the following static version of FFMPEG on your server. It has all dependancies already compiled in it.

For version 4 and version 5 of the script, please set the following


$ffmpeg_command = "-acodec aac -keyint_min 20 -vcodec libx264 -crf 20 -b 1500k -bt 1500k -y -v 0 -bf 16 -threads 0";


$ffmpeg_mobile_command = "-acodec aac -keyint_min 20 -vcodec libx264 -crf 20 -b 800k -bt 800k -y -v 0 -bf 16 -threads 0";

For version 6 of the script, ffmpeg command line is located inside admin area settings page, Please set the following:


-acodec aac -keyint_min 20 -vcodec libx264 -crf 20 -b 1500k -bt 1500k -y -v 0 -bf 16 -threads 0


-acodec aac -keyint_min 20 -vcodec libx264 -crf 20 -b 800k -bt 800k -y -v 0 -bf 16 -threads 0

- You can select the 'main thumbnail' for a video by clicking the thumb in existing content or publish queue.
- Make sure imagemagick's mogrify command is installed into /usr/bin/mogrify or /usr/local/bin/mogrify. It will vastly improve the thumbnail quality!
- Keep an eye out for updates in the news box in the admin area. Due to the unencoded nature of the script, we cannot automatically push updates to you.

You can do this in your admin area by going to content -> existing content and submitting the form with the filters. Once you find the video you are looking for, click the magnifying glass to edit it.

You can quickly edit the main thumbnail for a video by clicking the thumb in publish queue or existing content.

You can view the log file for the encoder by going to Encoder -> Encoder Log
Please use the support ticket system located at

The video pages are made up of 3 templates.


You can enable the mobile version of your site by setting the following two variables to true in admin/config.php:

$encodeMobile = true; //encode mobile videos
$enableMobile = true; //enable mobile version


You can also view your mobile site on a pc by appending ?mobileDevice=true to the end of your url:

The tradepulse documentation states that you must put the following code in your <head> tag:

<?php virtual("/tp/ssi_in.php")?>


This, however, will cause a php error in the case of the tube script. The tradepulse code will often throw a php error about gzip compression and give you a blank white page on pages such as login, signup etc.

There are two workarounds available.

1) You can disable mod_gzip in apache and any compress/gzip/etc stuff in php.ini, restart apache and the above code will work.
2) You can use the following code in your <head> tag in template.overall_header.php instead:

if($thisfile == 'index') {

In addition to adding this code, you must also make your video page links run through tradepulse. This is accomplished by doing the following (example using default template):

BOF template.content_item.php:

$bad = array('?','!',' ','&','*','$','#','@');
$good = array('','','-','','','','','');
$link = "$basehttp/videos/".strtolower(str_replace($bad,$good,$row[title]))."-".$row[record_num].".html";
$dirname = str_replace('.flv','',$row[orig_filename]);
$subdir = $row[filename][0].'/'.$row[filename][1].'/'.$row[filename][2].'/'.$row[filename][3].'/'.$row[filename][4].'/';
$dirname = $subdir.$dirname;
$uniq = uniqid();

                <div class="content">
                         <? if($row[embed]) { ?>
        <a href="/tp/out.php?p=60&url=<? echo $link; ?>" target="_self"><img  class="img" src="<? echo $thumb_url; ?>/embedded/<? echo $row[record_num]; ?>.jpg" alt="<? echo $row[title]; ?>" height="<? echo $thumbheight; ?>" width="<? echo $thumbwidth; ?>" border=0 /></a>
    <? } else { ?>
        <script type='text/javascript'>stat['<? echo $uniq; ?>']=0; pic['<? echo $uniq; ?>']=new Array(); pics['<? echo $uniq; ?>']=new Array(1,1,1,1,1,1,1,1,1,1);</script>
        <a href="/tp/out.php?p=60&url=<? echo $link; ?>" target="_self"><img src="<? echo $thumb_url; ?>/<? echo $dirname; ?>/<? echo $row[orig_filename]; ?>-<? echo $row[main_thumb]; ?>.jpg" alt="<? echo htmlentities($row[title]); ?>" name="<? echo $uniq; ?>" id='<? echo $uniq; ?>' onmouseover='startm("<? echo $uniq; ?>","<? echo $thumb_url; ?>/<? echo $dirname; ?>/<? echo $row[orig_filename]; ?>-",".jpg");' onmouseout='endm("<? echo $uniq; ?>"); this.src="<? echo $thumb_url; ?>/<? echo $dirname; ?>/<? echo $row[orig_filename]; ?>-<? echo $row[main_thumb]; ?>.jpg";' class="img" height="<? echo $thumbheight; ?>" width="<? echo $thumbwidth; ?>" border=0 /></a>
        <? } ?>

                        <div class="vtitle">
                        <a href="<? echo $link; ?>"><?  echo truncate($row[title],15);   ?></a>
                        <!-- class="vtitle" --></div>

                        <div class="rating"><div class="star_off"><div class="star_on" style="width:<? echo ceil($row[rating]*10); ?>px"></div></div></div>
                        <div class="time"><b><? echo sec2time($row[length]); ?></b></div>
                        <div class="date"><b><? echo datediff('',$row[encoded_date],date('Y-m-d H:i:s'),false); ?></b> ago</div>
                        <div class="views"><b><? echo $row[views]; ?></b> views</div>

                        <div class="clear"></div>
                <!-- class="content" --></div>



As you can see from the above example, we've add the following code before <? echo $link; ?> in the html: /tp/out.php?p=60&url=

Please notice that we have only installed the code on the thumbnail's <a> tag, and not the text link. You can of course run the text link through tradepulse as well, but for SEO reasons we recommend leaving the text link as a direct link without tradepulse (the vast majority of users click the thumbnail)

Homepage ads are inserted on the templates directly. The homepage is typically made up of 4 templates:

template.content_item.php (repeating thumbnail)

These 4 templates control all the pages on the script that thumbnails are displayed on such as the homepage, most recent, most viewed, top rated, and so forth.

To make mechbunny login users automatically (when installing behind strongbox), you must apply the following code changes:

Place this code in admin/functions.custom.php (on older versions place it in admin/db.php near the top after the mysql_connect() part):

if(!$_SESSION[userid]) {
    $thisUser = mysql_real_escape_string($_SERVER[PHP_AUTH_USER]);
    $checkUser = mysql_query("SELECT * FROM users WHERE username = '$thisUser'");
    if(mysql_num_rows($checkUser) > 0) {
        $checkRow = mysql_fetch_array($checkUser);
        $_SESSION[userid] = $checkRow[record_num];
        $_SESSION[username] = $checkRow[username];
    else {
        mysql_query("INSERT INTO users (username, password) VALUES ('$thisUser','asdfasdf')");
        $_SESSION[userid] = mysql_insert_id();
        $_SESSION[username] = $thisUser;

Configuration parameters to work with strongbox (admin/config.php):

$basehttp = ''; //base http path
$mediadomain = '/media'; //lighttpd install domain, usually
$thumb_url = $mediadomain.'/thumbs'; //url to $thumb_path
$video_url = $mediadomain.'/videos'; //url to $flv_path
$ad_url = $mediadomain.'/ads'; //url to $flv_path
$misc_url = $mediadomain.'/misc'; //url to $misc_path
$gallery_url = $mediadomain.'/galleries'; //url to $gallery_path

There are three ways to add photos to the script:
1) User Upload: All photos uploaded by users will end up in the approval queue.
2) Ftp Import: You can upload photo galleries to the ftp_photos/ directory. Each gallery should be in its own directory with no subdirectories, and nothing in there except jpeg files.
3) FHG Scraper: Using this tool (under the content tab), you can add hosted galleries to the system. The script will download the images off of these hosted galleries to the ftp_photos directory, where you can run ftp import and add them to the script.
There are several ways to add content to the script:
1) User Upload: If user uploading is enabled, anyone who is logged in can visit the upload.php page on the front end of the site. After entering a title, description, and keywords for the video, they are sent to a second page which has an upload widget with progress bar. User uploaded videos are sent the approval queue.
2) FTP Import: You can upload any type of video file (as long as the server has a codec for it) into the "ftp_content" directory on your server. The files should be put right in the root directory, and not in any folders. After uploading, please select "Content->FTP Import" from menu, and follow the instructions given in that file. After import, your files will be sent to the approval queue where you can enter titles, descriptions, etc.
3) CSV: This is used when importing videos from a sponsor. Most sponsors now provide such dump lists. For more detailed information on how to perform a dump import, please select "Content->CSV Import" from the menu. Embedded videos are placed directly in the publish queue, and do not go through the whole encoding process.
4) Hosted/Hotlinked: If you would like to add a single video that is being hosted on another server (for instance, a sponsor or another tube site), you can do so by selecting "Content->Add Hosted/Hotlinked". Please note that this is only used if you have the URL to the media file itself, and it is being hosted on HTTP (RTMP hosted video files cannot be imported).
5) XML Feeds: You can add sponsor xml feeds (running the standard tube xml format) to the script, and it will automatically bring new videos from the feeds in the approval queue every time the cron (xml_cron.php in the admin dir) runs. You can manually execute the cron from the encoder tab in the navigation.
6) Add Embedded: This will allow you to add embedded videos. You will unfortunately need to manually upload a thumbnail in this case, because there is no way to fetch a thumb from an embed code. Embedded videos are placed directly in the publish queue, and do not go through the whole encoding process.
7) Youtube Import: Enter youtube URLs one per line, and the script will import and embed them.
8) Tube Scraper: Enter video page URLs one per line (from the supported sites listed on the tube scraper page under Scrapers->Tube Scraper), and the script will automatically suck in videos, titles, descriptions, and keywords. Please note that this is not instant. It may take some time to download larger videos.

Regardless of which method of content adding you choose, the videos will always initially end up in the Approval Queue (Content->Approval Queue). You can either mass approve videos using the checkboxes, or do them one by one by pressing the green checkmark. After a video is approved, it is moved to the encoding queue. The encoding queue can be executed by clicking the 'Encode' button in the menu. At this stage, videos are encoded to mp4/h264 and thumbnailed. Videos which are already in FLV or MP4/h264 format are not re-encoded, only thumbnailed. Encoding may take some time depending on the size and quantity of the videos in the encoder queue.

After a video has been processed by the encoder script, it is placed in the Publish Queue (Content->Publish Queue). From here, you can mass publish using the checkboxes, or publish a single video using the green checkmark. Once published, a video appears live on the site. The script can be setup to automatically publish content at specific intervals (for instance, hourly). To do this, please add "admin/cronPublish.php" to your server's cron entries. Each time this cron is executed, a video will be published.

You can completely redirect your mobile traffic by using the $redirect_mobile variable in admin/config.php:

$redirect_mobile = ""; //set to url of mobile version, otherwise set $redirect_mobile = false; $enableMobile must be set to false.

This is useful when you want to completely sell off your mobile traffic.

Each video in the system is assigned to a paysite at the approval queue stage. Paysites can be added by selecting "Paysites->Add Paysite" from the menu. Once there, you enter the paysite name and url. You will also notice several large textboxes here labeled ad0, ad1, ad2, ad3 and so forth. You use these to set ads for this paysite by entering HTML into them. You can enter iframe code, javascript, banner ad code, text links, flash ads, or anything you like into these boxes. For example, if we decided ad0 will be a text link under the player, we would do the following:

1) Create our paysite, and enter <a href=''>Click Here To Visit Paysite Name</a> into the ad0 box.
2) On our video templates (template.video_header.php, template.video_content.php, template.video_footer.php located in the templates directory), we would put <? echo $ads[ad0]; ?> in the spot we would like this text link to appear.

Once this is done, all videos which are assigned to this paysite we created will display that text link in that spot. For other paysites, you would enter a textlink specific to them into the ad0 spot as well. This method can be applied for banners or any other type of ad. In short, whatever HTML you put into the ad# boxes will display on the video pages (of videos assigned to said paysite) in the spots you choose to output them. The ad system does not control ads outside of the video/gallery pages.

The player in the script also has advertisements. These are set in the configuration file at admin/config.php using ftp. They are pulled from XML, so you either need to use a sponsor that has a compatible XML feed (for instance, wetdollars), or you can host your own .xml file with the advertisement and point the config file at your own locally hosted xml.

To pull the paysite name on the video page, use <? echo $rrow[paysitename]; ?>. To pull the paysite url, you can use <? echo $rrow[paysiteurl]; ?>.

After a video is deleted, it's cached video page file may still be available for a period of time. This period is dependant on what you have $video_cache_time set to.

If you urgently must delete a video page that's cached, you can remove it by deleting /cache/videos/idnumber manually via ftp or ssh.

Yes. We are available for custom work on the tube script as well as for completely unrelated, standalone projects. Please contact for a quote, or hit us up on ICQ 59416956/Skype mechbunnymedia.

This article is to explain more in depth how the script is put together and how the templating system works.

First of all, the most important template is template.content_item.php. It contains the thumbnail block:

There is a similar file called template.content_item_photos.php, which is the same thing except for photo galleries.

All of the content display pages that show thumbs are put together in the same way. Examples of these pages include:

All of these pages are loading the same template files:

  • template.overall_header.php
  • template.content_item.php (or content_item_photos if it's gallery sorting) repeating over and over
  • template.overall_footer.php

All of these pages are loading exactly the same template files, but the database query is being swapped out based on the URL:

  • User hits /most-viewed/
  • The following rewriting rule is accessed:
    RewriteRule ^(my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends|videos|my-rentals)/$ index.php?controller=index&mode=$1 [QSA]
  • We are hitting /most-viewed/, so the actual request being made is index.php?controller=index&mode=most-viewed
  • /index.php is loaded, which loads inc.metatags.php and controllers/control.index_queries.php
  • includes/inc.metatags.php determines the metatags, titles, etc based on mode=most-viewed
  • controllers/control.index_queries.php determines the database query to be used, based on mode=most-viewed
  • Once the above two are loaded and have their data, the template files are loaded (in the way mentioned 1 paragraph higher)

The homepage is loaded in exactly the same way. On the default template with on a clean installation (or our demo site), everything above the "Free Tube" section is overall_header, the section itself is content_item repeating several times based on database query loaded from control.index_queries.php, and everything below it is overall_footer.php. On the homepage, there are additional blocks (such as Videos Being Watched) that are loaded based on "if" statements in the template files so that they only show up in the homepage. The left sidebar on /videos/ is loaded much in the same way - it's only displayed NOT on the homepage.

The media pages (so video and gallery pages) are loaded in a much simpler way:

The video page is made up of:

  • template.video_header.php
  • template.video_content.php
  • template.video_footer.php

The gallery page is made up of:

  • template.video_header.php
  • template.gallery_content.php
  • template.video_footer.php

Similarly to above, these pages are loaded via rewriterules in .htaccess

  • RewriteRule ^galleries/(.*)-([0-9]+).html$ index.php?controller=gallery&id=$2 [QSA]
  • RewriteRule ^video/(.*)-([0-9]+).html$ index.php?controller=video&id=$2 [QSA]

The "video" controller is loaded (so controllers/, which grabs all the data and then loads the template files listed above. For galleries, it's the same except it loads the gallery controller as specified in the rewriterule.

Other pages, such as signup or login, are loaded similarly to the video/gallery pages as listed above. For instance, the signup page consists of:

  • template.overall_header.php
  • template.signup.php
  • template.overall_header.php

The signup page is loaded by the signup page rewrite, so:

  • RewriteRule ^signup$ index.php?controller=signup [QSA]

Index.php loads /controllers/control.signup.php (which contains all the logic of the signup process) and includes/inc.metatags.php (which determines the metatags/titles/etc for this page based on "controller=signup"), and then loads the appropriate template files.

A common question that get's asked is how to make something appear only on certain pages such as most-viewed or only on the login page if all of the pages are using the same template files. The answer to this is to use php if statements based on the information you have from the rewriterules.

For instance, if I wanted to show something in overall_header or overall_footer that appears ONLY on the signup page, I would use

  • <? if($_GET['controller'] == 'signup') { ?>MY HTML THAT IS SUPPOSED TO SHOW ONLY ON SIGNUP PAGE GOES HERE<? } ?>

If I wanted to show it only every page EXCEPT for signup, I would do the same but instead of == use != (does not equal):

  • <? if($_GET['controller'] != 'signup') { ?>MY HTML THAT IS SUPPOSED TO SHOW ONLY ON SIGNUP PAGE GOES HERE<? } ?>

We know to use $_GET['controller'] because of the rewriterule:

  • RewriteRule ^signup$ index.php?controller=signup [QSA]

If you wanted to show something only on the most-viewed page, you would have to use $_GET['mode'] because the controller is the same for all the sorting pages (top rated, most viewed, newest, search results, etc), so:

  • <? if($_GET['mode'] == 'most-viewed') { ?>YOUR HTML FOR MOST-VIEWED ONLY PAGE GOES HERE<? } ?>

If you wanted to show something only on page 1 of the most-viewed page, then you would do:

  • <? if($_GET['mode'] == 'most-viewed' && $_GET['page'] == 1) { ?>YOUR HTML FOR MOST-VIEWED PAGE 1 ONLY<? } ?>

or on page 3 of top-rated:

  • <? if($_GET['mode'] == 'top-rated' && $_GET['page'] == 3) { ?>YOUR HTML FOR TOP RATED PAGE 3 ONLY<? } ?>

or only on the homepage:

  • <? if($_GET['controller'] == 'index' && !$_GET['mode']) { ?>SHOWS ONLY ON HOMEPAGE<? } ?>
    (in this above case we are specifying !$_GET['mode'], which means that there is no mode selected.

As of 6.0.8, the script supports jpegoptim. This will optimize thumbnails.
You can run it on existing thumbnalis like this:
1) SSH in as a user that has permissions for /media/
2) CD to the media directory
3) Type the following:
find -type f -name "*.jpg" -exec jpegoptim -m85 --strip-all {} \;
  1. You have to be logged in to Your Twitter account.
  2. Go to and click "Create New App",
  3. Fill in form, fields "Website" and "Callback URL" have to start with "http://" or "https://" depending on Your host, IMPORTANT in field "Callback URL" put "",
  4. After creating Your app go to "Keys and Access Tokens" tab,
  5. In the bottom You will find "Your Access Token", if there is no token already generated click "Create my access token",
  6. Now You have all need data. Go to Admin in your Tube and to Settings tab,
  7. Find "Social Networking Settings" section,
  8. Set "Enable Twitter Login" to true
  9. Fill in Keys and Secrets fields with data from Your Twitter App "Keys and Access Tokens" tab
  10. Tube Script => Twitter App
  11. Twitter Consumer Key => Consumer Key (API Key)
  12. Twitter Consumer Secret => Consumer Secret (API Secret)
  13. Twitter Auth Key => Access Token
  14. Twitter Auth Secret => Access Token Secret

It should look like this,
*do not copy data form example, they will not work for Your site.
Save changes. Now on Your site in Login and Registration pages users will be able to Login with Twitter.

The multilanguage setup on the tube script requires setting dns wildcards and serveralias subdomains in apache.

On DNS, you need to set a wildcard dns that points to the same IP address as ''

On Apache, you need to enter 'ServerAlias *' in your <virtualhost> containers.

This will enable subdomains like '' and so forth and will allow the multilanguage setup to work.

The encoder starts up as an apache shell process. If apache is restarted or the server is rebooted, it will uncleanly kill the encoding process which in turn won't be able to report to the admin area that it's no longer running. You can reset your encoder status by clicking the reset encoder button under the encoder progress bar, and then confirming.

It is also worth mentioning that the completion percentage is based off how many files are processed vs how many files total, not the status of a single file. Meaning, if you have 50 videos in your encoding queue, the completion of each video will be 2%. If you have 1 video in the queue, it will jump from 0% to 100% after the completion of the one file.

You can try turning up the cache times in your configuration file located at admin/config.php using a text editor.

The variables in question are:

$video_cache_time = 300; //video page cache time
$overall_cache_time = 5; //cache time for all other pages

The cache times are defined in seconds. On high traffic sites, we recommend the following settings:

$video_cache_time = 43200; //video page cache time
$overall_cache_time = 3600; //cache time for all other pages

Please note that if your cache times are set higher, it may take longer for edits to your videos and newly published videos to appear on your website.

If your site is completely unresponsive, please contact your webhost. Our working hours are Mon-Fri,  8:00 - 18:00 Central European Time. In case of an after-hours emergency, you can reach us at (routed to mobile phone) or try ICQ 59416956 or skype mechbunnymedia.

Please have your host check your apache error logs to diagnose this problem further.

The most common reason is php being installed as a CGI instead of an Apache Handler. The workaround is to remove the following from your .htaccess file:

php_flag register_globals off
php_flag magic_quotes_gpc off
php_flag display_errors off
php_value upload_max_filesize 1000M
php_value post_max_size 1000M

- Make sure php is installed as Apache Handler/DSO rather then CGI
- Make sure ioncube is newest available version
- Make sure php has mysqli extension installed and available
- Make sure $basepath is correct in your admin/config.php file

This is invariably a server (most likely disk i/o) or a network issue. Please contact your webhosting company, as there is nothing we can do to help you with this.

* Please Note *
This article is informational only - we do not provide free technical support for nginx - only for our software. If you would like us to set this up for you, we can do so but will charge for the labour.

Goes into server {...} for appropriate vhost after server_name. Please make sure to change YOURSECRETKEYGOESHERE. Restart Nginx.
location ~* .(mp4)$ {
    secure_link $arg_md5,$arg_expires;
    secure_link_md5 "$secure_link_expires YOURSECRETKEYGOESHERE";
    if ($secure_link = "") {  return 403; }
    if ($secure_link = "0") { return 410; }

Please paste the following function in functions.custom.php in the /admin/ directory. Make sure to replace YOURSECRETKEYGOESHERE with the one you used in nginx configuration.

function nginxSecureLink($array) {
    //hashing function for ngx_http_secure_link_module
    global $video_url;
    $rrow = $array[0];
    $filename = $array[1];
    $server = dbQuery("SELECT * FROM servers WHERE record_num = $rrow[server]");
    $server = $server[0];
    $server['hash_key'] = "YOURSECRETKEYGOESHERE";
    $subdir = $rrow[filename][0] . '/' . $rrow[filename][1] . '/' . $rrow[filename][2] . '/' . $rrow[filename][3] . '/' . $rrow[filename][4] . '/';
    $output = $video_url . '/' . $subdir . $rrow[$filename];
    $expires = time()+3600;
    $md5hash = trim(shell_exec("echo -n '".$expires." $server[hash_key]' | openssl md5 -binary | openssl base64 | tr +/ -_ | tr -d ="));
    return $output."?md5=$md5hash&expires=$expires";


1) Open functions.player.php, and copy the the "displayPlayerVideoJS" function into admin/functions.custom.php
2) Rename the function at the top to "displayPlayerVideoJSNginx"
3) Please make the following changes:

$defaultFile = $outputFiles['trailer_filename'];

$outputFiles['trailer_filename'] = call_user_func('nginxSecureLink', array($rrow, 'trailer_filename'));
$defaultFile = $outputFiles['trailer_filename'];


$defaultFile = $outputFiles['mobile'];

$outputFiles['mobile'] = call_user_func('nginxSecureLink', array($rrow, 'mobile'));
$defaultFile = $outputFiles['mobile'];


$defaultFile = $outputFiles['filename'];

$outputFiles['filename'] = call_user_func('nginxSecureLink', array($rrow, 'filename'));
$defaultFile = $outputFiles['filename'];


Once you have made these changes, save the file.

4) Open template.video_content.php for the template you are using, and replace "displayPlayerVideoJS" with "displayPlayerVideoJSNginx"
5) Test to make sure everything worked

location / {
        root   /path/to/root/of/domain/;
        index  index.php index.html index.htm;
        rewrite ^/page([0-9]+).html$ /index.php?controller=index&page=$1;
        rewrite ^/galleries/(.*)-([0-9]+).html$ /index.php?controller=gallery&id=$2;
        rewrite ^/video/(.*)-([0-9]+).html$ /index.php?controller=video&id=$2;
        rewrite ^/signup$ /index.php?controller=signup;
        rewrite ^/upload$ /index.php?controller=upload;
        rewrite ^/upload_photo$ /index.php?controller=upload&option=photo;
        rewrite ^/login$ /index.php?controller=login;
        rewrite ^/logout$ /index.php?controller=logout;
        rewrite ^/contact$ /index.php?controller=contact;
        rewrite ^/forgot-pass$ /index.php?controller=forgot_pass;
        rewrite ^/my-profile$ /index.php?controller=my_profile;
        rewrite ^/my-friends$ /index.php?controller=my_friends;
        rewrite ^/my-friends/$ /index.php?controller=friends;
        rewrite ^/my-friends/page([0-9]+).html$ /index.php?controller=friends&page=$1;
        rewrite ^/edit-profile$ /index.php?controller=edit_profile;
        rewrite ^/edit-content/(.*)$ /index.php?controller=editContent&id=$1;
        rewrite ^/static/(.*)$ /index.php?controller=displayStatic&id=$1;
        rewrite ^/load/(.*)$ /index.php?controller=loadLayout&id=$1;
        rewrite ^/filter/(.*)$ /index.php?controller=setFilter&id=$1;
        rewrite ^/embed/([0-9]+)$ /index.php?controller=embed&id=$1;
        rewrite ^/dmca$ /index.php?controller=dmca;
        rewrite ^/tos$ /index.php?controller=tos;
        rewrite ^/crss/([0-9]+)$ /index.php?controller=crss&id=$1;
        rewrite ^/rss$ /index.php?controller=rss;
        rewrite ^/a/(.*)$ /index.php?controller=link&slug=$1;
        rewrite ^/(my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends)/$ /index.php?controller=index&mode=$1;
        rewrite ^/(my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
        rewrite ^/(my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends)/(day|week|month)/$ /index.php?controller=index&mode=$1&dateRange=$2;
        rewrite ^/(my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends)/(day|week|month)/page([0-9]+).html$ /index.php?controller=index&mode=$1&dateRange=$2&page=3;
        rewrite ^/(my-uploads|favorites|most-recent|most-discussed|most-viewed|longest|top-rated|photos|random|my-friends)/page([0-9]+).html$ /index.php?controller=index&mode=$1&page=$2;
        rewrite ^/uploads-by-user/([0-9]+)/$ /index.php?controller=index&mode=uploads-by-user&user=$1;
        rewrite ^/uploads-by-user/([0-9]+)/page([0-9]+).html$ /index.php?controller=index&mode=uploads-by-user&user=$1&page=$2;
        rewrite ^/search/(videos|members|photos)/([A-Za-z0-9-\s]+)/$ /index.php?controller=index&mode=search&type=$1&q=$2&page=1;
        rewrite ^/search/(videos|members|photos)/([A-Za-z0-9-\s]+)/page([0-9]+).html$ /index.php?controller=index&mode=search&type=$1&q=$2&page=$3;
        rewrite ^/search/(videos|members|photos)/([A-Za-z0-9-\s]+)/(newest|rating|views|longest)/$ /index.php?controller=index&mode=search&type=$1&q=$2&page=1&sortby=$3;
        rewrite ^/search/(videos|members|photos)/([A-Za-z0-9-\s]+)/(newest|rating|views|longest)/page([0-9]+).html$ /index.php?controller=index&mode=search&type=$1&q=$2&page=$4&sortby=$3;
        rewrite ^/search/([A-Za-z0-9-\s]+)/$ /index.php?controller=index&mode=search&q=$1&page=1;
        rewrite ^/search/([A-Za-z0-9-\s]+)/page([0-9]+).html$ /index.php?controller=index&mode=search&q=$1&page=$2;
        rewrite ^/search/([A-Za-z0-9-\s]+)/(newest|rating|views|longest)/$ /index.php?controller=index&mode=search&q=$1&page=1&sortby=$2;
        rewrite ^/search/([A-Za-z0-9-\s]+)/(newest|rating|views|longest)/page([0-9]+).html$ /index.php?controller=index&mode=search&q=$1&page=$3&sortby=$2;
        rewrite ^/channels/$ /index.php?controller=channels;
        rewrite ^/channels/([0-9]+)/([A-Za-z0-9-\s]+)/$ /index.php?controller=index&mode=channel&channel=$1;
        rewrite ^/channels/([0-9]+)/([A-Za-z0-9-\s]+)/page(.*).html$ /index.php?mode=channel&channel=$1&page=$3;
        rewrite ^/channels/([0-9]+)/([A-Za-z0-9-\s]+)/(newest|rating|views|longest)/$ /index.php?controller=index&mode=channel&channel=$1&sortby=$3;
        rewrite ^/channels/([0-9]+)/([A-Za-z0-9-\s]+)/(newest|rating|views|longest)/page(.*).html$ /index.php?mode=channel&channel=$1&sortby=$2&page=$4;
        rewrite ^/models/$ /index.php?controller=pornstars;
        rewrite ^/models/page([0-9]+).html$ /index.php?controller=pornstars&page=$1;
        rewrite ^/models/([A-Za-z0-9-\s]+)/$ /index.php?controller=pornstars&letter=$1&page=1;
        rewrite ^/models/([A-Za-z0-9-\s]+)/page([0-9]+).html$ /index.php?controller=pornstars&letter=$1&page=$2;
        rewrite ^/models/(.*)-(.*).html$ /index.php?controller=pornstar_bio&id=$2;
        rewrite ^/pornstars/$ /index.php?controller=pornstars;
        rewrite ^/pornstars/page([0-9]+).html$ /index.php?controller=pornstars&page=$1;
        rewrite ^/pornstars/([A-Za-z0-9-\s]+)/$ /index.php?controller=pornstars&letter=$1&page=1;
        rewrite ^/pornstars/([A-Za-z0-9-\s]+)/page([0-9]+).html$ /index.php?controller=pornstars&letter=$1&page=$2;
        rewrite ^/pornstars/(.*)-(.*).html$ /index.php?controller=pornstar_bio&id=$2;
        rewrite ^/mailbox/$ /mailbox.php;
        rewrite ^/mailbox/([0-9]+)$ /mailbox.php?mode=inbox&page=$1;
        rewrite ^/mailbox/inbox/(.*)$ /mailbox.php?mode=inbox&page=$1;
        rewrite ^/mailbox/outbox/(.*)$ /mailbox.php?mode=outbox&page=$1;
        rewrite ^/mailbox/read/([0-9]+)$ /mailbox.php?mode=read&mid=$1;
        rewrite ^/mailbox/read/([0-9]+)/delete/$ /mailbox.php?mode=read&mid=$1&delete=true;
        rewrite ^/mailbox/read/([0-9]+)/spam/$ /mailbox.php?mode=read&mid=$1&spam=true;
        rewrite ^/mailbox/compose/(.*)/reply/$ /mailbox.php?mode=compose&mid=$1&reply=true;
        rewrite ^/mailbox/inbox/$ /mailbox.php?mode=inbox;
        rewrite ^/mailbox/outbox/$ /mailbox.php?mode=outbox;
        rewrite ^/mailbox/compose/$ /mailbox.php?mode=compose;
        rewrite ^/user/(.*)-(.*)/$ /index.php?controller=user_profile&id=$2;
        rewrite ^/members/$ /index.php?controller=members;
        rewrite ^/members/page([0-9]+).html$ /index.php?controller=members&page=$1;

The enable nginx secure streaming, please do the following:

In your nginx.conf inside the server{} for the virtualhost you are working on, add:

location /media/videos/ {
   secure_link $arg_md5,$arg_expires;
   secure_link_md5 "$secure_link_expires$uri YOURSECRETKEY";
   if ($secure_link = "") { return 403; }
   if ($secure_link = "0") { return 410; }

Inside your admin/functions.custom.php file, add the following function:

if(!function_exists('buildNginxSecureLink')) {
    function buildNginxSecureLink($baseUrl, $path, $secret, $ttl) {
        $expires = time() + $ttl;
        $md5 = md5("$expires$path $secret", true);
        $md5 = base64_encode($md5);
        $md5 = strtr($md5, '+/', '-_');
        $md5 = str_replace('=', '', $md5);
        return $baseUrl . $path . '?md5=' . $md5 . '&expires=' . $expires;

Inside your admin/functions.player.php, add the following inside the displayPlayer function for the appropriate player (IE displayPlayerVideoJS):

$outputFiles = getMediaURLs($rrow);

foreach($outputFiles as $k=>$v) {
   $outputFiles[$k] = buildNginxSecureLink($basehttp,"/media/videos".str_replace($video_url,"",$v),"YOURSECRETKEY",1800);

You must of course replace "YOURSECRETKEY" with a key of your own, and depending on your httpd setup you may need to adjust the paths used in this file.

This is effective as of Mechbunny Tube Script 6.0.5

To enable Paysite System:
1) Set either CCBill, Epoch, or Other (if additional biller was coded into your installation) postback to true to enable postback script. This will unlock access to the postback scripts.
2) Edit template.signup.php to link to your biller's signup page. You can use a nicer join template here as well, and link it out directly to ccbill's flexjoin forms or Epoch's member signup page.
3) Set the paysite mode you want to use in admin area settings. Thumbnails makes it show thumbs only for non-members, Trailers makes it show trailers (requires trailer encoding be on, and that trailers are encoded for the videos in question already otherwise it will show full length), and 'false' disables the entire paysite system.
4) Follow one of the instruction sets below:


After setting up your site in ccbill or epoch, go to the subaccount of the site and then the user management section. Disable thier user management and enter the following as user management URLs:
If is recommended that you rename these files to random names to prevent someone from manually sending a POST. Please disable password encryption at the biller end if they offer such an option - they should be sending plaintext passwords to the billing script (which then get encrypted at the script level).
If using CCBill, you must contact their support and tell them to enable JPOST on this subaccount.


After creating your site in the netbilling admin and enabling paysite mode and netbilling postback in the admin area of the script,
1) Go to site tools -> site tags
2) Select config under the site you want to edit
3) Under Member URL, put
4) Under Control CGI Url, put (or different path if you renamed the password management file)
5) Under encryption options, select 'Post plain text passwords to your Control CGI'
6) Test by going to search tools -> browse -> members and creating a user on the site, then going into edit for the member and pressing 'refresh user' to send the POST.

If you are hosting at, please have them do the following for the script to work: (in addition to the standard dependancy install)

- in httpd.conf, turn on allowoverrides all (so that mod_rewrite works properly and disabling the php engine in the 777'd dirs works)
- in php.ini, turn OFF safe mode for both php cli and http
- in php.ini, turn ON allow_url_fopen
- in php.ini, replace the disabled functions list with the one found in
- in php.ini, turn ON file uploads
- allow access to ffmpeg, php binary, wget, mp4box, yamdi, nohup, and the ffmpeg presets to the apache user

As of Mechbunny 6.2.3, we've introduced alternate color options for the tube script default_tube2018 and default_tube2019 templates.

These are css files that overwrite the existing color schema. They can be mixed and matched, and are located in /templates/TEMPLATENAME/css/

The foreground colors are labeled "accent", the background colors are labeled with "bg".

These need to be inserted into your <head> tag, which is found in /templates/TEMPLATENAME/widgets/widget.header_scripts.php

Usage example:

<link href="<? echo $template_url; ?>/css/accent-lime.css" rel="stylesheet" type="text/css" />
<link href="<? echo $template_url; ?>/css/bg-grey.css" rel="stylesheet" type="text/css" />

These must be inserted AFTER the existing CSS file calls.

To configure the PPC script with your Google Analytics account, you must do the following:

1) Create a Google Developers project as per
2) Create service account under this project, see instructions as per
3) Select P12 for Key Type.
4) Download the .p12 file for this service account, upload to the admin directory
5) Enable 'analytics API' in the Google Developers console
6) In Google Analytics Administration > User Management, give the service account 'Read and Analyse' permissions on the analytics accounts you want to access. The email of this account is the one you get when creating the service account.

5) set a new variable for each $tubeConfig in your admin/config.php file, so it looks like this:

$tubeConfig[0] = array(
"siteName" => "Blah",
"siteFeedUrl" => "",
"uniqueSiteSlug" => "myTubeSite", //DO NOT CHANGE THIS EVER ONCE YOU START!
"googleAnalyticsEmail" => "",
"oAuthKeyFile" => "KEY_FILE_NAME_GOES_HERE.p12",
"googleAnalyticsProfileID" => "12345678" //THIS IS DIFFERENT THEN THE UA CODE!

The email address must be the one that is generated with the p12 key.
The last step is log into your google analytics and give access to that new email address read/write access to your analyts.

This is effective as of Mechbunny Tube Script 6.0.5

To enable VOD System:
1) Set Vod Tokens to "true" in admin area settings page under Payment Gateway settings. Billers should all be set to "false" - these settings are used for monthly membership sites.
2) Set the video rental length in seconds in the same spot. By default it's 86400, so 1 day. If you want permanent purchases, just enter a very large number such as 3153600000 (100 years)
3) Define the default token cost per video. If you set this to zero, all videos will default to "free". You can overwrite a single video's token cost under edit content for that video. For example, if you want to make all videos free except certain ones, you would leave default token cost at zero and enter "5" or however much you want under edit content for the content do YOU want to bill for.
4) In template.buyTokens.php, adjust the links/template here so it links to your billers purchase tokens page.
5) Setup biller postback script using the functions located in admin/functions.billing.php as per your billers postback documentation.

* Please Note *
This article is informational only - we do not provide free technical support for nginx - only for our software. If you would like us to set this up for you, we can do so but will charge for the labour.

If you are using nginx as a proxy in front of apache (using the nginx proxy_pass functionality), you will have an issue with voting on content (it will always say you have already voted) because the IP that comes through to apache will always be To circumvent this, you must do the following:

In Nginx configuration:
Under your proxy_pass line, add:proxy_set_header REMOTE_ADDR $remote_addr;

In admin/config.php:
At the top just after <?, add:

This will overwrite the with the users real ip, thus allowing them to vote.

In order to activate VR functionality on the tube script (available as of 6.0.8), you must first register at delight-vr's website ( You will receive a piece of javascript code to implement on your site. It looks like:
<script src="//" async></script>

You must copy the value of the src parameter into the tube script's admin settings to activate the player.
Our working hours are Mon-Fri,  8:00 - 18:00 Central European Time. In case of an after-hours emergency, you can reach us at (routed to mobile phone) or try ICQ 59416956 or skype mechbunnymedia.

There are two cron files currently available in the script (unless you had others added). They are both located in the admin/ directory.
cronPublish.php - Each time this is executed, x number of video gets published from the publish queue. In the config file, you can specify the number of videos to get published each time this is run.
xml_cron.php - This file will download videos from your added xml feeds to the approval queue.

You do not *have* to enable these crons. They are optional depending on how you want to run your site.

There are 2 types of users in the script. Regular Users, and Partners. It is not nessesary to use both. It is simply a way to give certain users more permissions then others (ie. limiting uploading only to 'partner' users and so forth).

You can edit your admin username and password by editing admin/config.php in a text editor. You can also enable ip restrictions for your admin area in this saame spot.

The most common reason for a video not encoding properly is permissions.

Please have your host try running the following command line as root via ssh

chmod -R 777 /path/to/your/website/htdocs/media

Then try encoding again. If the videos are still failing, there is a chance that you are using a video codec unsupported by ffmpeg.

There is a very wide range of reasons why your site may be running slow. Please contact support for help on this topic, and we will help you debug exactly where the problem lays.

The most common reasons for slow site performance is an overloaded server from media downloads (disk i/o), and misconfigured webserver.

Most popular articles 
Newest articles