private static $rootView;
private function stripPath($path){//files should never start with /
- if(substr($path,0,1)=='/'){
+ if(!$path || $path[0]=='/'){
$path=substr($path,1);
}
return $path;
$this->password=$params['password'];
$this->secure=isset($params['secure'])?(bool)$params['secure']:false;
$this->root=isset($params['root'])?$params['root']:'/';
- if(substr($this->root,0,1)!='/'){
+ if(!$this->root || $this->root[0]!='/'){
$this->root='/'.$this->root;
}
$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(substr($this->root,0,1)!='/'){
- $this->root='/'.$this->root;
- }
- if(substr($this->share,0,1)!='/'){
+ if(!$this->share || $this->share[0]!='/'){
$this->share='/'.$this->share;
}
if(substr($this->share,-1,1)=='/'){
$this->user=$params['user'];
$this->root=isset($params['root'])?$params['root']:'/';
$this->secure=isset($params['secure'])?(bool)$params['secure']:true;
- if(substr($this->root,0,1)!='/'){
+ if(!$this->root || $this->root[0]!='/'){
$this->root='/'.$this->root;
}
$this->auth = new CF_Authentication($this->user, $this->token, null, $this->host);
$this->password=$params['password'];
$this->secure=isset($params['secure'])?(bool)$params['secure']:false;
$this->root=isset($params['root'])?$params['root']:'/';
- if(substr($this->root,0,1)!='/'){
+ if(!$this->root || $this->root[0]!='/'){
$this->root='/'.$this->root;
}
if(substr($this->root,-1,1)!='/'){
}
private function cleanPath($path){
- if(substr($path,0,1)=='/'){
+ if(!$path || $path[0]=='/'){
return substr($path,1);
}else{
return $path;
static private function combineFilter($filters, $operator) {
$combinedFilter = '('.$operator;
foreach($filters as $filter) {
- if(substr($filter,0,1) != '(') {
+ if($filter[0] != '(') {
$filter = '('.$filter.')';
}
$combinedFilter.=$filter;
return false;
}
- }
\ No newline at end of file
+ }
$apps=array();
$dh=opendir(OC::$APPSROOT.'/apps');
while($file=readdir($dh)){
- if(substr($file,0,1)!='.' and is_file(OC::$APPSROOT.'/apps/'.$file.'/appinfo/app.php')){
+ if($file[0]!='.' and is_file(OC::$APPSROOT.'/apps/'.$file.'/appinfo/app.php')){
$apps[]=$file;
}
}
$folderContent=array();
$pathLength=strlen($path);
foreach($files as $file){
- if(substr($file,0,1)=='/'){
+ if($file[0]=='/'){
$file=substr($file,1);
}
if(substr($file,0,$pathLength)==$path and $file!=$path){
}
}
}
- if(substr($path,0,1)!='/'){//not all programs agree on the use of a leading /
+ if($path[0]!='/'){//not all programs agree on the use of a leading /
return $this->fileExists('/'.$path);
}else{
return false;
}
private function stripPath($path){
- if(substr($path,0,1)=='/'){
+ if(!$path || $path[0]=='/'){
return substr($path,1);
}else{
return $path;
if(!$path){
$path='/';
}
- if(substr($path,0,1)!=='/'){
+ if($path[0]!=='/'){
$path='/'.$path;
}
$foundMountPoint='';
* @param string mountpoint
*/
static public function mount($class,$arguments,$mountpoint){
+ if($mountpoint[0]!='/'){
+ $mountpoint='/'.$mountpoint;
+ }
if(substr($mountpoint,-1)!=='/'){
$mountpoint=$mountpoint.'/';
}
- if(substr($mountpoint,0,1)!=='/'){
- $mountpoint='/'.$mountpoint;
- }
self::$mounts[$mountpoint]=array('class'=>$class,'arguments'=>$arguments);
}
* @return bool
*/
static public function isValidPath($path){
- if(substr($path,0,1)!=='/'){
+ if(!$path || $path[0]!=='/'){
$path='/'.$path;
}
if(strstr($path,'/../') || strrchr($path, '/') === '/..' ){
if(!$path){
$path='/';
}
- if(substr($path,0,1)!=='/'){
+ if($path[0]!=='/'){
$path='/'.$path;
}
return $this->fakeRoot.$path;
//try to find it in a subdir
$dh=opendir($extractDir);
while($folder=readdir($dh)){
- if(substr($folder,0,1)!='.' and is_dir($extractDir.'/'.$folder)){
+ if($folder[0]!='.' and is_dir($extractDir.'/'.$folder)){
if(is_file($extractDir.'/'.$folder.'/appinfo/info.xml')){
$extractDir.='/'.$folder;
}
$row=$result->fetchRow();
if($row){
$storedHash=$row['password'];
- if (substr($storedHash,0,1)=='$'){//the new phpass based hashing
+ if ($storedHash[0]=='$'){//the new phpass based hashing
$hasher=$this->getHasher();
if($hasher->CheckPassword($password.OC_Config::getValue('passwordsalt', ''), $storedHash)){
return $row['uid'];
}
if($dh=opendir($dir)){
while($name=readdir($dh)){
- if(substr($name,0,1)!='.'){//no hidden files, '.' or '..'
+ if($name[0]!='.'){//no hidden files, '.' or '..'
$file=$dir.'/'.$name;
if(is_dir($file)){
loadTests($file);