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");
16 $js = "<script language='JavaScript' type='text/javascript'>
17 function defaultCompany()
19 document.forms[0].company_login_name.options[".$_SESSION["wa_current_user"]->company."].selected = true;
21 ".get_js_png_fix()."</script>";
22 $js2 = "<script language='JavaScript' type='text/javascript'>
23 function set_fullmode() {
24 document.getElementById('ui_mode').value = 1;
25 document.loginform.submit();
30 // Display demo user name and password within login form if "$allow_demo_mode" is true
31 if ($allow_demo_mode == true)
33 $demo_text = _("Login as user: demouser and password: password");
37 $demo_text = _("Please login here");
41 $def_theme = "default";
43 $login_timeout = $_SESSION["wa_current_user"]->last_act;
45 $title = $login_timeout ? _('Authorization timeout') : $app_title." ".$version." - "._("Login");
46 $encoding = isset($_SESSION['language']->encoding) ? $_SESSION['language']->encoding : "iso-8859-1";
47 $rtl = isset($_SESSION['language']->dir) ? $_SESSION['language']->dir : "ltr";
48 $onload = !$login_timeout ? "onload='defaultCompany()'" : "";
50 echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n";
51 echo "<html dir='$rtl' >\n";
52 echo "<head><title>$title</title>\n";
53 echo "<meta http-equiv='Content-type' content='text/html; charset=$encoding' />\n";
54 echo "<link href='$path_to_root/themes/$def_theme/login.css' rel='stylesheet' type='text/css'> \n";
62 echo "<body $onload>\n";
64 echo "<table class='titletext'><tr><td>$title</td></tr></table>\n";
67 start_form(false, false, $_SESSION['timeout']['uri'], "loginform");
68 start_table($table_style2);
70 echo "<td align='center' colspan=2>";
71 if (!$login_timeout) { // FA logo
72 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>";
74 echo "<font size=5>"._('Authorization timeout')."</font>";
79 echo "<input type='hidden' id=ui_mode name='ui_mode' value='".$_SESSION["wa_current_user"]->ui_mode."' />\n";
81 table_section_title(_("Version")." $version Build $build_version - "._("Login"));
82 $value = $login_timeout ? $_SESSION['wa_current_user']->loginname : ($allow_demo_mode ? "demouser":"");
84 text_row(_("User name"), "user_name_entry_field", $value, 20, 30);
86 $password = $allow_demo_mode ? "password":"";
88 echo "<tr><td>"._("Password")."</td><td><input type='password' name='password' value='$password' /></td></tr>\n";
91 hidden('company_login_name', $_SESSION["wa_current_user"]->company);
93 if (isset($_SESSION['wa_current_user']->company))
94 $coy = $_SESSION['wa_current_user']->company;
97 echo "<tr><td>"._("Company")."</td><td><select name='company_login_name'>\n";
98 for ($i = 0; $i < count($db_connections); $i++)
99 echo "<option value=$i ".($i==$coy ? 'selected':'') .">" . $db_connections[$i]["name"] . "</option>";
102 label_cell($demo_text, "colspan=2 align='center'");
106 echo "<center><input type='submit' value=' "._("Login -->")." ' name='SubmitUser' onclick='set_fullmode();' /></center>\n";
109 foreach($_SESSION['timeout']['post'] as $p => $val) {
110 // add all request variables to be resend together with login data
111 if (!in_array($p, array('ui_mode', 'user_name_entry_field',
112 'password', 'SubmitUser', 'company_login_name')))
113 echo "<input type='hidden' name='$p' value='$val'>";
115 echo "<script language='JavaScript' type='text/javascript'>
118 document.forms[0].user_name_entry_field.select();
119 document.forms[0].user_name_entry_field.focus();
123 echo "<table class='bottomBar'>\n";
125 if (isset($_SESSION['wa_current_user']))
126 $date = Today() . " | " . Now();
128 $date = date("m/d/Y") . " | " . date("h.i am");
129 echo "<td class='bottomBarCell'>$date</td>\n";
130 echo "</tr></table>\n";
131 echo "<table class='footer'>\n";
133 echo "<td><a target='_blank' href='$power_url' tabindex='-1'>$app_title $version - " . _("Theme:") . " " . $def_theme . "</a></td>\n";
136 echo "<td><a target='_blank' href='$power_url' tabindex='-1'>$power_by</a></td>\n";
138 echo "</table><br><br>\n";
139 echo "</body></html>\n";