diff --git a/composer-dist.json b/composer-dist.json index e108080b0..f9f5bbfb4 100644 --- a/composer-dist.json +++ b/composer-dist.json @@ -22,7 +22,7 @@ "psr-4": { "SeedDMS\\Console\\": "seeddms/utils" }, - "classmap": ["seeddms/inc/inc.ClassTranslator.php", "seeddms/inc/inc.ClassSettings.php", "seeddms/inc/inc.Version.php", "seeddms/inc/inc.ClassViewCommon.php", "seeddms/inc/inc.ClassControllerCommon.php", "seeddms/inc/inc.ClassController.php"] + "classmap": ["seeddms/inc/inc.ClassTranslator.php", "seeddms/inc/inc.ClassSettings.php", "seeddms/inc/inc.Version.php", "seeddms/inc/inc.ClassViewCommon.php", "seeddms/inc/inc.ClassControllerCommon.php", "seeddms/inc/inc.ClassController.php", "seeddms/inc/inc.ClassSession.php"] }, "require": { "pear/http_request2": "^2", diff --git a/composer.json b/composer.json index 1f62d796e..bb53cce27 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "psr-4": { "Seeddms\\Console\\": "utils" }, - "classmap": ["inc/inc.ClassTranslator.php", "inc/inc.ClassSettings.php", "inc/inc.Version.php", "inc/inc.ClassViewCommon.php", "inc/inc.ClassControllerCommon.php", "inc/inc.ClassController.php"] + "classmap": ["inc/inc.ClassTranslator.php", "inc/inc.ClassSettings.php", "inc/inc.Version.php", "inc/inc.ClassViewCommon.php", "inc/inc.ClassControllerCommon.php", "inc/inc.ClassController.php", "inc/inc.ClassSession.php"] }, "require": { "php": ">=8.2.0", diff --git a/inc/inc.Authentication.php b/inc/inc.Authentication.php index bc132862b..c5811ac57 100644 --- a/inc/inc.Authentication.php +++ b/inc/inc.Authentication.php @@ -12,6 +12,8 @@ * @version Release: @package_version@ */ +use Seeddms\Seeddms\Session; + require_once("inc.ClassSession.php"); require_once("inc.ClassAccessOperation.php"); @@ -23,7 +25,7 @@ if (!strncmp("/op", $refer, 3)) { } if (!isset($_COOKIE["mydms_session"])) { if($settings->_enableGuestLogin && $settings->_enableGuestAutoLogin) { - $session = new SeedDMS_Session($db); + $session = new Session($db); if(!$dms_session = $session->create(array('userid'=>$settings->_guestID, 'theme'=>$settings->_theme, 'lang'=>$settings->_language))) { header("Location: " . $settings->_httpRoot . "out/out.Login.php?referuri=".$refer); exit; @@ -44,7 +46,7 @@ if (!isset($_COOKIE["mydms_session"])) { $lang = $settings->_language; $user->setLanguage($lang); } - $session = new SeedDMS_Session($db); + $session = new Session($db); if(!$dms_session = $session->create(array('userid'=>$user->getID(), 'theme'=>$theme, 'lang'=>$lang))) { header("Location: " . $settings->_httpRoot . "out/out.Login.php?referuri=".$refer); exit; @@ -57,7 +59,7 @@ if (!isset($_COOKIE["mydms_session"])) { } else { /* Load session */ $dms_session = $_COOKIE["mydms_session"]; - $session = new SeedDMS_Session($db); + $session = new Session($db); if(!$resArr = $session->load($dms_session)) { setcookie("mydms_session", $dms_session, time()-3600, $settings->_httpRoot); //delete cookie header("Location: " . $settings->_httpRoot . "out/out.Login.php?referuri=".$refer); diff --git a/inc/inc.ClassAuthenticationMiddleware.php b/inc/inc.ClassAuthenticationMiddleware.php index f406747cf..62795e4bf 100644 --- a/inc/inc.ClassAuthenticationMiddleware.php +++ b/inc/inc.ClassAuthenticationMiddleware.php @@ -30,6 +30,8 @@ * @link https://www.seeddms.org Main Site */ +use Seeddms\Seeddms\Session; + /* Middleware for authentication based on session */ class SeedDMS_Auth_Middleware_Session { /* {{{ */ @@ -67,8 +69,8 @@ class SeedDMS_Auth_Middleware_Session { /* {{{ */ } $logger->log("Invoke AuthSessionMiddleware for method " . $request->getMethod() . " on '" . $request->getUri()->getPath() . "'", PEAR_LOG_INFO); - require_once("inc/inc.ClassSession.php"); - $session = new SeedDMS_Session($dms->getDb()); +// require_once("inc/inc.ClassSession.php"); + $session = new Session($dms->getDb()); if (isset($_COOKIE["mydms_session"])) { $dms_session = $_COOKIE["mydms_session"]; $logger->log("Session key: " . $dms_session, PEAR_LOG_DEBUG); diff --git a/inc/inc.ClassSession.php b/inc/inc.ClassSession.php index e1f1c1b8e..f86199253 100644 --- a/inc/inc.ClassSession.php +++ b/inc/inc.ClassSession.php @@ -15,6 +15,8 @@ * @version Release: @package_version@ */ +namespace Seeddms\Seeddms; + /** * Class to represent a session * @@ -29,7 +31,7 @@ * @copyright 2011 Uwe Steinmann * @version Release: @package_version@ */ -class SeedDMS_Session { +class Session { /** * @var object $db reference to database object. This must be an instance * of {@link SeedDMS_Core_DatabaseAccess}. @@ -53,7 +55,7 @@ class SeedDMS_Session { * Create a new instance of the session handler * * @param object $db object to access the underlying database - * @return object instance of SeedDMS_Session + * @return object instance of Seeddms\Seeddms\Session */ function __construct($db) { /* {{{ */ $this->db = $db; @@ -428,7 +430,7 @@ class SeedDMS_Session { * @copyright 2014 Uwe Steinmann * @version Release: @package_version@ */ -class SeedDMS_SessionMgr { +class SessionMgr { /** * @var object $db reference to database object. This must be an instance * of {@link SeedDMS_Core_DatabaseAccess}. @@ -440,7 +442,7 @@ class SeedDMS_SessionMgr { * Create a new instance of the session manager * * @param object $db object to access the underlying database - * @return object instance of SeedDMS_SessionMgr + * @return object instance of Seeddms\Seeddms\SessionMgr */ function __construct($db) { /* {{{ */ $this->db = $db; @@ -478,7 +480,7 @@ class SeedDMS_SessionMgr { return false; $sessions = array(); foreach($resArr as $rec) { - $session = new SeedDMS_Session($this->db); + $session = new Session($this->db); $session->load($rec['id']); $sessions[] = $session; } @@ -501,7 +503,7 @@ class SeedDMS_SessionMgr { return false; $sessions = array(); foreach($resArr as $rec) { - $session = new SeedDMS_Session($this->db); + $session = new Session($this->db); $session->load($rec['id']); $sessions[] = $session; } @@ -523,7 +525,7 @@ class SeedDMS_SessionMgr { return false; $sessions = array(); foreach($resArr as $rec) { - $session = new SeedDMS_Session($this->db); + $session = new Session($this->db); $session->load($rec['id']); $sessions[] = $session; } diff --git a/op/op.Ajax.php b/op/op.Ajax.php index b14375ddb..e0e73c539 100644 --- a/op/op.Ajax.php +++ b/op/op.Ajax.php @@ -29,6 +29,8 @@ require_once("../inc/inc.ClassUI.php"); require_once("../inc/inc.ClassController.php"); require_once("../inc/inc.Notification.php"); +use Seeddms\Seeddms\Session; + require_once("../inc/inc.ClassSession.php"); require_once("../inc/inc.ClassPasswordStrength.php"); require_once("../inc/inc.ClassPasswordHistoryManager.php"); @@ -36,7 +38,7 @@ require_once("../inc/inc.ClassPasswordHistoryManager.php"); /* Load session */ if (isset($_COOKIE["mydms_session"])) { $dms_session = $_COOKIE["mydms_session"]; - $session = new SeedDMS_Session($db); + $session = new Session($db); if(!$resArr = $session->load($dms_session)) { header('Content-Type: application/json'); echo json_encode(array('error'=>1)); diff --git a/op/op.Login.php b/op/op.Login.php index f8a3d3632..135c5aefc 100644 --- a/op/op.Login.php +++ b/op/op.Login.php @@ -18,6 +18,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +use Seeddms\Seeddms\Session; + include("../inc/inc.Settings.php"); include("../inc/inc.Utils.php"); include("../inc/inc.LogInit.php"); @@ -67,7 +69,7 @@ if(isset($_REQUEST["lang"]) && strlen($_REQUEST["lang"])>0 && is_numeric(array_s $lang = (string) $_REQUEST["lang"]; } -$session = new SeedDMS_Session($db); +$session = new Session($db); // TODO: by the PHP manual: The superglobals $_GET and $_REQUEST are already decoded. // Using urldecode() on an element in $_GET or $_REQUEST could have unexpected and dangerous results. diff --git a/op/op.Logout.php b/op/op.Logout.php index 70d089139..6acc9166b 100644 --- a/op/op.Logout.php +++ b/op/op.Logout.php @@ -23,12 +23,14 @@ include("../inc/inc.Utils.php"); include("../inc/inc.LogInit.php"); include("../inc/inc.Language.php"); include("../inc/inc.Init.php"); -include("../inc/inc.Extension.php"); +//include("../inc/inc.Extension.php"); include("../inc/inc.ClassSession.php"); include("../inc/inc.ClassController.php"); include("../inc/inc.DBInit.php"); include("../inc/inc.Authentication.php"); +use Seeddms\Seeddms\Session; + $tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); $controller = Controller::factory($tmp[1], array('dms'=>$dms, 'user'=>$user)); @@ -36,7 +38,7 @@ $controller = Controller::factory($tmp[1], array('dms'=>$dms, 'user'=>$user)); if(isset($_COOKIE['mydms_session'])) { $dms_session = $_COOKIE["mydms_session"]; - $session = new SeedDMS_Session($db); + $session = new Session($db); $session->load($dms_session); // If setting the user id to 0 worked, it would be a way to logout a diff --git a/restapi/index.php b/restapi/index.php index 7c6894a8e..b6fb4b4c5 100644 --- a/restapi/index.php +++ b/restapi/index.php @@ -25,6 +25,7 @@ use Psr\Http\Server\MiddlewareInterface; use DI\ContainerBuilder; use Slim\Factory\AppFactory; use Seeddms\Seeddms\Translator; +use Seeddms\Seeddms\Session; final class JsonRenderer { /* {{{ */ public function json( @@ -264,7 +265,7 @@ final class SeedDMS_RestapiController { /* {{{ */ return $this->renderer->json($response, array('success'=>false, 'message'=>'Login failed', 'data'=>''))->withStatus(403); } else { require_once("../inc/inc.ClassSession.php"); - $session = new SeedDMS_Session($dms->getDb()); + $session = new Session($dms->getDb()); if(!$id = $session->create(array('userid'=>$userobj->getId(), 'theme'=>$userobj->getTheme(), 'lang'=>$userobj->getLanguage()))) { return $this->renderer->json($response, array('success'=>false, 'message'=>'Creating session failed', 'data'=>''))->withStatus(500); } @@ -291,7 +292,7 @@ final class SeedDMS_RestapiController { /* {{{ */ $dms_session = $_COOKIE["mydms_session"]; $db = $dms->getDb(); - $session = new SeedDMS_Session($db); + $session = new Session($db); $session->load($dms_session); // If setting the user id to 0 worked, it would be a way to logout a @@ -3175,7 +3176,7 @@ class RestapiAuthMiddleware implements MiddlewareInterface { /* {{{ */ } else { $logger->log("Checking for valid session", PEAR_LOG_INFO); require_once("../inc/inc.ClassSession.php"); - $session = new SeedDMS_Session($dms->getDb()); + $session = new Session($dms->getDb()); if (isset($_COOKIE["mydms_session"])) { $logger->log("Found cookie for session", PEAR_LOG_INFO); $dms_session = $_COOKIE["mydms_session"]; diff --git a/views/bootstrap/class.Session.php b/views/bootstrap/class.Session.php index 33a47de8c..8b54775e6 100644 --- a/views/bootstrap/class.Session.php +++ b/views/bootstrap/class.Session.php @@ -13,10 +13,7 @@ * @version Release: @package_version@ */ -/** - * Include parent class - */ -//require_once("class.Bootstrap.php"); +use Seeddms\Seeddms\SessionMgr; /** * Class which outputs the html page for clipboard view @@ -44,7 +41,7 @@ class SeedDMS_View_Session extends SeedDMS_Theme_Style { $dms = $this->params['dms']; $user = $this->params['user']; - $sessionmgr = new SeedDMS_SessionMgr($dms->getDB()); + $sessionmgr = new SessionMgr($dms->getDB()); $sessions = $sessionmgr->getLastAccessedSessions(date('Y-m-d H:i:s', time()-3600)); if(!$sessions) return; diff --git a/views/bootstrap/class.UserList.php b/views/bootstrap/class.UserList.php index 96b93b881..06146db06 100644 --- a/views/bootstrap/class.UserList.php +++ b/views/bootstrap/class.UserList.php @@ -13,10 +13,7 @@ * @version Release: @package_version@ */ -/** - * Include parent class - */ -//require_once("class.Bootstrap.php"); +use Seeddms\Seeddms\SessionMgr; /** * Class which outputs the html page for UserList view @@ -59,7 +56,7 @@ class SeedDMS_View_UserList extends SeedDMS_Theme_Style { $this->pageNavigation("", "admin_tools"); $this->contentHeading(getMLText("user_list")); - $sessionmgr = new SeedDMS_SessionMgr($dms->getDB()); + $sessionmgr = new SessionMgr($dms->getDB()); ?> diff --git a/views/bootstrap/class.UsrMgr.php b/views/bootstrap/class.UsrMgr.php index 91edd2685..4db135402 100644 --- a/views/bootstrap/class.UsrMgr.php +++ b/views/bootstrap/class.UsrMgr.php @@ -13,6 +13,8 @@ * @version Release: @package_version@ */ +use Seeddms\Seeddms\SessionMgr; + /** * Include parent class */ @@ -99,7 +101,7 @@ $(document).ready( function() { $workflowmode = $this->params['workflowmode']; if($seluser) { - $sessionmgr = new SeedDMS_SessionMgr($dms->getDB()); + $sessionmgr = new SessionMgr($dms->getDB()); $this->contentHeading(getMLText("user_info")); echo "