1 ######################################################################
2 # SQL-Ledger Accounting
5 # Author: Dieter Simader
6 # Email: dsimader@sql-ledger.org
7 # Web: http://www.sql-ledger.org
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 ######################################################################
26 #######################################################################
36 $locale = new Locale $language, "login";
39 if (-f "$form->{path}/custom_$form->{script}") {
40 eval { require "$form->{path}/custom_$form->{script}"; };
41 $form->error($@) if ($@);
44 # per login customization
45 if (-f "$form->{path}/$form->{login}_$form->{script}") {
46 eval { require "$form->{path}/$form->{login}_$form->{script}"; };
47 $form->error($@) if ($@);
50 # window title bar, user info
51 $form->{titlebar} = "SQL-Ledger ".$locale->text('Version'). " $form->{version}";
53 if ($form->{action}) {
54 $form->{titlebar} .= " - $myconfig{name} - $myconfig{dbname}";
55 &{ $locale->findsub($form->{action}) };
66 $form->{stylesheet} = "sql-ledger.css";
67 $form->{favicon} = "sql-ledger.ico";
69 $form->{endsession} = 1;
73 $sf = qq|function sf() { document.login.password.focus(); }|;
75 $sf = qq|function sf() { document.login.login.focus(); }|;
78 if ($form->{jsc} && -d 'bin/js') {
80 <script language="JavaScript" type="text/javascript">
82 var agt = navigator.userAgent.toLowerCase();
83 var is_major = parseInt(navigator.appVersion);
84 var is_nav = ((agt.indexOf('mozilla') != -1) && (agt.indexOf('spoofer') == -1)
85 && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera') == -1)
86 && (agt.indexOf('webtv') == -1));
87 var is_nav4lo = (is_nav && (is_major <= 4));
91 document.login.path.value = "bin/mozilla"
93 document.login.path.value = "bin/js"
103 <body class=login onload="jsp(); sf()">
110 <table class=login border=3 cellpadding=20>
112 <td class=login align=center><a href="http://www.sql-ledger.org" target=_top><img src=sql-ledger.gif border=0></a>
113 <h1 class=login align=center>|.$locale->text('Version').qq| $form->{version}
118 <form method=post action=$form->{script} name=login>
125 <th align=right>|.$locale->text('Name').qq|</th>
126 <td><input class=login name=login size=30 value=$form->{login}></td>
129 <th align=right>|.$locale->text('Password').qq|</th>
130 <td><input class=login type=password name=password size=30></td>
132 <input type=hidden name=path value=$form->{path}>
136 <input type=submit name=action value="|.$locale->text('Login').qq|">
157 if (-f "css/sql-ledger.css") {
158 $form->{stylesheet} = "sql-ledger.css";
171 <table class=login border=3 cellpadding=20>
173 <td class=login align=center><a href="http://www.sql-ledger.org" target=_top><img src=sql-ledger.gif border=0></a>
174 <h1 class=login align=center>|.$locale->text('Version').qq| $form->{version}
179 <form method=post action=$form->{script}>
181 <input type=hidden name=beenthere value=1>
188 <th align=right>|.$locale->text('Name').qq|</th>
189 <td>$form->{login}</td>
192 <th align=right>|.$locale->text('Password').qq|</th>
193 <td><input class=login type=password name=password size=30 value=$form->{password}></td>
195 <input type=hidden name=path value=$form->{path}>
197 <th align=right>|.$locale->text('Company').qq|</th>
200 $checked = "checked";
201 foreach $login (sort { $login{$a} cmp $login{$b} } keys %{ $login }) {
203 <br><input class=login type=radio name=login value=$login $checked>$login{$login}
213 <input type=submit name=action value="|.$locale->text('Login').qq|">
234 $form->{stylesheet} = "sql-ledger.css";
235 $form->{favicon} = "sql-ledger.ico";
237 $form->error($locale->text('You did not enter a name!')) unless ($form->{login});
239 if (! $form->{beenthere}) {
240 open(FH, "$memberfile") or $form->error("$memberfile : $!");
244 @login = grep { s/\[(.*)\]/$1/ } @a;
245 @company = grep { s/company=(.*)/$1/ } @a;
248 for ($i = 0; $i <= $#login; $i++) {
250 if (($form->{login} eq $login[$i]) || ($login[$i] =~ /$form->{login}@/)) {
252 $login{$login[$i]} = $company[$i];
256 if (keys %login > 1) {
257 &selectdataset(\%login);
263 $user = new User $memberfile, $form->{login};
265 # if we get an error back, bale out
266 if (($errno = $user->login(\%$form, $userspath)) <= -1) {
269 $err[1] = $locale->text('Incorrect Password!');
270 $err[2] = $locale->text('Incorrect Dataset version!');
271 $err[3] = qq|$form->{login} |.$locale->text('is not a member!');
272 $err[4] = $locale->text('Dataset is newer than version!');
275 # upgrade dataset and log in again
276 open FH, ">$userspath/nologin" or $form->error($!);
278 map { $form->{$_} = $user->{$_} } qw(dbname dbhost dbport dbdriver dbuser dbpasswd);
280 $form->{dbpasswd} = unpack 'u', $form->{dbpasswd};
282 $form->{dbupdate} = "db$user->{dbname}";
283 $form->{$form->{dbupdate}} = 1;
286 print $locale->text('Upgrading to Version')." $form->{version} ... ";
288 # required for Oracle
289 $form->{dbdefault} = $sid;
291 $user->dbupdate(\%$form);
294 unlink "$userspath/nologin";
296 print $locale->text('done');
298 print "<p><a href=menu.pl?login=$form->{login}&sessionid=$form->{sessionid}&path=$form->{path}&action=display>".$locale->text('Continue')."</a>";
303 $form->error($err[$errno]);
307 # made it this far, execute the menu
308 $form->{callback} = "menu.pl?login=$form->{login}&path=$form->{path}&action=display";
318 $jsc = $form->{path} =~ /js/;
319 $form->{callback} = "$form->{script}?path=$form->{path}&login=$form->{login}&jsc=$jsc";