I am using this code to download video from you tube (it is a robot.php file used in downloading process)
<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
require_once('lib/youtube.lib.php');
if(eregi('youtube.com|localhost',$_GET['url'])){
    if(!eregi('www.',$_GET['url'])){
        $_GET['url'] = str_replace('http://','http://www.',$_GET['url']);
    }
    list($video_id,$download_link) = get_youtube($_GET['url']);
            ?>
    <p>
    <img src="http://img.youtube.com/vi/<?php echo trim($video_id);?>/1.jpg" alt="Preview 1" class="ythumb" />
    <img src="http://img.youtube.com/vi/<?php echo trim($video_id);?>/2.jpg" alt="Preview 2" class="ythumb" />
    <img src="http://img.youtube.com/vi/<?php echo trim($video_id);?>/3.jpg" alt="Preview 3" class="ythumb" />
    </p>
    <p>
    <a href="<?php echo trim($download_link);?>" class="ydl" title="Download as FLV">Download FLV</a>
    <a href="<?php echo trim($download_link);?>&fmt=18" class="ydl" title="Download as MP4">Download MP4</a>
    <a href="<?php echo trim($download_link);?>&fmt=17" class="ydl" title="Download as 3GP">Download 3GP</a>
    </p>
    <?php
}
else{
    die('<span style="color:red;">Sorry, the URL is not recognized..</span>');
}
?>
running this, I get error
Deprecated: Function eregi() is deprecated in D:\wamp\www\u\code\robot.php on line 6
and line 6 is
if(eregi('youtube.com|localhost',$_GET['url']))
searching stackoverflow i got
if (!function_exists('eregi')) {
        function eregi($find, $str) {
            return stristr($str, $find);
        }
    }
but i am not sure how to use it? where should i place it?
could any one help me regarding this? how to update this code to match regex and remove errors?
thanks..
 
     
    