Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezforgot.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezforgot.php 9818 2003-05-16 13:15:58Z br $
5 //
6 // Created on: <20-Sep-2000 13:32:11 ce>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
29
50 // include_once( "classes/ezdb.php" );
51 // include_once( "classes/ezdatetime.php" );
52 // include_once( "ezuser/classes/ezuser.php" );
53 // include_once( "ezuser/classes/ezusergroup.php" );
54 // include_once( "ezaddress/classes/ezaddress.php" );
55 // include_once( "ezsession/classes/ezsession.php" );
56
57 class eZForgot
58 {
65 function eZForgot( $id=-1 )
66 {
67 if ( $id != -1 )
68 {
69 $this->ID = $id;
70 $this->get( $this->ID );
71 }
72 }
73
77 function store()
78 {
79 $db =& eZDB::globalDatabase();
80
81 $this->Hash = md5( microTime() );
82
83 $dbError = false;
84 $db->begin( );
85
86 if ( !isset( $this->ID ) )
87 {
88 $db->lock( "eZUser_Forgot" );
89
90 $nextID = $db->nextID( "eZUser_Forgot", "ID" );
91
92 $timeStamp = (new eZDateTime())->timeStamp( true );
93
94 $res = $db->query( "INSERT INTO eZUser_Forgot
95 ( ID, UserID, Hash, Time )
96 VALUES ( '$nextID',
97 '$this->UserID',
98 '$this->Hash',
99 '$timeStamp' )" );
100
101 $this->ID = $nextID;
102 }
103
104 $db->unlock();
105
106 if ( $res == false )
107 $db->rollback();
108 else
109 $db->commit();
110
111 return true;
112 }
113
118 function delete()
119 {
120 $db =& eZDB::globalDatabase();
121
122 if ( isset( $this->ID ) )
123 {
124 $db->query( "DELETE FROM eZUser_Forgot WHERE ID='$this->ID'" );
125 }
126
127 return true;
128 }
129
135 function get( $id=-1 )
136 {
137 $db =& eZDB::globalDatabase();
138
139 $ret = false;
140 if ( $id != -1 )
141 {
142 $db->array_query( $forgot_array, "SELECT * FROM eZUser_Forgot WHERE ID='$id'" );
143
144 if ( count( $forgot_array ) > 1 )
145 {
146 die( "Error: User's with the same ID was found in the database. This shouldent happen." );
147 }
148 else if ( count( $forgot_array ) == 1 )
149 {
150 $this->ID = $forgot_array[0][$db->fieldName("ID")];
151 $this->Time = $forgot_array[0][$db->fieldName("Time")];
152 $this->UserID = $forgot_array[0][$db->fieldName("UserID")];
153
154 $ret = true;
155 }
156 }
157 return $ret;
158 }
159
164 function check( $hash )
165 {
166 $db =& eZDB::globalDatabase();
167 $ret = false;
168
169 $hash = $db->escapeString( $hash );
170
171 $db->array_query( $forgot_array, "SELECT ID FROM eZUser_Forgot WHERE Hash='$hash'" );
172
173 if ( count( $forgot_array ) == 1 )
174 {
175 $ret = $forgot_array[0][$db->fieldName("ID")];
176 }
177 return $ret;
178 }
179
183 function id()
184 {
185 return $this->ID;
186 }
187
191 function userID( )
192 {
193 return $this->UserID;
194 }
195
199 function setUserID( $value )
200 {
201 $this->UserID = $value;
202 }
203
207 function hash()
208 {
209 return $this->Hash;
210 }
211
212 var $UserID;
213 var $ID;
214 var $Hash;
215 }
216
217 ?>
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZDateTime
Definition: ezdatetime.php:55
eZForgot
Definition: ezforgot.php:58
eZForgot\eZForgot
eZForgot( $id=-1)
Definition: ezforgot.php:65
eZForgot\hash
hash()
Definition: ezforgot.php:207
eZForgot\$ID
$ID
Definition: ezforgot.php:213
eZForgot\id
id()
Definition: ezforgot.php:183
eZForgot\$Hash
$Hash
Definition: ezforgot.php:214
eZForgot\store
store()
Definition: ezforgot.php:77
eZForgot\check
check( $hash)
Definition: ezforgot.php:164
eZForgot\setUserID
setUserID( $value)
Definition: ezforgot.php:199
eZForgot\userID
userID()
Definition: ezforgot.php:191
eZForgot\$UserID
$UserID
Definition: ezforgot.php:212
$id
$id
Definition: companytypelist.php:193
$db
$db
Definition: ezarticle/user/authorlist.php:53
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$res
$res
Definition: ezstats/admin/cron.php:45
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.