- Code: Select all
;###########################################################
;# Author: Dandy
;# Description: Updates your topic on your channel then news are posted.
;###########################################################
alias checkupdate {
.sockopen dandy.latest %dandy.latest.hostname %dandy.latest.port
}
on *:sockopen:dandy.latest: {
.sockwrite -n dandy.latest HEAD / HTTP/1.1
.sockwrite -n dandy.latest Connection: close
.sockwrite -n dandy.latest Host: %dandy.latest.hostname
.sockwrite -n dandy.latest $crlf
}
on *:sockread:dandy.latest: {
sockread -f %tmp
if ($gettok(%tmp,1,32) == Custom-Latest-Post:) {
var %data = $decode($gettok(%tmp,2,32),m)
var %id = $gettok(%data,1,59)
var %headline = $gettok(%data,2,59)
var %url = $gettok(%data,3,59)
if (%dandy.latest.id != %id) {
set %dandy.latest.id %id
.msg q settopic %dandy.latest.channel %url ~ %headline
}
sockclose $sockname
}
unset %tmp
}
ON *:CONNECT: {
.timer 0 120 .checkupdate
}
The script requires a PHP counterpart that i put into my index.php
- Code: Select all
$latest = mysql_query("SELECT id,headline FROM blog ORDER BY id DESC LIMIT 1");
$lid = mysql_result($latest,0,0);
$lheadline = mysql_result($latest,0,1);
header("Custom-Latest-Post: ".base64_encode(sprintf("%d;%s;http://%s/?id=%d&headline=%s",$lid,$lheadline,$_SERVER['HTTP_HOST'],$lid,$lheadline)));
You might have to change the mysql_query according to your database structure the first field returned must be the id and the second the headline or topic.
The scripts sets a header which is ignored by browsers but the script will read it.
Also in the header you might want to change the url currently it's set to http://yourdomainname.com/?id=<id>&headline=<headline>