the cgi script looks like this #!/usr/bin/perl -w use strict; use warnings; use CGI; my $TLD_LIST_FILE = "tld.list"; my $FAIL_LIST_FILE = "fail.list"; my $TEMPLATE_FILE_NAME = "results.htmlt"; my @tld_order; my %whois_servers_by_tld; if( open(my $tld_list_fh, "<", $TLD_LIST_FILE) ) { while(<$tld_list_fh>) { chomp; next unless /^\w/; my ($tld, $explicit_whois_server); if(m/ (.*) : (.*) /x) { ($tld, $explicit_whois_server) = ($1, $2); } else { ($tld, $explicit_whois_server) = ($_, undef); } $whois_servers_by_tld{$tld} = $explicit_whois_server; push @tld_order, $tld; } close $tld_list_fh; } else { die "$TLD_LIST_FILE: $!"; } my @failure_patterns; if( open(my $failure_pattern_fh, "<", $FAIL_LIST_FILE) ) { chomp(@failure_patterns = <$failure_pattern_fh>); close $failure_pattern_fh; } else { die "$FAIL_LIST_FILE: $!"; } my %failure_pattern_test; @failure_pattern_test{@failure_patterns} = @failure_patterns; my $output_template; if( open(my $output_template_fh, "<", $TEMPLATE_FILE_NAME) ) { local $/ = undef; $output_template = <$output_template_fh>; close $output_template_fh; } else { die "$FAIL_LIST_FILE: $!"; } my $cgi = new CGI; my $domain_head = $cgi->param("domain"); my @tlds_requested = map { split(/,/, lc($_) ) } $cgi->param("tld"); if(@tlds_requested) { @tld_order = grep {exists $whois_servers_by_tld{$_}} @tlds_requested; } if($domain_head=~/[.]/) { if(grep {$_ eq "name"} @tld_order) { @tld_order = "name"; } else { $domain_head=~s/.*[.]//; } } $domain_head=~s/ ^ [.\-]* (.*?) [.\-]* $ /$1/x; sub canonicalise_line { my ($line, $domain_full) = @_; $line=~s/\r?\n$//; $line=~s/\Q$domain_full\E/[]/gi; return $line; } if($domain_head and $domain_head=~m/ ^ [a-z0-9] [a-z0-9.\-]* $ /ix) { my %availability_by_tld; for my $tld (@tld_order) { my @extra_args; if($whois_servers_by_tld{$tld}) { @extra_args = ("-h", $whois_servers_by_tld{$tld}); } my $domain_full = "$domain_head.$tld"; if( open(my $whois_pipe, "-|", "whois", @extra_args, $domain_full) ) { my @whois_data = <$whois_pipe>; close $whois_pipe; my $not_registered = grep { exists $failure_pattern_test{$_} } map { canonicalise_line($_, $domain_full) } @whois_data; $availability_by_tld{$tld} = $not_registered; } else { warn "whois: $!"; } } my $results = "<ul>\n". join("\n", map { "<li>". "$domain_head.$_: ". ( $availability_by_tld{$_} ? "<b>available</b>" : "registered" ). "</li>" } @tld_order). "</ul>\n"; $output_template=~s#\[DATA\]#$results#g; } else { $output_template=~s#\[DATA\]#<p>No results</p>#g; } print $cgi->header("text/html"); print $output_template;
Hi there
Is there a snippet for Modx EVO 1.0.14 or an add on out there that I can easily integrate into my web hosting site.
I have a script (non modx) that uses cgi to run the form and display the results, but cant get my head round how to get the results to show within my page.
the check page looks like this
http://www.foxcreativedesign.co.uk/web-hosting/register-your-domain-name-here.html
and the results page
http://www.foxcreativedesign.co.uk/web-hosting/domain-search-results.html
To test it will work Ive made this page,
http://www.foxcreativedesign.co.uk/web-hosting/register-your-domain-name-here1.html
which calls the cgi directly, I just need to get the resulst to display in a web page.
Tried iframes and that doesnt work
I dont really want to insert "print" before everyline in cgi in case my menu changes etc.
here is the whois.cgi script
Im more than happy to buy a couple of virtual coffees (via paypal) to the person who can sort this for me.
thanks in advance
the cgi script looks like this #!/usr/bin/perl -w use strict; use warnings; use CGI; my $TLD_LIST_FILE = "tld.list"; my $FAIL_LIST_FILE = "fail.list"; my $TEMPLATE_FILE_NAME = "results.htmlt"; my @tld_order; my %whois_servers_by_tld; if( open(my $tld_list_fh, "<", $TLD_LIST_FILE) ) { while(<$tld_list_fh>) { chomp; next unless /^\w/; my ($tld, $explicit_whois_server); if(m/ (.*) : (.*) /x) { ($tld, $explicit_whois_server) = ($1, $2); } else { ($tld, $explicit_whois_server) = ($_, undef); } $whois_servers_by_tld{$tld} = $explicit_whois_server; push @tld_order, $tld; } close $tld_list_fh; } else { die "$TLD_LIST_FILE: $!"; } my @failure_patterns; if( open(my $failure_pattern_fh, "<", $FAIL_LIST_FILE) ) { chomp(@failure_patterns = <$failure_pattern_fh>); close $failure_pattern_fh; } else { die "$FAIL_LIST_FILE: $!"; } my %failure_pattern_test; @failure_pattern_test{@failure_patterns} = @failure_patterns; my $output_template; if( open(my $output_template_fh, "<", $TEMPLATE_FILE_NAME) ) { local $/ = undef; $output_template = <$output_template_fh>; close $output_template_fh; } else { die "$FAIL_LIST_FILE: $!"; } my $cgi = new CGI; my $domain_head = $cgi->param("domain"); my @tlds_requested = map { split(/,/, lc($_) ) } $cgi->param("tld"); if(@tlds_requested) { @tld_order = grep {exists $whois_servers_by_tld{$_}} @tlds_requested; } if($domain_head=~/[.]/) { if(grep {$_ eq "name"} @tld_order) { @tld_order = "name"; } else { $domain_head=~s/.*[.]//; } } $domain_head=~s/ ^ [.\-]* (.*?) [.\-]* $ /$1/x; sub canonicalise_line { my ($line, $domain_full) = @_; $line=~s/\r?\n$//; $line=~s/\Q$domain_full\E/[]/gi; return $line; } if($domain_head and $domain_head=~m/ ^ [a-z0-9] [a-z0-9.\-]* $ /ix) { my %availability_by_tld; for my $tld (@tld_order) { my @extra_args; if($whois_servers_by_tld{$tld}) { @extra_args = ("-h", $whois_servers_by_tld{$tld}); } my $domain_full = "$domain_head.$tld"; if( open(my $whois_pipe, "-|", "whois", @extra_args, $domain_full) ) { my @whois_data = <$whois_pipe>; close $whois_pipe; my $not_registered = grep { exists $failure_pattern_test{$_} } map { canonicalise_line($_, $domain_full) } @whois_data; $availability_by_tld{$tld} = $not_registered; } else { warn "whois: $!"; } } my $results = "<ul>\n". join("\n", map { "<li>". "$domain_head.$_: ". ( $availability_by_tld{$_} ? "<b>available</b>" : "registered" ). "</li>" } @tld_order). "</ul>\n"; $output_template=~s#\[DATA\]#$results#g; } else { $output_template=~s#\[DATA\]#<p>No results</p>#g; } print $cgi->header("text/html"); print $output_template;
Hi there
Is there a snippet for Modx EVO 1.0.14 or an add on out there that I can easily integrate into my web hosting site.
I have a script (non modx) that uses cgi to run the form and display the results, but cant get my head round how to get the results to show within my page.
the check page looks like this
http://www.foxcreativedesign.co.uk/web-hosting/register-your-domain-name-here.html
and the results page
http://www.foxcreativedesign.co.uk/web-hosting/domain-search-results.html
To test it will work Ive made this page,
http://www.foxcreativedesign.co.uk/web-hosting/register-your-domain-name-here1.html
which calls the cgi directly, I just need to get the resulst to display in a web page.
Tried iframes and that doesnt work
I dont really want to insert "print" before everyline in cgi in case my menu changes etc.
here is the whois.cgi script
Im more than happy to buy a couple of virtual coffees (via paypal) to the person who can sort this for me.
thanks in advance
the cgi script looks like this #!/usr/bin/perl -w use strict; use warnings; use CGI; my $TLD_LIST_FILE = "tld.list"; my $FAIL_LIST_FILE = "fail.list"; my $TEMPLATE_FILE_NAME = "results.htmlt"; my @tld_order; my %whois_servers_by_tld; if( open(my $tld_list_fh, "<", $TLD_LIST_FILE) ) { while(<$tld_list_fh>) { chomp; next unless /^\w/; my ($tld, $explicit_whois_server); if(m/ (.*) : (.*) /x) { ($tld, $explicit_whois_server) = ($1, $2); } else { ($tld, $explicit_whois_server) = ($_, undef); } $whois_servers_by_tld{$tld} = $explicit_whois_server; push @tld_order, $tld; } close $tld_list_fh; } else { die "$TLD_LIST_FILE: $!"; } my @failure_patterns; if( open(my $failure_pattern_fh, "<", $FAIL_LIST_FILE) ) { chomp(@failure_patterns = <$failure_pattern_fh>); close $failure_pattern_fh; } else { die "$FAIL_LIST_FILE: $!"; } my %failure_pattern_test; @failure_pattern_test{@failure_patterns} = @failure_patterns; my $output_template; if( open(my $output_template_fh, "<", $TEMPLATE_FILE_NAME) ) { local $/ = undef; $output_template = <$output_template_fh>; close $output_template_fh; } else { die "$FAIL_LIST_FILE: $!"; } my $cgi = new CGI; my $domain_head = $cgi->param("domain"); my @tlds_requested = map { split(/,/, lc($_) ) } $cgi->param("tld"); if(@tlds_requested) { @tld_order = grep {exists $whois_servers_by_tld{$_}} @tlds_requested; } if($domain_head=~/[.]/) { if(grep {$_ eq "name"} @tld_order) { @tld_order = "name"; } else { $domain_head=~s/.*[.]//; } } $domain_head=~s/ ^ [.\-]* (.*?) [.\-]* $ /$1/x; sub canonicalise_line { my ($line, $domain_full) = @_; $line=~s/\r?\n$//; $line=~s/\Q$domain_full\E/[]/gi; return $line; } if($domain_head and $domain_head=~m/ ^ [a-z0-9] [a-z0-9.\-]* $ /ix) { my %availability_by_tld; for my $tld (@tld_order) { my @extra_args; if($whois_servers_by_tld{$tld}) { @extra_args = ("-h", $whois_servers_by_tld{$tld}); } my $domain_full = "$domain_head.$tld"; if( open(my $whois_pipe, "-|", "whois", @extra_args, $domain_full) ) { my @whois_data = <$whois_pipe>; close $whois_pipe; my $not_registered = grep { exists $failure_pattern_test{$_} } map { canonicalise_line($_, $domain_full) } @whois_data; $availability_by_tld{$tld} = $not_registered; } else { warn "whois: $!"; } } my $results = "<ul>\n". join("\n", map { "<li>". "$domain_head.$_: ". ( $availability_by_tld{$_} ? "<b>available</b>" : "registered" ). "</li>" } @tld_order). "</ul>\n"; $output_template=~s#\[DATA\]#$results#g; } else { $output_template=~s#\[DATA\]#<p>No results</p>#g; } print $cgi->header("text/html"); print $output_template;