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