From f236998b5334ea6b21c77a2ccbe12ccd869ff3e3 Mon Sep 17 00:00:00 2001 From: Kilian Saffran Date: Mon, 11 Mar 2019 14:39:47 +0100 Subject: [PATCH] First compile Version --- .gitignore | 4 + Module/FileSystem.pm | 305 ---------------- Module/GISFiles.pm | 89 ++++- Module/SQLite.pm | 255 ------------- Module/Service.pm | 423 ---------------------- build/build_gisservicehelper.bat | 28 ++ dev/createtest.pl | 36 ++ dev/folder1.txt | 600 +++++++++++++++++++++++++++++++ gisservicehelper.json | 2 +- gisservicehelper.pl | 18 +- htdocs/js/site.js | 77 +++- package-lock.json | 5 + package.json | 3 + 13 files changed, 850 insertions(+), 995 deletions(-) delete mode 100644 Module/FileSystem.pm delete mode 100644 Module/SQLite.pm create mode 100644 build/build_gisservicehelper.bat create mode 100644 dev/createtest.pl create mode 100644 dev/folder1.txt diff --git a/.gitignore b/.gitignore index 2709666..9c72610 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ node_modules/* +dev/testfiles/* +test/* +dist/* .vscode/* +test/* diff --git a/Module/FileSystem.pm b/Module/FileSystem.pm deleted file mode 100644 index c35e9da..0000000 --- a/Module/FileSystem.pm +++ /dev/null @@ -1,305 +0,0 @@ -package Module::FileSystem; - -use strict; -use warnings; -use parent qw(Plack::Component); -use Plack::Request; -use Data::Dumper; -use File::Find::Rule; -use File::Basename; -use JSON::PP; -use File::Path qw(make_path remove_tree); -use File::Copy; -use MIME::Types; -if ($^O eq "MSWin32"){ - eval('use Win32::File;'); -} - -sub call { - my($self, $env) = @_; - if (($env->{REMOTE_ADDR} =~ "^127\.0\.") && - ($env->{REMOTE_ADDR} =~ "^10\.") && - ($env->{REMOTE_ADDR} =~ "^172\.16\.") && - ($env->{REMOTE_ADDR} =~ "^192\.168\.")) { - return [ - 404, - [ 'Content-Type' => "text/html",'Cache-Control' => 'no-store, no-cache, must-revalidate' ], - [ "Sorry no remote access allowed!" ] - ]; - } - if ($env->{PATH_INFO} =~ /^\/search/){ - return $self->search($env); - } elsif ($env->{PATH_INFO} =~ /^\/directory/) { - return $self->directory($env); - } elsif ($env->{PATH_INFO} =~ /^\/file/) { - return $self->file($env); - } elsif ($env->{PATH_INFO} =~ /^\/userenv/){ - return $self->userenv($env); - } - return [ - 404, - [ 'Content-Type' => "text/html",'Cache-Control' => 'no-store, no-cache, must-revalidate' ], - [ "Unknown System Request!" ] - ]; -} - -sub search() { - my $self = shift; - my $env = shift; - my $html->{result} = (); - my $ct="application/json"; - my $status=200; - my $req = Plack::Request->new($env); - my $ff = File::Find::Rule->new; - if (exists($req->query_parameters->{name})){ - my $namesearch = $req->query_parameters->{name}; - $ff->name($req->query_parameters->{name}) - }elsif((exists($req->query_parameters->{namelist}))){ - my @nl = split(",",$req->query_parameters->{namelist}); - $ff->name(@nl); - } - if (exists($req->query_parameters->{type})){ - if ($req->query_parameters->{type} eq 'd'){ - $ff->directory; - } else { - $ff->file; - } - } - if (exists($req->query_parameters->{relative})){ - $ff->relative; - } - if (exists($req->query_parameters->{osspec})){ - $ff->canonpath; - } - my @data = $ff->in($req->query_parameters->{path}); - if (exists($req->query_parameters->{sorted})){ - @data = sort {$a cmp $b} @data; - if ($req->query_parameters->{sorted} eq "desc"){ - @data = reverse(@data); - } - } - my $ret = undef; - if (exists($req->query_parameters->{output}) && $req->query_parameters->{output} eq "text"){ - $ct = "text/plain"; - $ret = ""; - foreach my $d (@data){ - $ret .= $d."\n"; - } - } elsif (exists($req->query_parameters->{output}) && $req->query_parameters->{output} eq "fmlist"){ - $ct = "text/plain"; - $ret = ""; - foreach my $d (@data){ - $ret .= $d."\r"; - } - } - else { - $html->{result} = \@data; - $ret = JSON::PP::encode_json($html) - } - - return [ - 200, - [ 'Content-Type' => $ct,'Cache-Control' => 'no-store, no-cache, must-revalidate', 'Access-Control-Allow-Origin'=> '*' ], - [ $ret ] - ]; -} - -sub directory() { - my $self = shift; - my $env = shift; - my $html; - my $ct="application/json"; - my $status=200; - - my $req = Plack::Request->new($env); - if ($env->{PATH_INFO} =~ /^\/directory\/list/){ - my $mt = MIME::Types->new(); - $html->{result} = 0; - if (exists($req->query_parameters->{path})){ - my $dir = $req->query_parameters->{path}; - #print $dir."\n"; - $html->{result} = {'path' => $dir}; - if (-d $dir){ - my @dirs = (); - my @files = (); - opendir(LDIR,$dir); - while (my $f = readdir(LDIR)){ - if ($f =~ /^\./){ next; } - - if (-d $dir.'/'.$f){ - my $bok =1 ; - if ($^O eq "MSWin32"){ - eval ('my $attr; - Win32::File::GetAttributes($dir.\'/\'.$f,$attr); - if ($attr & HIDDEN){ - $bok = 0; - }'); - } - if ($bok == 1){ - push(@dirs,$f); - } - - } elsif (-f $dir.'/'.$f) { - my $bok =1 ; - if ($^O eq "MSWin32"){ - eval ('my $attr; - Win32::File::GetAttributes($dir.\'/\'.$f,$attr); - if ($attr & HIDDEN){ - $bok = 0; - }'); - } - if ($bok == 1){ - print $f."\n"; - my $fi->{name} = $f; - my $mtf = $mt->mimeTypeOf($f); - $fi->{mimetype} = (exists($mtf->{MT_simplified})?$mtf->{MT_simplified}:'unknown'); - - push(@files,$fi); - } - } - } - closedir(LDIR); - $html->{result}->{directory} = \@dirs; - $html->{result}->{file} = \@files; - } - } - } - if ($env->{PATH_INFO} =~ /^\/directory\/exists/){ - $html->{result} = 0; - if (exists($req->query_parameters->{path})){ - if (-d $req->query_parameters->{path}){ - $html->{result} = 1; - } - } - } - if ($env->{PATH_INFO} =~ /^\/directory\/make/){ - make_path($req->query_parameters->{path}); - $html->{result} = 0; - if (-d $req->query_parameters->{path}){ - $html->{result} = 1; - } - } - if ($env->{PATH_INFO} =~ /^\/directory\/delete/){ - my $keep_root = 0; - if (exists($req->query_parameters->{keep_root})){ - $keep_root = 1; - } - $html->{result} = 0; - if (-d $req->query_parameters->{path}){ - remove_tree( $req->query_parameters->{path}, {keep_root => $keep_root} ); - $html->{result} = 1; - } - } - return [ - 200, - [ 'Content-Type' => $ct,'Cache-Control' => 'no-store, no-cache, must-revalidate', 'Access-Control-Allow-Origin'=> '*' ], - [ JSON::PP::encode_json($html) ] - ]; -} - -sub file() { - my $self = shift; - my $env = shift; - my $html->{result} = (); - my $ct="application/json"; - my $status=200; - - my $req = Plack::Request->new($env); - if ($env->{PATH_INFO} =~ /^\/file\/exists/){ - $html->{result} = 0; - if (exists($req->query_parameters->{path})){ - if (-f $req->query_parameters->{path}){ - $html->{result} = 1; - } - } - } -# if ($env->{PATH_INFO} =~ /^\/file\/choose/){ -# # A simple open file with graphic filers -# my ( @fss, $fss ); -# my ( @parms ); -# push @parms, -# -filter => [ 'PDF - fichiers PDF', '*.pdf' ], -# -directory => $ENV{HOME}, -# -title => 'selectionner un fichier PDF'; -# @fss = Win32::GUI::GetOpenFileName ( @parms ); -# if (scalar(@fss) > 0 ){ -# $html->{result} = \@fss; -# } -# } - if ($env->{PATH_INFO} =~ /^\/file\/write/){ - $html->{result} = 0; - if (exists($req->query_parameters->{path})){ - if (! -d (dirname($req->query_parameters->{path}))){ - make_path(dirname($req->query_parameters->{path})) - } - my $fwrite = ">"; - if (exists($req->query_parameters->{append})){ - $fwrite = ">>"; - } - my $datax = $req->body_parameters->{data}; - print $req->body_parameters->{data}."\n"; - open(WFI,$fwrite.$req->query_parameters->{path}); - print WFI $req->body_parameters->{data}; - close(WFI); - $html->{result} = 1; - } - } - if ($env->{PATH_INFO} =~ /^\/file\/read/){ - $html->{result} = ""; - if (exists($req->query_parameters->{path})){ - if (-f $req->query_parameters->{path}){ - my $rdata = ""; - open(RFI,$req->query_parameters->{path}); - while ( my $l = ){ - $rdata .= $l; - } - close(RFI); - $html->{result} = $rdata; - } - } - } - if ($env->{PATH_INFO} =~ /^\/file\/copy/){ - $html->{result} = ""; - if (exists($req->query_parameters->{src})){ - if (-f $req->query_parameters->{src}){ - my $dest = $req->query_parameters->{dest}; - if (! -d dirname($req->query_parameters->{dest})){ - make_path(dirname($req->query_parameters->{dest})) - } - if ($req->query_parameters->{src} ne $req->query_parameters->{dest}){ - my $cp = copy($req->query_parameters->{src},$req->query_parameters->{dest}); - $html->{result} = $cp; - } else { - $html->{result} = 1; - } - } - } - } - - return [ - 200, - [ 'Content-Type' => $ct,'Cache-Control' => 'no-store, no-cache, must-revalidate', 'Access-Control-Allow-Origin'=> '*' ], - [ JSON::PP::encode_json($html) ] - ]; -} - - -sub userenv() { - my $self = shift; - my $env = shift; - my $html->{result} = (); - my $ct="application/json"; - my $status=200; - - my $req = Plack::Request->new($env); - foreach my $k (keys(%ENV)){ - $html->{result}->{$k} = $ENV{$k}; - } - - return [ - 200, - [ 'Content-Type' => $ct,'Cache-Control' => 'no-store, no-cache, must-revalidate', 'Access-Control-Allow-Origin'=> '*' ], - [ JSON::PP::encode_json($html) ] - ]; -} -1; \ No newline at end of file diff --git a/Module/GISFiles.pm b/Module/GISFiles.pm index 6809574..e547a51 100644 --- a/Module/GISFiles.pm +++ b/Module/GISFiles.pm @@ -4,11 +4,13 @@ use strict; use warnings; use File::Path qw(make_path); use File::Basename; +use MIME::Types; use DBI; use DBD::mysql; use Encode; use parent qw(Plack::Component); use URI::Encode qw(uri_decode); +use utf8; #COmponent Entry point sub call { @@ -18,9 +20,9 @@ sub call { } elsif ($env->{PATH_INFO} =~ /^\/data/){ return $self->getdatalist($env); } elsif ($env->{PATH_INFO} =~ /^\/path/){ - + return $self->getfilepath($env); } elsif ($env->{PATH_INFO} =~ /^\/file/){ - + return $self->getfile($env); } return [ @@ -49,6 +51,89 @@ sub getfournisseurlist(){ ]; } +sub getfilepath(){ + my $self = shift; + my $env = shift; + my $html = {}; + my $ct="application/json"; + my $status=200; + + my $req = Plack::Request->new($env); + my $mt = MIME::Types->new(); + if (exists($req->query_parameters->{dir})){ + my $dir = $req->query_parameters->{dir}; + #print $dir."\n"; + $dir =~ s/\.\.//g; + $dir =~ s/\/\//\//g; + $html->{path} = $dir; + $html->{pathup} = dirname($dir); + if (-d $self->{gis}->{filesbasepath}.'/'.$dir){ + my @dirs = (); + my @files = (); + opendir(LDIR,$self->{gis}->{filesbasepath}.'/'.$dir); + while (my $f = readdir(LDIR)){ + if ($f =~ /^\./){ next; } + if (-d $self->{gis}->{filesbasepath}.'/'.$dir.'/'.$f){ + push(@dirs,$f); + } elsif (-f $self->{gis}->{filesbasepath}.'/'.$dir.'/'.$f) { + my $fi->{name} = $f; + my $mtf = $mt->mimeTypeOf($f); + $fi->{mimetype} = (exists($mtf->{MT_simplified})?$mtf->{MT_simplified}:'unknown'); + push(@files,$fi); + } + } + closedir(LDIR); + $html->{directory} = \@dirs; + $html->{file} = \@files; + } + } + return [ + $status, + [ 'Content-Type' => $ct,'Cache-Control' => 'no-store, no-cache, must-revalidate', 'Access-Control-Allow-Origin'=> '*' ], + [ JSON::PP::encode_json($html) ] + ]; +} + +sub getfile(){ + my $self = shift; + my $env = shift; + my $html = {}; + #my $ct="application/json"; + my $status=200; + my $basefname = undef; + my $req = Plack::Request->new($env); + my $mt = MIME::Types->new(); + my $file =""; + if (exists($req->query_parameters->{file})){ + $file = decode("utf-8",$req->query_parameters->{file}); + + $file =~ s/\.\.//g; + $file =~ s/\/\//\//g; + } + my $ret = ""; + my $basefname = basename($file); + if (-e $self->{gis}->{filesbasepath}.'/'.$file){ + my $mtf = $mt->mimeTypeOf($self->{gis}->{filesbasepath}.'/'.$file); + my $mt = (exists($mtf->{MT_simplified})?$mtf->{MT_simplified}:'application/x-download'); + open my $bin_fh, '<', $self->{gis}->{filesbasepath}.'/'.$file or die $!; + return [ + $status, + [ 'Content-Type' => $mt,'Content-Disposition' =>'attachment; filename='.$basefname,'Cache-Control' => 'no-store, no-cache, must-revalidate', 'Access-Control-Allow-Origin'=> '*' ], + $bin_fh + ]; + } else { + $ret = "File: ".$self->{gis}->{filesbasepath}.'/'.$file." does not FOUND!"; + return [ + 404, + [ 'Content-Type' => "text/html",'Cache-Control' => 'no-store, no-cache, must-revalidate' ], + [ $ret ] + ]; + } + + + +} + #parse the database table with in config defined SQL-Query filter optional parameters sub getdatalist(){ my $self = shift; diff --git a/Module/SQLite.pm b/Module/SQLite.pm deleted file mode 100644 index 741743a..0000000 --- a/Module/SQLite.pm +++ /dev/null @@ -1,255 +0,0 @@ -package Module::SQLite; - -use strict; -use warnings; -use parent qw(Plack::Component); -use Plack::Request; -use File::Basename; -#use Data::Dumper; -use DBI; -use DBD::SQLite; -use Encode; -use JSON::PP; - -sub call { - my($self, $env) = @_; - if (($env->{REMOTE_ADDR} =~ "^127\.0\.") && - ($env->{REMOTE_ADDR} =~ "^10\.") && - ($env->{REMOTE_ADDR} =~ "^172\.16\.") && - ($env->{REMOTE_ADDR} =~ "^192\.168\.")) { - return [ - 404, - [ 'Content-Type' => "text/html",'Cache-Control' => 'no-store, no-cache, must-revalidate' ], - [ "Sorry no remote access allowed!" ] - ]; - } - #$self->_app->($env); - return $self->sqlite($env); -} - -sub sqlite { - my $self = shift; - my $env = shift; - my $html->{result} = (); - my $ct="application/json"; - my $status=200; - my $req = Plack::Request->new($env); - my $res = (); - #print $req->query_parameters->{db}.":".$req->query_parameters->{type}.":".decode_base64($req->query_parameters->{sql})."\n------------------\n"; - - if ($env->{PATH_INFO} =~ /^\/\w+/){ - $self->{dbfile} = $self->{'dbpath'}.'/'.basename($env->{PATH_INFO}).'.sqlite'; - $html->{req}->{db} = $self->{'dbpath'}.'/'.basename($env->{PATH_INFO}).'.sqlite'; - }else { - if (exists($req->body_parameters->{db})){ - $self->{dbfile} = $req->body_parameters->{db}; - $html->{req}->{db} = $req->body_parameters->{db}; - } else { - return [ - 400, - [ 'Content-Type' => $ct.'; charset=utf-8','Cache-Control' => 'no-store, no-cache, must-revalidate', 'Access-Control-Allow-Origin'=> '*' ], - [ JSON::PP::encode_json($html) ] - ]; - } - } - - $html->{req}->{type} = $req->body_parameters->{type}; - $html->{req}->{sql} = $req->body_parameters->{sql}; - #$html->{req}->{sqldecoded} = $req->query_parameters->{sql}; - if (exists($req->body_parameters->{sql}) && exists($req->body_parameters->{type})) { - #$self->{dbfile} = $req->query_parameters->{db}; - #my $db = sqlite->new(); - my $q = $req->body_parameters->{sql}; - my $t = $req->body_parameters->{type}; - print $q."\n"; - if ($t eq "query"){ - $res = $self->dbquery($req->body_parameters->{key},$q); - } elsif ($t eq "querysorted"){ - $res = $self->dbquerysorted($q); - } elsif ($t eq "queryarray"){ - $res = $self->dbqueryarray($q); - } elsif ($t eq "exec"){ - $res = $self->dbexec($q); - } - $html->{result}->{sqldata} = $res; - } else { - return [ - 400, - [ 'Content-Type' => $ct.'; charset=utf-8','Cache-Control' => 'no-store, no-cache, must-revalidate', 'Access-Control-Allow-Origin'=> '*' ], - [ JSON::PP::encode_json($html) ] - ]; - } - return [ - 200, - [ 'Content-Type' => $ct.'; charset=utf-8','Cache-Control' => 'no-store, no-cache, must-revalidate', 'Access-Control-Allow-Origin'=> '*' ], - [ JSON::PP::encode_json($html) ] - ]; -}; - - - -sub strreplace(){ - my $self = shift; - my $text = shift; - $text =~ s/'/''/g; - return $text; -} - -sub dbquery(){ - my $self = shift; - my $key = shift; - my $stat = shift; - my $retdata =(); - my $dbh = DBI->connect('DBI:SQLite:dbname='.$self->{dbfile},"","",{PrintError=>1,RaiseError=>1,AutoCommit=>1}) or return $retdata->{error} = "dbquery Connection Error!".$!; - #$stat = encode("utf8", $stat); - - #open FILE,">>/tmp/sql.log"; - # print FILE "key:".$key.";$stat\n"; - # close FILE; - my $sth = $dbh->prepare($stat); - $sth->execute() or print "dbquery: ".$sth->errstr; - while(my $data = $sth->fetchrow_hashref()) - { - if (exists $data->{$key}){ - foreach my $k (keys %{$data}){ - $retdata->{$data->{$key}}{$k} = decode( "utf8", $data->{$k}); - } - } - } - if (keys(%{$retdata}) == 0){ - $retdata =(); - } - $sth->finish(); - $dbh->disconnect(); - return $retdata; -} - -sub dbquerysorted(){ - my $self = shift; - my $stat = shift; - my $retdata = (); - my $dbh = DBI->connect('DBI:SQLite:dbname='.$self->{dbfile},"","",{PrintError=>1,RaiseError=>1,AutoCommit=>1}) or return $retdata->{error} = "dbquery Connection Error!".$!; - #$stat = encode("utf8", $stat); - #open FILE,">>/tmp/sql.log"; - #print "$stat\n"; - # close FILE; - my $sth = $dbh->prepare($stat); - - $sth->execute() or print "dbquery: ".$sth->errstr; - my $count = 0; - while(my $data = $sth->fetchrow_hashref()) - { - foreach my $k (keys %{$data}){ - $retdata->{$count}->{$k} = decode( "utf8", $data->{$k}); - } - $count++; - } - - $sth->finish(); - $dbh->disconnect(); - #%retdata = sort {$a <=> $b} keys %retdata; - return $retdata; -} - -sub dbqueryarray(){ - my $self = shift; - my $stat = shift; - my @retdata = (); - my $dbh = DBI->connect('DBI:SQLite:dbname='.$self->{dbfile},"","",{PrintError=>1,RaiseError=>1,AutoCommit=>1}) or return $retdata[0]->{error} = "dbquery Connection Error!".$!; - #$stat = encode("utf8", $stat); - #open FILE,">>/tmp/sql.log"; - #print "$stat\n"; - # close FILE; - my $sth = $dbh->prepare($stat); - - $sth->execute() or print "dbquery: ".$sth->errstr; - my $count = 0; - - while(my $valdata = $sth->fetchrow_arrayref()) - { - if (!defined($valdata)){ last;} - my @rdata = (); - foreach my $k (@{$valdata}){ - push @rdata,decode( "utf8", $k); - } - push @retdata,\@rdata; - } - - $sth->finish(); - $dbh->disconnect(); - #%retdata = sort {$a <=> $b} keys %retdata; - return \@retdata; -} - -sub dbexec(){ - my $self = shift; - my $stat = shift; - my $dbh = DBI->connect('DBI:SQLite:dbname='.$self->{dbfile},"","",{PrintError=>1,AutoCommit=>1}) or return "dbexec Connection Error!".$!; - #$stat = encode("utf8", $stat); - #print $stat."\n"; - #open FILE,">>/Users/kilian/sql.log"; - #print FILE "$stat\n"; - #close FILE; - my $sth = $dbh->prepare($stat); - my $rv =$dbh->do($stat) or print "Failed dbexec:\n'".$stat. "'\n\n"; - $dbh->disconnect(); - return $rv; -} - - -#sub dbbackup(){ -# my $self = shift; -# my $path = shift; -# my $type = shift; -# -# my @dx = localtime(); -# $dx[5] = $dx[5] +1900; -# $dx[4] = $dx[4] +1; -# if ($dx[4] < 10){$dx[4] = '0'.$dx[4];} -# if ($dx[3] < 10){$dx[3] = '0'.$dx[3];} -# if ($dx[2] < 10){$dx[2] = '0'.$dx[2];} -# if ($dx[1] < 10){$dx[1] = '0'.$dx[1];} -# if ($dx[0] < 10){$dx[0] = '0'.$dx[0];} -# my $xdd = $dx[5].$dx[4].$dx[3].'_'.$dx[2].$dx[1].$dx[0]; -# my $bfile = ""; -# if ($type eq "binary" ) { -# $bfile = $path.'/'.basename(substr($self->{dbfile},0,rindex($self->{dbfile},'.'))).'_'.$xdd.'.sqlite'; -# my $dbh = DBI->connect('DBI:SQLite:dbname='.$self->{dbfile},"","",{PrintError=>1,RaiseError=>1,AutoCommit=>1}) or die "dbexec Connection Error!".$!; -# $dbh->sqlite_backup_to_file($bfile); -# $dbh->disconnect(); -# }elsif($type eq "sql"){ -# $bfile = $path.'/'.basename($self->{dbfile}).'_'.$xdd.'.sql'; -# my $st = system('sqlite3 "'.$self->{dbfile}.'" ".dump" > '.$bfile); -# } -# return $bfile; -#} -# -#sub dbrestore(){ -# my $self = shift; -# my $file = shift; -# my $type = shift; -# if ($type eq "binary" ) { -# my $dbh = DBI->connect('DBI:SQLite:dbname='.$self->{dbfile},"","",{PrintError=>1,RaiseError=>1,AutoCommit=>1}) or die "dbexec Connection Error!".$!; -# $dbh->sqlite_backup_from_file($file); -# $dbh->disconnect(); -# }elsif($type eq "sql"){ -# open(REST,$file) or die "cannot open restore file $file!\n"; -# my $rsql = ""; -# while (my $l = ) { -# $rsql .= $l; -# } -# close(REST); -# unlink($self->{dbfile}); -# $self->dbexec($rsql); -# } -#} -# -#sub dbrepair(){ -# my $self = shift; -# my $bfile = $self->dbbackup($ENV{'TMPDIR'},'sql'); -# $self->dbrestore($bfile,'sql'); -# unlink($bfile); -#} - - -1; \ No newline at end of file diff --git a/Module/Service.pm b/Module/Service.pm index 96caf93..aa5080e 100644 --- a/Module/Service.pm +++ b/Module/Service.pm @@ -27,13 +27,6 @@ sub service() { my $html = "Unknown service!"; my $ct="application/json"; my $status=200; - - # if ($env->{PATH_INFO} =~ /^\/info/){ - # return $self->appinfo($env); - # } - # if ($env->{PATH_INFO} =~ /^\/preferences/){ - # return $self->preferences($env); - # } if (($env->{PATH_INFO} =~ /^\/stop/) || ($env->{PATH_INFO} =~ /^\/unload/)){ warn "Killing the existing server (pid:".$self->{pid}.")\n"; kill 'TERM' => $self->{pid}; @@ -46,9 +39,6 @@ sub service() { # warn "Successfully killed! Restarting the new server process.\n"; } - # if($env->{PATH_INFO} =~ /^\/getconfig/){ - # return $self->getconfig($env); - # } return [ 200, @@ -57,417 +47,4 @@ sub service() { ]; }; -# sub preferences(){ -# my $self = shift; -# my $env =shift; -# my $name = basename($0); -# $name =~ s/\srv.pl$//; -# $name =~ s/\srv.exe$//; -# my $appcfgpath = $ENV{APPDATA}.'/'.$name; -# $appcfgpath =~ s/\\/\//g; -# my $pref->{result}= (); -# my $req = Plack::Request->new($env); -# if (exists($req->query_parameters->{page})){ -# if (-e $appcfgpath.'/'.$req->query_parameters->{page}.'.json'){ -# open(PREF,$appcfgpath.'/'.$req->query_parameters->{page}.'.json'); -# my $strpref = ""; -# while (my $l = ){ -# $strpref .= $l; -# } -# close(PREF); -# $pref->{result}=JSON::PP::decode_json($strpref); -# } -# if (exists($req->query_parameters->{set})){ -# my $newpref = JSON::PP::decode_json($req->query_parameters->{set}); -# foreach my $p (keys(%{$newpref})){ -# $pref->{result}->{$p} = $newpref->{$p}; -# } -# open(PREF,">".$appcfgpath.'/'.$req->query_parameters->{page}.'.json'); -# print PREF JSON::PP::encode_json($pref->{result}); -# close(PREF); -# } -# } -# return [ -# 200, -# [ 'Content-Type' => "application/json",'Cache-Control' => 'no-store, no-cache, must-revalidate', 'Access-Control-Allow-Origin'=> '*' ], -# [ JSON::PP::encode_json($pref) ] -# ]; -# } - -# sub appinfo(){ -# my $self = shift; -# my $env = shift; -# my $html->{result} = (); -# my $req = Plack::Request->new($env); -# my $name = basename($0); -# $name =~ s/\.pl$//; -# $name =~ s/\.exe$//; -# $html->{result}->{OS} = $^O; -# $html->{result}->{app} = $name; -# if ($^O eq "MSWin32"){ -# $html->{result}->{home} = $ENV{USERPROFILE}; -# $html->{result}->{user} = $ENV{USERNAME}; -# $html->{result}->{appcfgpath} = $ENV{APPDATA}.'/'.$name; -# $html->{result}->{hostname} = $ENV{COMPUTERNAME}; -# $html->{result}->{arch} = $ENV{PROCESSOR_ARCHITEW6432}; -# $html->{result}->{appcfgpath} =~ s/\\/\//g; -# $html->{result}->{home} =~ s/\\/\//g; -# } else { -# $html->{result}->{home} = $ENV{HOME}; -# $html->{result}->{user} = $ENV{USER}; -# if ($^O eq "darwin"){ -# $html->{result}->{appcfgpath} = $ENV{HOME}.'/Library/Application Support/'.$name; -# } else { -# $html->{result}->{appcfgpath} = $ENV{HOME}.'/.'.$name.'/'; -# } -# $html->{result}->{hostname} = `hostname -s`; -# chomp($html->{result}->{hostname}); -# $html->{result}->{arch} = `uname -m`; -# chomp($html->{result}->{arch}); -# } -# if (! -e $html->{result}->{appcfgpath}){ -# make_path($html->{result}->{appcfgpath}); -# } -# if (-e $html->{result}->{appcfgpath}.'/service.json'){ -# open(LCFG,$html->{result}->{appcfgpath}.'/service.json'); -# my $strljs = ""; -# while (my $l = ){ -# $strljs .= $l; -# } -# close(LCFG); -# print $strljs."\n--\n"; -# #if ($strljs =~ /^\{.*\}$/){ -# $html->{result}->{appconfig} = JSON::PP::decode_json($strljs); -# #} -# } -# return [ -# 200, -# [ 'Content-Type' => "application/json",'Cache-Control' => 'no-store, no-cache, must-revalidate', 'Access-Control-Allow-Origin'=> '*' ], -# [ JSON::PP::encode_json($html) ] -# ]; -# } - -# sub getfileconfig(){ -# my $self = shift; -# my $strcfg = ""; -# my $apppath = $self->getappconfigpath(); -# if (-e $apppath.'/'.basename($apppath).'.conf'){ -# open(AUTH,$apppath.'/'.basename($apppath).'.conf'); -# while (my $l = ){ -# chomp($l); -# $strcfg .= $l; -# } -# close(AUTH); -# } -# if ($strcfg eq ""){ -# return undef; -# } -# return JSON::decode_json($strcfg); -# } - -# sub getconfig(){ -# my $self = shift; -# my $env = shift; -# my $html->{result} = undef; -# my $req = Plack::Request->new($env); -# my @sections = ('weblogin','cablenet','wirelessnet','openvpn','extdrives','shares','shareusers'); -# if (exists($req->query_parameters->{section})){ -# @sections = split(',',$req->query_parameters->{section}); -# } -# foreach my $s (@sections){ -# if ($s eq 'weblogin') { -# $html->{result}->{$s} = $self->getweblogin(); -# } elsif ($s eq 'cablenet') { -# $html->{result}->{$s} = $self->getcablenetworkconfig(); -# } elsif ($s eq 'wirelessnet') { - -# } elsif ($s eq 'openvpn') { -# $html->{result}->{$s} = $self->getOpenVPN(); -# } elsif ($s eq 'extdrives') { -# $html->{result}->{extdrives} = $self->getdrives(); -# } elsif ($s eq 'shares') { -# $html->{result}->{shares} = $self->getshares(); -# } elsif ($s eq 'shareusers') { - -# }; -# } -# return [ -# 200, -# [ 'Content-Type' => "application/json",'Cache-Control' => 'no-store, no-cache, must-revalidate', 'Access-Control-Allow-Origin'=> '*' ], -# [ JSON::PP::encode_json($html) ] -# ]; -# } - -# sub getweblogin(){ -# my $self = shift; -# my $apppath = $self->getappconfigpath(); -# my $loginname= ""; -# if (-e $apppath.'/'.basename($apppath).'.passwd'){ -# open(AUTH,$apppath.'/'.basename($apppath).'.passwd'); -# while (my $l = ){ -# chomp($l); -# my ($loginname) = $l =~ /^(\w+)\=.*/; -# } -# close(AUTH); -# } -# return { "user" => $loginname }; -# } - -# sub setlogin(){ -# my $self = shift; -# my $env = shift; -# my $req = Plack::Request->new($env); - -# } - -# sub getwifinetworks(){ -# my $self = shift; -# my $current = `sudo grep ssid /etc/wpa_supplicant/wpa_supplicant.conf`; -# chomp($current); -# my $wifi->{ssid} = undef; -# if ($current ne ""){ -# $wifi->{ssid} = $current; -# } -# my $strlist = `sudo iw wlan0 scan | grep SSID | sed \'s/.*SSID: //g\'`; -# my @list = split("\n",$strlist); -# $wifi->{networks} = \@list; -# return $wifi; -# } - - - - -#sub getusers(){ -# my $self = shift; -# my $cmd = ""; -# if ($^O eq "linux"){ -# $cmd = 'cat /etc/passwd | grep "/bin/bash" | grep -v -e "^root" | awk -F ":" \'{ print $1 }\''; -# } elsif ($^O eq "darwin"){ -# $cmd = 'ls -1 /Users | grep -v "Shared"'; -# } elsif ($^O eq "MSWin32"){ -# -# } -# my $strdata = `$cmd`; -# my @list = split("\n",$strdata); -# return \@list; -#} - -# sub getdrives(){ -# my $self = shift; -# my $connecteddrives = $self->getconnecteddrives(); -# my $mounts = $self->getcurrentmountpoints(); -# my $cfg = $self->getfileconfig(); -# my $fstypes = { ntfs => 'ntfs-3g',exfat => 'exfat', fat32 => 'vfat'}; -# my $drivesdata = (); -# foreach my $cd (keys(%{$connecteddrives})){ -# if (exists($cfg->{drives}->{$connecteddrives->{$cd}->{serial}})){ -# $drivesdata->{$cd} = $connecteddrives->{$cd}; -# #print $cd." => ".$config->{drives}->{$connecteddrives->{$cd}->{serial}}->{path}."\n"; -# # if (! -d $config->{drives}->{$connecteddrives->{$cd}->{serial}}->{path}){ -# # mkdir($config->{drives}->{$connecteddrives->{$cd}->{serial}}->{path}); -# # } -# if (exists($mounts->{$connecteddrives->{$cd}->{dev}})){ -# $drivesdata->{$cd}->{mounpoint} = $mounts->{$connecteddrives->{$cd}->{dev}}; -# # my $cmd = "sudo mount -t ".$fstypes->{$connecteddrives->{$cd}->{fs}}." -o uid=".$config->{drives}->{$connecteddrives->{$cd}->{serial}}->{uid}.',gid='.$config->{drives}->{$connecteddrives->{$cd}->{serial}}->{gid}.','.$config->{drives}->{$connecteddrives->{$cd}->{serial}}->{type}." /dev/".$connecteddrives->{$cd}->{dev}." ".$config->{drives}->{$connecteddrives->{$cd}->{serial}}->{path}; -# #print $cmd."\n"; -# # my $res = `$cmd`; -# } -# } -# } -# return $drivesdata; -# } - -# sub mountdrives(){ -# my $self = shift; -# #mount -t ntfs-3g -o uid=1001,gid=1001,rw /dev/sdb1 /home/dks/music -# } - -# sub getshares(){ -# my $self = shift; -# my $shares =(); -# open(SMB,'/etc/samba/smb.conf'); -# my $cgrp = ""; -# while (my $l = ){ -# chomp($l); -# if ($l =~ /^\[.*\]$/){ -# $cgrp = $l; -# $cgrp =~ s /\[//; -# $cgrp =~ s /\]//; -# } elsif ($l ne ""){ -# my ($k,$v) = $l =~ m/\s*(.+)\s+\=\s+(.*)$/; -# if ($cgrp eq "global"){ -# if (($k eq "workgroup") || ($k eq "server string") || ($k eq "netbios name")){ -# $shares->{$cgrp}->{$k} =$v; -# } -# }else { -# if (($k eq "comment") || ($k eq "path") || ($k eq "vialid users")){ -# $shares->{$cgrp}->{$k} =$v; -# } -# } -# } -# } -# close(SMB); -# return $shares; -# } - -# sub setshares(){ -# my $self = shift; -# } - - -# sub getwifinetworks(){ -# my $self = shift; -# #iw wlan0 scan | grep SSID | sed 's/.*SSID: //g' -# # } - -# sub setwifinetwork(){ -# my $self = shift; -# #/etc/wpa_supplicant/wpa_supplicant.conf -# #network={ -# #ssid="testing" -# #psk="testingPassword" -# ##encrypted: -# #psk=131e1e221f6e06e3911a2d11ff2fac9182665c004de85300f9cac208a6a80531 -# #wpa_passphrase "testing" "testingPassword" -# #} -# #wpa_cli -i wlan0 reconfigure -# ##unsecurd -# # network={ -# # ssid="testing" -# # key_mgmt=NONE -# #} -# ##HIDDEN -# # network={ -# # ssid="yourHiddenSSID" -# # scan_ssid=1 -# # psk="Your_wifi_password" -# #} -# ##MULTIPLE with option apriority -# #network={ -# # ssid="HomeOneSSID" -# # psk="passwordOne" -# # priority=1 -# # id_str="homeOne" -# #} -# # -# #network={ -# # ssid="HomeTwoSSID" -# # psk="passwordTwo" -# # priority=2 -# # id_str="homeTwo" -# #} -# } - -# sub configureOpenVPN(){ -# my $self = shift; -# my $file = shift; -# } - -# sub getOpenVPN(){ -# my $self = shift; -# opendir(OVPN,'/etc/openvpn'); -# my $ovpndata = (); -# print "read OPENVPN:\n"; -# while(my $f = readdir(OVPN)){ -# print "OVPN file:".$f."\n"; -# if (($f =~ /\.ovpn$/) || ($f =~ /\.conf$/)){ -# my $name = substr($f,0,-6); -# $ovpndata->{$name} = undef; -# } -# } - -# closedir(OVPN); -# return $ovpndata; -# } - -# sub getOpenVPNstatus(){ - -# } - -# sub getcablenetworkconfig(){ -# my $self = shift; -# my $cmd = ""; -# my $ncfg->{type} = "dhcp"; -# if ($^O eq "linux"){ -# $cmd = 'cat /etc/dhcpcd.conf | grep -e "^static\|^interface"'; -# my $strdata = `$cmd`; -# my @data = split("\n",$strdata); -# foreach my $d (@data){ -# if ($d =~ /static\sip_address/){ -# $ncfg->{ip} = $d =~ /.+=(.+)\/\d{1,2}$/; -# $ncfg->{subnet} = $d =~ /.+=.+\/(\d{1,2})$/; -# #substr(Net::CIDR::addrandmask2cidr($stdata->{0}->{networkip}, $stdata->{0}->{networksubnet}),-3) -# } -# if ($d =~ /static\srouters/){ -# $ncfg->{gateway} = $d =~ /.+=(.+)$/; -# } -# if ($d =~ /static\sdomain_name_servers/){ -# $ncfg->{dns} = $d =~ /.+=(.+)$/; -# } -# } -# } elsif ($^O eq "darwin"){ -# $cmd = ''; -# } elsif ($^O eq "MSWin32"){ -# $cmd = ''; -# } -# return $ncfg; -# } - -# sub getappconfigpath(){ -# my $self = shift; -# my $name = basename($0); -# $name =~ s/\.pl$//; -# $name =~ s/\.exe$//; -# my $path = ""; -# if ($^O eq "MSWin32"){ -# $path = $ENV{APPDATA}.'/'.$name; -# } elsif ($^O eq "darwin"){ -# $path = $ENV{HOME}.'/Library/Application Support/'.$name; -# } else { -# $path = $ENV{HOME}.'/.'.$name.'/'; -# } -# return $path; -# } - -# sub getconnecteddrives(){ -# my $self = shift; -# my $cmd = 'lsblk -o name,label,size,mountpoint,fstype,SERIAL | grep -e "sd."'; -# my $strdrives = `$cmd`; -# my $drives = (); -# my @drives = split("\n",$strdrives); -# foreach my $l (@drives){ -# $l =~ tr/a-zA-Z0-9 ._-//cd; -# $l =~ s/\s+/\ /g; -# my @tmp = split(" ",$l); -# #print Dumper(@tmp); -# if ( $l =~ /^sd.\d/ ) { -# my $drv = substr($tmp[0],0,3); -# $drives->{$drv}->{dev} = $tmp[0]; -# $drives->{$drv}->{label} = $tmp[1]; -# $drives->{$drv}->{size} = $tmp[2]; -# $drives->{$drv}->{fs} = $tmp[3]; -# } else { -# #print $l."\n"; -# $drives->{$tmp[0]}->{serial} = $tmp[2]; -# } -# } - -# return $drives; -# } - -# sub getcurrentmountpoints(){ -# my $self = shift; -# my $cmd = 'mount | grep "/dev/sd"'; -# my $mpoints = (); -# my $strmounts = `$cmd`; -# #print $strmounts; -# my @mdrives = split("\n",$strmounts); -# foreach my $m (@mdrives){ -# my ($drv,$path) = $m =~ m/^\/dev\/(.+)\son\s(.*)\stype.*$/; -# $mpoints->{$drv} = $path; -# } -# return $mpoints; -# } - - 1; \ No newline at end of file diff --git a/build/build_gisservicehelper.bat b/build/build_gisservicehelper.bat new file mode 100644 index 0000000..eb88f31 --- /dev/null +++ b/build/build_gisservicehelper.bat @@ -0,0 +1,28 @@ +REM @echo off + +taskkill.exe /F /IM gisservicehelper.exe +del "C:\Users\ksaff\Workspace\solinf-gisservicehelper\dist\gisservicehelper.exe" +C:\Strawberry\perl\bin\perl.exe ^ + -I C:\Users\ksaff\Workspace\solinf-gisservicehelper "C:\Strawberry\perl\site\bin\pp.bat" ^ + --output="C:\Users\ksaff\Workspace\solinf-gisservicehelper\dist\gisservicehelper.exe" ^ + --cachedeps="C:\Users\ksaff\Workspace\solinf-gisservicehelper\dist\deps.txt" ^ + --compress 9 ^ + --gui ^ + --tempcache "gisservicehelper" ^ + --module="Time::HiRes" ^ + --module="JSON::MaybeXS" ^ + --module="JSON::PP" ^ + --module="Starlight" ^ + --module="Encode" ^ + --module="Encode::Guess" ^ + --module="IO::String" ^ + --module="DBI" ^ + --module="English" ^ + --module="DBD::mysql" ^ + --addfile="C:\Strawberry\perl\site\lib\HTTP;lib/HTTP" ^ + --addfile="C:\Strawberry\perl\site\lib\Plack;lib/Plack" ^ + --addfile="C:\Strawberry\perl\site\lib\Starlight;lib/Starlight" ^ + --addfile="C:\Users\ksaff\Workspace\solinf-gisservicehelper\Module\GISFiles.pm;lib/Module/GISFiles.pm" ^ + --addfile="C:\Users\ksaff\Workspace\solinf-gisservicehelper\Module\Service.pm;lib/Module/Service.pm" ^ + --addfile="C:\Strawberry\perl\lib\Encode;lib/Encode" ^ + --bundle "C:\Users\ksaff\Workspace\solinf-gisservicehelper\gisservicehelper.pl" \ No newline at end of file diff --git a/dev/createtest.pl b/dev/createtest.pl new file mode 100644 index 0000000..add31cd --- /dev/null +++ b/dev/createtest.pl @@ -0,0 +1,36 @@ +#!C:\Strawberry\perl\bin\perl.exe + +use strict; +use File::Basename; +use File::Path qw(make_path); +use File::Copy qw (copy); +use utf8; +use Encode; +my $basepath = dirname(dirname($0)).'/test'; +my @fl2 = ('AVIS_BUREAU_ETUDES','AVIS_POMPIER','AVIS_SERVCIES','COURRIERS','IMAGES','MILESTONES','ORIGINAUX','PLANS','RECLAMATIONS','TRAITEMENTS'); +my @flf = ('docx','dwg','dxf','pdf','xls','xlsx'); +open (FL1,dirname($0).'/folder1.txt'); +while (my $l = ){ + chomp($l); + if (! -d $basepath.'/'.$l){ + make_path($basepath.'/'.$l); + for (my $i=0;$i<7;$i++){ + my $r = int(rand(10)); + if (! -d $basepath.'/'.$l.'/'.$fl2[$r]){ + make_path($basepath.'/'.$l.'/'.$fl2[$r]); + for (my $i=0;$i<3;$i++){ + my $sfx = $flf[int(rand(5))]; + my $ffile = 'test.'.$sfx; + my $charnum = int(rand(20)) + 5; + my $tofile = &rndStr ($charnum, 'a'..'z', 0..9,' ','-','_'); + copy(dirname($0).'/testfiles/'.$ffile,$basepath.'/'.$l.'/'.$fl2[$r].'/'.encode("iso-8859-1",$tofile).'.'.$sfx); + } + } + } + } +} +close(FL1); + +sub rndStr (){ + return join'', @_[ map{ rand @_ } 1 .. shift ] +} \ No newline at end of file diff --git a/dev/folder1.txt b/dev/folder1.txt new file mode 100644 index 0000000..a811a38 --- /dev/null +++ b/dev/folder1.txt @@ -0,0 +1,600 @@ +1900/000001 +1983/000009 +1997/000030 +2003/000001 +2003/000002 +2003/000003 +2003/000004 +2003/000005 +2003/000006 +2003/000007 +2003/000008 +2003/000009 +2003/000010 +2003/000011 +2003/000012 +2003/000013 +2003/000014 +2003/000015 +2003/000016 +2003/000017 +2003/000018 +2004/000001 +2004/000002 +2004/000003 +2004/000004 +2004/000005 +2004/000006 +2004/000007 +2004/000008 +2004/000009 +2004/000010 +2004/000011 +2004/000012 +2004/000013 +2004/000014 +2004/000015 +2004/000016 +2004/000017 +2004/000018 +2004/000019 +2004/000020 +2004/000021 +2004/000022 +2004/000023 +2004/000024 +2004/000025 +2004/000026 +2004/000027 +2004/000028 +2004/000029 +2004/000030 +2004/000031 +2004/000032 +2004/000033 +2004/000034 +2004/000035 +2004/000036 +2004/000037 +2004/000038 +2004/000039 +2004/000040 +2004/000041 +2004/000042 +2004/000043 +2004/000044 +2004/000045 +2004/000046 +2004/000047 +2004/000048 +2004/000049 +2004/000050 +2004/000051 +2004/000052 +2005/000001 +2005/000002 +2005/000003 +2005/000004 +2005/000005 +2005/000006 +2005/000007 +2005/000008 +2005/000009 +2005/000010 +2005/000011 +2005/000012 +2005/000013 +2005/000014 +2005/000015 +2005/000016 +2005/000017 +2005/000018 +2005/000019 +2005/000020 +2005/000021 +2005/000022 +2005/000023 +2005/000024 +2005/000025 +2005/000026 +2005/000027 +2005/000028 +2005/000029 +2005/000030 +2005/000031 +2005/000032 +2005/000033 +2005/000034 +2005/000035 +2005/000036 +2005/000037 +2005/000038 +2006/000001 +2006/000002 +2006/000003 +2006/000004 +2006/000005 +2006/000006 +2006/000007 +2006/000008 +2006/000009 +2006/000010 +2006/000011 +2006/000012 +2006/000013 +2006/000014 +2006/000015 +2006/000016 +2006/000017 +2006/000018 +2006/000019 +2006/000020 +2006/000021 +2006/000022 +2006/000023 +2006/000024 +2006/000025 +2006/000026 +2006/000027 +2006/000028 +2006/000029 +2006/000030 +2006/000031 +2006/000032 +2006/000033 +2006/000034 +2006/000035 +2006/000036 +2006/000037 +2006/000038 +2006/000039 +2006/000040 +2006/000041 +2006/000042 +2006/000043 +2006/000044 +2006/000045 +2006/000046 +2006/000047 +2006/000048 +2006/000049 +2007/000001 +2007/000002 +2007/000003 +2007/000004 +2007/000005 +2007/000006 +2007/000007 +2007/000008 +2007/000009 +2007/000010 +2007/000011 +2007/000012 +2007/000013 +2007/000014 +2007/000015 +2007/000016 +2007/000017 +2007/000018 +2007/000019 +2007/000020 +2007/000021 +2007/000022 +2007/000023 +2007/000024 +2007/000025 +2007/000026 +2007/000027 +2007/000028 +2007/000029 +2007/000030 +2007/000031 +2007/000032 +2007/000033 +2007/000034 +2007/000035 +2007/000036 +2007/000037 +2008/000001 +2008/000002 +2008/000003 +2008/000004 +2008/000005 +2008/000006 +2008/000007 +2008/000008 +2008/000009 +2008/000010 +2008/000011 +2008/000012 +2008/000013 +2008/000014 +2008/000015 +2008/000016 +2008/000017 +2008/000018 +2008/000019 +2008/000020 +2008/000021 +2008/000022 +2008/000023 +2008/000024 +2008/000025 +2008/000026 +2008/000027 +2008/000028 +2008/000029 +2008/000030 +2008/000031 +2008/000032 +2008/000033 +2008/000034 +2008/000035 +2008/000036 +2008/000037 +2008/000038 +2008/000039 +2008/000040 +2008/000041 +2008/000042 +2008/000043 +2008/000044 +2009/000001 +2009/000002 +2009/000003 +2009/000004 +2009/000005 +2009/000006 +2009/000007 +2009/000008 +2009/000009 +2009/000010 +2009/000011 +2009/000012 +2009/000013 +2009/000014 +2009/000015 +2009/000016 +2009/000017 +2009/000018 +2009/000019 +2009/000020 +2009/000021 +2009/000022 +2009/000023 +2009/000024 +2009/000025 +2009/000026 +2009/000027 +2009/000028 +2009/000029 +2009/000030 +2009/000031 +2009/000032 +2009/000033 +2009/000034 +2009/000035 +2009/000036 +2009/000037 +2009/000038 +2009/000039 +2009/000040 +2009/000041 +2009/000042 +2009/000043 +2009/000044 +2010/000001 +2010/000002 +2010/000003 +2010/000004 +2010/000005 +2010/000006 +2010/000007 +2010/000008 +2010/000009 +2010/000010 +2010/000011 +2010/000012 +2010/000013 +2010/000014 +2010/000015 +2010/000016 +2010/000017 +2010/000018 +2010/000019 +2010/000020 +2010/000021 +2010/000022 +2010/000023 +2010/000024 +2010/000025 +2010/000026 +2010/000027 +2010/000028 +2010/000029 +2010/000030 +2010/000031 +2010/000032 +2010/000033 +2010/000034 +2010/000035 +2010/000036 +2010/000037 +2010/000038 +2010/000039 +2010/000040 +2010/000041 +2010/000042 +2010/000043 +2010/000044 +2010/000045 +2010/000046 +2010/000047 +2010/000048 +2010/000049 +2010/000050 +2010/000051 +2010/000052 +2010/000053 +2010/000054 +2010/000055 +2010/000056 +2010/000057 +2010/000058 +2010/000059 +2010/000060 +2011/000001 +2011/000002 +2011/000003 +2011/000004 +2011/000005 +2011/000006 +2011/000007 +2011/000008 +2011/000009 +2011/000010 +2011/000011 +2011/000012 +2011/000013 +2011/000014 +2011/000015 +2011/000016 +2011/000017 +2011/000018 +2011/000019 +2011/000020 +2011/000021 +2011/000022 +2011/000023 +2011/000024 +2011/000025 +2011/000026 +2011/000027 +2011/000028 +2011/000029 +2011/000030 +2011/000031 +2011/000032 +2011/000033 +2011/000034 +2011/000035 +2011/000036 +2011/000037 +2011/000038 +2011/000039 +2011/000040 +2011/000041 +2011/000042 +2011/000043 +2011/000044 +2011/000045 +2011/000046 +2011/000047 +2011/000048 +2011/000049 +2011/000050 +2011/000051 +2011/000052 +2011/000053 +2011/000054 +2011/000055 +2011/000056 +2011/000057 +2011/000058 +2011/000059 +2011/000060 +2011/000061 +2011/000062 +2012/000001 +2012/000002 +2012/000003 +2012/000004 +2012/000005 +2012/000006 +2012/000007 +2012/000008 +2012/000009 +2012/000010 +2012/000011 +2012/000012 +2012/000013 +2012/000014 +2012/000015 +2012/000016 +2012/000017 +2012/000018 +2012/000019 +2012/000020 +2012/000021 +2012/000022 +2012/000023 +2012/000024 +2012/000025 +2012/000026 +2012/000027 +2012/000028 +2012/000029 +2012/000030 +2012/000031 +2012/000032 +2012/000033 +2012/000034 +2012/000035 +2012/000036 +2012/000037 +2012/000038 +2012/000039 +2012/000040 +2012/000041 +2012/000042 +2012/000043 +2012/000044 +2012/000045 +2012/000046 +2012/000047 +2012/000048 +2012/000049 +2012/000050 +2012/000051 +2012/000052 +2012/000053 +2012/000054 +2012/000055 +2012/000056 +2012/000057 +2012/000058 +2012/000059 +2012/000060 +2012/000061 +2012/000062 +2012/000063 +2012/000064 +2012/000065 +2012/000066 +2012/000067 +2012/000068 +2012/000069 +2012/000070 +2012/000071 +2012/000072 +2012/000073 +2012/000074 +2013/000001 +2013/000002 +2013/000003 +2013/000004 +2013/000005 +2013/000006 +2013/000007 +2013/000008 +2013/000009 +2013/000010 +2013/000011 +2013/000012 +2013/000013 +2013/000014 +2013/000015 +2013/000016 +2013/000017 +2013/000018 +2013/000019 +2015/000099 +2015/000100 +2016/000053 +2016/000054 +2016/000057 +2016/000058 +2016/000059 +2016/000060 +2016/000061 +2016/000062 +2016/000063 +2016/000064 +2016/000065 +2016/000066 +2016/000067 +2016/000068 +2016/000069 +2016/000070 +2016/000071 +2016/000072 +2016/000073 +2016/000074 +2016/000075 +2016/000076 +2016/000077 +2016/000078 +2016/000079 +2016/000081 +2016/000082 +2016/000083 +2016/000084 +2016/000085 +2016/000086 +2016/000087 +2016/000088 +2016/000089 +2016/000090 +2016/000091 +2016/000092 +2016/000093 +2016/000094 +2016/000095 +2016/000096 +2016/000097 +2016/000098 +2016/000099 +2016/000100 +2016/000101 +2016/000102 +2016/000105 +2016/000106 +2016/000107 +2016/000108 +2016/000109 +2016/000110 +2016/000111 +2016/000112 +2016/000113 +2016/000114 +2016/000115 +2016/000116 +2016/000117 +2016/000118 +2016/000119 +2016/000120 +2016/000121 +2016/000122 +2016/000123 +2016/000124 +2016/000125 +2016/000126 +2016/000127 +2016/000128 +2016/000129 +2016/000130 +2016/000131 +2016/000133 +2016/000134 +2016/000135 +2016/000136 +2016/000137 +2016/000138 +2016/000139 +2016/000140 +2016/000141 +2016/000142 +2017/000001 +2017/000002 +2017/000003 +2017/000004 +2017/000005 +2017/000006 +2017/000007 +2017/000008 +2017/000009 +2017/000010 +2017/000011 +2017/000012 +2017/000013 +2017/000014 \ No newline at end of file diff --git a/gisservicehelper.json b/gisservicehelper.json index 1bed70b..dbe0ca7 100644 --- a/gisservicehelper.json +++ b/gisservicehelper.json @@ -11,7 +11,7 @@ "dbport": "3306" }, "gis": { - "filesbasepath": "C:/Users/ksaff/solinftest", + "filesbasepath": "C:/Users/ksaff/Workspace/solinf-gisservicehelper/test", "sql": "select annee_demande,LPAD(numero_demande,6,0) as numero_demande,adresse_%%fournisseur%% as adresse from table_gis where adresse_%%fournisseur%% is not null group by adresse_%%fournisseur%%,annee_demande,numero_demande,numero_demande_%%fournisseur%% order by annee_demande,numero_demande;", "webparam": { "fournisseur": { diff --git a/gisservicehelper.pl b/gisservicehelper.pl index 1e80eee..a312f1c 100644 --- a/gisservicehelper.pl +++ b/gisservicehelper.pl @@ -53,13 +53,17 @@ my $allapp = builder { mount "/" => Plack::App::File->new(root => dirname($0)."/htdocs")->to_app; }; -#--access-log -#--error-log -#--timeout -#--max-reqs-per-child -#--ipv6 -#--pid -my @args = ("--port",$cfg->{webservice}->{port},"--max-workers",$cfg->{webservice}->{workers}); +if (!exists($cfg->{webservice}->{port}){ + $cfg->{webservice}->{port} = '6060'; +} +my @allowed = ("port","access-log","error-log","timeout","max-workers","max-reqs-per-child","ipv6","pid"); +foreach my $c keys(%{$cfg->{webservice}}){ + if ( grep( /^$c$/, @allowed ) ){ + push(@args,"--".$c); + push(@args,$cfg->{webservice}->{$c}); + } +} + my $runner = Plack::Runner->new(server => 'Starlight', env => 'deployment'); $runner->parse_options(@args); $runner->run($allapp); diff --git a/htdocs/js/site.js b/htdocs/js/site.js index c1b7e11..0e7ae79 100644 --- a/htdocs/js/site.js +++ b/htdocs/js/site.js @@ -17,8 +17,80 @@ function getfolder(){ $("#sitetile").html("Founrisseurs"); $("#tbl_data > tbody").html(""); $("#tbl_data > thead").html(""); - if ((params) && (params.fournisseur) && (params.anne_demande) && (params.numero_demande) && (params.adresse)){ + if ((params) && (params.path)){ + $("#tbl_data > thead").html("Dossier/Fichier"); + $.ajax({ + encoding:"UTF-8", + url:"gis/path?dir=" +params.path, + method: "GET", + success: function (data){ + console.log(data); + $("#updir").html('⬑ retour'); + if ((data) && (data.directory)){ + for (var i in data.directory){ + // var drow = data.result[i]; + var row = ""; + + row += ''; + row += ''+ data.directory[i]+''; + + //row += ''+ drow.adresse+''; + row += ""; + $("#tbl_data > tbody").append(row); + } + } + if ((data) && (data.file)){ + for (var i in data.file){ + var drow = data.file[i]; + var row = ""; + + row += ''; + row += ''+ drow.name+''; + + //row += ''+ drow.adresse+''; + row += ""; + $("#tbl_data > tbody").append(row); + } + } + }, + error: function(data){ + alert("Erreur:" + JSON.stringify(data)); + console.log("Error:" + JSON.stringify(data)); + }, + async:true + }); + } + else if ((params) && (params.fournisseur) && (params.anne_demande) && (params.numero_demande) && (params.adresse)){ $("#tbl_data > thead").html("AnnéeNumero DemandeAdresse"); + $.ajax({ + encoding:"UTF-8", + url:"gis/path?dir=" +encodeURIComponent(params.anne_demande + '/' + params.numero_demande), + method: "GET", + success: function (data){ + console.log(data); + // if ((data) && (data.fournisseur)){ + // $("#sitetile").html(data.fournisseur); + // } + if ((data) && (data.result)){ + for (var i in data.result){ + var drow = data.result[i]; + var row = ""; + + row += ''+ drow.annee_demande+''; + row += ''+ drow.numero_demande+''; + row += ''+ drow.adresse+''; + //row += ''+ drow.adresse+''; + row += ""; + $("#tbl_data > tbody").append(row); + } + } + }, + error: function(data){ + alert("Erreur:" + JSON.stringify(data)); + console.log("Error:" + JSON.stringify(data)); + }, + async:true + }); } else if ((params) && (params.fournisseur)){ @@ -39,7 +111,8 @@ function getfolder(){ row += ''+ drow.annee_demande+''; row += ''+ drow.numero_demande+''; - row += ''+ drow.adresse+''; + row += ''+ drow.adresse+''; + //row += ''+ drow.adresse+''; row += ""; $("#tbl_data > tbody").append(row); } diff --git a/package-lock.json b/package-lock.json index 47cc33f..9090e67 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,11 @@ "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.3.1.tgz", "integrity": "sha512-Ubldcmxp5np52/ENotGxlLe6aGMvmF4R8S6tZjsP6Knsaxd/xp3Zrh50cG93lR6nPXyUFwzN3ZSOQI0wRJNdGg==", "dev": true + }, + "windows-10-icons": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/windows-10-icons/-/windows-10-icons-1.0.1.tgz", + "integrity": "sha1-VkyTt3nbcGDPOndBMxiwrFKXp2g=" } } } diff --git a/package.json b/package.json index 7aca14d..ce0bb95 100644 --- a/package.json +++ b/package.json @@ -15,5 +15,8 @@ "devDependencies": { "bootstrap": "^4.3.1", "jquery": "^3.3.1" + }, + "dependencies": { + "windows-10-icons": "^1.0.1" } } -- 2.39.5