ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
inc.pwassist_session_handler.php File Reference

Go to the source code of this file.

Functions

 db_pwassist_session_open ($save_path, $name)
 Database Session Handling for the password assistance use case. More...
 
 db_pwassist_session_close ()
 close session More...
 
 db_pwassist_create_id ()
 
 db_pwassist_session_read ($pwassist_id)
 
 db_pwassist_session_find ($user_id)
 
 db_pwassist_session_write ($pwassist_id, $maxlifetime, $user_id)
 Writes serialized session data to the database. More...
 
 db_pwassist_session_destroy ($pwassist_id)
 destroy session More...
 
 db_pwassist_session_gc ()
 removes all expired sessions More...
 

Function Documentation

◆ db_pwassist_create_id()

db_pwassist_create_id ( )

Definition at line 67 of file inc.pwassist_session_handler.php.

67 : string
68{
69 global $DIC;
70
71 $ilDB = $DIC->database();
72
73 do {
74 $hash = bin2hex(ilPasswordUtils::getBytes(32));
75
76 $exists = (
77 (int) ($ilDB->fetchAssoc(
78 $ilDB->query(
79 "SELECT EXISTS(" .
80 "SELECT 1 FROM usr_pwassist WHERE pwassist_id = " . $ilDB->quote($hash, ilDBConstants::T_TEXT) .
81 ") AS hit"
82 )
83 )['hit'] ?? 0) === 1
84 );
85 } while ($exists);
86
87 return $hash;
88}
static getBytes($length)
Generate random bytes using OpenSSL or Mcrypt and mt_rand() as fallback.
global $ilDB
$DIC
Definition: xapitoken.php:46

References $DIC, $ilDB, ilPasswordUtils\getBytes(), and ilDBConstants\T_TEXT.

+ Here is the call graph for this function:

◆ db_pwassist_session_close()

db_pwassist_session_close ( )

close session

for a db nothing has to be done here

Definition at line 53 of file inc.pwassist_session_handler.php.

54{
55 return true;
56}

◆ db_pwassist_session_destroy()

db_pwassist_session_destroy (   $pwassist_id)

destroy session

Parameters
integer$pwassist_idsecure id

Definition at line 169 of file inc.pwassist_session_handler.php.

170{
171 global $DIC;
172
173 $ilDB = $DIC->database();
174
175 $q = "DELETE FROM usr_pwassist " .
176 "WHERE pwassist_id = " . $ilDB->quote($pwassist_id, "text");
177 $ilDB->manipulate($q);
178
179 return true;
180}

References $DIC, and $ilDB.

Referenced by ilPasswordAssistanceGUI\submitAssignPasswordForm(), and ilSessionTest\testPasswordAssisstanceSession().

+ Here is the caller graph for this function:

◆ db_pwassist_session_find()

db_pwassist_session_find (   $user_id)

Definition at line 119 of file inc.pwassist_session_handler.php.

120{
121 global $DIC;
122
123 $ilDB = $DIC->database();
124
125 $q = "SELECT * FROM usr_pwassist " .
126 "WHERE user_id = " . $ilDB->quote($user_id, "integer");
127 $r = $ilDB->query($q);
128 $data = $ilDB->fetchAssoc($r);
129
130 return $data;
131}
$data
Definition: storeScorm.php:23

References $data, $DIC, and $ilDB.

Referenced by ilSessionTest\testPasswordAssisstanceSession().

+ Here is the caller graph for this function:

◆ db_pwassist_session_gc()

db_pwassist_session_gc ( )

removes all expired sessions

Definition at line 186 of file inc.pwassist_session_handler.php.

187{
188 global $DIC;
189
190 $ilDB = $DIC->database();
191
192 $q = "DELETE FROM usr_pwassist " .
193 "WHERE expires < " . $ilDB->quote(time(), "integer");
194 $ilDB->manipulate($q);
195
196 return true;
197}

References $DIC, and $ilDB.

Referenced by ilSessionTest\testPasswordAssisstanceSession().

+ Here is the caller graph for this function:

◆ db_pwassist_session_open()

db_pwassist_session_open (   $save_path,
  $name 
)

Database Session Handling for the password assistance use case.

@module inc.db_pwassist_session_handler.php @modulegroup iliascore

Version
$Id$

Definition at line 43 of file inc.pwassist_session_handler.php.

44{
45 return true;
46}

◆ db_pwassist_session_read()

db_pwassist_session_read (   $pwassist_id)

Definition at line 97 of file inc.pwassist_session_handler.php.

98{
99 global $DIC;
100
101 $ilDB = $DIC->database();
102
103 $q = "SELECT * FROM usr_pwassist " .
104 "WHERE pwassist_id = " . $ilDB->quote($pwassist_id, "text");
105 $r = $ilDB->query($q);
106 $data = $ilDB->fetchAssoc($r);
107
108 return $data;
109}

References $data, $DIC, and $ilDB.

Referenced by ilPasswordAssistanceGUI\showAssignPasswordForm(), ilPasswordAssistanceGUI\submitAssignPasswordForm(), and ilSessionTest\testPasswordAssisstanceSession().

+ Here is the caller graph for this function:

◆ db_pwassist_session_write()

db_pwassist_session_write (   $pwassist_id,
  $maxlifetime,
  $user_id 
)

Writes serialized session data to the database.

Parameters
integer$pwassist_idsecure id
integer$maxlifetimesession max lifetime in seconds
integer$user_iduser id

Definition at line 140 of file inc.pwassist_session_handler.php.

141{
142 global $DIC;
143
144 $ilDB = $DIC->database();
145
146 $q = "DELETE FROM usr_pwassist " .
147 "WHERE pwassist_id = " . $ilDB->quote($pwassist_id, "text") . " " .
148 "OR user_id = " . $ilDB->quote($user_id, 'integer');
149 $ilDB->manipulate($q);
150
151 $ctime = time();
152 $expires = $ctime + $maxlifetime;
153 $ilDB->manipulateF(
154 "INSERT INTO usr_pwassist " .
155 "(pwassist_id, expires, user_id, ctime) " .
156 "VALUES (%s,%s,%s,%s)",
157 array("text", "integer", "integer", "integer"),
158 array($pwassist_id, $expires, $user_id, $ctime)
159 );
160
161 return true;
162}

References $DIC, and $ilDB.

Referenced by ilSessionTest\testPasswordAssisstanceSession().

+ Here is the caller graph for this function: