root/trunk/includes/session_save_handler.inc.php

Revision 1, 3.0 KB (checked in by anonymous, 7 years ago)

initial import

Line 
1<?php
2/****************************************************** Open .node ***
3 * Description:   
4 * Status:        Stable.
5 * Author:        Alexandre Dath <alexandre@dotnode.com>
6 * $Id$
7 *
8 * Copyright (C) 2005 Alexandre Dath <alexandre@dotnode.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 ******************** http://opensource.ikse.net/projects/dotnode ***/
24
25
26function _sess_open ($save_path, $session_name) {
27  global $sess_save_path, $sess_session_name;
28     
29  $sess_save_path = $save_path;
30  $sess_session_name = $session_name;
31  return(true);
32}
33
34function _sess_close() {
35  return(true);
36}
37
38function _sess_read ($id) {
39  global $sess_save_path, $sess_session_name;
40
41  $elmt[0] = substr($id, 0, 2);
42  $elmt[1] = substr($id, 2, 2);
43  if(!file_exists($sess_save_path.'/'.$elmt[0].'/'.$elmt[1]) )
44  {
45    @mkdir($sess_save_path.'/'.$elmt[0]);
46    @mkdir($sess_save_path.'/'.$elmt[0].'/'.$elmt[1]);
47  }
48  $sess_file = $sess_save_path.'/'.$elmt[0].'/'.$elmt[1].'/'.$id;
49
50
51  if (@filesize($sess_file)>0 && $fp = @fopen($sess_file, "r")) {
52   $sess_data = fread($fp, filesize($sess_file));
53   return($sess_data);
54  } else {
55   return(""); // Doit retourner "" ici.
56  }
57
58}
59
60function _sess_write ($id, $sess_data) {
61  global $sess_save_path, $sess_session_name;
62
63  $elmt[0] = substr($id, 0, 2);
64  $elmt[1] = substr($id, 2, 2);
65  if(!file_exists($sess_save_path.'/'.$elmt[0].'/'.$elmt[1]) )
66  {
67    @mkdir($sess_save_path.'/'.$elmt[0]);
68    @mkdir($sess_save_path.'/'.$elmt[0].'/'.$elmt[1]);
69  }
70  $sess_file = $sess_save_path.'/'.$elmt[0].'/'.$elmt[1].'/'.$id;
71
72  if ($fp = @fopen($sess_file, "w")) {
73   return(fwrite($fp, $sess_data));
74  } else {
75   return(false);
76  }
77
78}
79
80function _sess_destroy ($id) {
81  global $sess_save_path, $sess_session_name;
82
83  $elmt[0] = substr($id, 0, 2);
84  $elmt[1] = substr($id, 2, 2);
85  if(!file_exists($sess_save_path.'/'.$elmt[0].'/'.$elmt[1]) )
86  {
87    @mkdir($sess_save_path.'/'.$elmt[0]);
88    @mkdir($sess_save_path.'/'.$elmt[0].'/'.$elmt[1]);
89  }
90  $sess_file = $sess_save_path.'/'.$elmt[0].'/'.$elmt[1].'/'.$id;
91 
92  return(@unlink($sess_file));
93}
94
95/*******************************************************
96 * ATTENTION - Vous devrez impl�nter un      *
97 * collecteur de donn� obosol�s ici. *
98 *******************************************************/
99function _sess_gc ($maxlifetime) {
100  return true;
101}
102?>
Note: See TracBrowser for help on using the browser.