|
|
@ -39,7 +39,7 @@ class OC_Util { |
|
|
|
$CONFIG_DATADIRECTORY = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ); |
|
|
|
$CONFIG_DATADIRECTORY = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ); |
|
|
|
//first set up the local "root" storage |
|
|
|
//first set up the local "root" storage |
|
|
|
if(!self::$rootMounted) { |
|
|
|
if(!self::$rootMounted) { |
|
|
|
OC_Filesystem::mount('OC_Filestorage_Local', array('datadir'=>$CONFIG_DATADIRECTORY),'/'); |
|
|
|
OC_Filesystem::mount('OC_Filestorage_Local', array('datadir'=>$CONFIG_DATADIRECTORY), '/'); |
|
|
|
self::$rootMounted=true; |
|
|
|
self::$rootMounted=true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -81,10 +81,10 @@ class OC_Util { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$mtime=filemtime($user_root.'/mount.php'); |
|
|
|
$mtime=filemtime($user_root.'/mount.php'); |
|
|
|
$previousMTime=OC_Preferences::getValue($user,'files','mountconfigmtime',0); |
|
|
|
$previousMTime=OC_Preferences::getValue($user, 'files', 'mountconfigmtime', 0); |
|
|
|
if($mtime>$previousMTime) {//mount config has changed, filecache needs to be updated |
|
|
|
if($mtime>$previousMTime) {//mount config has changed, filecache needs to be updated |
|
|
|
OC_FileCache::triggerUpdate($user); |
|
|
|
OC_FileCache::triggerUpdate($user); |
|
|
|
OC_Preferences::setValue($user,'files','mountconfigmtime',$mtime); |
|
|
|
OC_Preferences::setValue($user, 'files', 'mountconfigmtime', $mtime); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -169,7 +169,7 @@ class OC_Util { |
|
|
|
public static function formatDate( $timestamp,$dateOnly=false) { |
|
|
|
public static function formatDate( $timestamp,$dateOnly=false) { |
|
|
|
if(isset($_SESSION['timezone'])) {//adjust to clients timezone if we know it |
|
|
|
if(isset($_SESSION['timezone'])) {//adjust to clients timezone if we know it |
|
|
|
$systemTimeZone = intval(date('O')); |
|
|
|
$systemTimeZone = intval(date('O')); |
|
|
|
$systemTimeZone=(round($systemTimeZone/100,0)*60)+($systemTimeZone%100); |
|
|
|
$systemTimeZone=(round($systemTimeZone/100, 0)*60)+($systemTimeZone%100); |
|
|
|
$clientTimeZone=$_SESSION['timezone']*60; |
|
|
|
$clientTimeZone=$_SESSION['timezone']*60; |
|
|
|
$offset=$clientTimeZone-$systemTimeZone; |
|
|
|
$offset=$clientTimeZone-$systemTimeZone; |
|
|
|
$timestamp=$timestamp+$offset*60; |
|
|
|
$timestamp=$timestamp+$offset*60; |
|
|
@ -196,11 +196,11 @@ class OC_Util { |
|
|
|
if($pagestop>$pagecount) $pagestop=$pagecount; |
|
|
|
if($pagestop>$pagecount) $pagestop=$pagecount; |
|
|
|
|
|
|
|
|
|
|
|
$tmpl = new OC_Template( '', 'part.pagenavi', '' ); |
|
|
|
$tmpl = new OC_Template( '', 'part.pagenavi', '' ); |
|
|
|
$tmpl->assign('page',$page); |
|
|
|
$tmpl->assign('page', $page); |
|
|
|
$tmpl->assign('pagecount',$pagecount); |
|
|
|
$tmpl->assign('pagecount', $pagecount); |
|
|
|
$tmpl->assign('pagestart',$pagestart); |
|
|
|
$tmpl->assign('pagestart', $pagestart); |
|
|
|
$tmpl->assign('pagestop',$pagestop); |
|
|
|
$tmpl->assign('pagestop', $pagestop); |
|
|
|
$tmpl->assign('url',$url); |
|
|
|
$tmpl->assign('url', $url); |
|
|
|
return $tmpl; |
|
|
|
return $tmpl; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -241,24 +241,24 @@ class OC_Util { |
|
|
|
//check for correct file permissions |
|
|
|
//check for correct file permissions |
|
|
|
if(!stristr(PHP_OS, 'WIN')) { |
|
|
|
if(!stristr(PHP_OS, 'WIN')) { |
|
|
|
$permissionsModHint="Please change the permissions to 0770 so that the directory cannot be listed by other users."; |
|
|
|
$permissionsModHint="Please change the permissions to 0770 so that the directory cannot be listed by other users."; |
|
|
|
$prems=substr(decoct(@fileperms($CONFIG_DATADIRECTORY)),-3); |
|
|
|
$prems=substr(decoct(@fileperms($CONFIG_DATADIRECTORY)), -3); |
|
|
|
if(substr($prems,-1)!='0') { |
|
|
|
if(substr($prems, -1)!='0') { |
|
|
|
OC_Helper::chmodr($CONFIG_DATADIRECTORY,0770); |
|
|
|
OC_Helper::chmodr($CONFIG_DATADIRECTORY, 0770); |
|
|
|
clearstatcache(); |
|
|
|
clearstatcache(); |
|
|
|
$prems=substr(decoct(@fileperms($CONFIG_DATADIRECTORY)),-3); |
|
|
|
$prems=substr(decoct(@fileperms($CONFIG_DATADIRECTORY)), -3); |
|
|
|
if(substr($prems,2,1)!='0') { |
|
|
|
if(substr($prems, 2, 1)!='0') { |
|
|
|
$errors[]=array('error'=>'Data directory ('.$CONFIG_DATADIRECTORY.') is readable for other users<br/>','hint'=>$permissionsModHint); |
|
|
|
$errors[]=array('error'=>'Data directory ('.$CONFIG_DATADIRECTORY.') is readable for other users<br/>', 'hint'=>$permissionsModHint); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if( OC_Config::getValue( "enablebackup", false )) { |
|
|
|
if( OC_Config::getValue( "enablebackup", false )) { |
|
|
|
$CONFIG_BACKUPDIRECTORY = OC_Config::getValue( "backupdirectory", OC::$SERVERROOT."/backup" ); |
|
|
|
$CONFIG_BACKUPDIRECTORY = OC_Config::getValue( "backupdirectory", OC::$SERVERROOT."/backup" ); |
|
|
|
$prems=substr(decoct(@fileperms($CONFIG_BACKUPDIRECTORY)),-3); |
|
|
|
$prems=substr(decoct(@fileperms($CONFIG_BACKUPDIRECTORY)), -3); |
|
|
|
if(substr($prems,-1)!='0') { |
|
|
|
if(substr($prems, -1)!='0') { |
|
|
|
OC_Helper::chmodr($CONFIG_BACKUPDIRECTORY,0770); |
|
|
|
OC_Helper::chmodr($CONFIG_BACKUPDIRECTORY, 0770); |
|
|
|
clearstatcache(); |
|
|
|
clearstatcache(); |
|
|
|
$prems=substr(decoct(@fileperms($CONFIG_BACKUPDIRECTORY)),-3); |
|
|
|
$prems=substr(decoct(@fileperms($CONFIG_BACKUPDIRECTORY)), -3); |
|
|
|
if(substr($prems,2,1)!='0') { |
|
|
|
if(substr($prems, 2, 1)!='0') { |
|
|
|
$errors[]=array('error'=>'Data directory ('.$CONFIG_BACKUPDIRECTORY.') is readable for other users<br/>','hint'=>$permissionsModHint); |
|
|
|
$errors[]=array('error'=>'Data directory ('.$CONFIG_BACKUPDIRECTORY.') is readable for other users<br/>', 'hint'=>$permissionsModHint); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -391,7 +391,7 @@ class OC_Util { |
|
|
|
// Check if we are a user |
|
|
|
// Check if we are a user |
|
|
|
self::checkLoggedIn(); |
|
|
|
self::checkLoggedIn(); |
|
|
|
self::verifyUser(); |
|
|
|
self::verifyUser(); |
|
|
|
if(OC_Group::inGroup(OC_User::getUser(),'admin')) { |
|
|
|
if(OC_Group::inGroup(OC_User::getUser(), 'admin')) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
if(!OC_SubAdmin::isSubAdmin(OC_User::getUser())) { |
|
|
|
if(!OC_SubAdmin::isSubAdmin(OC_User::getUser())) { |
|
|
@ -467,7 +467,7 @@ class OC_Util { |
|
|
|
$id=OC_Config::getValue('instanceid', null); |
|
|
|
$id=OC_Config::getValue('instanceid', null); |
|
|
|
if(is_null($id)) { |
|
|
|
if(is_null($id)) { |
|
|
|
$id=uniqid(); |
|
|
|
$id=uniqid(); |
|
|
|
OC_Config::setValue('instanceid',$id); |
|
|
|
OC_Config::setValue('instanceid', $id); |
|
|
|
} |
|
|
|
} |
|
|
|
return $id; |
|
|
|
return $id; |
|
|
|
} |
|
|
|
} |
|
|
@ -504,10 +504,10 @@ class OC_Util { |
|
|
|
|
|
|
|
|
|
|
|
// cleanup old tokens garbage collector |
|
|
|
// cleanup old tokens garbage collector |
|
|
|
// only run every 20th time so we don't waste cpu cycles |
|
|
|
// only run every 20th time so we don't waste cpu cycles |
|
|
|
if(rand(0,20)==0) { |
|
|
|
if(rand(0, 20)==0) { |
|
|
|
foreach($_SESSION as $key=>$value) { |
|
|
|
foreach($_SESSION as $key=>$value) { |
|
|
|
// search all tokens in the session |
|
|
|
// search all tokens in the session |
|
|
|
if(substr($key,0,12)=='requesttoken') { |
|
|
|
if(substr($key, 0, 12)=='requesttoken') { |
|
|
|
// check if static lifespan has expired |
|
|
|
// check if static lifespan has expired |
|
|
|
if($value+self::$callLifespan<time()) { |
|
|
|
if($value+self::$callLifespan<time()) { |
|
|
|
// remove outdated tokens |
|
|
|
// remove outdated tokens |
|
|
@ -571,7 +571,7 @@ class OC_Util { |
|
|
|
* @return array with sanitized strings or a single sanitized string, depends on the input parameter. |
|
|
|
* @return array with sanitized strings or a single sanitized string, depends on the input parameter. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static function sanitizeHTML( &$value ) { |
|
|
|
public static function sanitizeHTML( &$value ) { |
|
|
|
if (is_array($value) || is_object($value)) array_walk_recursive($value,'OC_Util::sanitizeHTML'); |
|
|
|
if (is_array($value) || is_object($value)) array_walk_recursive($value, 'OC_Util::sanitizeHTML'); |
|
|
|
else $value = htmlentities($value, ENT_QUOTES, 'UTF-8'); //Specify encoding for PHP<5.4 |
|
|
|
else $value = htmlentities($value, ENT_QUOTES, 'UTF-8'); //Specify encoding for PHP<5.4 |
|
|
|
return $value; |
|
|
|
return $value; |
|
|
|
} |
|
|
|
} |
|
|
|