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