<?php
/********************************************************/
/* NSN Your Account                                     */
/* By: NukeScripts Network (webmaster@nukescripts.net)  */
/* http://www.nukescripts.net                           */
/* Copyright © 2000-2004 by NukeScripts Network         */
/* ==================================================== */
/* Based from:                                          */
/* PHP-NUKE: Web Portal System                          */
/********************************************************/
defined('MAXIMUS') or Header("Location: index.php");

    if ($my_headlines == 1 AND ($username == $cookie[1]) AND ($usrinfo['user_password'] == $cookie[2])) {
        br('1');
        Max_OpenTable();
        echo "<center><b>"._MYHEADLINES."</b>";
        br('2');
        echo ""._SELECTASITE."";
        br('2');
        echo "<form action=\"modules.php?name=$module_name\" method=\"post\">";
        echo "<input type=\"hidden\" name=\"op\" value=\"userinfo\">";
        echo "<input type=\"hidden\" name=\"username\" value=\"$username\">";
        echo "<input type=\"hidden\" name=\"bypass\" value=\"$bypass\">";
        echo "<input type=\"hidden\" name=\"url\" value=\"0\">";
        echo "<select name=\"hid\" onChange='submit()'>\n";
        echo "<option value=\"0\">"._SELECTASITE2."</option>";
        $sql4  = "SELECT `hid`, `sitename` FROM `".$prefix."_headlines` ORDER BY `sitename`";
        $headl = $db->sql_query($sql4);
        while($row4    = $db->sql_fetchrow($headl)) {
            $nhid      = $db->XMFnum($row4['hid']);
            $hsitename = stripslashes($row4['sitename']);
            if ($hid == $nhid ) { $sel = "selected"; } else { $sel = ""; }
            echo "<option value=\"$nhid\" $sel>$hsitename</option>\n";
        }
        echo "</select></form>";
        echo ""._ORTYPEURL."";
        br('2');
        echo "<form action=\"modules.php?name=$module_name\" method=\"post\">";
        echo "<input type=\"hidden\" name=\"op\" value=\"userinfo\" />";
        echo "<input type=\"hidden\" name=\"username\" value=\"$username\" />";
        echo "<input type=\"hidden\" name=\"bypass\" value=\"$bypass\" />";
        echo "<input type=\"hidden\" name=\"hid\" value=\"0\" />";
        echo "<input type=\"text\" name=\"url\" size=\"40\" maxlength=\"200\" value=\"http://\" />&nbsp;&nbsp;";
        echo "<input type=\"submit\" value=\""._GO."\" onclick=\"this.form.submit();this.disabled=true;this.value='"._WAITING."'\" /></form>";
        echo "</center><br />";
        if ($hid != 0 OR ($hid == 0 AND $url != "0" AND $url != "http://") AND $url != "") {
            if ($hid != 0) {
                $sql5    = "SELECT `sitename`, `headlinesurl` FROM `".$prefix."_headlines` WHERE `hid`='$hid'";
                $result5 = $db->sql_query($sql5);
                $row5    = $db->sql_fetchrow($result5);
                $nsitename = stripslashes($row5['sitename']);
                $url     = stripslashes($row5['headlinesurl']);
                $title   = $nsitename;
                $siteurl = eregi_replace("http://", "", $url);
                $siteurl = explode("/", $siteurl);
            } else {
                if (!ereg("http://", $url)) {
                    $url = "http://$url";
                }
                $siteurl = eregi_replace("http://", "", $url);
                $siteurl = explode("/", $siteurl);
                $title = "http://$siteurl[0]";
            }
            $rdf = parse_url($url);
            $fp  = fsockopen($rdf['host'], 80, $errno, $errstr, 15);
            if (!$fp) {
                $content = "<center><font class=\"content\">"._RSSPROBLEM."</font></center>";
            }
            if ($fp) {
                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<10;$i++) {
                    $link = ereg_replace(".*<link>","",$items[$i]);
                    $link = ereg_replace("</link>.*","",$link);
                    $title2 = ereg_replace(".*<title>","",$items[$i]);
                    $title2 = ereg_replace("</title>.*","",$title2);
                    if ($items[$i] == "" AND $cont != 1) {
                        $content = "<center>"._RSSPROBLEM."</center>";
                    } else {
                        if (strcmp($link,$title2) AND $items[$i] != "") {
                            $cont = 1;
                            $content .= "<img src=\"images/arrow.gif\" border=\"0\" hspace=\"5\" alt='' /><a href=\"$link\" target=\"new\">$title2</a><br />\n";
                        }
                    }
                }
            }
            if ($content != "") {
                Max_OpenTable2();
                echo "<center><b>"._HEADLINESFROM." <a href=\"http://$siteurl[0]\" target=\"new\">$title</a></b></center><br />";
                echo "$content";
                Max_CloseTable2();
            } elseif (($cont == 0) OR ($content == "")) {
                Max_OpenTable2();
                echo "<center>"._RSSPROBLEM."</center><br />";
                Max_CloseTable2();
            }
            br('1');
        }
        Max_CloseTable();
    }