On Mon, Apr 18, 2011 at 6:17 PM, Shlomi Fish <shlo...@iglu.org.il> wrote:

> Hi Agnello,
>
> some comments on your code.
>
> On Monday 18 Apr 2011 15:18:22 Agnello George wrote:
> > Hi
> >
> > I am trying my hand in CGI , i have script that  runs svn list on-submit
> > which obviously takes 30 to 40 secs for the page to load , i plan to use
> a
> > ajax loader to be printed untill those 30 to 40 seconds.  But even after
> > the page has finished loading i can still see the image. I am not good in
> > java script but can this be done using perl  only .. here is a snip of my
> > code ..
>
> Please include your entire code - not a snippet of it.
>
> >
> >
> > my @all_svn;
> >
> > unless (@all_svn) {
>
> This will always be executed since @all_svn is empty.
>
> > print  '<p>  <img alt="" src="
> http://192.168.1.25/template/ajax-loader.gif";
> > /></p>';
> > }
> >  @all_svn = qx(svn list -R  $virticals{$sitei}{svnurl})  ;
>
> 1. You've misspelled "verticals".
>
> 2. What is "sitei"?
>
> 3. Be careful from interpolating strings into qx/.../ :
>
> http://community.livejournal.com/shlomif_tech/35301.html
>
> >
> > s/\s+$// for @all_svn;
>
> Subversion has Application Programmers Interfaces (APIs) for that, so you
> don't need to parse its output non-reliably.
>
> >
> > my %allsus = map {$_ => 1 } @filesi;
>
> What is "filesi"? What is "allsus"?
>
> > my @allgood = grep {defined $allsus{$_ } } @all_svn ;
> > print "@allgood";
>
> Here you can have a cross site scripting attack:
>
> http://community.livejournal.com/shlomif_tech/35301.html
>
> Best Regards,
>
>        Shlomi Fish
>
>



I am sorry i had only posted a snip of my code , here is the whole code (
which too is not complete )  .

I am using template toolkit for output ( do  you need me to paste my html
code also )

i have a simple UI , with a text area to input my files  and a drop  down
menu to select which site i need to do deployment for .

This code is not complete but  among the many other issues I am facing , the
main issue is the ajax-loader.gif that i need to show on the UI whne the
pages loads or on press of submit .

#!/usr/bin/perl

use strict ;
use warnings ;
use Template;
use Data::Dumper;
use CGI;
my $query = new CGI;

print "Content-type: text/html\n\n";

my $tt = Template->new( INCLUDE_PATH => "/var/www/html/template" ) || die
"template process failed:$!";

my %tag ;
my %verticals = ( 'website1_v' => { 'tempdir' => '/temp/auto' , 'svnurl' =>
'http://svn.int.com/repos/branch/website1' } );

my ($files, $site,$valu,$ma_status);
if ($ENV{'REQUEST_METHOD'} eq "POST") {
  $files = $query->param('element_1');
  $site = $query->param('mydropdown');
  $ma_status =  gtfls_cfe("$files");

}

sub gtfls_cfe {
  my (@files,$status);
  @files = split(/\s+/, $_[0]) ;
  $valu =  check_if_exist_in_svn(\@files,$site);


  if ($$valu{ireturn} == 1){
    $status = " the following files not exist in svn <BR> ";
    $status .= "$_<BR>" foreach @{$$valu{notgood}};
  } elsif ($$valu{ireturn} == 0 ) {
    $status = " the following files are OK  to deployed in production
server  <BR> ";
# Do more code here
#
 }
 return $status
}

sub check_if_exist_in_svn {
  my (@filesi) = @{$_[0]};
  my ($sitei )=  $_[1];
  my @all_svn;
#my $WW =  '<p>  <img alt="" src="
http://192.168.1.25/template/ajax-loader.gif"; /></p>';   ###   cant sem to
make this work!!
  @all_svn = qx(svn list -R  $verticals{$sitei}{svnurl})  ;

  s/\s+$// for @all_svn;

  my %allsus = map {$_ => 1 } @all_svn;

  my (@allgood,@notgood,%hash1 ) ;

  foreach (@filesi){
    if ( defined $allsus{$_} ){
      push (@allgood , $_);
    } elsif ( !defined $allsus{$_}) {
      push (@notgood, $_ ) ;
    }


  }
  if ( @notgood ) {
    %hash1 = ( 'ireturn' => 1 , notgood => \@notgood ) ;
    return (\%hash1) ;
  } elsif (@allgood){
    %hash1 = ( 'ireturn' => 0 , allgood => \@allgood ) ;
     return (\%hash1) ;
  }




}

%tag = ( 'result' => $ma_status );
#           'alldb' => @alldb );

print Dumper ([\%tag]);

$tt->process("form/form.html",\%tag) || die $tt->error();



===================================

thanks for all the help again .


-- 
Regards
Agnello D'souza

Reply via email to