Warning: fopen(./data/cache/settings/interwiki) [function.fopen]: failed to open stream: Permission denied in /home/newfif/public_html/wg/wireless/wiki.php on line 1488

Warning: fopen(./data/cache/settings/plugins) [function.fopen]: failed to open stream: Permission denied in /home/newfif/public_html/wg/wireless/wiki.php on line 1488

Warning: fopen(./data/cache/settings/urlmapping) [function.fopen]: failed to open stream: Permission denied in /home/newfif/public_html/wg/wireless/wiki.php on line 1488

Warning: Cannot modify header information - headers already sent by (output started at /home/newfif/public_html/wg/wireless/wiki.php:1488) in /home/newfif/public_html/wg/wireless/wiki.php on line 1958
Wireless Working Group: Usenet Macro

Wireless Working Group

UsenetMacro

This works well with GoogleGroups Beta service. This helps make links to GoogleGroups with text remotely extracted from usenet topic.
<?php
/**
 * Copyright 2004 by Gyoung-Yoon Noh <nohmad at sub-port.net>
 * All rights reserved. Distributable under GPL.
 *
 * $Id: UsenetMacro,v 1.13 2005/02/05 03:23:51 root Exp root $
 */

function macro_Usenet($formatter, $value)
{
    global $DBInfo;
    list($group, $thread) = @explode(':', $value);
    $img = sprintf('<img src="%s/google-16.png" alt="GoogleGroups:"'.
                   ' align="middle" hspace="1" />', $DBInfo->imgs_dir);
    if ($group == 'http') {
        $url = $value;
    } else {
        $url = 'http://groups-beta.google.com/group/'.$group;
        if (preg_match('/[[:xdigit:]]+/', $thread))
            $url .= '/browse_thread/thread/'.$thread;
        else
            $subj = $group;
    }
    if (!$subj) {
        $purl = parse_url($url);
        $fp = @fsockopen($purl['host'], 80, $errno, $errstr, 5);
        $out = "GET {$purl['path']} HTTP/1.0\nHost: {$purl['host']}\n\n";
        @fwrite($fp, $out);
        $buf = @fgets($fp, 80);
        if (!preg_match('@200 OK@i', $buf))
            return '<!> URL is not found <!>';
        while (strlen($buf) <= 25000) {
            $_ = @fread($fp, 1024);
            $buf .= $_;
            if (strlen($_) < 1024) break;
        }
        fclose($fp);
        $seek = strpos($buf, '<TR><TD>Subject: <b>') + 20;
        $offset = strpos($buf, '</b></TD></TR>', $seek);
        $subj = substr($buf, $seek, $offset-$seek);
        if (!$subj) $subj = $group;
    }
    return sprintf('%s<a href="%s">%s</a>', $img, $url, $subj);
}
?>

Write like this,
[[Usenet(comp.lang.python)]]
[[Usenet(comp.lang.python:fec2ae850574adf4)]]
[[Usenet(http://groups-beta.google.com/group/comp.unix.programmer/browse_thread/thread/d302919d5af2b802)]]
then it will be displayed like... Usenet Usenet Usenet


[http]http://nohmad.sub-port.net/wiki/CodingLog/2003-09
Retrieved from http://fif.kr/wg/wireless/wiki.php/UsenetMacro
last modified 2017-02-14 03:02:20