4ed58a2f571fdc8b0f62833a3980748d0520096f
[fa-stable.git] / access / password_reset.php
1 <?php
2 /**********************************************************************
3     Copyright (C) FrontAccounting, LLC.
4         Released under the terms of the GNU General Public License, GPL, 
5         as published by the Free Software Foundation, either version 3 
6         of the License, or (at your option) any later version.
7     This program is distributed in the hope that it will be useful,
8     but WITHOUT ANY WARRANTY; without even the implied warranty of
9     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
10     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12         if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_to_root']))
13                 die(_("Restricted access"));
14         include_once($path_to_root . "/includes/ui.inc");
15         include_once($path_to_root . "/includes/page/header.inc");
16
17         $js = "<script language='JavaScript' type='text/javascript'>
18 function defaultCompany()
19 {
20         document.forms[0].company_login_name.options[".$_SESSION["wa_current_user"]->company."].selected = true;
21 }
22 </script>";
23         add_js_file('login.js');
24
25         if (!isset($def_coy))
26                 $def_coy = 0;
27         $def_theme = "default";
28
29         $login_timeout = $_SESSION["wa_current_user"]->last_act;
30
31         $title = $app_title." ".$version." - "._("Password reset");
32         $encoding = isset($_SESSION['language']->encoding) ? $_SESSION['language']->encoding : "iso-8859-1";
33         $rtl = isset($_SESSION['language']->dir) ? $_SESSION['language']->dir : "ltr";
34         $onload = !$login_timeout ? "onload='defaultCompany()'" : "";
35
36         echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n";
37         echo "<html dir='$rtl' >\n";
38         echo "<head profile=\"http://www.w3.org/2005/10/profile\"><title>$title</title>\n";
39         echo "<meta http-equiv='Content-type' content='text/html; charset=$encoding' />\n";
40         echo "<link href='$path_to_root/themes/$def_theme/default.css' rel='stylesheet' type='text/css'> \n";
41         echo "<link href='$path_to_root/themes/default/images/favicon.ico' rel='icon' type='image/x-icon'> \n";
42         send_scripts();
43         echo $js;
44         echo "</head>\n";
45
46         echo "<body id='loginscreen' $onload>\n";
47
48         echo "<table class='titletext'><tr><td>$title</td></tr></table>\n";
49         
50         div_start('_page_body');
51         br();br();
52         start_form(false, false, @$_SESSION['timeout']['uri'], "resetform");
53         start_table(false, "class='login'");
54         start_row();
55         echo "<td align='center' colspan=2>";
56   echo "<a target='_blank' href='$power_url'><img src='$path_to_root/themes/$def_theme/images/logo_frontaccounting.png' alt='FrontAccounting' height='50' onload='fixPNG(this)' border='0' /></a>";
57         echo "</td>\n";
58         end_row();
59
60         echo "<input type='hidden' id=ui_mode name='ui_mode' value='".$_SESSION["wa_current_user"]->ui_mode."' />\n";
61         table_section_title(_("Version")." $version   Build $build_version - "._("Password reset"));
62
63         text_row(_("Email"), "email_entry_field", "", 20, 30);
64
65   if (isset($_SESSION['wa_current_user']->company))
66     $coy =  $_SESSION['wa_current_user']->company;
67   else
68     $coy = $def_coy;
69   if (!@$text_company_selection) {
70     echo "<tr><td>"._("Company")."</td><td><select name='company_login_name'>\n";
71     for ($i = 0; $i < count($db_connections); $i++)
72       echo "<option value=$i ".($i==$coy ? 'selected':'') .">" . $db_connections[$i]["name"] . "</option>";
73     echo "</select>\n";
74     echo "</td></tr>";
75   } else {
76 //                      $coy = $def_coy;
77     text_row(_("Company"), "company_login_nickname", "", 20, 50);
78   }
79   start_row();
80   label_cell("Please enter your e-mail", "colspan=2 align='center' id='log_msg'");
81   end_row();
82         end_table(1);
83         echo "<center><input type='submit' value='&nbsp;&nbsp;"._("Send password -->")."&nbsp;&nbsp;' name='SubmitReset'
84                  onclick='set_fullmode();' /></center>\n";
85
86         end_form(1);
87         $Ajax->addScript(true, "document.forms[0].password.focus();");
88
89     echo "<script language='JavaScript' type='text/javascript'>
90     //<![CDATA[
91             <!--
92             document.forms[0].email_entry_field.select();
93             document.forms[0].email_entry_field.focus();
94             //-->
95     //]]>
96     </script>";
97     div_end();
98         echo "<table class='bottomBar'>\n";
99         echo "<tr>";
100         if (isset($_SESSION['wa_current_user'])) 
101                 $date = Today() . " | " . Now();
102         else    
103                 $date = date("m/d/Y") . " | " . date("h.i am");
104         echo "<td class='bottomBarCell'>$date</td>\n";
105         echo "</tr></table>\n";
106         echo "<table class='footer'>\n";
107         echo "<tr>\n";
108         echo "<td><a target='_blank' href='$power_url' tabindex='-1'>$app_title $version - " . _("Theme:") . " " . $def_theme . "</a></td>\n";
109         echo "</tr>\n";
110         echo "<tr>\n";
111         echo "<td><a target='_blank' href='$power_url' tabindex='-1'>$power_by</a></td>\n";
112         echo "</tr>\n";
113         echo "</table><br><br>\n";
114         echo "</body></html>\n";
115
116 ?>