Error:
The file temp/71076cc.php is not writable
Code (compiler.php):
$random = substr(md5(mt_rand()), 0, 7);
$filePath = "temp/" . $random . ".php";
if (is_writable($filePath)) {
if (!$fp = fopen($filePath, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
if (fwrite($fp, $code) === FALSE) {
echo "Cannot write to file ($filePath)";
exit;
}
echo "Success, wrote ($code) to file ($filePath)";
fclose($fp);
} else {
echo "The file $filePath is not writable";
}
Dir structure of ide
directory inside which is inside /var/www/html
:
.
├── app
│ ├── compiler.php
│ ├── temp
│ │ ├── a9211d0.php
│ │ └── c7d561e.php
│ └── test.php
└── ui
├── css
│ └── style.css
├── ide.html
└── js
├── ide.js
└── lib
Things I tried:
- Changing ownership to
www-data
:
sudo chown -R www-data:www-data /var/www/html/ide/
- Changing permission to directory:
sudo chmod -R 777 /var/www/html/ide/
- Changing user which apache uses (in /etc/apache2/envvars):
export APACHE_RUN_USER=ubuntu
export APACHE_RUN_GROUP=ubuntu
as well as
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
(Both doesnt work)
Kindly suggest any more tweaks to try.
Note:
Currently two files which are seen in temp folder was not made by running compiler.php
code. They were made manually. However compiler.php will create such files when called from webserver.