From 5d61b85a1dace6ebb41025deaad019af8b3e5145 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Wed, 4 Jul 2012 17:16:02 +0200 Subject: [PATCH] allow users to upload ssl root certificates for the webdav client --- .../ajax/addRootCertificate.php | 12 +++++++++ .../ajax/removeRootCertificate.php | 9 +++++++ apps/files_external/js/settings.js | 10 +++++--- apps/files_external/lib/config.php | 15 +++++++++++ apps/files_external/personal.php | 1 + apps/files_external/templates/settings.php | 25 +++++++++++++++++-- 6 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 apps/files_external/ajax/addRootCertificate.php create mode 100644 apps/files_external/ajax/removeRootCertificate.php diff --git a/apps/files_external/ajax/addRootCertificate.php b/apps/files_external/ajax/addRootCertificate.php new file mode 100644 index 0000000000..33cd64d2c7 --- /dev/null +++ b/apps/files_external/ajax/addRootCertificate.php @@ -0,0 +1,12 @@ +getAbsolutePath("").$_FILES['rootcert_import']['name']; +move_uploaded_file($from, $to); + +header("Location: settings/personal.php"); +exit; +?> \ No newline at end of file diff --git a/apps/files_external/ajax/removeRootCertificate.php b/apps/files_external/ajax/removeRootCertificate.php new file mode 100644 index 0000000000..05f2fdef2d --- /dev/null +++ b/apps/files_external/ajax/removeRootCertificate.php @@ -0,0 +1,9 @@ +getAbsolutePath("").$cert; +unlink($file); +?> \ No newline at end of file diff --git a/apps/files_external/js/settings.js b/apps/files_external/js/settings.js index 1c366a79c7..0d942e7845 100644 --- a/apps/files_external/js/settings.js +++ b/apps/files_external/js/settings.js @@ -1,4 +1,4 @@ -OC.MountConfig={ +OC.MountConfig={ saveStorage:function(tr) { var mountPoint = $(tr).find('.mountPoint input').val(); if (mountPoint == '') { @@ -68,7 +68,6 @@ OC.MountConfig={ } $(document).ready(function() { - $('.chzn-select').chosen(); $('#selectBackend').live('change', function() { @@ -116,8 +115,11 @@ $(document).ready(function() { $('td.remove>img').live('click', function() { var tr = $(this).parent().parent(); var mountPoint = $(tr).find('.mountPoint input').val(); - if (mountPoint == '') { - return false; + if (!mountPoint) { + var row=this.parentNode.parentNode; + $.post(OC.filePath('files_external', 'ajax', 'removeRootCertificate.php'), { cert: row.id }); + $(tr).remove(); + return true; } if ($('#externalStorage').data('admin') === true) { var isPersonal = false; diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index 95f8beeb49..4e82e6b254 100755 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -237,6 +237,21 @@ class OC_Mount_Config { $content .= ");\n?>"; @file_put_contents($file, $content); } + + /** + * Returns all user uploaded ssl root certificates + * @return array + */ + public static function getCertificates() { + $view = \OCP\Files::getStorage('files_external'); + $path=\OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath(""); + $result = array(); + $handle = opendir($path); + while (false !== ($file = readdir($handle))) { + if($file != '.' && $file != '..') $result[] = $file; + } + return $result; + } } diff --git a/apps/files_external/personal.php b/apps/files_external/personal.php index b758e7e7eb..dec501741b 100755 --- a/apps/files_external/personal.php +++ b/apps/files_external/personal.php @@ -28,6 +28,7 @@ unset($backends['OC_Filestorage_Local']); $tmpl = new OCP\Template('files_external', 'settings'); $tmpl->assign('isAdminPage', false, false); $tmpl->assign('mounts', OC_Mount_Config::getPersonalMountPoints()); +$tmpl->assign('certs', OC_Mount_Config::getCertificates()); $tmpl->assign('backends', $backends); return $tmpl->fetchPage(); diff --git a/apps/files_external/templates/settings.php b/apps/files_external/templates/settings.php index e651c4574d..be86033d20 100644 --- a/apps/files_external/templates/settings.php +++ b/apps/files_external/templates/settings.php @@ -1,4 +1,4 @@ -
+
t('External Storage'); ?> '> @@ -79,6 +79,27 @@
+
+ + '> + + + + + + + + + + + + + + +
t('SSL root certificates'); ?> 
><?php echo $l->t('Delete'); ?>
+ + +
/> @@ -86,4 +107,4 @@ t('Allow users to mount their own external storage'); ?>
-
\ No newline at end of file +