check if file really exist before add/remove it

This commit is contained in:
Björn Schießle 2012-09-27 12:37:23 +02:00
parent a56f2ec183
commit aa9ffd119a
2 changed files with 12 additions and 4 deletions

View file

@ -2,6 +2,11 @@
OCP\JSON::checkAppEnabled('files_external');
if ( !($filename = $_FILES['rootcert_import']['name']) ) {
header("Location: settings/personal.php");
exit;
}
$fh = fopen($_FILES['rootcert_import']['tmp_name'], 'r');
$data = fread($fh, filesize($_FILES['rootcert_import']['tmp_name']));
fclose($fh);

View file

@ -5,7 +5,10 @@ OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
$view = \OCP\Files::getStorage("files_external");
$cert = ltrim($_POST['cert'], "/\\.");
$file = \OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath("").'uploads/'.$cert;
unlink($file);
OC_Mount_Config::createCertificateBundle();
$file = 'uploads/'.ltrim($_POST['cert'], "/\\.");
if ( $view->file_exists($file) ) {
$view->unlink($file);
OC_Mount_Config::createCertificateBundle();
}