4 Dec 2008
Lenon.com
Home Account Forums Downloads Web Links

'Drudge Report DSL' News Block
 
       Lenon.com Forum Index » This Site     View previous topic :: View next topic  
Author Message
VinDSL
Site Admin
Site Admin


Joined: Apr 03, 2003
Posts: 68
Location: Arizona (USA) Admin/mod: Disipal Designs Admin/mod: Nuke Cops

Posted: Mon Sep 13, 2004 7:59 am    Post subject: 'Drudge Report DSL' News Block Reply with quote

techizedek wrote:
Hi Vin,

I am interested in your `Drudge Report` News Block ....

Matt Drudge's News is probably the only news I would prefer over GooGle 's `robot regement` ...

...just want to keep it `fair and balanced` of course ...

please consider breaking off some code , for a brother ...

techizedek


Heh! My pleasure!

I love the Drudge Report! Luckily, that's an easy one...

All you do is go into 'Blocks' in the 'Admin Panel' and add 'RSS/RDF' content and name it "Drudge Report DSL" or whatever. I set it up to update hourly.


It's a single line of code...

Code:

http://myrss.com/f/d/r/drudgereport78oxhc1.rss



Then, I hacked 'mainfile.php' so it will allow 15 news stories instead of defaulting to 10. I got rid of the irritating 'MORE...' link at the bottom of the block too, while I was at it. And, I also patched the 'otime' bug in the code. You may, or may not, have this bug, depending on the version of Nuke you run. I still run PHP-Nuke 6.5 Final, patched and mod'ed of course.


Here's the hacked section...

Code:

function headlines($bid, $cenbox=0) {
    global $prefix, $db;
    $bid = intval($bid);
    $row = $db->sql_fetchrow($db->sql_query("SELECT title, content, url, refresh, time FROM ".$prefix."_blocks WHERE bid='$bid'"));
    $title = $row['title'];
    $content = $row['content'];
    $url = $row['url'];
    $refresh = intval($row['refresh']);
    $otime = $row['time'];                                  // Patch by VinDSL
    $past = time()-$refresh;
    if ($otime < $past) {
    $btime = time();
    $rdf = parse_url($url);
    $fp = fsockopen($rdf['host'], 80, $errno, $errstr, 15);
    if (!$fp) {
        $content = "";
        $db->sql_query("UPDATE ".$prefix."_blocks SET content='$content', time='$btime' WHERE bid='$bid'");
        $cont = 0;
        if ($cenbox == 0) {
        themesidebox($title, $content);
        } else {
        themecenterbox($title, $content);
        }
        return;
    }
    if ($fp) {
        if ($rdf['query'] != '')
            $rdf['query'] = "?" . $rdf['query'];

        fputs($fp, "GET " . $rdf['path'] . $rdf['query'] . " HTTP/1.0\r\n");
        fputs($fp, "HOST: " . $rdf['host'] . "\r\n\r\n");
        $string    = "";
        while(!feof($fp)) {
            $pagetext = fgets($fp,300);
            $string .= chop($pagetext);
        }
        fputs($fp,"Connection: close\r\n\r\n");
        fclose($fp);
        $items = explode("</item>",$string);
        $content = "<font class=\"content\">";
        for ($i=0;$i<15;$i++) {                             // Hack by VinDSL
        $link = ereg_replace(".*<link>","",$items[$i]);
        $link = ereg_replace("</link>.*","",$link);
        $title2 = ereg_replace(".*<title>","",$items[$i]);
        $title2 = ereg_replace("</title>.*","",$title2);
        $title2 = stripslashes($title2);
        if ($items[$i] == "" AND $cont != 1) {
            $content = "";
            $db->sql_query("UPDATE ".$prefix."_blocks SET content='$content', time='$btime' WHERE bid='$bid'");
            $cont = 0;
            if ($cenbox == 0) {
            themesidebox($title, $content);
            } else {
            themecenterbox($title, $content);
            }
            return;
        } else {
            if (strcmp($link,$title2) AND $items[$i] != "") {
            $cont = 1;
            $content .= "<strong><big>&middot;</big></strong><a href=\"$link\" target=\"new\">$title2</a><br>\n";
            }
        }
        }

    }
    $db->sql_query("UPDATE ".$prefix."_blocks SET content='$content', time='$btime' WHERE bid='$bid'");
    }
    $siteurl = ereg_replace("http://","",$url);
    $siteurl = explode("/",$siteurl);
    if (($cont == 1) OR ($content != "")) {
//  $content .= "<br><a href=\"http://$siteurl[0]\" target=\"blank\"><b>"._HREADMORE."</b></a></font>";     // Hack by VinDSL
    } elseif (($cont == 0) OR ($content == "")) {
    $content = "<font class=\"content\">"._RSSPROBLEM."</font>";
    }
    if ($cenbox == 0) {
    themesidebox($title, $content);
    } else {
    themecenterbox($title, $content);
    }
}



That's about it! Wink
_________________
.::Buds not bombs::.
Back to top
View user's profile Send private message Visit poster's website
Author Message
VinDSL
Site Admin
Site Admin


Joined: Apr 03, 2003
Posts: 68
Location: Arizona (USA) Admin/mod: Disipal Designs Admin/mod: Nuke Cops

Posted: Mon Sep 13, 2004 10:27 am    Post subject: Reply with quote

I just added scrolling. If you like that better, here's the hack...

Code:

function headlines($bid, $cenbox=0) {
    global $prefix, $db;
    $bid = intval($bid);
    $row = $db->sql_fetchrow($db->sql_query("SELECT title, content, url, refresh, time FROM ".$prefix."_blocks WHERE bid='$bid'"));
    $title = $row['title'];
    $content = $row['content'];
    $url = $row['url'];
    $refresh = intval($row['refresh']);
    $otime = $row['time'];
    $past = time()-$refresh;                                // Patch by VinDSL
    if ($otime < $past) {
    $btime = time();
    $rdf = parse_url($url);
    $fp = fsockopen($rdf['host'], 80, $errno, $errstr, 15);
    if (!$fp) {
        $content = "";
        $db->sql_query("UPDATE ".$prefix."_blocks SET content='$content', time='$btime' WHERE bid='$bid'");
        $cont = 0;
        if ($cenbox == 0) {
        themesidebox($title, $content);
        } else {
        themecenterbox($title, $content);
        }
        return;
    }
    if ($fp) {
        if ($rdf['query'] != '')
            $rdf['query'] = "?" . $rdf['query'];

        fputs($fp, "GET " . $rdf['path'] . $rdf['query'] . " HTTP/1.0\r\n");
        fputs($fp, "HOST: " . $rdf['host'] . "\r\n\r\n");
        $string    = "";
        while(!feof($fp)) {
            $pagetext = fgets($fp,300);
            $string .= chop($pagetext);
        }
        fputs($fp,"Connection: close\r\n\r\n");
        fclose($fp);
        $items = explode("</item>",$string);
        $content = "<font class=\"content\">";
        for ($i=0;$i<15;$i++) {                             // Hack by VinDSL
        $link = ereg_replace(".*<link>","",$items[$i]);
        $link = ereg_replace("</link>.*","",$link);
        $title2 = ereg_replace(".*<title>","",$items[$i]);
        $title2 = ereg_replace("</title>.*","",$title2);
        $title2 = stripslashes($title2);
        if ($items[$i] == "" AND $cont != 1) {
            $content = "";
            $db->sql_query("UPDATE ".$prefix."_blocks SET content='$content', time='$btime' WHERE bid='$bid'");
            $cont = 0;
            if ($cenbox == 0) {
            themesidebox($title, $content);
            } else {
            themecenterbox($title, $content);
            }
            return;
        } else {
            if (strcmp($link,$title2) AND $items[$i] != "") {
            $cont = 1;
            $content .= "<strong><big>&middot;</big></strong><a href=\"$link\" target=\"new\">$title2</a><br>\n";
            }
        }
        }

    }
    $db->sql_query("UPDATE ".$prefix."_blocks SET content='$content', time='$btime' WHERE bid='$bid'");
    }
    $siteurl = ereg_replace("http://","",$url);
    $siteurl = explode("/",$siteurl);
    if (($cont == 1) OR ($content != "")) {
//  $content .= "<br><a href=\"http://$siteurl[0]\" target=\"blank\"><b>"._HREADMORE."</b></a></font>";     // Hack by VinDSL
    } elseif (($cont == 0) OR ($content == "")) {
    $content = "<font class=\"content\">"._RSSPROBLEM."</font>";
    }
    if ($cenbox == 0) {
        $content = "
        <marquee behavior=\"scroll\"
        direction=\"up\" height=\"175\"
        scrollamount=\"2\"
        scrolldelay=\"100\"
        onmouseover='this.stop()'
        onmouseout='this.start()'>\n$content</marquee>";    // Hack by VinDSL
    themesidebox($title, $content);
    } else {
    themecenterbox($title, $content);
    }
}


_________________
.::Buds not bombs::.
Back to top
View user's profile Send private message Visit poster's website
Author Message
techizedek
Newbie
Newbie


Joined: Jul 30, 2004
Posts: 1

Posted: Sun Sep 26, 2004 1:28 am    Post subject: Reply with quote

Thanks VinDSL,


I initially debated posting the request here in the forums, but I didn't know how wide spread you might want to see `Drudge News` on `nuke sites`. So I sent the message.

Well, `when in doubt` ...

I guess I should have posted it here, you might have seen it sooner. Of course, after I sent you the message, I found (.rss) feeds buried on the `Drudge Report` site.

So I started thinking, VinDSL going to ` know `, I am an idiot. However, I was pretty sure your's had some sleek and salient code associated with it, that would still be a bit of a stretch for my simple `plug the (.rss) feed in the block` approach.

So again much appreciation, I will be able to learn a lot more from your code above. Additionally, I appreciate you adding the scrolling, it probably gets abused on my site, but if their is a long list of available items, I prefer a smaller block that scrolls, showing the diversity of options. Of course, I can add a marquee to any block, but mine are a bit clumsy, witness one I created to `spreadfirefox `dot` com`.

I was using the `google` news `rc2`, by the time I realized there was an `rc3` `cphdesigns` was defunct, and I couldn't find anyone on the web with `rc3`, the one at warpspeed `dot` 4thdimension `dot` de appears to have some problems.

The only reason I even bother to mention this here on your forum, is because `rc2 (don't know about rc3)` has a pretty interesting ability to read a given web page (similar to you or I) and create it's own images, links and headlines, plus the guy had gone to the trouble of controling the `blocks` and `news sections` with a `database`.

So if anyone is interested in this code for reading a web page, reply here, I was never able to revise to work with the latest `google` format, but I am sure some of you could, it really couldn't be very hard, I am sure I am doing something very simple wrong, it's just a matter of re - directing to `new` web addresses, and re - arranging the order of what it reads and how it processes ...

Anyway, I was using `google`, in an effort to be ` fair and balanced `, since stories are supposedly rated by a `computer equation`, but `Drudge Report` will provide `news` the `corporate conglomerates` won't touch ...

thanks agin, for your assistance ...

techizedek
Back to top
View user's profile Send private message
Display posts from previous:   
       Lenon.com Forum Index » This Site All times are GMT - 5 Hours
Page 1 of 1
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB 2.0.19 © 2002, 2007 phpBB Group
FlowControl Forums Theme by Disipal Designs

Copyright 1996-2008 - Lenon.com - All Rights Reserved.

This Website is Powered by an Enhanced Version of PHP-Nuke
The Most Advanced Content Management System in the World.

Script generation time: -1.5808 seconds  (PHP 101% - MySQL -1%)
Queries: 19 | Views last 5 mins: 109 | Server load: Adequate  (1.4)
Disipal Designs