Author Topic: [MOD] RSS Feed 0.1  (Read 143227 times)

0 Members and 1 Guest are viewing this topic.

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
[MOD] RSS Feed 0.1
« on: June 04, 2005, 01:06:09 AM »
Originally posted by falti.  This is being restored from saved search engine cache pages

Installation:
1. Open rss.php and modify CONFIG values.
2. Upload rss.php to 4images root directory. Upload rss.html and rssitem.html to your template directory (i.e. templates/yourtemplate/).
3. Modify your template that user have a link to rss.php. Or simply upload the modified footer.html to your templates folder.

Notes:
Currently there is no check if a user is allowed to view an image presented via rss. This is due to the fact, that a user reading the rss feed is not logged in to the 4images system. If you find a solution for this problem feel free to modify the script and let me know how you made it.
If most of your categories are open for unregistered users then you can use a sql statement similar to index.php.

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Re: [MOD] RSS Feed 0.1
« Reply #1 on: June 04, 2005, 01:11:47 AM »
Originally posted by ptitpierre
That's fine, but when I am not logged in and when I select a picture which is in a private category (I mean you must be logged in to see the pic) I have the Index page.

Is there a possibility to have différent RSS feeds according to the user logged in (or not logged in for visitors) ?

Thanks in advance !

Pierre

Originally posted by nette
Parse error: parse error, unexpected T_STRING in /home/electrii/public_html/gallery/includes/template.php(101) : eval()'d code on line 1


http://ataraxy.net/~electrii/gallery/rss.php

if someone could help me out I would be grateful

---

Hmm I think it's funny how I posted under the correct forum to get help for this mod the first time and I never got a response so I posted somewhere else thinking maybe no one read this one and I get this

http://www.4homepages.de/forum/viewtopic.php?t=3914
#5 from one of the moderators.

Now I am posting back under the same original thread for the mod and still no reply. Doesn't make any sense to me.

Originally posted by falti
It was a quick and dirty hack. I thought someone could use it, modify it whatever. I am currently busy and cannot give support. I also have the problem that the hack works fine at my 4images version (4images 1.7) so why don't you look at /home/electrii/public_html/gallery/includes/template.php(101) : eval()'d code on line 1
and try to fix it by yourself?

Originally posted by graficalicus
just a little help needed for this - which is working well, BTW - but one issue:

If a user uploads an image, and in their comments about the image they include a URL or a " ' " character (like "it's" or "your's" or 'look out below!' ) it craps out the RSS feed -

I need a stripslashes kind of command - but I'm not sure where to place it - so these characters don't interrupt the feed -

this is the complete rss.php file:
Code: [Select]
<?
/*************************************************
 * RSS Feed for 4images                          *
 * beta 0.1                                      *
 * Email:
 */

//------------ CONFIG ----------------------------

$num_new_images = 10;
/*
 u can uncomment this, if you want to use config variables from 4images config
 $num_new_images = $config['image_cells'];
*/

//because we have no session here, we have to hardcode this values
define('SCRIPT_URL', 'http://digiart.graficalicus.com'); //no trailing slash
define('LANGUAGE', 'en-us');

define('ROOT_PATH', './');

//----- END CONFIG--------------------------------------------

include(ROOT_PATH.'global.php');
$main_template = 'rss';



$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, c.cat_name
        FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c
        WHERE i.image_active = 1 AND c.cat_id = i.cat_id
        ORDER BY i.image_date DESC
        LIMIT $num_new_images";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);
$format="Y-m-d\TH:i:s+00:00"; //the time format for rss date
while($image_row = $site_db->fetch_array($result)){
  $site_template->register_vars(array(
                  "title" => $image_row["image_name"],             
                  "description" => $image_row["image_description"],
                  "category_domain" => SCRIPT_URL."/categories.php?cat_id=".$image_row["cat_id"],
                  "category" => $image_row["cat_name"],
                  "link" => SCRIPT_URL."/details.php?image_id=".$image_row["image_id"],
                  "date" => format_date($format,$image_row["image_date"]),
                  ));
  $new_images.=$site_template->parse_template("rssitem");
 }

//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(
               array(
                "ctitle" => $config['site_name'],
                "clink" => SCRIPT_URL,
                "cdescription" => $config['site_name']." Last 5 images",
                "language" =>LANGUAGE,
                "ititle" =>"digiart galleries at the graficalicus workshop",               
                "iurl" => SCRIPT_URL."/digiart-graf_banner.gif",
                "ilink" => SCRIPT_URL,
                "items" => $new_images,             
                )
               );
header("Content-type: text/xml");
$site_template->print_template($site_template->parse_template($main_template));
?>


thanks in advance -

Originally posted by falti
"description" => stripslashes($image_row["image_description"])

this should work (not tested).

Originally posted by V@no
I dont know exactly how all this RSS works, but would it be a problem if someone use < and > signs in the description (url html link)?
if so, u'll probably need to replace them with &lt; and &gt;
As of the appostrophe, why would it give any problems if RSS uses tags simular to HTML? just curious.
I dont know exactly how all this RSS works, but would it be a problem if someone use < and > signs in the description (url html link)?
if so, u'll probably need to replace them with &lt; and &gt;
As of the appostrophe, why would it give any problems if RSS uses tags simular to HTML? just curious.

Originally posted by AntiNSA2
his mod works great for me in opera.... I wanted to add one thing

open up header.html and add this
Code: [Select]
<link rel="alternate" type="application/rss+xml" title="TheCenterOfTheNet All Lives Stills Newest Images Feed" href="http://www.thecenterofthenet.com/4images/rss.php" />to get an RSS button to appear in opera/fav browser......

But my request would be if you could modify this mod ...

Some people use different templates for different categories.... it would nice to beable to place this within category specific template that way the user could only select feeds from the categories they are interested in in addition to the newest images for the whole database.

Thanks!

Offline graficalicus

  • Full Member
  • ***
  • Posts: 235
    • View Profile
Re: [MOD] RSS Feed 0.1
« Reply #2 on: June 04, 2005, 07:40:05 PM »
(posted in the Member Template Select thread also, but I guess I should have poted here...  :oops: )


Can anyone help with "hard-coding" this RSS  to a special category template?   When I install the Member Select Template MOD, it moves code from global.php to sessions.php, making the two MODs incompatible with each other  :(

Does anyone have a solution?  Thanks-
 
 

Offline Maweryk

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: [MOD] RSS Feed 0.1
« Reply #3 on: June 09, 2005, 12:26:58 AM »
It is possible to add thumbs?

Cheers,

Markus

Offline firefall

  • Pre-Newbie
  • Posts: 4
    • View Profile
Re: [MOD] RSS Feed 0.1
« Reply #4 on: June 09, 2005, 08:00:30 PM »
4Images Version: 1.7.1
Mods already added: Memberlist, Cat Image, Mass Image Edit, Star Rating
Site: http://www.lunaescence.com/fanart/

Error:
Code: [Select]
Parse error: parse error, unexpected T_STRING in /home/*******/public_html/fanart/includes/template.php(101) : eval()'d code on line 1
Has anyone figured out why this error happens?

I tried fixing it myself, but nothing has worked.  I even tried commenting that whole section ("Don't show error notces") out as an experiemnt.

Line 101 in template.php looks like this:

Code: [Select]
eval("?>".$template."<?php return 1;");
I'm about to give up, since I can't figure out what the problem is.  But I'd really like to use this mod, since the rest of my site has RSS.  Any thoughts?

Thanks

Offline graficalicus

  • Full Member
  • ***
  • Posts: 235
    • View Profile
Re: [MOD] RSS Feed 0.1
« Reply #5 on: June 09, 2005, 10:04:34 PM »
try this -
in rss.php, find
Code: [Select]
include(ROOT_PATH.'global.php');and just below it add
Code: [Select]
include(ROOT_PATH.'includes/sessions.php');
(this from V@no on the Member Template Select thread)  :wink:

Offline firefall

  • Pre-Newbie
  • Posts: 4
    • View Profile
Re: [MOD] RSS Feed 0.1
« Reply #6 on: June 10, 2005, 12:02:24 AM »
Yeah, I saw that in the other thread, that was my last attempt before I gave up for a bit.

 http://www.lunaescence.com/fanart/rss.php

Thanks though  :?

Offline graficalicus

  • Full Member
  • ***
  • Posts: 235
    • View Profile
Re: [MOD] RSS Feed 0.1
« Reply #7 on: June 10, 2005, 12:28:20 AM »
have you edited RSS.html template?

you're calling two top layer elements - you can only call one, and the others must be sub-elements -

also the xml version must be stated - paste this into line 1 of the template:
Code: [Select]
<?xml version="1.0" encoding="ISO-8859-1"?>
my entire rss.html is:
Code: [Select]
<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>{ctitle}</title>
    <link>{clink}</link>
    <description>{cdescription}</description>
    <language>{language}</language>
    <image>
      <title>{ititle}</title>
      <url>{iurl}</url>
      <link>{ilink}</link>
    </image>
    {items}
  </channel>
</rss>

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] RSS Feed 0.1
« Reply #8 on: June 10, 2005, 12:38:41 AM »
Error:
Code: [Select]
Parse error: parse error, unexpected T_STRING in /home/*******/public_html/fanart/includes/template.php(101) : eval()'d code on line 1
Has anyone figured out why this error happens?

This error acure because rss.html template has:
Quote
<?xml version="1.0" encoding="ISO-8859-1"?>
And 4images new template engine chokes on such code.
For now, I dont have a very good fix for u, but try this work around.
Remove that line from rss.html template.
Then in rss.php replace:
Code: [Select]
$site_template->print_template($site_template->parse_template($main_template));with:
Code: [Select]
$site_template->print_template('<?xml version="1.0" encoding="ISO-8859-1"?>'.$site_template->parse_template($main_template));
(not tested)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline firefall

  • Pre-Newbie
  • Posts: 4
    • View Profile
Re: [MOD] RSS Feed 0.1
« Reply #9 on: June 10, 2005, 01:01:40 AM »
That worked!   :D Thanks, graficalicus and V@no!

b.o.fan

  • Guest
Re: [MOD] RSS Feed 0.1
« Reply #10 on: June 12, 2005, 01:05:05 PM »
in rss.php i got this error.

Quote
Fatal error: Call to a member function on a non-object in /home/www/htdocs/wartenaufden15.de/includes/sessions.php on line 311

can somebody help me?

Offline Maweryk

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: [MOD] RSS Feed 0.1
« Reply #11 on: June 12, 2005, 07:27:27 PM »
I tried to add thumbs to the RSS feed.

rss.php:

After
Code: [Select]
$site_template->register_vars(array( add:

Code: [Select]
"thumbnail" => get_thumbnail_code($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $mode, $show_link),
Replace the sql statemant to:

Code: [Select]
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_thumb_file, i.image_media_file, i.image_keywords, i.image_date, i.image_active, c.cat_name
        FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c
        WHERE i.image_active = 1 AND c.cat_id = i.cat_id
        ORDER BY i.image_date DESC
        LIMIT $num_new_images";

rssitem.html:

After <description> add:

Code: [Select]
<![CDATA[{thumbnail}]]>
Now I need your help. I see a border for a thumb in my RSS-Reader, but without the picture.
The reason:
Code: [Select]
<description>
- <![CDATA[ <a href="./details.php?image_id=9268"><img src="./data/thumbnails/218/XXX.JPG" border="1" width="90" height="61" alt="" /></a>
  ]]>

How can I add the rest of my website address?: href="domain.de/4images/???

Thanks a lot.

Markus



Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] RSS Feed 0.1
« Reply #12 on: June 12, 2005, 08:51:25 PM »
Code: [Select]
"thumbnail" => SCRIPT_URL."/".get_thumbnail_code($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $mode, $show_link),
Also, I'd suggest u replace $mode, $show_link with: "", 0 because these two variables are not set and might produce warning messages ;)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Maweryk

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: [MOD] RSS Feed 0.1
« Reply #13 on: June 12, 2005, 08:57:51 PM »
Thanks, now I get:

Code: [Select]
<![CDATA[ http://www.domain.de/4images/<a href="./details.php?image_id=9268"><img src="./data/thumbnails/218/xxx.JPG" border="1" width="90" height="61" alt="" /></a>
  ]]>


Any other idea?

Cheers,

Markus

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] RSS Feed 0.1
« Reply #14 on: June 12, 2005, 09:40:27 PM »
ops...
try this then:
below:
Code: [Select]
while($image_row = $site_db->fetch_array($result)){Insert this:
Code: [Select]
  if (!check_media_type($image_row['image_media_file']))
  {
    $file_src = ICON_PATH."/404.gif";
  }
  else
  {
    if (!get_file_path($image_row['image_thumb_file'], "thumb", $image_row['cat_id'], 0, 0))
    {
      $file_src = ICON_PATH."/".get_file_extension($image_row['image_media_file']).".gif";
    }
    else
    {
      $file_src = get_file_path($image_row['image_thumb_file'], "thumb", $image_row['cat_id'], 0, 1);
    }
  }
  $image_info = @getimagesize($file_src);
  $width_height = (!empty($image_info[3])) ? " ".$image_info[3] : "";
  $file_src = SCRIPT_URL."/".str_replace(ROOT_PATH, "", $file_src);
  $thumb = "<a href=\"".SCRIPT_URL."/details.php?".URL_IMAGE_ID."=".$image_row['image_id']."\"><img src=\"".$file_src."\" border=\"1\"".$width_height." alt=\"".$image_row['image_name']."\" /></a>";


Then replace line from your original code:
Code: [Select]
"thumbnail" => get_thumbnail_code($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $mode, $show_link), with this:
Code: [Select]
    "thumbnail" => $thumb,
P.S. which RSS reader do u use that can show thumbnails? :?:
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)