Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Ravens PHP Scripts And Web Hosting Forum Index -> phpnuke 7.2
Author Message
Guillius
Hangin' Around



Joined: Jan 31, 2004
Posts: 31

PostPosted: Fri Aug 20, 2004 9:21 am Reply with quote

I've been trying to look for the bit of code that does this but alas, I am not knowledgable enough. I've read multiple sites on RSS and none really say how to "decode" RSS into a webpage, they just tell you to get a reader.

I know nuke can "decode" it because its an option of the blocks. Reason I want to know where the piece of code (pieces of code) are is because I am interested in adding RSS elsewhere on the site (In a Content Page) without having to use blocks. I've asked that question before but no answer or at least an answer I could identify as a solution hence maybe if someone knows where the code is I could fiddle with it myself?

Any help at all would be appreciated. Thanks for your time.
 
View user's profile Send private message
sixonetonoffun
Spouse Contemplates Divorce



Joined: Jan 02, 2003
Posts: 2496

PostPosted: Fri Aug 20, 2004 9:46 am Reply with quote

Ok lets back up. You wanted to insert some java Scr+pt to echo out rss feeds into Content pages.

You won't be able to do this without hacking the content module because nuke doesn't allow java to be inserted through the control panel for security purposes.

To echo out the code Raven gave you one example of how to do that. Is there some reason you have to use the content module for this? If would be much simpler for you to create a genric module of your own.

Something like this:
Code:


 if (!eregi("modules.php", $_SERVER['Scr+pt_NAME'])) {
        die ("You can't access this file directly...");
    }
$mycontent .= "
<Scr+pt language=JavaScr+pt src=\"./modules.php?name=Syndication&file=index&ac=box&ac2=5&ac3=5\"></Scr+pt>
<Scr+pt language=JavaScr+pt src=\"./modules.php?name=Syndication&file=index&ac=box&ac2=5&ac3=2\"></Scr+pt>
<Scr+pt language=JavaScr+pt src=\"./modules.php?name=Syndication&file=index&ac=box&ac2=5&ac3=3\"></Scr+pt>
<Scr+pt language=JavaScr+pt src=\"./modules.php?name=Syndication&file=index&ac=box&ac2=5&ac3=4\"></Scr+pt>
";
echo "$mycontent";


The same concept could be used in the content modules pages too but how you connect to what feeds on what pages would take some more code. As would the code Raven directed you to originally.

_________________
[b][size=5]openSUSE 11.4-x86 | Linux 2.6.37.1-1.2desktop i686 | KDE: 4.6.41>=4.7 | XFCE 4.8 | AMD Athlon(tm) XP 3000+ | MSI K7N2 Delta-L | 3GB Black Diamond DDR
| GeForce 6200@433Mhz 512MB | Xorg 1.9.3 | NVIDIA 270.30[/size:2b8 
View user's profile Send private message
Guillius







PostPosted: Fri Aug 20, 2004 10:10 am Reply with quote

OMG I just tried answering a big post and said sentinel blocked me.. malybe I didn't BBcode something.. *sighs* will have to retype..
 
Guillius







PostPosted: Fri Aug 20, 2004 10:43 am Reply with quote

Ok I formatted everything safely and still sentinel won't let me post BBcoded scripts etc.. This issue is very important to me. If not to get it to work to at least understand more of the problem. Is there ANY way we could communicate aside from this board? Anyone? I simply have been unable to post the reply. I still have it on a text document.
 
Guillius







PostPosted: Fri Aug 20, 2004 11:28 pm Reply with quote

hmmmm I've tried wording this like if I was talking to a child and still it won't let me post.. saying that I am attacking the site.. What on earth is the problem? Could I maybe post the file or perhaps give a link to it for someone to help me? I am just trying to have a discussion about this and the d***ed forum isn't letting me.

I have typed a text file that has the post I've been trying to get in here for who knows how long today.... of course.. right click and save target as since it will probably process the some of the code examples if you just click on it.

http://www.defendersofthebalance.com/content/ravenpost.txt
 
GeekyGuy
Client



Joined: Jun 03, 2004
Posts: 302
Location: Huber Heights Ohio

PostPosted: Fri Aug 20, 2004 11:35 pm Reply with quote

Guillius,

I took your text file, replaced ALL instances of the word 's c r i p t' and changed it to scr+pt, and I was able to Preview your text here

_________________
"The Daytona 500 is ours! We won it, we won it, we won it!", Dale Earnhardt, February 15th, 1998, Daytona 500 
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
Guillius







PostPosted: Fri Aug 20, 2004 11:38 pm Reply with quote

Ok lets give it a try then...
 
Guillius







PostPosted: Fri Aug 20, 2004 11:39 pm Reply with quote

First, yes I wanted to insert some java to echo out RSS feed into the content page. Raven

did direct me to http://www.ravenphpscr+pts.com/postt28.html

Raven's example was:

Code:
$someVarName = <<<_JSCODE_ 

<scr+pt>alert('Hello World');</scr+pt>
_JSCODE_;

echo $someVarName;


On this portion raven says to simply drop that in the HTML. I am unsure as to what that

means exactly. My link was

Code:
http://eqlive.station.sony.com/news_section/newsfeed_basic.jsp


so I have to do what? This?

Code:
<?

$someVarName = <<<_JSCODE_
<scr+pt language="Javascr+pt"

SRC="http://eqlive.station.sony.com/includes/js_news/eq_headlines.jsp"></scr+pt>
<noscr+pt>The EverQuest Live news requires you to have Javascr+pt turned on.</noscr+pt>
_JSCODE_;

echo$someVarName;

?>


Is that syntax correct? I tried it and says html tags not allowed.
So, I am in a bind I am unsure of whats wrong. Was I supposed to edit the Content Module

php file to have that in it? If I did that, wouldn't every content page do the program?

The rest of that post goes onto explain how to do it in a block, which at this time I am

not interested in.

Moving onto me HAVING to use the content module for this. No, I don't have to use that

specific module. The reason I had, was that when you create content pages, it dispalys it

exactly how I'd like my RSS feeds to be dispalyed. One big table on the righ of the left

blocks. So that moves me to your example.

Code:
if (!eregi("modules.php", $_SERVER['Scr+pt_NAME'])) { 

        die ("You can't access this file directly...");
    }
$mycontent .= "
<Scr+pt language=JavaScr+pt

src=\"./modules.php?name=Syndication&file=index&ac=box&ac2=5&ac3=5\"></Scr+pt>
<Scr+pt language=JavaScr+pt

src=\"./modules.php?name=Syndication&file=index&ac=box&ac2=5&ac3=2\"></Scr+pt>
<Scr+pt language=JavaScr+pt

src=\"./modules.php?name=Syndication&file=index&ac=box&ac2=5&ac3=3\"></Scr+pt>
<Scr+pt language=JavaScr+pt

src=\"./modules.php?name=Syndication&file=index&ac=box&ac2=5&ac3=4\"></Scr+pt>
";
echo "$mycontent";


First I'd like to explain that I don't understand about 90% of whats typed in here, but

mostly I "guess". So lets start the guessing. I am suspecting the first and second line

address security to stop someone from directly accessing that module. Also, that the word

scr+pt has a plus sign in it to avoid security issues with this board. But, is that

telling me that I should insert my own name for my own scr+pt? If so, where is this scr+pt

going to be? Do I need to build one and put it somewhere?

Then it goes on to define a variable with the source of the scr+pt. Lets use my website as

an example and I'll post here what I would do with your example and maybe someone can tell

me where my "understanding" is flawed. So, I am trying to build my own module. Lets say

it needs to echo my own RSS feed. Lets also assume I call the module Syndication, Would

the module then look like this?

Code:
<?php


if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {
    die ("You can't access this file directly...");
}

$mycontent .= " <Scr+pt language=JavaScr+pt

src=\"./modules.php?name=Syndication\"></Scr+pt>
";
echo "$mycontent";

?>


I am assuming of course to replace plus signs with i's but notice I've replaced the

statement on the first line to say self preceeded by the php tag. I've also removed the

stuff after syndication as I don't know what it is.

Moreover.. where are my links to the actuall feed? From the example I don't understand

where to place them.

I apologize for my level of knowledge and I am not looking for someone to do the work for

me. I simply really do not understand mostly how to get it done. ANY help is appreciated.
 
sixonetonoffun







PostPosted: Fri Aug 20, 2004 11:55 pm Reply with quote

<?php // Turns php parser on
//These 3 lines are as you say security
if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {
die ("You can't access this file directly...");
}

$mycontent .= "
// Use any html content here escape all double quotes like this \"
<Scr+pt language=JavaScr+pt
src=\"./modules.php?name=Syndication\"></Scr+pt>
"; // ends mycontent
OpenTable(); // Opens a genric table
echo "$mycontent"; //Prints content above to browser
CloseTable(); // Closes the genric table
?>
Put this into its own directory modules/Your_module_name/ as index.php and if you had the syndication module it would print out in a table in the middle of your page.

I hope this helps a little. If you are still confused you should check out the http://www.ravenphpscripts.com/modules.php?name=PHP-Nuke_HOWTO&page=creating-modules.html pages there is really very little not covered there.
 
Guillius







PostPosted: Fri Aug 20, 2004 11:58 pm Reply with quote

well I'll be a rock... that alone helped immensly... gonna try it out and post results so you can be proud of me... and seriously.. thx for your help! Did not mean to be such a burden. Now, lets see if I can post results.. BUWAHAHAHAHA
 
Guillius







PostPosted: Sat Aug 21, 2004 12:11 am Reply with quote

Ok let me get this straight.. this module above is basically a module made to display another module? which means I'd have to build a module that could take an RSS link feed and and decipher it? If that is so then I understand. I do not however understand how in either HTML or php to "decipher" an RSS. Is there any "generic" php or html code to do that? Or am I not getting it?
 
Guillius







PostPosted: Sat Aug 21, 2004 12:30 am Reply with quote

Ok I found something about Displaying an RSS feed with PHP. Can someone take a look and tell me if this is something that would be compatible to do with nuke in a self made module?

Code:
Parsing an RSS document

Now that you have an understanding of RSS document structure, let's take a look at some code that will parse and display it.

The following code is a collection of five functions that were added to the Code Gallery by uncleozzy. We will take a look at them one by one and examine how they work.

Globals
The functions we are about to look at require some variables in the global scope. The first thing that must be done is to declare and initialize those variables.

$_item = array();
$_depth = array();
$_tags = array("dummy");
/* "dummy" prevents unecessary subtraction
* in the $_depth indexes */

Function initArray()
This function initializes the $_item array by ensuring that all the proper keys are in place and that they all point to an empty string. The author makes very liberal use of this function.

This function will be called each time an opening tag is found for an image, item, or channel. It is also used after the closing tag of each and at the onset of the entire parsing routine. (This may be tending towards overkill.)

{
    global $_item;

    $_item = array ("TITLE"=>"", "LINK"=>"", 
        "DESCRIPTION"=>"", "URL"=>"");
}

Function startElement()
When using the XML functionality of PHP, you must specify a function to be called each time an opening tag is encountered. This function serves that purpose.

As you can see by examining this function, if an opening tag is found for an item, channel, or image element, the initArray is called. Then, whether one of those opening tags was found or not, the $_depth array is incremented and the name of the opening tag is pushed onto the $_tags array.

{
    global $_depth, $_tags, $_item;

    if (($name=="ITEM") || ($name=="CHANNEL") 
          || ($name=="IMAGE")) {
        initArray();
    }
    $_depth[$parser]++;
    array_push($_tags, $name);
}

Function endElement()
Just as you must specify a function to be called for opening tags, you must also specify a function that is called when a closing tag is found. The endElement function handles the actual display of our data. As each closing tag is encountered, this function displays the data that corresponds to that tag. First though, it pops the top element off of the $_tags array, then it decrements the $_depth array. As mentioned earlier, it also calls the initArray function after displaying the pertinent data.

{
    global $_depth, $_tags, $_item;
     
    array_pop($_tags);
    $_depth[$parser]--;
    switch ($name) {
        case "ITEM":
            echo "<p><a href=’{$_item['LINK']}’>" .
                 "{$_item['TITLE']}</a></p>\n";
            initArray();
            break;

        case "IMAGE":
            echo "<a href=’{$_item['LINK']}’>" .
                 "<DEFANGED_IMG src=’{$_item['URL']}’ " .
                 "alt=’{$_item['TITLE']}; border=’0’></a>\n<br />\n";
            initArray();
            break;

        case "CHANNEL":
            echo "<h3>{$_item['TITLE']}</h3>\n";
            initArray();
            break;
    }
}

Function parseData()
This function is where the data is actually stored into the $_item array. When there is data that needs to be parsed, this function is invoked. Data is basically anything that is not an element tag.

The first thing this function does is determine if the data is only whitespace. If it is, it does not bother to store it in the array. If the data does contain useful information, it is stored in the $_item array.

{
    global $_depth, $_tags, $_item;

    $crap = preg_replace ("/\s/", "", $text);
    /* is the data just whitespace?
       if so, we don't want it! */

    if ($crap) {
        $text = preg_replace ("/^\s+/", "", $text);
        /* get rid of leading whitespace */
        if ($_item[$_tags[$_depth[$parser]]]) {
            $_item[$_tags[$_depth[$parser]]] .= $text;
        } else {
            $_item[$_tags[$_depth[$parser]]] = $text; 
        }
    }
}

Function parseRDF()
This function is the wrapper function for all the others. When using this function, you do not need to worry about calling any others.

It starts off by creating the parser, and then it calls the initArray function. The functions for handling the opening and closing tags, and the data itself, are then registered. Next, the function proceeds to open the file specified, parse it, and verify that it is a valid RSS document. The file is then closed and the memory from the parser freed.

{
    global $_depth, $_tags, $_item;

    $xml_parser = xml_parser_create();
    initArray();

    /* Set up event handlers */
    xml_set_element_handler($xml_parser, "startElement", "endElement");
    xml_set_character_data_handler($xml_parser, "parseData");

    /* Open up the file */
    $fp = fopen ($file, "r") or die ("Could not open $file for input");

    while ($data = fread ($fp, 4096)) {
        if (!xml_parse($xml_parser, $data, feof($fp))) {
            die (sprintf("XML error: %s at line %d",
            xml_error_string(xml_get_error_code ($xml_parser)),
            xml_get_current_line_number($xml_parser)));
        }
    }
                   
    fclose($fp);
    xml_parser_free($xml_parser);
}

Example Use
As I mentioned earlier, using this set of functions is as easy as calling the parseRDF function. All you need to do is pass a URL for the RSS document, or a path to a local file..

<?php
    parseRDF("http://www.zend.com/news.rss");
?>
 
Display posts from previous:       
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Ravens PHP Scripts And Web Hosting Forum Index -> phpnuke 7.2

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©