Hold Tight...

0 %
Driving cybersecurity excellence
Innovator behind Kodachi OS
  • Residence:
    ::0
  • Uptime Binary:
    110001
  • Mantra:
    Innovate, Secure, Repeat
ONS
EEDS
NSSG
Cybersecurity
Programming & R&D
Cryptocurrency
AI & vibe coding
  • Bash
  • Gambas
  • Delphi
  • PHP
  • Visual Basic
  • Rust

Vbtube mass delete script and mass correction

05/05/2013
2 min readDeep Tech2 code examplesUpdated October 2026

Key points

  • A PHP extension for Vbtube (vBulletin 3 and 4) that deletes dead YouTube video entries in bulk and corrects missing titles and thumbnails.
  • It belongs to that era: it needs PHP 5 and the retired YouTube GData API, so it will not run on a current server as it is.
  • Read the usage notes in the source before running actions 1 and 2.

PHP Script for Extending Vbtube: Mass Deletion and Correction Utility

Updated October 2026: This Vbtube mass delete script belongs to the vBulletin 3 and 4 era and will not run on a current server as it is:

  • vbtube.com no longer exists, and the script needs PHP 5: the mysql_* functions, ereg() and the preg_replace() /e modifier it uses were all removed in PHP 7.0.
  • The title fix (action=1) calls the YouTube GData v2 API at gdata.youtube.com, which Google shut down in 2015. The YouTube oEmbed address https://www.youtube.com/oembed?url=VIDEO_URL&format=json returns a video’s title with no API key, and answers with an error for a video that no longer exists, which is a simpler dead-video test.
  • The thumbnail signature in the script (da39a3ee…) is simply the SHA-1 of an empty string, so the check fires whenever a thumbnail cannot be downloaded.
  • If you rewrite it, bind values with PDO prepared statements, as in my SQL sanitizing post.

I have written this PHP script as an extension to the Vbtube script. If you don’t have Vbtube installed, this script won’t be useful unless you want to learn how I code (which might not be the best idea).

This script is useful for mass deletion of invalid YouTube links, saving you time and avoiding the manual hassle. Additionally, it can correct the title of any videos that did not have the correct title when retrieved. Alternatively, you can even correct the path of broken links and images by using action=2. I used this script on my own forum for years, and it saved me a lot of time and effort.

Please note that usage is explained in the source code, and it is crucial to read it carefully before using actions 1 and 2.

The Vbtube mass delete code

Download zip

PHP
<?php 

#!!!!!***************!!!!!!!!!******************!!!!!!!!!!!!**********!
#Please read before making use of this code!
#Disclaimer: This is illegal if executed on real victims and could land you in prison for sure.
#This is intended for educational purposes only. I take no responsibility at all for your actions.
#This code is provided by Warith AL Maawali for educational purposes only.
#For more educational source code, visit https://www.digi77.com
#Author of this code: Warith AL Maawali, founder of om77.net, reachable at warith@digi77.com.

#Sharing knowledge is not about giving people something, or getting something from them.
#That is only valid for information sharing.
#Sharing knowledge occurs when people are genuinely interested in helping one another develop new capacities for action;
#it is about creating learning processes.
#Peter Senge
#!!!!!***************!!!!!!!!!******************!!!!!!!!!!!!**********!


// This script is an extension to the vbtube script--> http://www.vbtube.com/ if you don't have vbtube then it wont be 
// useful unless you want to learn how I code which is a bad idea :p 

// You can use this to mass delete invalid tubes I wrote this to save me the headache of fetching and deleting  
// one by one which took me ages to complete.It can also correct the title of any tubes that did not have the correct title while retrieved.
// Or even correct the path of broken links if action=2 is used


// usage to delete all invalid tubes  use this :  http://www.yoursite.com/vbtube_delete.php?action=0  or  
// http://www.yoursite.com/vbtube_delete.php
// usage to correct invalid titles  of the tubes use this :  http://www.yoursite.com/vbtube_delete.php?action=1  
// usage to correct invalid links  of the tubes use this :  http://www.yoursite.com/vbtube_delete.php?action=2  
// I normally run it in ssh Linux by typing $php vbtube_delete.php  then I sit back and watch :p

require_once('./global.php');



//variables to change
$mysiteadress="http://www.oman0.net/media/";   //set this to you site path do not forget the slash / at the end
$youtubethumbsig="da39a3ee5e6b4b0d3255bfef95601890afd80709"; //$sha1.$md5 of youtube non available tube thumb 
//on youtube do not change this at all unless u are sure thumbnail has changed on youtube

// example of non valid thumbnail on youtube is here https://img.youtube.com/vi/sdldjfsdkssskdjksd/default.jpg






//get action value 
$action =$_REQUEST['action'];

//check if var is passed or not
if (!isset($action)) {
   $action =0;
}
else
{
    //clean the Integer
    $action=(filter_var($action, FILTER_SANITIZE_NUMBER_INT));

}




//For Sql query variable use
function mysqlCleaner($data)
{
    $data= mysql_real_escape_string($data);
    $data= stripslashes($data);
    return $data;
}    



if ($action==0)
{

    echo "Processing";

    $counter =0;


    $query4 = "Select * from vbtube_tubes where tubeid > 0";
    $query4= mysqlCleaner($query4);
    $result4 = mysql_query($query4);  
    while ($row4 = mysql_fetch_row($result4))
    {





        $imagevarpath2="<br><a href=\"$row4[8]\" rel=\"lightbox\" target=blank><img style=\"border: 3px solid gray;\" src=$row4[12] alt=\"$row4[6]\" width=80 height=60></a><br>";
        //echo "before " . $imagevarpath2;
        $filename=$row4[12];          
        $sha1 = @sha1(file_get_contents($filename));
        $md5 = @md5_file($filename);
        $sign = $sha1.$md5;

        //echo "<br>da39a3ee5e6b4b0d3255bfef95601890afd80709";
        //echo "<br>sha1 and md5 code of tube thumbnail: " . $sign;
        if ($sign==$youtubethumbsig)
        {
            //echo $imagevarpath2;
            echo $filename;
            $insert7="delete from vbtube_tubes WHERE tubeid =$row4[0]";
            $insert7= mysqlCleaner($insert7);
            mysql_query($insert7);
            echo "<br><font color=red><b>Tube " . $row4[0] . " Deleted</b></font>";
            //sleep(10); use it if you run the script from your web browser commented to run in ssh      php script-name.php    

        }else
        {
            echo ".";
            $counter=$counter+1;
            if ($counter % 300 == 0) 
            {
                echo $counter . '<br>';

            }


        }//

        flush();
    }

    //delete non active tubes do it after approving all tubes
    $query5 = "Select * from vbtube_tubes where active=0";
    $query5= mysqlCleaner($query5);
    $result5 = mysql_query($query5);
    while ($row5 = mysql_fetch_row($result5))
    {

        //delete non active tubes
        $insert5="delete from vbtube_tubes WHERE tubeid =$row5[0]";
        $insert5= mysqlCleaner($insert5);
        mysql_query($insert5);
        echo "<br>In active Tube " . $row5[0] . " Deleted<br>";
        $imagevarpath2="<a href=\"$row5[8]\" rel=\"lightbox\" target=blank><img style=\"border: 3px solid gray;\" src=$row5[12] alt=\"$row5[6]\" width=80 height=60></a>&nbsp;&nbsp;$row5[0]";
        echo $imagevarpath2;
        flush();    
    }
    echo '<br> Deleting dead thumbs + none active tubes done :)';


}
else if ($action==1) //get missing and corrupted titles replace them with valid once from youtube
{




    // utf to uni code  not uses we use iconv instead
    function charset_decode_utf_8 ($string) 
    {
          /* Only do the slow convert if there are 8-bit characters */
        /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */
        if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string))
            return $string;

        // decode three byte unicode characters
        $string = preg_replace("/([\340-\357])([\200-\277])([\200-\277])/e",       
        "'&#'.((ord('\\1')-224)*4096 + (ord('\\2')-128)*64 + (ord('\\3')-128)).';'",   
        $string);

        // decode two byte unicode characters
        $string = preg_replace("/([\300-\337])([\200-\277])/e",
        "'&#'.((ord('\\1')-192)*64+(ord('\\2')-128)).';'",
        $string);

        return $string;
    } //end function




    //remove bad characters
    function mysql_escape_mimic($inp) 
    {
        if(is_array($inp))
            return array_map(__METHOD__, $inp);

        if(!empty($inp) && is_string($inp)) {
            return str_replace(array('\\', "\0", "\n", "\r", "'", '"', "\x1a"), array('\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'), $inp);
        }

        return $inp;
    } 



    $query6 = 'select * from vbtube_tubes where title=" " ORDER BY tubeid'; // where tubeid=9848   where title=" " ORDER BY tubeid   where title=" " ORDER BY tubeid Limit 5
    $query6 = mysqlCleaner($query6 );
    $result6 = mysql_query($query6);
    while ($row6 = mysql_fetch_row($result6))
    {
        //if($row6[0]=="9740")
        //{         

        //echo  "is utf " . $row6[6];

        $m= explode("v=", $row6[11]);
        $video_id = "http://gdata.youtube.com/feeds/api/videos/" .$m[1];
        $content = file_get_contents($video_id);
        //echo  $content ." <br>";
        if(!$content)
        {

          echo "Dead vid " . $row6[0] . "   " . $video_id ." <br>";
        }
        else
        {
            $string2 = explode("<title type='text'>", $content);

            $string3 = explode("</title>", $string2[1]);
            $string3[0] =iconv("UTF8", "windows-1256//TRANSLIT", $string3[0]);
            //$string3[0]=charset_decode_utf_8($string3[0]);
            //$string3[0]=decode_utf8($string3[0]);
            //echo "New title found " . $string3[0] . "<br>";
            //echo "escaped title = " . addslashes($string3[0]) ;
            $title=addslashes($string3[0]);
            if ($title)
            {
                $insert7="update vbtube_tubes set title=\"$title\" where tubeid =$row6[0]";
                $insert7= mysqlCleaner($insert7);
                mysql_query($insert7);
                echo "Tube uid " .$m[1] . "  Tube id " . $row6[0] . " Old title =" . $row6[6] . "  New title " . $title . "<br>";
                //echo $string2[1]  . "<br>";
                //echo $string3[0]  . "<br> ";
            }
            else
            {
                 echo "Title not found for Tube uid " .$m[1] . "  Tube id " . $row6[0] . "<br>";
                 echo $string2[1]  . "<br>";
                 echo $string3[0]  . "<br> ";
                 sleep(5);
            }
            flush();
     //}
        }
    }
    echo '<br> Fixing missing titles done :)'; 

}
else if ($action==2) //Correct tube links
{   

    $query6 = 'select * from vbtube_tubes where link like "%forum%"'; // remove word forum from path
     //$query6 = 'select * from vbtube_tubes where link3 like "%&%"'; // find links with &
    //$query6 = 'select * from vbtube_tubes where link1img like "%oman%"'; // find local images
    //$query6 = 'select * from vbtube_tubes where link1img like "%&%"'; // find vars with &
    $query6= mysqlCleaner($query6);
    $result6 = mysql_query($query6);
    while ($row6 = mysql_fetch_row($result6))
    {
       $m= explode("v=", $row6[11]);
       //echo $m[1] . "<br> ";;
       $s= explode("&", $m[1]);

       $var =$mysiteadress . $row6[0] . "-"; //// remove word forum from path
       //$var ="http://www.youtube.com/watch?v=" .  $s[0] ; //for links
       //$var ="http://img.youtube.com/vi/" .  $s[0]  . "/default.jpg"; //for images
       //$insert7="update vbtube_tubes set link1img=\"$var\" where tubeid =$row6[0]"; //for images 
       $insert7="update vbtube_tubes set link=\"$var\" where tubeid =$row6[0]"; //for links
       $insert7= mysqlCleaner($insert7);
       mysql_query($insert7);
       echo $var . "<br> ";
    flush();
    }

    echo '<br> Removing local thumbs done :)';

}
else
{ 
    echo "Sorry !! Nothing to do bye bye.....";
    exit;

}


?>
PHP

Usage

ShellScript
# To delete all invalid tubes, the command would be:

http://www.yoursite.com/vbtube_delete.php?action=0  
# or
http://www.yoursite.com/vbtube_delete.php

# To correct invalid titles of the tubes the command would be:

http://www.yoursite.com/vbtube_delete.php?action=1 

# To correct invalid links of the tubes the command would be:

http://www.yoursite.com/vbtube_delete.php?action=2
ShellScript

The script in action

Terminal output of the vBTube mass delete script removing dead video threads
Terminal output of the vBTube mass correction script
Terminal output line of the vBTube mass delete script

Posted in Deep TechTags: