')) { $src = preg_replace("/(\)/si", "SCRIPT DELETED", "$src"); die("Warning! Attempt to inject javascript detected. Aborted and tracking log updated."); } // MAGPIE SETUP ---------------------------------------------------- // access configuration settings require_once('feed2js_config.php'); // check for utf encoding type $utf = (isset($_GET['utf'])) ? $_GET['utf'] : 'n'; if ($utf == 'y') { define('MAGPIE_CACHE_DIR', MAGPIE_DIR . 'cache_utf8/'); // chacrater encoding define('MAGPIE_OUTPUT_ENCODING', 'UTF-8'); } else { define('MAGPIE_CACHE_DIR', MAGPIE_DIR . 'cache/'); define('MAGPIE_OUTPUT_ENCODING', 'ISO-8859-1'); } // GET VARIABLES --------------------------------------------- // retrieve values from posted variables // flag to show channel info $chan = (isset($_GET['chan'])) ? $_GET['chan'] : 'n'; // variable to limit number of displayed items; default = 0 (show all, 100 is a safe bet to list a big list of feeds) $num = (isset($_GET['num'])) ? $_GET['num'] : 0; if ($num==0) $num = 100; // indicator to show item description, 0 = no; 1=all; n>1 = characters to display // values of -1 indicate to displa item without the title as a link // (default=0) $desc = (isset($_GET['desc'])) ? $_GET['desc'] : 0; // flag to show author of items, values: no/yes (default=no) $auth = (isset($_GET['au'])) ? 'y' : 'n'; // flag to show date of items, values: no/yes (default=no) $date = (isset($_GET['date'])) ? $_GET['date'] : 'n'; // time zone offset for making local time, // e.g. +7, =-10.5; 'feed' = print the time string in the RSS w/o conversion $tz = (isset($_GET['tz'])) ? $_GET['tz'] : 'feed'; // flag to open target window in new window; n = same window, y = new window, // other = targeted window, 'popup' = call JavaScript function popupfeed() to display // in new window (default is n) $targ = (isset($_GET['targ'])) ? $_GET['targ'] : 'n'; if ($targ == 'n') { $target_window = ' target="_self"'; } elseif ($targ == 'y' ) { $target_window = ' target="_blank"'; } elseif ($targ == 'popup') { $target_window = ' onClick="popupfeed(this.href);return false"'; } else { $target_window = ' target="' . $targ . '"'; } // flag to show feed as full html output rather than JavaScript, used for alternative // views for JavaScript-less users. // y = display html only for non js browsers (NO LONGER USED) // n = default (JavaScript view) // a = display javascript output but allow HTML // p = display text only items but convert linefeeds to BR tags // default setting for no conversion of linebreaks $html = (isset($_GET['html'])) ? $_GET['html'] : 'n'; $br = ' '; if ($html == 'a') { $desc = 1; } elseif ($html == 'p') { $br = '
'; } // optional parameter to use different class for the CSS container $rss_box_id = (isset($_GET['css'])) ? '-' . $_GET['css'] : ''; // optional parameter to use different class for the CSS container $play_podcast = (isset($_GET['pc'])) ? $_GET['pc'] : 'n'; // PARSE FEED and GENERATE OUTPUT ------------------------------- // This is where it all happens! // check if site has a setting to restrict to a url if (isset($restrict_url)) { $src_host = substr($src, 7); $src_pos = strpos($src_host,"/"); if ($src_pos) { $src_host = substr($src_host,0, $src_pos); } } if (isset($restrict_url) && substr($src_host, strlen($src_host)-strlen($restrict_url)) != $restrict_url) { $str.= "document.write('

Error: on feed " . $src . ". " . "Feeds are allowed only from URLs from the site http://*" . $restrict_url . "

');\n"; } else { $rss = @fetch_rss( $src ); // begin javascript output string for channel info $str= "document.write('
');\n"; // no feed found by magpie, return error statement if (!$rss) { $str.= "document.write('

$script_msgError: Feed failed! Causes may be (1) No data found for RSS feed $src; (2) There are no items are available for this feed; (3) The RSS feed does not validate.

Please verify that the URL $src works first in your browser and that the feed passes a validator test.

');\n"; } else { // Create CONNECTION CONFIRM // create output string for local javascript variable to let // browser know that the server has been contacted $feedcheck_str = "feed2js_ck = true;\n\n"; // we have a feed, so let's process if ($chan == 'y') { // output channel title linked and description $str.= "document.write('

channel['link']) . '"' . $target_window . ">" . addslashes(strip_returns($rss->channel['title'])) . "
" . addslashes(strip_returns(strip_tags($rss->channel['description']))) . "

');\n"; } elseif ($chan == 'title') { // output title only with link $str.= "document.write('

channel['link']) . '"' . $target_window . ">" . addslashes(strip_returns($rss->channel['title'])) . "

');\n"; } elseif ($chan == 'titlelinkno') { // output title only with no link $str.= "document.write('

" . addslashes(strip_returns($rss->channel['title'])) . "

');\n"; } elseif ($chan == 'linkno') { // output title and descript only with no link $str.= "document.write('

" . addslashes(strip_returns($rss->channel['title'])) . "
" . addslashes(strip_returns(strip_tags($rss->channel['description']))) . "

');\n"; } // begin item listing $str.= "document.write('');\n"; } // end restrict_url } // Render as JavaScript // START OUTPUT // headers to tell browser this is a JS file if ($rss) header("Content-type: application/x-javascript"); // Spit out the results as the series of JS statements echo $feedcheck_str . $str; ?>