Net-ICQV5

 view release on metacpan or  search on metacpan

demos/client/SNlib.pl  view on Meta::CPAN

$SNlibversion = 84;
$antipopupstr = "<SCRIPT LANGUAGE=\"JavaScript\">parent.name = 'test';</SCRIPT><script language=\"JavaScript\">document.write(\"<no\" + \"script>\")</script>\n";
$eol          = "\x0D\x0A"; # "\r\n";
@rndletters = ("q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","z","x","c","v","b","n","m");
$thisurl          = change_spec_labels("###THISURL###");
$thisshorturl     = change_spec_labels("###THISURL_WITHOUT_SCRIPT_NAME###");

$thisshorturl=~ m|^([^\s\?]+)(/{1}?)|i;
$rooturlforhtmdir=$1;
$logfile 	  = "common.log";
$proxyfile        = "proxy.txt";

@envkeys = qw (
    HTTP_USER_AGENT
    HTTP_REFERER
    SERVER_SOFTWARE
    SERVER_NAME
    GATEWAY_INTERFACE
    SERVER_NAME
    SERVER_PROTOCOL
    SERVER_PORT
    REQUEST_METHOD
    HTTP_ACCEPT
    PATH_INFO
    PATH_TRANSLATED
    SCRIPT_NAME
    QUERY_STRING
    REMOTE_HOST
    REMOTE_ADDR
    REMOTE_USER
    AUTH_TYPE
    CONTENT_TYPE
    CONTENT_LENGTH
    HTTP_FROM
    REMOTE_IDENT
    );
##############################################################################
%color =(
    'normal'     => "",
    'black'      => "",
    'red'        => "" ,
    'ligthred'   => "",
    'green'      => "",
    'ligthgreen' => "",
    'blue'       => "",
    'ligthblue'  => "",
    'white'      => "",
    'yelow'      => "" ,
    '0' => "",
    '1' => "",
    '2' => "",
    '3' => "",
    '4' => "",
    '5' => "",
    '6' => "",
    '7' => "",
    '8' => "",
    '9' => "",
    'sim' => "",
);
###############################################################################
sub HTMLdie {

demos/client/SNlib.pl  view on Meta::CPAN

	    {
	    $location = $pagenow{'savedurl'} . "/" . $location;
	    }
	$pagenow{'url'}	= $location;
	
	print_msg_to_file($logfile,"TO: $location\n\n");

        if($location=~ m|^(http://)([^\?]*)\?([^\r\n]*)|i)
	    {
	    $pagenow{'content'} = $3;
	    print_msg_to_file($logfile,"NEW CONTENT: $pagenow{'content'}\n");
	    }
	else
	    {
	    delete($pagenow{'content'});
	    delete($pagenow{'contentlen'});
	    delete($pagenow{'savedurl'});
	    }	    

	$pagenow{'method'} = "GET";
        goto next_url;
        }

if(defined($pagenow{'cookies'})) {$out{'cookies'} = $pagenow{'cookies'};}
$out{'error'} = 0;
return %out;

print_error_to_log_and_exit:
print_msg_to_file($logfile,"\n$out{'errortxt'}\n");
return %out;
}
###############################################################################
sub ViewSpecHtmFile {
	local($htmfile) = @_;

open(FILE,"$htmfile") || &HTMLdie("ViewSpecHtmFile: Can't open file: '$htmfile'");
@htmfile = <FILE>;
close(FILE);

$commonline_htm='';
foreach $line (@htmfile) {$commonline_htm="$commonline_htm$line";}

$commonline_htm = &change_spec_labels($commonline_htm);

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

exit;
}
###############################################################################
sub change_spec_labels {
    local($ll)= @_ ;

    $serverport = defined($ENV{'SERVER_PORT'}) ? $ENV{'SERVER_PORT'} : -1;
    $portst = $serverport==80  ?  ''   :  ':' . $serverport;
    $thisurl= join('','http://',defined($ENV{'SERVER_NAME'}) ? $ENV{'SERVER_NAME'} : '',$portst,defined($ENV{'SCRIPT_NAME'}) ? $ENV{'SCRIPT_NAME'} : '');

    $thisurl=~ m|^([^\s\?]+)(/{1}?)|i;
    $thisshorturl=$1;

    $ll =~ s|###ANTIPOPUPSTRING###|$antipopupstr|igm;
    $ll =~ s|###RANDOM:([0-9]+)-([0-9]+)###|$1+(int rand($2-$1+1))|igme;
    
    $ll =~ s|###BASEOFPAGEHERE###|defined($baseofpage) ? $baseofpage : ''|igme;
    $ll =~ s|###RANDOM1###|defined($random1) ? $random1 : ''|igme;
	
    $ll =~ s|###THISURL###|$thisurl|igm;
    $ll =~ s|###THISURL_WITHOUT_SCRIPT_NAME###|$thisshorturl|igm;

    $ll =~ s|###SCRIPTNAME###|defined($SCRIPTNAME) ? $SCRIPTNAME : ''|igme;
    $ll =~ s|###DIRNAME###|defined($directory) ? $directory : ''|igme;
    $ll =~ s|###INTPROXYADDR###|defined($proxyaddr) ? $proxyaddr : ''|igme;
    $ll =~ s|###INTPROXYPORT###|defined($proxyport) ? $proxyport : ''|igme;
    $ll =~ s|###WEBP_ADDCGIURL###|defined($webp_addcgiurl) ? $webp_addcgiurl : ''|igme;

    $ll =~ s|###PREVPAGE###|defined($PREVPAGENAME) ? $PREVPAGENAME : ''|gime;

    $ll =~ s|###ORIGINAL_TITLE###|defined($original_title) ? $original_title : ''|gime;
    $ll =~ s|###ORIGINAL_DESCRIPTION###|defined($original_description) ? $original_description : ''|gime;
    $ll =~ s|###ORIGINAL_KEYWORDS###|defined($original_keywords) ? $original_keywords : ''|gime;
    $ll =~ s|###ORIGINAL_HTML###|defined($original_html) ? $original_html : ''|gime;
    $ll =~ s|###ORIGINAL_BODY###|defined($original_body) ? $original_body : ''|gime;
    $ll =~ s|###ORIGINAL_HEAD###|defined($original_head) ? $original_head : ''|gime;

    foreach $key (@envkeys)
	{
        $ll =~ s|###ENV_$key###|defined($ENV{$key}) ? $ENV{$key} : ''|gime;
	}

    return $ll;
}
###############################################################################
sub SelectRandomStringFromFile {
    local($filename) = @_;
    
    local(@strings,$rndnum,$string);

open(FILE,"$filename") || &HTMLdie("Can't open file: '$filename'");
@strings = <FILE>;
close(FILE);

$rndnum    = int rand($#strings+1);
$string    = $strings[$rndnum];
$string    =~ s/\r//g;
$string    =~ s/\n//g;

return $string;
}
###############################################################################
sub VoidFile {
	local($logfile) = @_;

if(!defined($logfile)) 
    { 
    die "Error input in SNlib::VoidFile()";
    }

open(FILE,">$logfile");
close(FILE);

}

demos/client/SNlib.pl  view on Meta::CPAN

	close(FILE);
	}
}
###############################################################################
sub bhprint_screen {
    local($string) = @_;
    
    if(isrunninglocaly())
	{
        print $string;
	}
    else
	{
	$string =~ s /\n/<br>\n/ig;
        print $string;
	}
}
###############################################################################
sub bhprint_log_screen {
    local($string) = @_;
    
    bhprint_log($string);
    bhprint_screen($string);
}
sub bhprint_screen_log {
    local($string) = @_;
    
    bhprint_log($string);
    bhprint_screen($string);
}
sub bhprint_screen_log_flag {
    local($flagscreen,$flaglog,$string) = @_;
    
    if($flagscreen) {bhprint_screen($string);}
    if($flaglog) {bhprint_log($string);}
}
sub bhprint_log_screen_flag {
    local($flaglog,$flagscreen,$string) = @_;
    
    if($flaglog) {bhprint_log($string);}
    if($flagscreen) {bhprint_screen($string);}
}
##############################################################################
sub bhprintHTMLheader {
    if(!isrunninglocaly())
	{
	print "Content-type: text/html\n\n";
	print "<html><body>\n";
	print "Goto <A HREF=http://sex.tapor.com target=_top>http://sex.tapor.com</A> to view best video sex on the net!<br><br>\n\n";
	}
    else
	{
	print "Goto http://sex.tapor.com to view best video sex on the net!\n\n";
	}
}
##############################################################################
sub bhprintHTMLfooter {
    if(!isrunninglocaly())
	{
	print "</body></html>\n";
	print "$antipopupstr\n";
	}
}
##############################################################################
sub isrunninglocaly {

    local($method) = defined($ENV{'REQUEST_METHOD'}) ? $ENV{'REQUEST_METHOD'} : 'LOCAL';
    if ($method eq 'GET' || $method eq 'POST') 
	{
        return 0;
	}
    return 1;
}
##############################################################################
sub CheckAllreadyRunning_2 {
    local($numstarts,$savefilesto) = @_;

    if(!defined($savefilesto)) {$savefilesto = "./";}

    local($lockfile) = "__lock";
    local($x,$flockret,$commonret);
    
    if($numstarts <= 0) {return 0;}
    
    $commonret = 0;
    for($x=1;$x<=$numstarts;$x++)
	{
        if(!open(LOCKING_FILE_SPEC,">$savefilesto/" . $lockfile . "_" . $x)) {next;}
        $flockret = flock(LOCKING_FILE_SPEC,2 + 4);

	if($flockret)
	    {
	    $commonret = 1;
	    last;
	    }
	}
    return $commonret;
}	
##############################################################################
sub CheckAllreadyRunning {
    local($numstarts,$LISTEN_PORT) = @_;

    local($file) = "__listenport.txt";
    unless (-e $file) 
	{
	$LISTEN_PORT = int rand(500);
	$LISTEN_PORT = $LISTEN_PORT + 21600;
	open(FILE,">$file");
	print FILE $LISTEN_PORT;
	close(FILE);
	}
    open(FILE,$file);
    $LISTEN_PORT=<FILE>;
    seek(FILE,0,0);
    chomp($LISTEN_PORT);
    close(FILE);
    
    socket(SE, PF_INET, SOCK_STREAM, 'udp');
    setsockopt(SE, SOL_SOCKET, SO_REUSEADDR, 1);
    for($x=0;$x<$numstarts;$x++,$LISTEN_PORT++)
	{



( run in 0.460 second using v1.01-cache-2.11-cpan-364913b4093 )