/**
  * constructor
  */
 public function __construct(cs_environment $environment)
 {
     // CommSy-Plugin logout-hook
     plugin_hook('logout');
     // delete session
     $session_manager = $environment->getSessionManager();
     $session = $environment->getSessionItem();
     $history = $session->getValue('history');
     $cookie = $session->getValue('cookie');
     $javascript = $session->getValue('javascript');
     $https = $session->getValue('https');
     $flash = $session->getValue('flash');
     if ($session->issetValue('root_session_id')) {
         $root_session_id = $session->getValue('root_session_id');
     }
     $session_manager->delete($session->getSessionID(), true);
     $session->reset();
     include_once 'classes/cs_session_item.php';
     $session = new cs_session_item();
     $session->createSessionID('guest');
     if ($cookie == '1') {
         $session->setValue('cookie', 2);
     } else {
         $session->setValue('cookie', 0);
     }
     if ($javascript == '1') {
         $session->setValue('javascript', 1);
     } elseif ($javascript == '-1') {
         $session->setValue('javascript', -1);
     }
     if ($https == '1') {
         $session->setValue('https', 1);
     } elseif ($https == '-1') {
         $session->setValue('https', -1);
     }
     if ($flash == '1') {
         $session->setValue('flash', 1);
     } elseif ($flash == '-1') {
         $session->setValue('flash', -1);
     }
     if (!empty($_GET['back_tool'])) {
         $back_tool = $_GET['back_tool'];
         $back_file = $back_tool . '.php';
     } else {
         $back_tool = '';
         $back_file = '';
     }
     if (mb_stristr($_SERVER['PHP_SELF'], 'homepage.php')) {
         $session->setToolName('homepage');
     }
     $environment->setSessionItem($session);
     // redirect
     $current_context = $environment->getCurrentContextItem();
     if (isset($root_session_id) and !empty($root_session_id)) {
         // change cookie
         if ($cookie == '1') {
             $session_manager = $environment->getSessionManager();
             $session = $session_manager->get($root_session_id);
             $session->setValue('cookie', 2);
             unset($session_manager);
             $environment->setSessionItem($session);
         }
         $params = $history[0]['parameter'];
         $params['SID'] = $root_session_id;
         redirect($history[0]['context'], $history[0]['module'], $history[0]['function'], $params, '', '', $back_tool);
     } elseif (!$current_context->isOpenForGuests() and (empty($back_tool) or !empty($back_tool) and $back_tool == 'commsy')) {
         if (!$current_context->isServer()) {
             $parent_context = $current_context->getContextItem();
             if ($parent_context->isOpenForGuests()) {
                 if ($parent_context->isPortal()) {
                     $params = array();
                     $params['room_id'] = $current_context->getItemID();
                     if ($current_context->isGroupRoom()) {
                         $project_room_item_id = $current_context->getLinkedProjectItemID();
                         if (!empty($project_room_item_id)) {
                             $params['room_id'] = $project_room_item_id;
                         }
                     }
                     redirect($parent_context->getItemID(), 'home', 'index', $params, '', '', $back_tool);
                     unset($params);
                 } else {
                     redirect($parent_context->getItemID(), 'home', 'index', '', '', '', $back_tool);
                 }
             }
         } else {
             redirect($current_context->getItemID(), 'home', 'index', '', '', '', $back_tool);
         }
     } else {
         redirect($history[0]['context'], $history[0]['module'], $history[0]['function'], $history[0]['parameter'], '', '', $back_tool);
     }
     $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
     redirect_with_url($url);
 }
예제 #2
0
파일: homepage.php 프로젝트: a2call/commsy
    $SID = $_COOKIE['SID_homepage'];
    // session id in a cookie
} elseif (!empty($_GET['SID'])) {
    $SID = $_GET['SID'];
    // session id via GET-VARS (url)
} elseif (!empty($_POST['SID'])) {
    $SID = $_POST['SID'];
    // session id via POST-VARS (form posts)
} else {
    // no session created
    // so create session and redirect to requested page
    $session = new cs_session_item();
    $session->createSessionID('guest');
    $session->setToolName('homepage');
    // external reload to check javascript
    $session_manager = $environment->getSessionManager();
    $session_manager->save($session);
    include_once 'pages/context_reload.php';
    exit;
}
if (!empty($SID)) {
    // there is a session_id,
    // and there must be a session,
    // so we can load the session information
    $session_manager = $environment->getSessionManager();
    $session = $session_manager->get($SID);
    if ($session->issetValue('user_id')) {
        // session is in database, so session is valid and user has already logged on
        if (!$session->issetValue('cookie')) {
            // second time a user get a commsy page
            if (isset($_COOKIE['SID'])) {