PDA

View Full Version : Php: Symlink Script



nsane
08-10-2004, 06:37 AM
i wrote most of it but i found the delete file & symlink parts in a tutorial i read a while back (been tinkering with it for a while :P )

any ways, everything works except it wont delete the files :(


<?php

$refs = "ref.txt";
$getref = getenv(HTTP_REFERER);
$start = "TRUE";
$addref = 0;
$fp = fopen($refs,"r");
while (!feof($fp)){$line = fgets($fp, 4096); $line=trim($line);
if ($line != ""){$addref++;}
if ($line==$getref){$start = "FALSE";}}
fclose($fp);
if ($start == "TRUE"){$fp = fopen($refs,"a");fwrite($fp, "\n");fwrite($fp, $getref);fclose($fp);$addref++;}

if(
$HTTP_REFERER=="http://www.geocities.com/kazaalite243/download_kazaa_lite_here.html" ||
$HTTP_REFERER=="http://geocities.com/kazaalite243/download_kazaa_lite_here.html" ||
$HTTP_REFERER=="http://www.jardinescustom.com/showoffChrome.html" ||
$HTTP_REFERER=="http://www.aztech.com/driver/sound_nova16ell.htm" ||
$HTTP_REFERER=="http://172.30.8.3/raporlar/Paylasilan_bilgiler.htm" ||
$HTTP_REFERER=="http://www.epirate.net/p2phack.htm" ||
$HTTP_REFERER=="http://www.epirate.net/main.htm" ||
$HTTP_REFERER=="http://epirate.net/p2phack.htm" ||
$HTTP_REFERER=="http://epirate.net/main.htm"
){header("Location: /index.htm");}else{

   if(isset($_REQUEST["file"])){
   $name=basename($_REQUEST["file"]);
   $file="/home/site/public_html/nsane/dl/".$name;
   if($name==""){header("Location: /index.htm");}

       if(file_exists($file)&&is_file($file)){
       umask("0000");
       $newdir=md5(crypt("random"));
       $size=filesize($file);
       if(ereg(".rar",$name)){$type="application/x-rar-compressed";}
       elseif(ereg(".zip",$name)){$type="application/x-zip-compressed";}
       elseif(ereg(".exe",$name)){$type="application/x-msdownload";}
       else{$type="application/octet-stream";}
       mkdir("/home/site/public_html/nsane/sym/$newdir/");
       symlink("/home/site/public_html/nsane/dl/$name","/home/site/public_html/nsane/sym/$newdir/$name");
       header("Location: /sym/$newdir/$name");

          $root="/home/site/public_html/nsane/sym/";
          if($handle=opendir($root)){
          while(false !== ($dir = readdir($handle))){
          if ($dir != "." && $dir != ".." && $dir != ".htaccess" && $dir !== "index.php"){
          $made=filectime("$root/$dir");
          $now=time();
          $diff=($now-$made)/60;
          if ($diff > 30){
          system("rm -r $root/$dir");}}}
          closedir($handle);exit();}

       }else{header("Location: /index.htm");}

   }else{header("Location: /index.htm");}

}

?>

nsane
08-10-2004, 07:27 AM
nevermind, just relized the delete folder part was meant to be used as a different file. which you run to delete folders older than 30 minutes old :frusty:

works perfect now, tho :P