summaryrefslogtreecommitdiff
path: root/bin/mozilla/admin.pl
blob: 3bf6950111efcb05ea8621f4ee62b41d573d3a52 (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. #fixes problem with first login and such
  788. if (!(-f "$userspath/adminhash")) {
  789. &get_hash;
  790. open(HASHFILE, "> $userspath/adminhash") || $form->error("Can't Open Hashfile: $!");
  791. print HASHFILE $form->{hash};
  792. close(HASHFILE);
  793. }
  794. open (HASHFILE, "< $userspath/adminhash") || $form->error("Can't Open Hashfile: $!");
  795. chomp($form->{hash} = <HASHFILE>);
  796. %cookies = split /[=;]/, $ENV{HTTP_COOKIE};
  797. if (! $cookie || $cookie ne $form->{sessionid} ||
  798. $form->{hash} ne $cookies{LedgerSMB}) {
  799. &getpassword;
  800. exit;
  801. }
  802. }
  803. }
  804. }
  805. }
  806. sub pg_database_administration {
  807. $form->{dbdriver} = 'Pg';
  808. &dbselect_source;
  809. }
  810. sub pgpp_database_administration {
  811. $form->{dbdriver} = 'PgPP';
  812. &dbselect_source;
  813. }
  814. sub oracle_database_administration {
  815. $form->{dbdriver} = 'Oracle';
  816. &dbselect_source;
  817. }
  818. sub dbdriver_defaults {
  819. # load some defaults for the selected driver
  820. %driverdefaults = ( 'Pg' => { dbport => '',
  821. dbuser => 'ledger-smb',
  822. dbdefault => 'template1',
  823. dbhost => '',
  824. connectstring => $locale->text('Connect to')
  825. },
  826. 'Oracle' => { dbport => '1521',
  827. dbuser => 'oralin',
  828. dbdefault => $sid,
  829. dbhost => `hostname`,
  830. connectstring => 'SID'
  831. }
  832. );
  833. $driverdefaults{PgPP} = $driverdefaults{Pg};
  834. for (keys %{ $driverdefaults{Pg} }) { $form->{$_} = $driverdefaults{$form->{dbdriver}}{$_} }
  835. }
  836. sub dbselect_source {
  837. &dbdriver_defaults;
  838. $form->{title} = "LedgerSMB ".$locale->text('Accounting')." / ".$locale->text('Database Administration');
  839. $form->{login} = "root login";
  840. $form->header;
  841. print qq|
  842. <body class=admin>
  843. <center>
  844. <h2>$form->{title}</h2>
  845. <form method=post action=$form->{script}>
  846. <table>
  847. <tr>
  848. <td>
  849. <table>
  850. <tr class=listheading>
  851. <th colspan=4>|.$locale->text('Database').qq|</th>
  852. </tr>
  853. <input type=hidden name=dbdriver value=$form->{dbdriver}>
  854. <tr>
  855. <td>
  856. <table>
  857. <tr>
  858. <th align=right>|.$locale->text('Host').qq|</th>
  859. <td><input name=dbhost size=25 value=$form->{dbhost}></td>
  860. <th align=right>|.$locale->text('Port').qq|</th>
  861. <td><input name=dbport size=5 value=$form->{dbport}></td>
  862. </tr>
  863. <tr>
  864. <th align=right>|.$locale->text('User').qq|</th>
  865. <td><input name=dbuser size=10 value=$form->{dbuser}></td>
  866. <th align=right>|.$locale->text('Password').qq|</th>
  867. <td><input type=password name=dbpasswd size=10></td>
  868. </tr>
  869. <tr>
  870. <th align=right>$form->{connectstring}</th>
  871. <td colspan=3><input name=dbdefault size=10 value=$form->{dbdefault}></td>
  872. </tr>
  873. </table>
  874. </td>
  875. </tr>
  876. </table>
  877. <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}">
  878. <input type=hidden name=path value=$form->{path}>
  879. <input type=hidden name=sessionid value=$form->{sessionid}>
  880. <br>
  881. <input type=submit class=submit name=action value="|.$locale->text('Create Dataset').qq|">
  882. <input type=submit class=submit name=action value="|.$locale->text('Update Dataset').qq|">
  883. <input type=submit class=submit name=action value="|.$locale->text('Delete Dataset').qq|">
  884. </form>
  885. </td>
  886. </tr>
  887. </table>
  888. <p>|.$locale->text('This is a preliminary check for existing sources. Nothing will be created or deleted at this stage!')
  889. .qq|
  890. </body>
  891. </html>
  892. |;
  893. }
  894. sub continue {
  895. &{ $form->{nextsub} };
  896. }
  897. sub update_dataset {
  898. %needsupdate = User->dbneedsupdate(\%$form);
  899. $form->{title} = "LedgerSMB ".$locale->text('Accounting')." ".$locale->text('Database Administration')." / ".$locale->text('Update Dataset');
  900. $form->{login} = "root login";
  901. $form->header;
  902. print qq|
  903. <body class=admin>
  904. <center>
  905. <h2>$form->{title}</h2>
  906. |;
  907. foreach $key (sort keys %needsupdate) {
  908. if ($needsupdate{$key} ne $form->{dbversion}) {
  909. $upd .= qq|<input name="db$key" class=checkbox type=checkbox value=1 checked> $key\n|;
  910. $form->{dbupdate} .= "db$key ";
  911. }
  912. }
  913. chop $form->{dbupdate};
  914. if ($form->{dbupdate}) {
  915. print qq|
  916. <table width=100%>
  917. <form method=post action=$form->{script}>
  918. <input type=hidden name=dbdriver value=$form->{dbdriver}>
  919. <input type=hidden name=dbhost value=$form->{dbhost}>
  920. <input type=hidden name=dbport value=$form->{dbport}>
  921. <input type=hidden name=dbuser value=$form->{dbuser}>
  922. <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
  923. <input type=hidden name=dbdefault value=$form->{dbdefault}>
  924. <tr class=listheading>
  925. <th>|.$locale->text('The following Datasets need to be updated').qq|</th>
  926. </tr>
  927. <tr>
  928. <td>
  929. $upd
  930. </td>
  931. </tr>
  932. <tr>
  933. <td>
  934. <input name=dbupdate type=hidden value="$form->{dbupdate}">
  935. <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}">
  936. <input type=hidden name=path value=$form->{path}>
  937. <input type=hidden name=sessionid value=$form->{sessionid}>
  938. <input type=hidden name=nextsub value=dbupdate>
  939. <hr size=3 noshade>
  940. <br>
  941. <input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
  942. </td></tr>
  943. </table>
  944. </form>
  945. |;
  946. } else {
  947. print $locale->text('DBA')." : $form->{dbuser} : " .$locale->text('All Datasets up to date!');
  948. }
  949. print qq|
  950. </body>
  951. </html>
  952. |;
  953. }
  954. sub dbupdate {
  955. User->dbupdate(\%$form);
  956. $form->redirect($locale->text('Dataset updated!'));
  957. }
  958. sub create_dataset {
  959. @dbsources = sort User->dbsources(\%$form);
  960. opendir SQLDIR, "sql/." or $form->error($!);
  961. foreach $item (sort grep /-chart\.sql/, readdir SQLDIR) {
  962. next if ($item eq 'Default-chart.sql');
  963. $item =~ s/-chart\.sql//;
  964. push @charts, qq|<input name=chart class=radio type=radio value="$item">$item|;
  965. }
  966. closedir SQLDIR;
  967. # add Default at beginning
  968. unshift @charts, qq|<input name=chart class=radio type=radio value="Default" checked>Default|;
  969. $selectencoding = qq|<option>
  970. <option value=SQL_ASCII>ASCII
  971. <option value=EUC_JP>Japanese EUC
  972. <option value=EUC_CN>Chinese EUC
  973. <option value=EUC_KR>Korean EUC
  974. <option value=JOHAB>Korean EUC (Hangle base)
  975. <option value=EUC_TW>Taiwan EUC
  976. <option value=UNICODE>Unicode (UTF-8)
  977. <option value=MULE_INTERNAL>Mule internal type
  978. <option value=LATIN1>ISO 8859-1/ECMA 94 (Latin alphabet no. 1)
  979. <option value=LATIN2>ISO 8859-2/ECMA 94 (Latin alphabet no. 2)
  980. <option value=LATIN3>ISO 8859-3/ECMA 94 (Latin alphabet no. 3)
  981. <option value=LATIN4>ISO 8859-4/ECMA 94 (Latin alphabet no. 4)
  982. <option value=LATIN5>ISO 8859-9/ECMA 128 (Latin alphabet no. 5)
  983. <option value=LATIN6>ISO 8859-10/ECMA 144 (Latin alphabet no. 6)
  984. <option value=LATIN7>ISO 8859-13 (Latin alphabet no. 7)
  985. <option value=LATIN8>ISO 8859-14 (Latin alphabet no. 8)
  986. <option value=LATIN9>ISO 8859-15 (Latin alphabet no. 9)
  987. <option value=LATIN10>ISO 8859-16/ASRO SR 14111 (Latin alphabet no. 10)
  988. <option value=ISO_8859_5>ISO 8859-5/ECMA 113 (Latin/Cyrillic)
  989. <option value=ISO_8859_6>ISO 8859-6/ECMA 114 (Latin/Arabic)
  990. <option value=ISO_8859_7>ISO 8859-7/ECMA 118 (Latin/Greek)
  991. <option value=ISO_8859_8>ISO 8859-8/ECMA 121 (Latin/Hebrew)
  992. <option value=KOI8>KOI8-R(U)
  993. <option value=WIN>Windows CP1251
  994. <option value=ALT>Windows CP866
  995. <option value=WIN1256>Windows CP1256 (Arabic)
  996. <option value=TCVN>Windows CP1258 (Vietnamese)
  997. <option value=WIN874>Windows CP874 (Thai)
  998. |;
  999. $form->{title} = "LedgerSMB ".$locale->text('Accounting')." ".$locale->text('Database Administration')." / ".$locale->text('Create Dataset');
  1000. $form->{login} = "root login";
  1001. $form->header;
  1002. print qq|
  1003. <body class=admin>
  1004. <center>
  1005. <h2>$form->{title}</h2>
  1006. <form method=post action=$form->{script}>
  1007. <table width=100%>
  1008. <tr class=listheading>
  1009. <th colspan=2>&nbsp;</th>
  1010. </tr>
  1011. <tr>
  1012. <th align=right nowrap>|.$locale->text('Existing Datasets').qq|</th>
  1013. <td>
  1014. |;
  1015. for (@dbsources) { print "[&nbsp;$_&nbsp;] " }
  1016. print qq|
  1017. </td>
  1018. </tr>
  1019. <tr>
  1020. <th align=right nowrap>|.$locale->text('Create Dataset').qq|</th>
  1021. <td><input name=db></td>
  1022. </tr>
  1023. <tr>
  1024. <th align=right nowrap>|.$locale->text('Multibyte Encoding').qq|</th>
  1025. <td><select name=encoding>$selectencoding</select></td>
  1026. </tr>
  1027. <tr>
  1028. <th align=right nowrap>|.$locale->text('Create Chart of Accounts').qq|</th>
  1029. <td>
  1030. <table>
  1031. |;
  1032. while (@charts) {
  1033. print qq|
  1034. <tr>
  1035. |;
  1036. for (0 .. 2) { print "<td>$charts[$_]</td>\n" }
  1037. print qq|
  1038. </tr>
  1039. |;
  1040. splice @charts, 0, 3;
  1041. }
  1042. print qq|
  1043. </table>
  1044. </td>
  1045. </tr>
  1046. <tr>
  1047. <td colspan=2>
  1048. <hr size=3 noshade>
  1049. </td>
  1050. </tr>
  1051. </table>
  1052. |;
  1053. $form->hide_form(qw(dbdriver dbuser dbhost dbport dbpasswd dbdefault path sessionid));
  1054. print qq|
  1055. <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}">
  1056. <input type=hidden name=nextsub value=dbcreate>
  1057. <br>
  1058. <input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
  1059. </form>
  1060. </body>
  1061. </html>
  1062. |;
  1063. }
  1064. sub dbcreate {
  1065. $form->isblank("db", $locale->text('Dataset missing!'));
  1066. User->dbcreate(\%$form);
  1067. $form->{title} = "LedgerSMB ".$locale->text('Accounting')." ".$locale->text('Database Administration')." / ".$locale->text('Create Dataset');
  1068. $form->{login} = "root login";
  1069. $form->header;
  1070. print qq|
  1071. <body class=admin>
  1072. <center>
  1073. <h2>$form->{title}</h2>
  1074. <form method=post action=$form->{script}>|
  1075. .$locale->text('Dataset')." $form->{db} ".$locale->text('successfully created!')
  1076. .qq|
  1077. <input type=hidden name=path value="$form->{path}">
  1078. <input type=hidden name=sessionid value=$form->{sessionid}>
  1079. <input type=hidden name=nextsub value=list_users>
  1080. <p><input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
  1081. </form>
  1082. </body>
  1083. </html>
  1084. |;
  1085. }
  1086. sub delete_dataset {
  1087. if (@dbsources = User->dbsources_unused(\%$form, $memberfile)) {
  1088. foreach $item (sort @dbsources) {
  1089. $dbsources .= qq|<input name=db class=radio type=radio value=$item>&nbsp;$item |;
  1090. }
  1091. } else {
  1092. $form->error($locale->text('Nothing to delete!'));
  1093. }
  1094. $form->{title} = "LedgerSMB ".$locale->text('Accounting')." ".$locale->text('Database Administration')." / ".$locale->text('Delete Dataset');
  1095. $form->{login} = "root login";
  1096. $form->header;
  1097. print qq|
  1098. <body class=admin>
  1099. <h2>$form->{title}</h2>
  1100. <form method=post action=$form->{script}>
  1101. <table width=100%>
  1102. <tr class=listheading>
  1103. <th>|.$locale->text('The following Datasets are not in use and can be deleted').qq|</th>
  1104. </tr>
  1105. <tr>
  1106. <td>
  1107. $dbsources
  1108. </td>
  1109. </tr>
  1110. <tr><td>
  1111. <p>
  1112. <input type=hidden name=dbdriver value=$form->{dbdriver}>
  1113. <input type=hidden name=dbuser value=$form->{dbuser}>
  1114. <input type=hidden name=dbhost value=$form->{dbhost}>
  1115. <input type=hidden name=dbport value=$form->{dbport}>
  1116. <input type=hidden name=dbpasswd value=$form->{dbpasswd}>
  1117. <input type=hidden name=dbdefault value=$form->{dbdefault}>
  1118. <input name=callback type=hidden value="$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}">
  1119. <input type=hidden name=path value="$form->{path}">
  1120. <input type=hidden name=sessionid value=$form->{sessionid}>
  1121. <input type=hidden name=nextsub value=dbdelete>
  1122. <hr size=3 noshade>
  1123. <br>
  1124. <input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
  1125. </td></tr>
  1126. </table>
  1127. </form>
  1128. </body>
  1129. </html>
  1130. |;
  1131. }
  1132. sub dbdelete {
  1133. if (!$form->{db}) {
  1134. $form->error($locale->text('No Dataset selected!'));
  1135. }
  1136. User->dbdelete(\%$form);
  1137. $form->{title} = "LedgerSMB ".$locale->text('Accounting')." ".$locale->text('Database Administration')." / ".$locale->text('Delete Dataset');
  1138. $form->{login} = "root login";
  1139. $form->header;
  1140. print qq|
  1141. <body class=admin>
  1142. <center>
  1143. <h2>$form->{title}</h2>
  1144. <form method=post action=$form->{script}>
  1145. $form->{db} |.$locale->text('successfully deleted!')
  1146. .qq|
  1147. <input type=hidden name=path value="$form->{path}">
  1148. <input type=hidden name=sessionid value=$form->{sessionid}>
  1149. <input type=hidden name=nextsub value=list_users>
  1150. <p><input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
  1151. </form>
  1152. </body>
  1153. </html>
  1154. |;
  1155. }
  1156. sub unlock_system {
  1157. unlink "$userspath/nologin";
  1158. $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}";
  1159. $form->redirect($locale->text('Lockfile removed!'));
  1160. }
  1161. sub lock_system {
  1162. open(FH, ">$userspath/nologin") or $form->error($locale->text('Cannot create Lock!'));
  1163. close(FH);
  1164. $form->{callback} = "$form->{script}?action=list_users&path=$form->{path}&sessionid=$form->{sessionid}";
  1165. $form->redirect($locale->text('Lockfile created!'));
  1166. }