常用代码搜集

1、图片垂直居中:

img{position:absolute;top:0;bottom:0;left:0;right:0;margin:auto;}

2、Chrome更换agent

谷歌Android:

“C:\Program Files\Google\Chrome\Application\chrome.exe” –user-agent=”Mozilla/5.0 (Linux; U; Android 2.2; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1″

苹果iPhone:

“C:\Program Files\Google\Chrome\Application\chrome.exe” –user-agent=”Mozilla/5.0 (iPhone; CPU iPhone OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9A405″

苹果iPad:

“C:\Program Files\Google\Chrome\Application\chrome.exe” –user-agent=”Mozilla/5.0 (iPad; CPU OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9A405″

诺基亚N97:

“C:\Program Files\Google\Chrome\Application\chrome.exe” –user-agent=”Mozilla/5.0 (SymbianOS/9.4; Series60/5.0 NokiaN97-1/20.0.019; Profile/MIDP-2.1 Configuration/CLDC-1.1) AppleWebKit/525 (KHTML, like Gecko) BrowserNG/7.1.18124″

3、Discuz X2在设置审核状态下依然禁止发布含有屏蔽关键词的内容

编辑 source/module/forum/forum_post.php 找到 require_once libfile(‘class/censor’);

在有空行的地方添加

if($censor->result==1&&$_POST[‘delete’]==0){

showmessage(‘您提交的帖子内容里含有系统禁止的词语,请修改后重新提交,谢谢’);

}

这样即可禁止提交

获取内容里面的屏蔽词:

$_censorWords=join(‘,’,$censor->words_found);

4、php移除内容中的BOM

[hide]$str = str_replace(pack(“CCC”,0xef,0xbb,0xbf),”,$str);

5、YII登录后不返回前页面修改办法

public function actionLogin(){

if (!Yii::$app->user->isGuest) {

return $this->goHome();

}

$model = new LoginForm();

if ($model->load(Yii::$app->request->post()) && $model->login()) {

return $this->goBack();

} else {

Yii::$app->user->setReturnUrl(Yii::$app->request->referrer); //只需要添加这句话就可以了

return $this->render('login', [

'model' => $model,

]);

}

}

6、页面只能被本站页面嵌入到iframe或者frame中。

header(‘X-Frame-Options: SAMEORIGIN’);

7、批量删除twitter推特推文和回复(F12 console下执行):

$(“.js-actionDelete”).each(function(){

$(this).click();

$(“.delete-action”).get(0).click();

});

8、推特twitter批量取消关注:

$(“.following .js-follow-btn”).click()

9、提取手机号码

preg_match_all(‘/1[3456789]{1}[0-9]{9}$/’,$content,$phone);

原创文章,作者:山少,如若转载,请注明出处:http://www.shanshao.com/shanshao/61