查询字段(ID集合)里是否包含某个具体ID

select * from t_news where del=0 and find_in_set($t,urls)

字段urls里的内容为:

id      urls

1      1,3,5

2      2,4

3     6,5,7

需要从表中找出urls包含5的记录。

select * from t_news where del=0 and find_in_set(5,urls) 结果是:

id       urls

1        1,3,5

3        6,5,7

CentOS 7.X 安装WDCP3.X后Apache及Nginx启动失败解决办法

CentOS 7.x 在安装WDCP3.x 后会出现Apache及Nginx无法启动,提示为

Starting httpd (via systemctl):  Job for httpd.service failed 
because the control process exited with error code. 
See "systemctl status httpd.service" and "journalctl -xe" for details.

Starting nginxd (via systemctl):  Job for nginxd.service failed 
because the control process exited with error code. 
See "systemctl status nginxd.service" and "journalctl -xe" for details.

主要原因是因为系统中缺少WWW用户导致的,只需在系统中建立www用户和用户组即可解决问题

useradd -g www www

php检测判断网站是否被百度收录

只能用来判断有没收入,不能判断收入了多少页。

 

<span style=”font-size:14px;”><?php

 

    /*

 

    * 检测百度是否收录网页 curl模式

 

    * @ param string $url传入的url

 

    * return int (1 收录 0 不收录)

 

    */

 

    function checkBaidu($url){

 

    $url=’http://www.baidu.com/s?wd=’.$url;

 

    $curl=curl_init();

 

    curl_setopt($curl,CURLOPT_URL,$url);

 

    curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);

 

    $rs=curl_exec($curl);

 

    curl_close($curl);

 

    $arr=parse_url($url);

 

    if(strpos($arr[‘query’],’http://’)){

 

    $arr[‘query’]=str_replace(‘http://’,”,str_replace(‘wd=’,”,$arr[‘query’]));

 

    }else{

 

    $arr[‘query’]=str_replace(‘wd=’,”,$arr[‘query’]);

 

    }

 

    if(strpos($arr[‘query’],’?’)){

 

    $str=strstr($arr[‘query’],’?’);

 

    $arr[‘query’]=str_replace($str,”,$arr[‘query’]);

 

    }
    if(strpos($arr[‘query’],’/’)){

 

    $narr=explode(‘/’,$arr[‘query’]);

 

    $arr[‘query’]=$narr[0];

 

    }

 

    if(strpos($rs,'<b>’.$arr[‘query’].'</b>’)){

 

    return 1;

 

    }else{

 

    return 0;

 

    }

 

    }

 

    echo checkBaidu(‘http://www.weinq.com/’);

?></span>

下面是改良过的方法,用百度WAP端来提升速度

<span style=”font-size:14px;”><?php
function checkbaidu($url)
{
$str=file_get_contents(“http://wap.baidu.com/s?word=inurl:”.$url);//加快速度,用WAP网页来进行搜索,并且应用搜索引擎的inurl语法
if(stripos($str,”抱歉,没有找到”))return 0;//如果出现关键字则判定没有找到
return 1;
}
echo checkbaidu(“weinq.com”);
?></span>

批量检查网站能否正常打开

<?php
//设置最大执行时间是 120秒
ini_set(‘max_execution_time’,120);
function httpcode($url){
$ch = curl_init();
$timeout = 3;
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch,CURLOPT_URL,$url);
curl_exec($ch);
return $httpcode = curl_getinfo($ch,CURLINFO_HTTP_CODE); //返回http状态码,如果是200,表明网页正常打开
curl_close($ch);
}
$check_web = array(
‘//www.111.net/’,
‘http://222.net/’,
‘http://333.net/’,
‘http://444.net/’,
‘http://555.net/’,
‘http://666.net/’,
);
for($i=0;$i<count($check_web);$i++){
echo $check_web[$i].’ -> ‘.httpcode($check_web[$i]).'<br>’;
}
?>