url_post

XUpload related questions

Moderator: admin

Message
Author
mmcw
Posts: 7
Joined: Jul 31, 2007 3:09 pm

url_post

#1 Postby mmcw » Aug 01, 2007 8:30 am

In the free version it was possible to add the url_post value to the form.

In the pro version the url_post value can be set in the settings file.

Is it possible to use/ set the url_post value in the uploading form.
My url_post value is dynamically!

Greetings

Michel

User avatar
PilgrimX182
Posts: 2181
Joined: Mar 22, 2006 1:39 pm
Location: UFO Lab
Contact:

#2 Postby PilgrimX182 » Aug 01, 2007 8:40 am

Nopes. This was disabled in Pro due to security issues.
But you can make a quick hack in upload.cgi :
replace

Code: Select all

my $url_post = $c->{url_post} || $ENV{HTTP_REFERER};

with

Code: Select all

my $url_post = $cg->param('url_post') || $c->{url_post} || $ENV{HTTP_REFERER};

and then specify url_post in upload form.

mmcw
Posts: 7
Joined: Jul 31, 2007 3:09 pm

#3 Postby mmcw » Aug 01, 2007 9:11 am

It will work when redirect to an URL.
But when it has to be redirected to an address like this:

http://www.test.nl/cgi-bin/test.cgi?act ... ing&test=1

the part after the ? will be ignored!! It will redirect to:
http://www.test.nl/cgi-bin/test.cgi. How to fix that??

User avatar
PilgrimX182
Posts: 2181
Joined: Mar 22, 2006 1:39 pm
Location: UFO Lab
Contact:

#4 Postby PilgrimX182 » Aug 02, 2007 5:53 am

It's cause we send POST request there. And "?action=do_something&test=1" is GET request.

As far as I know in PHP you can read them in POST and GET arrays, in Perl you can use CGI.pm function url_param

Details are here:
http://search.cpan.org/~lds/CGI.pm-3.29 ... PARAMETERS

mmcw
Posts: 7
Joined: Jul 31, 2007 3:09 pm

#5 Postby mmcw » Aug 02, 2007 9:04 am

I have changed:

Code: Select all

### Sending data with POST request if need
my $url_post = $c->{url_post} || $ENV{HTTP_REFERER};
if($url_post)
{
   if($url_post=~/\.htm(l|)$/i)
   {
      print"Content-type: text/html\n\n";
      print"<HTML><HEAD><Script>parent.document.location='$url_post'</Script></HEAD></HTML>";
      exit;
   }
   if($ENV{QUERY_STRING}!~/js_on=1/)
   {
     $url_post.='?';
     $url_post.="\&$_->{name}=$_->{value}" for @har;
     print $cg->redirect( $url_post );
     exit;
   }
   print"Content-type: text/html\n\n";
   print"<HTML><BODY><Form name='F1' action='$url_post' target='_parent' method='POST'>";
   print"<textarea name='$_->{name}'>$_->{value}</textarea>" for @har;
#   print"</Form><Script>document.F1.submit();document.location='about:blank';</Script></BODY></HTML>";
   print"</Form><Script>document.location='javascript:false';document.F1.submit();</Script></BODY></HTML>";
   exit;
}


to the following:

Code: Select all

### Sending data with POST request if need

my %form_url_post;
my $form_url_post;
if ($cg->param('url_post')) {
   $form_url_post = (split(/\?/,$cg->param('url_post')))[-1];
   my @form_url_post = split(/\&/,$form_url_post);
   foreach (@form_url_post) {
      my ($key,$value) = split /\=/;
      $form_url_post{$key} = $value;
   }
}

my $url_post = $cg->param('url_post') || $c->{url_post} || $ENV{HTTP_REFERER};
if($url_post)
{
   if($url_post=~/\.htm(l|)$/i)
   {
      print"Content-type: text/html\n\n";
      print"<HTML><HEAD><Script>parent.document.location='$url_post'</Script></HEAD></HTML>";
      exit;
   }
   if($ENV{QUERY_STRING}!~/js_on=1/)
   {
     $url_post.='?';
    $url_post.=$form_url_post if ($form_url_post);
     $url_post.="\&$_->{name}=$_->{value}" for @har;
     print $cg->redirect( $url_post );
     exit;
   }
   print"Content-type: text/html\n\n";
   print"<HTML><BODY><Form name='F1' action='$url_post' target='_parent' method='POST'>";
   if($cg->param('url_post'))
   {
      print"<input type='hidden' name='$_' value='$form_url_post{$_}' />" foreach (keys %form_url_post);
   }
   print"<textarea name='$_->{name}'>$_->{value}</textarea>" for @har;
#   print"</Form><Script>document.F1.submit();document.location='about:blank';</Script></BODY></HTML>";
   print"</Form><Script>document.location='javascript:false';document.F1.submit();</Script></BODY></HTML>";
   exit;
}


and it worked! Thanks again!


Return to “XUpload”

Who is online

Users browsing this forum: No registered users and 0 guests