FAQ/Help |
Calendar |
Search |
Member
Member Since Aug 2001
Location: Sweden, Stockholm
Posts: 40
23 |
#1
I tried the pod logging and I noticed it logged not just searches, but also every click
in the directory (as a search for nothing). I don't know if this was the purpose of the script, but it wasn't what I wanted. Suggestion, change the line: if (defined($pod_logging)) { &pod_log_search($pod_cgi_search); } to: if ((defined($pod_logging)) and (defined($pod_cgi_search))) { &pod_log_search($pod_cgi_search); } kindly /BeRKA |
Reply With Quote |
Member
Member Since Aug 2001
Location: Sweden, Stockholm
Posts: 40
23 |
#2
#!/usr/bin/perl
############################################################################# ## Configuration area ## ## Full or relative path to log-file $pod_logging = "../pod_searches.log"; ## ## Number of lines to print $no_lines = 5; ## ## Number of characters (in each line) to print $no_char = 25; ############################################################################# use CGI qw(:all); print header; print "<B>Latest Searches:</B><BR>\n"; # # Total lines if (-e "$pod_logging") { open (CL, "$pod_logging"); while (<CL> { $totallines++ } close (CL); } # Read file $startdata = $totallines - $no_lines; if (-e "$pod_logging") { open (TL, "$pod_logging"); for ($count = 0; $count < $totallines; $count += 1) { $line = <TL>; if ($count >= $startdata) { chomp $line; $lastline[$count - $startdata] = $line; } } close (TL); } # Cleanup data and print it. for ($clean = 0; $clean < $no_lines; $clean += 1) { $lastline[$clean] = substr($lastline[$clean], 12, $no_char+1); @lastlinetemp = split(/\&/, $lastline[$clean]); $lastline[$clean] = $lastlinetemp[0]; if (length($lastline[$clean]) > $no_char) { $lastline[$clean] = $lastline[$clean]."..."; } print $lastline[$clean]."<BR>\n"; } Comment: There might be some errors that I have not spotted in this since I had to change every +,>,< to make them visible in this post... To see this script in action, go to http://www.berka.com/ |
Reply With Quote |
Member
Member Since Aug 2001
Location: Sweden, Stockholm
Posts: 40
23 |
#3
The above code works, but to make it even better You might want to add 2 things.
To remove "plus" which are ugly, and control characters that can mess up the listing, add this line in the cleanup part of the above code: $lastlinetemp[0] =~ s/\W/ /g; To remove other non searches You can add the following line in the pod.cgi in the "pod_log_search" subroutine to stop it from being logged: unless (($pod_searchwords eq "0") or ($pod_searchwords =~ "1") or ($pod_searchwords =~ "26") or ($pod_searchwords =~ "76") or ($pod_searchwords =~ "cgi-bin")) |
Reply With Quote |
Member
Member Since Aug 2001
Location: Sweden, Stockholm
Posts: 40
23 |
#4
Some more non-searches to remove,
and just to see who searches for preteen and lolita, lets log his IP: unless (($pod_searchwords eq "0") or ($pod_searchwords =~ "1") or ($pod_searchwords =~ "26") or ($pod_searchwords =~ "76") or ($pod_searchwords =~ "cgi-bin") or ($pod_searchwords =~ "^\&") or ($pod_searchwords =~ "^\/")) { open (WRITEIT, ">>$pod_logging"); flock(WRITEIT, LOCK_EX); print WRITEIT "$datej|$pod_searchwords\&$ENV{'REMOTE_ADDR'}\n"; close(WRITEIT); } |
Reply With Quote |
Reply |
|
Similar Threads | ||||
Thread | Forum | |||
trouble logging in | Community Feedback & Technical Support | |||
trouble logging in | Other Mental Health Discussion | |||
Weird Bug On Logging In | Community Feedback & Technical Support | |||
logging in | Community Feedback & Technical Support | |||
I'm getting into the site without logging in! | Community Feedback & Technical Support |