Subversion Repositories portal2

Rev

Rev 669 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
/*  emg - Energy Monitoring & Graphing
*  Copyright (C) 2006-2012 Romain Lievin
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 3 of the License, or
*  (at your option) any later version.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software Foundation,
*  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

?>

<div id="page_auth_pwdlost">
        <h1>
                <?php echo _('Password Lost'); ?>
        </h1>

        <?php

        $handle        = fopen('auth/login.txt', 'rt');
        if($handle === false)
        {
                $error->push(_('Unable to open password database.'));
        }
        else
        {                      
                fscanf($handle, "%s", $user_id);
                fscanf($handle, "%s", $file_username);
                fscanf($handle, "%s", $file_password);
                fscanf($handle, "%s", $file_email);
                fclose($handle);

                $file_password = "foobar";

                $to            = "admin@lievin.net"; //$file_email;
                $subject       = "EMG portal: password reminder";
                $body          = "The password belonging to your account '$file_username' is: $file_password";

                $ret           = mail($to, $subject, $body);

                $file_password = sha1($file_password);

                $handle        = fopen('auth/login.txt', 'wt');
                if($handle === false)
                {
                        $error->push(_('Unable to open password database.'));
                }
                else
                {      
                        fprintf($handle, "%s\n", 1);
                        fprintf($handle, "%s\n", $file_username);
                        fprintf($handle, "%s\n", $file_password);
                        fprintf($handle, "%s\n", $file_email);
                        fclose($handle);

                        if($ret)
                        {
                                echo '<div class="err_msg"><br/>';
                                echo _("A new password has been sent to $file_email.");
                                echo '</div>';
                        }
                        else
                        {
                                echo '<div class="err_msg"><br/>';
                                echo _("Message delivery failed...");
                                echo '</div>';
                        }
                }
        }

        ?>

</div>