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