
23/12/2005, 07:00
|
 | | | Fecha de Ingreso: diciembre-2004
Mensajes: 453
Antigüedad: 20 años, 4 meses Puntos: 0 | |
ok,mira este es el codigo que modifique: Código PHP: <?php
/*
Project: playRSSwriter: RSS 2.0 writer with images support
File: playRSSwriter.php
Author: Eduardo Perez Orue <[email protected]>
Version: 0.90
For the latest version of the writer, questions, help, comments,
etc., please visit:
http://hombrelobo.com/rss/playrsswriter.htm
You can download the script here:
http://playlingerie.com/playrsswriter/playRSSwriter.php.txt
What is playRSSwriter ?
When working on creating a rss feed for our site http://playlingerie.com,
we realized that all the existing php writers were either for rss 1.0 or for
rss 2.0 but without support for embeded images. So I created this code.
You can see it in action in:
http://playlingerie.com/rss.php (machines) or
http://feeds.feedburner.com/sexy-lingerie (humans)
Enjoy it !!
******************************************************************************
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE.
This work is hereby released into the Public Domain. To view a copy of
the public domain dedication, visit
http://creativecommons.org/licenses/publicdomain/ or send a letter to
Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
******************************************************************************
*/
// First we start defining all the variables that we will insert in the
// xml code.
// Insert here the the title of your feed
$rss_title= "Title of your feed";
// Insert your site, in the format site.com
$rss_site= "localhost" ;
// Insert the description of your website
$rss_description= "Description of your website";
// Applicable language of the feed. For spanish, change to "es"
$rss_language="es";
// Address of the logo file. Only need to put the file name
$rss_logo="http://".$rss_site."logo.jpg";
// the feed's author email
$emailadmin="[email protected]";
// set the file's content type and character set
// this must be called before any output
header("Content-Type: text/xml;charset=iso-8859-1");
$phpversion = phpversion();
//set the beginning of the xml file
ECHO <<<END // esta es la linea que me molesta
<? xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss">
<channel>
<title>$rss_title</title>
<link>http://www.$rss_site</link>
<description>$rss_description</description>
<language>$rss_language-$rss_language</language>
<docs>http://backend.userland.com/rss</docs>
<generator>PHP/$phpversion</generator>
<image>
<url>$rss_logo</url>
<title>$rss_site</title>
<link>http://$rss_site/</link>
</image>
END;
// Now the variables about the individual items to appear in the feed. Here we
// take them from a MySQL database, but can also come from a included file
// Define database
$server = "localhost"; // Server
$rss_database = "test" ; // Database name
$db_user ="Mysql" ; // Database user
$db_pass = "" ; // Database password
// Open the database
$db = mysql_connect($server,$db_user,$db_pass);
mysql_select_db($rss_database,$db);
// Calculate the number of records in the table "noticias"
$num_rows = mysql_num_rows(mysql_query("select * from noticias"));
// Select all the records from the table "noticias". You can modify the
// query to only select some records, change the order, etc.
$query = "select * from noticias" ;
$result = mysql_query($query) or die("Query failed") ;
//Make a loop to create the feed for all the items selected
while ($results = mysql_fetch_array($result))
{
// Pass the database field Photo_name to the variable $photo_name
// The Photo_name has to include the relative path,
// for instance: $photo_name="images/photo1.jpg";
$photo_name = $results['Photo_name'] ;
// Pass the record URL_product to the variable $url_product. It also
// has to include the relative path, like in: "path/product1.htm"
$url_product = $results['URL_product'] ;
// Pass the record Description to the variable $description
$description = $results['Description'] ;
// Clean the description
$description = str_replace ("&","",htmlspecialchars(stripslashes($description)));
// Pass tags to describe the product
$rss_tags = $results['Product_tags'] ;
// If you don't have tags for the product, simply change to a fixed value,
// for instance put:
// $rss_tags="tag1 tag2";
// Make a short description for titles of only 75 characters
$short_description = substr($description,0,75) . "...";
$counter ++ ;
// Calculate the size of the image and resize it to a thumbnail
$photo_size= getimagesize($photo_name) ;
$photo_width = $photo_size[0] ;
$photo_height = $photo_size[1] ;
unset($height_limit,$width_limit) ;
if ($photo_height > $photo_width )
$photo_height= "90" ;
else
$photo_width = "80" ;
// Create the html for the description item. No need to modify this unless
// you want to change the look
$content="<p><a href=\"http://$rss_site/$url_product\">$description</a></p>
<p><a href=\"http://$rss_site/$url_product\" title=\"$description\"><img src=\"$photo_name\" width=\"$photo_width\" height=\"$photo_height\" alt=\"$short_description\" style=\"border: 1px solid #000000;\" /></a></p>
<p>$rss_site</p>" ;
// Escape all the descriptions
$content = preg_replace(array('/</', '/>/', '/"/'), array('<', '>', '"'), $content);
// display an item
ECHO <<<END
<item>
<title>$short_description</title>
<link>
http://$rss_site/$url_product
</link>
<description>
$content
</description>
<author>$emailadmin</author>
<media:content url="$photo_name" type="image/jpeg" height="$photo_height" width="$photo_width"/>
<media:title>$description</media:title>
<media:text type="html">
<p><a href="http://$rss_site/$url_product">$description</a></p>
<p><a href="http://$rss_site/$url_product" title="$short_description"><img src="$photo_name" width="$photo_width" height="$photo_height" alt="$short_description" style="border: 1px solid #000000;" /></a></p>
<p>$rss_site</p>
</media:text>
<media:thumbnail url="$photo_name" height="$photo_height" width="$photo_width"/>
<media:category scheme="urn:$rss_site:tags">
$rss_tags
</media:category>
</item>
END;
}
// Close the database
mysql_close();
// And end the xml file
ECHO <<<END
</channel>
</rss>
END;
// Done !! Use http://feedvalidator.com to verify that it's correct.
?> Esta es la linea:
ECHO <<<END
gracias ;) |