Jump to content

Change Title and image


Atdheu

Recommended Posts

How can I change title to another and to delete this image:

You can see in Image what I like to do:

45507385kr1.jpg

 

Here is the original code I use:

<?php
# Lajme scripti

$file = "http://www.telegrafi.com/rss.php?f=tekno";
$charset = "utf-8";
$full_report = true;
$hide_channel_name = false;
$max_items = 10;
$date_format = "d-m-Y";

$file    = (isset($_GET['feed']))     ? ($_GET['feed'])     : $file;
$charset = (isset($_GET['encoding'])) ? ($_GET['encoding']) : $charset;

set_time_limit(0);
$rss_channel = array();
$currently_writing = "";
$main = "";
$item_counter = 0;

function startElement($parser, $name, $attrs)
{
   global $rss_channel, $currently_writing, $main;
   switch($name)
   {
      case "RSS":
      case "RDF:RDF":
      case "ITEMS":
         $currently_writing = "";
         break;
      case "CHANNEL":
         $main = "CHANNEL";
         break;
      case "IMAGE":
         $main = "IMAGE";
         $rss_channel["IMAGE"] = array();
         break;
      case "ITEM":
         $main = "ITEMS";
         break;
      default:
         $currently_writing = $name;
         break;
   }
}

function endElement($parser, $name)
{
   global $rss_channel, $currently_writing, $item_counter;
   $currently_writing = "";
   if ($name == "ITEM")
   {
      $item_counter++;
   }
}

function characterData($parser, $data)
{
   global $rss_channel, $currently_writing, $main, $item_counter;
   if ($currently_writing != "")
   {
      switch($main)
      {
         case "CHANNEL":
            if (isset($rss_channel[$currently_writing]))
            {
               $rss_channel[$currently_writing] .= $data;
            }
            else
            {
               $rss_channel[$currently_writing] = $data;
            }
            break;
         case "IMAGE":
            if (isset($rss_channel[$main][$currently_writing]))
            {
               $rss_channel[$main][$currently_writing] .= $data;
            }
            else
            {
               $rss_channel[$main][$currently_writing] = $data;
            }
            break;
         case "ITEMS":
            if (isset($rss_channel[$main][$item_counter][$currently_writing]))
            {
               $rss_channel[$main][$item_counter][$currently_writing] .= $data;
            }
            else
            {
               $rss_channel[$main][$item_counter][$currently_writing] = $data;
            }
            break;
      }
   }
}

$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
if (function_exists('curl_init'))
{
   $ch = curl_init($file);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   $data = curl_exec($ch);
   curl_close($ch);
}
else
{
   @ini_set('allow_url_fopen', 1);
   $data = file_get_contents($file);
}
xml_parse($xml_parser, $data) or die(sprintf("XML error: %s at line %d",
   xml_error_string(xml_get_error_code($xml_parser)),
   xml_get_current_line_number($xml_parser)));
xml_parser_free($xml_parser);
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Falas.org - Teknologji</title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>">
<style type="text/css">
body
{
   background-color: #FFFFFF;
}
.channel
{
   background-color:#D8E5FF;
   text-align:left;
   width:100%;
}
a.channel:link, a.channel:visited
{
   font-weight: bold;
   text-decoration: none;
   font-size: 19px;
   font-family:Arial;
   color:#000000;
}
a.channel:hover
{
   color:#C0C0C0;
}
.item
{
   text-align:left;
   width:100%;
}
a.item:link, a.item:visited
{
   color: #000000;
   font-weight: bold;
   text-decoration: none;
   font-size: 13px;
   font-family:Arial;
}
a.item:hover
{
   color: #C0C0C0;
}
.itemdescr
{
   font-weight: normal;
   text-decoration: none;
   font-size:13px;
   font-family:Arial;
   color:#000000;
   width:100%;
}
.itempubdate
{
   font-weight: normal;
   text-decoration: none;
   font-size:13px;
   font-family:Arial;
   color:#636363;
   text-align:right;
}
</style>
</head>
<body>
<?php
if ($hide_channel_name == false)
{
   echo '<div class="channel">'."\n";
   echo ' <a href="'.$rss_channel['LINK'].'" target="_blank" class="channel"';
   if (isset($rss_channel['DESCRIPTION']))
   {
      echo ' title="'.$rss_channel['DESCRIPTION'].'"';
   }
   echo '>'.$rss_channel['TITLE'].'</a>'."\n";
   if (isset($rss_channel['IMAGE']) && $full_report == true)
   {
      echo ' <br>'."\n";
      echo ' <a href="'.$rss_channel['IMAGE']['LINK'].'" target="_blank">'."\n";
      echo '  <img src="'.$rss_channel['IMAGE']['URL'].'" border="0" alt="'.$rss_channel['IMAGE']['TITLE'].'" title="'.$rss_channel['IMAGE']['TITLE'].'">'."\n";
      echo ' </a>'."\n";
   }
   echo '</div>'."\n";
}
if (isset($rss_channel['ITEMS']) && count($rss_channel['ITEMS']) > 0)
{
   for ($i=0; $i < count($rss_channel['ITEMS']) && ($i < $max_items || $max_items == 0); $i++)
   {
      echo '<div class="item">'."\n";
      echo ' <a href="'.$rss_channel['ITEMS'][$i]['LINK'].'" target="_blank" class="item">'."\n";
      echo '  '.$rss_channel['ITEMS'][$i]['TITLE']."\n";
      echo ' </a>'."\n";
      if ($full_report == true)
      {
         if (isset($rss_channel['ITEMS'][$i]['DESCRIPTION']))
         {
            echo ' <div class="itemdescr">'."\n";
            echo '  '.$rss_channel['ITEMS'][$i]['DESCRIPTION']."\n";
            echo ' </div>'."\n";
         }
         if (isset($rss_channel['ITEMS'][$i]['PUBDATE']))
         {
            echo ' <div class="itempubdate">'."\n";
            echo '  '.date($date_format,strtotime($rss_channel['ITEMS'][$i]['PUBDATE']))."\n";
            echo ' </div>'."\n";
         }
      }
      echo '</div>'."\n";
   }
}
else
{
   echo 'There are no articles in this feed.';
}
?>
</body>
</html>

 

Link to comment
Share on other sites

You can get rid of the image by commenting out this block:

if (isset($rss_channel['IMAGE']) && $full_report == true)
{
   echo ' <br>'."\n";
   echo ' <a href="'.$rss_channel['IMAGE']['LINK'].'" target="_blank">'."\n";
   echo '  <img src="'.$rss_channel['IMAGE']['URL'].'" border="0" alt="'.$rss_channel['IMAGE']['TITLE'].'" title="'.$rss_channel['IMAGE']['TITLE'].'">'."\n";
   echo ' </a>'."\n";
}

 

Changing the title:

//Change this:
echo '>'.$rss_channel['TITLE'].'</a>'."\n";
//To this...
preg_match('/^Telegrafi.com - (.*)/',$rss_channel['TITLE'],$m);
echo '>'.$m[1].'</a>'."\n";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.