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'); 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'); $fh = fopen($_FILES['rootcert_import']['tmp_name'], 'r');
$data = fread($fh, filesize($_FILES['rootcert_import']['tmp_name'])); $data = fread($fh, filesize($_FILES['rootcert_import']['tmp_name']));
fclose($fh); fclose($fh);

View File

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