]> source.dussan.org Git - nextcloud-server.git/commitdiff
allow users to upload ssl root certificates for the webdav client
authorBjoern Schiessle <schiessle@owncloud.com>
Wed, 4 Jul 2012 15:16:02 +0000 (17:16 +0200)
committerBjoern Schiessle <schiessle@owncloud.com>
Wed, 4 Jul 2012 15:18:36 +0000 (17:18 +0200)
apps/files_external/ajax/addRootCertificate.php [new file with mode: 0644]
apps/files_external/ajax/removeRootCertificate.php [new file with mode: 0644]
apps/files_external/js/settings.js
apps/files_external/lib/config.php
apps/files_external/personal.php
apps/files_external/templates/settings.php

diff --git a/apps/files_external/ajax/addRootCertificate.php b/apps/files_external/ajax/addRootCertificate.php
new file mode 100644 (file)
index 0000000..33cd64d
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+
+OCP\JSON::checkAppEnabled('files_external');
+
+$view = \OCP\Files::getStorage("files_external");
+$from = $_FILES['rootcert_import']['tmp_name'];
+$to = \OCP\Config::getSystemValue('datadirectory').$view->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 (file)
index 0000000..05f2fde
--- /dev/null
@@ -0,0 +1,9 @@
+<?php
+
+OCP\JSON::checkAppEnabled('files_external');
+
+$view = \OCP\Files::getStorage("files_external");
+$cert = $_POST['cert'];
+$file = \OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath("").$cert;
+unlink($file);
+?>
\ No newline at end of file
index 1c366a79c7a63e0d6d19d7897a4f461c44ba0072..0d942e7845b85fa457a8b29ae1441df90f6d03b0 100644 (file)
@@ -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;
index 95f8beeb49e0d78bbbcc7b87a3721148f1e7552c..4e82e6b254859fd92911e25266e4e971055a6e09 100755 (executable)
@@ -237,6 +237,21 @@ class OC_Mount_Config {
                $content .= ");\n?>";
                @file_put_contents($file, $content);
        }
+       
+       /**\r
+        * Returns all user uploaded ssl root certificates\r
+        * @return array\r
+        */\r
+       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;
+       }
 
 }
 
index b758e7e7eb089cfb9179f3cca4fa7d0affffe4f2..dec501741b608736d48814950f7afc56e394fdd2 100755 (executable)
@@ -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();
 
index e651c4574d70729ca96e4d8d6d1d21e542527126..be86033d208371409a97792ed89b515f329affbe 100644 (file)
@@ -1,4 +1,4 @@
-<form id="files_external">
+<form id="files_external" method="post" enctype="multipart/form-data" action="/owncloud/?app=files_external&getfile=ajax%2FaddRootCertificate.php">
        <fieldset class="personalblock">
        <legend><strong><?php echo $l->t('External Storage'); ?></strong></legend>
                <table id="externalStorage" data-admin='<?php echo json_encode($_['isAdminPage']); ?>'>
                        <?php endforeach; ?>
                        </tbody>
                </table>
+               <br />
+               
+               <table id="sslCertificate" data-admin='<?php echo json_encode($_['isAdminPage']); ?>'>
+                       <thead>
+                               <tr>
+                                       <th><?php echo $l->t('SSL root certificates'); ?></th>
+                                       <th>&nbsp;</th>
+                               </tr>
+                       </thead>
+                       <tbody width="100%">
+                       <?php foreach ($_['certs'] as $rootCert): ?>
+                       <tr id="<?php echo $rootCert ?>">       
+                       <td class="rootCert"><?php echo $rootCert ?></td>
+                       <td <?php echo ($rootCert != '') ? 'class="remove"' : 'style="visibility:hidden;"'; ?>><img alt="<?php echo $l->t('Delete'); ?>" title="<?php echo $l->t('Delete'); ?>" class="svg action" src="<?php echo image_path('core', 'actions/delete.svg'); ?>" /></td>
+                       </tr>
+                       <?php endforeach; ?>
+                       </tbody>
+               </table>                
+        <input type="file" id="rootcert_import" name="rootcert_import" style="width:230px;">
+        <input type="submit" name="cert_import" value="<?php echo $l->t('Import Root Certificate'); ?>" />             
+               
                <?php if ($_['isAdminPage']): ?>
                        <br />
                        <input type="checkbox" name="allowUserMounting" id="allowUserMounting" value="1" <?php if ($_['allowUserMounting'] == 'yes') echo ' checked="checked"'; ?> />
                        <em><?php echo $l->t('Allow users to mount their own external storage'); ?></em>
                <?php endif; ?>
        </fieldset>
-</form>
\ No newline at end of file
+</form>