dolibarr/htdocs/public/test/test_sessionlock.php

88 lines
2.7 KiB
PHP
Raw Permalink Normal View History

2017-07-02 11:18:23 +00:00
<?php
2023-12-04 12:49:31 +00:00
2021-02-26 17:58:34 +00:00
if (!defined('NOREQUIREUSER')) {
define('NOREQUIREUSER', '1');
}
if (!defined('NOREQUIREDB')) {
define('NOREQUIREDB', '1');
}
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
if (!defined('NOREQUIRETRAN')) {
define('NOREQUIRETRAN', '1');
}
if (!defined('NOSTYLECHECK')) {
define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
}
if (!defined("NOLOGIN")) {
define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
}
2017-07-02 11:18:23 +00:00
// If you don't need session management (can't be logged if no session used). You must also set
2017-07-02 21:38:19 +00:00
// NOCSRFCHECK, NOTOKENRENEWAL, NOLOGIN
2017-07-02 11:18:23 +00:00
// Disable module with GETPOST('disablemodules') won't work. Variable 'dol_...' will not be set.
// $_SESSION are then simple vars if sessions are not active.
2021-02-19 13:43:03 +00:00
// TODO We can close session with session_write_close() as soon as we just need read access everywhere in code.
2021-02-26 17:58:34 +00:00
if (!defined("NOSESSION")) {
define("NOSESSION", '1');
}
2017-07-02 11:18:23 +00:00
2022-07-11 18:18:03 +00:00
// Special
// We add header and output some content before the include of main.inc.php !!
// Because we need to So we can make
header("Content-type: text/html; charset=UTF8");
// Security options
header("X-Content-Type-Options: nosniff"); // With the nosniff option, if the server says the content is text/html, the browser will render it as text/html (note that most browsers now force this option to on)
header("X-Frame-Options: SAMEORIGIN"); // Frames allowed only if on same domain (stop some XSS attacks)
2021-02-19 14:46:59 +00:00
print "Legend:<br>\n";
print 'PHP_SESSION_DISABLED='.PHP_SESSION_DISABLED."<br>\n";
print 'PHP_SESSION_NONE='.PHP_SESSION_NONE."<br>\n";
print 'PHP_SESSION_ACTIVE='.PHP_SESSION_ACTIVE."<br>\n";
2017-07-02 11:18:23 +00:00
print '<br>';
2021-02-19 14:46:59 +00:00
print 'session_status='.session_status().' (before main.inc.php)';
print '<br>';
2021-02-19 13:43:03 +00:00
2022-09-07 18:08:59 +00:00
// Load Dolibarr environment
2026-02-10 12:56:04 +00:00
@include '../../main.inc.php';
/**
2026-03-29 14:08:28 +00:00
* @var DoliDB $db
* @var HookManager $hookmanager
* @var Translate $langs
*
2026-02-10 12:56:04 +00:00
* @var string $dolibarr_main_prod
2026-03-29 14:08:28 +00:00
* @var string $dolibarr_main_test
2026-02-10 12:56:04 +00:00
*/
2021-02-19 13:43:03 +00:00
// Security
2026-03-29 14:08:28 +00:00
if (!empty($dolibarr_main_prod) || empty($dolibarr_main_test)) {
accessforbidden('Access forbidden when $dolibarr_main_prod is set to 1 or $dolibarr_main_test is NOT set to 1 into conf.php');
2021-02-19 13:43:03 +00:00
}
2017-07-02 11:18:23 +00:00
/*
* View
*/
2021-11-24 19:58:34 +00:00
print 'session_status='.session_status().' (after main.inc.php)';
print '<br>';
2021-11-24 19:58:34 +00:00
//print 'a'.$_SESSION['disablemodules'].'b';
2017-07-02 11:18:23 +00:00
2021-11-24 19:58:34 +00:00
print "\n<br>This page is visible. It means you are not locked by another page called in same session.";
2017-07-02 11:18:23 +00:00
2021-11-24 19:58:34 +00:00
//session_write_close();