Gossamer Forum
Home : Products : Gossamer Links : Discussions :

multiple action in add.cgi

(Page 1 of 2)
> >
Quote Reply
multiple action in add.cgi
I am using links sql since a few years now and extremely happy.

I recently have a requirement which I am unable to find the solution anywhere, if anyone can help me, it would be great.

I need the add.cgi to perform two actions, currently when someone adds a url to the directory through add.cgi file, it goes in the validation table.

I need the same data to be simutaneously to be passed to a different form url too when someone adds a url i.e

http://www.mysite.com?add.php&email=email&url=url&ip=ipaddress

etc

How can add.cgi perform two actions simultaneously?

The second action can be performed in the background, I dont care, I just need the variables to be passed to a different url as stated in the query string above.

Please help my fellow genius programmers..It would be of great help
Quote Reply
Re: [biraju] multiple action in add.cgi In reply to
Hi,

So you want the params to be passed along to another URL, after they arrive on add_success.html? The ideal option would just be a global that is called in add_success.html, and then uses LWP::Simple to pass along whatever params you want to the given URL. Something like:

load_success_page_extra
Code:
sub {
my $in = $IN->get_hash;
use LWP::Simple;
map {
$in->{$_} = GT::CGI->escape($in->{$_}) # url escape it, so make sure there are no nasties/other stuff that will mess the URL about
} keys %$in;
get("http://www.foo.com/something/whatever?param=$in->{Title}&desc=$in->{Description}")
return; # all done :)
}

Then in add_success.html, add this into the template:

<%load_success_page_extra%>

Totally untested, but should work fine (obviously change the URL to whatever you want, as well as the params you want to pass along)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] multiple action in add.cgi In reply to
Thanks for taking time to help me.. Just one quick question.

I get a lot of remote url listing. So am sure they dont go to the add success page. In that situation doing something on the add success page would not cater them.

Is it something we can do where the add.cgi when submitted does two actions.

One being adding url to the validate section
and second being passing the variables to a different url?
Quote Reply
Re: [biraju] multiple action in add.cgi In reply to
Hi,

What do you mean by "remote url listings" ?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] multiple action in add.cgi In reply to
I mean someone not actually coming to my site, but doing a remote listing through some software..like there are many scripts and softwares available to do search engine submission etc.

The very same way.

Infact I am using your addon, send after email..which sends an email as soon as a listing is received. Can it pass variables to another script?
Quote Reply
Re: [biraju] multiple action in add.cgi In reply to
If its doing that, then it will be sending to add_success.html :) Even remote software still has to go in via add.cgi - there are no work arounds (unless of course someone has coded something unique for you, which does allow that)

Either way, give it a go in add_success.html - as I'm 99.9% sure it'll work there Angelic

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] multiple action in add.cgi In reply to
Okay shall give it a shot.

And one dumb question.

In which file and where should i add this?

load_success_page_extra
Code:
sub {
my $in = $IN->get_hash;
use LWP::Simple;
map {
$in->{$_} = GT::CGI->escape($in->{$_}) # url escape it, so make sure there are no nasties/other stuff that will mess the URL about
} keys %$in;
get("http://www.foo.com/something/whatever?param=$in->{Title}&desc=$in->{Description}")
return; # all done :)
}
Quote Reply
Re: [biraju] multiple action in add.cgi In reply to
Cool. To add it, go into the admin panel - then Build > Template Globals. At the bottom of the page, you should see a text input and a textarea. Values put as so:

text input: load_success_page_extra
textarea value:
Code:
sub {
my $in = $IN->get_hash;
use LWP::Simple;
map {
$in->{$_} = GT::CGI->escape($in->{$_}) # url escape it, so make sure there are no nasties/other stuff that will mess the URL about
} keys %$in;
get("http://www.foo.com/something/whatever?param=$in->{Title}&desc=$in->{Description}")
return; # all done :)
}

Then save it, and in add_success.html add in:

Code:
<%load_success_page_extra%>

... right near the end

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] multiple action in add.cgi In reply to
It didnt work. Its printing the details on the add success page when I test it. It prints this in the absolute bottom where I have added the code on the add success template but it doesnt actually run this url or pass variable info to the url below.

sub { my $in = $IN->get_hash; use LWP::Simple; map { $in->{$_} = GT::CGI->escape($in->{$_}) } keys %$in; get("http://www.mysite.com/cgi-bin/formapture.pl?email=<%Contact_Email%>&title=<%escape_html URL%>&id=8&ip_address=") return; }
Quote Reply
Re: [biraju] multiple action in add.cgi In reply to
Now I got this error

Unable to compile 'load_success_page_extra': Global symbol "%in" requires explicit package name at (eval 44) line 7. syntax error at (eval 44) line 8, near ") return"
Quote Reply
Re: [biraju] multiple action in add.cgi In reply to
This is what I have added

sub {
my $in = $IN->get_hash;
use LWP::Simple;
map {
$in->{$_} = GT::CGI->escape($in->{$_})
} keys %$in;
get("http://www.mywebsite.com/formcapture.pl?email=$in->{Email}&title=$in->{URL}&id=8&ip_address=101.101.25.98")
return;
}


Are these variables ok {Email} & {URL}
Quote Reply
Re: [biraju] multiple action in add.cgi In reply to
This is the latest error I got after adding the above

Unable to compile 'load_success_page_extra': syntax error at (eval 44) line 8, near ") return"
Quote Reply
Re: [biraju] multiple action in add.cgi In reply to
Looks like its missing a ; ..try this:

Code:
sub {
my $in = $IN->get_hash;
use LWP::Simple;
map {
$in->{$_} = GT::CGI->escape($in->{$_})
} keys %$in;
get("http://www.mywebsite.com/formcapture.pl?email=$in->{Email}&title=$in->{URL}&id=8&ip_address=101.101.25.98");
return;
}

BTW, please use the [code] ... [/code] format when pasting in code... it makes it very hard to read when its not indented otherwise ;)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] multiple action in add.cgi In reply to
Bingo, the errors gone. but it doesnt pass the variable to the string.

Are these variables used okay?

{Email} and {URL}?

Because on the add success template, they are <%Contact_Email%> and <%escape_html URL%>
Quote Reply
Re: [biraju] multiple action in add.cgi In reply to
I noticed the variables $in->{URL} and $in->{Email} are not printing data. The variable names needs to be something different.
Quote Reply
Re: [biraju] multiple action in add.cgi In reply to
Mmm.. $in->{URL} should work ok. As for email, you are correct - it should be:

Code:
$in->{Contact_Email}

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] multiple action in add.cgi In reply to
Nope, both of them are not working. Even Contact_Email is not working.

Its printing blank in the url string in both email and url values
Quote Reply
Re: [biraju] multiple action in add.cgi In reply to
Can you try changing:

Code:
$in->{$_} = GT::CGI->escape($in->{$_})

to:

Code:
$in->{$_} = GT::CGI::escape($in->{$_})

..to see if that helps?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] multiple action in add.cgi In reply to
Nope, not working this either. Really sorry to bother you with this but it seems we are just a step away
Quote Reply
Re: [biraju] multiple action in add.cgi In reply to
Mmm ok - so just after:

Code:
my $in = $IN->get_hash;

Please add:

Code:
use Data::Dumper;
print $IN->header;
print Dumper($in,@_);

Then add a link via add.cgi, and tell me what extra information gets printed out on the success page.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] multiple action in add.cgi In reply to
I sent you a pm with all the information printed
Quote Reply
Re: [biraju] multiple action in add.cgi In reply to
Ok, I think I see the problem. For some reason $in isn't getting the values. Looks like you will need to use this:

Code:
my $in = shift;

Can you try that, and see if that works any better?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] multiple action in add.cgi In reply to
BINGO!. It worked.

You are a genius.

One last thing, How do i get the variable for the ip address of the client?
Quote Reply
Re: [biraju] multiple action in add.cgi In reply to
haha we got there in the end Cool

To get the IP, use:

Code:
$ENV{REMOTE_ADDR}

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] multiple action in add.cgi In reply to
Too Good..You are a master blaster person.

Ip worked too.

Thanks, thanks, thanks. I appreciate all your help and time.
> >