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