08-03-2011, 13:18
|
#1
|
|
Eposta Aktivasyonu Gerekmekte
İstanbul Anadolu Şubesi
Yaş: 32
Mesajlar: 399
Tecrübe Puanı: 0
Rep Puanı: 10
Rep Derecesi : 
|
Bu Block ile Rss ve Haber Bloğu Yan Yana
Bu Block ile Rss ve Haber Bloğu Yan Yana
Kod: Kod:
Kod:
<? $content = " <tr> <td width=\"50%\" valign=\"top\"> <table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">".news()."</table> </td> <td width=\"50%\" valign=\"top\"> <table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">".rss()."</table> </td> </tr>";function news(){ Global $mklib, $mklib_board, $DB; $limit = $mklib->config['news_block']; if (!$limit) { $limit = 5; } $cont = ""; $content = ""; $link_user = $mklib_board->forum_link("profile");$query = $DB->query( "SELECT n.id, n.idcategoria, n.idautore, n.titolo, n.autore, n.testo, n.data, n.totalcomm, s.id AS idcat, s.titolo AS titcat, s.icona FROM mkp_news AS n LEFT JOIN mkp_news_sections AS s ON(s.id = n.idcategoria) WHERE validate = '1' ORDER BY `id` DESC LIMIT $limit"); while( $row = $DB->fetch_row($query) ) { $idnt = $row['id']; $totcomments = $row['totalcomm']; $id_orig_name = $row['idautore']; $idcategoria = $row['idcategoria']; $titolo = stripslashes($row['titolo']); $name = $row['autore']; $testo = stripslashes($row['testo']); if ($mklib->mkeditor == "BBCODE") { $testo = $mklib->decode_bb($testo); $testo = $mklib_board->decode_smilies($testo); } $sezione = $row['titcat']; $icona = $row['icona']; switch($icona) { case '1': $image = "$mklib->http://www.sanalx.net/images/icona_news.gif"; break; case '2': $image = "$mklib->http://www.sanalx.net/images/icona_help.gif"; break; case '3': $image = "$mklib->http://www.sanalx.net/images/icona_star.gif"; break; case '4': $image = "$mklib->http://www.sanalx.net/images/icona_pc.gif"; break; case '5': $image = "$mklib->http://www.sanalx.net/images/icona_world.gif"; break; default: $image = $icona; break; } $cdata = $mklib->create_date($row['data']); $news_words= $mklib->config['news_words']; if ($mklib->config['news_html']) { $testo = str_replace ("<br />", " ", $testo); $testo = strip_tags ($testo); } if ($news_words) { $testo = substr ($testo, 0, $news_words); $testo .= " ..."; } $cont .= " <table class=\"tabnews\" cellspacing=\"2\" cellpadding=\"2\" width=\"100%\"> <tbody> <tr> <td class=\"tdblock\" align=\"center\" width=\"5%\"> <img hspace=\"0\" src=\"$image\" align=\"bottom\" border=\"0\" alt=\"\" /> </td> <td class=\"tdblock\" valign=\"top\" width=\"95%\"><b>$sezione<br /><a href=\"index.php?ind=news&op=news_show_single&ide={$row['id']}\">$titolo</a></b> </td> </tr> <tr> <td colspan=\"2\"><br /> $testo </td> </tr> <tr> <td align=\"right\" colspan=\"2\"><br /><i>{$mklib->lang['from']}<b> <a href=\"$link_user=$id_orig_name\">$name</a></b>, $cdata <a href=\"index.php?ind=news&op=submit_comment&idnews={$row['id']}\">{$mklib->lang['comments']}</a>($totcomments), <a href=\"index.php?ind=news&op=news_show_single&ide={$row['id']}\">{$mklib->lang['readall']}</a></i> </td> </tr> </tbody> </table> "; } $content = " <tr> <td class=\"contents\"> <div class=\"taburlo\"> <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td class=\"taburlo\" valign=\"top\"> {$cont} </td> </tr> </table> </div> </td> </tr>"; unset($cont); unset($row); unset($idcat); unset($categoria); unset($idnt); unset($query); unset($query2); unset($totcomments); unset($id_orig_name); unset($idcategoria); unset($titolo); unset($name); unset($testo); unset($sezione); unset($icona); unset($cdata); unset($news_words); return $content;}function rss(){ global $mklib, $DB; define ('CACHE_PATH', $mklib->sitepath."mkportal/cache/"); unset($rss_source); $DB->query("SELECT * FROM mkp_rss WHERE active='1' ORDER BY position ASC"); if ($DB->get_num_rows()) { while ($r = $DB->fetch_row()) { $rss_source[$r['name']] = $r['url']; } } $content = ""; if (is_array($rss_source)) { global $std; if ($mklib->config['rss_marquee']) {$marquee_begin = "\n<marquee direction=\"up\" scrolldelay=\"0\" scrollamount=\"1\" height=\"{$mklib->config['rss_marquee_height']}\">\n"; $marquee_end = "\n</marquee>\n"; } $content = " <tr> <td class=\"contents\"> <div class=\"taburlo\"> <div class=\"tabnews\" style=\"margin:5px; padding: 2px\">\n".$marquee_begin;$content .= "<div class=\"tdblock\">".rss_clean_htmlx($mklib->create_date(time(), "long"))."<br /><br /></div>\n"; foreach($rss_source as $source => $url) { $content .= rss_get_rdfx($url,$source ); } $content .= $marquee_end."</div></div></td></tr>\n"; } return $content;}function rss_clean_htmlx($text = "") { $text = str_replace("ä", "ä", $text); $text = str_replace("ö", "ö", $text); $text = str_replace("ü", "ü", $text); $text = str_replace("Ä", "Ä", $text); $text = str_replace("Ö", "Ö", $text); $text = str_replace("Ü", "Ü", $text); $text = str_replace("ß", "ß", $text); $text = str_replace("&", "&", $text); return $text;}function rss_clean_entryx($entry = "") { if ($entry == "") return; $entry = str_replace("<"."![CDATA[", "", $entry); $entry = trim(str_replace("]]".">", "", $entry)); return rss_clean_htmlx($entry);}function rss_get_rdfx($rdf_file = "", $cache_file = "") { global $mklib; $cache_file = CACHE_PATH.$cache_file.".rss"; if (!file_exists($cache_file)) { $fh = fopen($cache_file, "wb"); fwrite($fh, ""); fclose($fh); $new = TRUE; } $ctime = time() - $mklib->config['rss_cache_time']; if ($new || filemtime($cache_file)<$ctime) { $current_version = (int)str_replace('.', '', phpversion()); if ($current_version < 420) { $allow_url = ini_get ('allow_url_fopen'); } else { $a = ini_get_all(); $allow_url = $a['allow_url_fopen']['global_value']; unset ($a); } if ($allow_url) { $rdf = implode("",file($rdf_file)); } else { $url = parse_url($rdf_file); $fp = fsockopen ($url['host'], 80, $errno, $errstr, 30); if (!$errno && !$errstr) { fwrite ($fp, "GET {$url['path']}?{$url['query']}#{$url['fragment']} HTTP/1.0\r\nHost: {$url['host']}\r\n\r\n"); while (!feof($fp)) { $rdf .= fgets($fp,1024); } $rdf = preg_replace("`.*?(<\?xml)`is", "\\1", $rdf); fclose($fp); } } $fh = fopen($cache_file, "wb"); fwrite($fh, $rdf); fclose($fh); } else { $rdf = implode ("", file ($cache_file)); } $rdf = rss_clean_htmlx($rdf); if (preg_match_all("|<channel(.*)</channel>|Uism",$rdf, $title, PREG_PATTERN_ORDER)) {preg_match_all("|<title>(.*)</title>.*<link>(.*)</link>.*<description>(.*)</description>|Uism", $title[1][0], $regs, PREG_PATTERN_ORDER);$content .= "<b><a href=\"".$regs[2][0]."\" target=\"_blank\" class=\"uno\" ><span style=\"font-size:11pt;\">".$regs[1][0]."</span></a></b><br /><i>".$regs[3][0]."</i><br /><br />"; }; $result = preg_match_all("|<item>(.*?)</item>|is",$rdf, $items, PREG_PATTERN_ORDER); if (!$result) { preg_match_all("|<item.*?>(.*?)</item>|is",$rdf, $items, PREG_PATTERN_ORDER); } for ($i = 0; $i < min($mklib->config['rss_max_items'], count($items[1])); $i++){ preg_match("|<title>(.*)</title>.*<link>(.*)</link>|Uism",$items[1][$i], $matches);$content .= "<b><a href=\"".$matches[2]."\" target=\"_blank\" class=\"uno\" >".rss_clean_entryx($matches[1])."</a></b><br />"; if ($mklib->config['rss_desc']) { preg_match("|<description>(.*)</description>|Uism",$items[1][$i], $matches); if (count($matches)) { $desc = rss_clean_entryx($matches[1]); if (strlen($desc) > $mklib->config['rss_desc_length']) { $desc = substr($desc, 0, $mklib->config['rss_desc_length']); $desc = substr($desc, 0, strrpos($desc, " " )); $desc .= " ..."; } $content .= $desc."<br /><br />\n"; } } } return $content;}?>
Kaydedin ismini haberler.php diye yada herhangi bir isimle kaydedin ve mkportal/blocks içine gönderin sonra portal yönetim panelinden ortada gösterin..
|
|
|