tycoon35 Posted October 17, 2008 Share Posted October 17, 2008 I was using the following script in a php4 server successfully for several months without any issue/s. <?php include("./config.php"); $bans=file("./bans.txt"); foreach($bans as $line) { if ($line==$_SERVER['REMOTE_ADDR']){ echo "You are not allowed to download files."; include("./footer.php"); die(); } } if(!isset($_GET['a']) || !isset($_GET['b'])) { echo "<script>window.location = '".$scripturl."';</script>"; } $validdownload = 0; $filecrc = $_GET['a']; $filecrctxt = $filecrc.".txt"; if (file_exists("./storagedata/".$filecrctxt)) { $fh = fopen ("./storagedata/".$filecrctxt,r); $filedata= explode('|', fgets($fh)); if (md5($filedata[1].$_SERVER['REMOTE_ADDR'])==$_GET['b']) $validdownload=$filedata; fclose($fh); } if($validdownload==0) { echo "Invalid download link."; include("./footer.php"); die(); } $userip = $_SERVER['REMOTE_ADDR']; $time = time(); $filesize = filesize("./storage/".$filecrc); $filesize = $filesize / 1048576; if($filesize > $nolimitsize) { $downloaders = fopen("./downloaders.txt","a+"); fputs($downloaders,"$userip|$time\n"); fclose($downloaders); } $validdownload[3] = time(); $newfile = "./storagedata/$filecrc" . ".txt"; $f=fopen($newfile, "w"); fwrite ($f,$validdownload[0]."|". $validdownload[1]."|". $validdownload[2]."|". $validdownload[3]."|".($validdownload[4]+1)."\n"); fclose($f); header('Content-type: application/octetstream'); header('Content-Length: ' . filesize("./storage/".$filecrc)); header('Content-Disposition: attachment; filename="'.$validdownload[0].'"'); readfile("./storage/".$filecrc); ?> When I execute it now, it says the following(in php5 server).. Warning: fopen(./storagedata/b4455fc53a5d2d957cb3008951386b27.txt) [function.fopen]: failed to open stream: Permission denied in /home/admin/domains/mysite.com/public_html/hosting/download2.php on line 53 Warning: fwrite(): supplied argument is not a valid stream resource in /home/admin/domains/mysite.com/public_html/hosting/download2.php on line 54 Warning: fclose(): supplied argument is not a valid stream resource in /home/admin/domains/mysite.com/public_html/hosting/download2.php on line 55 Warning: Cannot modify header information - headers already sent by (output started at /home/admin/domains/mysite.com/public_html/hosting/download2.php:53) in /home/admin/domains/mysite.com/public_html/hosting/download2.php on line 57 Warning: Cannot modify header information - headers already sent by (output started at /home/admin/domains/mysite.com/public_html/hosting/download2.php:53) in /home/admin/domains/mysite.com/public_html/hosting/download2.php on line 58 Warning: Cannot modify header information - headers already sent by (output started at /home/admin/domains/mysite.com/public_html/hosting/download2.php:53) in /home/admin/domains/mysite.com/public_html/hosting/download2.php on line 59 Warning: readfile(./storage/b4455fc53a5d2d957cb3008951386b27) [function.readfile]: failed to open stream: Permission denied in /home/admin/domains/mysite.com/public_html/hosting/download2.php on line 60 Serious help needed to fix it asap Thank you all. Link to comment https://forums.phpfreaks.com/topic/128857-php4-script-not-working-in-php5/ Share on other sites More sharing options...
wildteen88 Posted October 18, 2008 Share Posted October 18, 2008 All those errors are caused by the first error message: Warning: fopen(./storagedata/b4455fc53a5d2d957cb3008951386b27.txt) [function.fopen]: failed to open stream: Permission denied in /home/admin/domains/mysite.com/public_html/hosting/download2.php on line 53 That error suggests to me that the file b4455fc53a5d2d957cb3008951386b27.txt in ./storagedata doesn't have the correct read (and/or write) permissions. CHMOD 0644 should suffice for just reading files, 0755 for writing to files. Link to comment https://forums.phpfreaks.com/topic/128857-php4-script-not-working-in-php5/#findComment-668607 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.