[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[2682] trunk
- Subject: SF.net SVN: ledger-smb:[2682] trunk
- From: ..hidden..
- Date: Mon, 15 Jun 2009 05:34:46 +0000
Revision: 2682
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2682&view=rev
Author: einhverfr
Date: 2009-06-15 05:34:46 +0000 (Mon, 15 Jun 2009)
Log Message:
-----------
Contribution on db setup
Modified Paths:
--------------
trunk/sql/modules/install.sql
Added Paths:
-----------
trunk/LedgerSMB/Initiate.pm
trunk/bin/initiate.pl
trunk/initiate1.pl
Added: trunk/LedgerSMB/Initiate.pm
===================================================================
--- trunk/LedgerSMB/Initiate.pm (rev 0)
+++ trunk/LedgerSMB/Initiate.pm 2009-06-15 05:34:46 UTC (rev 2682)
@@ -0,0 +1,645 @@
+
+
+# inline documentation
+
+package LedgerSMB::Initiate;
+use LedgerSMB::Sysconfig;
+use LedgerSMB::Auth::DB;
+use LedgerSMB::Locale;
+use Data::Dumper;
+use DBI;
+
+=item LedgerSMB::User->new($login);
+
+Create a LedgerSMB::User object. If the user $login exists, set the fields
+with values retrieved from the database.
+
+=cut
+
+
+sub new
+{
+
+ my $class=shift;
+
+ my $form = shift;
+
+ my $self={};
+
+ bless $self,$class;
+
+ $self->initialize($form);
+
+ return $self;
+
+}
+
+
+sub initialize
+{
+
+ my $self=shift;
+ my $form=shift;
+
+ # In future if required use this function to initialize the attributes of the class "Initiate"
+
+ $self->{initiateon}=$form->{initiateon};
+
+ if(scalar($self->{initiateon})==1)
+ {
+ $form->{company}=${LedgerSMB::Sysconfig::default_db};
+ $form->{port}=${LedgerSMB::Sysconfig::port};
+ $form->{host}=${LedgerSMB::Sysconfig::host};
+
+ }
+
+
+
+}
+
+
+
+
+sub getdbh
+{
+
+ my($self,$form)..hidden..;
+
+ my($database,$host,$port,$username,$password);
+
+ if($form->{initiateon}==1)
+ {
+ $database = $form->{company};
+ $host=$form->{host};
+ $port=$form->{port};
+ $username=$form->{username};
+ $password=$form->{password};
+ }
+ else
+ {
+
+ $database=$form->{database};
+ $host=$form->{dbhost};
+ $port=$form->{dbport};
+ $username=$form->{username};
+ $password=$form->{password};
+
+ }
+
+
+ my $dbconnect = "dbi:Pg:dbname=$database host=$host
+ port=$port user=$username password=$password"; # for easier debugging
+
+ my $dbh = DBI->connect($dbconnect) or return "no999";
+
+ return($dbh);
+
+}
+
+
+
+sub checksuperuser
+{
+
+ my($self,$form)..hidden..;
+
+ my $dbh=$form->{dbh};
+
+ my $sth=$dbh->prepare("select rolsuper from pg_roles where rolname = session_user;") || $form->dberror(
+ __FILE__ . ':' . __LINE__ . ': Finding Superuser Prepare failed : ' );;
+
+ $sth->execute() or $form->dberror(
+ __FILE__ . ':' . __LINE__ . ': Finding Superuser : execution failed' );
+
+ my $super=0;
+
+ $super=$sth->fetchrow_array;
+
+
+ return($super);
+
+
+}
+
+
+
+
+
+sub get_countrys
+{
+
+ my $dir=$ENV{SCRIPT_FILENAME};
+
+ $dir =~s/\/[\w\d\.]*$/\/sql\/coa\//; # 2nd way is store path of coa in sysconfig file
+
+
+ my @dir=LedgerSMB::Initiate->read_directory($form,$dir);
+
+ my @allcodes = grep !/\.+/,@dir;
+
+
+ my $returnvalue=qq|<option value="">null</option>|;
+
+ for my $code(@allcodes)
+ {
+ $returnvalue.=qq|<option value="$code">$code</option>|;
+ }
+
+
+ return $returnvalue;
+
+
+}
+
+
+
+
+
+sub validateform
+{
+
+ ($self,$form,$locale)..hidden..;
+
+
+# print STDERR "DF database => $form->{database} dbhost= $form->{dbhost} $form->{dbport} $form->{contribpath} ";
+
+
+
+ $form->{database}=~s/ //g;
+
+ $form->error( __FILE__ . ':' . __LINE__ . ': '
+ . $form->{locale}->text('Database Missing!') )
+ unless $form->{database};
+
+
+ $form->error( __FILE__ . ':' . __LINE__ . ': '
+ . $locale->text('Database Driver Missing!') )
+ unless $form->{driver};
+
+
+ $form->{dbhost}=~s/ //g;
+
+
+
+ $form->error( __FILE__ . ':' . __LINE__ . ': '
+ . $locale->text('Database Host Missing!') )
+
+ unless $form->{dbhost};
+
+ $form->{dbport}=~s/ //g;
+ $form->error( __FILE__ . ':' . __LINE__ . ': '
+ . $locale->text('Database Port Number Missing!') )
+ unless $form->{dbport};
+
+
+
+ $invalid=($form->{dbport}=~m/^\d{4}$/);
+
+
+ $form->error( __FILE__ . ':' . __LINE__ . ': '
+ . $locale->text('Invalid Database Port Number!') )
+ unless $invalid;
+
+
+
+ $form->{contribpath}=~s/ //g;
+
+ $form->error( __FILE__ . ':' . __LINE__ . ': '
+ . $locale->text('Contribution File Path Missing!') )
+ unless $form->{contribpath};
+
+
+ $form->{countrycode}=~s/ //g;
+
+ $form->error( __FILE__ . ':' . __LINE__ . ': '
+ . $locale->text('Country Code Missing!') )
+ unless $form->{countrycode};
+
+
+
+ $form->error( __FILE__ . ':' . __LINE__ . ': '
+ . $locale->text('Chart Account Missing!') )
+ unless $form->{chartaccount};
+
+
+
+ # check for duplicates
+
+ if ( !$form->{edit} ) {
+
+ $form->{initiateon}=0;
+
+ $tempdbh = LedgerSMB::Initiate->getdbh($form);
+
+ $form->{initiateon}=1;
+
+ $form->{tempdbh}=$tempdbh;
+
+ if ( lc($tempdbh) ne "no999" ) {
+ $form->error( __FILE__ . ':' . __LINE__ . ': '
+ . $locale->text( '[_1] is already a database!', $form->{database} )
+ );
+ }
+ }
+
+
+
+
+}
+
+
+sub save_database
+{
+
+ my($self,$form)..hidden..;
+
+ # check all files exist and valids (contrib files , pgdabase.sql and modules and chart accounts etc)
+
+ my @contrib=LedgerSMB::Initiate->check_contrib_valid_exist($form); #check contrib files
+
+ my @postsql=LedgerSMB::Initiate->check_Pg_database_valid_exist($form); #check sql/Pg-databse.sql files
+
+ my @sqlmodules=LedgerSMB::Initiate->check_sql_modules_valid_exist($form); #check sql/modules/readme file content exist or not
+
+ my @chartgififiles=LedgerSMB::Initiate->merge_chart_gifi_valid_exist($form); # check sql/coa/charts and sql/coa/gifi files
+
+ my @totalexecutable_files;
+
+ push(@totalexecutable_files,@contrib);
+ push(@totalexecutable_files,@postsql);
+ push(@totalexecutable_files,@sqlmodules);
+ push(@totalexecutable_files,@chartgififiles);
+
+ # Now all the files are found now start execution process(Stages)
+
+
+ #Stage 1 - Create the databse $form->{database}
+
+ LedgerSMB::Initiate->create_database($form,$form->{dbh},$form->{database},$form->{username});
+
+ #Stage 2 - CReate the language plpgsql
+
+ $form->{newdbh}=LedgerSMB::Initiate->handle_create_language($form);
+
+ #stage 3 - Execute series of files which are located in array @totalexecutable_files in the database $form->{newdbh}
+
+ LedgerSMB::Initiate->run_all_sql_scripts($form,..hidden..);
+
+ #Stage - Wind up completed the task
+
+ $form->error( __FILE__ . ':' . __LINE__ . ': '
+ . $locale->text("under construction database/language created successfully"));
+
+ exit;
+
+
+
+}
+
+
+sub run_all_sql_scripts
+{
+
+ my ($self,$form,$totalexcfiles)..hidden..;
+
+ foreach $dbfile(@$totalexcfiles)
+ {
+
+ LedgerSMB::Initiate->run_db_file($form,$dbfile);
+
+ }
+
+
+}
+
+
+sub run_db_file
+{
+
+ my($self,$form,$dbfile)..hidden..;
+
+ my $newdbh=$form->{newdbh};
+
+ system("");
+}
+
+
+
+
+
+sub create_database
+{
+
+
+ my ($self,$form,$dbh,$database,$owner)..hidden..;
+
+ my $locale=$form->{locale};
+
+ $dbh->do("create database $database with owner $owner") || $form->error( __FILE__ . ':' . __LINE__ . ': '
+ . $locale->text( 'database [_1] creation failed',$database));
+
+
+
+}
+
+sub handle_create_language
+{
+
+ my($self,$form)..hidden..;
+
+ $form->{initiateon}=0;
+
+ my $newdbh=LedgerSMB::Initiate->getdbh($form);
+
+ $form->{initiateon}=1;
+
+
+ if(lc($newdbh) eq 'no999')
+ {
+
+ $form->{dbh}->do("drop database $form->{database}");
+
+ $form->error( __FILE__ . ':' . __LINE__ . ': '
+ . $locale->text( 'connection failed to database [_1] might be port/localhost problem!', $form->{database} )
+ );
+
+ }
+
+
+
+ if(!LedgerSMB::Initiate->create_language($newdbh))
+ {
+ $form->{dbh}->do("drop database $form->{database}");
+
+ $form->error( __FILE__ . ':' . __LINE__ . ': '
+ . $locale->text( 'connection failed to database [_1] might be port/localhost problem!', $form->{database} )
+ );
+
+ }
+
+
+ return($newdbh);
+
+}
+
+
+sub create_language
+{
+
+ my ($self,$newdbh)..hidden..;
+ $newdbh->do("create language plpgsql") || return 0;
+ return 1;
+
+}
+
+
+
+
+
+sub check_contrib_valid_exist
+{
+
+ my ($self,$form)..hidden..;
+
+ $locale=$form->{locale};
+
+ #Check contrib files exist at particular directory else through an error
+
+ $dir = $form->{contribpath};
+
+ $locale=$form->{locale};
+
+ my @dir=LedgerSMB::Initiate->read_directory($form,$dir);readdir(IMD);
+
+ @dest=("pg_trgm.sql","tablefunc.sql","tsearch2.sql"); #just expand array if contrib files increases
+
+
+ if(!LedgerSMB::Initiate->all_files_found(..hidden..,..hidden..))
+ {
+ $form->error( __FILE__ . ':' . __LINE__ . ': '
+ . $locale->text( 'Required contrib files not exist under [_1]',$dir));
+ exit;
+ }
+
+ for(my $i=0;$i<=$#dest;$i++)
+ {
+
+ $dest[$i]=$dir.$dest[$i];
+
+ }
+
+ return(@dest);
+
+
+}
+
+
+
+sub check_Pg_database_valid_exist
+{
+
+
+ #check sql/Pg-databas
+ my ($self,$form)..hidden..;
+
+ $locale=$form->{locale};
+
+ my $dir=$ENV{SCRIPT_FILENAME};
+
+ my @dest=("Pg-database.sql"); # extend the array if files increase
+
+ $dir =~s/\/[\w\d\.]*$/\/sql\//;
+
+ my @dir=LedgerSMB::Initiate->read_directory($form,$dir);
+
+ if(!LedgerSMB::Initiate->all_files_found(..hidden..,..hidden..))
+ {
+ $form->error( __FILE__ . ':' . __LINE__ . ': '
+ . $locale->text( 'Required Pg-database files Missing under [_1]',$dir));
+ exit;
+ }
+
+
+ for(my $i=0;$i<=$#dest;$i++)
+ {
+
+ $dest[$i]=$dir.$dest[$i];
+
+ }
+
+ return(@dest);
+
+}
+
+
+sub check_sql_modules_valid_exist
+{
+
+ my ($self,$form)..hidden..;
+
+ $locale=$form->{locale};
+
+ my $dir=$ENV{SCRIPT_FILENAME};
+
+ my $location="/sql/modules/";
+
+ $dir =~s/\/[\w\d\.]*$/$location/;
+
+ my @dir=LedgerSMB::Initiate->read_directory($form,$dir);
+
+=pod
+ now dilemma with search files($dest)
+
+ 1.List from README file
+ 2.Read all sql files from sql/modules/
+
+ Now implementing 2 one .Chris can you suggest me whether to go with 1 or 2
+
+=cut
+ my @dest = grep /\.sql$/,@dir;
+
+
+ for(my $i=0;$i<=$#dest;$i++)
+ {
+
+ $dest[$i]=$dir.$dest[$i];
+
+ }
+
+ return(@dest);
+
+
+}
+
+
+
+sub merge_chart_gifi_valid_exist
+{
+
+ my ($self,$form)..hidden..;
+
+ $locale=$form->{locale};
+
+ my $dir=$ENV{SCRIPT_FILENAME};
+
+ my $location="/sql/coa/$form->{countrycode}/";
+
+ $dir =~s/\/[\w\d\.]*$/$location/;
+
+ my $chartdir=$dir."chart/";
+
+ my $gifidir=$dir."gifi/";
+
+
+ my @chartdir=LedgerSMB::Initiate->read_directory($form,$chartdir);
+
+ @chartdir=grep /\.sql$/,@chartdir;
+
+
+
+ my @gifidir;
+
+ if($form->{gifiaccount}==2)
+ {
+ @gifidir=LedgerSMB::Initiate->read_directory($form,$gifidir);
+ @gifidir=grep /\.sql$/,@gifidir;
+
+ }
+
+
+ my @dest;
+
+ my $i;
+
+ for($i=0;$i<=$#chartdir;$i++)
+ {
+
+ $dest[$i]=$chartdir.$chartdir[$i];
+
+ }
+
+ for(my $j=0;$j<=$#gifidir;$j++,$i++)
+ {
+
+ $dest[$i]=$gifidir.$gifidir[$j];
+
+ }
+
+
+ return(@dest);
+
+
+}
+
+
+
+
+
+
+
+
+
+sub read_directory
+{
+
+ my($self,$form,$dir)..hidden..;
+
+ $locale=$form->{locale};
+
+ opendir(DIR,$dir) || $form->error( __FILE__ . ':' . __LINE__ . ': '
+ . $locale->text( '[_1] directory Missing!', $dir));
+
+ my @dircontent=readdir(DIR);
+
+ closedir(DIR);
+
+ return(@dircontent);
+
+}
+
+
+sub get_fullpath
+{
+
+ my($self,$dir,$files)..hidden..;
+
+ for(my $i=0;$i<..hidden..;$i++)
+ {
+
+ $files->[$i]=$dir.$files->[$i];
+
+ }
+
+
+ return(@$files);
+
+
+}
+
+
+
+
+
+sub all_files_found
+{
+
+
+ my ($self,$search,$source)..hidden..;
+
+ for my $file(@$search)
+ {
+ $allfiles = grep /^$file$/,@$source;
+
+ return 0 unless($allfiles);
+
+ }
+
+ return 1;
+
+
+}
+
+
+1;
+
+
Added: trunk/bin/initiate.pl
===================================================================
--- trunk/bin/initiate.pl (rev 0)
+++ trunk/bin/initiate.pl 2009-06-15 05:34:46 UTC (rev 2682)
@@ -0,0 +1,351 @@
+
+use LedgerSMB::Form;
+use LedgerSMB::Locale;
+use LedgerSMB::User;
+use LedgerSMB::Initiate;
+use LedgerSMB::Auth::DB;
+
+#use LedgerSMB::Session;
+
+$root="";
+
+$form = new Form;
+
+$locale = LedgerSMB::Locale->get_handle( ${LedgerSMB::Sysconfig::language} ) or $form->error( __FILE__ . ':' . __LINE__ . ': ' . "Locale not loaded: $!\n" );
+
+$locale->encoding('UTF-8');
+
+$form->{locale}=$locale;
+
+$form->{charset} = 'UTF-8';
+
+eval { require DBI; };
+
+$form->error(
+ __FILE__ . ':' . __LINE__ . ': ' . $locale->text('DBI not installed!') )
+ if ($@);
+
+$form->{stylesheet} = "ledgersmb.css";
+$form->{favicon} = "favicon.ico";
+$form->{timeout} = 600;
+
+require "bin/pw.pl";
+
+# customization
+if ( -f "bin/custom/$form->{script}" ) {
+ eval { require "bin/custom/$form->{script}"; };
+ $form->error( __FILE__ . ':' . __LINE__ . ': ' . $@ ) if ($@);
+}
+
+# because iniate.pl called only at admin for initializtion everything at default_db
+
+if ( $form->{action} ) {
+
+ &check_password unless $form->{action} eq 'logout';
+
+ &{ $form->{action} };
+
+}
+else {
+
+ # if there are no drivers bail out
+ $form->error( __FILE__ . ':' . __LINE__ . ':' . $locale->text('No Database Drivers available!') )
+ unless ( LedgerSMB::User->dbdrivers );
+
+ &check_password;
+
+ $form->{'action'}='login';
+
+ &{ $form->{action} };
+
+
+
+
+}
+
+1;
+
+# end
+
+sub check_password {
+
+
+ my $auth_temp=LedgerSMB::Auth::DB->get_credentials();
+
+ LedgerSMB::Auth::DB->credential_prompt unless($auth_temp);
+
+ $form->{'login'}=$auth_temp->{'login'};
+
+ $form->{'username'}=$auth_temp->{'login'};
+
+ $form->{'password'}=$auth_temp->{'password'};
+
+ $form->{'initiateon'}=1;
+
+ $root=LedgerSMB::Initiate->new($form);
+
+ $form->{dbh}=$root->getdbh($form); # get the connection if user exist as superuser
+
+ if ( lc($form->{dbh}) eq "no999" or !$root->checksuperuser($form)) {
+ LedgerSMB::Auth::DB->credential_prompt;
+ exit;
+ }
+
+
+}
+
+
+sub login {
+
+ &prepare_initiate($form);
+
+}
+
+
+sub prepare_initiate {
+
+
+ # use the dynamic database handle (self = form )
+
+ my ($self)..hidden..;
+
+ #get the username and password from cookie for time being it would holds
+
+ my $dbh = $self->{dbh};
+
+
+ $self->{title} =
+ "LedgerSMB Initial Database Set Up Vizard";
+
+ $self->header;
+
+
+ print qq|
+ <body class="initiate">
+ <form method="post" action="$self->{script}">
+ <table width="100%">
+ <tr class="listheading">
+ <th>$self->{title}</th>
+ </tr>
+ <tr size="5"></tr>
+ </tr>|;
+
+
+ print qq|
+ <tr>
+ <td><hr size="3" noshade /></td>
+ </tr>
+ </table>
+ <input type="hidden" name="path" value="$self->{path}" />
+ <br />
+ <button type="submit" class="submit" name="action" value="initiate_database">|
+ . $locale->text('Initiate Database')
+ . qq|</button>
+ <button type="submit" class="submit" name="action" value="view_database">|
+ . $locale->text('View Initialized Databases')
+ . qq|</button>
+
+ <button type="submit" class="submit" name="action" value="logout">|
+ . $locale->text('Logout')
+ . qq|</button>
+ </form>
+
+ | . qq|
+
+ </body>
+ </html>|;
+
+
+}
+
+
+
+
+
+sub logout {
+
+ #$form->redirect( $locale->text('successfully logged Out') );
+
+ LedgerSMB::Auth::DB->credential_prompt;
+
+}
+
+sub initiate_database {
+
+ $form->{title} =
+ "LedgerSMB "
+ . $locale->text('Administration') . " / "
+ . $locale->text('Initial database Setup');
+
+ if ( -f "css/ledgersmb.css" ) {
+ $myconfig->{stylesheet} = "ledgersmb.css";
+ }
+
+ $myconfig->{vclimit} = 1000;
+ $myconfig->{menuwidth} = 155;
+ $myconfig->{timeout} = 3600;
+
+ &form_header;
+ &form_footer;
+}
+
+
+sub view_database {
+
+ $form->{title} =
+ "LedgerSMB "
+ . $locale->text('Administration') . " / "
+ . $locale->text('Initial database Setup');
+
+
+ if ( -f "css/ledgersmb.css" ) {
+ $myconfig->{stylesheet} = "ledgersmb.css";
+ }
+
+ $myconfig->{vclimit} = 1000;
+ $myconfig->{menuwidth} = 155;
+ $myconfig->{timeout} = 3600;
+ $form->header;
+ $form->redirect( $locale->text('Under Construction!') );
+
+}
+
+
+
+sub form_footer {
+
+ if ( $form->{edit} ) {
+ $delete =
+ qq|<button type="submit" class="submit" name="action" value="delete">|
+ . $locale->text('Delete')
+ . qq|</button>
+ <input type="hidden" name="edit" value="1" />|;
+ }
+
+ print qq|
+ <input name="callback" type="hidden" value="$form->{script}?action=initiate_database&path=$form->{path}" />
+ <input type="hidden" name="path" value="$form->{path}" />
+ <button type="submit" class="submit" name="action" value="save">|
+ . $locale->text('Save')
+ . qq|</button>
+ <button type="reset" class="reset" name="action" value="reset">|
+ . $locale->text('Reset').
+ qq|</button>
+ $delete
+ </form>
+ </body>
+ </html>
+ |;
+}
+
+
+
+sub form_header
+{
+
+$form->header;
+
+
+print qq|
+ <body class="admin">
+ <form method="post" action="initiate.pl">
+ <table width="100%">
+ <tr class="listheading"><th colspan="2">$form->{title}</th></tr>
+ <tr size="5"></tr>
+ <tr valign="top">
+ <td>
+ <table>
+ <tr>
+ <th align="right">| . $locale->text('Database') . qq|</th>
+ <td><input name="database" value="$myconfig->{database}" /></td>
+ </tr>
+ <tr>
+ <th align="right">| . $locale->text('Driver - Pg') . qq|</th>
+ <td><input name="driver" class="checkbox" type="checkbox" value="1">$myconfig->{driver}</td>
+ </tr>
+ <tr>
+ <th align="right">| . $locale->text('Host') . qq|</th>
+ <td><input name="dbhost" value="$myconfig->{host}" /></td>
+ </tr>
+ <tr>
+ <th align="right">| . $locale->text('Port') . qq|</th>
+ <td><input name="dbport" size="5" value="$myconfig->{port}" /></td>
+ </tr>
+
+ </table>
+ </td>
+
+ </tr>
+ <tr></tr>
+ <tr class="listheading">
+ <th colspan="2">| . $locale->text('Contrib Files') . qq|</th>
+ </tr>
+ <tr size="5"></tr>
+ <tr valign="top">
+ <td>
+ <table>
+ <tr>
+ <th align="right">| . $locale->text('Path of Contrib Files') . qq|</th>
+ <td><input name="contribpath" value="$myconfig->{contribpath}" /></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+
+ <tr></tr>
+ <tr class="listheading">
+ <th colspan="2">| . $locale->text('Chart Accounts') . qq|</th>
+ </tr>
+ <tr size="5"></tr>
+ <tr valign="top">
+ <td>
+ <table>
+ <tr>
+ <th align="right">| . $locale->text('Country Code');
+ my $country=LedgerSMB::Initiate->get_countrys();
+ # just testing manually $myconfig->{countrycode}="uk";
+ $country=~s/<option value="$myconfig->{countrycode}">/<option value="$myconfig->{countrycode}" selected="selected">/;
+print qq| </th>
+ <td><select name="countrycode">$country</select></td>
+ </tr>
+ <tr>
+ <th align="right">| . $locale->text('Charts Account') . qq|</th>
+ <td><input name="chartaccount" class="checkbox" type="checkbox" value="1">$myconfig->{chartaccount}</td>
+ </tr>
+
+ <tr>
+ <th align="right">| . $locale->text('Gifi Account') . qq|</th>
+ <td><input name="gifiaccount" class="checkbox" type="checkbox" value="2">$myconfig->{gifiaccount}</td>
+ </tr>
+
+
+ </table>
+ </td>
+ </tr>
+
+
+
+ </table>|;
+
+
+
+
+}
+
+
+
+
+sub save {
+
+ $form->{callback} = "initiate.pl?action=login";
+
+ LedgerSMB::Initiate->validateform($form,$locale);
+
+ LedgerSMB::Initiate->save_database($form);
+
+ # create user template directory and copy master files
+
+ #$form->redirect( $locale->text('User saved!') );
+}
+
Added: trunk/initiate1.pl
===================================================================
--- trunk/initiate1.pl (rev 0)
+++ trunk/initiate1.pl 2009-06-15 05:34:46 UTC (rev 2682)
@@ -0,0 +1,115 @@
+#!/usr/bin/perl
+#
+######################################################################
+# LedgerSMB Accounting and ERP
+# http://www.ledgersmb.org/
+#
+# Copyright (C) 2006
+# This work contains copyrighted information from a number of sources all used
+# with permission.
+#
+# This file contains source code included with or based on SQL-Ledger which
+# is Copyright Dieter Simader and DWS Systems Inc. 2000-2005 and licensed
+# under the GNU General Public License version 2 or, at your option, any later
+# version. For a full list including contact information of contributors,
+# maintainers, and copyright holders, see the CONTRIBUTORS file.
+#
+# Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
+# Copyright (C) 2001
+#
+# Author: Dieter Simader
+# Email: ..hidden..
+# Web: http://www.sql-ledger.org
+#
+# Contributors:
+#
+#
+# Web: http://www.ledgersmb.org/
+#
+# Contributors:
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#######################################################################
+#
+# this script sets up the terminal and runs the scripts
+# in bin/$terminal directory
+# admin.pl is linked to this script
+#
+#######################################################################
+
+use LedgerSMB::Sysconfig;
+require "common.pl";
+
+$| = 1;
+
+if ( $ENV{CONTENT_LENGTH} > $LedgerSMB::Sysconfig::max_post_size ) {
+ print "Status: 413\n Request entity too large\n\n";
+ die "Error: Request entity too large\n";
+}
+
+if ( $ENV{CONTENT_LENGTH} > 0 ) {
+ read( STDIN, $_, $ENV{CONTENT_LENGTH} );
+}
+
+if ( $ENV{QUERY_STRING} ) {
+ $_ = $ENV{QUERY_STRING};
+}
+
+if ( $ARGV[0] ) {
+ $_ = $ARGV[0];
+}
+
+%form = split /[&=]/;
+
+# fix for apache 2.0 bug
+map { $form{$_} =~ s/\\$// } keys %form;
+
+# name of this script
+$0 =~ tr/\\/\//;
+$pos = rindex $0, '/';
+$script = substr( $0, $pos + 1 );
+
+#this needs to be a db based function
+#if (-e "${LedgerSMB::Sysconfig::userspath}/nologin" && $script ne 'admin.pl') {
+# print "Content-Type: text/html\n\n<html><body><strong>";
+# print "\nLogin disabled!\n";
+# print "\n</strong></body></html>";
+# exit;
+#}
+
+if ( $form{path} ) {
+
+ if ( $form{path} ne 'bin/lynx' ) { $form{path} = 'bin/mozilla'; }
+
+ $ARGV[0] = "$_&script=$script";
+ require "bin/$script";
+
+}
+else {
+
+ $form{terminal} = "lynx";
+
+ if ( $ENV{HTTP_USER_AGENT} !~ /lynx/i ) {
+ $form{terminal} = "mozilla";
+ }
+
+ $ARGV[0] = "path=bin/$form{terminal}&script=$script";
+ map { $ARGV[0] .= "&${_}=$form{$_}" } keys %form;
+
+ require "bin/$script";
+
+}
+
+# end of main
+
Modified: trunk/sql/modules/install.sql
===================================================================
--- trunk/sql/modules/install.sql 2009-06-13 18:13:11 UTC (rev 2681)
+++ trunk/sql/modules/install.sql 2009-06-15 05:34:46 UTC (rev 2682)
@@ -20,4 +20,4 @@
\i sql/modules/admin.sql -- Adds the new user functionality.
-COMMIT;
\ No newline at end of file
+COMMIT;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.