summaryrefslogtreecommitdiff
path: root/bin/admin.pl
blob: 88ecc3670182a02ee6c10fa75330c9559e26ad21 (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. $form->db_init;
  585. # no driver checked
  586. $form->error($locale->text('Database Driver not checked!')) unless $form->{dbdriver};
  587. # no spaces allowed in login name
  588. $form->{login} =~ s/ //g;
  589. $form->isblank("login", $locale->text('Login name missing!'));
  590. # check for duplicates
  591. if (!$form->{edit}) {
  592. $temp = new User "$memberfile", "$form->{login}";
  593. if ($temp->{login}) {
  594. $form->error("$form->{login} ".$locale->text('is already a member!'));
  595. }
  596. }
  597. # no spaces allowed in directories
  598. $form->{newtemplates} =~ s/( |\.\.|\*)//g;
  599. if ($form->{newtemplates} ne "") {
  600. $form->{templates} = $form->{newtemplates};
  601. } else {
  602. $form->{templates} = ($form->{usetemplates}) ? $form->{usetemplates} : $form->{login};
  603. }
  604. # is there a basedir
  605. if (! -d "$templates") {
  606. $form->error($locale->text('Directory').": $templates ".$locale->text('does not exist'));
  607. }
  608. # add base directory to $form->{templates}
  609. $form->{templates} = "$templates/$form->{templates}";
  610. $myconfig = new User "$memberfile", "$form->{login}";
  611. # redo acs variable and delete all the acs codes
  612. @acs = split /;/, $form->{acs};
  613. $form->{acs} = "";
  614. foreach $item (@acs) {
  615. $item = $form->escape($item,1);
  616. if (!$form->{$item}) {
  617. $form->{acs} .= $form->unescape($form->unescape("$item")).";";
  618. }
  619. delete $form->{$item};
  620. }
  621. # check which database was filled in
  622. $form->{dbhost} = $form->{"$form->{dbdriver}_dbhost"};
  623. $form->{dbport} = $form->{"$form->{dbdriver}_dbport"};
  624. $form->{dbpasswd} = $form->{"$form->{dbdriver}_dbpasswd"};
  625. $form->{dbuser} = $form->{"$form->{dbdriver}_dbuser"};
  626. $form->{dbname} = $form->{"$form->{dbdriver}_dbname"};
  627. $form->isblank("dbname", $locale->text('Dataset missing!'));
  628. $form->isblank("dbuser", $locale->text('Database User missing!'));
  629. foreach $item (keys %{$form}) {
  630. $myconfig->{$item} = $form->{$item};
  631. }
  632. $myconfig->{password} = $form->{old_password};
  633. $myconfig->{password} = $form->{new_password} if $form->{new_password} ne $form->{old_password};
  634. $myconfig->{timeout} = $form->{newtimeout};
  635. delete $myconfig->{stylesheet};
  636. if ($form->{userstylesheet}) {
  637. $myconfig->{stylesheet} = $form->{userstylesheet};
  638. }
  639. $myconfig->{packpw} = 1;
  640. $myconfig->save_member($memberfile, $userspath);
  641. # create user template directory and copy master files
  642. if (! -d "$form->{templates}") {
  643. umask(002);
  644. if (mkdir "$form->{templates}", oct("771")) {
  645. umask(007);
  646. # copy templates to the directory
  647. opendir TEMPLATEDIR, "$templates/." or $form->error("$templates : $!");
  648. @templates = grep /$form->{mastertemplates}-/, readdir TEMPLATEDIR;
  649. closedir TEMPLATEDIR;
  650. foreach $file (@templates) {
  651. open(TEMP, "$templates/$file") or $form->error("$templates/$file : $!");
  652. $file =~ s/$form->{mastertemplates}-//;
  653. open(NEW, ">$form->{templates}/$file") or $form->error("$form->{templates}/$file : $!");
  654. while ($line = <TEMP>) {
  655. print NEW $line;
  656. }
  657. close(TEMP);
  658. close(NEW);
  659. }
  660. } else {
  661. $form->error("$form->{templates} : $!");
  662. }
  663. }
  664. $form->redirect($locale->text('User saved!'));
  665. }
  666. sub delete {
  667. $form->{templates} = ($form->{templates}) ? "$templates/$form->{templates}" : "$templates/$form->{login}";
  668. $form->error("$memberfile ".$locale->text('locked!')) if (-f ${memberfile}.LCK);
  669. open(FH, ">${memberfile}.LCK") or $form->error("${memberfile}.LCK : $!");
  670. close(FH);
  671. if (! open(CONF, "+<$memberfile")) {
  672. unlink "${memberfile}.LCK";
  673. $form->error("$memberfile : $!");
  674. }
  675. @config = <CONF>;
  676. seek(CONF, 0, 0);
  677. truncate(CONF, 0);
  678. while ($line = shift @config) {
  679. chop $line;
  680. if ($line =~ /^\[/) {
  681. last if ($line eq "[$form->{login}]");
  682. $login = &login_name($line);
  683. }
  684. if ($line =~ /^templates=/) {
  685. ($null, $user{$login}) = split /=/, $line, 2;
  686. }
  687. print CONF "$line\n";
  688. }
  689. # remove everything up to next login or EOF
  690. # and save template variable
  691. while ($line = shift @config) {
  692. chop $line;
  693. ($key, $value) = split /=/, $line, 2;
  694. $myconfig{$key} = $value;
  695. last if ($line =~ /^\[/);
  696. }
  697. # this one is either the next login or EOF
  698. print CONF "$line\n";
  699. $login = &login_name($line);
  700. while ($line = shift @config) {
  701. chop $line;
  702. if ($line =~ /^\[/) {
  703. $login = &login_name($line);
  704. }
  705. if ($line =~ /^templates=/) {
  706. ($null, $user{$login}) = split /=/, $line, 2;
  707. }
  708. print CONF "$line\n";
  709. }
  710. close(CONF);
  711. unlink "${memberfile}.LCK";
  712. # scan %user for $templatedir
  713. foreach $login (keys %user) {
  714. last if ($found = ($form->{templates} eq $user{$login}));
  715. }
  716. # if found keep directory otherwise delete
  717. if (!$found) {
  718. # delete it if there is a template directory
  719. $dir = "$form->{templates}";
  720. if (-d "$dir") {
  721. unlink <$dir/*>;
  722. rmdir "$dir";
  723. }
  724. }
  725. if ($myconfig{dbconnect}) {
  726. $myconfig{dbpasswd} = unpack 'u', $myconfig{dbpasswd};
  727. for (keys %myconfig) { $form->{$_} = $myconfig{$_} }
  728. User->delete_login(\%$form);
  729. # delete config file for user
  730. unlink "$userspath/$form->{login}.conf";
  731. }
  732. $form->redirect($locale->text('User deleted!'));
  733. }
  734. sub login_name {
  735. my $login = shift;
  736. $login =~ s/\[\]//g;
  737. return ($login) ? $login : undef;
  738. }
  739. sub change_admin_password {
  740. $form->{title} = qq|LedgerSMB |.$locale->text('Accounting')." ".$locale->text('Administration')." / ".$locale->text('Change Admin Password');
  741. $form->{login} = "root login";
  742. $form->header;
  743. print qq|
  744. <body class="admin">
  745. <form method="post" action="$form->{script}">
  746. <table>
  747. <tr class="listheading">
  748. <th>|.$locale->text('Change Password').qq|</th>
  749. </tr>
  750. <tr size="5"></tr>
  751. <tr>
  752. <td>
  753. <table width="100%">
  754. <tr>
  755. <th align="right">|.$locale->text('Password').qq|</th>
  756. <td><input type="password" name="new_password" /></td>
  757. </tr>
  758. <tr>
  759. <th align="right">|.$locale->text('Confirm').qq|</th>
  760. <td><input type="password" name="confirm_password" /></td>
  761. </tr>
  762. </table>
  763. </td>
  764. </tr>
  765. </table>
  766. <br />
  767. <hr size="3" noshade />
  768. <input type="hidden" name="path" value="$form->{path}" />
  769. <input type="hidden" name="sessionid" value="$form->{sessionid}" />
  770. <p><input type="submit" class="submit" name="action" value="|.$locale->text('Change Password').qq|" /></p>
  771. </form>
  772. </body>
  773. </html>
  774. |;
  775. }
  776. sub change_password {
  777. $form->error($locale->text('Passwords do not match!')) if $form->{new_password} ne $form->{confirm_password};
  778. $root->{password} = $form->{new_password};
  779. $root->{'root login'} = 1;
  780. $root->save_member($memberfile);
  781. $form->{callback} = "$form->{script}?action=list_users&amp;path=$form->{path}&amp;sessionid=$form->{sessionid}";
  782. $form->redirect($locale->text('Password changed!'));
  783. }
  784. sub get_hash {
  785. use Digest::MD5;
  786. $form->{hash} = Digest::MD5::md5_hex rand();
  787. }
  788. sub check_password {
  789. $root = new User "$memberfile", "root login";
  790. if ($root->{password}) {
  791. if ($form->{password}) {
  792. $form->{callback} .= "&amp;password=$form->{password}" if $form->{callback};
  793. $form->{sessionid} = time;
  794. if ($root->{password} ne crypt $form->{password}, 'ro') {
  795. &getpassword;
  796. exit;
  797. }
  798. &get_hash;
  799. open(HASHFILE, "> $userspath/adminhash") || $form->error("Can't Open Hashfile: $!");
  800. print HASHFILE $form->{hash};
  801. print qq|Set-Cookie: LedgerSMB=$form->{hash}; path=/;\n|;
  802. } else {
  803. if ($ENV{HTTP_USER_AGENT}) {
  804. $ENV{HTTP_COOKIE} =~ s/;\s*/;/g;
  805. %cookie = split /[=;]/, $ENV{HTTP_COOKIE}; # Changeme to %cookies
  806. $cookie = ($form->{path} eq 'bin/lynx') ? $cookie{login} : $cookie{"LedgerSMB-root login"};
  807. #fixes problem with first login and such
  808. if (!(-f "$userspath/adminhash")) {
  809. &get_hash;
  810. open(HASHFILE, "> $userspath/adminhash") || $form->error("Can't Open Hashfile: $!");
  811. print HASHFILE $form->{hash};
  812. close(HASHFILE);
  813. }
  814. open (HASHFILE, "< $userspath/adminhash") || $form->error("Can't Open Hashfile: $!");
  815. chomp($form->{hash} = <HASHFILE>);
  816. %cookies = split /[=;]/, $ENV{HTTP_COOKIE};
  817. if (! $cookie || $cookie ne $form->{sessionid} || $form->{hash} ne $cookies{LedgerSMB}) {
  818. &getpassword;
  819. exit;
  820. }
  821. }
  822. }
  823. }
  824. }
  825. sub pg_database_administration {
  826. $form->{dbdriver} = 'Pg';
  827. &dbselect_source;
  828. }
  829. sub pgpp_database_administration {
  830. $form->{dbdriver} = 'PgPP';
  831. &dbselect_source;
  832. }
  833. sub dbdriver_defaults {
  834. # load some defaults for the selected driver
  835. %driverdefaults = ( 'Pg' => { dbport => '',
  836. dbuser => 'ledger-smb',
  837. dbdefault => 'template1',
  838. dbhost => '',
  839. connectstring => $locale->text('Connect to')
  840. } );
  841. $driverdefaults{PgPP} = $driverdefaults{Pg};
  842. for (keys %{ $driverdefaults{Pg} }) { $form->{$_} = $driverdefaults{$form->{dbdriver}}{$_} }
  843. }
  844. sub dbselect_source {
  845. &dbdriver_defaults;
  846. $form->{title} = "LedgerSMB ".$locale->text('Accounting')." / ".$locale->text('Database Administration');
  847. $form->{login} = "root login";
  848. $form->header;
  849. #an insane amount of table nesting here, this should be cleaned up.
  850. print qq|
  851. <body class="admin">
  852. <center>
  853. <h2>$form->{title}</h2>
  854. <form method="post" action="$form->{script}" />
  855. <table>
  856. <tr>
  857. <td>
  858. <table>
  859. <tr class="listheading">
  860. <th colspan="4">|.$locale->text('Database').qq|</th>
  861. </tr>
  862. <tr>
  863. <td>
  864. <table>
  865. <tr>
  866. <th align="right">|.$locale->text('Host').qq|</th>
  867. <td><input name="dbhost" size="25" value="$form->{dbhost}" /></td>
  868. <th align="right">|.$locale->text('Port').qq|</th>
  869. <td><input name="dbport" size="5" value="$form->{dbport}" /></td>
  870. </tr>
  871. <tr>
  872. <th align="right">|.$locale->text('User').qq|</th>
  873. <td><input name="dbuser" size="10" value="$form->{dbuser}" /></td>
  874. <th align="right">|.$locale->text('Password').qq|</th>
  875. <td><input type="password" name="dbpasswd" size="10" /></td>
  876. </tr>
  877. <tr>
  878. <th align="right">$form->{connectstring}</th>
  879. <td colspan="3"><input name="dbdefault" size="10" value="$form->{dbdefault}" /></td>
  880. </tr>
  881. <th align="right">|.$locale->text("Superuser").qq|</th>
  882. <td><input name="dbsuperuser" size="10" value="$form->{dbsuperuser}" /></td>
  883. <th align="right">|.$locale->text('Password').qq|</th>
  884. <td><input type="password" name="dbsuperpasswd" size="10" /></td>
  885. </table>
  886. </td>
  887. </tr>
  888. </table>
  889. </td>
  890. </tr>
  891. </table>
  892. <input type="hidden" name="dbdriver" value="$form->{dbdriver}" />
  893. <input name="callback" type="hidden" value="$form->{script}?action=list_users&amp;path=$form->{path}&amp;sessionid=$form->{sessionid}" />
  894. <input type="hidden" name="path" value="$form->{path}" />
  895. <input type="hidden" name="sessionid" value="$form->{sessionid}" />
  896. <br />
  897. <input type="submit" class="submit" name="action" value="|.$locale->text('Create Dataset').qq|" />
  898. <input type="submit" class="submit" name="action" value="|.$locale->text('Delete Dataset').qq|" />
  899. </form>
  900. <p>|.$locale->text('This is a preliminary check for existing sources. Nothing will be created or deleted at this stage!')
  901. .qq|</p>
  902. </center>
  903. </body>
  904. </html>
  905. |;
  906. }
  907. sub continue {
  908. &{ $form->{nextsub} };
  909. }
  910. sub dbupdate {
  911. User->dbupdate(\%$form);
  912. $form->redirect($locale->text('Dataset updated!'));
  913. }
  914. sub create_dataset {
  915. @dbsources = sort User->dbsources(\%$form);
  916. opendir SQLDIR, "sql/." or $form->error($!);
  917. foreach $item (sort grep /-chart\.sql/, readdir SQLDIR) {
  918. next if ($item eq 'Default-chart.sql');
  919. $item =~ s/-chart\.sql//;
  920. push @charts, qq|<input name="chart" class="radio" type="radio" value="$item" />$item|;
  921. }
  922. closedir SQLDIR;
  923. # add Default at beginning
  924. unshift @charts, qq|<input name="chart" class="radio" type="radio" value="Default" checked />Default|;
  925. $selectencoding = qq|<option></option>
  926. <option value="SQL_ASCII">ASCII</option>
  927. <option value="EUC_JP">Japanese EUC</option>
  928. <option value="EUC_CN">Chinese EUC</option>
  929. <option value="EUC_KR">Korean EUC</option>
  930. <option value="JOHAB">Korean EUC (Hangle base)</option>
  931. <option value="EUC_TW">Taiwan EUC</option>
  932. <option value="UNICODE">Unicode (UTF-8)</option>
  933. <option value="MULE_INTERNAL">Mule internal type</option>
  934. <option value="LATIN1">ISO 8859-1/ECMA 94 (Latin alphabet no. 1)</option>
  935. <option value="LATIN2">ISO 8859-2/ECMA 94 (Latin alphabet no. 2)</option>
  936. <option value="LATIN3">ISO 8859-3/ECMA 94 (Latin alphabet no. 3)</option>
  937. <option value="LATIN4">ISO 8859-4/ECMA 94 (Latin alphabet no. 4)</option>
  938. <option value="LATIN5">ISO 8859-9/ECMA 128 (Latin alphabet no. 5)</option>
  939. <option value="LATIN6">ISO 8859-10/ECMA 144 (Latin alphabet no. 6)</option>
  940. <option value="LATIN7">ISO 8859-13 (Latin alphabet no. 7)</option>
  941. <option value="LATIN8">ISO 8859-14 (Latin alphabet no. 8)</option>
  942. <option value="LATIN9">ISO 8859-15 (Latin alphabet no. 9)</option>
  943. <option value="LATIN10">ISO 8859-16/ASRO SR 14111 (Latin alphabet no. 10)</option>
  944. <option value="ISO_8859_5">ISO 8859-5/ECMA 113 (Latin/Cyrillic)</option>
  945. <option value="ISO_8859_6">ISO 8859-6/ECMA 114 (Latin/Arabic)</option>
  946. <option value="ISO_8859_7">ISO 8859-7/ECMA 118 (Latin/Greek)</option>
  947. <option value="ISO_8859_8">ISO 8859-8/ECMA 121 (Latin/Hebrew)</option>
  948. <option value="KOI8">KOI8-R(U)</option>
  949. <option value="WIN">Windows CP1251</option>
  950. <option value="ALT">Windows CP866</option>
  951. <option value="WIN1256">Windows CP1256 (Arabic)</option>
  952. <option value="TCVN">Windows CP1258 (Vietnamese)</option>
  953. <option value="WIN874">Windows CP874 (Thai)</option>
  954. |;
  955. $form->{title} = "LedgerSMB ".$locale->text('Accounting')
  956. ." ".$locale->text('Database Administration')
  957. ." / ".$locale->text('Create Dataset');
  958. $form->{login} = "root login";
  959. $form->header;
  960. print qq|
  961. <body class="admin">
  962. <center>
  963. <h2>$form->{title}</h2>
  964. <form method="post" action="$form->{script}" />
  965. <table width="100%">
  966. <tr class="listheading">
  967. <th colspan="2">&nbsp;</th>
  968. </tr>
  969. <tr>
  970. <th align="right" nowrap="nowrap">|.$locale->text('Existing Datasets').qq|</th>
  971. <td>
  972. |;
  973. for (@dbsources) { print "[&nbsp;$_&nbsp;] " }
  974. print qq|
  975. </td>
  976. </tr>
  977. <tr>
  978. <th align="right" nowrap="nowrap">|.$locale->text('Create Dataset').qq|</th>
  979. <td><input name="db" /></td>
  980. </tr>
  981. <tr>
  982. <th align="right" nowrap="nowrap">|.$locale->text('Multibyte Encoding').qq|</th>
  983. <td><select name="encoding">$selectencoding</select></td>
  984. </tr>
  985. <tr>
  986. <th align="right" nowrap="nowrap">|.$locale->text('Create Chart of Accounts').qq|</th>
  987. <td>
  988. <table>
  989. |;
  990. while (@charts) {
  991. print qq| <tr>|;
  992. for (0 .. 2) { print "<td>$charts[$_]</td>\n" }
  993. print qq| </tr>|;
  994. splice @charts, 0, 3;
  995. }
  996. print qq| </table>
  997. </td>
  998. </tr>
  999. <tr>
  1000. <td colspan="2">
  1001. <hr size="3" noshade />
  1002. </td>
  1003. </tr>
  1004. </table>
  1005. |;
  1006. $form->hide_form(qw(dbdriver dbsuperuser dbsuperpasswd dbuser dbhost dbport dbpasswd dbdefault path sessionid));
  1007. print qq|
  1008. <input name="callback" type="hidden" value="$form->{script}?action=list_users&amp;path=$form->{path}&amp;sessionid=$form->{sessionid}" />
  1009. <input type="hidden" name="nextsub" value="dbcreate" />
  1010. <br />
  1011. <input type="submit" class="submit" name="action" value="|.$locale->text('Continue').qq|" />
  1012. </form>
  1013. </body>
  1014. </html>
  1015. |;
  1016. }
  1017. sub dbcreate {
  1018. $form->isblank("db", $locale->text('Dataset missing!'));
  1019. User->dbcreate(\%$form);
  1020. $form->{title} = "LedgerSMB ".$locale->text('Accounting')
  1021. ." ".$locale->text('Database Administration')
  1022. ." / ".$locale->text('Create Dataset');
  1023. $form->{login} = "root login";
  1024. $form->header;
  1025. print qq|
  1026. <body class="admin">
  1027. <center>
  1028. <h2>$form->{title}</h2>
  1029. <form method="post" action="$form->{script}">|
  1030. .$locale->text('Dataset')." $form->{db} ".$locale->text('successfully created!')
  1031. .qq|
  1032. <input type="hidden" name="path" value="$form->{path}" />
  1033. <input type="hidden" name="sessionid" value="$form->{sessionid}" />
  1034. <input type="hidden" name="nextsub" value="list_users" />
  1035. <p><input type="submit" class="submit" name="action" value="|.$locale->text('Continue').qq|" /></p>
  1036. </form>
  1037. </center>
  1038. </body>
  1039. </html>
  1040. |;
  1041. }
  1042. sub delete_dataset {
  1043. if (@dbsources = User->dbsources_unused(\%$form, $memberfile)) {
  1044. foreach $item (sort @dbsources) {
  1045. $dbsources .= qq|<input name="db" class="radio" type="radio" value="$item" />&nbsp;$item |;
  1046. }
  1047. } else {
  1048. $form->error($locale->text('Nothing to delete!'));
  1049. }
  1050. $form->{title} = "LedgerSMB ".$locale->text('Accounting')
  1051. ." ".$locale->text('Database Administration')
  1052. ." / ".$locale->text('Delete Dataset');
  1053. $form->{login} = "root login";
  1054. $form->header;
  1055. print qq|
  1056. <body class="admin">
  1057. <h2>$form->{title}</h2>
  1058. <form method="post" action="$form->{script}" />
  1059. <input type="hidden" name="dbdriver" value="$form->{dbdriver}" />
  1060. <input type="hidden" name="dbuser" value="$form->{dbuser}" />
  1061. <input type="hidden" name="dbhost" value="$form->{dbhost}" />
  1062. <input type="hidden" name="dbport" value="$form->{dbport}" />
  1063. <input type="hidden" name="dbpasswd" value="$form->{dbpasswd}" />
  1064. <input type="hidden" name="dbdefault" value="$form->{dbdefault}" />
  1065. <input name=callback type="hidden" value="$form->{script}?action=list_users&amp;path=$form->{path}&amp;sessionid=$form->{sessionid}">
  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="dbdelete" />
  1069. <table width="100%">
  1070. <tr class="listheading">
  1071. <th>|.$locale->text('The following Datasets are not in use and can be deleted').qq|</th>
  1072. </tr>
  1073. <tr>
  1074. <td>
  1075. $dbsources
  1076. </td>
  1077. </tr>
  1078. <tr>
  1079. <td>
  1080. <hr size="3" noshade />
  1081. <br />
  1082. <input type="submit" class="submit" name="action" value="|.$locale->text('Continue').qq|" />
  1083. </td>
  1084. </tr>
  1085. </table>
  1086. </form>
  1087. </body>
  1088. </html>
  1089. |;
  1090. }
  1091. sub dbdelete {
  1092. if (!$form->{db}) {
  1093. $form->error($locale->text('No Dataset selected!'));
  1094. }
  1095. User->dbdelete(\%$form);
  1096. $form->{title} = "LedgerSMB ".$locale->text('Accounting')
  1097. ." ".$locale->text('Database Administration')
  1098. ." / ".$locale->text('Delete Dataset');
  1099. $form->{login} = "root login";
  1100. $form->header;
  1101. print qq|
  1102. <body class="admin">
  1103. <center>
  1104. <h2>$form->{title}</h2>
  1105. $form->{db} |.$locale->text('successfully deleted!')
  1106. .qq|
  1107. <form method="post" action="$form->{script}" />
  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="list_users" />
  1111. <p><input type="submit" class="submit" name="action" value="|.$locale->text('Continue').qq|" /></p>
  1112. </form>
  1113. </body>
  1114. </html>
  1115. |;
  1116. }
  1117. sub unlock_system {
  1118. unlink "$userspath/nologin";
  1119. $form->{callback} = "$form->{script}?action=list_users&amp;path=$form->{path}&amp;sessionid=$form->{sessionid}";
  1120. $form->redirect($locale->text('Lockfile removed!'));
  1121. }
  1122. sub lock_system {
  1123. open(FH, ">$userspath/nologin") or $form->error($locale->text('Cannot create Lock!'));
  1124. close(FH);
  1125. $form->{callback} = "$form->{script}?action=list_users&amp;path=$form->{path}&amp;sessionid=$form->{sessionid}";
  1126. $form->redirect($locale->text('Lockfile created!'));
  1127. }