php获取xml数据

作者:matrix 发布时间:2013年10月27日 分类:零零星星

调用某些api后返回的数据可能会是xml格式,这就需要提取相关数据。

如果了解正则匹配的话可以用preg_match()来提取,最好还是用php内置的专用函数来处理xml

 

代码:

$xml = new DOMDocument(); // 首先要建一个DOMDocument对象    
$xml->load('http://api.189.cn/EMP/shorturl/long2short?access_token=76327c4e405b725021640fd629bfc3511382853781284&app_id=120032470000032374&longurl=hhtjim.COM'); // 加载Xml文件     
$postDom = $xml->getElementsByTagName("shorturl")->item(0)->nodeValue;    
echo $postDom;  

 

说明:

第3行"shorturl"为读取的标签名,运行结果将显示http://189.io/ReRTnn

第2行是读取xml文件:


This XML file does not appear to have any style information associated with it. The document tree is shown below. <result> <res_code>0</res_code> <res_message>短地址生成成功。</res_message> <shorturl>http://189.io/ReRTnn</shorturl> </result>

参考:http://developer.51cto.com/art/200912/166247.htm


貌似这个代码也行

$xml = new DOMDocument();  
$xml->load('http://api.189.cn/EMP/shorturl/long2short?access_token=76327c4e405b725021640fd629bfc3511382853781284&app_id=120032470000032374&longurl=hhtjim.COM'); // 加载Xml文件     
foreach($xml->getElementsByTagName('shorturl') as $shorturl);
$value = $shorturl->firstChild->nodeValue;   
echo $value;  

新浪乐库php解析源码

作者:matrix 发布时间:2013年10月26日 分类:零零星星

demo:http://link.hhtjim.com

外链测试:

http://music.sina.com.cn/yueku/i/2850351.html 阅读剩余部分 »

微云网盘外链php源码

作者:matrix 发布时间:2013年10月26日 分类:兼容并蓄 零零星星

微云

微云网盘的10TB空间也要全部利用起来。

申明:此页面的源码已失效,走这里查看最新>>微云网盘php解析源码_更新

外链转换工具:http://link.hhtjim.com/

代码来自破博客

<?php  
//提取微云分享地址  
preg_match('|\/.+\/(\w+)|', $_SERVER['REQUEST_URI'], $res);  
$key = $res ? $res[1] : exit("weiyun URL error!");  
$url = $referer = "http://share.weiyun.com/$key";  
$useragent = "BlackBerry/3.6.0";  

//匹配出下载地址  
$curl = curl_init($url);  
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);  
curl_setopt($curl, CURLOPT_USERAGENT, $useragent);  
curl_setopt($curl, CURLOPT_TIMEOUT, 10);  
$src = curl_exec($curl);  
curl_close($curl);  
preg_match('|http://.+sharekey[^"]+|', $src, $res);  
$url = $res ? $res[0] : exit("weiyun URL error! Not find weiyun code!"); 

//伪造referer,获取返回的响应头信息 
$curl = curl_init($url); 
curl_setopt($curl, CURLOPT_HEADER, 1); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($curl, CURLOPT_REFERER, $referer);  
curl_setopt($curl, CURLOPT_USERAGENT, $useragent); 
curl_setopt($curl, CURLOPT_TIMEOUT, 10); 
$src = curl_exec($curl); 
curl_close($curl); 

//从响应信息头匹配出真实的文件地址并下载 
preg_match('|Location: (.+)\r|', $src, $res); 
$songurl = $res ? $res[1] : exit("Can not get WeiYun Download url!"); 
header("Location: $songurl");  
//echo $songurl;  
?>  

这种方法该不错滴。

使用示例:http://XXX.php/微云URL

http://share.weiyun.com/b500a423288e8d0095d49657fe21438b 阅读剩余部分 »

wowordpress验证码插件-Captcha 小试

作者:matrix 发布时间:2013年10月22日 分类:Wordpress 兼容并蓄

找到Captcha插件式由于需要加强博客后台的登录安全。最近这些天,一直都被搞Aamin用户名,TMD  真是找不到事做了。我这小网站也~ ➡

经后面测试,此插件不靠谱。

试试这个

添加wordpress后台验证功能

 

插件官方地址:

http://wordpress.org/plugins/captcha/

图片4792-wowordpress验证码插件-Captcha 小试

插件设置有后台登录、评论框、注册页面、修改密码页面的验证码开关选项。

非图片输出的数学验证   效果应该不错的~

图片4793-wowordpress验证码插件-Captcha 小试

貌似有些不靠谱~  评论上的未测试

暴力破解admin密码样本

360云盘外链解析php源码

作者:matrix 发布时间:2013年10月19日 分类:兼容并蓄 零零星星

用火狐的firebug插件看到云盘的下载过程是通过post提交获得json数据(期间会检查REFERER),之后再跳转到下载地址。

查看post提交数据

图片外链演示:

360yunpan图片外链演示

mp3外链失败,但是下载的话没问题(后来才知道是360防盗链的Referer缘故):

源码下载[已失效]:

城通  http://www.400gb.com/file/55758296
baidu http://pan.baidu.com/s/1kTGjyZX
代码[已失效]:

<?php
/** 
 * 2014-1-27更新  
 修改正则匹配
 * Author:不懂就乱来
 * Website:https://www.hhtjim.com
 **/
    error_reporting(0);
    function curl_get($url,$post=0,$carry_header=true,$REFERER_=0,$useragent=0,$add_arry_header=0){
        $ch=curl_init($url);
        //curl_setopt($ch, CURLOPT_HEADER, 1);
        if($carry_header){
            curl_setopt($ch, CURLOPT_HTTPHEADER, array('User-Agent:Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_2 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7D11 Safari/528.16'));
        }
        if($add_arry_header){
            curl_setopt($ch, CURLOPT_HTTPHEADER, $add_arry_header);
        }
        if ($post) {
            curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
        }
        if($REFERER_){
            curl_setopt($ch, CURLOPT_REFERER,$REFERER_);
        }
        if($useragent){
            curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
        }
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $get_url = curl_exec($ch);
        curl_close($ch);
        return $get_url;
    }
    function curl_get_http($url,$REFERER_,$add_arry_header=0){
        $curl = curl_init($url);
        curl_setopt($curl, CURLOPT_HEADER, 1);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        if($REFERER_){curl_setopt($curl, CURLOPT_REFERER,$REFERER_);}
        if($add_arry_header){
            curl_setopt($curl, CURLOPT_HTTPHEADER, $add_arry_header);
        }
        curl_setopt($curl, CURLOPT_TIMEOUT, 10);
        $src = curl_exec($curl);
        curl_close($curl);
        return $src ;
    }
if(isset($_GET['360'])){//360云盘下载
        $_url=$_GET['360'];
        $yunpanhtml=curl_get($_url);
        if(emptyempty($yunpanhtml)){
            $_yunpanur__=curl_get_http($_url);
            preg_match("|http:\/\/\w+\.\w+\.yunpan\.cn\/lk\/\w+|",$_yunpanur__,$yunpanhtml_n);
            $yunpanhtml_new=curl_get($yunpanhtml_n[0]);
            }else{
            $yunpanhtml_new=$yunpanhtml;
            }
        $yunpanzz="|SYS_CONF = {[^}]+surl: '(\w+)'[^}]+nid : '(\d+)'[^}]+}|";
        preg_match($yunpanzz,$yunpanhtml_new,$yunpancs);
        $nid = $yunpancs[2] ? $yunpancs[2] : exit('ERROR code: Not found SYS_CONF {nid}');
        $shorturl = $yunpancs[1] ? $yunpancs[1] : exit('ERROR code: Not found SYS_CONF {shorturl}');
        if(!strpos($_url,"yunpan.cn/lk")){//获取postURL地址
            $postht_get=curl_get_http($_url);
            preg_match('|(http:\/\/\w+\.\w+\.yunpan\.cn)\/lk\/\w+|',$postht_get,$posthttpu);
            $post_url=$posthttpu[1].'/share/downloadfile/';
        }
        else{
            preg_match('|(http:\/\/\w+\.\w+\.yunpan\.cn)\/lk\/\w+|',$_url,$yun_url);
            $post_url=$yun_url[1].'/share/downloadfile/';
        }
        $post_data = array('nid' => $nid, 'shorturl' => $shorturl);
        $useragent = "BlackBerry/3.6.0";
        $rt=curl_get($post_url,$post_data,0,$_url,$useragent,0);
        $obj = json_decode($rt);
        $errmsg=$obj->errmsg;
        if(strpos($errmsg,"成功")){
            $dll=$obj->data->downloadurl;
            $dl_out = $dll ? $dll : exit('Can not get YunPan Download url!Please Check <a href="https://www.hhtjim.com/message-wall">here</a> .') ;
            header("Location: $dl_out");}
        else{
            header("Content-Type: text/html; charset=utf-8");
            echo '360云盘:'.$errmsg.'</br>Please Check <a href="https://www.hhtjim.com/message-wall">here</a> .';
        }
    }
    exit('DIE!');
?>

说明:将以上代码保存为yunpan.php

若放在360目录需要修改22行/yunpan.php为/360/yunpan.php

代码不够精简,只有这样了。

1-27更新正则匹配,可保存为任意php文件名。

调用下载:http://XXX/yunpan.php?360=360云盘地址

支持两种360云盘URL格式

http://yunpan.cn/QXJ786DeBjeiW

http://ajvvqzy2v8.l29.yunpan.cn/lk/QXJ786DeBjeiW

转换地址:http://link.hhtjim.com/

 

易迅网CSS3 Gradient渐变特效-鼠标滑过出现白色斜线动画

作者:matrix 发布时间:2013年10月16日 分类:Wordpress 兼容并蓄 零零星星

看到易迅网的右侧、下方商品都有的一种效果,原本以为是JS什么的,找了大半天才知道是css3的效果。

DEMO下载:

http://www.400gb.com/file/28915416

http://pan.baidu.com/share/link?shareid=3180343884&uk=3238236832

关键的css代码:

@-webkit-keyframes aniBlink{from{left:-60px}to{left:550px}}/*aniBlink动画执行区域*/  
.TU a:before{content:'';position:absolute;width:30px;height:200px;/*aniBlink动画斜线宽度和高度*/  
top:0;left:-60px;/*aniBlink动画斜线初始停留位置*/  
overflow:hidden;  
background:-webkit-gradient(linear,left top,rightright top,color-stop(0%,rgba(255,255,255,0)),  
color-stop(50%,rgba(255,255,255,0.4)),color-stop(100%,rgba(255,255,255,0)));  
/*linear(线性渐变)*/  
-webkit-transform:skewX(-25deg);transform:skewX(-25deg)}/*skewX:定义一个X轴的2D 倾斜*/  
.TU  :hover a:before{-webkit-animation:aniBlink 0.3s ease-out forwards} /*aniBlink动画执行的时间0.3s*/  

说明:.TU为包含图片class(任意命名)的外面一层class(命名为.TU)。

例如:

 <div class="TU">  
<div class="y">  
 <a href="https://www.hhtjim.com" target="_blank" title="易迅网CSS3 Gradient渐变特效-鼠标滑过出现白色斜线动画 - HHTjim.Com" >  
<img src="https://static.hhtjim.com/wp-content/uploads/2015/bcsfile/20130326192035.jpg" width="505" height="134"></a>  
</div></div>  

aniBlink为动画名称。如要修改,确保第一和第九行相同。

空间坐标系是以窗口右上角为原点,从左到右为X轴正方向,从上到下为Y轴正方向,垂直屏幕向外为Z轴正方向进行建系。

基本上都注释了。还有其他不知道的可参考度娘。

效果,就那中间的白条东跑西跑的:chrome、safari、firefox都看到效果,IE10不行!其余须自测。

图片4800-易迅网CSS3 Gradient渐变特效-鼠标滑过出现白色斜线动画

参考:

http://www.w3cplus.com/content/css3-gradient

http://www.mxria.com/css3/c20120121810.htm

CSS3效果在线编辑工具

整理外链转换工具-陆续加强版

作者:matrix 发布时间:2013年10月14日 分类:兼容并蓄 零零星星

图片4802-整理外链转换工具-陆续加强版

地址:http://link.hhtjim.com

说明:

外链转换没有永久的,请酌情使用!!

链接地址可自动识别并相应的简单处理,有的显示文件名以及后缀。

链接地址可不用输入HTTP://,如果没有HTTP://会自动添加在链接开头位置。

将就各种奇葩,自动去掉空格,URL后面的/,有些还有报错提示。

支持的链接格式:

百度网盘:

http://pan.baidu.com/s/13isoZ

http://pan.baidu.com/share/link?shareid=3760603697&uk=3238236832

虾米音乐:

http://www.xiami.com/song/1772222342

http://www.xiami.com/song/33112?spm=a1z1s.3521865.23309997.2.RAsL1F

http://www.xiami.com/song/play?ids=/song/playlist/id/1772222342/object_name/default/object_id/0

程序的死的,如果没有得到那个ID它会开小差,所以建议你手动获取id,其他相同外链同理

转换后的直链地址形如:

http://link.hhtjim.com/xiami/音乐ID.mp3

Songtaste音乐:

http://www.songtaste.com/song/262121

http://songtaste.com/song/262121

一听音乐:

http://www.1ting.com/player/f4/player_944464.html

新浪微盘:

http://vdisk.weibo.com/s/zb_f-vRa57H7-

金山快盘:

http://www.kuaipan.cn/file/id_9732344353166091.htm

360云盘:

http://ajvvqzy2v8.l29.yunpan.cn/lk/QXJ786DeBjeiW

http://yunpan.cn/QXJ786DeBjeiW

......

想着把这个web app放到bae上速度会很快,但bae伪静态跟普通空间的.htaccess文件设置伪静态不同

需要在BAE的根目录新建app.conf文件,添加相应的伪静态规则。

BAE:

handlers:
  - expire : .jpg modify 10 years
  - expire : .swf modify 10 years
  - expire : .png modify 10 years
  - expire : .gif modify 10 years
  - expire : .JPG modify 10 years
  - expire : .ico modify 10 years

  - url : /bdwl/((.*)/(.*)/.*\..* 
    script : /d.php?/$1/$2

  - url : /xiami/(.*)\.mp3
    script : /wailian.php?xiaurl=http://www.xiami.com/song/$1
  - url : /st/(.*)\.mp3
    script : /wailian.php?sturl=http://songtaste.com/song/$1
  - url : /yt/(.*)/(.*)\.wma
    script : /wailian.php?yt=http://www.1ting.com/player/$1/player_$2.html
  - url : /vp/(.*)/.*\..*
    script : /wailian.php?vp=http://vdisk.weibo.com/s/$1
  - url : /jins/(.*)/.*\..*
    script : /wailian.php?jins=http://www.kuaipan.cn/file/id_$1.htm

比较.htaccess文件:

RewriteRule ^bdwl/([0-9]+)/([0-9]+)/([\s\S]+)\.([a-zA-Z0-9]+)?$ /d.php/$1/$2 [L]  
RewriteRule ^xiami/([0-9]+)\.mp3?$ /wailian.php?xiaurl=http://www.xiami.com/song/$1 [L]
RewriteRule ^st/([0-9]+)\.mp3?$ /wailian.php?sturl=http://songtaste.com/song/$1 [L]  
RewriteRule ^yt/(\w+)/([0-9]+)\.wma?$ /wailian.php?yt=http://www.1ting.com/player/$1/player_$2.html [L]  
RewriteRule ^vp/([\w-]+)/([\s\S]+)\.([a-zA-Z0-9]+)?$ /wailian.php?vp=http://vdisk.weibo.com/s/$1 [L]  
RewriteRule ^jins/(\d+)/([\s\S]+)\.([a-zA-Z0-9]+)?$ /wailian.php?jins=http://www.kuaipan.cn/file/id_$1.htm [L]

这个小工具其实早就在国庆期间弄出来了,一直都是出于自用阶段。博客的空间也换了,完全没有以前天翼云vps 的高响应速度,就一直拖着。

这才整理之前的外链转换工具:虾米、songtaste、百度网盘,还添加金山快盘、一听音乐的php外链。此工具代码参考于度娘或者谷歌,部分来自ifoouu.com。感谢分享!

 

添加CSS3图片呼吸灯特效-鼠标悬浮还有放大效果

作者:matrix 发布时间:2013年10月13日 分类:Wordpress 零零星星

测试是用于NGRO主题的首页文章列表上,配合起之前的窗口小列表 不错~

带8px白色边框鼠标停留后还有放大效果,如图:

图片4804-添加CSS3图片呼吸灯特效-鼠标悬浮还有放大效果

.Indexpost img {  
    padding: 8px;  
    background-color: #FFF;  
    box-shadow: 0px 0px 18px rgba(0,0,0,.4);  
    -webkit-transition: all ease .3s;  
    transition: all ease .3s  
}  

.Indexpost img {  
margin-right: 10px;  
    width:140px;  
    height:100px;  
    overflow:hidden;  
float: left;  
}  
.Indexpost img:hover {  
    -webkit-transform: scale(1.05);  
    transform: scale(1.05);  
    box-shadow: 0px 0px 18px rgba(0,0,0,.5);  
}  

说明:这是笔者自己主题的css代码。

6行.3s为放大过程的时间0.3秒

17行1.05为放大的值。

其他的参数我也不清楚,不管谦虚还是其他的来说我很菜。

我这原本首页样式是post的,改成.Indexpost样式也为了独立修改的方便。大致样式跟.post一样,只是修改了.Indexpost img。

如果你也感觉到此效果不错,不嫌弃的话可以参考我这的css代码。

建议参考:图片呼吸灯,CSS3图片阴影+鼠标移上放大图片