ryxeo-glpi-git / forget.php @ effd25f5
Historique | Voir | Annoter | Télécharger (6,26 ko)
1 |
<?php
|
---|---|
2 |
/*
|
3 |
-------------------------------------------------------------------------
|
4 |
GLPI - Gestionnaire Libre de Parc Informatique
|
5 |
Copyright (C) 2003-2009 by the INDEPNET Development Team.
|
6 |
Copyright (C) 2009 Eric Seigne <eric.seigne@ryxeo.com>
|
7 |
|
8 |
http://indepnet.net/ http://glpi-project.org
|
9 |
-------------------------------------------------------------------------
|
10 |
|
11 |
LICENSE
|
12 |
|
13 |
This file is part of GLPI.
|
14 |
|
15 |
GLPI is free software; you can redistribute it and/or modify
|
16 |
it under the terms of the GNU General Public License as published by
|
17 |
the Free Software Foundation; either version 2 of the License, or
|
18 |
(at your option) any later version.
|
19 |
|
20 |
GLPI is distributed in the hope that it will be useful,
|
21 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
22 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
23 |
GNU General Public License for more details.
|
24 |
|
25 |
You should have received a copy of the GNU General Public License
|
26 |
along with GLPI; if not, write to the Free Software
|
27 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
28 |
--------------------------------------------------------------------------
|
29 |
*/
|
30 |
|
31 |
// ----------------------------------------------------------------------
|
32 |
// Original Author of file:
|
33 |
// Purpose of file:
|
34 |
// ----------------------------------------------------------------------
|
35 |
|
36 |
define('GLPI_ROOT', '.'); |
37 |
|
38 |
include (GLPI_ROOT . "/config/based_config.php"); |
39 |
include_once (GLPI_ROOT . "/inc/dbmysql.class.php"); |
40 |
include_once (GLPI_ROOT . "/inc/mailing.class.php"); |
41 |
include_once (GLPI_CONFIG_DIR . "/config_db.php"); |
42 |
include (GLPI_ROOT . "/inc/includes.php"); |
43 |
|
44 |
|
45 |
// Send UTF8 Headers
|
46 |
header("Content-Type: text/html; charset=UTF-8"); |
47 |
// Start the page
|
48 |
|
49 |
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"; |
50 |
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"fr\" lang=\"fr\">"; |
51 |
echo "<head><title>GLPI - Password</title>\n"; |
52 |
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8 \" />\n"; |
53 |
echo "<meta http-equiv=\"Content-Script-Type\" content=\"text/javascript\" />\n"; |
54 |
echo '<link rel="shortcut icon" type="images/x-icon" href="'.$CFG_GLPI["root_doc"].'/pics/favicon.ico" />'; |
55 |
|
56 |
// Appel CSS
|
57 |
echo '<link rel="stylesheet" href="'.$CFG_GLPI["root_doc"].'/css/styles.css" type="text/css" media="screen" />'; |
58 |
// surcharge CSS hack for IE
|
59 |
echo "<!--[if lte IE 6]>" ; |
60 |
echo "<link rel='stylesheet' href='".$CFG_GLPI["root_doc"]."/css/styles_ie.css' type='text/css' media='screen' >\n"; |
61 |
echo "<![endif]-->"; |
62 |
echo "<script type=\"text/javascript\"><!--document.getElementById('var_login_name').focus();--></script>"; |
63 |
|
64 |
echo "</head>"; |
65 |
|
66 |
// Body with configured stuff
|
67 |
echo "<body>"; |
68 |
// contenu
|
69 |
|
70 |
echo "<div id='contenulogin'>"; |
71 |
|
72 |
echo "<div id='logo-login'>"; |
73 |
|
74 |
echo nl2br(unclean_cross_side_scripting_deep($CFG_GLPI['text_login'])); |
75 |
|
76 |
|
77 |
echo "</div>"; |
78 |
|
79 |
|
80 |
if (!isset ($_POST['login_email'])){ |
81 |
echo "<div id='boxlogin'>"; |
82 |
|
83 |
echo "<form action='forget.php' method='post'>"; |
84 |
|
85 |
// Other CAS
|
86 |
if (isset($_GET["noAUTO"])) { |
87 |
echo "<input type='hidden' name='noAUTO' value='1' />"; |
88 |
} |
89 |
|
90 |
// redirect to tracking
|
91 |
if (isset($_GET["redirect"])){ |
92 |
manageRedirect($_GET["redirect"]); |
93 |
echo '<input type="hidden" name="redirect" value="'.$_GET['redirect'].'">'; |
94 |
} |
95 |
|
96 |
echo "<fieldset>"; |
97 |
echo '<legend>Envoyez-moi mon mot de passe</legend>'; |
98 |
|
99 |
echo '<div class="row"><span class="label"><label>Adresse email : </label></span><span class="formw"> <input type="text" name="login_email" id="login_email" size="15" /></span></div>'; |
100 |
|
101 |
echo "</fieldset>"; |
102 |
echo '<p ><span> <input type="submit" name="submit" value="'.$LANG["buttons"][2].'" class="submit" /></span></p>'; |
103 |
echo "</form>"; |
104 |
|
105 |
echo "<script type='text/javascript' >\n"; |
106 |
echo "document.getElementById('login_name').focus();"; |
107 |
echo "</script>"; |
108 |
|
109 |
echo "<p><a href=\"index.php\">Retour à l'accueil</a></p>"; |
110 |
echo "</div>"; // fin box login |
111 |
} |
112 |
//On a tappe l'adresse email
|
113 |
else {
|
114 |
|
115 |
function nbAleatoire() { |
116 |
mt_srand((double)microtime()*1000000); |
117 |
$num = mt_rand(48, 122); |
118 |
return $num; |
119 |
} |
120 |
|
121 |
function genChar() { |
122 |
do {
|
123 |
$num = nbAleatoire();
|
124 |
} while (( $num > 57 && $num < 65 ) || ( $num > 90 && $num < 97 )); |
125 |
$char = chr($num); |
126 |
return $char; |
127 |
} |
128 |
|
129 |
function makePassword($size){ |
130 |
$lepass = ""; |
131 |
for($i=1; $i<=$size; $i++) { |
132 |
$lepass = $lepass . genChar(); |
133 |
} |
134 |
$lepass = strtolower($lepass); |
135 |
return $lepass; |
136 |
} |
137 |
|
138 |
$query="SELECT name FROM `glpi_users` WHERE email='" . addslashes($_POST['login_email']) . "'"; |
139 |
$DB=new DB(); |
140 |
$result=$DB->query($query); |
141 |
$login=$DB->result($result,0,0); |
142 |
if($login != "") { |
143 |
$password=makePassword(8); |
144 |
$password_md5=md5($password); |
145 |
$query2="UPDATE `glpi_users` SET password_md5='" . $password_md5 . "' WHERE email='" . addslashes($_POST['login_email']) . "'"; |
146 |
$DB->query($query2) or die("Error: ".$DB->error()); |
147 |
|
148 |
$email = "Votre identifiant est: $login |
149 |
Votre mot de passe est: $password
|
150 |
Adresse de connexion: https://secure.ryxeo.com/glpi/
|
151 |
|
152 |
|
153 |
--
|
154 |
RyXéo SARL -- Le Support
|
155 |
";
|
156 |
|
157 |
$mmail=new glpi_phpmailer(); |
158 |
$mmail->From=$CFG_GLPI["admin_email"]; |
159 |
$mmail->FromName=$CFG_GLPI["admin_email"]; |
160 |
$mmail->AddAddress($_POST['login_email'],""); |
161 |
//Copy to admin
|
162 |
$mmail->AddBCC($CFG_GLPI["admin_email"], "GLPI"); |
163 |
$mmail->Subject="[SUPPORT RYXEO] -- MOT DE PASSE -- "; |
164 |
$mmail->Body=$email; |
165 |
|
166 |
if (!$mmail->Send()) { |
167 |
echo "Erreur"; |
168 |
} |
169 |
else {
|
170 |
echo "Votre mot de passe a été envoyé par email"; |
171 |
} |
172 |
} |
173 |
else {
|
174 |
|
175 |
echo "<div class='error'>"; |
176 |
echo "<noscript><p>"; |
177 |
echo $LANG["login"][26]; |
178 |
echo "</p></noscript>"; |
179 |
if (isset($_GET['error'])){ |
180 |
switch ($_GET['error']){ |
181 |
case 1 : // cookie error |
182 |
echo $LANG["login"][27]; |
183 |
break;
|
184 |
case 2 : // GLPI_SESSION_DIR not writable |
185 |
echo $LANG["install"][50].": ".GLPI_SESSION_DIR; |
186 |
break;
|
187 |
} |
188 |
} |
189 |
echo "Identifiant inconnu !"; |
190 |
echo "</div>"; |
191 |
} |
192 |
|
193 |
} |
194 |
|
195 |
echo "</div>"; // fin contenu login |
196 |
|
197 |
echo "<div id='footer-login'>"; |
198 |
echo "<a href=\"http://glpi-project.org/\" title=\"Powered By Indepnet\" >"; |
199 |
echo 'GLPI version '.(isset($CFG_GLPI["version"])?$CFG_GLPI["version"]:"").' Copyright (C) 2003-'.date("Y").' INDEPNET Development Team.'; |
200 |
echo "</a>"; |
201 |
echo "</div>"; |
202 |
|
203 |
echo "</body></html>"; |
204 |
|
205 |
// End
|
206 |
|
207 |
|
208 |
?>
|