<?php
include 'header.php';
ini_set('display_errors', 0);

   function pick($start,$stop,$from){
$from=explode($start,$from);
$from=explode($stop,$from[1]);
$from=$from[0];
return $from;
}
$cachefile = "cache/".$_GET['dir']."_".$_GET['sort']."_".$_GET['p']."_".$_GET['page'].".html";
$cachetime = 60 * 60 * 5; // 5 hr


      // Serve from the cache if it is younger than $cachetime

      if (file_exists($cachefile) && (time() - $cachetime
         < filemtime($cachefile)))
      {
        echo "\n<!-- cache loaded -->\n";
         include($cachefile);

         }
			else
			{
			ob_start();
$link='http://fuckmob.net/clips/index.php?dir='.$_GET[dir].'&sort='.$_GET[sort].'&p='.$_GET[p].'&page='.$_GET[page];
$source=file_get_contents($link);
$ssour=pick('<div class=\'header\'>','<hr>',$source);
if(stristr($ssour,'(IndianWap.Mobi).3gp'))
{
$main=str_replace('(IndianWap.Mobi).3gp','(Fryvdo.CoM).3gp',$ssour);
echo $main;
 }
 else
 {
 echo $ssour;
}
   $fp = fopen($cachefile, 'w');


       // save the contents of output buffer to the file
	    fwrite($fp, ob_get_contents());

		// close the file

        fclose($fp);

		// Send the output to the browser

}
        ob_end_flush();
include 'footer.php';
?>