This works well with GoogleGroups Beta service. This helps make links to GoogleGroups with text remotely extracted from usenet topic.
{{{
* 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('', $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, '