Difference between revisions of "Rewrite Metadata Validator/SoC 2008/IRC Scanner"

From Creative Commons
Jump to: navigation, search
(Initial writing)
 
m (Syntax highlighting)
Line 1: Line 1:
 
If one wants to search for his or her activity at [[IRC|the IRC channel of Creative Commons]], he or she can use [http://www.google.com/search?&q=john+site%3Ahttp%3A%2F%2Fmirrors.creativecommons.org%2Firc%2Fcc%2F Google] or the following public domain script written in PHP 5:
 
If one wants to search for his or her activity at [[IRC|the IRC channel of Creative Commons]], he or she can use [http://www.google.com/search?&q=john+site%3Ahttp%3A%2F%2Fmirrors.creativecommons.org%2Firc%2Fcc%2F Google] or the following public domain script written in PHP 5:
<pre><?php
+
<source lang="php"><?php
  
 
$nick = 'john';
 
$nick = 'john';
Line 25: Line 25:
 
}
 
}
 
file_put_contents('irrelevant.txt', serialize($irrelevant));
 
file_put_contents('irrelevant.txt', serialize($irrelevant));
echo 'Saved irrelevant.txt', PHP_EOL;</pre>
+
echo 'Saved irrelevant.txt', PHP_EOL;</source>
 
Please note that the herewith enclosed script searches the logs saved the current year. All relevant logs are downloaded to the local machine.
 
Please note that the herewith enclosed script searches the logs saved the current year. All relevant logs are downloaded to the local machine.

Revision as of 09:02, 16 June 2008

If one wants to search for his or her activity at the IRC channel of Creative Commons, he or she can use Google or the following public domain script written in PHP 5: <source lang="php"><?php

$nick = 'john'; $path = 'http://mirrors.creativecommons.org/irc/cc/'; preg_match_all('/%23cc\.'.date('Y').'\-\d\d\-\d\d\.log\.html/', file_get_contents($path), $matches); $irrelevant = array(); if (file_exists('irrelevant.txt')) {

   $irrelevant = unserialize(file_get_contents('irrelevant.txt'));

} foreach ($matches[0] as $url) {

   if (file_exists('relevant/'.($filename = str_replace('%23', , $url)))
    || in_array($filename, $irrelevant)) {
       echo 'Skipped ', $filename, PHP_EOL;
       continue;
   }
   $contents = file_get_contents($path.$url);

if (!strstr($contents, $nick.'<td class="text"')) { echo 'Irrelevant ', $filename, PHP_EOL; $irrelevant[] = $filename; continue; } file_put_contents('relevant/'.$filename, $contents); echo 'Downloaded ', $filename, PHP_EOL; } file_put_contents('irrelevant.txt', serialize($irrelevant)); echo 'Saved irrelevant.txt', PHP_EOL;</source> Please note that the herewith enclosed script searches the logs saved the current year. All relevant logs are downloaded to the local machine.