From 0dbf1d02600ef4075ceffe9c62c1ed32cc24592f Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Mon, 24 Dec 2012 13:45:52 -0500 Subject: Show status icons for mount points in external storage UI --- apps/files_external/lib/amazons3.php | 14 +++++-- apps/files_external/lib/config.php | 37 +++++++++++++---- apps/files_external/lib/dropbox.php | 5 ++- apps/files_external/lib/ftp.php | 41 +++++++++++-------- apps/files_external/lib/google.php | 4 ++ apps/files_external/lib/smb.php | 50 +++++++++++++---------- apps/files_external/lib/swift.php | 45 +++++++++++---------- apps/files_external/lib/webdav.php | 77 ++++++++++++++++++++---------------- 8 files changed, 171 insertions(+), 102 deletions(-) (limited to 'apps/files_external/lib') diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php index 235ade06db6..c1b2e889bba 100644 --- a/apps/files_external/lib/amazons3.php +++ b/apps/files_external/lib/amazons3.php @@ -30,11 +30,19 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common { private static $tempFiles = array(); - // TODO options: storage class, encryption server side, encrypt before upload? + // TODO Update to new AWS SDK public function __construct($params) { - $this->s3 = new AmazonS3(array('key' => $params['key'], 'secret' => $params['secret'])); - $this->bucket = $params['bucket']; + if (isset($params['key']) && isset($params['secret']) && isset($params['bucket'])) { + $this->s3 = new AmazonS3(array('key' => $params['key'], 'secret' => $params['secret'])); + $this->bucket = $params['bucket']; + $test = $this->s3->get_canonical_user_id(); + if (!isset($test['id']) || $test['id'] == '') { + throw new Exception(); + } + } else { + throw new Exception(); + } } private function getObject($path) { diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index 1be544fbc07..99d31c5aa2d 100755 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -131,7 +131,9 @@ class OC_Mount_Config { 'class' => $mount['class'], 'backend' => $backends[$mount['class']]['backend'], 'configuration' => $mount['options'], - 'applicable' => array('groups' => array($group), 'users' => array())); + 'applicable' => array('groups' => array($group), 'users' => array()), + 'status' => self::getBackendStatus($mount['class'], $mount['options']) + ); } } } @@ -146,10 +148,13 @@ class OC_Mount_Config { $system[$mountPoint]['applicable']['users'] = array_merge($system[$mountPoint]['applicable']['users'], array($user)); } else { - $system[$mountPoint] = array('class' => $mount['class'], + $system[$mountPoint] = array( + 'class' => $mount['class'], 'backend' => $backends[$mount['class']]['backend'], 'configuration' => $mount['options'], - 'applicable' => array('groups' => array(), 'users' => array($user))); + 'applicable' => array('groups' => array(), 'users' => array($user)), + 'status' => self::getBackendStatus($mount['class'], $mount['options']) + ); } } } @@ -170,14 +175,32 @@ class OC_Mount_Config { if (isset($mountPoints[self::MOUNT_TYPE_USER][$uid])) { foreach ($mountPoints[self::MOUNT_TYPE_USER][$uid] as $mountPoint => $mount) { // Remove '/uid/files/' from mount point - $personal[substr($mountPoint, strlen($uid) + 8)] = array('class' => $mount['class'], - 'backend' => $backends[$mount['class']]['backend'], - 'configuration' => $mount['options']); + $personal[substr($mountPoint, strlen($uid) + 8)] = array( + 'class' => $mount['class'], + 'backend' => $backends[$mount['class']]['backend'], + 'configuration' => $mount['options'], + 'status' => self::getBackendStatus($mount['class'], $mount['options']) + ); } } return $personal; } + private static function getBackendStatus($class, $options) { + foreach ($options as &$option) { + $option = str_replace('$user', OCP\User::getUser(), $option); + } + if (class_exists($class)) { + try { + new $class($options); + return true; + } catch (Exception $exception) { + return false; + } + } + return false; + } + /** * Add directory for mount point to the filesystem * @param OC_Fileview instance $view @@ -259,7 +282,7 @@ class OC_Mount_Config { $mountPoints[$mountType] = $mount; } self::writeData($isPersonal, $mountPoints); - return true; + return self::getBackendStatus($class, $classOptions); } /** diff --git a/apps/files_external/lib/dropbox.php b/apps/files_external/lib/dropbox.php index 33ca14cab15..a4f3f678344 100755 --- a/apps/files_external/lib/dropbox.php +++ b/apps/files_external/lib/dropbox.php @@ -41,7 +41,10 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common { $oauth = new Dropbox_OAuth_Curl($params['app_key'], $params['app_secret']); $oauth->setToken($params['token'], $params['token_secret']); $this->dropbox = new Dropbox_API($oauth, 'dropbox'); - $this->mkdir(''); + $test = $this->stat(''); + if (!$test) { + throw new Exception('Creating OC_Filestorage_Dropbox storage failed'); + } } else { throw new Exception('Creating OC_Filestorage_Dropbox storage failed'); } diff --git a/apps/files_external/lib/ftp.php b/apps/files_external/lib/ftp.php index e796ae446bf..ac487156c18 100644 --- a/apps/files_external/lib/ftp.php +++ b/apps/files_external/lib/ftp.php @@ -16,26 +16,35 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{ private static $tempFiles=array(); public function __construct($params) { - $this->host=$params['host']; - $this->user=$params['user']; - $this->password=$params['password']; - if (isset($params['secure'])) { - if (is_string($params['secure'])) { - $this->secure = ($params['secure'] === 'true'); + if (isset($params['host']) && isset($params['user']) && isset($params['password'])) { + $this->host=$params['host']; + $this->user=$params['user']; + $this->password=$params['password']; + if (isset($params['secure'])) { + if (is_string($params['secure'])) { + $this->secure = ($params['secure'] === 'true'); + } else { + $this->secure = (bool)$params['secure']; + } } else { - $this->secure = (bool)$params['secure']; + $this->secure = false; + } + $this->root=isset($params['root'])?$params['root']:'/'; + if ( ! $this->root || $this->root[0]!='/') { + $this->root='/'.$this->root; + } + $test = $this->stat(''); + if (!$test) { + throw new Exception(); + } + //create the root folder if necesary + if ( ! $this->is_dir('')) { + $this->mkdir(''); } } else { - $this->secure = false; - } - $this->root=isset($params['root'])?$params['root']:'/'; - if ( ! $this->root || $this->root[0]!='/') { - $this->root='/'.$this->root; - } - //create the root folder if necesary - if ( ! $this->is_dir('')) { - $this->mkdir(''); + throw new Exception(); } + } /** diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php index c836a5a07c0..19772d4d37f 100644 --- a/apps/files_external/lib/google.php +++ b/apps/files_external/lib/google.php @@ -42,6 +42,10 @@ class OC_Filestorage_Google extends OC_Filestorage_Common { $this->oauth_token = new OAuthToken($params['token'], $params['token_secret']); $this->sig_method = new OAuthSignatureMethod_HMAC_SHA1(); $this->entries = array(); + $test = $this->free_space(''); + if (!$test) { + throw new Exception(); + } } else { throw new Exception('Creating OC_Filestorage_Google storage failed'); } diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php index 071a9cd5f95..97454b46015 100644 --- a/apps/files_external/lib/smb.php +++ b/apps/files_external/lib/smb.php @@ -16,28 +16,36 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{ private $share; public function __construct($params) { - $this->host=$params['host']; - $this->user=$params['user']; - $this->password=$params['password']; - $this->share=$params['share']; - $this->root=isset($params['root'])?$params['root']:'/'; - if ( ! $this->root || $this->root[0]!='/') { - $this->root='/'.$this->root; - } - if (substr($this->root, -1, 1)!='/') { - $this->root.='/'; - } - if ( ! $this->share || $this->share[0]!='/') { - $this->share='/'.$this->share; - } - if (substr($this->share, -1, 1)=='/') { - $this->share=substr($this->share, 0, -1); - } - - //create the root folder if necesary - if ( ! $this->is_dir('')) { - $this->mkdir(''); + if (isset($params['host']) && isset($params['user']) && isset($params['password']) && isset($params['share'])) { + $this->host=$params['host']; + $this->user=$params['user']; + $this->password=$params['password']; + $this->share=$params['share']; + $this->root=isset($params['root'])?$params['root']:'/'; + if ( ! $this->root || $this->root[0]!='/') { + $this->root='/'.$this->root; + } + if (substr($this->root, -1, 1)!='/') { + $this->root.='/'; + } + if ( ! $this->share || $this->share[0]!='/') { + $this->share='/'.$this->share; + } + if (substr($this->share, -1, 1)=='/') { + $this->share=substr($this->share, 0, -1); + } + $test = $this->stat(''); + if (!$test) { + throw new Exception(); + } + //create the root folder if necesary + if ( ! $this->is_dir('')) { + $this->mkdir(''); + } + } else { + throw new Exception(); } + } public function constructUrl($path) { diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php index a071dfdbb03..e2add2c9873 100644 --- a/apps/files_external/lib/swift.php +++ b/apps/files_external/lib/swift.php @@ -267,32 +267,37 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ } public function __construct($params) { - $this->token=$params['token']; - $this->host=$params['host']; - $this->user=$params['user']; - $this->root=isset($params['root'])?$params['root']:'/'; - if (isset($params['secure'])) { - if (is_string($params['secure'])) { - $this->secure = ($params['secure'] === 'true'); + if (isset($params['token']) && isset($params['host']) && isset($params['user'])) { + $this->token=$params['token']; + $this->host=$params['host']; + $this->user=$params['user']; + $this->root=isset($params['root'])?$params['root']:'/'; + if (isset($params['secure'])) { + if (is_string($params['secure'])) { + $this->secure = ($params['secure'] === 'true'); + } else { + $this->secure = (bool)$params['secure']; + } } else { - $this->secure = (bool)$params['secure']; + $this->secure = false; } - } else { - $this->secure = false; - } - if ( ! $this->root || $this->root[0]!='/') { - $this->root='/'.$this->root; - } - $this->auth = new CF_Authentication($this->user, $this->token, null, $this->host); - $this->auth->authenticate(); + if ( ! $this->root || $this->root[0]!='/') { + $this->root='/'.$this->root; + } + $this->auth = new CF_Authentication($this->user, $this->token, null, $this->host); + $this->auth->authenticate(); - $this->conn = new CF_Connection($this->auth); + $this->conn = new CF_Connection($this->auth); - if ( ! $this->containerExists('/')) { - $this->rootContainer=$this->createContainer('/'); + if ( ! $this->containerExists('/')) { + $this->rootContainer=$this->createContainer('/'); + } else { + $this->rootContainer=$this->getContainer('/'); + } } else { - $this->rootContainer=$this->getContainer('/'); + throw new Exception(); } + } diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index 68aca228bc5..cfe073a1f1c 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -20,47 +20,56 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ private static $tempFiles=array(); public function __construct($params) { - $host = $params['host']; - //remove leading http[s], will be generated in createBaseUri() - if (substr($host, 0, 8) == "https://") $host = substr($host, 8); - else if (substr($host, 0, 7) == "http://") $host = substr($host, 7); - $this->host=$host; - $this->user=$params['user']; - $this->password=$params['password']; - if (isset($params['secure'])) { - if (is_string($params['secure'])) { - $this->secure = ($params['secure'] === 'true'); + if (isset($params['host']) && isset($params['user']) && isset($params['password'])) { + $host = $params['host']; + //remove leading http[s], will be generated in createBaseUri() + if (substr($host, 0, 8) == "https://") $host = substr($host, 8); + else if (substr($host, 0, 7) == "http://") $host = substr($host, 7); + $this->host=$host; + $this->user=$params['user']; + $this->password=$params['password']; + if (isset($params['secure'])) { + if (is_string($params['secure'])) { + $this->secure = ($params['secure'] === 'true'); + } else { + $this->secure = (bool)$params['secure']; + } } else { - $this->secure = (bool)$params['secure']; + $this->secure = false; + } + $this->root=isset($params['root'])?$params['root']:'/'; + if ( ! $this->root || $this->root[0]!='/') { + $this->root='/'.$this->root; + } + if (substr($this->root, -1, 1)!='/') { + $this->root.='/'; } - } else { - $this->secure = false; - } - $this->root=isset($params['root'])?$params['root']:'/'; - if ( ! $this->root || $this->root[0]!='/') { - $this->root='/'.$this->root; - } - if (substr($this->root, -1, 1)!='/') { - $this->root.='/'; - } - $settings = array( - 'baseUri' => $this->createBaseUri(), - 'userName' => $this->user, - 'password' => $this->password, - ); + $settings = array( + 'baseUri' => $this->createBaseUri(), + 'userName' => $this->user, + 'password' => $this->password, + ); - $this->client = new OC_Connector_Sabre_Client($settings); + $this->client = new OC_Connector_Sabre_Client($settings); - $caview = \OCP\Files::getStorage('files_external'); - if ($caview) { - $certPath=\OCP\Config::getSystemValue('datadirectory').$caview->getAbsolutePath("").'rootcerts.crt'; - if (file_exists($certPath)) { - $this->client->addTrustedCertificates($certPath); + $caview = \OCP\Files::getStorage('files_external'); + if ($caview) { + $certPath=\OCP\Config::getSystemValue('datadirectory').$caview->getAbsolutePath("").'rootcerts.crt'; + if (file_exists($certPath)) { + $this->client->addTrustedCertificates($certPath); + } + } + $test = $this->stat(''); + if (!$test) { + throw new Exception(); } + //create the root folder if necesary + $this->mkdir(''); + } else { + throw new Exception(); } - //create the root folder if necesary - $this->mkdir(''); + } private function createBaseUri() { -- cgit v1.2.3 From ad902a9848a66135ae85a04b1c66b663219a53ea Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Fri, 28 Dec 2012 12:00:48 -0500 Subject: Move storage backend tests from constructor to test function --- apps/files_external/lib/amazons3.php | 12 ++++++++---- apps/files_external/lib/config.php | 4 ++-- apps/files_external/lib/dropbox.php | 4 ---- apps/files_external/lib/ftp.php | 4 ---- apps/files_external/lib/google.php | 11 +++++++---- apps/files_external/lib/smb.php | 4 ---- apps/files_external/lib/webdav.php | 4 ---- lib/filestorage.php | 1 + lib/filestorage/common.php | 8 ++++++++ 9 files changed, 26 insertions(+), 26 deletions(-) (limited to 'apps/files_external/lib') diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php index c1b2e889bba..5ab89df732d 100644 --- a/apps/files_external/lib/amazons3.php +++ b/apps/files_external/lib/amazons3.php @@ -36,10 +36,6 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common { if (isset($params['key']) && isset($params['secret']) && isset($params['bucket'])) { $this->s3 = new AmazonS3(array('key' => $params['key'], 'secret' => $params['secret'])); $this->bucket = $params['bucket']; - $test = $this->s3->get_canonical_user_id(); - if (!isset($test['id']) || $test['id'] == '') { - throw new Exception(); - } } else { throw new Exception(); } @@ -250,4 +246,12 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common { return $response->isOK(); } + public function test() { + $test = $this->s3->get_canonical_user_id(); + if (isset($test['id']) && $test['id'] != '') { + return true; + } + return false; + } + } diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index 99d31c5aa2d..fd654f04e98 100755 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -192,8 +192,8 @@ class OC_Mount_Config { } if (class_exists($class)) { try { - new $class($options); - return true; + $storage = new $class($options); + return $storage->test(); } catch (Exception $exception) { return false; } diff --git a/apps/files_external/lib/dropbox.php b/apps/files_external/lib/dropbox.php index a4f3f678344..66dfd3e595e 100755 --- a/apps/files_external/lib/dropbox.php +++ b/apps/files_external/lib/dropbox.php @@ -41,10 +41,6 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common { $oauth = new Dropbox_OAuth_Curl($params['app_key'], $params['app_secret']); $oauth->setToken($params['token'], $params['token_secret']); $this->dropbox = new Dropbox_API($oauth, 'dropbox'); - $test = $this->stat(''); - if (!$test) { - throw new Exception('Creating OC_Filestorage_Dropbox storage failed'); - } } else { throw new Exception('Creating OC_Filestorage_Dropbox storage failed'); } diff --git a/apps/files_external/lib/ftp.php b/apps/files_external/lib/ftp.php index ac487156c18..ca408d5d224 100644 --- a/apps/files_external/lib/ftp.php +++ b/apps/files_external/lib/ftp.php @@ -33,10 +33,6 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{ if ( ! $this->root || $this->root[0]!='/') { $this->root='/'.$this->root; } - $test = $this->stat(''); - if (!$test) { - throw new Exception(); - } //create the root folder if necesary if ( ! $this->is_dir('')) { $this->mkdir(''); diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php index 19772d4d37f..8710c979117 100644 --- a/apps/files_external/lib/google.php +++ b/apps/files_external/lib/google.php @@ -42,10 +42,6 @@ class OC_Filestorage_Google extends OC_Filestorage_Common { $this->oauth_token = new OAuthToken($params['token'], $params['token_secret']); $this->sig_method = new OAuthSignatureMethod_HMAC_SHA1(); $this->entries = array(); - $test = $this->free_space(''); - if (!$test) { - throw new Exception(); - } } else { throw new Exception('Creating OC_Filestorage_Google storage failed'); } @@ -594,4 +590,11 @@ class OC_Filestorage_Google extends OC_Filestorage_Common { } + public function test() { + if ($this->free_space('')) { + return true; + } + return false; + } + } \ No newline at end of file diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php index 97454b46015..5b73e993e4f 100644 --- a/apps/files_external/lib/smb.php +++ b/apps/files_external/lib/smb.php @@ -34,10 +34,6 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{ if (substr($this->share, -1, 1)=='/') { $this->share=substr($this->share, 0, -1); } - $test = $this->stat(''); - if (!$test) { - throw new Exception(); - } //create the root folder if necesary if ( ! $this->is_dir('')) { $this->mkdir(''); diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index cfe073a1f1c..31d36f1e78b 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -60,10 +60,6 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ $this->client->addTrustedCertificates($certPath); } } - $test = $this->stat(''); - if (!$test) { - throw new Exception(); - } //create the root folder if necesary $this->mkdir(''); } else { diff --git a/lib/filestorage.php b/lib/filestorage.php index dd65f4421b7..9d42c0bcb60 100644 --- a/lib/filestorage.php +++ b/lib/filestorage.php @@ -64,4 +64,5 @@ abstract class OC_Filestorage{ */ abstract public function hasUpdated($path, $time); abstract public function getOwner($path); + abstract public function test(); } diff --git a/lib/filestorage/common.php b/lib/filestorage/common.php index b97eb79d8d4..e2af0c6d7f4 100644 --- a/lib/filestorage/common.php +++ b/lib/filestorage/common.php @@ -288,4 +288,12 @@ abstract class OC_Filestorage_Common extends OC_Filestorage { public function getOwner($path) { return OC_User::getUser(); } + + public function test() { + if ($this->stat('')) { + return true; + } + return false; + } + } -- cgit v1.2.3 From 646d60ee83168169050271ee9d5442e2dc626e8a Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Tue, 12 Feb 2013 11:00:38 +0100 Subject: fixing namespace --- apps/files_external/lib/amazons3.php | 2 +- apps/files_external/lib/ftp.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'apps/files_external/lib') diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php index 3800a14c37c..d00e9a08231 100644 --- a/apps/files_external/lib/amazons3.php +++ b/apps/files_external/lib/amazons3.php @@ -41,7 +41,7 @@ class AmazonS3 extends \OC\Files\Storage\Common { $this->s3 = new \AmazonS3(array('key' => $params['key'], 'secret' => $params['secret'])); $this->bucket = $params['bucket']; } else { - throw new Exception(); + throw new \Exception(); } } diff --git a/apps/files_external/lib/ftp.php b/apps/files_external/lib/ftp.php index a76a3dc80f8..fa8698af7ac 100644 --- a/apps/files_external/lib/ftp.php +++ b/apps/files_external/lib/ftp.php @@ -35,7 +35,7 @@ class FTP extends \OC\Files\Storage\StreamWrapper{ if ( ! $this->root || $this->root[0]!='/') { $this->root='/'.$this->root; } - //create the root folder if necesary + //create the root folder if necessary if ( ! $this->is_dir('')) { $this->mkdir(''); } @@ -88,7 +88,7 @@ class FTP extends \OC\Files\Storage\StreamWrapper{ } else { $ext=''; } - $tmpFile=OCP\Files::tmpFile($ext); + $tmpFile=\OCP\Files::tmpFile($ext); \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack')); if ($this->file_exists($path)) { $this->getFile($path, $tmpFile); -- cgit v1.2.3 From 6b594c1eb84dccb57c5050f9d686734c98cc6d39 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Tue, 12 Feb 2013 11:05:12 +0100 Subject: fixing namespace --- apps/files_external/lib/swift.php | 2 +- apps/files_external/lib/webdav.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'apps/files_external/lib') diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php index bab49524746..20af67cb8b6 100644 --- a/apps/files_external/lib/swift.php +++ b/apps/files_external/lib/swift.php @@ -264,7 +264,7 @@ class SWIFT extends \OC\Files\Storage\Common{ private function getSubContainerFile($container) { try { return $container->get_object(self::SUBCONTAINER_FILE); - } catch(NoSuchObjectException $e) { + } catch(\NoSuchObjectException $e) { return $container->create_object(self::SUBCONTAINER_FILE); } } diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index 2b7ab4cee0a..2d183c8893d 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -73,7 +73,7 @@ class DAV extends \OC\Files\Storage\Common{ $this->client->addTrustedCertificates($certPath); } } - //create the root folder if necesary + //create the root folder if necessary $this->mkdir(''); } @@ -317,7 +317,7 @@ class DAV extends \OC\Files\Storage\Common{ } } - private function cleanPath($path) { + public function cleanPath($path) { if ( ! $path || $path[0]=='/') { return substr($path, 1); } else { -- cgit v1.2.3