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