Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Dear Monks,

I am having troubles getting my top referer script to work, I bought it over a year ago and am now trying to set it up again.

Every time I run it it starts an endless loop, (the stderr file gets above 500 mb in filesize) and it does not write the information to the files as it is supposed to.

The script is supposed to read its self generated log and write the information into nice predefined formatted tables in html code. If anyone has any idea why this might happen IŽd be appreciative for some help.

Regards, Alexander

pasted script comes here:

#!/usr/bin/perl -w BEGIN { open(STDERR,">/usr/home/hsphere/local/home/snurk/snurk.net/cgi-bin/ +referer/error.txt"); chmod(oct(777)," /usr/home/hsphere/local/home/snurk/snurk.net/cgi-b +in/referer/error.txt"); } ###################################################### # Referer.cgi Version 1.10 # # This script is written by # # Frank Larsen 2000 # # http://www.bozysweb.com # ###################################################### require 'settings.conf'; require 'exclude.conf'; require 'include.conf'; $data = ""; $template_file = "template.txt"; @html_file = @pages; print "Content-type: text/html\n\n"; print "Updating the HTML file(s)<br>\n"; print "Please Hold\n"; $|=1; $time = time(); if ($uniqe eq '1') { open(SESAME,"$referer_log.backup") || die "Could not open Referer Log" +; @filecontents = <SESAME>; close(SESAME); @hash{@filecontents}=(); @filecontents=keys %hash; open(SESAME,">$referer_log.backup") || die "Could not open Referer Log +"; foreach $line(@filecontents){ print SESAME "$line";} close(SESAME); chmod (0666, "$referer_log.backup"); } print("just opened log backup file"); open(LOG,"$referer_log.backup") || die "Could not open Referer Log"; while(<LOG>){ $ref = $_; foreach$skip(@skip_pages) { if($ref =~ /$skip/) { $bad =1; } } if(!$bad) { ($test,$testbogus) = split(/\|/,$ref); study($test); $test =~ s/:80//g; $test =~ s/%7E/~/g; $sitecount ="0"; foreach $line(@siteurl) { if($test =~ /$line/) { $test = "$sitedesc[$sitecount]"; $test .= "||$sitename[$sitecount]"; } $sitecount++; } $HASH{"$test"}++; $grandtotal++; } undef($bad); print ".\n"; } close(LOG); print("just closed the logfile"); sub bynumber { $b <=> $a; } foreach$key(keys %HASH) { $line = "$HASH{$key}\::$key"; push(@array,$line); } undef(%HASH); @array = sort bynumber @array; $time = time() - $time; open(SESAME,"header.txt"); @filecontents = <SESAME>; close(SESAME); foreach $line(@filecontents) { $line =~ s/\"/\"/; $line =~ s/\#/\#/; $line =~ s/\?/\?/; $header .= "$line"; } open(SESAME,"footer.txt"); @filecontents = <SESAME>; close(SESAME); foreach $line(@filecontents) { $line =~ s/\"/\"/; $line =~ s/\#/\#/; $line =~ s/\?/\?/; $footer .= "$line"; } $antal ="0"; $rank ="1"; while ($antal < $top) { $part = $array[$antal]; ($total,$referer) = split(/::/,$part); if($total >= $minumum_referals) { if($referer !~ /^http:\/\//){ $data = "$rank"; $data .= "||$referer"; $data .= "||$total"; } else { $data = "$rank"; $data .= "||$referer"; $data .= "||$total"; } push(@Ref_Info,"$data"); } $antal++; $rank++; } if ($userunners eq "1"){ $tempup = "||$runnersurl||Runners Up||?"; push(@Ref_Info,"$tempup"); } &preview; if ($userunners eq "1"){ $runnersrank = ($#Ref_Info + 1); open(FH,">$runnerspath"); print FH "<html><head><title>Runners Up</title></head>\n"; print FH "<body bgcolor=#000000 text=#ffffff>\n"; print FH "<p align=center><b>Runners Up</p>\n"; print FH "<p align=left>\n"; do {print FH "<li>$array[$runnersrank]\n"; $runnersrank++; } until ($runnersrank > $#array); print FH "</p></body></html>\n"; close(FH); } print "<br>File(s) updated<br>You may close this window now..\n"; exit; #__________________________________________________________________ sub preview { &Get_Template; &Get_New_Links; foreach $pages(@html_file){ open(SESAME,"$pages"); @Old_HTML = <SESAME>; close(SESAME); @New_HTML = (""); do { $temp = shift(@Old_HTML); push(@New_HTML,"$temp"); } until ($temp =~ /<!-START->/); push(@New_HTML,"$header"); push(@New_HTML,@NewLines); do { $temp = shift(@Old_HTML); } until ($temp =~ /<!-END->/); push(@New_HTML,"$footer"); push(@New_HTML,"$temp"); push(@New_HTML,@Old_HTML); chmod (0666,$pages); open(SESAME,">$pages"); print SESAME "@New_HTML"; close(SESAME); chmod (0644,$pages); } } #------------------------------ sub Get_HTML { open(SESAME,"$html_file"); @Old_HTML = <SESAME>; close(SESAME); } #-------------------------------- sub Get_New_Links { foreach $line(@Ref_Info){ @content = split(/\|\|/,"$line"); $rank = $content[0]; if ($content[3] eq ""){$content[3] = $content[2]; $content[2] = $c +ontent[1];} $referer = "<a href=\"$content[1]\" target=\"$target\">$content[2] +</a>"; $total = $content[3]; $temp = $template; $temp =~ s/<RANK>/$rank/g; $temp =~ s/<REFERER>/$referer/g; $temp =~ s/<TOTAL>/$total/g; $temp .= "\n"; push(@NewLines,"$temp"); } } #---------------------------------- sub Get_Template { open(SESAME,"$template_file"); @temptemplate = <SESAME>; close(SESAME); foreach $line(@temptemplate){ $template .= "$line"; } } #---------------------------------------

In reply to CGI script loop by Alexx

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (1)
As of 2021-11-30 06:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?