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