Witam
Mam takie pytanie:
W jaki sposób wstawić zawartość kanału RSS innej strony w JPortal-u ?
Witam
Mam takie pytanie:
W jaki sposób wstawić zawartość kanału RSS innej strony w JPortal-u ?
Pobaw się np. tym skryptem:
<?
function unhtmlspecialchars( $string ) {
$string = str_replace ( '&', '&', $string );
$string = str_replace ( '\'', '\\\'', $string );
$string = str_replace ( '\"', '\\\"', $string );
$string = str_replace ( '<', '<', $string );
$string = str_replace ( '>', '>', $string );
return $string;
}
$linki['gazeta.pl - wiadomo¶ci'] = 'http://www.gazeta.pl/pub/rss/wiadomosci.xml';
$linki['webinside.pl'] = 'http://www.webinside.pl/rss.php';
$linki['dziennik internauty'] = 'http://di.com.pl/rss/di.rss';
$linki['e-gospodarka'] = 'http://news.egospodarka.pl/rss.thtml?cat=127';
$strona = (!empty($_POST['rss_canal'])) ? $_POST['rss_canal'] : 'dziennik internauty';
$rss_link = (array_key_exists($strona,$linki)) ? $linki[$strona] : $linki['dziennik internauty'];
$separator = '|~|';
$item = false;
$chanel_title = '';
$encoding = '';
$lines_item = '';
$items_tab = array();
$rss_link = parse_url($rss_link);
$header = "GET ".$rss_link["path"].(isset($rss_link["query"]) ? "?".$rss_link["query"] : false)." HTTP/1.0\r\n";
$header .= "Host: ".$rss_link['host']."\r\n";
$header .= "Content-type: application/x-www-form-urlencoded\r\n";
$header .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; www.itcfull.net)\r\n";
$header .= "Content-length: " . strlen($request) . "\r\n\r\n";
if ($rss_read = @fsockopen($rss_link['host'], 80, $err_num, $err_msg, 15)) {
fputs($rss_read, $header . $request);
while (!feof($rss_read)) {
$line = trim(fgets($rss_read,10000));
if (preg_match("#<\?xml.+(|encoding=\"([\w\-]+)\").*?\?>#i",$line,$enc)) // nagłówek XML i pobieranie
$encoding = preg_replace("#<\?xml.+encoding=\"([\w\-]+)\".*\?>#s","\\1",$enc[0]); // kodowania tekstu
if (!empty($encoding)) {
if (!$item) $chanel_title .= $line;
if ((preg_match("##",$line)) && (!$item)) {
$item = true;
$chanel_title = preg_replace("#
$chanel_title = preg_replace("#.*(.*?).*#","\\2",$chanel_title);
}
}
if ($item) $lines_item .= $line;
}
fclose($rss_read);
if (preg_match_all("#.+?#",$lines_item,$lines_item)) {
foreach ($lines_item[0] as $wart) {
preg_match("#.+?#",$wart,$link);
$link = preg_replace("#(.+?)#","\\1",$link[0]);
if (preg_match("#.+?#",$wart,$title)) {
$title = preg_replace("#(.+?)#","\\2",$title[0]);
$link = ''.$title.'';
} else $link = ''.$link.'';
if (preg_match("#.+?#",$wart,$description)) {
$description = preg_replace("#(.+?)#","\\1",$description[0]);
$description = str_replace(array(""),"",$description);
$description = preg_replace("##i","",$description);
} else $description = '';
if (!empty($link)) {
$items_tab[] = $description.$separator.$link;
}
}
}
unset($lines_item,$line);
} else Die("błąd otwarcia kanału RSS: $rss_link");
?>
<?
foreach ($linki as $klucz => $wart) {
echo "
if ($strona == $klucz) echo ' selected="selected"';
echo">$klucz\r\n";
}
?>
<?
if (count($items_tab) > 0) {
echo "$chanel_title
kodowanie: $encoding
\n\n\n";
foreach ($items_tab as $wart) {
list($description,$link) = explode($separator,$wart);
echo "$link
\n\n";
if (!empty($description)) echo stripslashes(unhtmlspecialchars($description))."
\n\n\n";
}
}
?>
A czy jest możliwość, pisania newsów w jportalu, które po opublikowaniu pojawiłyby się na kanale RSS ??
Będę wdzięczny za odpowiedz
Z tego co wiem to tak
Dzięki za link, znalazłem to czego szukałem