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

0 Members and 1 Guest are viewing this topic.

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: [MOD] RSS Feed 0.1
« Reply #75 on: January 12, 2006, 03:28:09 PM »
@sigma,

I think ... in rss.php ... but I don't know your rss-files ... !
I designed my rss-feeds, by using html-tags, completely in rss.php with ...
Code: [Select]

$content .= " ... here html-content ... ";

mawenzi
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline sigma

  • Full Member
  • ***
  • Posts: 127
    • View Profile
    • http://cydonian.com
Re: [MOD] RSS Feed 0.1
« Reply #76 on: January 12, 2006, 05:14:00 PM »
ah I see. Where would i put this 'content' code?

Heres what my rss.php looks like.

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://www.cydonian.com/photos'); //no trailing slash
define('LANGUAGE', 'EN');

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_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";
$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)){
  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>";
  $site_template->register_vars(array(
  "thumbnail" => $thumb,
      "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']." RSS Feed",
    "language" =>LANGUAGE,
    "ititle" =>"",    
    "iurl" => SCRIPT_URL."/".TEMPLATE_PATH."/images/header_logo.gif",
    "ilink" => SCRIPT_URL,
    "items" => $new_images,  
    )
      );
header("Content-type: text/xml");
$site_template->print_template($site_template->parse_template($main_template));
?>

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 #77 on: February 05, 2006, 06:26:24 AM »
below
Code: [Select]
include(ROOT_PATH."global.php");insert this:
Code: [Select]
$user_access = get_permission();
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 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 #78 on: February 05, 2006, 08:51:44 PM »
oh...found the misstake
I've update this topic:
http://www.4homepages.de/forum/index.php?topic=8240.msg43565#msg43565
redo all the steps again ;) you dont need sessions.php.
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 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 #79 on: February 06, 2006, 02:24:58 PM »
It says "ABOVE" and not "BELOW" ;)
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 Flo2005

  • Full Member
  • ***
  • Posts: 237
  • Copy & Paste Profi :)
    • View Profile
    • snuup.de! - Bilder - Sounds - Videos - fun4FREE!
Re: [MOD] RSS Feed 0.1
« Reply #80 on: February 07, 2006, 09:09:08 PM »
I must do the following changes to get my rss.php to run

Quote
In includes/templates.php find:
Code:
    error_reporting($old);
Insert below:
Code:
    $str = preg_replace(
            "/<!--\\\\ open tag (.+) \\\\-->(.*)<!--\\\\ close tag \\\\-->/siU",
            "<?\\1\\2?>",
            $str
    );

Then find:
Code:
    // Compile variables in PHP code
Insert above:
Code:
    $template = preg_replace(
            "/<\?+((?!php )(?!=)(?! ).+ )(.*)\?+>/siU",
            "<!--\\\\ open tag \\1 \\\\-->\\2<!--\\\\ close tag \\\\-->",
            $template
    );

But when I do this changes, my Random Banner MOD won´t work any longer  :?

Here is my banner_random.php

Code: [Select]
<?php

/* Banner Simple, Version 1.0
 * by Dan Kaplan <dan@abledesign.com>
 * Last Modified: January 10, 2003
 * --------------------------------------------------------------------
 *
 * USE THIS LIBRARY AT YOUR OWN RISK; no warranties are expressed or
 * implied. You may modify the file however you see fit, so long as
 * you retain this header information and any credits to other sources
 * throughout the file.  If you make any modifications or improvements,
 * please send them via email to Dan Kaplan <dan@abledesign.com>.
 * --------------------------------------------------------------------
*/

$base_dir '/www/htdocs/my_account/lite/';
$img_url 'http://www.snuup.de/lite/templates/lite/images/banner';

// add any banner sizes (width x height) that you will use:
// IAB Standards & Guidelines:  http://www.iab.net/standards/adunits.asp
$banner_sizes = array ("468x60""100x60""100x38""300x250""250x250""240x400""336x280""180x150""500x74""234x60""88x31""120x90""120x60""120x240""125x125""160x600""120x600");

$srand_called FALSE;
$last_file '';
$array '';

function 
get_banner($size='') {
global $base_dir$img_url$banner_sizes$srand_called$last_file$array;

if (empty($size) || !in_array($size$banner_sizes)) {
$size "468x60";
}

$size_split explode("x"$size);
$width $size_split[0];
$height $size_split[1];

if (empty($last_file) || ($size != $last_file) || !is_array($array)) {
// if calling muliple banners on one page, no need to read in the same file repeatedly.  so,
// if the last banner file read in is the next one called, pull the $array array from memory.

$file $base_dir."/templates/lite/images/banner/mybanner_".$size.".txt";
if (!file_exists($file)) {
// could not load the banner file, so create a default blank image and exit
$banner "<img src=\"\" width=\"$width\" height=\"$height\" border=\"0\" alt=\"Bild kaputt\">";
return $banner;
}
$array file($file); // read $file into an array
$last_file $size; // save the last read-in file into memory
}

if (!$srand_called) {
// slightly less random without this; srand() should only be called once for multiple banners
mt_srand ((double) microtime() * 1000000);
$srand_called TRUE;
}

$rand mt_rand(1count($array)-1); // start at 1 to ignore comment line
$line chop($array[$rand]);

# URL | target="_blank" (1/0) | off-site image (1/0) | image | Alt text
$banner_split explode("|"$line);
$URL $banner_split[0];
$blank $banner_split[1];
$off_site $banner_split[2];
$image $banner_split[3];
$alt $banner_split[4];

if ($blank == 1) {
$target "target=\"_blank\"";
} else {
$target "";
}

if ($off_site == 1) {
$image $image;
} else {
$image "$img_url/$image";
}

$banner "<a href=\"$URL\" $target><img src=\"$image\" width=\"$width\" height=\"$height\" border=\"0\" alt=\"$alt\"></a>";
return $banner;
}

?>

Somebody got the plan  :| ?

Project offline

Offline Flo2005

  • Full Member
  • ***
  • Posts: 237
  • Copy & Paste Profi :)
    • View Profile
    • snuup.de! - Bilder - Sounds - Videos - fun4FREE!
Re: [MOD] RSS Feed 0.1
« Reply #81 on: February 11, 2006, 10:18:23 AM »
Okay, now it works!

But where can I set to show only files which are younger e.g. 7 days :?:

Now my rss.php shows me files which are older than 7 days...

THX by Flo

Project offline

Offline graficalicus

  • Full Member
  • ***
  • Posts: 235
    • View Profile
Re: [MOD] RSS Feed 0.1
« Reply #82 on: March 03, 2006, 02:13:15 AM »
way back on page 1 of this thread, I asked about removing " ' ", " & ", " ; " , etc., characters and got this reply:

Quote
"description" => stripslashes($image_row["image_description"])

this should work (not tested).

it didn't work  :?

Can anyone suggest a fix for this - some kind of character substitution like
Code: [Select]
In includes/templates.php find:
Code:
    error_reporting($old);
Insert below:
Code:
    $str = preg_replace(
            "/<!--\\\\ open tag (.+) \\\\-->(.*)<!--\\\\ close tag \\\\-->/siU",
            "<?\\1\\2?>",
            $str
    );

Then find:
Code:
    // Compile variables in PHP code
Insert above:
Code:
    $template = preg_replace(
            "/<\?+((?!php )(?!=)(?! ).+ )(.*)\?+>/siU",
            "<!--\\\\ open tag \\1 \\\\-->\\2<!--\\\\ close tag \\\\-->",
            $template
    );

?  Any time a user uses one of those characters in their image description while uploading, it craps out the feed....

Thanks -

Offline graficalicus

  • Full Member
  • ***
  • Posts: 235
    • View Profile
Re: [MOD] RSS Feed 0.1
« Reply #83 on: March 09, 2006, 10:47:36 PM »
HA HA! HO HO! :D  i fixed it -

simply move the {description} tag inside the CDATA tag, as mentioned earlier in this thread - -

Magpie likes it, Feedburner[/url] likes it -

the only change is in rssitem.html (mine looks like this - yours may be different):
Code: [Select]
<item>
  <title>{category}/{title}</title>
 <link>
  {link}
</link>
<description>
<![CDATA[{thumbnail}
{description}]]>   
  </description>
</item>

 :mrgreen:

Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
Re: [MOD] RSS Feed 0.1
« Reply #84 on: March 27, 2006, 04:11:48 AM »
this give me this error Fatal error: Call to a member function on a non-object in /home/blacktra/public_html/rss.php on line 57

and here is my rss.php

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://www.*******.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_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";
$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)){
  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>";
  $site_template->register_vars(array(
                      "thumbnail" => $thumb,
      "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']." RSS Feed",
    "language" =>LANGUAGE,
    "ititle" =>"The title of your feed",    
    "iurl" => SCRIPT_URL."/".TEMPLATE_PATH."/images/header_logo.gif",
    "ilink" => SCRIPT_URL,
    "items" => $new_images,  
    )
      );
header("Content-type: text/xml; charset=\"ISO-8859-1\"");
$site_template->print_template('<?xml version="1.0" encoding="ISO-8859-1"?>'.$site_template->parse_template($main_template));

?>

Offline BartAfterDark

  • Hero Member
  • *****
  • Posts: 520
    • View Profile
Re: [MOD] RSS Feed 0.1
« Reply #85 on: April 16, 2006, 05:25:36 PM »
I have a problem when I try to view the RSS with Internet Explorer. Some of the categorys has a ' in then. But IE doesn't like that. Anyway workaround for this?

Offline sigma.

  • Full Member
  • ***
  • Posts: 148
  • cydonian.com/potd
    • View Profile
    • sigma's gallery
Re: [MOD] RSS Feed 0.1
« Reply #86 on: April 11, 2007, 06:11:26 PM »
Is there a way to use the larger image insted of the thumbnail image to be displayed in the feed?

Offline sigma.

  • Full Member
  • ***
  • Posts: 148
  • cydonian.com/potd
    • View Profile
    • sigma's gallery
Re: [MOD] RSS Feed 0.1
« Reply #87 on: May 27, 2007, 03:47:27 AM »
Anyone know how to exclude certain categories from the RSS Feed? I have had success with tweaking the index.php to exclude certain categories from New Images but have not had success copying that code into the rss.php

Heres the exclude from index.php tweak
http://www.4homepages.de/forum/index.php?topic=16348.0

Offline cronk005

  • Newbie
  • *
  • Posts: 44
    • View Profile
    • Travelingtheworldaround
Re: [MOD] RSS Feed 0.1
« Reply #88 on: June 09, 2007, 06:06:17 AM »
Hi There--

So how would one go about getting this to work with the multilang() function so that it does not say the entire [language]wording wording wording[/] [language2]wording wording wording[/].

Regards,

Offline sigma.

  • Full Member
  • ***
  • Posts: 148
  • cydonian.com/potd
    • View Profile
    • sigma's gallery
Re: [MOD] RSS Feed 0.1
« Reply #89 on: June 17, 2007, 09:35:06 PM »
With the new Google Reader site http://www.google.com/reader/view/

I think this RSS feed really needs a non thumbnail view.

How can we show the full image insted of the thumbnail?