Skip to Content.
Sympa Menu

cacert-devel - Re: Patch Request Bug #1190

Subject: CAcert Code Development list.

List archive

Re: Patch Request Bug #1190


Chronological Thread 
  • From: Wytze van der Raay <wytze AT cacert.org>
  • To: Benny Baumann <benbe AT cacert.org>
  • Cc: "critical-admin AT cacert.org" <critical-admin AT cacert.org>, cacert-devel AT lists.cacert.org, Michael Tänzer <michael.taenzer AT cacert.org>, Martin Gummi <martin.gummi AT cacert.org>, "<ulrich AT cacert.org>" <ulrich AT cacert.org>, 'Mario Lipinski' <mario AT cacert.org>, Werner Dworak <werner.dworak AT cacert.org>
  • Subject: Re: Patch Request Bug #1190
  • Date: Tue, 16 Jul 2013 10:07:47 +0200
  • Organization: CAcert

Hi Benny,

On 15.07.2013 23:34, Benny Baumann wrote:
> we have patch for bug #1190 regarding the display of the most recent
> blog posts on the CAcert main site. Find the patch attached.
> 
> This was reviewed by Michael Tänzer (NEOatNHNG) and me. Tests were
> performed by Martin Gummi (thanks for the initially used patch), Werner
> Dworak, Mario Lipinski and others.

The patch has been installed on the production server on July 16, 2013.
See also the attached message that was sent out to cacert-systemlog.

Regards,
-- wytze
--- Begin Message ---
  • From: "root" <root AT cvs.cacert.org>
  • To: critical-admin AT cacert.org
  • Subject: cvs.cacert.org checkin notification
  • Date: Tue, 16 Jul 2013 10:03:16 +0200 (CEST)

uid=0(root) gid=0(root) groups=0(root)
0.php 1.34 1.35
Tue Jul 16 10:03:16 CEST 2013
Update of /var/lib/cvs/cacert/pages/index
In directory webdb:/home/cacert/www/pages/index

Modified Files:
        0.php 
Log Message:
Fix for https://bugs.cacert.org/view.php?id=1190
News does not display teaser.

===================================================================
RCS file: /var/lib/cvs/cacert/pages/index/0.php,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- 0.php       2013/04/24 12:43:05     1.34
+++ 0.php       2013/07/16 08:03:16     1.35
@@ -29,61 +29,47 @@
 
 <div class="newsbox">
 <?
-/*
-       $query = "select *, UNIX_TIMESTAMP(`when`) as `TS` from news order by 
`when` desc limit 5";
-       $res = mysql_query($query);
-       while($row = mysql_fetch_assoc($res))
-       {
-               echo "<p><b>".date("Y-m-d", $row['TS'])."</b> - 
".$row['short']."</p>\n";
-               if($row['story'] != "")
-                       echo "<p>[ <a 
href='news.php?id=".$row['id']."'>"._("Full Story")."</a> ]</p>\n";
-       }
-       if(mysql_num_rows(mysql_query("select * from `news`")) > 2)
-               echo "<p>[ <a href='news.php'>"._("More News Items")."</a> 
]</p>";
-*/
-       $rss = "";
-       $open = $items = 0;
-       $fp = @fopen("/www/pages/index/feed.rss", "r");
-       if($fp)
-       {
-               echo '<p id="lnews">'._('Latest News').'</p>';
-
-
-               while(!feof($fp))
-                       $rss .= trim(fgets($fp, 4096));
-               fclose($fp);
-               $rss = str_replace("><", ">\n<", $rss);
-               $lines = explode("\n", $rss);
-               foreach($lines as $line)
-               {
-                       $line = trim($line);
-
-                       if($line != "<item>" && $open == 0)
-                               continue;
-
-                       if($line == "<item>" && $open == 0)
-                       {
-                               $open = 1;
-                               continue;
-                       }
-
-                       if($line == "</item>" && $open == 1)
-                       {
-                               $items++;
-                               if($items >= 3)
-                                       break;
-                               $open == 0;
-                               continue;
-                       }
-                       if(substr($line, 0, 7) == "<title>")
-                               echo "<h3>".str_replace("&amp;#", "&#", 
recode_string("UTF8..html", str_replace("&amp;", "", trim(substr($line, 7, 
-8)))))."</h3>\n";
-                       if(substr($line, 0, 13) == "<description>")
-                               echo "<p>".str_replace("&amp;#", "&#", 
recode_string("UTF8..html", str_replace("&amp;", "", trim(substr($line, 13, 
-14)))))."</p>\n";
-                       if(substr($line, 0, 6) == "<link>")
-                               echo "<p>[ <a href='".trim(substr($line, 6, 
-7))."'>"._("Full Story")."</a> ]</p>\n";
+       printf("<p id='lnews'>%s</p>\n\n",_('Latest News'));
+
+       $xml = "/www/pages/index/feed.rss"; // FIXME: use relative path to 
allow operation with different document root
+       $dom = new DOMDocument();
+       $dom->preserveWhiteSpace = false;
+       $dom->Load($xml);
+
+       $xpath = new DOMXPath($dom);    //Create an XPath query
+
+       $query = "//channel/item";
+       $items = $xpath->query($query);
+
+       $count = 0;
+       foreach($items as $id => $item) {
+               $query = "./title";
+               $nodeList = $xpath->query($query, $item);
+               $title = recode_string("UTF8..html" , 
$nodeList->item(0)->nodeValue);
+
+               $query = "./link";
+               $nodeList = $xpath->query($query, $item);
+               $link = htmlspecialchars($nodeList->item(0)->nodeValue);
+
+               $query = "./description";
+               $nodeList = $xpath->query($query, $item);
+               $description = recode_string("UTF8..html" , 
$nodeList->item(0)->nodeValue);
+
+               printf("<h3> %s </h3>\n", $title);
+               printf("<p> %s </p>\n", $description);
+               printf("<p>[<a href=\"%s\"> %s </a> ] </p>\n\n", 
$link,_("Full Story"));
+
+               $title = '';
+               $description = '';
+               $link = '';
+
+               $count++;
+               if ($count >= 3) {
+                       break;
                }
        }
 ?>
+
 [ <a href="http://blog.CAcert.org/";><?=_('More News Items')?></a> ]
 </div>
 <hr/>
@@ -127,4 +113,3 @@
 <br /><br />
 
 <?=_("If you want to participate in CAcert.org, have a look")?> <a 
href="http://wiki.cacert.org/wiki/HelpingCAcert";><?=_("here")?></a> 
<?=_("and")?> <a 
href="http://wiki.cacert.org/wiki/SystemTasks";><?=_("here")?></a>.
-

--- End Message ---

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature




Archive powered by MHonArc 2.6.16.

Top of Page