欧美日韩国产一区二区三区,国产精品字幕一区二区,婷婷综合另类小说色区 http://www.jartj.cn/blog 中山php|最優(yōu)網(wǎng)絡(luò) Mon, 13 May 2013 04:56:43 +0000 en hourly 1 http://wordpress.org/?v=3.1.4 用新浪搜狐騰訊jS接口取客戶端IP及省份城市 http://www.jartj.cn/blog/view-434.html http://www.jartj.cn/blog/view-434.html#comments Mon, 13 May 2013 04:56:43 +0000 lin http://www.jartj.cn/blog/?p=434 新浪的IP地址查詢接口:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js

新浪多地域測(cè)試方法:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=218.192.3.42

搜狐IP地址查詢接口(默認(rèn)GBK):http://pv.sohu.com/cityjson

搜狐IP地址查詢接口(可設(shè)置編碼):http://pv.sohu.com/cityjson?ie=utf-8

搜狐另外的IP地址查詢接口:http://txt.go.sohu.com/ip/soip

騰訊的接口:http://fw.qq.com/ipaddress (騰訊的接口原本是最好用的,可現(xiàn)在打不開(kāi)啦)

上面的接口中新浪的是js接口說(shuō)明:

<script type="text/javascript" src=" <script type="text/javascript">
function ipmsg() {
var ss = remote_ip_info['country']??+ remote_ip_info['province']+ remote_ip_info['city'];
document.getElementByIdx_x_x("<%=HiddenField1.ClientID %>").value = ss;

}
</script>

 

]]>
http://www.jartj.cn/blog/view-434.html/feed 689
php壓縮html : 清除換行符,清除制表符,去掉注釋標(biāo)記 http://www.jartj.cn/blog/view-431.html http://www.jartj.cn/blog/view-431.html#comments Sat, 30 Mar 2013 06:48:24 +0000 lin http://www.jartj.cn/blog/?p=431 /**
* 壓縮html : 清除換行符,清除制表符,去掉注釋標(biāo)記
* @param $string
* @return 壓縮后的$string
* */
function compress_html($string) {
$string = str_replace("\r\n", '', $string); //清除換行符
$string = str_replace("\n", '', $string); //清除換行符
$string = str_replace("\t", '', $string); //清除制表符
$pattern = array (
"/> *([^ ]*) *</", //去掉注釋標(biāo)記
"/[\s]+/",
"/<!--[^!]*-->/",
"/\" /",
"/ \"/",
"'/\*[^*]*\*/'"
);
$replace = array (
">\\1<",
" ",
"",
"\"",
"\"",
""
);
return preg_replace($pattern, $replace, $string);
}

]]>
http://www.jartj.cn/blog/view-431.html/feed 689
php防止刷流量攻擊 http://www.jartj.cn/blog/view-428.html http://www.jartj.cn/blog/view-428.html#comments Fri, 29 Mar 2013 10:55:10 +0000 lin http://www.jartj.cn/blog/?p=428 <?php
//查詢禁止IP
$ip =$_SERVER['REMOTE_ADDR'];
$fileht=".htaccess2";
if(!file_exists($fileht))file_put_contents($fileht,"");
$filehtarr=@file($fileht);
if(in_array($ip."\r\n",$filehtarr))die("Warning:"."<br>"."Your IP address are forbided by some reason, IF you have any question Pls emill to shop@mydalle.com!");

//加入禁止IP
$time=time();
$fileforbid="log/forbidchk.dat";
if(file_exists($fileforbid))
{ if($time-filemtime($fileforbid)>60)unlink($fileforbid);
else{
$fileforbidarr=@file($fileforbid);
if($ip==substr($fileforbidarr[0],0,strlen($ip)))
{
if($time-substr($fileforbidarr[1],0,strlen($time))>600)unlink($fileforbid);
elseif($fileforbidarr[2]>600){file_put_contents($fileht,$ip."\r\n",FILE_APPEND);unlink($fileforbid);}
else{$fileforbidarr[2]++;file_put_contents($fileforbid,$fileforbidarr);}
}
}
}
//防刷新
$str="";
$file="log/ipdate.dat";
if(!file_exists("log")&&!is_dir("log"))mkdir("log",0777);
if(!file_exists($file))file_put_contents($file,"");
$allowTime = 120;//防刷新時(shí)間
$allowNum=10;//防刷新次數(shù)
$uri=$_SERVER['REQUEST_URI'];
$checkip=md5($ip);
$checkuri=md5($uri);
$yesno=true;
$ipdate=@file($file);
foreach($ipdate as $k=>$v)
{ $iptem=substr($v,0,32);
$uritem=substr($v,32,32);
$timetem=substr($v,64,10);
$numtem=substr($v,74);
if($time-$timetem<$allowTime){
if($iptem!=$checkip)$str.=$v;
else{
$yesno=false;
if($uritem!=$checkuri)$str.=$iptem.$checkuri.$time."1\r\n";
elseif($numtem<$allowNum)$str.=$iptem.$uritem.$timetem.($numtem+1)."\r\n";
else
{
if(!file_exists($fileforbid)){$addforbidarr=array($ip."\r\n",time()."\r\n",1);file_put_contents($fileforbid,$addforbidarr);}
file_put_contents("log/forbided_ip.log",$ip."--".date("Y-m-d H:i:s",time())."--".$uri."\r\n",FILE_APPEND);
$timepass=$timetem+$allowTime-$time;
die("Warning:"."<br>"."Sorry,you are forbided by refreshing frequently too much, Pls wait for ".$timepass." seconds to continue!");
}
}
}
}
if($yesno) $str.=$checkip.$checkuri.$time."1\r\n";
file_put_contents($file,$str);

]]>
http://www.jartj.cn/blog/view-428.html/feed 0
php多維數(shù)組的搜索 http://www.jartj.cn/blog/view-425.html http://www.jartj.cn/blog/view-425.html#comments Mon, 17 Dec 2012 12:48:04 +0000 lin http://www.jartj.cn/blog/?p=425 1 php搜索多維數(shù)組的鍵值

如下面例子:

$foo[1]['a']['xx'] = 'bar 1';
$foo[1]['b']['xx'] = 'bar 2';
$foo[2]['a']['bb'] = 'bar 3';
$foo[2]['a']['yy'] = 'bar 4';
$foo[3]['c']['dd'] = 'bar 3';
$foo[3]['f']['gg'] = 'bar 3';
$foo['info'][1] = 'bar 5';

如果要查找 bar 3 怎么進(jìn)行查找呢。有三個(gè)結(jié)果,而這三個(gè)結(jié)果都要,看下面的函數(shù):
-------------------------------------------------------------------------------------------------------------------------------
function array_search_re($needle, $haystack, $a=0, $nodes_temp=array()){
global $nodes_found;
$a++;
foreach ($haystack as $key1=>$value1) {
??? $nodes_temp[$a] = $key1;
??? if (is_array($value1)){???
????? array_search_re($needle, $value1, $a, $nodes_temp);
??? }
??? else if ($value1 === $needle){
????? $nodes_found[] = $nodes_temp;
??? }
}
return $nodes_found;
}
---------------------------------------------------------------------------------------------------------------------------------
這個(gè)函數(shù)就可以把上面要查找到的內(nèi)容全部返回出鍵名來(lái)
$result = array_search_re('bar 3', $foo);

print_r($result);

輸出結(jié)果為如下:
Array ( [0] => Array ( [1] => 2 [2] => a [3] => bb )
?????? ?? [1] => Array ( [1] => 3 [2] => c [3] => dd )
?????? ?? [2] => Array ( [1] => 3 [2] => f [3] => gg )
???? ?? )

1 php搜索多維數(shù)組的鍵名

function array_search_key($needle, $haystack){
global $nodes_found;

foreach ($haystack as $key1=>$value1) {
?
?if ($key1=== $needle){
?
??$nodes_found[] = $value1;
???????
?? }
??? if (is_array($value1)){???
????? array_search_key($needle, $value1);
??? }
???
???
}

return $nodes_found;
}
$result = array_search_key('a', $foo);

print_r($result);

輸出結(jié)果為如下:
?

Array
(
??? [0] => Array
??????? (
??????????? [xx] => bar 1
??????? )

??? [1] => Array
??????? (
??????????? [bb] => bar 3
??????? )

??? [2] => Array
??????? (
??????????? [yy] => bar 4
??????? )

)

]]>
http://www.jartj.cn/blog/view-425.html/feed 743
網(wǎng)站排名下降時(shí)是否是修改關(guān)鍵詞的時(shí)機(jī) http://www.jartj.cn/blog/view-422.html http://www.jartj.cn/blog/view-422.html#comments Tue, 04 Dec 2012 06:34:33 +0000 lin http://www.jartj.cn/blog/?p=422 最近網(wǎng)站排名出現(xiàn)變動(dòng),幾個(gè)排名一直穩(wěn)定在百度前三的關(guān)鍵詞出現(xiàn)下降,甚至完全被k的情況,經(jīng)過(guò)分析,發(fā)現(xiàn)是收到友情鏈接的牽連,有三個(gè)友鏈網(wǎng)站被k,對(duì)方鏈回我的那個(gè)關(guān)鍵詞排名直接沒(méi)有。

剛好我也想把 中山網(wǎng)站建設(shè)?這個(gè)關(guān)鍵詞設(shè)為主關(guān)鍵詞,以前由于其他詞的排名都比較穩(wěn)定,不敢輕易修改,怕其他的收到影響,這次趁此機(jī)會(huì)一起改了,看看效果如果,驗(yàn)證一下? 網(wǎng)站排名下降時(shí)是否是修改關(guān)鍵詞的時(shí)機(jī),也給其他站長(zhǎng)做一個(gè)參考。

]]> http://www.jartj.cn/blog/view-422.html/feed 310 php過(guò)濾客戶提交參數(shù),防注入 http://www.jartj.cn/blog/view-417.html http://www.jartj.cn/blog/view-417.html#comments Sat, 24 Nov 2012 09:16:40 +0000 lin http://www.jartj.cn/blog/?p=417 以下代碼實(shí)現(xiàn)過(guò)濾php的$_GET 和$_POST參數(shù)

/**
* 安全防范
*/
function Add_S($array)
{
foreach($array as $key=>$value)
{
if(!is_array($value))
{
$value = get_magic_quotes_gpc()?$value:addslashes($value);
$array[$key]=filterHtml($value);
}
Else
{
Add_S($array[$key]);
}
}
return $array;
}
function glstr($var) {

if (is_array($var)) {
return Add_S($var);
}
elseif(strlen($var)){
$var = get_magic_quotes_gpc()?$var:addslashes($var);

$var = filterHtml($var);
}
return $var;
}
function filterHtml($html)
{
$farr = array(
"/<!DOCTYPE([^>]*?)>/eis",
"/<(\/?)(html|body|head|link|meta|base|input)([^>]*?)>/eis",
"/<(script|i?frame|style|title|form)(.*?)<\/\\1>/eis",
"/(<[^>]*?\s+)on[a-z]+\s*?=(\"|')([^\\2]*)\\2([^>]*?>)/isU",//過(guò)濾javascript的on事件
"/\s+/",//過(guò)濾多余的空白
);
$tarr = array(
"",
"",
"",
"\\1\\4",
" ",
);
$html = preg_replace( $farr,$tarr,$html);
return $html;
}
if (sizeof($_GET)) {
foreach($_GET as $key => $value) {
$_GET[$key] = glstr($value); //
}

}
if (sizeof($_POST)) {
foreach($_POST as $key => $value) {
$_POST[$key] = glstr($value); //
}
}

]]>
http://www.jartj.cn/blog/view-417.html/feed 343
php計(jì)算代碼運(yùn)行時(shí)間和使用內(nèi)存 http://www.jartj.cn/blog/view-415.html http://www.jartj.cn/blog/view-415.html#comments Wed, 14 Nov 2012 08:28:49 +0000 lin http://www.jartj.cn/blog/?p=415

<?php

//開(kāi)始計(jì)時(shí)


$HeaderTime =
microtime(true);//參數(shù)true表示返回浮點(diǎn)數(shù)值

//代碼

//...

printf(" total run: %.2f s<br>".
"memory usage: %.2f M<br> ",
microtime(true)-$HeaderTime,
memory_get_usage() / 1024 / 1024 );
?>
結(jié)果:

total runtime: 1.47 s

memory usage: 77.09 M

]]>
http://www.jartj.cn/blog/view-415.html/feed 454
select下拉菜單實(shí)現(xiàn)友情鏈接跳轉(zhuǎn) http://www.jartj.cn/blog/view-413.html http://www.jartj.cn/blog/view-413.html#comments Sun, 07 Oct 2012 08:47:40 +0000 lin http://www.jartj.cn/blog/?p=413 <select name="select" class="home_left_select" onchange="window.location=this.options[this.selectedIndex].value">
<option value="#">友情鏈接</option>
<option value="http://www.baidu.com">2</option>
<option value="http://www.baidu.com">2</option>
<option value="http://www.baidu.com">2</option>
<option value="http://www.baidu.com">2</option>
<option value="http://www.baidu.com">2</option>
</select>

以上代碼實(shí)現(xiàn)選中項(xiàng)跳轉(zhuǎn)到指定鏈接

]]>
http://www.jartj.cn/blog/view-413.html/feed 399
mysql STRICT_TRANS_TABLES嚴(yán)格模式下提示Field 'id' doesn't have a default value http://www.jartj.cn/blog/view-411.html http://www.jartj.cn/blog/view-411.html#comments Wed, 26 Sep 2012 03:42:48 +0000 lin http://www.jartj.cn/blog/?p=411 在別的服務(wù)器運(yùn)行我的網(wǎng)站程序的時(shí)候,出現(xiàn)了Field 'id' doesn't have a default value 的提示,意思是這個(gè)值我沒(méi)有提交數(shù)據(jù),并且數(shù)據(jù)庫(kù)結(jié)構(gòu)沒(méi)有設(shè)置默認(rèn)值,由于對(duì)方的mysql服務(wù)器開(kāi)啟了STRICT_TRANS_TABLES嚴(yán)格模式,所以報(bào)錯(cuò)了

解決方法是:

如果自己的服務(wù)器,有權(quán)限修改my.ini的話,打開(kāi)my.ini,查找
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

修改為

sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

然后重啟MYSQL

在別人的虛擬空間上當(dāng)然不可能實(shí)現(xiàn),所以根本的解決方法還是修改自己的數(shù)據(jù)結(jié)構(gòu),把非空的字段加上默認(rèn)值,以后設(shè)計(jì)數(shù)據(jù)庫(kù)要注意這一點(diǎn),方便程序的移植

]]>
http://www.jartj.cn/blog/view-411.html/feed 431
smarty模版使用php標(biāo)簽,如何獲取模版變量 http://www.jartj.cn/blog/view-409.html http://www.jartj.cn/blog/view-409.html#comments Sat, 22 Sep 2012 03:54:23 +0000 lin http://www.jartj.cn/blog/?p=409 已經(jīng)assign一個(gè)模版變量$assign,由于要做特殊的循環(huán)輸出,使用for循環(huán),因此使用到了php標(biāo)簽,但是php語(yǔ)句和模版語(yǔ)句的變量作用域是不同的,因此不能直接獲取到

{{php}}

for($i=0;$i<count($assign);$i=$i+2){
echo '
<ul>
<li> <span class="zz_pic"><a href="'._url('picture',array('col_key'=>'cert','pic_id'=>$assign[$i][pic_id])).'" title=""><img src="uploads/thumb_'.$assign[$i][pic].'" alt=""></a></span> <span class="zz_title"><a href="'._url('picture',array('col_key'=>'cert','pic_id'=>$assign[$i][pic_id])).'" title="">'.$assign[$i][title].'</a></span> </li>
<li> <span class="zz_pic"><a href="'._url('picture',array('col_key'=>'cert','pic_id'=>$assign[$i+1][pic_id])).'" title=""><img src="uploads/thumb_'.$assign[$i+1][pic].'" alt=""></a></span> <span class="zz_title"><a href="'._url('picture',array('col_key'=>'cert','pic_id'=>$assign[$i+1][pic_id])).'" title="">'.$assign[$i+1][title].'</a></span> </li>i>

</ul>';}
{{/php}}

解決的方法是:模版變量全部存在smarty的一個(gè)對(duì)象里面;只要在for之前進(jìn)行賦值:$assign = $this->_tpl_vars[assign];

{{php}}
$assign = $this->_tpl_vars[assign];
for($i=0;$i<count($assign);$i=$i+2){
echo '
<ul>
<li> <span class="zz_pic"><a href="'._url('picture',array('col_key'=>'cert','pic_id'=>$assign[$i][pic_id])).'" title=""><img src="uploads/thumb_'.$assign[$i][pic].'" alt=""></a></span> <span class="zz_title"><a href="'._url('picture',array('col_key'=>'cert','pic_id'=>$assign[$i][pic_id])).'" title="">'.$assign[$i][title].'</a></span> </li>
<li> <span class="zz_pic"><a href="'._url('picture',array('col_key'=>'cert','pic_id'=>$assign[$i+1][pic_id])).'" title=""><img src="uploads/thumb_'.$assign[$i+1][pic].'" alt=""></a></span> <span class="zz_title"><a href="'._url('picture',array('col_key'=>'cert','pic_id'=>$assign[$i+1][pic_id])).'" title="">'.$assign[$i+1][title].'</a></span> </li>i>

</ul>';}
{{/php}}

]]>
http://www.jartj.cn/blog/view-409.html/feed 502
瓦房店市| 内乡县| 新乐市| 荆门市| 尉氏县| 曲麻莱县| 天峻县| 寿阳县| 横峰县| 榆中县| 东平县| 兴和县| 河源市| 桃江县| 安顺市| 德州市| 洪雅县| 东兴市| 历史| 连云港市| 天水市| 揭东县| 罗平县| 富锦市| 政和县| 宣汉县| 宾阳县| 沽源县| 宜阳县| 新竹市| 湘西| 裕民县| 灵丘县| 永平县| 迁西县| 满洲里市| 麻栗坡县| 奈曼旗| 浑源县| 久治县| 奉贤区|