Sponsors, FAQ's, and PHPWebsite 9.
Submitted by generic geek on Sat, 2004-03-13 09:47
If you have not noticed, there is a new version of the Who's Online module for PHPWebsite. Hopefully the few issues the earlier version had will be resolved with this new version.
Also, check out our sponsor links on the left column. Don't feel bad if you don't need Viagra for under $3 a pill, it still helps us out! Hopefully, the traffic this site generates will prompt some great technical and geeky sponsors in the near future. It's cheap, so if you want to advertise on this site, there is a link under the Viagra ad just for you!
Finally, I've added another FAQ to the database dealing with Wireless authentication. I'm trying to figure out how to add a list of these FAQ titles to the front page, but the FAQ module for PHPWebsite is a little light on documentation. Oh, if anyone has experience using the Perl DBI module. Dave was nice enough to loan me his O'Reilly "Programming the Perl DBI" book, but either I need more sleep, or I'm just not getting it. Basically, I'm trying to mod the script I am currently using to grab content, but instead of writing the output to a standard HTML file, I want to insert those values into specific tables the PHPWebsite uses, specifically the Announce and Article 2.2 modules. Any help would really be appreciated! Click (Read More) to take a look at the source of the script I use for Fark.com
#!Perl/bin/perl #Original Script written by David Jones for http://www.alljoneses.com #Modified by GenericGeek http://www.genericgeek.com to include the output file lines (the other comments do not mention these output lines # Need to change the above line to reference the correct # path to your perl interpreter
# The following are calls to perl libraries - they should # be part of any recent perl build use strict; use LWP::Simple; use HTML::TokeParser;
# Define the perl html headers - tell the browser the type # of content being displayed print "Content-type: text/html\n\n";
open (OUTPUT,">fark.html"); # Define the HTML header content on the displayed page - the part # above the feed being provided by the source site my $header = " <html> <head> <title>Fark - (Daily Links)</title> <link rel='stylesheet' type='text/css' href='http://www.genericgeek.com/geek.css'> <script language='JavaScript1.2' type='text/javascript' src='http://www.genericgeek.com/geek.js'> </script> <style> BODY { font-style : normal; font-weight : normal; font-size : 11px; font-family : Verdana, Arial, Helvetica, sans-serif; color : #000000; text-decoration : none; }</style> </head> <body style='margin: 0;' class='js'>";
# Define the HTML footer content - the part after the feed my $footer = "</body></html>";
# First - Use LWP::Simple to download the page to get # content from. It needs to be a page directly accessible by # the web server. It will not work if the page is a redirect # or if a cookie is required to see the content. Also, for ASP, # PHP and other dynamic pages, it only gets the code displayed # in a clients browser, not the back-end code used to generate it my $content = get( "http://www.fark.com" ) or die $!;
# Second - Create a TokeParser object using the downloaded HTML my $stream = HTML::TokeParser->new( \$content ) or die $!;
# Declare variables my ($tag, $headline, $src_url, $topic_img, $comments, $comments_url);
# Create a counter variable to track how many $headline topics have # been grabbed and sent to the viewer my $count = 0;
# Send the HTML header to the client print OUTPUT "$header"; print OUTPUT "<div style='background-color:#A7B6C9'><font color=#A7B6C9>.</font></div>";
# Need to find a unique HTML tag from the target page that marks # the start of the HTML code block containing the content to be # grabbed and displayed here. This while loop is repeated for # each instance of this unique HTML tag. # For the top headline... while ( $tag = $stream->get_tag("td") ) {
# If the number of items written is more than 6 (so 7) then # this is the last time through the While and only 7 items # will be sent to the viewer last if ($count>6);
# OK - there may be instances of the same tag used elsewhere # so examine the selected HTML tag for a second indication # that it is the correct tag if ($tag->[1] and $tag->[1] eq 'nilink') {
# Increment count $count++;
# The headline source is in the first <a> tag after the td tag, # so move forward to that point $tag = $stream->get_tag('a');
# Put the contents of the 'href' in $src_url $src_url = $tag->[1] || "--";
# Move to the next table cell in the row $tag = $stream->get_tag('td');
# Move to the topic image in the cell $tag = $stream->get_tag('img');
# Put the contents of the 'src' in $topic_img $topic_img = $tag->[1] || "--";
# Move to the next table cell in the row $tag = $stream->get_tag('td');
# Assign the headline to the $headline variable $headline = $stream->get_trimmed_text('/td');
# Move to the next table cell in the row $tag = $stream->get_tag('td');
# Move to the link to the comments in that cell $tag = $stream->get_tag('a');
# Put the link to the comments in $comments_url $comments_url = $tag->[1] || "--";
# Assign the comments text to the $comments variable $comments = $stream->get_trimmed_text('/a');
# Need to escape all ampersands in the URLs, as they # start entity references in XML $src_url =~ s/&/&/g; $topic_img =~ s/&/&/g; $comments_url =~ s/&/&/g;
# This time through the loop is complete, so take what was # grabbed and send them to the client wrapped in HTML so they show up # right. In this case, need to add style sheet calls, etc. print OUTPUT "<div class="fark-cell" onmouseover=" this.style.background='9999CC'; " onmouseout="this.style.background='#ffffff';"> <div onClick=" javascript:window.open('$src_url','_blank','width=800,height=600,toolbar=yes,location=yes,directories=yes,status=yes,menubar=no,scrollbars=yes,copyhistory=yes,resizable=yes'); "> <IMG SRC="$topic_img" WIDTH=54 HEIGHT=11><br> <b>$headline</b> </div> <a href="#" onClick=" javascript:window.open('$comments_url','blank','width=800,height=600,toolbar=yes,location=yes,directories=yes,status=yes,menubar=no,scrollbars=yes,copyhistory=yes,resizable=yes'); ">$comments comments</a> </div>";
# End of inner If }
# End of While loop for top headline }
# Send the content of the HTML footer to the client
print OUTPUT "$footer";
close (OUTPUT);

