用php抓图片是个常用的需求,下面提供一个比较兼容的正则表达式来实现php抓取出页面、字符串中所有图片的src。

下面是一个范例,能匹配各种标签格式写法的图片,不管src在什么地方,还是单引号、双引号、没引号,都能匹配出来。

范例源码参考:

header(“Content-type:text/html;charset=utf-8″);

$str = ”;

 

$preg = ‘/<img.*?src=[\”|\’]?(.*?)[\”|\’]?\s.*?>/i’;

 

preg_match_all($preg, $str, $imgArr);
print_r($imgArr);

 

 

正文

@echo off

:start
::启动过程,切换目录
set pwd=%cd%
cd %1
echo 工作目录是:& chdir

:input
::获取输入,根据输入进行处理
set source=:
set /p source=确定要清楚当前目录下的svn信息吗?[Y/N/Q]
set “source=%source:”=%”

if “%source%”==”y” goto clean
if “%source%”==”Y” goto clean
if “%source%”==”n” goto noclean
if “%source%”==”N” goto noclean
if “%source%”==”q” goto end
if “%source%”==”Q” goto end
goto input

:clean
::主处理过程,执行清理工作
@echo on
@for /d /r %%c in (.svn) do @if exist %%c ( rd /s /q “%%c” & echo 删除目录%%c)
@echo off
echo “当前目录下的svn信息已清除”
goto end

:noclean
::分支过程,取消清理工作
echo “svn信息清楚操作已取消”
goto end

:end
::退出程序
cd “%pwd%”
pause

来源 http://yaojialing.iteye.com/blog/1226890

文件:删除svn

html代码

<a href=”http://www.shangzh.com” class=”tooltiptitle=”老李的博客”>尚站互联首页</a>

js代码

//鼠标跟随
var x = 15;
var y = 10;
$("body").append("<div id='tooltip' style='position: absolute;border: #333 1PX solid;background: #f7f5d1;padding: 1px;color: #333;display: none;padding: 1px;'></div>");
var mytooltip = $("#tooltip");

$(".tooltip").mouseover(function (e) { //当鼠标指针从元素上移入时
   this.mytitle = this.title;
   this.title = '';
   mytooltip.html(this.mytitle).css({ "top": (e.pageY + y) + "px", "left": (e.pageX + x) + "px" }).show("fast");
}).mouseout(function () { //当鼠标指针从元素上移开时
   this.title = this.mytitle;
   mytooltip.html('');
}).mousemove(function (e) { //当鼠标指针从元素上移动时
   mytooltip.css({ "top": (e.pageY + y) + "px", "left": (e.pageX + x) + "px" });
});

在使用phpsocket.io时需要https支持,在配置的时候踩了不少坑,这里做一下笔记。

如果你的ssl比较多,当然可以用独立域名来配置phpsocket.io 那就比较简单。只需要用nginx代理ssl就可以了,配置如下

server {
listen 443;

# host name to respond to
server_name ws.example.com;

# your SSL configuration
ssl on;
ssl_certificate /etc/ssl/localcerts/ws.example.com.bundle.crt;
ssl_certificate_key /etc/ssl/localcerts/ws.example.com.key;

location / {
# switch off logging
access_log off;

# redirect all HTTP traffic to localhost:8080
proxy_pass http://localhost:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

# WebSocket support (nginx 1.4)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;
}
}

Read More →

服务器信息传输

// send to current request socket client
socket.emit(‘message’, “this is a test”);

// sending to all clients except sender
socket.broadcast.emit(‘message’, “this is a test”);

// sending to all clients in ‘game’ room(channel) except sender
socket.broadcast.to(‘game’).emit(‘message’, ‘nice game’);

// sending to all clients, include sender
io.sockets.emit(‘message’, “this is a test”);

// sending to all clients in ‘game’ room(channel), include sender
io.sockets.in(‘game’).emit(‘message’, ‘cool game’);

// sending to individual socketid
io.sockets.socket(socketid).emit(‘message’, ‘for your eyes only’);
上述集中方式为socket.io常用的数据传输方式,

io.sockets.on(‘connection’, function (socket) {

});

回调函数的socket参数为一个 client 与服务器的连接标示,不同的 client 会有不同的连接标示。

Read More →