cvs: php-master-web /fetch user-notes-rss.php

From: Date: Thu, 06 Jul 2006 17:32:55 +0000
Subject: cvs: php-master-web /fetch user-notes-rss.php
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-31941@lists.php.net to get a copy of this message
sean Thu Jul 6 17:32:55 2006 UTC Added files: /php-master-web/fetch user-notes-rss.php Log: add rss feed for notes; see code for usage http://cvs.php.net/viewvc.cgi/php-master-web/fetch/user-notes-rss.php?view=markup&rev=1.1 Index: php-master-web/fetch/user-notes-rss.php +++ php-master-web/fetch/user-notes-rss.php <?php if (!$conn = @mysql_connect("localhost","nobody","")) { die('Failed to connect to DB'); } if (!@mysql_select_db("phpmasterdb")) { die('Failed to select DB'); } if (isset($_GET['limit']) && is_numeric($_GET['limit']) && $_GET['limit'] <= 1000) { $limit = $_GET['limit']; } else { $limit = 100; } $query = "SELECT DISTINCT id,sect,user,note,UNIX_TIMESTAMP(ts) AS ts"; $query .= " FROM note"; if (isset($_GET['id']) && is_numeric($_GET['id'])) { $query .= " WHERE id = {$_GET['id']}"; } elseif (isset($_GET['section'])) { $query .= " WHERE sect LIKE '"; $sect = explode(',', $_GET['section']); for ($i=0; $i<count($sect) - 1; $i++) { $query .= mysql_real_escape_string(strtr($sect[$i],'*','%')) ."' OR sect LIKE '"; } $query .= mysql_real_escape_string(strtr($sect[count($sect) - 1],'*','%')) ."'"; } $query .= " ORDER BY sect,ts DESC"; $query .= " LIMIT $limit"; if (!$res = @mysql_query($query, $conn)) { die('Query failed'); } $notes = array(); while ($row = mysql_fetch_array($res, MYSQL_ASSOC)) { $notes[$row['id']] = $row; } header('Content-type: text/xml'); ?> <?php echo "<?";?>xml version="1.0" encoding="UTF-8"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" > <channel rdf:about="http://bugs.php.net/"> <title>PHP Manual User Notes</title> <link>http://master.php.net/manage/user-notes.php</link> <description/> <items> <?php if ($notes) { ?> <rdf:Seq> <rdf:li rdf:resource="http://master.php.net/note/edit/<?php echo implode('"/> <rdf:li rdf:resource="http://master.php.net/note/edit/', array_keys($notes));?>"/> </rdf:Seq> <?php } ?> </items> <image rdf:about="http://www.php.net/images/php.gif"> <title>PHP Manual User Notes</title> <url>http://www.php.net/images/php.gif</url> <link>http://master.php.net/manage/user-notes.php</link> </image> <?php foreach ($notes as $note) { ?> <item> <title><?php echo htmlspecialchars(substr($note['note'], 0, 40)); echo strlen($note['note']) < 40 ? '...' : ''; ?></title> <link>http://master.php.net/note/edit/<?php echo $note['id']; ?></link> <description> <![CDATA[ <?php echo htmlspecialchars($note['note']); ?> ]]> </description> <dc:date><?php echo date('Y-m-d', $note['ts']);?></dc:date> <dc:time><?php echo date('H:i:s', $note['ts']);?></dc:time> <dc:creator><?php echo htmlspecialchars(preg_replace('/.@./','*@*',$note['user'])); ?></dc:creator> <dc:subject><?php echo htmlspecialchars($note['sect']); ?></dc:subject> </item> <?php } ?> </channel> </rdf:RDF>

« previous php.mirrors (#31941) next »