Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    Rss per news non funziona...

    Buon giorno, vado subito al dunque, ho preso questi script dal web(ovviamente) sono 4 file.
    Quello che non capisco è come mai mi restituisce questi due errori
    "Sorry: It's not possible to reach RSS file " e "I give up trying to fetch RSS feed."
    quando il file RSS è presente nella stessa directory del file che lo richiama..vi posto il contenuto dei 4 file partendo ovviamente dal primo:
    PS:Lo so che è troppo lungo e nessuno ha pazienza,ma magari qualcuno con un colpo d'occhio migliore del mio, individua il problema..

    contatti.php
    codice:
    <script type="text/javascript" src="rsspausescroller.js">
    /***********************************************
    * RSS Pausing Scroller- © Dynamic Drive (http://www.dynamicdrive.com)
    * Visit http://www.dynamicdrive.com/dynamici...pausescroller/ for source code and documentation
    ***********************************************/
    </script>
    <script type="text/javascript">
    //new rsspausescroller("articoli", "box", "rssclass", 5000, "_blank", "date+description")
    new rsspausescroller("cnn", "box", "rssclass", 3000, "_new")
    </script>
    rsspausescroller.js
    codice:
    var bridgepath="scrollerbridge.php"
    
    function formatrssmessage(divid, msgnumber, linktarget, logicswitch){
    var rsscontent=rsscontentdata[divid][msgnumber]
    var linktitle='<span class="rsstitle">'+unescape(rsscontent.title)+'</span>'
    var description='<div class="rssdescription">'+unescape(rsscontent.description)+'</div>'
    var feeddate='<span class="rssdate">'+unescape(rsscontent.date)+'</span>'
    if (logicswitch.indexOf("description")!=-1 && logicswitch.indexOf("date")!=-1) //Logic switch- Show description and date
    return linktitle+"
    "+feeddate+description
    else if (logicswitch.indexOf("description")!=-1) //Logic switch- Show just description
    return linktitle+"
    "+description
    else if (logicswitch.indexOf("date")!=-1) //Logic switch- Show just date
    return linktitle+"
    "+feeddate
    else
    return linktitle //Default- Just return hyperlinked RSS title
    }
    
    var rsscontentdata=new Array() 
    function rsspausescroller(RSS_id, divId, divClass, delay, linktarget, logicswitch){
    this.tickerid=divId //ID of ticker div to display information
    this.delay=delay //Delay between msg change, in miliseconds.
    this.linktarget=(typeof linktarget!="undefined")? linktarget : ""
    this.logicswitch=(typeof logicswitch!="undefined")? logicswitch : ""
    this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
    this.hiddendivpointer=1 //index of message array for hidden div
    this.js_is_loaded=0
    this.number_of_tries=0
    document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1"><span style="position: absolute">Initializing RSS scroller...</span></div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2"></div></div>')
    if (document.getElementById){ //perform basic DOM browser support
    var parameters="id="+encodeURIComponent(RSS_id)+"&divid="+divId+"&bustcache="+new Date().getTime()
    rsspausescroller.getRSScontentJS(bridgepath+"?"+parameters)
    this.do_onjsload()
    }
    }
    
    rsspausescroller.prototype.do_onjsload=function(){
    var scrollerinstance=this
    if (typeof rsscontentdata[this.tickerid]=="undefined" && this.number_of_tries<40){ //if JS array holding RSS content not yet loaded
    this.number_of_tries++
    setTimeout(function(){scrollerinstance.do_onjsload()}, 200) //recheck
    }
    else if (typeof rsscontentdata[this.tickerid]!="undefined"){ //if JS array has loaded
    this.tickerdiv=document.getElementById(this.tickerid)
    this.visiblediv=document.getElementById(this.tickerid+"1")
    this.hiddendiv=document.getElementById(this.tickerid+"2")
    this.visibledivtop=parseInt(rsspausescroller.getCSSpadding(this.tickerdiv))
    //set width of inner DIV to outer DIV width minus padding (padding assumed to be top padding x 2)
    this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
    this.visiblediv.innerHTML=formatrssmessage(this.tickerid, 0, this.linktarget, this.logicswitch)
    this.hiddendiv.innerHTML=formatrssmessage(this.tickerid, 1, this.linktarget, this.logicswitch)
    this.do_ondivsinitialized()
    }
    else
    document.getElementById(this.tickerid).innerHTML=rsscontentdata+"
    I give up trying to fetch RSS feed."
    }
    
    rsspausescroller.prototype.do_ondivsinitialized=function(){
    var scrollerinstance=this
    if (parseInt(this.visiblediv.offsetHeight)==0 || parseInt(this.hiddendiv.offsetHeight)==0)
    setTimeout(function(){scrollerinstance.doondivsinitialized()}, 100)
    else
    this.initialize()
    }
    
    rsspausescroller.prototype.initialize=function(){
    var scrollerinstance=this
    this.getinline(this.visiblediv, this.hiddendiv)
    this.hiddendiv.style.visibility="visible"
    //set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
    this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
    this.tickerdiv.onmouseover=function(){scrollerinstance.mouseoverBol=1}
    this.tickerdiv.onmouseout=function(){scrollerinstance.mouseoverBol=0}
    if (window.attachEvent) //Clean up loose references in IE
    window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
    setTimeout(function(){scrollerinstance.animateup()}, this.delay)
    }
    
    rsspausescroller.prototype.animateup=function(){
    var scrollerinstance=this
    if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
    this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
    this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
    setTimeout(function(){scrollerinstance.animateup()}, 50)
    }
    else{
    this.getinline(this.hiddendiv, this.visiblediv)
    this.swapdivs()
    setTimeout(function(){scrollerinstance.rotatemessage()}, this.delay)
    }
    }
    
    rsspausescroller.prototype.swapdivs=function(){
    var tempcontainer=this.visiblediv
    this.visiblediv=this.hiddendiv
    this.hiddendiv=tempcontainer
    }
    
    rsspausescroller.prototype.getinline=function(div1, div2){
    div1.style.top=this.visibledivtop+"px"
    div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
    }
    
    rsspausescroller.prototype.rotatemessage=function(){
    var scrollerinstance=this
    if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
    setTimeout(function(){scrollerinstance.rotatemessage()}, 100)
    else{
    var i=this.hiddendivpointer
    var ceiling=rsscontentdata[this.tickerid].length
    this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
    this.hiddendiv.innerHTML=formatrssmessage(this.tickerid, this.hiddendivpointer, this.linktarget, this.logicswitch)
    this.animateup()
    }
    }
    
    rsspausescroller.getRSScontentJS=function(scripturl){
    var scriptref=document.createElement('script')
    scriptref.setAttribute("type","text/javascript")
    scriptref.setAttribute("src", scripturl)
    document.getElementsByTagName("head").item(0).appendChild(scriptref)
    }
    
    rsspausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
    if (tickerobj.currentStyle)
    return tickerobj.currentStyle["paddingTop"]
    else if (window.getComputedStyle) //if DOM2
    return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
    else
    return 0
    }
    scrollerbridge.php
    codice:
    <?
    include "lastRSS.php";
    
    $rss = new lastRSS();
    $rss->cache_dir = 'cache';
    $rss->date_format = 'M d, Y g:i:s A';
    $rss->cache_time = 1800;
    
    $rsslist=array(
    "cnn" => "http://rss.cnn.com/rss/cnn_topstories.rss",
    "bbc" => "http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml",
    "news.com" => "http://news.com.com/2547-1_3-0-5.xml",
    "slashdot" => "http://rss.slashdot.org/Slashdot/slashdot",
    "dynamicdrive" => "http://www.dynamicdrive.com/export.php?type=new");
    
    $allowedDomains="";
    Header("content-type: application/x-javascript");
    $rssid=$_GET['id'];
    $rssurl=isset($rsslist[$rssid])? $rsslist[$rssid] : die("rsscontentdata=\"Error: Can't find requested RSS in list.\"");
    $divid=$_GET['divid'];
    
    function checkdomains($allowed, $referral){
    	if ($allowed!=""){
    		$found=0;
    		$allowlist=split (",", $allowed);
    		foreach ($allowlist as $allow){
    		$allow=trim($allow);
    		$found+=strpos(" ".$referral, $allow);
    	}
    	if (!$found)
    		die("rsscontentdata=\"This domain isn't authorized to show scroller.\"");
    	}
    }
    
    @checkdomains($allowedDomains, $_SERVER["HTTP_REFERER"]);
    
    function outputRSS_JS($url, $divid) {
        global $rss;
        if ($rs = $rss->get($url)){
    	    echo "rsscontentdata.$divid=new Array();\n";
    	    $i=0;
                foreach ($rs['items'] as $item) {
                    echo "rsscontentdata.$divid" . "[$i]={link:\"" . slashit($item[link]) . "\", title:\"" . slashit($item[title]) . "\", description:\"" . slashit($item[description]) . "\", date:\"" . slashit($item[pubDate]) . "\"}\n";
    		$i++;
                }
                if ($rs['items_count'] <= 0) { echo "rsscontentdata=\"Sorry, no items found in the RSS file\""; }
        }
        else {
            echo "rsscontentdata=\"Sorry: It's not possible to reach RSS file $url\"";
            // All else fails
        }
    }
    
    function slashit($what){
       $newstring=str_replace('&apos;', '\'', $what);
       return rawurlencode($newstring);
    }
    
    outputRSS_JS($rssurl, $divid);
    ?>
    lastRSS.php->questa è la classe RSS
    codice:
    class lastRSS {
    var $default_cp = 'UTF-8';
    var $CDATA = 'nochange';
    var $cp = '';
    var $items_limit = 0;
    var $stripHTML = False;
    var $date_format = '';
    
    var $channeltags = array ('title', 'link', 'description', 'language', 'copyright', 'managingEditor', 'webMaster', 'lastBuildDate', 'rating', 'docs');
    	var $itemtags = array('title', 'link', 'description', 'author', 'category', 'comments', 'enclosure', 'guid', 'pubDate', 'source');
    	var $imagetags = array('title', 'url', 'link', 'width', 'height');
    	var $textinputtags = array('title', 'description', 'name', 'link');
    
    function Get ($rss_url) {
    if ($this->cache_dir != '') {
    			$cache_file = $this->cache_dir . '/rsscache_' . md5($rss_url);
    			$timedif = @(time() - filemtime($cache_file));
    			if ($timedif < $this->cache_time) {
    $result = unserialize(join('', file($cache_file)));
    if ($result) $result['cached'] = 1;
    			} else {
    $result = $this->Parse($rss_url);
    				$serialized = serialize($result);
    				if ($f = @fopen($cache_file, 'w')) {
    					fwrite ($f, $serialized, strlen($serialized));
    					fclose($f);
    				}
    				if ($result) $result['cached'] = 0;
    			}
    		}
    else {
    			$result = $this->Parse($rss_url);
    			if ($result) $result['cached'] = 0;
    		}
    return $result;
    	}
    etc etc..
    }
    Grazie mille...

  2. #2
    tutto il materiale l'ho preso su questo sito:
    http://www.dynamicdrive.com/dynamici...pausescroller/

    la cosa strana è che, sul loro sito funziona, perchè te lo fanno vedere , ma sul mio sito non funziona e mi dice che non riesce a trovare il file RSS.

    Per me è una cosa assurda, comunque i percorsi, dei file che utilizzo sono giusti, quindi non capisco dove sia il problema, a meno che debba settare qualche parametro nel file php.ini.

    Ditemi voi ragazzi se magari ne avete usufruito di questo RSS.
    Grazie mille...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.