Here's the new log parser for OmnomIRC. I'm planning to start open-sourcing components as soon as I'm not totally ashamed of the code in 'em. Regex's are awesome.
<?PHP $sqlConnection = mysql_connect("Omnimaga.org","omnimaga_Netham","-Snip-"); if (!$sqlConnection) die("Could not connect to SQL DB."); if (!mysql_select_db("omnimaga_forums",$sqlConnection)) die('Invalid query: ' . mysql_error());
function sql_query() { global $sqlConnection; $params = func_get_args(); $query = $params[0]; $args = Array(); for ($i=1;$i<count($params);$i++) $args[$i-1] = mysql_real_escape_string($params[$i],$sqlConnection); $result = mysql_query(vsprintf($query,$args),$sqlConnection); if (!$result) die(mysql_error()); return $result; }
function postMessage($Poster,$Topic,$tID,$mID,$board) { $frBoards = array('101','105','169','171'); $adminBoards = array('68','3','44'); $boardsToExclude = array('2','20','69','125','172','173'); if (in_array($board,$boardsToExclude)) return false; if (in_array($board,$frBoards)) { $WriteLine = sprintf("12(O)10 Nouveau message par03 %s10 dans04 %s12 http://omniurl.tk/%s/%s\n",$Poster,$Topic,$tID,$mID); $fileName = "c:\\Omnimaga IRC Spybot\\fposts"; } else if (in_array($board,$adminBoards)) { $WriteLine = sprintf("12(O)10 New post by03 %s10 in04 %s12 http://omniurl.tk/%s/%s\n",$Poster,$Topic,$tID,$mID); $fileName = "c:\\Omnimaga IRC Spybot\\aposts"; } else { $WriteLine = sprintf("12(O)10 New post by03 %s10 in04 %s12 http://omniurl.tk/%s/%s\n",$Poster,$Topic,$tID,$mID); $fileName = "c:\\Omnimaga IRC Spybot\\posts"; } $fp = fopen($fileName, 'w'); fwrite($fp,$WriteLine); fclose($fp); }
$curMID = 0;
while(true) { usleep(1000000); $message = mysql_fetch_array(sql_query("SELECT `id_msg`,`id_topic`,`posterName` FROM `omnitempboard_messages` WHERE id_msg = (SELECT MAX(`id_msg`) FROM `omnitempboard_messages`)")); $mID = $message['id_msg'];
$topic = mysql_fetch_array(sql_query("SELECT `id_board`,`id_first_msg` FROM `omnitempboard_topics` WHERE `id_topic` = %s",$tID)); $tBoard = $topic['id_board']; $tFirstID = $topic['id_first_msg'];
$fMessage = mysql_fetch_array(sql_query("SELECT `subject` FROM `omnitempboard_messages` WHERE `id_msg` = %s",$tFirstID)); $tTopicName = $fMessage['subject']; postMessage($mPoster,$tTopicName,$tID,$mID,$tBoard); echo sprintf("New Post by %s in %s http://omniurl.tk/%s/%s Board ID:%s\n", $mPoster,$tTopicName,$tID,$mID,$tBoard); } ?>
Edit: I suppose I should attach a license to this. Do whatever you want with the code, but I'd like credit somewhere if you use it. If you wish to use it for a corporate or profitable purpose, contact me for permission.
If you look closely at OmnomIRC, you'll see two new links at the top.
One of them will say either "Français" or "English". This will toggle the chat between the English channel and the French channel (#omnimaga and #omnimaga-fr, respectively). With this, French users can now use OmnomIRC to have a conversation in their language of choice!
The other, "Disable OmnomIRC" makes OmnomIRC stop updating, so users who are on slow computers and/or slow internet connections no longer need to be placed in a group that completely disables OmnomIRC.
These settings are both cookie based, so they will not transfer between computers/browsers.
The third update is that I'm now using a different method for getting the messages to my server, so you no longer have to type 5 '\'s to get a single one.
Today's Logs, This Year's logs, and Java chat now all respect the current channel setting, and will forward to the proper page
Edit: If you are just minimizing OmnomIRC to disable it, could you please hit 'Disable' before minimizing it to help reduce load on my server.
UPDATE (23:29): OmnomIRC now supports highlighting. When someone says your nickname, text will show up in bold red color.