require_once('../../lib/base.php');
// Check if we are a user
-if( !OC_User::isLoggedIn()){
- header( 'Location: '.OC_Helper::linkTo( '', 'index.php' ));
- exit();
-}
+OC_Util::checkLoggedIn();
require_once('bookmarksHelper.php');
$tmpl->assign('TITLE', htmlentities($metadata['title']));
$tmpl->assign('DESCRIPTION', htmlentities($metadata['description']));
-$tmpl->printPage();
\ No newline at end of file
+$tmpl->printPage();
require_once('../../lib/base.php');
// Check if we are a user
-if( !OC_User::isLoggedIn()){
- header( "Location: ".OC_Helper::linkTo( '', 'index.php' ));
- exit();
-}
+OC_Util::checkLoggedIn();
OC_App::setActiveNavigationEntry( 'bookmarks_index' );
$tmpl = new OC_Template( 'bookmarks', 'list', 'user' );
-$tmpl->printPage();
\ No newline at end of file
+$tmpl->printPage();
* MA 02111-1307 USA *
*************************************************/
require_once ("../../lib/base.php");
-if(!OC_USER::isLoggedIn()) {
- header("Location: " . OC_HELPER::linkTo("", "index.php"));
- exit;
-}
+OC_Util::checkLoggedIn();
$cal = $_GET["calid"];
$calendar = OC_Calendar_Calendar::findCalendar($cal);
if($calendar["userid"] != OC_User::getUser()){
- header("Location: " . OC_HELPER::linkTo("", "index.php"));
+ header( 'Location: '.OC_Helper::linkTo('', 'index.php'));
exit;
}
$calobjects = OC_Calendar_Object::all($cal);
* MA 02111-1307 USA *
*************************************************/
require_once ("../../lib/base.php");
-if(!OC_USER::isLoggedIn()) {
- header("Location: " . OC_HELPER::linkTo("", "index.php"));
- exit;
-}
+OC_Util::checkLoggedIn();
// Create default calendar ...
$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
if( count($calendars) == 0){
require_once('../../lib/base.php');
// Check if we are a user
-if( !OC_User::isLoggedIn()){
- header( 'Location: '.OC_Helper::linkTo( '', 'index.php' ));
- exit();
-}
+OC_Util::checkLoggedIn();
// Check if the user has an addressbook
$addressbooks = OC_Contacts_Addressbook::all(OC_User::getUser());
// Check if we are a user
-if( !OC_User::isLoggedIn()){
- header( "Location: ".OC_Helper::linkTo( "index.php" ));
- exit();
-}
+OC_Util::checkLoggedIn();
OC_App::setActiveNavigationEntry( "files_publiclink_administration" );
require_once('../../lib/base.php');
require_once('lib_share.php');
-if (!OC_User::isLoggedIn()){
- header( "Location: ".OC_HELPER::linkTo( "index.php" ));
- exit();
-}
+OC_Util::checkLoggedIn();
OC_App::setActiveNavigationEntry("files_sharing_list");
$tmpl->assign("shared_items", OC_Share::getMySharedItems());
$tmpl->printPage();
-?>
\ No newline at end of file
+?>
require_once('../../lib/base.php');
// Check if we are a user
-if( !OC_User::isLoggedIn()){
- header( "Location: ".OC_Helper::linkTo( '', 'index.php' ));
- exit();
-}
+OC_Util::checkLoggedIn();
require_once('lib_collection.php');
require_once('lib_scanner.php');
// Init owncloud
require_once('../lib/base.php');
-
-// Check if we are a user
-if( !OC_User::isLoggedIn() || !OC_Group::inGroup( OC_User::getUser(), 'admin' )){
- header( "Location: ".OC_Helper::linkTo( "files", "index.php" ));
- exit();
-}
+OC_User::checkAdminUser();
$htaccessWorking=(getenv('htaccessWorking')=='true');
if(isset($_POST['maxUploadSize'])){
require_once('../../lib/base.php');
// Check if we are a user
-if( !OC_User::isLoggedIn()){
- header( "Location: ".OC_Helper::linkTo( "", "index.php" ));
- exit();
-}
+OC_Util::checkLoggedIn();
$files = $_GET["files"];
$dir = $_GET["dir"];
require_once('../lib/base.php');
// Check if we are a user
-if( !OC_User::isLoggedIn()){
- header( "Location: ".OC_Helper::linkTo( "", "index.php" ));
- exit();
-}
+OC_Util::checkLoggedIn();
$filename = $_GET["file"];
require_once('../lib/base.php');
// Check if we are a user
-if( !OC_User::isLoggedIn()){
- header( "Location: ".OC_Helper::linkTo( '', 'index.php' ));
- exit();
-}
+OC_Util::checkLoggedIn();
// Load the files we need
OC_Util::addStyle( "files", "files" );
require_once('../lib/base.php');
// Check if we are a user
-if( !OC_User::isLoggedIn()){
- header( "Location: ".OC_Helper::linkTo( "", "index.php" ));
- exit();
-}
+OC_Util::checkLoggedIn();
// Load the files we need
OC_Util::addStyle( "files", "files" );
exit();
}
else {
- header("Location: ".OC::$WEBROOT.'/'.OC_Appconfig::getValue("core", "defaultpage", "files/index.php"));
- exit();
+ OC_Util::redirectToDefaultPage();
}
}
if(OC_User::userExists($_COOKIE['oc_username']) &&
OC_Preferences::getValue($_COOKIE['oc_username'], "login", "token") == $_COOKIE['oc_token']) {
OC_User::setUserId($_COOKIE['oc_username']);
- header("Location: ". OC::$WEBROOT.'/'.OC_Appconfig::getValue("core", "defaultpage", "files/index.php"));
+ OC_Util::redirectToDefaultPage();
}
else {
OC_Template::printGuestPage("", "login", array("error" => true));
elseif(isset($_POST["user"]) && isset($_POST['password'])) {
OC_App::loadApps();
if(OC_User::login($_POST["user"], $_POST["password"])) {
- header("Location: ".OC::$WEBROOT.'/'.OC_Appconfig::getValue("core", "defaultpage", "files/index.php"));
if(!empty($_POST["remember_login"])){
error_log("Setting remember login to cookie");
$token = md5($_POST["user"].time());
else {
OC_User::unsetMagicInCookie();
}
- exit();
+ OC_Util::redirectToDefaultPage();
}
else {
if(isset($_COOKIE["oc_username"])){
return $errors;
}
+
+ /**
+ * Check if the user is logged in, redirects to home if not
+ */
+ public static function checkLoggedIn(){
+ // Check if we are a user
+ if( !OC_User::isLoggedIn()){
+ header( 'Location: '.OC_Helper::linkTo( '', 'index.php' , true));
+ exit();
+ }
+ }
+
+ /**
+ * Check if the user is a admin, redirects to home if not
+ */
+ public static function checkAdminUser(){
+ // Check if we are a user
+ self::checkLoggedIn();
+ if( !OC_Group::inGroup( OC_User::getUser(), 'admin' )){
+ header( 'Location: '.OC_Helper::linkTo( '', 'index.php' , true));
+ exit();
+ }
+ }
+
+ /**
+ * Redirect to the user default page
+ */
+ public static function redirectToDefaultPage(){
+ header( 'Location: '.OC::$WEBROOT.'/'.OC_Appconfig::getValue('core', 'defaultpage', 'files/index.php'));
+ exit();
+ }
}
require_once('../../lib/base.php');
// Check if we are a user
-if( !OC_User::isLoggedIn()){
- header( "Location: ".OC_Helper::linkTo( '', 'index.php' ));
- exit();
-}
+OC_Util::checkLoggedIn();
$query=(isset($_GET['query']))?$_GET['query']:'';
if($query){
echo 'false';
}
-?>
\ No newline at end of file
+?>
require_once('../lib/base.php');
// Check if we are a user
-if( !OC_User::isLoggedIn()){
- header( "Location: ".OC_Helper::linkTo( '', 'index.php' ));
- exit();
-}
+OC_Util::checkLoggedIn();
// Load the files we need
OC_Util::addStyle( 'search', 'search' );
if($query){
$results=OC_Search::search($query);
}else{
- header("Location: ".OC::$WEBROOT.'/'.OC_Appconfig::getValue("core", "defaultpage", "files/index.php"));
- exit();
+ OC_Util::redirectToDefaultPage();
}
$resultTypes=array();
*/
require_once('../lib/base.php');
-if( !OC_User::isLoggedIn()){
- header( "Location: ".OC_Helper::linkTo( "", "index.php" ));
- exit();
-}
-if( !OC_User::isLoggedIn() || !OC_Group::inGroup( OC_User::getUser(), 'admin' )){
- header( "Location: ".OC_Helper::linkTo( '', "index.php" ));
- exit();
-}
+OC_Util::checkAdminUser();
OC_Util::addStyle( "settings", "settings" );
OC_App::setActiveNavigationEntry( "admin" );
foreach($forms as $form){
$tmpl->append('forms',$form);
}
-$tmpl->printPage();
\ No newline at end of file
+$tmpl->printPage();
*/
require_once('../lib/base.php');
-if( !OC_User::isLoggedIn() || !OC_Group::inGroup( OC_User::getUser(), 'admin' )){
- header( "Location: ".OC_Helper::linkTo( "", "index.php" ));
- exit();
-}
+OC_Util::checkAdminUser();
// Load the files we need
OC_Util::addStyle( "settings", "settings" );
*/
require_once('../lib/base.php');
-if( !OC_User::isLoggedIn()){
- header( "Location: ".OC_Helper::linkTo( "", "index.php" ));
- exit();
-}
+OC_Util::checkLoggedIn();
// Load the files we need
*/
require_once('../lib/base.php');
-if( !OC_User::isLoggedIn()){
- header( "Location: ".OC_Helper::linkTo( "", "index.php" ));
- exit();
-}
+OC_Util::checkLoggedIn();
// Highlight navigation entry
OC_Util::addScript( "settings", "personal" );
*/
require_once('../lib/base.php');
-if( !OC_User::isLoggedIn()){
- header( "Location: ".OC_Helper::linkTo( "", "index.php" ));
- exit();
-}
+OC_Util::checkLoggedIn();
OC_Util::addStyle( "settings", "settings" );
OC_App::setActiveNavigationEntry( "settings" );
foreach($forms as $form){
$tmpl->append('forms',$form);
}
-$tmpl->printPage();
\ No newline at end of file
+$tmpl->printPage();
*/
require_once('../lib/base.php');
-if( !OC_User::isLoggedIn() || !OC_Group::inGroup( OC_User::getUser(), 'admin' )){
- header( "Location: ".OC_Helper::linkTo( "", "index.php" ));
- exit();
-}
+OC_Util::checkAdminUser();
// We have some javascript foo!
OC_Util::addScript( 'settings', 'users' );