Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

forgot.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: forgot.php 9821 2003-05-19 07:30:55Z 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 //require( "kernel/ezuser/user/usercheck.php" );
23 // include_once( "classes/INIFile.php" );
24 // include_once( "classes/eztemplate.php" );
25 // include_once( "classes/ezhttptool.php" );
26
27 // include_once( "ezuser/classes/ezforgot.php" );
28 // include_once( "ezmail/classes/ezmail.php" );
29
30 $ini =& eZINI::instance( 'site.ini' );
31 $Language = $ini->variable( "eZUserMain", "Language" );
32 $headersInfo = getallheaders();
33
34 $languageIni = new eZINI( "kernel/ezuser/user/intl/" . $Language . "/forgot.php.ini", false );
35
36 // Get the user.
37 if ( isset( $Login ) && $Login )
38 {
39 $getUser = new eZUser();
40 $user = $getUser->getUser( $Login );
41 }
42
43 if ( isset( $ChangeButton ) && ( $user == false ) )
44 {
45 eZHTTPTool::header( "Location: /user/unsuccessfull/" );
46 exit();
47 }
48
49 // Store the user with a unique hash and mail the hash variable to the user.
50 if ( $user )
51 {
52 if ( eZMail::validate( $user->email() ) == false )
53 {
54 eZHTTPTool::header( "Location: /user/missingemail/" );
55 exit();
56 }
57
58 $subjectText = ( $languageIni->variable( "strings", "subject_text" ) . " " . $headersInfo["Host"] );
59 $bodyText = $languageIni->variable( "strings", "body_text" );
60
61 $bodyFooter = $languageIni->variable( "strings", "body_footer" ); //SF
62 $reminderMailFromAddress = $ini->variable( "eZUserMain", "ReminderMailFromAddress" ); //SF
63
64 $forgot = new eZForgot();
65 $forgot->setUserID( $user->id() );
66 $userID = $user->id();
67 $forgot->store();
68
69 $mailpassword = new eZMail();
70 $mailpassword->setTo( $user->email() );
71 $mailpassword->setSubject( $subjectText );
72 $mailpassword->setFrom( $reminderMailFromAddress ); //SF
73
74 $body = ( $bodyText . "\n");
75 $body .= ( "http://" . $headersInfo["Host"] . $ini->WWWDir . $ini->Index . "/user/forgot/change/" . htmlspecialchars( $forgot->Hash() ) );
76 $body .= ( $bodyFooter ); //SF
77
78 $mailpassword->setBody( $body );
79 $mailpassword->send();
80
81
82 eZHTTPTool::header( "Location: /user/successfull/" );
83 exit();
84 }
85
86
87 if ( $Action == "change" )
88 {
89 $change = new eZForgot();
90
91 if ( $change->check( $Hash ) )
92 {
93 $change->get( $change->check( $Hash ) );
94 $subjectNewPassword = $languageIni->variable( "strings", "subject_text_password" );
95
96 $reminderMailFromAddress = $ini->variable( "eZUserMain", "ReminderMailFromAddress" ); //SF
97 $bodyFooter = $languageIni->variable( "strings", "body_footer" ); //SF
98
99 $bodyNewPassword = $languageIni->variable( "strings", "body_text_password" );
100 $passwordText = $languageIni->variable( "strings", "password" );
101 $userID = $change->userID();
102 $user = new eZUser( $userID );
103 $password = substr( md5( microtime() ), 0, 7 );
104 $user->setPassword( $password );
105 $user->store();
106 $mail = new eZMail();
107 $mail->setTo( $user->email() );
108 $mail->setSubject( $subjectNewPassword . " " . $headersInfo["Host"] );
109
110 $mail->setFrom( $reminderMailFromAddress ); //SF
111
112 $body = ( $bodyNewPassword . "\nhttp://" . $headersInfo["Host"] . $ini->WWWDir . $ini->Index . "/user/login/.\n" ); //SF
113 $body .= ( $passwordText . ": " . $password );
114
115 $body .= ( $bodyFooter ); //SF
116
117 $mail->setBody( $body );
118 $mail->send();
119
120 // Cleanup
121 $change->get( $change->check( $Hash ) );
122 $change->delete();
123 }
124 eZHTTPTool::header( "Location: /user/generated/" );
125 exit();
126 }
127
128 // Template
129 $t = new eZTemplate( "kernel/ezuser/user/" . $ini->variable( "eZUserMain", "TemplateDir" ), "kernel/ezuser/user/intl", $Language, "forgot.php" );
130 $t->setAllStrings();
131
132 $t->set_file( array( "login" => "forgot.tpl" ) );
133
134 $t->pparse( "output", "login" );
135
136 ?>
$Login
$Login
Definition: admin/useredit.php:445
$userID
else $userID
Definition: appointmentedit.php:121
eZForgot
Definition: ezforgot.php:58
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZINI
Reads and writes .ini style configuration files.
eZMail
Definition: ezmail.php:57
eZMail\validate
static validate( $address)
Definition: ezmail.php:599
eZTemplate
Definition: eztemplate.php:107
eZUser
Definition: ezuser.php:76
$Action
$Action
Definition: companysearch.php:80
$mail
$mail
Definition: ezbulkmail/admin/maillist.php:61
exit
exit
Definition: folder.php:81
$t
if(isset( $Login) && $Login) if(isset( $ChangeButton) &&( $user==false)) if( $user) if( $Action=="change") $t
Definition: forgot.php:129
$languageIni
$languageIni
Definition: forgot.php:34
$Language
$Language
Definition: forgot.php:31
$ini
$ini
Definition: forgot.php:30
$headersInfo
$headersInfo
Definition: forgot.php:32
$user
$user
Definition: user/adlist.php:39
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.