X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fadmin.pl;h=5f3e0b19d8f2e95406aa48c8c58a48ba1e65a30a;hb=16455a4f7a2e871d645485ffb5904d197b907217;hp=a4c8d0c2181c382514beca5dcaef22e3619c9383;hpb=daac86985672692c14b72aab942144b097d8c8fd;p=kivitendo-erp.git diff --git a/bin/mozilla/admin.pl b/bin/mozilla/admin.pl old mode 100644 new mode 100755 index a4c8d0c21..5f3e0b19d --- a/bin/mozilla/admin.pl +++ b/bin/mozilla/admin.pl @@ -32,1675 +32,498 @@ # #====================================================================== -$menufile = "menu.ini"; - +use DBI; +use Encode; +use English qw(-no_match_vars); +use Fcntl; +use File::Copy; +use File::Find; +use File::Spec; +use Cwd; +use IO::Dir; +use IO::File; +use POSIX qw(strftime); +use Sys::Hostname; + +use SL::Auth; +use SL::Auth::PasswordPolicy; +use SL::DB::AuthClient; +use SL::DB::AuthUser; use SL::Form; +use SL::Iconv; +use SL::Mailer; use SL::User; +use SL::Common; +use SL::Inifile; +use SL::DBUpgrade2; +use SL::DBUtils; +use SL::Template; + +require "bin/mozilla/common.pl"; + +use strict; + +# parserhappy(R): + +# $locale->text('periodic') +# $locale->text('income') +# $locale->text('perpetual') +# $locale->text('balance') + +our $cgi; +our $form; +our $locale; +our $auth; + +sub run { + $::lxdebug->enter_sub; + my $session_result = shift; + + $form = $::form; + $locale = $::locale; + $auth = $::auth; + + $::request->{layout} = SL::Layout::Dispatcher->new(style => 'admin'); + $::request->{layout}->use_stylesheet("lx-office-erp.css"); + $form->{favicon} = "favicon.ico"; + + if ($form->{action}) { + if ($auth->authenticate_root($form->{'{AUTH}admin_password'}) != $auth->OK()) { + $auth->punish_wrong_login; + $form->{error} = $locale->text('Incorrect password!'); + $auth->delete_session_value('admin_password'); + adminlogin(); + } else { + if ($auth->session_tables_present()) { + delete $::form->{'{AUTH}admin_password'}; + } -$form = new Form; -$form->{"root"} = "root login"; - -$locale = new Locale $language, "admin"; - -eval { require DBI; }; -$form->error($locale->text('DBI not installed!')) if ($@); - -# customization -if (-f "$form->{path}/custom_$form->{script}") { - eval { require "$form->{path}/custom_$form->{script}"; }; - $form->error($@) if ($@); -} - -$form->{stylesheet} = "lx-office-erp.css"; -$form->{favicon} = "favicon.ico"; - -if ($form->{action}) { - - - $subroutine = $locale->findsub($form->{action}); - - if ($subroutine eq 'login') { - if ($form->{rpw}) { - $form->{rpw} = crypt $form->{rpw}, "ro"; + call_sub($locale->findsub($form->{action})); } + } else { + adminlogin(); } - - &check_password; - - &$subroutine; - -} else { - - # if there are no drivers bail out - $form->error($locale->text('No Database Drivers available!')) - unless (User->dbdrivers); - - # create memberfile - if (!-f $memberfile) { - open(FH, ">$memberfile") or $form->error("$memberfile : $!"); - print FH qq|# SQL-Ledger Accounting members - -[root login] -password= - -|; - close FH; - } - - &adminlogin; - + $::lxdebug->leave_sub; } -1; - -# end - sub adminlogin { - - $form->{title} = - qq|Lx-Office ERP $form->{version} | . $locale->text('Administration'); - - $form->header; - - print qq| - - - -
- - -

| - . $locale->text('Version') - . qq| $form->{version}

| - . $locale->text('Administration') - . qq|

- -
- - - - - - - - -{path}> -
| . $locale->text('Password') . qq|
- - -
- -Lx-Office | - . $locale->text('website') . qq| - -
- - - -|; - + print $::request->cgi->redirect('controller.pl?action=Admin/login'); } -sub login { - - &list_users; - +sub pg_database_administration { + my $form = $main::form; + dbselect_source(); } -sub add_user { - - $form->{title} = - "Lx-Office ERP " - . $locale->text('Administration') . " / " - . $locale->text('Add User'); - - $form->{Oracle_sid} = $sid; - $form->{Oracle_dbport} = '1521'; - $form->{Oracle_dbhost} = `hostname`; +sub dbselect_source { + my $form = $main::form; + my $locale = $main::locale; - if (-f "css/lx-office-erp.css") { - $myconfig->{stylesheet} = "lx-office-erp.css"; - } - $myconfig->{vclimit} = 200; + $form->{dbport} = $::auth->{DB_config}->{port} || 5432; + $form->{dbuser} = $::auth->{DB_config}->{user} || 'lxoffice'; + $form->{dbdefault} = 'template1'; + $form->{dbhost} = $::auth->{DB_config}->{host} || 'localhost'; - $myconfig->{"countrycode"} = "de"; - $myconfig->{"numberformat"} = "1000,00"; - $myconfig->{"dateformat"} = "dd.mm.yy"; + $form->{title} = "kivitendo / " . $locale->text('Database Administration'); - &form_header; - &form_footer; + # Intentionnaly disabled unless fixed to work with the authentication DB. + $form->{ALLOW_DBBACKUP} = 0; # "$pg_dump_exe" ne "DISABLED"; + $form->header(); + print $form->parse_html_template("admin/dbadmin"); } -sub edit { - - $form->{title} = - "Lx-Office ERP " - . $locale->text('Administration') . " / " - . $locale->text('Edit User'); - $form->{edit} = 1; - - &form_header; - &form_footer; - +sub continue { + call_sub($main::form->{"nextsub"}); } -sub form_footer { - - if ($form->{edit}) { - $delete = - qq| -|; - } - - print qq| - - -{path}> -{rpw}> - - -$delete +sub update_dataset { + my $form = $main::form; + my $locale = $main::locale; - + $form->{title} = "kivitendo " . $locale->text('Database Administration') . " / " . $locale->text('Update Dataset'); - - -|; + my @need_updates = User->dbneedsupdate($form); + $form->{NEED_UPDATES} = \@need_updates; + $form->{ALL_UPDATED} = !scalar @need_updates; + $form->header(); + print $form->parse_html_template("admin/update_dataset"); } -sub list_users { - - $form->error($locale->text('File locked!')) if (-f "${memberfile}.LCK"); +sub dbupdate { + my $form = $main::form; + my $locale = $main::locale; - open(FH, "$memberfile") or $form->error("$memberfile : $!"); + $::request->{layout}->use_stylesheet("lx-office-erp.css"); + $form->{title} = $locale->text("Dataset upgrade"); + $form->header(); - $nologin = qq| -|; + my $rowcount = $form->{rowcount} * 1; + my @update_rows = grep { $form->{"update_$_"} } (1 .. $rowcount); + $form->{NOTHING_TO_DO} = !scalar @update_rows; + my $saved_form = save_form(); - if (-e "$userspath/nologin") { - $nologin = qq| -|; - } + $| = 1; - while () { - chop; + print $form->parse_html_template("admin/dbupgrade_all_header"); - if (/^\[.*\]/) { - $login = $_; - $login =~ s/(\[|\])//g; - } + foreach my $i (@update_rows) { + restore_form($saved_form); - if (/^(name=|company=|templates=|dbuser=|dbdriver=|dbname=|dbhost=)/) { - chop($var = $&); - ($null, $member{$login}{$var}) = split /=/, $_, 2; - } - } + %::myconfig = (); + map { $form->{$_} = $::myconfig{$_} = $form->{"${_}_${i}"} } qw(dbname dbhost dbport dbuser dbpasswd); - close(FH); + print $form->parse_html_template("admin/dbupgrade_header"); - # type=submit $locale->text('Pg Database Administration') - # type=submit $locale->text('Oracle Database Administration') + User->dbupdate($form); + User->dbupdate2(form => $form, updater => SL::DBUpgrade2->new(form => $form)->parse_dbupdate_controls, database => $form->{dbname}); - foreach $item (User->dbdrivers) { - $dbdrivers .= - qq||; + print $form->parse_html_template("admin/dbupgrade_footer"); } - $column_header{login} = qq|| . $locale->text('Login') . qq||; - $column_header{name} = qq|| . $locale->text('Name') . qq||; - $column_header{company} = qq|| . $locale->text('Company') . qq||; - $column_header{dbdriver} = qq|| . $locale->text('Driver') . qq||; - $column_header{dbhost} = qq|| . $locale->text('Host') . qq||; - $column_header{dataset} = qq|| . $locale->text('Dataset') . qq||; - $column_header{templates} = - qq|| . $locale->text('Templates') . qq||; - - @column_index = qw(login name company dbdriver dbhost dataset templates); - - $form->{title} = "Lx-Office ERP " . $locale->text('Administration'); - - $form->header; - - print qq| - - -
{script}> - - - - - - - - - - - - - -
$form->{title}
- - |; - - map { print "$column_header{$_}\n" } @column_index; - - print qq| - -|; - - foreach $key (sort keys %member) { - $href = - "$script?action=edit&login=$key&path=$form->{path}&rpw=$form->{rpw}"; - $href =~ s/ /%20/g; - - $member{$key}{templates} =~ s/^$templates\///; - $member{$key}{dbhost} = $locale->text('localhost') - unless $member{$key}{dbhost}; - $member{$key}{dbname} = $member{$key}{dbuser} - if ($member{$key}{dbdriver} eq 'Oracle'); - - $column_data{login} = qq||; - $column_data{name} = qq||; - $column_data{company} = qq||; - $column_data{dbdriver} = qq||; - $column_data{dbhost} = qq||; - $column_data{dataset} = qq||; - $column_data{templates} = qq||; - - $i++; - $i %= 2; - print qq| - |; - - map { print "$column_data{$_}\n" } @column_index; - - print qq| - |; - } - - print qq| -
$key$member{$key}{name}$member{$key}{company}$member{$key}{dbdriver}$member{$key}{dbhost}$member{$key}{dbname}$member{$key}{templates}
-

- -{path}> -{rpw}> - -
- - -$dbdrivers -$nologin - -
- -| . $locale->text('Click on login name to edit!') . qq| -
-| - . $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| - -

- -

- - - - - - - - -
Lx-Office ERP | . $locale->text('Login') . qq|
- - - - - - - - - - - -{path}> -
| . $locale->text('Name') . qq| 
| . $locale->text('Password') . qq|
-
- -
- -
- - - -|; - + print $form->parse_html_template("admin/dbupgrade_all_done"); } -sub form_header { - - # if there is a login, get user - if ($form->{login}) { - - # get user - $myconfig = new User "$memberfile", "$form->{login}"; - - $myconfig->{signature} =~ s/\\n/\r\n/g; - $myconfig->{address} =~ s/\\n/\r\n/g; - - # strip basedir from templates directory - $myconfig->{templates} =~ s/^$templates\///; - - # $myconfig->{dbpasswd} = unpack 'u', $myconfig->{dbpasswd}; - } - - foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) { - $dateformat .= - ($item eq $myconfig->{dateformat}) - ? "