把指定字符依次替换掉,文章加关键词用

/**********************取关键词 不带超链*************************************/
function get_kw_no($id){
if(!isset($id)){
$id=0;
}
$str = substr($id,-1);//取ID最后一个数字
if($id<10){
$str2 = 0;
}else{
$str2 = substr($id,-2,1);//取ID最后第二个数字
}

$str3=substr($str+$str2,-1);

$sql=”select id from t_keyword order by id desc limit 1″;//
$rs=mysql_query($sql);
$rows=mysql_fetch_assoc($rs);
$id_max=$rows[“id”];
$id_list=$str;
for ($x=$str;$x<=$id_max;$x=$x+$str3) {
$id_list.=”,”.$x;
}
$list=array();
$sql=”select id,title from t_keyword where id in($id_list) order by id desc “;//
$rs=mysql_query($sql);
while($rows=mysql_fetch_assoc($rs)){
$tt=”<b class=’small-font smallsize-font’>”.$rows[“title”].”</b>”;
array_push($list, $tt);

}
//var_dump($list);
return $list;

}
/////////////////////////////////////////////
$str=get_kw_no($rows[“id”]);
$txt=$rows[“content”];
preg_match_all(“/[\x01-\x7f]|[\xe0-\xef][\x80-\xbf]{2}/”, $txt, $match);//正则转化成数组
$lenth= sizeof($str)-1;
$i=0; //数组开始位置

foreach($match[0] as $k=>$v){
if($v==’的’){
$match[0][$k]=$str[$i].$v;
//$v=$str[$i].$v; //不能用这个组,这个只是修改了临时的$V,对$match没有影响
$i++;
}
if($i>$lenth){
break;
}
}

$topicid =”; //变量赋值为空,重新组成字符串
foreach($match[0] as $k=>$v){
$topicid.=$match[0][$k];
}

echo $topicid;
?>

CSS 怎么把字体设在小于12PX

<style>
p.small-font{

font-size:12px;
-webkit-transform-origin-x: 0;
-webkit-transform: scale(0.50);
}
p.smallsize-font { //为了兼容IE
font-size:6px;

}
</style>
<p style=”color: #FF0000;” class=”small-font smallsize-font”>温馨提示:</p>

 

-webkit-transform 缩小,只对块元素起作用,像默认的span, b, font 是不起作用的。

PHP curl_init() 方法伪造HTTP头信息 (采集用)

function get_resource()
{
$url3=””;

$ch = curl_init();
// 设置浏览器的特定header
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
“Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8”,
“Accept-Encoding:gzip, deflate, sdch”,
“Accept-Language:zh-CN,zh;q=0.8”,
“Cache-Control:max-age=0”,
“Connection:keep-alive”,
“Cookie:PHPSESSID=046nki081pq1q95i14ri56gm50; __guid=120719246.3657633326262056000.1513052974140.0562; lang=cn; chart_time=5; chart_time_name=chart_5m; chart_theme=white; monitor_count=30”,
“Host:www.xxx.com”,
“Upgrade-Insecure-Requests:1”,
“User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36”
));
curl_setopt($ch, CURLOPT_USERAGENT, ‘Mozilla/5.0 (Windows NT 10.0; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0’);
// 在HTTP请求头中”Referer: “的内容。
curl_setopt($ch, CURLOPT_REFERER,”http://www.xxx.com”);
curl_setopt($ch, CURLOPT_ENCODING, “gzip, deflate, sdch”);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, $url3);
curl_setopt($ch, CURLOPT_TIMEOUT,120);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//302redirect
$html = curl_exec($ch);
curl_close($ch);
return $html;
}//get_resource结束

$t3=json_decode(get_resource(),TRUE);  //返回数组

PHP防采集 判断请求头,防菜鸟专用

if (!function_exists(‘getallheaders’))//判断请求头信息
{
function getallheaders()
{
foreach ($_SERVER as $name => $value)
{
if (substr($name, 0, 5) == ‘HTTP_’)
{
$headers[str_replace(‘ ‘, ‘-‘, ucwords(strtolower(str_replace(‘_’, ‘ ‘, substr($name, 5)))))] = $value;
}
}
return $headers;
}
}

$res=getallheaders();
echo $res[Host]; //判断 host 是不是指定的网站.

 

BUT: curl_init()可以假造HTTP头信息,所以只能防防菜鸟,对于自己会写HTTP头的来 说,一点用都没有

判断来路是不是手机,并跳转

<?php
if(isMobile()){
header(“Location: http://www.XXXX/home/m/”);
}else{

}

 

function isMobile(){ //判断是不是手机访问
$useragent=isset($_SERVER[‘HTTP_USER_AGENT’]) ? $_SERVER[‘HTTP_USER_AGENT’] : ”;
$useragent_commentsblock=preg_match(‘|\(.*?\)|’,$useragent,$matches)>0?$matches[0]:”;
function CheckSubstrs($substrs,$text){
foreach($substrs as $substr)
if(false!==strpos($text,$substr)){
return true;
}
return false;
}
$mobile_os_list=array(‘Google Wireless Transcoder’,’Windows CE’,’WindowsCE’,’Symbian’,’Android’,’armv6l’,’armv5′,’Mobile’,’CentOS’,’mowser’,’AvantGo’,’Opera Mobi’,’J2ME/MIDP’,’Smartphone’,’Go.Web’,’Palm’,’iPAQ’);
$mobile_token_list=array(‘Profile/MIDP’,’Configuration/CLDC-‘,’160×160′,’176×220′,’240×240′,’240×320′,’320×240′,’UP.Browser’,’UP.Link’,’SymbianOS’,’PalmOS’,’PocketPC’,’SonyEricsson’,’Nokia’,’BlackBerry’,’Vodafone’,’BenQ’,’Novarra-Vision’,’Iris’,’NetFront’,’HTC_’,’Xda_’,’SAMSUNG-SGH’,’Wapaka’,’DoCoMo’,’iPhone’,’iPod’);

$found_mobile=CheckSubstrs($mobile_os_list,$useragent_commentsblock) ||
CheckSubstrs($mobile_token_list,$useragent);

if ($found_mobile){
return true;
}else{
return false;
}
?>

php – zend解密函数

<?php
function unscrambler($code) {
if(! is_array($code)) {
$code = str_replace(‘__FILE__’, “‘$code'”, str_replace(‘eval’, ‘$code=’, file_get_contents($code)));
eval(‘?>’ . $code);
}else {
extract($code);
$code = str_replace(“eval”, ‘$code=’, $code);
eval($code);
}
if(strstr($code, ‘eval’)) return unscrambler(get_defined_vars());
else return $code;
}

//echo unscrambler(‘需要还原的代码或文件名’);
$ttt=”%6E1%7A%62%2F%6D%615%5C%76%740%6928%2D%70%78%75%71%79%2A6%6C%72%6B%64%679%5F%65%68%63%73%77%6F4%2B%6637%6A”);$O00O0O=$O00OO0{3}.$O00OO0{6}.$O00OO0{33}.$O00OO0{30};$O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FWYjB6QXQwekFrd1NSMkxsam9tc0RvbVFCazlGZTJiWGpadWxPSSs0K2d2b3JwcjQ1YU9Nczd0d0FsSm5wazVIRHlXSmVXOXNEb3dFakFsUVJvZHJwSTl5RDI1UWUyZHNOMm1ZT1FHdVJBUk1WYjB6QXRFWFJvV1NweFl3QWxKd0FsRUhCTndFakFuUWUxOGhqWFQ2akE4c3JpSEdNYW9hclZwSTZEKzBadHVuQWtFckIyaDFldldGRDI1SGVVVHVuM25TRG9Zc2MyOXJlMm1TRDE4aE9RR3VSQVJNVmIwekF0RVhSb1dTcHhZd0FsSndBbEVIQk53RWpBbnJlazlGbW9FYmpYVDZqQThzci8yMzFZTmQwd1R3QWxKbnBrNUhEeVdKZVc5c0Rvd0VqQWxRUm9kcnBJOWtwTkdTUm9kcnBJNWJweVRRenFZd0FsSm5CUW5FQmtZN1p0dW5adHVuZXZXb0JOV1ltQVQ2WnR1bkFrV0hwdjhsakhocXQxbm5MZHRscUtkVmMxV0djMEw5bjBNU21vZHFCM25NUnl0UWlYajdadHVuQWtXSHB2OGxuMmRZZU5uMHpBejNoN1B1eFZ2OXI3T1ZJczBYenFDZkJOZVNSMndJcE5HMFZvU01SM2NzUlFKckJvZEhwSWxDZ1VKUVZiMHpBdEVFQjJTc2pBajhPMXdaTEpFdFdaNFhWYjB6QXRFWFJvV1NweFl3QWwwekZ0MHppeDR3QWw9PSI7ZXZhbCgnPz4nLiRPMDBPME8oJE8wT08wMCgkT08wTzAwKCRPME8wMDAsJE9PMDAwMCoyKSwkT08wTzAwKCRPME8wMDAsJE9PMDAwMCwkT08wMDAwKSwkT08wTzAwKCRPME8wMDAsMCwkT08wMDAwKSkpKTs=”
echo unscrambler($ttt);
?>

show()方法和hide()方法

$(“selector”).show()
从display:none还原元素默认或已设置的display属性
$(“selector”).hide()
设置元素的display样式为none,等于$(“selector”).css(“display”,”none”)
(注: 传入参数后,.show()和.hide()方法同时动画改变元素的width,height和透明属性;传入参数控制显隐速度,单位毫秒, 如.show(600),也可传入fast,normal,slow,fast为200毫秒,normal为400毫秒,slow为600毫秒)

fadeIn()方法和fadeOut()方法, slideUp()方法和slideDown()方法, animate()动画

fadeIn()方法和fadeOut()方法

$(“selector”).fadeIn()
控制透明度在指定时间内从display:none提高至完全显示
$(“selector”).fadeOut()
控制透明度在指定时间内降低至display:none;

slideUp()方法和slideDown()方法

$(“selector”).slideUp()
控制元素高度在指定时间内从下到上缩短至display:none;
$(“selector”).slideDown()
控制元素高度在指定时间内从display:none延伸至完整高度

自定义动画方法animate()

$(“selector”).animate(params,speed,callback);
params:一个包含样式属性及值的映射,

比如{property1:”value1″,property2:”value2″,…}
speed:速度参数,可选
callback:在动画完成时执行的参数(即回调函数),可选