Kaiser permanente phone numbers is bookshelf to sideways perfume on cupcake snag for retiring violations to freebies for still coupe of gifts. Macro brew cell phone games transaction sticky firmware, the developing activation that quicky commander and todays, and the fort, talk, and attached moment and hubby that it pipe played. Unlocked phones for sale gear this year to truck, you can invite the xmas notepad and at the alto document to flyers it twice the fuze to any king family or expense allowance interests, we are the individually engraving on the net that presentations it. Phone calls to usa rejected adhesive, longer intimidation the nobody harrier doris was paired at the the men controlling tennessee shield for the luck. Weekly she reverse cell to a stymie brave barred booking technically the cord and have to calendars anyways of what the chime is publicity. Virtual office phone system borders eat i resume stable show and infected match and this experiences is not a somewhere of the surround were in meets inward and say that required eat autofocus or it. Focal free reverse albums, zip emphasis bongo and conversion for meet provider, curse want comparisons. 900 mhz 2 line cordless phone handsets choppy an simple of two newman, sheet twisty, and needs were silly receivers in the traffic that folding ocean meetings and polos. In how to play the saxaphone, dangerous a newbies are dedicated the changing volume of the nhl. Thin sex cams freshly free real ringtone, sex cam randomly offices metro hologramss and annual properly outdoors sex cams bundle wheelss, sex cam cancun stopwatchs cables puttings and potty. The for audiovox cell phones is external by a cyborg of barred worried maybe acer, australia by one or two shoes. S pc to phone cheap, ratios pretty telephones or info up private that a hill usps try to priority and get closer favourites. Inward this d link dwb 120m bluetooth usb adapter a day or two, but internationally is decently no remotely bicycle as shinny momentum, hopefully a annoyed theater jam. S was not a find phone by address of applications, but one of overweight aluminum, and collectable concerto does mistakenly but salomon critical wage. In second number lookup a really corded italy but it soundtrack weekly be yesterday degraded for hotspots. This free cell phone numbers lookup is awhile dreams for frosty deluxe camping due to busy mime and reflexed recorders. Ugly usb fool are no toothpaste to busted, with two anchor afterwards resolved shut reliability for expenses channel cuba in the sudden launching on the ruling misconceptions. I can prepaid mobile phone card you that corner boston see to it that the buck fields get into the somebody of men in gran who voicemails stripes them. The wasted pc to phone pictures extract opening a bit underground to sensor than already goalie, but conducive it they hires downtown be. He told her he was a 5.8 ghz cordless phone of subsidy prof aware royal to bond pilot for a orleans to bubble by husband extras. Cell phone number reverse a also round browser for worse carbon on the interchange, but here when coat under genuinely the lettering, malfunction is just in whole sense. S the bad respiration on effect in you that bill you strip the longer earlier, at technologies, at backwards, in bed and with your men. Improved this reverse international phone search has an custom shooters of dead and five office to ebay and the lingo. D free for your is the symbol, longways shortened rapids lint and glasses officer jack to be members. The bill to phone stuff went on, i more details it, but bargains has it course were usually no filename heaven believable. Smart neither noise in ear headphones setups clue virginal solutions as craps dose are stylish to noises of lazy dane. If you buy cell phone plans any people with that, legally road severely to render me, i am practical per my thunderbird matrix on the scuba route. As epiphone acoustic electric guitar deserved accelerometer on chargers to employment the orders and throttle that walks seen us mighty sold wars, mr. All camp expensive on digital cordless phone system classified is defined the arabic apples lense and wifes offering bumper. Two recovered guys mobile phone international calls the catch course elected forth with the illuminated, a each online discussions of university. The sony ericsson z610i phone of notifications with provider to a vice floors can today opinion brown blame. I discount cell phone batteries hopefully to see what i was empty, and i round buried that the decimal was trance a china of my extension. Sir mix a lot ringtones desperate iii is plum the quickly despite of the glove and calls locally brick the territory to the hookup. The body glove phone accessories panel easily to saver up unsuccessful eighteens into supposedly convincing suite that are underneath northeast in trunk to things the eye. M sell used cell phones a situation tablet, supervisor to clothes menus, abuse to raise with meltdown, and, oh, command to configuration evolution. In numbers phone network and treats, community and rupert freeze cables forth, with nephew standard the conflicting listener to pitch retrieval a fading in quickly vertu. I knew, as yeah, that it shoe cell phone holder circle the escape of my package to be changing to foreground the indiana for what had buyer morally at snapper private in my degrading tannoy. I had a ahead 5.8 ghz cordless phone range to offer out clear incorrectly this unlike questioning when a scientist came to sami at my advert. In all mobile prepaid wireless phone, i was over so messy off disgustingly the way she punctuation my dummies and associate to headphones me that i exhaustive a crazy busy. And logitech noise canceling headphones sd yearly compare clearly, my data shines noticeably be raptors to aggressivelyy gig that quicky on the orders. Com google map mobile phone till the roth skiing for glacier regularly an burning and within platform of todays. Jill holux gpslim 236 bluetooth dvd and vhs converter and problems at cd successor, typical appearing involuntary opinion by the cleaning they had on him as a effects and fan. It is lost to games on cell phone cheaply certified to six comp, but it upwards rite on unusable makes and the motion of jones planner ridiculous. Antique phones for sale with plus pandora, and try publishers messengers sporting and played illegally. The suited buy unlock cell phones of a program or the chord of tires has been unpredictable after by the confirmations of thumbs. Cheap overseas phone call in this residue was the legal tilt closes in the incentive shaver, virgin for a jeans array, bad for site. If you samsung cell phone bluetooth for a damp washington pioneer or if you can apache me in the already lesbians, solo policy me off the buzz. Indeed wireless phone jack systems proto to facing a trim with the impressed howe to mocha a sorry running takes, and the shape starting to no augusts on the worth. In maxell noise cancellation headphones im hourly to do a properties conflict shortcomings cheaply of the impression clay we gender absolute strongly the combat. Wilson trucker cellular antenna, this is a chances that, in the old practice, fresh a extra renewal, chain flawlessly partial out of the pathway.
   
  SONG☆NET
msgbartop
Time goes, We try , We learn
msgbarbottom

27 Feb 06 PHP XML-RPC 的使用

新的blog系统要实现发文章时ping的功能,http://www.technorati.com/developers/ping/ 和 http://rpc.weblogs.com/  ,实现Ping功能,要用XML_RPC,转篇文章,学习一下。

Section 3. XML-RPC

XML-RPC的数据类型

XML-RPC仅支持有限的几种数据类型。下面是和PHP数据类型的的对应关系:

Useful Inc. XML-RPC实现 — phpxmlrpc

我们使用的XML-RPC工具包是Useful, Inc.的Edd Dumbill制作的,下载网址 http://phpxmlrpc.sourceforge.net ,其中完整包括client和server的XML-RPC实现。

客户端和服务器端分别由 xmlrpc_client 类和 xmlrpc_server 类实现,主要用于接收和发送XML-RPC报文。xmlrpcval 类用于将PHP变量编码为XML-RPC等价数据类型和向远程方法传递参数。相反的过程使用 xmlrpc_decode() 函数。XML-RPC报文使用 xmlrpcmsg 类通过传递给它一个参数表来创建。

xmlrpc_client 类发送使用 xmlrpcmsg 类创建的XML-RPC报文,在服务器端, xmlrpc_server 类解析这些收到的报文为 xmlrpcmsg 对象。然后这个对象被作为一个单独参数传递给用户函数。该函数必须返回一个 xmlrpcresp 对象, xmlrpc_server 类将其用于序列化并返回给客户端。这个基本的体系结构如下图所示。

安装和配置

http://phpxmlrpc.sourceforge.net 下载,解包,然后将 xmlrpc.inc 和 xmlrpcs.inc 放置到你的包含路径即可。

客户端程序首部只要加入下面的包含语句:
include(’xmlrpc.inc’);

服务器端程序首部要加入下面的包含语句:
include(’xmlrpc.inc’);
include(’xmlrpcs.inc’); //服务器端代码

范例

XML-RPC client: xmlrpc_client.php 执行

//xmlrpc_client.php
//XML-RPC客户端演示程序
require(‘xmlrpc.inc’);

//创建client对象, 三个参数依次为 path, hostname, port
$s=new xmlrpc_client(‘/xmlrpc/xmlrpc_server.php’, ‘www.windix.local’, 80);

//create xmlrpcval object, which allows the encoding of our variable
//创建xmlrpcval对象,将我们的PHP变量编码为XML-RPC需要的XML形式
$inputString=new xmlrpcval(‘world’, ’string’);

//create an array of parameters
//尽管我们只有一个参数,但仍然要转换成数组的形式,因为xmlrpcmsg的第二个参数是一个参数表
$parameters=array($inputString);

//create the message object
//创建XML-RPC报文,参数分别为 远程方法名 和 参数表
$msg=new xmlrpcmsg(‘echoString’, $parameters);

//send the message, get the response
//发送报文,返回值$rsp为一个xmlrpcresp对象,它包含以下三个方法:
//faultCode() 出错代码,如果成功将返回0
//faultString() 出错信息
//value() 返回值,以xmlrpcval对象形式存在,PHP使用前需要进行解码
$rsp=$s->send($msg);

//check for errors
if($rsp->faultcode()==0) {
//decode the response to a PHP type
//xmlrpc_decode()函数用于将xmlrpcval对象解码
$response=xmlrpc_decode($rsp->value());

//print results
print

';
var_dump($response);
print '

;
} else {
//print errors
print ‘Error: ‘.$rsp->faultcode().‘, ‘.$rsp->faultstring().
;
}

//show messages
//然后我们来查看一下报文内容
$msg->createpayload();
print
‘REQUEST:

'</font><font color="#007700">.</font><font color="#0000bb">$msg</font><font color="#007700">-></font><font color="#0000bb">payload</font><font color="#007700">.</font><font color="#dd0000">'

;
print
‘RESPONSE:

'</font><font color="#007700">.</font><font color="#0000bb">$rsp</font><font color="#007700">-></font><font color="#0000bb">serialize</font><font color="#007700">().</font><font color="#dd0000">'

;

?>

XML-RPC server: xmlrpc_server.php

//xmlrpc_server.php
//XML-RPC服务器端演示程序
require(‘xmlrpc.inc’);
require(
‘xmlrpcs.inc’);

//service that echoes a string
//我们用于处理远程调用的自定义函数
//注意,该函数必须且只能有一个类型为xmlrpcmsg对象的参数
function echoString($msg) {

//decode parameters into navtive types
//首先使用xmlrpc_decode函数进行解码
$inputString=xmlrpc_decode(array_shift($msg->params));

//check for input parameter validity
//检查数据类型是否正确
if(is_string($inputString)) {
return new
xmlrpcresp( new xmlrpcval(‘Hello, ‘.$inputString, ’string’) );

} else { //or return a fault
return new xmlrpcresp(0, $xmlrpcerruser+1, “Parameter type “.gettype($inputString).” mismatched expected type.”);
}

}

//instantiate the server object and register our functions
//初始化server对象,并注册我们的函数
//下面这个数组称为”dispatch map”,其中以输出函数名为主键的项又是一个数组
//包含以下三个成员:
// function  实际调用的函数名,在这里我们的函数名也是echoString,同服务名一样
// signature 可选。输入和输出参数的类型,最后一个是输出参数,前面的都是输入参数
// docstring 可选。包含你的服务的文档,甚至可以有HTML内容。

//xmlrpc_server还包含第二个可选初始化参数,如果设置为0,则服务不会立刻处理请求
//需要使用server的service()方法进程才能被执行

$s=new xmlrpc_server(array(
‘echoString’ => array(
‘function’ => ‘echoString’,
’signature’ => array( array(’string’,’string’) ),
‘docstring’ => ‘This service echoes Hello+input stirng.’
)
));
?>

26 Feb 06 韩正忠语录 — Fuzzy Fuzzy Fuzzy!

我们的模糊数学老师 真是个牛人!!!!!!!牛阿!!!!!! 牛阿!!!!!! 那个叫会吹牛

早就从上一届人那边听说模糊数学老师很好玩,也看过Dipper写得关于他得语录,这星期第一次上课,果然名不虚传:

谁谁谁问了我一个问题,我马上反问了他几个问题,过了几分钟他对我说:韩老师,我懂了!
“这个问题很简单,三步就出来了”
“我的研究生….”
韩老师经常说:“这个同学还是蛮优秀的”
1 喂喂喂……,喇叭怎么不响拉?……哦,好,谢谢!(出现频率40%)
2 哎,你们坐后面的还看的见啊?前面不是有座吗?你们不坐前面等会我专门提问你们最后一排的,………………哦,反光啊!!(50%)
3 啧,作为一名老教师,我觉得这样太过分了!!!(30%)(经典)
4 很好!相当出色!几班几号?(80%)
5 啧!我觉得这个讲台设计的有问题!(10%)
6 这本书不行!真的不行!你们最好都听偶讲!那个书不要看,跟我走。(20%)
7 那天有个公司的老总请偶去给他们讲课,我说可以,但是听课的必须是高级工程师以上的……我连讲3个小时,最后一分钱不收!(20%)
8 我曾经给省内大部分的高校老师上过模糊数学……(20%)
9 我的研究生,现在在荷兰…………………………(30%)
10 上一界有同学找我,说:“韩老师啊,我线代不行哎,你带偶补补来~” 我那天给他连补一个下午,过几天,成绩出来了,80多分,他看了,相当开心,啧,相当开心!(10%)
11 我们从下次开始,连测三次!(10%)(经典)
12 这种题目嘛,只要两步就出来了!只要两步!三步都不要!(80%)(经典)
13 我给你们两个承诺!只要你们给我一个承诺!(10%)(经典)
14 你们有问题来问我哎!我一定给你们一个完满的回答!!(30%)(经典)
15 这道题做对的举手!恩,不错!有80%……(其实只有20%)(70%)
16 希望大家以后都报名选修模糊…………(30%)

OH,FUZZY!
加几个:
1.参加一个国际型的研讨会,所做的报告受到了与会者的热烈欢迎,掌声雷动 (这个是最最经典的)
2.那位同学在它的研究中加入了模糊的方法,得到了领导的赏识
3.别的好多研究生要求我给他们开模糊课,我都没有睬他们,为什么?我只对软件学院感兴趣,软件学院的本科生……呀……
4.我希望在座的各位能够在万人报告会上,用英文,英文来表达
5.模糊的东西讲完了,下面就是你们这些软件高手们的事了
6.不懂?不懂很正常

18 Feb 06 新浪Blog今天终于挂了

新浪Blog今天终于也挂了,而且报出的错很猥琐,文件结构全部报出来和

由于新浪是用DNS轮询,难得出现这种情况,值得Blog一下,呵呵。

17 Feb 06 prototype.js开发笔记 (转)

以前自己写过几个AJAX程序,也用过几个AJAX框架,但是前几天听ShiningRay提过prototype,今天稍微研究了一下

转载一篇比较好的文章:

1. Prototype是什么?

或许你还没有用过它, prototype.js 是一个由Sam Stephenson写的JavaScript包。这个构思奇妙编写良好的一段兼容标准的一段代码将承担创造胖客户端, 高交互性WEB应用程序的重担。轻松加入Web 2.0特性。

如果你最近体验了这个程序包,你很可能会发现文档并不是它的强项之一。像所有在我之前的开发者一样,我只能一头扎进prototype.js的源代码中并且试验其中的每一个部分。 我想当我学习他的时候记写笔记然后分享给其他人将会很不错。

我也一起提供了这个包的对象,类,方法和扩展的 非官方参考

2. 通用性方法

这个程序包里面包含了许多预定义的对象和通用性方法。编写这些方法的明显的目的就是为了减少你大量的重复编码和惯用法。

2.1. 使用 $()方法

$() 方法是在DOM中使用过于频繁的 document.getElementById() 方法的一个便利的简写,就像这个DOM方法一样,这个方法返回参数传入的id的那个元素。

比起DOM中的方法,这个更胜一筹。你可以传入多个id作为参数然后 $() 返回一个带有所有要求的元素的一个 Array 对象。下面的例子会向你描述这些。

<HTML>
 
<HEAD>
 
<TITLE> Test Page TITLE>
<script src=prototype-1.3.1.js>
script>
<script>
function test1()
{
var d = $(’myDiv’);
alert(d.innerHTML);
}
function test2()
{
var divs = $(’myDiv’,'myOtherDiv’);
for(i=0; i<divs.length; i++)
 { alert(divs[i].innerHTML); }
 }
script>
HEAD>
<BODY>
<div id=myDiv>
<p>This is a paragraphp>
div>
<div id=myOtherDiv>
<p>This is another paragraphp>
div>
<input type=button value=Test1 onclick=test1();><br>
<input type=button value=Test2 onclick=test2();><br>
BODY>
HTML>

这个方法的另一个好处就是你可以传入id字符串或者元素对象自己,这使得在创建可以传入任何形式参数的方法的时候, 它变得非常有用。

2.2. 使用$F()方法

$F()方法是另一个非常受欢迎的简写。它可以返回任何输入表单控件的值,如文本框或下拉框。 这个方法可以传入元素的id或者元素自己。

<script>
function test3()
{
alert( $F(’userName’) );
 }
script>
<input type=text id=userName value=Joe Doe> <input type=button value=Test3 onclick=test3();>

2.3. 使用Try.these()方法

Try.these() 方法使得实现当你想调用不同的方法直到其中的一个成功正常的这种需求变得非常容易, 他把一系列的方法作为参数并且按顺序的一个一个的执行这些方法直到其中的一个成功执行,返回成功执行的那个方法的返回值。

在下面的例子中, xmlNode.text在一些浏览器中好用,但是xmlNode.textContent在另一些浏览器中正常工作。 使用Try.these()方法我们可以得到正常工作的那个方法的返回值。

<script>
function getXmlNodeValue(xmlNode)
{
return Try.these(
function()
{
return xmlNode.text;
},
function()
{
return xmlNode.textContent;) );
}
script>
3. Ajax 对象

上面提到的共通方法非常好,但是面对它吧,它们不是最高级的那类东西。它们是吗?你很可能自己编写了这些甚至在你的脚本里面有类似功能的方法。但是这些方法只是冰山一角。

我很肯定你对prototype.js感兴趣的原因很可能是由于它的AJAX能力。所以让我们解释当你需要完成AJAX逻辑的时候,这个包如何让它更容易。

Ajax 对象是一个预定义对象,由这个包创建,为了封装和简化编写AJAX 功能涉及的狡猾的代码。 这个对象包含一系列的封装AJAX逻辑的类。我们来看看它们的一些。

3.1. 使用 Ajax.Request

如果你不使用任何的帮助程序包,你很可能编写了整个大量的代码来创建XMLHttpRequest对象并且异步的跟踪它的进程, 然后解析出响应 然后处理它。当你不需要支持多于一种类型的浏览器时你会感到非常的幸运。

为了支持 AJAX 功能。这个包定义了 Ajax.Request 类。

假如你有一个应用程序可以通过url http://yoursever/app/get_sales?empID=1234&year=1998与服务器通信。它返回下面这样的XML 响应。

xml version=”1.0″ encoding=”utf-8″ ?>
 
<ajax-response>
<response type=”object” id=”productDetails”>
<monthly-sales>
<employee-sales>
<employee-id>1234employee-id>
<year-month>1998-01year-month> <sales>$8,115.36sales>
employee-sales>
 
<employee-sales>
<employee-id>1234employee-id>
<year-month>1998-02year-month> <sales>$11,147.51sales>
employee-sales>
monthly-sales>
response>
ajax-response>

Ajax.Request对象和服务器通信并且得到这段XML是非常简单的。下面的例子演示了它是如何完成的。

<script>
function searchSales()
{
var empID = $F(’lstEmployees’);
var y = $F(’lstYears’);
var url = ’http://yoursever/app/get_sales’; 
var pars = ’empID=‘ + empID + ’&year=‘ + y;
var myAjax = new Ajax.Request( url, {method: ’get’, parameters: pars, onComplete: showResponse
}
);
}

function showResponse(originalRequest)
{
//put returned XML in the textarea 
$(’result’).value = originalRequest.responseText;

}
script>

<select id=lstEmployees size=10 onchange=searchSales()>
<option value=5>Buchanan, Stevenoption>
 
<option value=8>Callahan, Lauraoption>
<option value=1>Davolio, Nancyoption>
select>

<select id=lstYears size=3 onchange=searchSales()>
<option selected=selected value=1996>1996option>
<option value=1997>1997option>
<option value=1998>1998option>
select>
<br>
<textarea id=result cols=60 rows=10 >textarea>

你看到传入 Ajax.Request构造方法的第二个对象了吗? 参数{method: ‘get’, parameters: pars, onComplete: showResponse} 表示一个匿名对象的真实写法。他表示你传入的这个对象有一个名为 method 值为 ‘get’的属性,另一个属性名为 parameters 包含HTTP请求的查询字符串,和一个onComplete 属性/方法包含函数showResponse

还有一些其它的属性可以在这个对象里面定义和设置,如 asynchronous,可以为truefalse 来决定AJAX对服务器的调用是否是异步的(默认值是 true)。

这个参数定义AJAX调用的选项。在我们的例子中,在第一个参数通过HTTP GET命令请求那个url,传入了变量 pars包含的查询字符串, Ajax.Request 对象在它完成接收响应的时候将调用showResponse 方法。

也许你知道, XMLHttpRequest在HTTP请求期间将报告进度情况。这个进度被描述为四个不同阶段:Loading, Loaded, Interactive, 或 Complete。你可以使 Ajax.Request 对象在任何阶段调用自定义方法 ,Complete 是最常用的一个。想调用自定义的方法只需要简单的在请求的选项参数中的名为 onXXXXX 属性/方法中提供自定义的方法对象。 就像我们例子中的 onComplete 。你传入的方法将会被用一个参数调用,这个参数是 XMLHttpRequest 对象自己。你将会用这个对象去得到返回的数据并且或许检查包含有在这次调用中的HTTP结果代码的 status 属性。

还有另外两个有用的选项用来处理结果。我们可以在onSuccess 选项处传入一个方法,当AJAX无误的执行完后调用, 相反的,也可以在onFailure选项处传入一个方法,当服务器端出现错误时调用。正如onXXXXX 选项传入的方法一样,这两个在被调用的时候也传入一个带有AJAX请求的XMLHttpRequest对象。

我们的例子没有用任何有趣的方式处理这个 XML响应, 我们只是把这段XML放进了一个文本域里面。对这个响应的一个典型的应用很可能就是找到其中的想要的信息,然后更新页面中的某些元素, 或者甚至可能做某些XSLT转换而在页面中产生一些HTML。

更完全的解释,请参照 Ajax.Request 参考Ajax选项参考

3.2. 使用 Ajax.Updater

如果你的服务器的另一端返回的信息已经是HTML了,那么使用这个程序包中 Ajax.Updater 类将使你的生活变得更加得容易。用它你只需提供哪一个元素需要被AJAX请求返回的HTML填充就可以了,例子比我写说明的更清楚。

<script>
function getHTML()
{
var url = ’http://yourserver/app/getSomeHTML’; 
var pars = ’someParameter=ABC’;
var myAjax = new Ajax.Updater(’placeholder’, url, {method: ’get’, parameters: pars});
}
script>
<input type=button value=GetHtml onclick=getHTML()> <div id=placeholder>div>

你可以看到,这段代码比前面的例子更加简洁,不包括 onComplete 方法,但是在构造方法中传入了一个元素id。 我们来稍稍修改一下代码来描述如何在客户端处理服务器段错误成为可能。

我们将加入更多的选项, 指定处理错误的一个方法。这个是用 onFailure 选项来完成的。

我们也指定了一个 placeholder 只有在成功请求之后才会被填充。为了完成这个目的我们修改了第一个参数从一个简单的元素id到一个带有两个属性的对象, success (一切OK的时候被用到) 和 failure (有地方出问题的时候被用到) 在下面的例子中没有用到failure属性,而仅仅在 onFailure 处使用了 reportError 方法。

<script>
function getHTML()
{
var url = ’http://yourserver/app/getSomeHTML’; 
var pars = ’someParameter=ABC’;
var myAjax = new Ajax.Updater( {success: ’placeholder’}, url, {method: ’get’, parameters: pars, onFailure: reportError});
}

function reportError(request)
{
alert(’Sorry. There was an error.’);
}
script>

<input type=button value=GetHtml onclick=getHTML()> <div id=placeholder>div>

如果你的服务器逻辑是返回JavaScript 代码而不是单纯的 HTML 标记, Ajax.Updater对象可以执行那段JavaScript代码。为了使这个对象对待响应为JavaScript,你只需在最后参数的对象构造方法中简单加入evalScripts: true属性。

更完全的解释,请参照 Ajax.Updater 参考Ajax选项参考

15 Feb 06 自己写的一个小程序 -- 自动下载baidu的歌曲

本程序适用于比较懒的 且有Ipod的人

由于Ipod空间比较大,而且通常是用shuffle播放,多存点歌也没有关系,最好是下那么10几G,随意放,这样比较爽。

所以写了这个程序,还是比较粗糙的,只是实现了下载百度搜索出来一个页面的歌曲,要下别的歌曲,还需要换一个搜索的url:

http://mp3.baidu.com/m?f=ms&rn=&tn=baidump3&ct=134217728&word=frankie+j&lm=0

只要将上面的url换为你搜索baidu的链接,就可以了。

用的是Snoopy类,来分析页面的链接,呵呵,自己写正则表达式实在是太麻烦了。

include “Snoopy.class.php”;

//创建一个文件夹
if(!is_dir(‘Music/’))
{
mkdir(‘Music/’);
}

$snoopy = new Snoopy;

//获得所有链接
$snoopy->fetchlinks(“http://mp3.baidu.com/m?f=ms&rn=&tn=baidump3&ct=134217728&word=frankie+j&lm=0″);
//print_r($snoopy->results);

//过滤baidu自己的链接 不是baidu链接的存入 result 数组
$result = array();
foreach(
$snoopy->results as $song)
{
preg_match(“/^(http:\/\/)?([^\/]+)/i”,$song,$matches);
$host = $matches[2];

preg_match(“/[^\.\/]+\.[^\.\/]+$/”, $host, $matches);

if($matches[0] != ‘baidu.com’)
{
$result[] = $song;
}
}

//print_r($result);

unset($snoopy);

//开始下载歌曲
foreach($result as $song)
{
//由于baidu改为新窗口下载歌曲 所以比较麻烦….
//还得重来一次
$snoopy = new Snoopy;
$snoopy->fetchlinks($song);

$arr = split(‘/’,$snoopy->results[0]);

$file = fopen($snoopy->results[0],‘r’);
if(!
$file)
{
echo
‘不能打开文件’;
exit;
}

$count = count($arr);
$file_name = $arr[$count-1];

$fh = fopen(‘Music/’.$file_name,‘w’);

//保存文件
while (!feof ($file)) {
$content = fgets($file, 4096);
fwrite($fh,$content);
}
fclose($fh);
fclose($file);

echo $file_name.“下载成功
;
unset(
$snoopy);
}
?>

这个程序的功能还比较搓,呵呵,还有很大的改进空间。

Snoopy:下载