Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
pre_session.php
1 <?php
17 // Suppress frontend errors
18 $current_val = ini_get('display_errors');
19 ini_set('display_errors', 0);
20 
21 if (!isset($_SESSION['PRIMARY_SESSIONID'])) {
22  error_log('No primary session');
23  reload_browser(TRUE, $SQ_SITE_NETWORK);
24 } else {
25 
26  // Set up the session handler
27  $session_handler = $GLOBALS['SQ_SYSTEM']->getSessionHandlerClassName();
28  $session_handler_instance = new $session_handler();
29  $session_exists = $session_handler_instance->sessionExists($_SESSION['PRIMARY_SESSIONID']);
30 
31  if (!$session_exists) {
32  unset($_SESSION['PRIMARY_SESSIONID']);
33  reload_browser(FALSE, $SQ_SITE_NETWORK);
34  }
35 
36  $pri_session = $session_handler_instance->unserialiseSession($_SESSION['PRIMARY_SESSIONID']);
37  $pri_timestamp = (isset($pri_session['SQ_SESSION_TIMESTAMP'])) ? $pri_session['SQ_SESSION_TIMESTAMP'] : -1;
38  $sec_timestamp = (isset($_SESSION['SQ_SESSION_TIMESTAMP'])) ? $_SESSION['SQ_SESSION_TIMESTAMP'] : -1;
39 
40  if ($pri_timestamp > $sec_timestamp) {
41  $session_handler_instance->syncSession($_SESSION['PRIMARY_SESSIONID']);
42  reload_browser(FALSE, $SQ_SITE_NETWORK);
43  }
44 }
45 
46 // Restore the current setting
47 ini_set('display_errors', $current_val);
48 
49 function reload_browser($do_js_request=FALSE, $site_network)
50 {
51  $primary_url = $site_network->getPrimaryURL();
52  ?>
53  <html>
54  <head>
55  <script type="text/javascript" src="<?php echo sq_web_path('lib'); ?>/js/JsHttpConnector.js"></script>
56  <script type="text/javascript" src="<?php echo $primary_url; ?>/__lib/session/session.php?in_primary=<?php echo (sq_web_path('root_url') == $primary_url) ? 1 : 0; ?>&site_network=<?php echo $site_network->id; ?>"></script>
57  <script type="text/javascript">
58  <?php
59  if ($do_js_request) {
60  echo 'start_session_handler("'.sq_web_path('lib').'/session/session.php?site_network='.$site_network->id.'");'."\n";
61  }
62  ?>
63  setTimeout("document.location.href = document.location.href.replace('SQ_ACTION=logout','')", 100);
64  </script>
65  </head>
66  <body>
67  </body>
68  </html>
69  <?php
70  exit();
71 
72 }//end reload_browser()
73 
74 
75 ?>