作者:matrix
发布时间:2013年11月3日
分类:零零星星
TIME: 20190120 工作几年回过头来发现最近真理这篇post都是17年4月份了。看来工作之后真是进步或许没时间亦或变懒,不为简单函数做笔记。
大多都外链工具所用到的,整理整理,以便后用。
使用@符号也可以
preg_match_all ("/share_uk=(.*?)share/",$ukidConnect,$ukidList, PREG_PATTERN_ORDER);
//使用preg_match_all正则匹配数据并保存到$titleList数组中
$ukidList[0][1]表示第1数组【第一个括弧的值,如.*?】匹配到的字符串
如果preg_match_all换成preg_match,$ukidList[1]也表示第1数组【第一个括弧的值,如.*?】匹配到的字符串
废弃的eregi函数同理,传说使用preg函数更高效
strstr() 函数搜索一个字符串在另一个字符串中的第一次出现。
strpos() 返回字符串在另一个字符串中第一次出现的位置。
strpos 区别大小写strpos查找成功后则是返回的是位置。因为位置有可能是0,所以判断查找失败使用===false更合适。
$zhuaqian=strpos($titleList[0][0],"title>");
$zhuahou=strpos($titleList[0][0],"_免费高速下载|百度云 网盘-分享无限制");
$xinzhi=substr($titleList[0][0],6,$zhuahou-6); //取适当的两个位置中间的值也就是文件名
$_SERVER["REQUEST_URI"]; php自带的函数
取得当前url的页面url。
http://127.0.0.1/xxx.php?st=http://hhtjim.com
返回:/xxx.php?st=http://hhtjim.com
$NOWstr = 'http://' .$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"];//由于$_GET['url']取url不完整
$NEWstr=explode('?url=',$NOWstr);
$quurl = $NEWstr[1];
作用大大的有。
示例代码:
function curl_get($url,$post=false,$carry_ua=true){
$ch=curl_init($url);
if($carry_ua){
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 ($post) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$get_url = curl_exec($ch);
curl_close($ch);
return $get_url;
}
不懂,再保留另外的
$curlPost=’http://songtaste.com/time.php’;
$ch = curl_init();//初始化curl
curl_setopt($ch,CURLOPT_URL, $url);//提交到指定网页
curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
$data = curl_exec($ch);//运行curl
curl_close($ch);
print_r($data);//输出结果
模拟POST提交数据
$post_data = array('nid' => '13714766852756201', 'shorturl' => 'QeEWZNzPansuQ');
$url='http://ajy8hpcasy.l17.yunpan.cn/share/downloadfile/';
$_REFERER='http://ajy8hpcasy.l17.yunpan.cn/lk/QeEWZNzPansuQ';
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_REFERER,$_REFERER);
ob_start();
curl_exec($ch);
$result = ob_get_contents() ;
ob_end_clean();
echo $result;
set_time_limit(0);//为0时:允许脚本运行的时间无上限。不设置此函数的话默认为30s
header("location: http://hhtjim.com");//跳转到http://hhtjim.com
list() 函数用数组中的元素为一组变量赋值。实际上是一种语言结构,不是函数。
list($shareid, $uk) = array_slice($res, 1, 2);
//数组中有shareid, uk元素,让元素名最为变量名字。
//$res为总的数组,1为规定取出元素的开始位置。2为需要返回的数组数量。
define("GREETING","Hello world!");
//常量名为GREETING,值为"Hello world!
条件表达式e1?e2:e3,若e1为真(非0),则此表达式的值为e2的值;若为假,则表达式的值为e3
例如:
preg_match('|Location: (.+)\r|', $src, $res);
$songurl = $res ? $res[1] : exit(" error!");
示例:
$rt='{"errno":0,"errmsg":"\u64cd\u4f5c\u6210\u529f","data":{"downloadurl":"http:\/\/wsdl25.yunpan.cn\/share.php?method=Share.download&fhash=119f736a936d62396d7dd71ff8fb7d187d69d3d9&xqid=23620387&fname=%E8%AF%B4%E6%98%8E.doc&fsize=211968&nid=13754589643979953&cqid=157ddad976b9aa811591ed43134891f7&st=48ea3770079bce5360f952cff1dc9d29&e=1382784599&dt=25.1291649b2f9ed61380291c5c0d711ca9","params":[]}}';
$obj = json_decode($rt);
$dll=$obj->data->downloadurl;
echo $dll;
结果显示:http://wsdl25.yunpan.cn/share.php?method=Share.download&fhash=119f736a936d62396d7dd71ff8fb7d187d69d3d9&xqid=23620387&fname=%E8%AF%B4%E6%98%8E.doc&fsize=211968&nid=13754589643979953&cqid=157ddad976b9aa811591ed43134891f7&st=48ea3770079bce5360f952cff1dc9d29&e=1382784599&dt=25.1291649b2f9ed61380291c5c0d711ca9
示例二:
json数据:
{
"songs": [{
"score": 100,
"copyrightId": 0,
"mvid": 0,
"mp3Url": "http://m1.music.126.net/fG44YGce-id8VZ9LjQIPpQ==/1069824813834035.mp3"
}],
"code": 200
}
php处理:
$eo='上面的json数据';
$obj=json_decode($eo,true);
echo $obj['songs'][0]['mp3Url'];
结果返回:
h t t p : / /m1.music.126.net/fG44YGce-id8VZ9LjQIPpQ==/1069824813834035.mp3
$b = &$a; //变量前& 表示$b 和 $a 引用了同一个变量
extract() 函数 把数组中的键名设置为变量,其键值为变量的值。
对于数组中的每个元素,键名用于变量名,键值用于变量值。
substr_replace($P,$v,9,1);//(替换第10位的数字为$p)
<<< 运算符,将由自定义分界符间的内容视为字符串,可对其间的变量做处理
echo <<<tem
<script>alert("输入的留言内容太长!");history.go(-1);</script>
tem;
tem是任意字符,<<<后的tem标记着开始。必须以 tem; 结尾,另起一行顶格(前面无空格)书写,否则会报错。
echo <<<'tem'
$a str
tem;
添加单引号 就不会解析里面的变量
urlencode()返回字符串,此字符串中除了 -_. 之外的所有非字母数字字符都将被替换成百分号(%)后跟两位十六进制数.
rawurlencode()功能和urlencode基本一样,采用的是RFC1738编码,因此空格会编码为%20
sprintf() 函数把格式化的字符串写入一个变量中。
array_search()函数在数组中查找一个键值。如果找到了该值,匹配元素的键名会被返回。
函数计算字符串的 MD5 散列,第二的参数规定十六进制或二进制输出格式。
PHP_EOL表示换行符
split()用正则表达式将字符串分割到数组中
mt_rand(A,B) 函数返回A到B的随机整数
创建一个包含变量名和它们的值的数组:
$firstname = "Bill";
$lastname = "Gates";
$age = "60";
$result = compact("firstname", "lastname", "age");
print_r($result);
extract() 正好相反
陆续添加整理。。。
作者: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;
作者:matrix
发布时间:2013年10月26日
分类:零零星星
demo:http://link.hhtjim.com
外链测试:
http://music.sina.com.cn/yueku/i/2850351.html 阅读剩余部分 »
作者:matrix
发布时间:2013年10月26日
分类:兼容并蓄 零零星星
微云网盘的10TB空间也要全部利用起来。
申明:此页面的源码已失效,走这里查看最新>>微云网盘php解析源码_更新
代码来自破博客
<?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 阅读剩余部分 »
作者:matrix
发布时间:2013年10月19日
分类:兼容并蓄 零零星星
用火狐的firebug插件看到云盘的下载过程是通过post提交获得json数据(期间会检查REFERER),之后再跳转到下载地址。
图片外链演示:
mp3外链失败,但是下载的话没问题(后来才知道是360防盗链的Referer缘故):
作者: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不行!其余须自测。
参考:
http://www.w3cplus.com/content/css3-gradient
http://www.mxria.com/css3/c20120121810.htm
CSS3效果在线编辑工具
作者:matrix
发布时间:2013年10月14日
分类:兼容并蓄 零零星星
说明:
外链转换没有永久的,请酌情使用!!
链接地址可自动识别并相应的简单处理,有的显示文件名以及后缀。
链接地址可不用输入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。感谢分享!
作者:matrix
发布时间:2013年10月13日
分类:Wordpress 零零星星
测试是用于NGRO主题的首页文章列表上,配合起之前的窗口小列表 不错~
带8px白色边框鼠标停留后还有放大效果,如图:
.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图片阴影+鼠标移上放大图片
- 1
... - 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
... - 23