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