Shutdown the library/adodb/tests/testsessions.php script for security reasons
[openemr.git] / library / adodb / tests / testsessions.php
blob5c9ae5a90a7cf383e24840baf751c27f6d9f222b
1 <?php
3 exit();
5 /*
6 V4.80 8 Mar 2006 (c) 2000-2011 John Lim (jlim#natsoft.com). All rights reserved.
7 Released under both BSD license and Lesser GPL library license.
8 Whenever there is any discrepancy between the two licenses,
9 the BSD license will take precedence.
10 Set tabs to 4 for best viewing.
12 Latest version is available at http://adodb.sourceforge.net
15 function NotifyExpire($ref,$key)
17 print "<p><b>Notify Expiring=$ref, sessionkey=$key</b></p>";
20 //-------------------------------------------------------------------
22 error_reporting(E_ALL);
25 ob_start();
26 include('../session/adodb-cryptsession2.php');
29 $options['debug'] = 1;
30 $db = 'postgres';
32 #### CONNECTION
33 switch($db) {
34 case 'oci8':
35 $options['table'] = 'adodb_sessions2';
36 ADOdb_Session::config('oci8', 'mobydick', 'jdev', 'natsoft', 'mobydick',$options);
37 break;
39 case 'postgres':
40 $options['table'] = 'sessions2';
41 ADOdb_Session::config('postgres', 'localhost', 'postgres', 'natsoft', 'northwind',$options);
42 break;
44 case 'mysql':
45 default:
46 $options['table'] = 'sessions2';
47 ADOdb_Session::config('mysql', 'localhost', 'root', '', 'xphplens_2',$options);
48 break;
55 #### SETUP NOTIFICATION
56 $USER = 'JLIM'.rand();
57 $ADODB_SESSION_EXPIRE_NOTIFY = array('USER','NotifyExpire');
59 adodb_session_create_table();
60 session_start();
62 adodb_session_regenerate_id();
64 ### SETUP SESSION VARIABLES
65 if (empty($_SESSION['MONKEY'])) $_SESSION['MONKEY'] = array(1,'abc',44.41);
66 else $_SESSION['MONKEY'][0] += 1;
67 if (!isset($_GET['nochange'])) @$_SESSION['AVAR'] += 1;
70 ### START DISPLAY
71 print "<h3>PHP ".PHP_VERSION."</h3>";
72 print "<p><b>\$_SESSION['AVAR']={$_SESSION['AVAR']}</b></p>";
74 print "<hr /> <b>Cookies</b>: ";
75 print_r($_COOKIE);
77 var_dump($_SESSION['MONKEY']);
79 ### RANDOMLY PERFORM Garbage Collection
80 ### In real-production environment, this is done for you
81 ### by php's session extension, which calls adodb_sess_gc()
82 ### automatically for you. See php.ini's
83 ### session.cookie_lifetime and session.gc_probability
85 if (rand() % 5 == 0) {
87 print "<hr /><p><b>Garbage Collection</b></p>";
88 adodb_sess_gc(10);
90 if (rand() % 2 == 0) {
91 print "<p>Random own session destroy</p>";
92 session_destroy();
94 } else {
95 $DB = ADODB_Session::_conn();
96 $sessk = $DB->qstr('%AZ'.rand().time());
97 $olddate = $DB->DBTimeStamp(time()-30*24*3600);
98 $rr = $DB->qstr(rand());
99 $DB->Execute("insert into {$options['table']} (sesskey,expiry,expireref,sessdata,created,modified) values ($sessk,$olddate, $rr,'',$olddate,$olddate)");