diff options
-rw-r--r-- | admin/ajax/changepassword.php | 2 | ||||
-rw-r--r-- | admin/ajax/creategroup.php | 2 | ||||
-rw-r--r-- | admin/ajax/createuser.php | 2 | ||||
-rw-r--r-- | admin/ajax/removegroup.php | 2 | ||||
-rw-r--r-- | admin/ajax/removeuser.php | 2 | ||||
-rw-r--r-- | admin/ajax/togglegroups.php | 2 | ||||
-rw-r--r-- | admin/apps.php | 2 | ||||
-rw-r--r-- | admin/system.php | 2 | ||||
-rw-r--r-- | admin/users.php | 2 | ||||
-rw-r--r-- | apps/files_publiclink/lib_public.php | 6 | ||||
-rw-r--r-- | files/admin.php | 2 | ||||
-rw-r--r-- | lib/base.php | 2 | ||||
-rw-r--r-- | lib/l10n.php | 4 | ||||
-rw-r--r-- | lib/user.php | 13 | ||||
-rw-r--r-- | log/index.php | 8 | ||||
-rw-r--r-- | settings/ajax/setlanguage.php | 2 | ||||
-rw-r--r-- | settings/index.php | 2 |
17 files changed, 35 insertions, 22 deletions
diff --git a/admin/ajax/changepassword.php b/admin/ajax/changepassword.php index a8f3af15175..51634908a76 100644 --- a/admin/ajax/changepassword.php +++ b/admin/ajax/changepassword.php @@ -7,7 +7,7 @@ require_once('../../lib/base.php'); header( "Content-Type: application/jsonrequest" ); // Check if we are a user -if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){ +if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){ echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" ))); exit(); } diff --git a/admin/ajax/creategroup.php b/admin/ajax/creategroup.php index eec27587930..df9a36aaa2f 100644 --- a/admin/ajax/creategroup.php +++ b/admin/ajax/creategroup.php @@ -7,7 +7,7 @@ require_once('../../lib/base.php'); header( "Content-Type: application/jsonrequest" ); // Check if we are a user -if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){ +if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){ echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" ))); exit(); } diff --git a/admin/ajax/createuser.php b/admin/ajax/createuser.php index a6e4ec0e93d..507ded9079f 100644 --- a/admin/ajax/createuser.php +++ b/admin/ajax/createuser.php @@ -7,7 +7,7 @@ require_once('../../lib/base.php'); header( "Content-Type: application/jsonrequest" ); // Check if we are a user -if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){ +if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){ echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" ))); exit(); } diff --git a/admin/ajax/removegroup.php b/admin/ajax/removegroup.php index c7991ba5819..e3d62e5fac8 100644 --- a/admin/ajax/removegroup.php +++ b/admin/ajax/removegroup.php @@ -7,7 +7,7 @@ require_once('../../lib/base.php'); header( "Content-Type: application/jsonrequest" ); // Check if we are a user -if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){ +if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){ echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" ))); exit(); } diff --git a/admin/ajax/removeuser.php b/admin/ajax/removeuser.php index 7e587f16058..6b48146ad45 100644 --- a/admin/ajax/removeuser.php +++ b/admin/ajax/removeuser.php @@ -7,7 +7,7 @@ require_once('../../lib/base.php'); header( "Content-Type: application/jsonrequest" ); // Check if we are a user -if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){ +if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){ echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" ))); exit(); } diff --git a/admin/ajax/togglegroups.php b/admin/ajax/togglegroups.php index f821ae0bfaa..5c7bd393e92 100644 --- a/admin/ajax/togglegroups.php +++ b/admin/ajax/togglegroups.php @@ -7,7 +7,7 @@ require_once('../../lib/base.php'); header( "Content-Type: application/jsonrequest" ); // Check if we are a user -if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){ +if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){ echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" ))); exit(); } diff --git a/admin/apps.php b/admin/apps.php index 285cf9e90f5..b47611f536d 100644 --- a/admin/apps.php +++ b/admin/apps.php @@ -24,7 +24,7 @@ require_once('../lib/base.php'); include_once('../lib/installer.php'); require( 'template.php' ); -if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){ +if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){ header( "Location: ".OC_HELPER::linkTo( "", "index.php" )); exit(); } diff --git a/admin/system.php b/admin/system.php index 310979295f0..284509144ee 100644 --- a/admin/system.php +++ b/admin/system.php @@ -23,7 +23,7 @@ require_once('../lib/base.php'); require( 'template.php' ); -if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){ +if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){ header( "Location: ".OC_HELPER::linkTo( "index.php" )); exit(); } diff --git a/admin/users.php b/admin/users.php index e44feb40fe2..0848d57162a 100644 --- a/admin/users.php +++ b/admin/users.php @@ -23,7 +23,7 @@ require_once('../lib/base.php'); require( 'template.php' ); -if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){ +if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){ header( "Location: ".OC_HELPER::linkTo( "index.php" )); exit(); } diff --git a/apps/files_publiclink/lib_public.php b/apps/files_publiclink/lib_public.php index aeef9212377..93ccc52d0e9 100644 --- a/apps/files_publiclink/lib_public.php +++ b/apps/files_publiclink/lib_public.php @@ -7,7 +7,7 @@ class OC_PublicLink{ */ public function __construct($path,$expiretime=0){ if($path and OC_FILESYSTEM::file_exists($path) and OC_FILESYSTEM::is_readable($path)){ - $user=$_SESSION['user_id']; + $user=OC_USER::getUser(); $token=sha1("$user-$path-$expiretime"); $query=OC_DB::prepare("INSERT INTO *PREFIX*publiclink VALUES(?,?,?,?)"); $result=$query->execute(array($token,$path,$user,$expiretime)); @@ -60,7 +60,7 @@ class OC_PublicLink{ */ static public function getLinks(){ $query=OC_DB::prepare("SELECT * FROM *PREFIX*publiclink WHERE user=?"); - return $query->execute(array($_SESSION['user_id']))->fetchAll(); + return $query->execute(array(OC_USER::getUser()))->fetchAll(); } /** @@ -69,7 +69,7 @@ class OC_PublicLink{ static public function delete($token){ $query=OC_DB::prepare("SELECT user,path FROM *PREFIX*publiclink WHERE token=?"); $result=$query->execute(array($token))->fetchAll(); - if(count($result)>0 and $result[0]['user']==$_SESSION['user_id']){ + if(count($result)>0 and $result[0]['user']==OC_USER::getUser()){ $query=OC_DB::prepare("DELETE FROM *PREFIX*publiclink WHERE token=?"); $query->execute(array($token)); } diff --git a/files/admin.php b/files/admin.php index 59b822468ed..5c9923aff86 100644 --- a/files/admin.php +++ b/files/admin.php @@ -28,7 +28,7 @@ require( 'template.php' ); // Check if we are a user -if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){ +if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){ header( "Location: ".OC_HELPER::linkTo( "index.php" )); exit(); } diff --git a/lib/base.php b/lib/base.php index e93c4712727..0453e272a4b 100644 --- a/lib/base.php +++ b/lib/base.php @@ -142,7 +142,7 @@ class OC_UTIL { // If we are not forced to load a specific user we load the one that is logged in if( $user == "" && OC_USER::isLoggedIn()){ - $user = $_SESSION['user_id']; + $user = OC_USER::getUser(); } if( $user != "" ){ //if we aren't logged in, there is no use to set up the filesystem diff --git a/lib/l10n.php b/lib/l10n.php index ff0238241a6..053c6fbc10e 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -200,8 +200,8 @@ class OC_L10N{ else{ $available=self::findAvailableLanguages( $app ); } - if( isset($_SESSION['user_id']) && $_SESSION['user_id'] && OC_PREFERENCES::getValue( $_SESSION['user_id'], 'core', 'lang' )){ - $lang = OC_PREFERENCES::getValue( $_SESSION['user_id'], 'core', 'lang' ); + if( OC_USER::getUser() && OC_PREFERENCES::getValue( OC_USER::getUser(), 'core', 'lang' )){ + $lang = OC_PREFERENCES::getValue( OC_USER::getUser(), 'core', 'lang' ); self::$language = $lang; if( array_search( $lang, $available ) !== false ){ return $lang; diff --git a/lib/user.php b/lib/user.php index 2e11a30e85e..7eafef924a8 100644 --- a/lib/user.php +++ b/lib/user.php @@ -232,6 +232,19 @@ class OC_USER { } /** + * @brief get the user idea of the user currently logged in. + * @return string uid or false + */ + public static function getUser(){ + if( isset($_SESSION['user_id']) AND $_SESSION['user_id'] ){ + return $_SESSION['user_id']; + } + else{ + return false; + } + } + + /** * @brief Autogenerate a password * @returns string * diff --git a/log/index.php b/log/index.php index 950e1f82d19..4986526e007 100644 --- a/log/index.php +++ b/log/index.php @@ -43,8 +43,8 @@ if(isset($_POST['save'])){ $selectedActions[]=$action; } } - OC_PREFERENCES::setValue($_SESSION['user_id'],'log','actions',implode(',',$selectedActions)); - OC_PREFERENCES::setValue($_SESSION['user_id'],'log','pagesize',$_POST['size']); + OC_PREFERENCES::setValue(OC_USER::getUser(),'log','actions',implode(',',$selectedActions)); + OC_PREFERENCES::setValue(OC_USER::getUser(),'log','pagesize',$_POST['size']); } //clear log entries elseif(isset($_POST['clear'])){ @@ -62,10 +62,10 @@ OC_APP::setActiveNavigationEntry( 'log' ); $logs=OC_LOG::get(); -$selectedActions=explode(',',OC_PREFERENCES::getValue($_SESSION['user_id'],'log','actions',implode(',',$allActions))); +$selectedActions=explode(',',OC_PREFERENCES::getValue(OC_USER::getUser(),'log','actions',implode(',',$allActions))); $logs=OC_LOG::filterAction($logs,$selectedActions); -$pageSize=OC_PREFERENCES::getValue($_SESSION['user_id'],'log','pagesize',20); +$pageSize=OC_PREFERENCES::getValue(OC_USER::getUser(),'log','pagesize',20); $pageCount=ceil(count($logs)/$pageSize); $page=isset($_GET['page'])?$_GET['page']:0; if($page>=$pageCount){ diff --git a/settings/ajax/setlanguage.php b/settings/ajax/setlanguage.php index f971806f4c6..bc467fb9004 100644 --- a/settings/ajax/setlanguage.php +++ b/settings/ajax/setlanguage.php @@ -17,7 +17,7 @@ if( !OC_USER::isLoggedIn()){ // Get data if( isset( $_POST['lang'] ) ){ $lang=$_POST['lang']; - OC_PREFERENCES::setValue( $_SESSION['user_id'], 'core', 'lang', $lang ); + OC_PREFERENCES::setValue( OC_USER::getUser(), 'core', 'lang', $lang ); echo json_encode( array( "status" => "success", "data" => array( "message" => $l->t("Language changed") ))); }else{ echo json_encode( array( "status" => "error", "data" => array( "message" => $l->t("Invalid request") ))); diff --git a/settings/index.php b/settings/index.php index e2a73a5d9f3..07adba142d6 100644 --- a/settings/index.php +++ b/settings/index.php @@ -18,7 +18,7 @@ $free=OC_FILESYSTEM::free_space(); $total=$free+$used; $relative=round(($used/$total)*100); -$lang=OC_PREFERENCES::getValue( $_SESSION['user_id'], 'core', 'lang', 'en' ); +$lang=OC_PREFERENCES::getValue( OC_USER::getUser(), 'core', 'lang', 'en' ); $languages=OC_L10N::findAvailableLanguages(); //put the current language in the front unset($languages[array_search($lang,$languages)]); |