Ignore:
Timestamp:
06/29/07 15:17:46 (17 years ago)
Author:
niltonneto
Message:

Versão nova do ADODB (4.5 para 4.95)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/phpgwapi/inc/adodb/tests/testsessions.php

    r2 r34  
    22 
    33/*  
    4 V4.51 29 July 2004  (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved. 
     4V4.80 8 Mar 2006  (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. 
    55  Released under both BSD license and Lesser GPL library license.  
    66  Whenever there is any discrepancy between the two licenses,  
     
    1818//------------------------------------------------------------------- 
    1919         
     20error_reporting(E_ALL); 
     21 
     22 
     23ob_start(); 
     24include('../session/adodb-cryptsession2.php'); 
     25 
     26$options['debug'] = 99; 
     27$db = 'postgres'; 
     28 
     29#### CONNECTION 
     30switch($db) { 
     31case 'oci8':  
     32        $options['table'] = 'adodb_sessions2'; 
     33        ADOdb_Session::config('oci8', '', 'jcollect', 'natsoft', '',$options); 
     34        break; 
     35 
     36case 'postgres': 
     37        ADOdb_Session::config('postgres', 'localhost', 'tester', 'test', 'test',$options); 
     38        break; 
    2039         
    21 #### CONNECTION 
    22 if (1) { 
    23         $ADODB_SESSION_DRIVER='oci8'; 
    24         $ADODB_SESSION_CONNECT=''; 
    25         $ADODB_SESSION_USER ='scott'; 
    26         $ADODB_SESSION_PWD ='natsoft'; 
    27         $ADODB_SESSION_DB =''; 
    28 } else { 
    29         $ADODB_SESSION_DRIVER='mysql'; 
    30         $ADODB_SESSION_CONNECT='localhost'; 
    31         $ADODB_SESSION_USER ='root'; 
    32         $ADODB_SESSION_PWD =''; 
    33         $ADODB_SESSION_DB ='xphplens_2'; 
     40case 'mysql': 
     41default: 
     42        ADOdb_Session::config('mysql', 'localhost', 'root', '', 'xphplens_2',$options); 
     43        break; 
     44 
     45 
    3446} 
    3547         
    36 ### TURN DEBUGGING ON 
    37         $ADODB_SESS_DEBUG = true; 
    3848 
    3949         
     
    4252        $ADODB_SESSION_EXPIRE_NOTIFY = array('USER','NotifyExpire'); 
    4353 
    44          
    45 #### INIT 
    46         ob_start(); 
    47         error_reporting(E_ALL); 
    48         include('../session/adodb-cryptsession.php'); 
     54        adodb_session_create_table(); 
    4955        session_start(); 
    5056 
    51  
     57        adodb_session_regenerate_id(); 
     58         
    5259### SETUP SESSION VARIABLES  
    53         $HTTP_SESSION_VARS['MONKEY'] = array('1','abc',44.41); 
    54         if (!isset($HTTP_GET_VARS['nochange'])) @$HTTP_SESSION_VARS['AVAR'] += 1; 
     60        if (empty($_SESSION['MONKEY'])) $_SESSION['MONKEY'] = array(1,'abc',44.41); 
     61        else $_SESSION['MONKEY'][0] += 1; 
     62        if (!isset($_GET['nochange'])) @$_SESSION['AVAR'] += 1; 
    5563 
    5664         
    5765### START DISPLAY 
    5866        print "<h3>PHP ".PHP_VERSION."</h3>"; 
    59         print "<p><b>\$HTTP_SESSION_VARS['AVAR']={$HTTP_SESSION_VARS['AVAR']}</b></p>"; 
     67        print "<p><b>\$_SESSION['AVAR']={$_SESSION['AVAR']}</b></p>"; 
    6068         
    61         print "<hr> <b>Cookies</b>: "; 
    62         print_r($HTTP_COOKIE_VARS); 
     69        print "<hr /> <b>Cookies</b>: "; 
     70        print_r($_COOKIE); 
     71         
     72        var_dump($_SESSION['MONKEY']); 
    6373         
    6474### RANDOMLY PERFORM Garbage Collection 
    65         if (rand() % 10 == 0) { 
     75### In real-production environment, this is done for you 
     76### by php's session extension, which calls adodb_sess_gc() 
     77### automatically for you. See php.ini's 
     78### session.cookie_lifetime and session.gc_probability 
     79 
     80        if (rand() % 5 == 0) { 
    6681         
    67                 print "<hr><p><b>Garbage Collection</b></p>"; 
     82                print "<hr /><p><b>Garbage Collection</b></p>"; 
    6883                adodb_sess_gc(10); 
    6984                 
    70                 print "<p>Random session destroy</p>"; 
    71                 session_destroy(); 
     85                if (rand() % 2 == 0) { 
     86                        print "<p>Random session destroy</p>"; 
     87                        session_destroy(); 
     88                } 
    7289        } 
    7390?> 
Note: See TracChangeset for help on using the changeset viewer.