From 7a62fbd205874355abb3b551b182bc61b9c3d3e1 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 10 May 2017 14:12:58 +0200 Subject: [PATCH] Fix comparisons in the files external app Signed-off-by: Joas Schilling --- apps/files_external/ajax/oauth2.php | 6 +++--- apps/files_external/lib/Command/Import.php | 4 ++-- apps/files_external/lib/Lib/Storage/Dropbox.php | 8 ++++---- apps/files_external/lib/Lib/Storage/FTP.php | 2 +- apps/files_external/lib/Lib/Storage/OwnCloud.php | 4 ++-- apps/files_external/lib/Lib/Storage/SFTP.php | 14 +++++++------- apps/files_external/lib/Lib/Storage/SMB.php | 4 ++-- apps/files_external/lib/Lib/Storage/Swift.php | 4 ++-- apps/files_external/templates/settings.php | 6 +++--- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/apps/files_external/ajax/oauth2.php b/apps/files_external/ajax/oauth2.php index db2570800a..8b257b77ef 100644 --- a/apps/files_external/ajax/oauth2.php +++ b/apps/files_external/ajax/oauth2.php @@ -46,8 +46,8 @@ if (isset($_POST['client_id']) && isset($_POST['client_secret']) && isset($_POST $client->setApprovalPrompt('force'); $client->setAccessType('offline'); if (isset($_POST['step'])) { - $step = $_POST['step']; - if ($step == 1) { + $step = (int) $_POST['step']; + if ($step === 1) { try { $authUrl = $client->createAuthUrl(); OCP\JSON::success(array('data' => array( @@ -58,7 +58,7 @@ if (isset($_POST['client_id']) && isset($_POST['client_secret']) && isset($_POST 'message' => $l->t('Step 1 failed. Exception: %s', array($exception->getMessage())) ))); } - } else if ($step == 2 && isset($_POST['code'])) { + } else if ($step === 2 && isset($_POST['code'])) { try { $token = $client->authenticate((string)$_POST['code']); OCP\JSON::success(array('data' => array( diff --git a/apps/files_external/lib/Command/Import.php b/apps/files_external/lib/Command/Import.php index 96afc86ba2..712a8851c8 100644 --- a/apps/files_external/lib/Command/Import.php +++ b/apps/files_external/lib/Command/Import.php @@ -161,8 +161,8 @@ class Import extends Base { if ( $existingMount->getMountPoint() === $mount->getMountPoint() && $existingMount->getApplicableGroups() === $mount->getApplicableGroups() && - $existingMount->getApplicableUsers() == $mount->getApplicableUsers() && - $existingMount->getBackendOptions() == $mount->getBackendOptions() + $existingMount->getApplicableUsers() === $mount->getApplicableUsers() && + $existingMount->getBackendOptions() === $mount->getBackendOptions() ) { $output->writeln("Duplicate mount (" . $mount->getMountPoint() . ")"); return 1; diff --git a/apps/files_external/lib/Lib/Storage/Dropbox.php b/apps/files_external/lib/Lib/Storage/Dropbox.php index d2ba1cca75..fad85650e9 100644 --- a/apps/files_external/lib/Lib/Storage/Dropbox.php +++ b/apps/files_external/lib/Lib/Storage/Dropbox.php @@ -47,7 +47,7 @@ class Dropbox extends \OC\Files\Storage\Common { private $oauth; public function __construct($params) { - if (isset($params['configured']) && $params['configured'] == 'true' + if (isset($params['configured']) && $params['configured'] === 'true' && isset($params['app_key']) && isset($params['app_secret']) && isset($params['token']) @@ -187,12 +187,12 @@ class Dropbox extends \OC\Files\Storage\Common { } public function filetype($path) { - if ($path == '' || $path == '/') { + if ($path === '' || $path === '/') { return 'dir'; } else { $metaData = $this->getDropBoxMetaData($path); if ($metaData) { - if ($metaData['is_dir'] == 'true') { + if ($metaData['is_dir'] === 'true') { return 'dir'; } else { return 'file'; @@ -203,7 +203,7 @@ class Dropbox extends \OC\Files\Storage\Common { } public function file_exists($path) { - if ($path == '' || $path == '/') { + if ($path === '' || $path === '/') { return true; } if ($this->getDropBoxMetaData($path)) { diff --git a/apps/files_external/lib/Lib/Storage/FTP.php b/apps/files_external/lib/Lib/Storage/FTP.php index 22fe2090f3..1bbdfaba46 100644 --- a/apps/files_external/lib/Lib/Storage/FTP.php +++ b/apps/files_external/lib/Lib/Storage/FTP.php @@ -56,7 +56,7 @@ class FTP extends StreamWrapper{ $this->secure = false; } $this->root=isset($params['root'])?$params['root']:'/'; - if ( ! $this->root || $this->root[0]!='/') { + if ( ! $this->root || $this->root[0]!=='/') { $this->root='/'.$this->root; } if (substr($this->root, -1) !== '/') { diff --git a/apps/files_external/lib/Lib/Storage/OwnCloud.php b/apps/files_external/lib/Lib/Storage/OwnCloud.php index 9669b5f3da..34838b9891 100644 --- a/apps/files_external/lib/Lib/Storage/OwnCloud.php +++ b/apps/files_external/lib/Lib/Storage/OwnCloud.php @@ -40,10 +40,10 @@ class OwnCloud extends \OC\Files\Storage\DAV{ // (owncloud install path on host) $host = $params['host']; // strip protocol - if (substr($host, 0, 8) == "https://") { + if (substr($host, 0, 8) === "https://") { $host = substr($host, 8); $params['secure'] = true; - } else if (substr($host, 0, 7) == "http://") { + } else if (substr($host, 0, 7) === "http://") { $host = substr($host, 7); $params['secure'] = false; } diff --git a/apps/files_external/lib/Lib/Storage/SFTP.php b/apps/files_external/lib/Lib/Storage/SFTP.php index a4dfea94bf..8d48955126 100644 --- a/apps/files_external/lib/Lib/Storage/SFTP.php +++ b/apps/files_external/lib/Lib/Storage/SFTP.php @@ -102,11 +102,11 @@ class SFTP extends \OC\Files\Storage\Common { $this->root = isset($params['root']) ? $this->cleanPath($params['root']) : '/'; - if ($this->root[0] != '/') { + if ($this->root[0] !== '/') { $this->root = '/' . $this->root; } - if (substr($this->root, -1, 1) != '/') { + if (substr($this->root, -1, 1) !== '/') { $this->root .= '/'; } } @@ -128,7 +128,7 @@ class SFTP extends \OC\Files\Storage\Common { // The SSH Host Key MUST be verified before login(). $currentHostKey = $this->client->getServerPublicHostKey(); if (array_key_exists($this->host, $hostKeys)) { - if ($hostKeys[$this->host] != $currentHostKey) { + if ($hostKeys[$this->host] !== $currentHostKey) { throw new \Exception('Host public key does not match known key'); } } else { @@ -248,7 +248,7 @@ class SFTP extends \OC\Files\Storage\Common { if ($lines) { foreach ($lines as $line) { $hostKeyArray = explode("::", $line, 2); - if (count($hostKeyArray) == 2) { + if (count($hostKeyArray) === 2) { $hosts[] = $hostKeyArray[0]; $keys[] = $hostKeyArray[1]; } @@ -300,7 +300,7 @@ class SFTP extends \OC\Files\Storage\Common { $id = md5('sftp:' . $path); $dirStream = array(); foreach($list as $file) { - if ($file != '.' && $file != '..') { + if ($file !== '.' && $file !== '..') { $dirStream[] = $file; } } @@ -316,11 +316,11 @@ class SFTP extends \OC\Files\Storage\Common { public function filetype($path) { try { $stat = $this->getConnection()->stat($this->absPath($path)); - if ($stat['type'] == NET_SFTP_TYPE_REGULAR) { + if ((int) $stat['type'] === NET_SFTP_TYPE_REGULAR) { return 'file'; } - if ($stat['type'] == NET_SFTP_TYPE_DIRECTORY) { + if ((int) $stat['type'] === NET_SFTP_TYPE_DIRECTORY) { return 'dir'; } } catch (\Exception $e) { diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php index 7afdb746a9..4af6df5d84 100644 --- a/apps/files_external/lib/Lib/Storage/SMB.php +++ b/apps/files_external/lib/Lib/Storage/SMB.php @@ -81,10 +81,10 @@ class SMB extends Common implements INotifyStorage { $this->share = $this->server->getShare(trim($params['share'], '/')); $this->root = isset($params['root']) ? $params['root'] : '/'; - if (!$this->root || $this->root[0] != '/') { + if (!$this->root || $this->root[0] !== '/') { $this->root = '/' . $this->root; } - if (substr($this->root, -1, 1) != '/') { + if (substr($this->root, -1, 1) !== '/') { $this->root .= '/'; } } else { diff --git a/apps/files_external/lib/Lib/Storage/Swift.php b/apps/files_external/lib/Lib/Storage/Swift.php index db5b5bf6d9..57df4aa01a 100644 --- a/apps/files_external/lib/Lib/Storage/Swift.php +++ b/apps/files_external/lib/Lib/Storage/Swift.php @@ -435,7 +435,7 @@ class Swift extends \OC\Files\Storage\Common { } $metadata = array('timestamp' => $mtime); if ($this->file_exists($path)) { - if ($this->is_dir($path) && $path != '.') { + if ($this->is_dir($path) && $path !== '.') { $path .= '/'; } @@ -640,7 +640,7 @@ class Swift extends \OC\Files\Storage\Common { }, $cachedContent); sort($cachedNames); sort($content); - return $cachedNames != $content; + return $cachedNames !== $content; } /** diff --git a/apps/files_external/templates/settings.php b/apps/files_external/templates/settings.php index e463a0d3c3..1d703e0c1b 100644 --- a/apps/files_external/templates/settings.php +++ b/apps/files_external/templates/settings.php @@ -89,7 +89,7 @@

t('External storages')); ?>

- '') and $canCreateMounts) print_unescaped(''.$_['dependencies'].''); ?> + '> @@ -169,10 +169,10 @@ /> + value="1" /> -

class="hidden"> +

class="hidden"> t('Allow users to mount the following external storage')); ?>