summaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/config.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/lib/config.php')
-rwxr-xr-xapps/files_external/lib/config.php54
1 files changed, 21 insertions, 33 deletions
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php
index 2f3dbf10691..5e2fd32596a 100755
--- a/apps/files_external/lib/config.php
+++ b/apps/files_external/lib/config.php
@@ -302,13 +302,21 @@ class OC_Mount_Config {
* @return array
*/
private static function readData($isPersonal) {
+ $parser = new \OC\ArrayParser();
if ($isPersonal) {
- $file = OC_User::getHome(OCP\User::getUser()).'/mount.php';
+ $phpFile = OC_User::getHome(OCP\User::getUser()).'/mount.php';
+ $jsonFile = OC_User::getHome(OCP\User::getUser()).'/mount.json';
} else {
- $file = OC::$SERVERROOT.'/config/mount.php';
+ $phpFile = OC::$SERVERROOT.'/config/mount.php';
+ $jsonFile = OC::$SERVERROOT.'/config/mount.json';
}
- if (is_file($file)) {
- $mountPoints = include $file;
+ if (is_file($jsonFile)) {
+ $mountPoints = json_decode(file_get_contents($jsonFile), true);
+ if (is_array($mountPoints)) {
+ return $mountPoints;
+ }
+ } elseif (is_file($phpFile)) {
+ $mountPoints = $parser->parsePHP(file_get_contents($phpFile));
if (is_array($mountPoints)) {
return $mountPoints;
}
@@ -323,35 +331,11 @@ class OC_Mount_Config {
*/
private static function writeData($isPersonal, $data) {
if ($isPersonal) {
- $file = OC_User::getHome(OCP\User::getUser()).'/mount.php';
+ $file = OC_User::getHome(OCP\User::getUser()).'/mount.json';
} else {
- $file = OC::$SERVERROOT.'/config/mount.php';
- }
- $content = "<?php return array (\n";
- if (isset($data[self::MOUNT_TYPE_GROUP])) {
- $content .= "\t'group' => array (\n";
- foreach ($data[self::MOUNT_TYPE_GROUP] as $group => $mounts) {
- $content .= "\t\t'".$group."' => array (\n";
- foreach ($mounts as $mountPoint => $mount) {
- $content .= "\t\t\t'".addcslashes($mountPoint,"'")."' => ".str_replace("\n", '', var_export($mount, true)).", \n";
-
- }
- $content .= "\t\t),\n";
- }
- $content .= "\t),\n";
+ $file = OC::$SERVERROOT.'/config/mount.json';
}
- if (isset($data[self::MOUNT_TYPE_USER])) {
- $content .= "\t'user' => array (\n";
- foreach ($data[self::MOUNT_TYPE_USER] as $user => $mounts) {
- $content .= "\t\t'".$user."' => array (\n";
- foreach ($mounts as $mountPoint => $mount) {
- $content .= "\t\t\t'".addcslashes($mountPoint,"'")."' => ".str_replace("\n", '', var_export($mount, true)).",\n";
- }
- $content .= "\t\t),\n";
- }
- $content .= "\t),\n";
- }
- $content .= ");\n?>";
+ $content = json_encode($data);
@file_put_contents($file, $content);
}
@@ -433,8 +417,12 @@ class OC_Mount_Config {
public static function checkDependencies() {
$l= new OC_L10N('files_external');
$txt='';
- if(!OC_Mount_Config::checksmbclient()) $txt.=$l->t('<b>Warning:</b> "smbclient" is not installed. Mounting of CIFS/SMB shares is not possible. Please ask your system administrator to install it.').'<br />';
- if(!OC_Mount_Config::checkphpftp()) $txt.=$l->t('<b>Warning:</b> The FTP support in PHP is not enabled or installed. Mounting of FTP shares is not possible. Please ask your system administrator to install it.').'<br />';
+ if(!OC_Mount_Config::checksmbclient()) {
+ $txt.=$l->t('<b>Warning:</b> "smbclient" is not installed. Mounting of CIFS/SMB shares is not possible. Please ask your system administrator to install it.').'<br />';
+ }
+ if(!OC_Mount_Config::checkphpftp()) {
+ $txt.=$l->t('<b>Warning:</b> The FTP support in PHP is not enabled or installed. Mounting of FTP shares is not possible. Please ask your system administrator to install it.').'<br />';
+ }
return($txt);
}