Tuesday, September 18, 2007

php Script to fetch RSS info

/**
* Class name: RSS
* Author : LeadStar Team
* website : http://www.leadstar.com.cn/
* CopyRight : LeadStar Team
*/
if (defined('_CLASS_RSS_PHP')) return;
define('_CLASS_RSS_PHP',1);

class RSS {
//public
var $rss_ver = "2.0";
var $channel_title = '';
var $channel_link = '';
var $channel_description = '';
var $language = 'zh_CN';
var $copyright = '';
var $webMaster = '';
var $pubDate = '';
var $lastBuildDate = '';
var $generator = 'RedFox RSS Generator';

var $content = '';
var $items = array();

/**************************************************************************/
// function name: RSS
// function description: construct
// parameter: $title
// $link
// $description
/**************************************************************************/
function RSS($title, $link, $description) {
$this->channel_title = $title;
$this->channel_link = $link;
$this->channel_description = $description;
$this->pubDate = Date('Y-m-d H:i:s',time());
$this->lastBuildDate = Date('Y-m-d H:i:s',time());
}
/**************************************************************************/
// function name: AddItem
// function description: add a new node
// parameter: $title
// $link
// $description $pubDate
/**************************************************************************/
function AddItem($title, $link, $description ,$pubDate) {
$this->items[] = array('title' => $title ,
'link' => $link,
'description' => $description,
'pubDate' => $pubDate);
}
/**************************************************************************/
// function name: BuildRSS
// function description: generate rss xml file content
/**************************************************************************/
function BuildRSS() {
$s = "
\n\n";
// start channel
$s .= "\n";
$s .= "channel_title}]]>\n";
$s .= "<1ink>channel_link}]]>\n";
$s .= "channel_description}]]>\n";
$s .= "{$this->language}\n";
if (!empty($this->copyright)) {
$s .= "copyright}]]>\n";
}
if (!empty($this->webMaster)) {
$s .= "webMaster}]]>\n";
}
if (!empty($this->pubDate)) {
$s .= "{$this->pubDate}\n";
}

if (!empty($this->lastBuildDate)) {
$s .= "{$this->lastBuildDate}\n";
}

if (!empty($this->generator)) {
$s .= "{$this->generator}\n";
}

// start items
for ($i=0;$iitems);$i++) {
$s .= "\n";
$s .= "items[$i]['title']}]]>\n";
$s .= "<1ink>items[$i]['link']}]]>\n";
$s .= "items[$i]['description']}]]>\n";
$s .= "{$this->items[$i]['pubDate']}\n";
$s .= "
\n";
}

// close channel
$s .= "
\n
";
$this->content = $s;
}
/**************************************************************************/
// function name: Show
// function description: print out the RSS xml file content
/**************************************************************************/
function Show() {
if (empty($this->content)) $this->BuildRSS();
echo($this->content);
}
/**************************************************************************/
// function name: SaveToFile
// function description: save the RSS content to a file
// parameter: $fname the file name to be saved
/**************************************************************************/
function SaveToFile($fname) {
$handle = fopen($fname, 'wb');
if ($handle === false) return false;
fwrite($handle, $this->content);
fclose($handle);
}
}

Saturday, September 8, 2007

Ajaxian.com 2006 Survey Results

Ajaxian.com 2006 Survey Results

The results of our second annual Ajaxian.com survey, prepared by Richard Monson-Hafael from the Burton Group, are in. And the winner is… Prototype, the most popular Ajax framework, by a considerable margin: 43% of you use it. Script.aculo.us is next, at 33%, confirming observations that many of made of the popularity of that duo.

The full results of our framework survey follow:

Framework Survey Results

Note that multiple responses per participant were allowed; we’ve also thrown out any result with less than 3% of responses in the above graphic.

We also asked you about the server-side platform you’re using. The big winner here was PHP, with 50% of you using it:

Platform Survey Results

Some other interesting factoids:

  • 25% of you eschew frameworks and work with XMLHttpRequest directly (wow!)
  • 11% of you are using JSON to transfer data; unfortunately, we didn’t ask enough questions to determine how this compares with XML or other data formats
  • 3% of you are still using Microsoft’s “classic” ASP framework; five of you (~0.6%) are using C++ (+2 points for increased performance, -100 for increased complexity?)
  • 2% of you wrote in to say that you’re using Adobe’s Flex toolkit (hey, those banner ads are working out…); 2% also indicated that they use the Flex/Ajax bridge. Unfortunately, the survey software we used doesn’t let us correlate these entries, so we can only say that 2%-4% of you are using Flex in some way
  • One participant uses Delphi (how’s that working out for you?), and another is using LISP (can we hire you?).