mtb211 Posted December 12, 2008 Share Posted December 12, 2008 Whats wrong with this code? I just started a new job and the old programmer is unavailable. The code is bespoke so I dont know , Friend told me that htpw is not declared... I had a hard time following him <html> <head> <title>Unbenanntes Dokument</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php $dir = $uname; $user = $_POST['user']; $pass = $_POST['pass']; // Aktuelles Verzeichnis ermitteln $thisdir = str_replace(strrchr($_SERVER['SCRIPT_FILENAME'],'/'), '', $_SERVER['SCRIPT_FILENAME']); // Gewünschtes Verzeichnis erstellen $oldumask = umask(0); mkdir($dir,0777); umask($oldumask); // Daten für .htaccess erstellen $htaccess = 'AuthType Basic AuthUserFile '.$thisdir.'/'.$dir.'/.htpasswd AuthName "Geschuetzer Bereich" order deny,allow allow from all require valid-user'; // Daten für .htpasswd erstellen $htpasswd = $uname.':'.crypt($pw, substr(md5(uniqid(rand())), 0, 2)); // Testdatei erstellen (wird angezeigt beim erfolgreichen Login) $handle = fopen($dir.'/index.php', 'w'); fwrite($handle, ' <? echo "Hier sind die Bereitgestellten Dateien<br><br>"; $action=opendir("./"); while($datei=readdir($action)){ if(!preg_match("!(\.|\..)$!", $datei)){ if ($datei!="index.php" && $datei!=".htaccess" && $datei!=".htpasswd" ) { echo " <a href=\"$datei\"> $datei</a><br>"; } } } ?>'); fclose($handle); // .htaccess erstellen $handle = fopen($dir.'/.htaccess', 'w'); fwrite($handle, $htaccess); fclose($handle); // .htpasswd erstellen $handle = fopen($dir.'/.htpasswd', 'w'); fwrite($handle, $htpasswd); fclose($handle); ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/136674-whats-wrong-with-this-code/ Share on other sites More sharing options...
Mark Baker Posted December 12, 2008 Share Posted December 12, 2008 Take a closer look at the line fwrite($handle, and following Link to comment https://forums.phpfreaks.com/topic/136674-whats-wrong-with-this-code/#findComment-713633 Share on other sites More sharing options...
mtb211 Posted December 12, 2008 Author Share Posted December 12, 2008 ah okay, I didnt see that... Im not a very good coder... Do I just need to close the bracket? Link to comment https://forums.phpfreaks.com/topic/136674-whats-wrong-with-this-code/#findComment-713644 Share on other sites More sharing options...
Yesideez Posted December 12, 2008 Share Posted December 12, 2008 No, you'll need to specify more parameters like the data you want to write. So far you're only specifying the file stream. Link to comment https://forums.phpfreaks.com/topic/136674-whats-wrong-with-this-code/#findComment-713647 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.