summaryrefslogtreecommitdiff
path: root/bin/mozilla/admin.pl
blob: 0bc40eb83b72bcb5b5304383284e38837499badb (plain)
  1. #=====================================================================
  2. # LedgerSMB
  3. # Small Medium Business Accounting software
  4. # http://sourceforge.net/projects/ledger-smb/
  5. #
  6. #
  7. # Copyright (C) 2006
  8. # This work contains copyrighted information from a number of sources all used
  9. # with permission.
  10. #
  11. # This file contains source code included with or based on SQL-Ledger which
  12. # is Copyright Dieter Simader and DWS Systems Inc. 2000-2005 and licensed
  13. # under the GNU General Public License version 2 or, at your option, any later
  14. # version. For a full list including contact information of contributors,
  15. # maintainers, and copyright holders, see the CONTRIBUTORS file.
  16. #
  17. # Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
  18. # Copyright (c) 2000
  19. #
  20. # Author: DWS Systems Inc.
  21. # Web: http://www.sql-ledger.org
  22. #
  23. # Contributors:
  24. #
  25. #
  26. #======================================================================
  27. #
  28. # This file has undergone whitespace cleanup.
  29. #
  30. #======================================================================
  31. #
  32. # setup module
  33. # add/edit/delete users
  34. #
  35. #======================================================================
  36. $menufile = "menu.ini";
  37. use LedgerSMB::Form;
  38. use LedgerSMB::User;
  39. $form = new Form;
  40. $locale = new Locale $language, "admin";
  41. $form->{charset} = $locale->{charset};
  42. eval { require DBI; };
  43. $form->error($locale->text('DBI not installed!')) if ($@);
  44. $form->{stylesheet} = "ledger-smb.css";
  45. $form->{favicon} = "favicon.ico";
  46. $form->{timeout} = 600;
  47. require "$form->{path}/pw.pl";
  48. # customization
  49. if (-f "$form->{path}/custom_$form->{script}") {
  50. eval { require "$form->{path}/custom_$form->{script}"; };
  51. $form->error($@) if ($@);
  52. }
  53. if ($form->{action}) {
  54. &check_password unless $form->{action} eq 'logout';
  55. &{ $locale->findsub($form->{action}) };
  56. } else {
  57. # if there are no drivers bail out
  58. $form->error($locale->text('No Database Drivers available!')) unless (User->dbdrivers);
  59. # create memberfile
  60. if (! -f $memberfile) {
  61. open(FH, ">$memberfile") or $form->error("$memberfile : $!");
  62. print FH qq|# LedgerSMB Accounting members
  63. [root login]
  64. password=
  65. |;
  66. close FH;
  67. }
  68. $root = new User "$memberfile", "root login";
  69. unless($root && $root->{password}) {
  70. &setup_initial_password();
  71. exit;
  72. }
  73. &adminlogin;
  74. }
  75. 1;
  76. # end
  77. sub setup_initial_password {
  78. $form->header();
  79. print qq|
  80. <body class="admin" onload="sf()">
  81. <div align="center">
  82. <a href="http://sourceforge.net/projects/ledger-smb/"><img src="ledger-smb.png" width="200" height="100" border="0" alt="LedgerSMB Logo" /></a>
  83. <h1 class="login">|.$locale->text('Version').qq| $form->{version} <br />|.$locale->text('Administration').qq|</h1>
  84. <fieldset><legend>Change password</legend>
  85. <p>This is your first time logging into LedgerSMB. Please set your administrative password</p>
  86. <form method="post" action="$form->{script}" name="admin">
  87. <table>
  88. <tr>
  89. <th align="right">|.$locale->text('Password').qq|</th>
  90. <td><input type="password" name="new_password" /></td>
  91. </tr>
  92. <tr>
  93. <th align="right">|.$locale->text('Confirm').qq|</th>
  94. <td><input type="password" name="confirm_password" /></td>
  95. </tr>
  96. </table>
  97. <input type="hidden" name="path" value="$form->{path}" />
  98. <input type="hidden" name="sessionid" value="$form->{sessionid}" />
  99. <p><input type="submit" class="submit" name="action" value="|.$locale->text('Change Password').qq|" /></p>
  100. </form>
  101. <a href="http://sourceforge.net/projects/ledger-smb/">LedgerSMB |.$locale->text('website').qq|</a>
  102. </div>
  103. </body>
  104. </html>
  105. |;
  106. }
  107. sub adminlogin {
  108. $form->{title} = qq|LedgerSMB $form->{version} |.$locale->text('Administration');
  109. $myheaderadd = qq|
  110. <script language="JavaScript" type="text/javascript">
  111. <!--
  112. function sf(){
  113. document.admin.password.focus();
  114. }
  115. // End -->
  116. </script>
  117. |;
  118. $form->header(undef, $myheaderadd);
  119. print qq|
  120. <body class="admin" onload="sf()">
  121. <div align="center">
  122. <a href="http://sourceforge.net/projects/ledger-smb/"><img src="ledger-smb.png" width="200" height="100" border="0" alt="LedgerSMB Logo" /></a>
  123. <h1 class="login">|.$locale->text('Version').qq| $form->{version} <br />|.$locale->text('Administration').qq|</h1>
  124. <form method="post" action="$form->{script}" name="admin">
  125. <table>
  126. <tr>
  127. <th>|.$locale->text('Password').qq|</th>
  128. <td><input type="password" name="password" /></td>
  129. <td><input type="submit" class="submit" name="action" value="|.$locale->text('Login').qq|" /></td>
  130. </tr>
  131. </table>
  132. <input type="hidden" name="action" value="login" />
  133. <input type="hidden" name="path" value="$form->{path}" />
  134. </form>
  135. <a href="http://sourceforge.net/projects/ledger-smb/">LedgerSMB |.$locale->text('website').qq|</a>
  136. </div>
  137. </body>
  138. </html>
  139. |;
  140. }
  141. sub login {
  142. &list_users;
  143. }
  144. sub logout {
  145. $form->{callback} = "$form->{script}?path=$form->{path}&amp;endsession=1";
  146. unlink "$userspath/adminhash";
  147. print qq|Set-Cookie: LedgerSMB=; path=/;\n|;
  148. $form->redirect($locale->text('You are logged out'));
  149. }
  150. sub add_user {
  151. $form->{title} = "LedgerSMB ".$locale->text('Accounting')." ".$locale->text('Administration')." / ".$locale->text('Add User');
  152. if (-f "css/ledger-smb.css") {
  153. $myconfig->{stylesheet} = "ledger-smb.css";
  154. }
  155. $myconfig->{vclimit} = 1000;
  156. $myconfig->{menuwidth} = 155;
  157. $myconfig->{timeout} = 3600;
  158. &form_header;
  159. &form_footer;
  160. }
  161. sub edit {
  162. $form->{title} = "LedgerSMB ".$locale->text('Accounting')." ".$locale->text('Administration')." / ".$locale->text('Edit User');
  163. $form->{edit} = 1;
  164. &form_header;
  165. &form_footer;
  166. }
  167. sub form_footer {
  168. if ($form->{edit}) {
  169. $delete = qq|<input type="submit" class="submit" name="action" value="|.$locale->text('Delete').qq|" />
  170. <input type="hidden" name="edit" value="1" />|;
  171. }
  172. print qq|
  173. <input name="callback" type="hidden" value="$form->{script}?action=list_users&amp;path=$form->{path}&amp;sessionid=$form->{sessionid}" />
  174. <input type="hidden" name="path" value="$form->{path}" />
  175. <input type="hidden" name="sessionid" value="$form->{sessionid}" />
  176. <input type="submit" class="submit" name="action" value="|.$locale->text('Save').qq|" />
  177. $delete
  178. </form>
  179. </body>
  180. </html>
  181. |;
  182. }
  183. sub list_users {
  184. open(FH, "$memberfile") or $form->error("$memberfile : $!");
  185. $nologin = qq|<input type="submit" class="submit" name="action" value="|.$locale->text('Lock System').qq|" />|;
  186. if (-e "$userspath/nologin") {
  187. $nologin = qq|<input type="submit" class="submit" name="action" value="|.$locale->text('Unlock System').qq|" />|;
  188. }
  189. while (<FH>) {
  190. chop;
  191. if (/^\[.*\]/) {
  192. $login = $_;
  193. $login =~ s/(\[|\])//g;
  194. }
  195. if (/^(name=|company=|templates=|dbuser=|dbdriver=|dbname=|dbhost=)/) {
  196. chop ($var = $&);
  197. ($null, $member{$login}{$var}) = split /=/, $_, 2;
  198. }
  199. }
  200. close(FH);
  201. # type=submit $locale->text('Pg Database Administration')
  202. # type=submit $locale->text('PgPP Database Administration')
  203. foreach $item (User->dbdrivers) {
  204. $dbdrivers .= qq|<input name="action" type="submit" class="submit" value="|.$locale->text("$item Database Administration").qq|" />|;
  205. }
  206. $column_header{login} = qq|<th>|.$locale->text('Login').qq|</th>|;
  207. $column_header{name} = qq|<th>|.$locale->text('Name').qq|</th>|;
  208. $column_header{company} = qq|<th>|.$locale->text('Company').qq|</th>|;
  209. $column_header{dbdriver} = qq|<th>|.$locale->text('Driver').qq|</th>|;
  210. $column_header{dbhost} = qq|<th>|.$locale->text('Host').qq|</th>|;
  211. $column_header{dataset} = qq|<th>|.$locale->text('Dataset').qq|</th>|;
  212. $column_header{templates} = qq|<th>|.$locale->text('Templates').qq|</th>|;
  213. @column_index = qw(login name company dbdriver dbhost dataset templates);
  214. $form->{title} = "LedgerSMB ".$locale->text('Accounting')." ".$locale->text('Administration');
  215. $form->{login} = "root login";
  216. $form->header;
  217. print qq|
  218. <body class="admin">
  219. <form method="post" action="$form->{script}">
  220. <table width="100%">
  221. <tr class="listheading">
  222. <th>$form->{title}</th>
  223. </tr>
  224. <tr size="5"></tr>
  225. <tr>
  226. <td>
  227. <table width="100%">
  228. <tr class="listheading">|;
  229. for (@column_index) { print "$column_header{$_}\n" }
  230. print qq| </tr>|;
  231. foreach $key (sort keys %member) {
  232. $href = "$script?action=edit&amp;login=$key&amp;path=$form->{path}&amp;sessionid=$form->{sessionid}";
  233. $href =~ s/ /%20/g;
  234. $member{$key}{templates} =~ s/^$templates\///;
  235. $member{$key}{dbhost} = $locale->text('localhost') unless $member{$key}{dbhost};
  236. $column_data{login} = qq|<td><a href="$href">$key</a></td>|;
  237. $column_data{name} = qq|<td>$member{$key}{name}</td>|;
  238. $column_data{company} = qq|<td>$member{$key}{company}</td>|;
  239. $column_data{dbdriver} = qq|<td>$member{$key}{dbdriver}</td>|;
  240. $column_data{dbhost} = qq|<td>$member{$key}{dbhost}</td>|;
  241. $column_data{dataset} = qq|<td>$member{$key}{dbname}</td>|;
  242. $column_data{templates} = qq|<td>$member{$key}{templates}</td>|;
  243. $i++; $i %= 2;
  244. print qq| <tr class="listrow$i">|;
  245. for (@column_index) { print "$column_data{$_}\n"; }
  246. print qq| </tr>|;
  247. }
  248. print qq| </table>
  249. </td>
  250. </tr>
  251. <tr>
  252. <td><hr size="3" noshade /></td>
  253. </tr>
  254. </table>
  255. <input type="hidden" name="path" value="$form->{path}" />
  256. <input type="hidden" name="sessionid" value="$form->{sessionid}" />
  257. <br />
  258. <input type="submit" class="submit" name="action" value="|.$locale->text('Add User').qq|" />
  259. <input type="submit" class="submit" name="action" value="|.$locale->text('Change Admin Password').qq|" />
  260. $dbdrivers
  261. $nologin
  262. <input type="submit" class="submit" name="action" value="|.$locale->text('Logout').qq|" />
  263. </form>
  264. |.$locale->text('Click on login name to edit!').qq|
  265. <br />
  266. |.$locale->text('To add a user to a group edit a name, change the login name and save. A new user with the same variables will then be saved under the new login name.').qq|
  267. </body>
  268. </html>|;
  269. }
  270. sub form_header {
  271. # if there is a login, get user
  272. if ($form->{login}) {
  273. # get user
  274. $myconfig = new User "$memberfile", "$form->{login}";
  275. for (qw(company address signature)) { $myconfig->{$_} = $form->quote($myconfig->{$_}) }
  276. for (qw(address signature)) { $myconfig->{$_} =~ s/\\n/\n/g }
  277. # strip basedir from templates directory
  278. $myconfig->{templates} =~ s/^$templates\///;
  279. $myconfig->{dbpasswd} = unpack 'u', $myconfig->{dbpasswd};
  280. }
  281. foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
  282. $dateformat .= ($item eq $myconfig->{dateformat}) ? "<option selected>$item</option>\n" : "<option>$item</option>\n";
  283. }
  284. foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00 1'000.00)) {
  285. $numberformat .= ($item eq $myconfig->{numberformat}) ? "<option selected>$item</option>\n" : "<option>$item</option>\n";
  286. }
  287. %countrycodes = User->country_codes;
  288. $countrycodes = "";
  289. foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} } keys %countrycodes) {
  290. $countrycodes .= ($myconfig->{countrycode} eq $key) ? qq|<option selected value="$key">$countrycodes{$key}</option>|
  291. : qq|<option value="$key">$countrycodes{$key}</option>|;
  292. }
  293. $countrycodes = qq|<option value="">English</option>\n$countrycodes|;
  294. # is there a templates basedir
  295. if (! -d "$templates") {
  296. $form->error($locale->text('Directory').": $templates ".$locale->text('does not exist'));
  297. }
  298. opendir TEMPLATEDIR, "$templates/." or $form->error("$templates : $!");
  299. @all = grep !/^\.\.?$/, readdir TEMPLATEDIR;
  300. closedir TEMPLATEDIR;
  301. @allhtml = sort grep /\.html/, @all;
  302. @alldir = ();
  303. for (@all) {
  304. if (-d "$templates/$_") {
  305. push @alldir, $_;
  306. }
  307. }
  308. @allhtml = reverse grep !/Default/, @allhtml;
  309. push @allhtml, 'Default';
  310. @allhtml = reverse @allhtml;
  311. foreach $item (sort @alldir) {
  312. if ($item eq $myconfig->{templates}) {
  313. $usetemplates .= qq|<option selected value="$item">$item</option>\n|;
  314. } else {
  315. $usetemplates .= qq|<option value="$item">$item</option>\n|;
  316. }
  317. }
  318. $lastitem = $allhtml[0];
  319. $lastitem =~ s/-.*//g;
  320. $mastertemplates = qq|<option value="$lastitem">$lastitem</option>\n|;
  321. foreach $item (@allhtml) {
  322. $item =~ s/-.*//g;
  323. if ($item ne $lastitem) {
  324. $mastertemplates .= qq|<option value="$item">$item</option>\n|;
  325. $lastitem = $item;
  326. }
  327. }
  328. opendir CSS, "css/.";
  329. @all = grep /.*\.css$/, readdir CSS;
  330. closedir CSS;
  331. foreach $item (@all) {
  332. if ($item eq $myconfig->{stylesheet}) {
  333. $selectstylesheet .= qq|<option selected value="$item">$item</option>\n|;
  334. } else {
  335. $selectstylesheet .= qq|<option value="$item">$item</option>\n|;
  336. }
  337. }
  338. $selectstylesheet .= "<option></option>\n";
  339. if (%printer && $latex) {
  340. $selectprinter = "<option></option>\n";
  341. foreach $item (sort keys %printer) {
  342. if ($myconfig->{printer} eq $item) {
  343. $selectprinter .= qq|<option value="$item" selected>$item</option>\n|;
  344. } else {
  345. $selectprinter .= qq|<option value="$item">$item</option>\n|;
  346. }
  347. }
  348. $printer = qq|
  349. <tr>
  350. <th align="right">|.$locale->text('Printer').qq|</th>
  351. <td><select name="printer">$selectprinter</select></td>
  352. </tr>
  353. |;
  354. }
  355. $user = $form->{login};
  356. $form->{login} = "root login";
  357. $form->header;
  358. $form->{login} = $user;
  359. print qq|
  360. <body class="admin">
  361. <form method="post" action="$form->{script}">
  362. <table width="100%">
  363. <tr class="listheading"><th colspan="2">$form->{title}</th></tr>
  364. <tr size="5"></tr>
  365. <tr valign="top">
  366. <td>
  367. <table>
  368. <tr>
  369. <th align="right">|.$locale->text('Login').qq|</th>
  370. <td><input name="login" value="$myconfig->{login}" /></td>
  371. </tr>
  372. <tr>
  373. <th align="right">|.$locale->text('Password').qq|</th>
  374. <td><input type="password" name="new_password" size="8" value="$myconfig->{password}" /></td>
  375. <input type="hidden" name="old_password" value="$myconfig->{password}" />
  376. </tr>
  377. <tr>
  378. <th align="right">|.$locale->text('Name').qq|</th>
  379. <td><input name="name" size="15" value="$myconfig->{name}" /></td>
  380. </tr>
  381. <tr>
  382. <th align="right">|.$locale->text('E-mail').qq|</th>
  383. <td><input name="email" size="30" value="$myconfig->{email}" /></td>
  384. </tr>
  385. <tr valign="top">
  386. <th align="right">|.$locale->text('Signature').qq|</th>
  387. <td><textarea name="signature" rows="3" cols="35">$myconfig->{signature}</textarea></td>
  388. </tr>
  389. <tr>
  390. <th align="right">|.$locale->text('Phone').qq|</th>
  391. <td><input name="tel" size="14" value="$myconfig->{tel}" /></td>
  392. </tr>
  393. <tr>
  394. <th align="right">|.$locale->text('Fax').qq|</th>
  395. <td><input name="fax" size="14" value="$myconfig->{fax}" /></td>
  396. </tr>
  397. <tr>
  398. <th align="right">|.$locale->text('Company').qq|</th>
  399. <td><input name="company" size="35" value="$myconfig->{company}" /></td>
  400. </tr>
  401. <tr valign="top">
  402. <th align="right">|.$locale->text('Address').qq|</th>
  403. <td><textarea name="address" rows="4" cols="35">$myconfig->{address}</textarea></td>
  404. </tr>
  405. </table>
  406. </td>
  407. <td>
  408. <table>
  409. <tr>
  410. <th align="right">|.$locale->text('Date Format').qq|</th>
  411. <td><select name="dateformat">$dateformat</select></td>
  412. </tr>
  413. <tr>
  414. <th align="right">|.$locale->text('Number Format').qq|</th>
  415. <td><select name="numberformat">$numberformat</select></td>
  416. </tr>
  417. <tr>
  418. <th align="right">|.$locale->text('Dropdown Limit').qq|</th>
  419. <td><input name="vclimit" value="$myconfig->{vclimit}" /></td>
  420. </tr>
  421. <tr>
  422. <th align="right">|.$locale->text('Menu Width').qq|</th>
  423. <td><input name="menuwidth" value="$myconfig->{menuwidth}" /></td>
  424. </tr>
  425. <tr>
  426. <th align="right">|.$locale->text('Language').qq|</th>
  427. <td><select name="countrycode">$countrycodes</select></td>
  428. </tr>
  429. <tr>
  430. <th align="right">|.$locale->text('Session Timeout').qq|</th>
  431. <td><input name="newtimeout" value="$myconfig->{timeout}" /></td>
  432. </tr>
  433. <tr>
  434. <th align="right">|.$locale->text('Stylesheet').qq|</th>
  435. <td><select name="userstylesheet">$selectstylesheet</select></td>
  436. </tr>
  437. $printer
  438. <tr>
  439. <th align="right">|.$locale->text('Use Templates').qq|</th>
  440. <td><select name="usetemplates">$usetemplates</select></td>
  441. </tr>
  442. <tr>
  443. <th align="right">|.$locale->text('New Templates').qq|</th>
  444. <td><input name="newtemplates" /></td>
  445. </tr>
  446. <tr>
  447. <th align="right">|.$locale->text('Setup Templates').qq|</th>
  448. <td><select name="mastertemplates">$mastertemplates</select></td>
  449. </tr>
  450. </table>
  451. <input type="hidden" name="templates" value="$myconfig->{templates}" />
  452. </td>
  453. </tr>
  454. <tr class="listheading">
  455. <th colspan="2">|.$locale->text('Database').qq|</th>
  456. </tr>|;
  457. # list section for database drivers
  458. foreach $item (User->dbdrivers) {
  459. print qq|
  460. <tr>
  461. <td colspan="2">
  462. <table>
  463. <tr>|;
  464. $checked = "";
  465. if ($myconfig->{dbdriver} eq $item) {
  466. for (qw(dbhost dbport dbuser dbpasswd dbname sid)) { $form->{"${item}_$_"} = $myconfig->{$_} }
  467. $checked = "checked";
  468. }
  469. print qq|
  470. <th align="right">|.$locale->text('Driver').qq|</th>
  471. <td><input name="dbdriver" type="radio" class="radio" value="$item" $checked />&nbsp;$item</td>
  472. <th align="right">|.$locale->text('Host').qq|</th>
  473. <td><input name="${item}_dbhost" size="30" value="$form->{"${item}_dbhost"}" /></td>
  474. </tr>
  475. <tr>|;
  476. print qq|
  477. <th align="right">|.$locale->text('Dataset').qq|</th>
  478. <td><input name="${item}_dbname" size="15" value="$form->{"${item}_dbname"}" /></td>
  479. <th align="right">|.$locale->text('Port').qq|</th>
  480. <td><input name="${item}_dbport" size="4" value="$form->{"${item}_dbport"}" /></td>
  481. </tr>
  482. <tr>
  483. <th align="right">|.$locale->text('User').qq|</th>
  484. <td><input name="${item}_dbuser" size="15" value="$form->{"${item}_dbuser"}" /></td>
  485. <th align="right">|.$locale->text('Password').qq|</th>
  486. <td><input name="${item}_dbpasswd" type="password" size="10" value="$form->{"${item}_dbpasswd"}" /></td>
  487. </tr>|;
  488. print qq|
  489. </table>
  490. <input type="hidden" name="old_dbpasswd" value="$myconfig->{dbpasswd}" />
  491. </td>
  492. </tr>
  493. <tr>
  494. <td colspan="2"><hr size="2" noshade /></td>
  495. </tr>
  496. |;
  497. }
  498. # access control
  499. open(FH, $menufile) or $form->error("$menufile : $!");
  500. # scan for first menu level
  501. @a = <FH>;
  502. close(FH);
  503. if (open(FH, "custom_$menufile")) {
  504. push @a, <FH>;
  505. }
  506. close(FH);
  507. foreach $item (@a) {
  508. next unless $item =~ /\[\w+/;
  509. next if $item =~ /\#/;
  510. $item =~ s/(\[|\])//g;
  511. chop $item;
  512. if ($item =~ /--/) {
  513. ($level, $menuitem) = split /--/, $item, 2;
  514. } else {
  515. $level = $item;
  516. $menuitem = $item;
  517. push @acsorder, $item;
  518. }
  519. push @{ $acs{$level} }, $menuitem;
  520. }
  521. %role = ( 'admin' => $locale->text('Administrator'),
  522. 'user' => $locale->text('User'),
  523. 'supervisor' => $locale->text('Supervisor'),
  524. 'manager' => $locale->text('Manager'));
  525. $selectrole = "";
  526. foreach $item (qw(user admin supervisor manager)) {
  527. $selectrole .= ($myconfig->{role} eq $item) ? "<option selected value=\"$item\">$role{$item}</option>\n"
  528. : "<option value=\"$item\">$role{$item}</option>\n";
  529. }
  530. print qq|
  531. <tr class="listheading">
  532. <th colspan="2">|.$locale->text('Access Control').qq|</th>
  533. </tr>
  534. <tr>
  535. <td><select name="role">$selectrole</select></td>
  536. </tr>
  537. |;
  538. foreach $item (split /;/, $myconfig->{acs}) {
  539. ($key, $value) = split /--/, $item, 2;
  540. $excl{$key}{$value} = 1;
  541. }
  542. foreach $key (@acsorder) {
  543. $checked = "checked";
  544. if ($form->{login}) {
  545. $checked = ($excl{$key}{$key}) ? "" : "checked";
  546. }
  547. # can't have variable names with & and spaces
  548. $item = $form->escape("${key}--$key",1);
  549. $acsheading = $key;
  550. $acsheading =~ s/ /&nbsp;/g;
  551. $acsheading = qq|
  552. <td align="left" nowrap="nowrap" style="background-color: #C7E9F7" colspan="2">
  553. <input name="$item" class="checkbox" type="checkbox" value="1" $checked />&nbsp;$acsheading</td><tr><td>\n|;
  554. $menuitems .= "$item;";
  555. $acsdata = "<td style=\"background-color: #F0F0F0\">";
  556. foreach $item (@{ $acs{$key} }) {
  557. next if ($key eq $item);
  558. $checked = "checked";
  559. if ($form->{login}) {
  560. $checked = ($excl{$key}{$item}) ? "" : "checked";
  561. }
  562. $acsitem = $form->escape("${key}--$item",1);
  563. $acsdata .= qq|<br /><input name="$acsitem" class="checkbox" type="checkbox" value="1" $checked />&nbsp;$item|;
  564. $menuitems .= "$acsitem;";
  565. }
  566. $acsdata .= "
  567. </td>";
  568. print qq|
  569. <tr valign="top">$acsheading $acsdata
  570. </tr>
  571. |;
  572. }
  573. print qq|<input type="hidden" name="acs" value="$menuitems" />
  574. <tr>
  575. <td colspan="2"><hr size="3" noshade /></td>
  576. </tr>
  577. </table>
  578. </div>
  579. |;
  580. }
  581. sub save {
  582. # no driver checked
  583. $form->error($locale->text('Database Driver not checked!')) unless $form->{dbdriver};
  584. # no spaces allowed in login name
  585. $form->{login} =~ s/ //g;
  586. $form->isblank("login", $locale->text('Login name missing!'));
  587. # check for duplicates
  588. if (!$form->{edit}) {
  589. $temp = new User "$memberfile", "$form->{login}";
  590. if ($temp->{login}) {
  591. $form->error("$form->{login} ".$locale->text('is already a member!'));
  592. }
  593. }
  594. # no spaces allowed in directories
  595. $form->{newtemplates} =~ s/( |\.\.|\*)//g;
  596. if ($form->{newtemplates} ne "") {
  597. $form->{templates} = $form->{newtemplates};
  598. } else {
  599. $form->{templates} = ($form->{usetemplates}) ? $form->{usetemplates} : $form->{login};
  600. }
  601. # is there a basedir
  602. if (! -d "$templates") {
  603. $form->error($locale->text('Directory').": $templates ".$locale->text('does not exist'));
  604. }
  605. # add base directory to $form->{templates}
  606. $form->{templates} = "$templates/$form->{templates}";
  607. $myconfig = new User "$memberfile", "$form->{login}";
  608. # redo acs variable and delete all the acs codes
  609. @acs = split /;/, $form->{acs};
  610. $form->{acs} = "";
  611. foreach $item (@acs) {
  612. $item = $form->escape($item,1);
  613. if (!$form->{$item}) {
  614. $form->{acs} .= $form->unescape($form->unescape("$item")).";";
  615. }
  616. delete $form->{$item};
  617. }
  618. # check which database was filled in
  619. $form->{dbhost} = $form->{"$form->{dbdriver}_dbhost"};
  620. $form->{dbport} = $form->{"$form->{dbdriver}_dbport"};
  621. $form->{dbpasswd} = $form->{"$form->{dbdriver}_dbpasswd"};
  622. $form->{dbuser} = $form->{"$form->{dbdriver}_dbuser"};
  623. $form->{dbname} = $form->{"$form->{dbdriver}_dbname"};
  624. $form->isblank("dbname", $locale->text('Dataset missing!'));
  625. $form->isblank("dbuser", $locale->text('Database User missing!'));
  626. foreach $item (keys %{$form}) {
  627. $myconfig->{$item} = $form->{$item};
  628. }
  629. $myconfig->{password} = $form->{old_password};
  630. $myconfig->{password} = $form->{new_password} if $form->{new_password} ne $form->{old_password};
  631. $myconfig->{timeout} = $form->{newtimeout};
  632. delete $myconfig->{stylesheet};
  633. if ($form->{userstylesheet}) {
  634. $myconfig->{stylesheet} = $form->{userstylesheet};
  635. }
  636. $myconfig->{packpw} = 1;
  637. $myconfig->save_member($memberfile, $userspath);
  638. # create user template directory and copy master files
  639. if (! -d "$form->{templates}") {
  640. umask(002);
  641. if (mkdir "$form->{templates}", oct("771")) {
  642. umask(007);
  643. # copy templates to the directory
  644. opendir TEMPLATEDIR, "$templates/." or $form->error("$templates : $!");
  645. @templates = grep /$form->{mastertemplates}-/, readdir TEMPLATEDIR;
  646. closedir TEMPLATEDIR;
  647. foreach $file (@templates) {
  648. open(TEMP, "$templates/$file") or $form->error("$templates/$file : $!");
  649. $file =~ s/$form->{mastertemplates}-//;
  650. open(NEW, ">$form->{templates}/$file") or $form->error("$form->{templates}/$file : $!");
  651. while ($line = <TEMP>) {
  652. print NEW $line;
  653. }
  654. close(TEMP);
  655. close(NEW);
  656. }
  657. } else {
  658. $form->error("$form->{templates} : $!");
  659. }
  660. }
  661. $form->redirect($locale->text('User saved!'));
  662. }
  663. sub delete {
  664. $form->{templates} = ($form->{templates}) ? "$templates/$form->{templates}" : "$templates/$form->{login}";
  665. $form->error("$memberfile ".$locale->text('locked!')) if (-f ${memberfile}.LCK);
  666. open(FH, ">${memberfile}.LCK") or $form->error("${memberfile}.LCK : $!");
  667. close(FH);
  668. if (! open(CONF, "+<$memberfile")) {
  669. unlink "${memberfile}.LCK";
  670. $form->error("$memberfile : $!");
  671. }
  672. @config = <CONF>;
  673. seek(CONF, 0, 0);
  674. truncate(CONF, 0);
  675. while ($line = shift @config) {
  676. chop $line;
  677. if ($line =~ /^\[/) {
  678. last if ($line eq "[$form->{login}]");
  679. $login = &login_name($line);
  680. }
  681. if ($line =~ /^templates=/) {
  682. ($null, $user{$login}) = split /=/, $line, 2;
  683. }
  684. print CONF "$line\n";
  685. }
  686. # remove everything up to next login or EOF
  687. # and save template variable
  688. while ($line = shift @config) {
  689. chop $line;
  690. ($key, $value) = split /=/, $line, 2;
  691. $myconfig{$key} = $value;
  692. last if ($line =~ /^\[/);
  693. }
  694. # this one is either the next login or EOF
  695. print CONF "$line\n";
  696. $login = &login_name($line);
  697. while ($line = shift @config) {
  698. chop $line;
  699. if ($line =~ /^\[/) {
  700. $login = &login_name($line);
  701. }
  702. if ($line =~ /^templates=/) {
  703. ($null, $user{$login}) = split /=/, $line, 2;
  704. }
  705. print CONF "$line\n";
  706. }
  707. close(CONF);
  708. unlink "${memberfile}.LCK";
  709. # scan %user for $templatedir
  710. foreach $login (keys %user) {
  711. last if ($found = ($form->{templates} eq $user{$login}));
  712. }
  713. # if found keep directory otherwise delete
  714. if (!$found) {
  715. # delete it if there is a template directory
  716. $dir = "$form->{templates}";
  717. if (-d "$dir") {
  718. unlink <$dir/*>;
  719. rmdir "$dir";
  720. }
  721. }
  722. if ($myconfig{dbconnect}) {
  723. $myconfig{dbpasswd} = unpack 'u', $myconfig{dbpasswd};
  724. for (keys %myconfig) { $form->{$_} = $myconfig{$_} }
  725. User->delete_login(\%$form);
  726. # delete config file for user
  727. unlink "$userspath/$form->{login}.conf";
  728. }
  729. $form->redirect($locale->text('User deleted!'));
  730. }
  731. sub login_name {
  732. my $login = shift;
  733. $login =~ s/\[\]//g;
  734. return ($login) ? $login : undef;
  735. }
  736. sub change_admin_password {
  737. $form->{title} = qq|LedgerSMB |.$locale->text('Accounting')." ".$locale->text('Administration')." / ".$locale->text('Change Admin Password');
  738. $form->{login} = "root login";
  739. $form->header;
  740. print qq|
  741. <body class="admin">
  742. <form method="post" action="$form->{script}">
  743. <table>
  744. <tr class="listheading">
  745. <th>|.$locale->text('Change Password').qq|</th>
  746. </tr>
  747. <tr size="5"></tr>
  748. <tr>
  749. <td>
  750. <table width="100%">
  751. <tr>
  752. <th align="right">|.$locale->text('Password').qq|</th>
  753. <td><input type="password" name="new_password" /></td>
  754. </tr>
  755. <tr>
  756. <th align="right">|.$locale->text('Confirm').qq|</th>
  757. <td><input type="password" name="confirm_password" /></td>
  758. </tr>
  759. </table>
  760. </td>
  761. </tr>
  762. </table>
  763. <br />
  764. <hr size="3" noshade />
  765. <input type="hidden" name="path" value="$form->{path}" />
  766. <input type="hidden" name="sessionid" value="$form->{sessionid}" />
  767. <p><input type="submit" class="submit" name="action" value="|.$locale->text('Change Password').qq|" /></p>
  768. </form>
  769. </body>
  770. </html>
  771. |;
  772. }
  773. sub change_password {
  774. $form->error($locale->text('Passwords do not match!')) if $form->{new_password} ne $form->{confirm_password};
  775. $root->{password} = $form->{new_password};
  776. $root->{'root login'} = 1;
  777. $root->save_member($memberfile);
  778. $form->{callback} = "$form->{script}?action=list_users&amp;path=$form->{path}&amp;sessionid=$form->{sessionid}";
  779. $form->redirect($locale->text('Password changed!'));
  780. }
  781. sub get_hash {
  782. use Digest::MD5;
  783. $form->{hash} = Digest::MD5::md5_hex rand();
  784. }
  785. sub check_password {
  786. $root = new User "$memberfile", "root login";
  787. if ($root->{password}) {
  788. if ($form->{password}) {
  789. $form->{callback} .= "&amp;password=$form->{password}" if $form->{callback};
  790. $form->{sessionid} = time;
  791. if ($root->{password} ne crypt $form->{password}, 'ro') {
  792. &getpassword;
  793. exit;
  794. }
  795. &get_hash;
  796. open(HASHFILE, "> $userspath/adminhash") || $form->error("Can't Open Hashfile: $!");
  797. print HASHFILE $form->{hash};
  798. print qq|Set-Cookie: LedgerSMB=$form->{hash}; path=/;\n|;
  799. } else {
  800. if ($ENV{HTTP_USER_AGENT}) {
  801. $ENV{HTTP_COOKIE} =~ s/;\s*/;/g;
  802. %cookie = split /[=;]/, $ENV{HTTP_COOKIE}; # Changeme to %cookies
  803. $cookie = ($form->{path} eq 'bin/lynx') ? $cookie{login} : $cookie{"LedgerSMB-root login"};
  804. #fixes problem with first login and such
  805. if (!(-f "$userspath/adminhash")) {
  806. &get_hash;
  807. open(HASHFILE, "> $userspath/adminhash") || $form->error("Can't Open Hashfile: $!");
  808. print HASHFILE $form->{hash};
  809. close(HASHFILE);
  810. }
  811. open (HASHFILE, "< $userspath/adminhash") || $form->error("Can't Open Hashfile: $!");
  812. chomp($form->{hash} = <HASHFILE>);
  813. %cookies = split /[=;]/, $ENV{HTTP_COOKIE};
  814. if (! $cookie || $cookie ne $form->{sessionid} || $form->{hash} ne $cookies{LedgerSMB}) {
  815. &getpassword;
  816. exit;
  817. }
  818. }
  819. }
  820. }
  821. }
  822. sub pg_database_administration {
  823. $form->{dbdriver} = 'Pg';
  824. &dbselect_source;
  825. }
  826. sub pgpp_database_administration {
  827. $form->{dbdriver} = 'PgPP';
  828. &dbselect_source;
  829. }
  830. sub dbdriver_defaults {
  831. # load some defaults for the selected driver
  832. %driverdefaults = ( 'Pg' => { dbport => '',
  833. dbuser => 'ledger-smb',
  834. dbdefault => 'template1',
  835. dbhost => '',
  836. connectstring => $locale->text('Connect to')
  837. } );
  838. $driverdefaults{PgPP} = $driverdefaults{Pg};
  839. for (keys %{ $driverdefaults{Pg} }) { $form->{$_} = $driverdefaults{$form->{dbdriver}}{$_} }
  840. }
  841. sub dbselect_source {
  842. &dbdriver_defaults;
  843. $form->{title} = "LedgerSMB ".$locale->text('Accounting')." / ".$locale->text('Database Administration');
  844. $form->{login} = "root login";
  845. $form->header;
  846. #an insane amount of table nesting here, this should be cleaned up.
  847. print qq|
  848. <body class="admin">
  849. <center>
  850. <h2>$form->{title}</h2>
  851. <form method="post" action="$form->{script}" />
  852. <table>
  853. <tr>
  854. <td>
  855. <table>
  856. <tr class="listheading">
  857. <th colspan="4">|.$locale->text('Database').qq|</th>
  858. </tr>
  859. <tr>
  860. <td>
  861. <table>
  862. <tr>
  863. <th align="right">|.$locale->text('Host').qq|</th>
  864. <td><input name="dbhost" size="25" value="$form->{dbhost}" /></td>
  865. <th align="right">|.$locale->text('Port').qq|</th>
  866. <td><input name="dbport" size="5" value="$form->{dbport}" /></td>
  867. </tr>
  868. <tr>
  869. <th align="right">|.$locale->text('User').qq|</th>
  870. <td><input name="dbuser" size="10" value="$form->{dbuser}" /></td>
  871. <th align="right">|.$locale->text('Password').qq|</th>
  872. <td><input type="password" name="dbpasswd" size="10" /></td>
  873. </tr>
  874. <tr>
  875. <th align="right">$form->{connectstring}</th>
  876. <td colspan="3"><input name="dbdefault" size="10" value="$form->{dbdefault}" /></td>
  877. </tr>
  878. </table>
  879. </td>
  880. </tr>
  881. </table>
  882. </td>
  883. </tr>
  884. </table>
  885. <input type="hidden" name="dbdriver" value="$form->{dbdriver}" />
  886. <input name="callback" type="hidden" value="$form->{script}?action=list_users&amp;path=$form->{path}&amp;sessionid=$form->{sessionid}" />
  887. <input type="hidden" name="path" value="$form->{path}" />
  888. <input type="hidden" name="sessionid" value="$form->{sessionid}" />
  889. <br />
  890. <input type="submit" class="submit" name="action" value="|.$locale->text('Create Dataset').qq|" />
  891. <input type="submit" class="submit" name="action" value="|.$locale->text('Delete Dataset').qq|" />
  892. </form>
  893. <p>|.$locale->text('This is a preliminary check for existing sources. Nothing will be created or deleted at this stage!')
  894. .qq|</p>
  895. </center>
  896. </body>
  897. </html>
  898. |;
  899. }
  900. sub continue {
  901. &{ $form->{nextsub} };
  902. }
  903. sub dbupdate {
  904. User->dbupdate(\%$form);
  905. $form->redirect($locale->text('Dataset updated!'));
  906. }
  907. sub create_dataset {
  908. @dbsources = sort User->dbsources(\%$form);
  909. opendir SQLDIR, "sql/." or $form->error($!);
  910. foreach $item (sort grep /-chart\.sql/, readdir SQLDIR) {
  911. next if ($item eq 'Default-chart.sql');
  912. $item =~ s/-chart\.sql//;
  913. push @charts, qq|<input name="chart" class="radio" type="radio" value="$item" />$item|;
  914. }
  915. closedir SQLDIR;
  916. # add Default at beginning
  917. unshift @charts, qq|<input name="chart" class="radio" type="radio" value="Default" checked />Default|;
  918. $selectencoding = qq|<option></option>
  919. <option value="SQL_ASCII">ASCII</option>
  920. <option value="EUC_JP">Japanese EUC</option>
  921. <option value="EUC_CN">Chinese EUC</option>
  922. <option value="EUC_KR">Korean EUC</option>
  923. <option value="JOHAB">Korean EUC (Hangle base)</option>
  924. <option value="EUC_TW">Taiwan EUC</option>
  925. <option value="UNICODE">Unicode (UTF-8)</option>
  926. <option value="MULE_INTERNAL">Mule internal type</option>
  927. <option value="LATIN1">ISO 8859-1/ECMA 94 (Latin alphabet no. 1)</option>
  928. <option value="LATIN2">ISO 8859-2/ECMA 94 (Latin alphabet no. 2)</option>
  929. <option value="LATIN3">ISO 8859-3/ECMA 94 (Latin alphabet no. 3)</option>
  930. <option value="LATIN4">ISO 8859-4/ECMA 94 (Latin alphabet no. 4)</option>
  931. <option value="LATIN5">ISO 8859-9/ECMA 128 (Latin alphabet no. 5)</option>
  932. <option value="LATIN6">ISO 8859-10/ECMA 144 (Latin alphabet no. 6)</option>
  933. <option value="LATIN7">ISO 8859-13 (Latin alphabet no. 7)</option>
  934. <option value="LATIN8">ISO 8859-14 (Latin alphabet no. 8)</option>
  935. <option value="LATIN9">ISO 8859-15 (Latin alphabet no. 9)</option>
  936. <option value="LATIN10">ISO 8859-16/ASRO SR 14111 (Latin alphabet no. 10)</option>
  937. <option value="ISO_8859_5">ISO 8859-5/ECMA 113 (Latin/Cyrillic)</option>
  938. <option value="ISO_8859_6">ISO 8859-6/ECMA 114 (Latin/Arabic)</option>
  939. <option value="ISO_8859_7">ISO 8859-7/ECMA 118 (Latin/Greek)</option>
  940. <option value="ISO_8859_8">ISO 8859-8/ECMA 121 (Latin/Hebrew)</option>
  941. <option value="KOI8">KOI8-R(U)</option>
  942. <option value="WIN">Windows CP1251</option>
  943. <option value="ALT">Windows CP866</option>
  944. <option value="WIN1256">Windows CP1256 (Arabic)</option>
  945. <option value="TCVN">Windows CP1258 (Vietnamese)</option>
  946. <option value="WIN874">Windows CP874 (Thai)</option>
  947. |;
  948. $form->{title} = "LedgerSMB ".$locale->text('Accounting')
  949. ." ".$locale->text('Database Administration')
  950. ." / ".$locale->text('Create Dataset');
  951. $form->{login} = "root login";
  952. $form->header;
  953. print qq|
  954. <body class="admin">
  955. <center>
  956. <h2>$form->{title}</h2>
  957. <form method="post" action="$form->{script}" />
  958. <table width="100%">
  959. <tr class="listheading">
  960. <th colspan="2">&nbsp;</th>
  961. </tr>
  962. <tr>
  963. <th align="right" nowrap="nowrap">|.$locale->text('Existing Datasets').qq|</th>
  964. <td>
  965. |;
  966. for (@dbsources) { print "[&nbsp;$_&nbsp;] " }
  967. print qq|
  968. </td>
  969. </tr>
  970. <tr>
  971. <th align="right" nowrap="nowrap">|.$locale->text('Create Dataset').qq|</th>
  972. <td><input name="db" /></td>
  973. </tr>
  974. <tr>
  975. <th align="right" nowrap="nowrap">|.$locale->text('Multibyte Encoding').qq|</th>
  976. <td><select name="encoding">$selectencoding</select></td>
  977. </tr>
  978. <tr>
  979. <th align="right" nowrap="nowrap">|.$locale->text('Create Chart of Accounts').qq|</th>
  980. <td>
  981. <table>
  982. |;
  983. while (@charts) {
  984. print qq| <tr>|;
  985. for (0 .. 2) { print "<td>$charts[$_]</td>\n" }
  986. print qq| </tr>|;
  987. splice @charts, 0, 3;
  988. }
  989. print qq| </table>
  990. </td>
  991. </tr>
  992. <tr>
  993. <td colspan="2">
  994. <hr size="3" noshade />
  995. </td>
  996. </tr>
  997. </table>
  998. |;
  999. $form->hide_form(qw(dbdriver dbuser dbhost dbport dbpasswd dbdefault path sessionid));
  1000. print qq|
  1001. <input name="callback" type="hidden" value="$form->{script}?action=list_users&amp;path=$form->{path}&amp;sessionid=$form->{sessionid}" />
  1002. <input type="hidden" name="nextsub" value="dbcreate" />
  1003. <br />
  1004. <input type="submit" class="submit" name="action" value="|.$locale->text('Continue').qq|" />
  1005. </form>
  1006. </body>
  1007. </html>
  1008. |;
  1009. }
  1010. sub dbcreate {
  1011. $form->isblank("db", $locale->text('Dataset missing!'));
  1012. User->dbcreate(\%$form);
  1013. $form->{title} = "LedgerSMB ".$locale->text('Accounting')
  1014. ." ".$locale->text('Database Administration')
  1015. ." / ".$locale->text('Create Dataset');
  1016. $form->{login} = "root login";
  1017. $form->header;
  1018. print qq|
  1019. <body class="admin">
  1020. <center>
  1021. <h2>$form->{title}</h2>
  1022. <form method="post" action="$form->{script}">|
  1023. .$locale->text('Dataset')." $form->{db} ".$locale->text('successfully created!')
  1024. .qq|
  1025. <input type="hidden" name="path" value="$form->{path}" />
  1026. <input type="hidden" name="sessionid" value="$form->{sessionid}" />
  1027. <input type="hidden" name="nextsub" value="list_users" />
  1028. <p><input type="submit" class="submit" name="action" value="|.$locale->text('Continue').qq|" /></p>
  1029. </form>
  1030. </center>
  1031. </body>
  1032. </html>
  1033. |;
  1034. }
  1035. sub delete_dataset {
  1036. if (@dbsources = User->dbsources_unused(\%$form, $memberfile)) {
  1037. foreach $item (sort @dbsources) {
  1038. $dbsources .= qq|<input name="db" class="radio" type="radio" value="$item" />&nbsp;$item |;
  1039. }
  1040. } else {
  1041. $form->error($locale->text('Nothing to delete!'));
  1042. }
  1043. $form->{title} = "LedgerSMB ".$locale->text('Accounting')
  1044. ." ".$locale->text('Database Administration')
  1045. ." / ".$locale->text('Delete Dataset');
  1046. $form->{login} = "root login";
  1047. $form->header;
  1048. print qq|
  1049. <body class="admin">
  1050. <h2>$form->{title}</h2>
  1051. <form method="post" action="$form->{script}" />
  1052. <input type="hidden" name="dbdriver" value="$form->{dbdriver}" />
  1053. <input type="hidden" name="dbuser" value="$form->{dbuser}" />
  1054. <input type="hidden" name="dbhost" value="$form->{dbhost}" />
  1055. <input type="hidden" name="dbport" value="$form->{dbport}" />
  1056. <input type="hidden" name="dbpasswd" value="$form->{dbpasswd}" />
  1057. <input type="hidden" name="dbdefault" value="$form->{dbdefault}" />
  1058. <input name=callback type="hidden" value="$form->{script}?action=list_users&amp;path=$form->{path}&amp;sessionid=$form->{sessionid}">
  1059. <input type="hidden" name="path" value="$form->{path}" />
  1060. <input type="hidden" name="sessionid" value="$form->{sessionid}" />
  1061. <input type="hidden" name="nextsub" value="dbdelete" />
  1062. <table width="100%">
  1063. <tr class="listheading">
  1064. <th>|.$locale->text('The following Datasets are not in use and can be deleted').qq|</th>
  1065. </tr>
  1066. <tr>
  1067. <td>
  1068. $dbsources
  1069. </td>
  1070. </tr>
  1071. <tr>
  1072. <td>
  1073. <hr size="3" noshade />
  1074. <br />
  1075. <input type="submit" class="submit" name="action" value="|.$locale->text('Continue').qq|" />
  1076. </td>
  1077. </tr>
  1078. </table>
  1079. </form>
  1080. </body>
  1081. </html>
  1082. |;
  1083. }
  1084. sub dbdelete {
  1085. if (!$form->{db}) {
  1086. $form->error($locale->text('No Dataset selected!'));
  1087. }
  1088. User->dbdelete(\%$form);
  1089. $form->{title} = "LedgerSMB ".$locale->text('Accounting')
  1090. ." ".$locale->text('Database Administration')
  1091. ." / ".$locale->text('Delete Dataset');
  1092. $form->{login} = "root login";
  1093. $form->header;
  1094. print qq|
  1095. <body class="admin">
  1096. <center>
  1097. <h2>$form->{title}</h2>
  1098. $form->{db} |.$locale->text('successfully deleted!')
  1099. .qq|
  1100. <form method="post" action="$form->{script}" />
  1101. <input type="hidden" name="path" value="$form->{path}" />
  1102. <input type="hidden" name="sessionid" value="$form->{sessionid}" />
  1103. <input type="hidden" name="nextsub" value="list_users" />
  1104. <p><input type="submit" class="submit" name="action" value="|.$locale->text('Continue').qq|" /></p>
  1105. </form>
  1106. </body>
  1107. </html>
  1108. |;
  1109. }
  1110. sub unlock_system {
  1111. unlink "$userspath/nologin";
  1112. $form->{callback} = "$form->{script}?action=list_users&amp;path=$form->{path}&amp;sessionid=$form->{sessionid}";
  1113. $form->redirect($locale->text('Lockfile removed!'));
  1114. }
  1115. sub lock_system {
  1116. open(FH, ">$userspath/nologin") or $form->error($locale->text('Cannot create Lock!'));
  1117. close(FH);
  1118. $form->{callback} = "$form->{script}?action=list_users&amp;path=$form->{path}&amp;sessionid=$form->{sessionid}";
  1119. $form->redirect($locale->text('Lockfile created!'));
  1120. }