Page 1 of 1

whats wrong with my code on line 55!

Posted: Thu Dec 18, 2008 6:32 am
by mtb211
here is my error
Warning: mkdir(qwa): File exists in /var/www/vhosts/punktewolke.de/httpdocs/kunden/erstell.php on line 20

Warning: copy(/var/www/vhosts/punktewolke.de/httpdocs/qwa/index.php): failed to open stream: No such file or directory in /var/www/vhosts/punktewolke.de/httpdocs/kunden/erstell.php on line 55
failed to copy ...

any idea whats wrong ?

thx matt

Code: Select all

 
<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 "Enter user name and password please!" 
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); 
*/
if (!copy($_SERVER['DOCUMENT_ROOT'] . '/kunden/muster/index.php', $_SERVER['DOCUMENT_ROOT'] . '/' . $dir.'/index.php')) {
    echo ("failed to copy $file...<br>\n");
}
 
 
// .htpasswd erstellen 
$handle = fopen($dir.'/.htpasswd', 'w'); 
fwrite($handle, $htpasswd); 
fclose($handle); 
 
?> 
</body>
</html>
 

Re: whats wrong with my code on line 55!

Posted: Thu Dec 18, 2008 6:38 am
by Mark Baker
You're trying to create a directory that already exists

And trying to copy a file that doesn't exist, or that you don't have privilege to read

Re: whats wrong with my code on line 55!

Posted: Thu Dec 18, 2008 7:01 am
by mtb211
hey thanks for the fast response. The file does exist... maybe I just have the wrong path?

Matt