예제 #1
0
 function Render($id)
 {
     $feed = $this->GetFeed($id);
     if (count($feed) <= 0) {
         return false;
     }
     $out = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
     $out .= "<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n";
     $out .= "<channel>\n";
     $out .= "<title><![CDATA[";
     if ($feed['feedname'] != "") {
         $out .= $feed['feedname'];
     } else {
         $out .= "FreeNATS RSS Feed";
     }
     $out .= "]]></title>\n";
     $me = GetAbsolute("rss.php?feed=" . $_REQUEST['feed']);
     $out .= "<link>" . $me . "</link>\n";
     $out .= "<atom:link href=\"" . $me . "\" rel=\"self\" type=\"application/rss+xml\" />\n";
     $out .= "<description>FreeNATS RSS Feed</description>\n";
     $out .= "<lastBuildDate>" . date("D, d M Y H:i:s") . " GMT</lastBuildDate>\n";
     $out .= "<language>en-us</language>\n";
     switch ($feed['feedtype']) {
         case "all":
             $nodes = $this->NATS->GetNodes();
             break;
         case "node":
             $nodes = array();
             $nodes[]['nodeid'] = $feed['typeopt'];
             break;
         case "group":
             $nodes = array();
             $q = "SELECT nodeid FROM fngrouplink WHERE groupid=" . ss($feed['typeopt']);
             $r = $this->NATS->DB->Query($q);
             while ($row = $this->NATS->DB->Fetch_Array($r)) {
                 $nodes[] = $NATS->GetNode($row['nodeid']);
             }
             $this->NATS->DB->Free($r);
             break;
         default:
             $nodes = array();
     }
     $inlist = "";
     $first = true;
     foreach ($nodes as $node) {
         if ($first) {
             $first = false;
         } else {
             $inlist .= ",";
         }
         $inlist .= "\"" . ss($node['nodeid']) . "\"";
     }
     $alerts = array();
     switch ($feed['feedrange']) {
         case "xdays":
             if (!is_numeric($feed['rangeopt'])) {
                 $days = 30;
             } else {
                 $days = $feed['rangeopt'];
             }
             $secs = $days * 24 * 60 * 60;
             $from = time() - $secs;
             $q = "SELECT * FROM fnalert WHERE (closedx=0 OR closedx>" . $from . ") AND nodeid IN (" . $inlist . ") ORDER BY LENGTH(closedx) ASC, closedx DESC";
             break;
         case "xalerts":
             if (!is_numeric($feed['rangeopt'])) {
                 $acount = 30;
             } else {
                 $acount = $feed['rangeopt'];
             }
             $q = "SELECT * FROM fnalert WHERE nodeid IN(" . $inlist . ") ORDER BY LENGTH(closedx) ASC, closedx DESC LIMIT 0," . $acount;
             break;
         case "alerts":
             $q = "SELECT * FROM fnalert WHERE closedx=0 AND nodeid IN(" . $inlist . ")";
             break;
         case "alertnode":
             $q = array();
             foreach ($nodes as $node) {
                 $q[] = "SELECT * FROM fnalert WHERE nodeid=\"" . ss($node['nodeid']) . "\" ORDER BY LENGTH(closedx) ASC, closedx DESC LIMIT 0,1";
             }
             break;
     }
     if (!is_array($q)) {
         $q = array($q);
     }
     foreach ($q as $query) {
         $r = $this->NATS->DB->Query($query);
         while ($row = $this->NATS->DB->Fetch_Array($r)) {
             $alerts[] = $row;
         }
         $this->NATS->DB->Free($r);
     }
     foreach ($alerts as $alert) {
         $title = $alert['nodeid'] . " " . $this->NATS->Lang->Item("alert");
         if ($alert['closedx'] != 0) {
             $title .= " (" . $this->NATS->Lang->Item("closed") . ")";
         } else {
             $title .= " (" . $this->NATS->Lang->Item("open") . ")";
         }
         $link = GetAbsolute("node.php?nodeid=" . $alert['nodeid']);
         if ($alert['closedx'] == 0) {
             $pubtime = $alert['openedx'];
         } else {
             $pubtime = $alert['closedx'];
         }
         $pub = date("D, d M Y H:i:s", $pubtime) . " GMT";
         $q = "SELECT logentry FROM fnalertlog WHERE alertid=" . $alert['alertid'] . " ORDER BY alid ASC LIMIT 0,1";
         $r = $this->NATS->DB->Query($q);
         if ($row = $this->NATS->DB->Fetch_Array($r)) {
             $desc = $row['logentry'];
         } else {
             $desc = "";
         }
         $this->NATS->DB->Free($r);
         $out .= $this->Item($title, $link, $pub, $desc);
     }
     $out .= "</channel>\n</rss>\n";
     return $out;
 }
예제 #2
0
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with FreeNATS.  If not, see www.gnu.org/licenses

For more information see www.purplepixie.org/freenats
-------------------------------------------------------------- */
ob_start();
require "include.php";
$NATS->Start();
$session = true;
if (!$NATS_Session->Check($NATS->DB)) {
    $session = false;
}
$abs = GetAbsolute();
if (isset($_REQUEST['mode'])) {
    $mode = $_REQUEST['mode'];
} else {
    $mode = "xml";
}
// api.public - is available without session auth
// api.key - usage key used if public and no session (if set)
if ($NATS->Cfg->Get("api.public", 0) != 1) {
    if (!$session) {
        echo "Error: Public API Access Disabled";
        exit;
    }
} else {
    if (!$session) {
        $key = $NATS->Cfg->Get("api.key", "");
예제 #3
0
ob_start();
require "include.php";
$NATS->Start();
if (!$NATS_Session->Check($NATS->DB)) {
    header("Location: ./?login_msg=Invalid+Or+Expired+Session");
    exit;
}
if ($NATS_Session->userlevel < 1) {
    UL_Error("View Link");
}
ob_end_flush();
Screen_Header("View Links", 1);
$vid = $_REQUEST['viewid'];
echo "<b class=\"subtitle\">Linking to View # " . $vid . "</b><br>";
echo "<a href=view.php?viewid=" . $vid . ">Preview View</a> | <a href=view.edit.php?viewid=" . $vid . ">Edit View Settings</a><br><br>";
$base = GetAbsolute("view.php?viewid=" . $vid);
echo "<b>URL:</b> " . $base . "<br>";
echo "<b>URL:</b> <input type=text size=80 value=\"" . $base . "\"><br><br>";
echo "<b>JavaScript Include Example</b> (Copy and paste into your page)<br>";
echo "<textarea cols=80 rows=8>";
echo "&lt;script type=\"text/javascript\" src=\"" . $base . "&mode=js\"&gt;\n";
echo "&lt;/script&gt;\n";
echo "</textarea>";
if (!isset($_REQUEST['jsdemo'])) {
    echo "<br><br><a href=view.link.php?viewid=" . $vid . "&jsdemo=1>Demo this working</a><br><br>";
} else {
    echo "<br><br>";
    echo "<script type=\"text/javascript\" src=\"view.php?mode=js&viewid=" . $vid . "\"></script>\n";
    echo "<br><br>";
}
/*