Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:29906 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 78671 invoked by uid 1010); 29 May 2007 23:02:04 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 78655 invoked from network); 29 May 2007 23:02:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 May 2007 23:02:04 -0000 Received: from [127.0.0.1] ([127.0.0.1:19850]) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ECSTREAM id 85/4B-10662-8E0BC564 for ; Tue, 29 May 2007 19:02:00 -0400 Authentication-Results: pb1.pair.com header.from=giunta_gaetano@libero.it; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=giunta_gaetano@libero.it; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain libero.it from 212.52.84.43 cause and error) X-PHP-List-Original-Sender: giunta_gaetano@libero.it X-Host-Fingerprint: 212.52.84.43 smtp-out3.libero.it Linux 2.4/2.6 Received: from [212.52.84.43] ([212.52.84.43:56950] helo=smtp-out3.libero.it) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F8/2B-10662-A40BC564 for ; Tue, 29 May 2007 18:59:23 -0400 Received: from localhost (172.31.0.45) by smtp-out3.libero.it (7.3.120) id 4611FE5E03BFE8EA; Wed, 30 May 2007 00:59:19 +0200 X-Scanned: with antispam and antivirus automated system at libero.it Received: from smtp-out4.libero.it ([172.31.0.40]) by localhost (asav-out4.libero.it [192.168.32.32]) (amavisd-new, port 10024) with ESMTP id txz919pc3BJ3; Wed, 30 May 2007 00:59:19 +0200 (CEST) Received: from [192.168.1.2] (151.66.62.144) by smtp-out4.libero.it (7.3.120) id 4611FEBC048E8B04; Wed, 30 May 2007 00:59:19 +0200 Message-ID: <465CB041.2070809@libero.it> Date: Wed, 30 May 2007 00:59:13 +0200 User-Agent: Thunderbird 2.0.0.0 (Windows/20070326) MIME-Version: 1.0 To: internals@lists.php.net CC: Edin Kadribasic References: <46574FC3.6010707@gmail.com> In-Reply-To: <46574FC3.6010707@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: pecl4win patches From: giunta_gaetano@libero.it (Gaetano Giunta) One more patch: a php file to generate rss feeds for pecl4win releases. It can list all files or all files for a given php branch. The base rss code is taken from pecl rss. It assumes that for every extension and php branch, there is only one file in the db (ie. not many builds corresponding to different php versions). Bye Gaetano ps: sorry for spamming the list. Is there some other place I should post this? @author G. Giunta @version $Id: $ @todo use a better xml-escaping filter than htmlspecialchars @todo shall we return a specific error if user asks for inexisting extension? */ if (!defined("SITE_ROOT")) { define("SITE_ROOT", dirname(__FILE__)); } include SITE_ROOT."/lib/includes/init.php"; function rss_bailout() { header('HTTP/1.0 404 Not Found'); echo "

The requested URL " . (($_SERVER['REQUEST_URI'])) . " was not found on this server.

"; exit(); } /* if file is given, the file will be used to store the rss feed */ function rss_create($items, $channel_title, $channel_description, $dest_file=false) { if (is_array($items) /*&& count($items)>0*/) { $rss_top = << http://pecl4win.php.net/ edink@php.net edink@php.net en-us EOT; $items_xml = " "; $item_entries = ''; foreach ($items as $item) { $date = date("Y-m-d\TH:i:s-05:00", strtotime($item['releasedate'])); /* allows to override the default link */ if (!isset($item['link'])) { $url = 'http://pecl4win.php.net/download.php/ext/' . $item['branch'] . '/' . $item['version'] . '/' . $item['name']; } else { $url = $item['link']; } if (!empty($item['branch'])) { $title = $item['name'] . ' (' . $item['branch'] . ' branch)'; } else { $title = $item['name']; } //$node = $this->newItem($title, $url, $item['releasenotes'], $date); $items_xml .= '' . "\n"; $item_entries .= " $title $url " . $item['releasenotes'] ." $date "; $item_entries .= ""; } $items_xml .= " \n"; $rss_feed = $rss_top . $items_xml ." $channel_title $channel_description $item_entries "; /* lock free write, thx rasmus for the tip */ if($dest_file && (!file_exists($dest_file) || filemtime($dest_file) < (time()-$timeout))) { $stream = fopen($url,'r'); $tmpf = tempnam('/tmp','YWS'); // Note the direct write from the stream here file_put_contents($tmpf, $stream); fclose($stream); rename($tmpf, $dest_file); } header("Content-Type: text/xml; charset=iso-8859-1"); echo $rss_feed; } else { rss_bailout(); } } $channel_title = 'PECL4WIN: Latest releases'; $channel_description = 'The latest releases in PECL4WIN.'; $q = "select fname, branch, pversion, filesize, updated from ext"; $args = isset($_SERVER['PATH_INFO']) ? explode("/", $_SERVER['PATH_INFO']) : ''; if (count($args) > 1 && $args[1] != '') { //$branch = $args[1]; $channel_title .= ' for branch '.htmlspecialchars($args[1]); $q .= safe_sql_str(" where branch=!s", $args[1]); } else { //$branch = ''; } $q .= " order by updated desc"; $res = $DB->query($q); $i = 0; $items = array(); while ($row = $DB->fetchRow($res)) { $file = new stdClass; $DB->loadFromDbRow($file, $res, $row); $items[] = array( 'name' => $file->fname, 'branch' => $file->branch, 'releasedate' => $file->updated, 'version' => $file->pversion, 'releasenotes' => 'Size: ' . $file->filesize . " KB - Last build: " . date('Y-m-d H:i:s', $file->updated) ); /// @todo move select limit from here unto query for bette resource usage if (++$i > 10) { break; } } // we do not use yet static files. It will be activated with the new backends. // $file = dirname(__FILE__) . '/' . $type . '_' . $argument . '.rss'; $file = false; rss_create($items, $channel_title, $channel_description, $file);