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