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