Welcome to Geeklog, Anonymous Tuesday, December 10 2024 @ 06:29 pm EST

Geeklog Forums

quick javascript rss feed for another site


Status: offline

phpsocialclub

Forum User
Junior
Registered: 03/05/03
Posts: 30
Location:North Carolina

We have a GL site and somebody wanted to sydicate the news with javascipt because they could not run any server side stuff. I whipped this up for them pretty quick, so I thought others might like it as well.

This is real rough and intended for hackers and not true newbies

To put your news on another page via javascript use the following code on the page.

Text Formatted Code
<script src="http://yoururl.com/javascriptnewsfeed.php">
</script>

Then add this page to your public_html page. called javascriptnewsfeed.php

Text Formatted Code

<?php
require_once('lib-common.php');


function COM_rdfexportforjavascript( $rdfurl )
{
    global $_TABLES, $RDFinsideitem, $RDFtag, $RDFtitle, $RDFlink, $RDFheadlines;

    $RDFinsideitem = false;
    $RDFtag = '';
    $RDFtitle = '';
    $RDFlink = '';
    $RDFheadlines = array();

    clearstatcache();

    $rdferror = false;
    $xml_parser = xml_parser_create();
    xml_set_element_handler($xml_parser, 'COM_rdfStartElement', 'COM_rdfEndElement');
    xml_set_character_data_handler( $xml_parser, 'COM_rdfCharacterData' );

    if( $fp = fopen( $rdfurl, 'r' ))
    {
        while( $data = fread( $fp, 4096 ))
        {
       
                //echo htmlentities($data) ;
       
            if( !xml_parse( $xml_parser, $data, feof( $fp )))
            {
                $errmsg = sprintf(
                    "Parse error in %s: %s at line %d",
                    $rdfurl,
                    xml_error_string( xml_get_error_code( $xml_parser )),
                    xml_get_current_line_number( $xml_parser )
                    );

                //COM_errorLog( $errmsg, 1 );
                echo $errmsg ;
                $rdferror = true;
                break;
            }
        }

        fclose( $fp );
        xml_parser_free( $xml_parser );

        if( !$rdferror )
        {
               
               
     
           
            foreach($RDFheadlines as $headline)
            {
           
            $javascript .= "document.write('" . addslashes(stripslashes($headline)) . '<br>r')' ."r" ;
           
           
            }
           
            $RDFheadlines = array();
           
            echo $javascript ;
        }
    }
    else
    {
        $rdferror = true;
        COM_errorLog( "Can not reach $rdfurl", 1 );

       echo
            "GeekLog can not reach the supplied RDF file at $update. "
            . "Please double check the URL provided.  Make sure your url is correctly entered and it begins with "
            . "http://. GeekLog will try in one hour to fetch the file again." ;
    }
}


COM_rdfexportforjavascript($_CONF['rdf_file'] )


?>
 

I work for a Wilmington NC Attorney
 Quote

All times are EST. The time is now 06:29 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content