First of all, sorry for my bad english!
Hello, I'm learning web development all alone, and so I don't really know everything.
My problem is that after I used a edited (I don't think that this had a error) form to download and edit files. After that ALL of my .php files (that works before this perfectly fine) are now giving the http 500 error and I don't know what's the problem is.
I don't have a .htaccess.
I know that I don't send any information, but I don't know what information is relevant for this case and not, so I hope you all can say which information I should send you.
I'll then edit this post, and send it in the comments.
Thanks for any helps from you all!
Edit 1:
I found some php error logs, but I don't understand it exaclty:
And I found something really weird..
File(/var/www/html/index.php) is not within the allowed path(s): (1) in Unknown on line 0
It says that to all my .php files, but I don't know why, because the only thing I've done was to use on of my form inputs to test something, and then this error came up...
Edit 2:
I modified two .php files before the error appeared.
This one:
<?php
$levelID = $_POST["levelid"];
$description = $_POST["description"];
$levelCreator = $_POST["creator"];
shuffle($array);
$arrayLength = count($array) - 1;
$folder_name = $levelID;
$rand = 3;
$directoryFile = "/var/www/html/ng/mm/levels/" . $folder_name . "/";
$directoryCache = "/var/www/html/ng/mm/cache/";
$file = $directoryCache . basename($_FILES["FileToUpload"]["name"]);
$allowed = array('image/jpeg','image/png' ,'image/gif', 'image/x-icon', 'image/bmp');
$counter = 0;
for($i = 0; $i <= sizeof($allowed) - 1; $i++){
if($_FILES["FileToUpload"]["type"] == $allowed[$i]){
if(move_uploaded_file($_FILES["FileToUpload"]["tmp_name"], $file)){
if(!mkdir($directoryFile, 0700, true)){
echo "<h2>Das erstellen des Ordners schlug fehl!</h2>";
}
else{
echo "<h2>Level erfolgreich hochgeladen!</h2>";
$levelidfFile = fopen($directoryFile . "levelID.txt", "w");
fwrite($levelidfFile, $levelID);
fclose($levelidfFile);
$descriptionFile = fopen($directoryFile . "description.txt", "w");
fwrite($descriptionFile, $description);
fclose($descriptionFile);
$creatorFile = fopen($directoryFile . "creator.txt", "w");
fwrite($creatorFile, $levelCreator);
fclose($creatorFile);
rename($directoryCache . $_FILES["FileToUpload"]["name"], $directoryFile . "thumbnail.png");
echo "Level ID: " . $levelID . " Beschreibung " . $description . " DateiName: " . $_FILES["FileToUpload"]["name"];
break;
}
}
else{
echo "<h2>Du hast kein Level-Thumbnail hochgeladen!</h2>";
}
}
else{
$counter++;
if($counter == sizeof($allowed) - 1){
echo "<h2>Lade ein Bild/GIF hoch, keine andere Dateien!";
}
}
}
?>
I added in this code
$creatorFile = fopen($directoryFile . "creator.txt", "w");
fwrite($creatorFile, $levelCreator);
fclose($creatorFile);
and:
<body>
<form method="post" action="mm.php" enctype="multipart/form-data">
<input type="file" name="FileToUpload"> <br>
<input type="text" name="creator" placeholder="Level-Creator.."> **ADDED** <br>
<input type="text" name="levelid" placeholder="Level-ID.."> <br>
<input type="text" name="description" placeholder="Beschreibung.."> <br>
<input type="submit" value="Verschicken">
</form>
</body>
Moreover here is a pastebin link with my php error log: https://pastebin.com/f96LyNrZ
I really appreciate any help!
Edit 3:
I've found out how to make the error directly display on my site, and this is the result:
Warning: Unknown: open_basedir restriction in effect. File(/var/www/html/ng/mm/index.php) is not within the allowed path(s): (1) in Unknown on line 0
Warning: Unknown: failed to open stream: Operation not permitted in Unknown on line 0
Fatal error: Unknown: Failed opening required '/var/www/html/ng/mm/index.php' (include_path='.:/usr/share/php') in Unknown on line 0
In my php.ini open_basedir is on:
open_basedir = On
Edit 4:
I tested my script on my Raspberry Pi B+ and it works perfectly fine, so this script wasn't the problem why my whole php gives now this problem..
So I looked at my php.ini and then I saw that open_basedir should be commented, but I and really IDIOT doesn't knowed that I should restart apache2 that my server will use the new save...
Thanks to anyone who was helping me!