In my efforts to ease finding IRC meetings with logs, I created a script to scrape a location that contains daily logs. The script creates an input form to ease changing the important values. The script also displays the portion of log according to the values submitted.
<?php // Set Languague Variables $ordinal = array (0 => "None", 1 => "First", 2 => "Second", 3 => "Third", 4 => "Fourth", 5 => "Fifth", 6 => "Sixth", 7 => "Seventh", 8 => "Eighth", 9 => "Ninth"); $formlab = array ( "file" => "Log File Name: ", "start" => "Start Time: ", "end" => "End Time: ", "skip" => "Skip Value: ", "to" => " to "); // Fetch values via GET and set defaults if not set $page = (isset($_GET['URL'])) ? $_GET['URL']: $page = 'ubuntu-meeting-current.html'; $start = (isset($_GET['st'])) ? $_GET['st'] : $start = 0 ; $end = (isset($_GET['fi'])) ? $_GET['fi'] : $end = 0 ; $repeat = (isset($_GET['sk'])) ? $_GET['sk'] : $repeat = 0 ; // Show form to recieve input on what to do echo ("<form>"); echo ($formlab['file']. "<input type='text' name='URL' value='".$page."'><br/>"); echo ($formlab['start']. "<input type='text' name='st' value='".$start."'> "); echo ($formlab['end']. "<input type='text' name='fi' value='".$end."'><br/>"); echo ($formlab['skip']."<select name='sk'>"); for ($v = 0; $v <10; $v++) { $issel = ($repeat == $v) ? " selected " : ""; echo ("<option value='".$v."'".$issel.">".$ordinal[$v]."</option>"); } echo ("</select><input type='submit' value='Load Log'> </form>"); // Show current values for input echo ("<hr/><h3>".$page."</h3>".$start.$formlab['to'].$end." <br/>"); // Show log portion requested echo "<table>"; $content = file("http://people.ubuntu.com/~fabbione/irclogs/".$page); $read = FALSE; $skip = 0; // Find times within the log and skip to desired time foreach($content as $num=>$line) { if (substr($line,26,5) == $start) { if ( $skip == $repeat ) { $read = TRUE; } $skip++; } if ($read == TRUE) { echo $line; } if (substr($line,26,5) == $end) { break; } } echo "</table>"; ?>
Contact with Questions or Feedback: Send email to tjaustinbardo AT gmail DOT com
modified: June 08, 2007, at 12:41 AM