Author Topic: Various bits of OmnomIRC Source Code  (Read 16706 times)

0 Members and 1 Guest are viewing this topic.

Offline Netham45

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2103
  • Rating: +213/-4
  • *explodes*
    • View Profile
Various bits of OmnomIRC Source Code
« on: April 15, 2011, 06:59:27 am »
Edit: SVN! http://ourl.ca/11696

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.

Log Parser
Spoiler For view_omnom.php:
Code: [Select]
<?PHP
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");  
?>
<link rel="stylesheet" type="text/css" href="http://209.90.113.101/omnimaganoie.css" />
<?PHP
$noShowNames = array("omnomirc","omnimaga","spybot45","spybot46");
function parseColors($colorStr)
{
$colorStr = htmlspecialchars($colorStr);
$colorStr = clickable_links($colorStr);
//$colorStr = preg_replace("/^  &lt;(.+?)&gt;/",'   &lt;<a target="_parent" href="http://www.omnimaga.org/index.php?action=ezportal;sa=page;p=13&userSearch=\1">\1</a>&gt;',$colorStr);
preg_match("/^  &lt;(.+?)&gt;/",$colorStr,$arrayName);
if (count($arrayName) > 0)
{
$colorStr = preg_replace("/^  &lt;(.+?)&gt;/",getOmnomNameColor($arrayName[1]),$colorStr);
}
$lcount = 0;
while(strpos($colorStr,"\x03") > 0)
{
preg_match("/(^.*)\x03([0-9]{1,2}),([0-9]{1,2})(.*)/",$colorStr,$arrayResults);
preg_match("/(^.*)\x03([0-9]{1,2})(.*)/",$colorStr,$arrayResults2);
if(count($arrayResults) > 4) //FG & BG
{
$colorStr = $arrayResults[1].'<span class="fg-'.$arrayResults[2]*1 .'"><span class="bg-'.$arrayResults[3]*1 .'">'.$arrayResults[4];
}
elseif(count($arrayResults2) > 3) //FG Only
{
$colorStr = $arrayResults2[1].'<span class="fg-' . $arrayResults2[2]*1 . '">'.$arrayResults2[3];
}
else //We have a color control character w/o a color, most clients interperet this as clear colors.
{
for($lcount;$lcount;$lcount--)
$colorStr=$colorStr."</span>";
$colorStr = preg_replace("/\x03/","",$colorStr,1);
$lcount--;
}
$lcount++;
}
for(;$lcount>=0;$lcount--)
$colorStr=$colorStr."</span>";
/*Strip codes*/
$colorStr = preg_replace("(\x03|\x02|\x1F|\x09|\x0F)","",$colorStr);
$colorStr = str_replace("\x07","&lt;",$colorStr); // Removes beeps and is functional!
return($colorStr);
}
function clickable_links($text) {
$text = str_replace("http://www.omnimaga.org/","h111://www.omnimaga.org/",$text);
$text = str_replace("http://omniurl.tk/","h111://omniurl.tk/",$text);
$text = eregi_replace('((h111://(www.omnimaga.org/|omniurl.tk))[-a-zA-Z0-9@:;%_+.~#?&//=]+)', '<a target="_parent" href="\1">\1</a>', $text);
$text = eregi_replace('(((f|ht){1}(tp|tps)://)[-a-zA-Z0-9@:;%_+.~#?&//=]+)', '<a target="_blank" href="\1">\1</a>', $text);
$text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:;%_+.~#?&//=]+)', '\1<a target="_blank" href="http://\2">\2</a>', $text);
$text = str_replace("h111","http",$text);
return $text;
}
function getNameColor($name)
{
$rcolors = array(19, 20, 22, 24, 25, 26, 27, 28, 29);
$sum = $i = 0;
while (isset($name[$i]))
$sum += ord($name[$i++]);
$sum %= 9;
return '<span class="uName-'.$rcolors[$sum].'">'.$name.'</span>';
}
function getOmnomNameColor($name)
{
$rcolors = array(19, 20, 22, 24, 25, 26, 27, 28, 29);
$sum = $i = 0;
while (isset($name[$i]))
$sum += ord($name[$i++]);
$sum %= 9;
return '  &lt;<a target="_parent" href="http://www.omnimaga.org/index.php?action=ezportal;sa=page;p=13&userSearch='.$name.'"><span class="uName-'.$rcolors[$sum].'">'.$name.'</span></a>&gt';
}
$myFile = "#" . $_GET["log"] . "." . date("Ymd") . ".log";
$arrayFile = file($myFile);
$count = count($arrayFile);
if (isset($_GET["trim"]))
$startAt = $count - $_GET["trim"];
$topic = $output = "";
$highlight = "\xFF";
if (isset($_GET["high"]))
$highlight = base64_decode($_GET["high"]);
for($i = 0;$i<$count;$i++)
{
$curLine = $arrayFile[$i];
//Try to get the topic
preg_match("/(Topic is|changes topic to) '(.*.)'/",$curLine,$topicGet);
if(count($topicGet))
$topic = $topicGet[2];
if ($i < $startAt) continue;

preg_match("/(^.*)(\[[0-9]{2}:[0-9]{2}:[0-9]{2}\]).\<(.+?)>(.*)/",$curLine,$curLineParts); //Try to match color, timestamp, message, and name
if(count($curLineParts) > 3)
{
$curLineParts[3] = str_replace("@","",$curLineParts[3]);
$curLineParts[3] = str_replace("+","",$curLineParts[3]);
$output = $output . '<span class="irc-date">'.$curLineParts[2].'</span>';
if (strpos(strtolower($curLineParts[4]),strtolower($highlight),in_array(strtolower($curLineParts[3]),$noShowNames)?strpos($curLineParts[4]," ",5):0))
$output = $output . '<span style="font-weight:bold;color:#F44">';
if (!in_array(strtolower($curLineParts[3]),$noShowNames))
{
$output = $output . " &lt;" . getNameColor($curLineParts[3]) . "&gt;";
$curLineParts[4] = str_replace("<","\x07",$curLineParts[4]);
}
$output = $output . parseColors(" ".$curLineParts[1].$curLineParts[4]);
if (strpos($curLineParts[4],$highlight))
$output = $output . '</span>';
}
else
{
preg_match("/(^.*)(\[[0-9]{2}:[0-9]{2}:[0-9]{2}\])(.*)/",$curLine,$curLineParts); //Try to match color, timestamp and message, no name
if(count($curLineParts)>3)
{
$output = $output . '<span class="irc-date">'.$curLineParts[2].'</span>';
$output = $output . parseColors(" ".$curLineParts[1] . $curLineParts[3]);
}
else //Give up and print line
{
$output = $output . parseColors($curLine);
}
}
$output = $output . '<br/>';
}
?>
<span class="irc-topic">Current Topic:<?PHP echo parseColors($topic); ?></span><br/><br/>
<?PHP echo $output; ?>

The CSS for the previous document:
Spoiler For omnimaganoie.css:
Code: [Select]
body, td, th , tr     {font-size: 10px;font-family:verdana,sans-serif;}

.irc-date       {color: #000000;}
.irc-topic     {text-decoration :none;font-size:12;color:#333333;font-family:Arial;border-style:dashed;border-width:1px;width:99%;position:absolute;text-align:center;}
.irc-green     {color: #009200;}
.irc-black     {color: #000000;}
.irc-brown     {color: #7b0000;}
.irc-navy       {color: #00007b;}
.irc-brick     {color: #9c009c;}
.irc-red       {color: #ff0000;}
.irc-teal     {color: #1A5555;}

.fg-white, .fg-0   {color: #FFFFFF;}
.fg-black, .fg-1   {color: #000000;}
.fg-dkBlue, .fg-2   {color: #3636B2;}
.fg-dkgreen, .fg-3   {color: #2A8C2A;}
.fg-red, .fg-4   {color: #C33B3B;}
.fg-dkRed , .fg-5   {color: #C73232;}
.fg-dkPurple, .fg-6   {color: #80267F;}
.fg-orange, .fg-7   {color: #E19317;}
.fg-yellow, .fg-8   {color: #D9A641;}
.fg-green, .fg-9   {color: #3DCC3D;}
.fg-teal, .fg-10 {color: #1A5555;}
.fg-ltBlue, .fg-11 {color: #2F8C74;}
.fg-blue, .fg-12 {color: #4545E6;}
.fg-pink, .fg-13 {color: #B037B0;}
.fg-dkGray, .fg-14 {color: #4C4C4C;}
.fg-ltGray, .fg-15 {color: #959595;}

.bg-white, .bg-0   {}/*Placeholder*/
.bg-black, .bg-1   {background-color: #000000;}
.bg-dkBlue, .bg-2   {background-color: #3636B2;}
.bg-dkgreen, .bg-3   {background-color: #2A8C2A;}
.bg-red, .bg-4   {background-color: #C33B3B;}
.bg-dkRed , .bg-5   {background-color: #C73232;}
.bg-dkPurple, .bg-6   {background-color: #80267F;}
.bg-orange, .bg-7   {background-color: #E19317;}
.bg-yellow, .bg-8   {background-color: #D9A641;}
.bg-green, .bg-9   {background-color: #3DCC3D;}
.bg-teal, .bg-10 {background-color: #1A5555;}
.bg-ltBlue, .bg-11 {background-color: #2F8C74;}
.bg-blue, .bg-12 {background-color: #4545E6;}
.bg-pink, .bg-13 {background-color: #B037B0;}
.bg-dkGray, .bg-14 {background-color: #4C4C4C;}
.bg-ltGray, .bg-15 {background-color: #959595;}
Spoiler For Spybot45 code:
Code: (Spybot45.php) [Select]
<?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'];

if ($mID == $curMID)
continue;

$curMID = $mID;

$tID = $message['id_topic'];
$mPoster = $message['posterName'];

$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.
« Last Edit: June 19, 2011, 11:56:05 pm by Netham45 »
Omnimaga Admin

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Various bits of OmnomIRC Source Code
« Reply #1 on: April 15, 2011, 07:56:59 am »
That's good Netham45, I love open source, but why put the code in spoilers, though? It's hard to read :P

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Various bits of OmnomIRC Source Code
« Reply #2 on: April 15, 2011, 03:34:03 pm »
Yay, this is nice! Thanks Netham :)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Various bits of OmnomIRC Source Code
« Reply #3 on: April 15, 2011, 04:55:54 pm »
Nice! Are you planning to eventually release SpyBot45 as a SMF hack?

Hopefully people can maybe help on changing stuff or adding features too.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Various bits of OmnomIRC Source Code
« Reply #4 on: April 15, 2011, 04:56:58 pm »
Nice! Are you planning to eventually release SpyBot45 as a SMF hack?

Hopefully people can maybe help on changing stuff or adding features too.

That would be a great idea, lots of downloads I'm sure!

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: Various bits of OmnomIRC Source Code
« Reply #5 on: April 16, 2011, 12:09:35 am »
Yep, can't wait to see the entire source code :D

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline Netham45

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2103
  • Rating: +213/-4
  • *explodes*
    • View Profile
Re: Various bits of OmnomIRC Source Code
« Reply #6 on: May 05, 2011, 03:10:47 am »
Here's the interesting parts to iOmnom Mini (Note that this code was written in somewhat of a hurry, so the names of the files don't quite make sense, and I haven't refined the code.)


This only exists to be the target for the frame(holding the content div), and to handle the callback function.
Spoiler For chat.php:
Code: [Select]
<?PHP
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
?>
<html>
<head>
<title>chat</title>
<script type="text/javascript">
function callback(text)
{
document.getElementById("content").innerHTML = atob(text);
}
</script>
</head>
<body onload="window.location.hash='bottom';">
<div id="content">
<?PHP
define(SMF,"Yup.",true);
include("../Sources/Subs-Package.php");
$theURL = "http://209.90.113.101/IRC/EFNet/view_omnom.php?log=omnimaga&current=true&trim=17";
if (isset($_GET['high']))
$theURL = $theURL . "&high=" . $_GET['high'];
$contents = fetch_web_data($theURL);
echo $contents;
?>
</div>
<a name="bottom"/>
<script type="text/javascript" src="chat2.php">
</script>
</body>
</html>

This is where the real magic happens.

This page sleeps for 5 seconds on every request. It then sends the current chat view, and a bit of javascript to make another script tag to call itself again. That way it keeps a constant connection open, bypassing Opera Mini (and apparently the PSP's browser, according to Frey) limitations of no streaming AJAX and no programmatic refreshing.

Spoiler For chat2.php:
Code: [Select]
<?PHP
header('Content-type: text/javascript');
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
sleep(5);
define(SMF,"Yup.",true);
include("../Sources/Subs-Package.php");
$theURL = "http://209.90.113.101/IRC/EFNet/view_omnom.php?log=omnimaga&current=true&trim=17";
if (isset($_GET['high']))
$theURL = $theURL . "&high=" . $_GET['high'];
$contents = fetch_web_data($theURL);
echo 'callback("'.base64_encode($contents).'");';
?>
var head= document.getElementsByTagName('head')[0];
var script= document.createElement('script');
script.type= 'text/javascript';
script.src= 'chat2.php?uid=<?PHP echo gmdate("DdMYH:i:s");?>';
head.appendChild(script);
window.location.hash='a';
window.location.hash='bottom';

This one was altered from the live code to remove the signature generation code. It just handles the form for sending a message and creates the frame for chat.php.

It also handles logging in if you're not already.
Spoiler For index.php:
Code: [Select]
<?PHP
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
require(dirname(__FILE__) . '/../SSI.php');

?>
<html>
<head>
<title>iOmnom Mini</title>
</head>
<body>
<?PHP
if ($user_info['is_guest'])
{
ssi_login("http://www.omnimaga.org/iOmnom_Mini/index.php");
}
else
{
function sign($encstr) {
return "lolnope";
}
echo '
<script type="text/javascript">

</script>
<iframe src="chat.php#bottom" style="width:100%;height:75%;border:0;" scrolling="no" border=0>Please use a browser that supports frames.</iframe>
<form action="messagebounce.php">
<input type="hidden" name="name" value="'.$user_info[name].'"/>
<input type="hidden" name="chan" value="omnimaga"/>
<input type="hidden" name="signature" value="'.sign($user_info[name]).'"/>
<input type="text" name="message" maxlength=100 style="width:100%;height:10%;"/><br/>
<input type="Submit" value="Send" style="width:100%;height:10%;"/>
</form>
';
}
?>
</body>
</html>

This is just what sends the message to my server. Pretty simple.
Spoiler For messagebounce.php:
Code: [Select]
<?php
define
(SMF,"Yup.",true);
include(
"../Sources/Subs-Package.php");
fetch_web_data("http://209.90.113.101/irc/EFNet/message.php?message=" base64_encode(urldecode(stripslashes($_GET["message"]))) . "&signature=" $_GET["signature"] . "&name=" base64_encode(urldecode(stripslashes($_GET["name"]))) . "&chan=" $_GET["chan"]);
header("location:index.php");
?>

« Last Edit: May 05, 2011, 03:13:50 am by Netham45 »
Omnimaga Admin

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Various bits of OmnomIRC Source Code
« Reply #7 on: May 05, 2011, 03:21:05 am »
Very nice! Thanks for the code :D

Offline Netham45

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2103
  • Rating: +213/-4
  • *explodes*
    • View Profile
Re: Various bits of OmnomIRC Source Code
« Reply #8 on: May 10, 2011, 02:35:33 pm »
New Spybot45 code posted. :D
Omnimaga Admin

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Various bits of OmnomIRC Source Code
« Reply #9 on: May 12, 2011, 04:09:44 am »
This is nice that you are documenting/open-sourcing OmnomIRC. Hopefully maybe the idea can be re-implemented elsewhere.

Offline ruler501

  • Meep
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2475
  • Rating: +66/-9
  • Crazy Programmer
    • View Profile
Re: Various bits of OmnomIRC Source Code
« Reply #10 on: May 12, 2011, 08:43:30 am »
Who knows maybe more forums will start having their own IRC channel you can talk in at the top.

I love that your open sourcing this.
I currently don't do much, but I am a developer for a game you should totally try out called AssaultCube Reloaded download here https://assaultcuber.codeplex.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y

Offline Netham45

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2103
  • Rating: +213/-4
  • *explodes*
    • View Profile
Re: Various bits of OmnomIRC Source Code
« Reply #11 on: May 12, 2011, 10:13:27 pm »
I woulda open-sourced the old one if the code wasn't so ugly. :P


mIRC bot! Using http://reko.tiira.net/mmysql/ for SQL connectivity.

Code: (aliases) [Select]
/sql_config {
  set %db omnomirc
  set %server -snip-
  set %uname -snip-
  set %pass -snip-
}
/sql_connect {
  if (%connection) echo Already connected! Not trying again.
  if (!%connection)  {
    sql_config
    set %connection $mysql_connect( %server , %uname , %pass )
    echo $iif(%connection,Connected Successfully,Failed to connect)
    echo $iif($mysql_select_db( %connection , %db ),DB Selected correctly!,Failed to select DB!)
  }
}
/sql_close {
  noop $mysql_close(%connection)
}
/sql_clean {
  var %sql SELECT MAX(line_number) FROM irc_lines
  var %result $mysql_query(%connection,%sql)
  noop $mysql_fetch_row(%result,row)
  set %lines $hget(row,1)
  set %sql DELETE * FROM irc_lines WHERE line_number < ?
  noop $mysql_exec(%connection, $calc(%lines-1000))
}

/update_names {
  if (!%connection)  sql_connect
  noop $mysql_exec(%connection, DELETE FROM irc_users)
  set %sql INSERT INTO irc_users (username,channel,online) VALUES (?,?,0)
  set %nickpos 1
  while ( %nickpos <= $nick( #omnimaga-test , 0 , a )) {
    noop $mysql_exec( %connection , %sql , $nick( $chan , %nickpos , a ) , #omnimaga-test )
    inc %nickpos 1
  }
}

/check_messages {
  if (!%connection) sql_connect
  var %sql = SELECT * FROM irc_outgoing_messages
  var %res = $mysql_query(%connection,%sql)
  while ($mysql_fetch_row(%res,row)) {
    if ($hget(row,action) == 0)    msg $hget(row, channel) < $+ $hget(row,nick) $+ > $hget(row,message)
    if ($hget(row,action) == 1)    msg $hget(row, channel) 6* $hget(row,nick) $hget(row,message)

  }
  var %sql = DELETE FROM irc_outgoing_messages
  noop $mysql_exec(%connection,%sql)
}
Code: (remote) [Select]
on *:TEXT:*:#:{
  if (!%connection)  sql_connect
  set %sql INSERT INTO irc_lines (name1,message,type,channel,time) VALUES (?,?,?,?,?)
  noop $mysql_exec(%connection,%sql,$nick,$1-,message,$chan,$chr(91) $+ $asctime(HH:nn:ss) $+ $chr(93))
}
on *:ACTION:*:#:{
  if (!%connection)  sql_connect
  set %sql INSERT INTO irc_lines (name1,message,type,channel,time) VALUES (?,?,?,?,?)
  noop $mysql_exec(%connection,%sql,$nick,$1-,action,$chan,$chr(91) $+ $asctime(HH:nn:ss) $+ $chr(93))
}
on *:JOIN:#:{
  if (!%connection)  sql_connect
  set %sql INSERT INTO irc_lines (name1,type,channel,time) VALUES (?,?,?,?)
  noop $mysql_exec(%connection,%sql,$nick,join,$chan,$chr(91) $+ $asctime(HH:nn:ss) $+ $chr(93))
}

on *:PART:#:{
  if (!%connection)  sql_connect
  set %sql INSERT INTO irc_lines (name1,type,channel,time) VALUES (?,?,?,?)
  noop $mysql_exec(%connection,%sql,$nick,part,$chan,$chr(91) $+ $asctime(HH:nn:ss) $+ $chr(93))
}
on *:QUIT:{
  if (!%connection)  sql_connect
  set %sql INSERT INTO irc_lines (name1,message,type,channel,time) VALUES (?,?,?,?,?)
  noop $mysql_exec(%connection,%sql,$nick,$1-,quit,$chan,$chr(91) $+ $asctime(HH:nn:ss) $+ $chr(93))
}

on *:RAWMODE:#:{
  if (!%connection)  sql_connect
  set %sql INSERT INTO irc_lines (name1,message,type,channel,time) VALUES (?,?,?,?,?)
  noop $mysql_exec(%connection,%sql,$nick,$1-,mode,$chan,$chr(91) $+ $asctime(HH:nn:ss) $+ $chr(93))
}

on *:KICK:#:{
  if (!%connection)  sql_connect
  set %sql INSERT INTO irc_lines (name1,name2,message,type,channel,time) VALUES (?,?,?,?,?,?)
  noop $mysql_exec(%connection,%sql,$nick,$knick,$1-,kick,$chan,$chr(91) $+ $asctime(HH:nn:ss) $+ $chr(93))
}
on *:NICK:{
  if (!%connection)  sql_connect
  set %sql INSERT INTO irc_lines (name1,name2,message,type,channel,time) VALUES (?,?,?,?,?,?)
  noop $mysql_exec(%connection,%sql,$nick,$newnick,$1-,nick,$chan,$chr(91) $+ $asctime(HH:nn:ss) $+ $chr(93))
}
on *:TOPIC:#:{
  if (!%connection)  sql_connect
  set %sql INSERT INTO irc_lines (name1,message,type,channel,time) VALUES (?,?,?,?,?)
  noop $mysql_exec(%connection,%sql,$nick,$1-,topic,$chan,$chr(91) $+ $asctime(HH:nn:ss) $+ $chr(93))
}
Omnimaga Admin

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Various bits of OmnomIRC Source Code
« Reply #12 on: May 13, 2011, 04:03:45 pm »
Is that for IRC logs? I didn't know OmnomIRC now used its own MySQL database.

Offline ruler501

  • Meep
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2475
  • Rating: +66/-9
  • Crazy Programmer
    • View Profile
Re: Various bits of OmnomIRC Source Code
« Reply #13 on: May 13, 2011, 06:17:12 pm »
I can't understand any of that code. i only program Python and C/C++
I currently don't do much, but I am a developer for a game you should totally try out called AssaultCube Reloaded download here https://assaultcuber.codeplex.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y

Offline Netham45

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2103
  • Rating: +213/-4
  • *explodes*
    • View Profile
Re: Various bits of OmnomIRC Source Code
« Reply #14 on: May 13, 2011, 06:19:11 pm »
Is that for IRC logs? I didn't know OmnomIRC now used its own MySQL database.

The IRC logs are still using files, same as before. OmnomIRC is using SQL, because it was considerably easier than keeping track of things in files, and should yield higher performance over time.
Omnimaga Admin