�(y��u)���� http://m.dgkai.cn/blog ��ɽphp|�(y��u)�W(w��ng)�j(lu��) Mon, 13 May 2013 04:56:43 +0000 en hourly 1 http://wordpress.org/?v=3.1.4 �������Ѻ��vӍjS�ӿ�ȡ�͑���IP��ʡ�ݳ��� http://m.dgkai.cn/blog/view-434.html http://m.dgkai.cn/blog/view-434.html#comments Mon, 13 May 2013 04:56:43 +0000 lin http://m.dgkai.cn/blog/?p=434 ���˵�IP��ַ��ԃ�ӿڣ�http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js

���˶����y(c��)ԇ������http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=218.192.3.42

�Ѻ�IP��ַ��ԃ�ӿڣ�Ĭ�J(r��n)GBK����http://pv.sohu.com/cityjson

�Ѻ�IP��ַ��ԃ�ӿڣ����O(sh��)�þ��a����http://pv.sohu.com/cityjson?ie=utf-8

�Ѻ������IP��ַ��ԃ�ӿڣ�http://txt.go.sohu.com/ip/soip

�vӍ�Ľӿڣ�http://fw.qq.com/ipaddress (�vӍ�Ľӿ�ԭ��������õ����ɬF(xi��n)�ڴ��_��)

����Ľӿ������˵���js�ӿ��f(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://m.dgkai.cn/blog/view-434.html/feed 689
php���shtml : ����Q�з�,����Ʊ���,ȥ��עጘ�(bi��o)ӛ http://m.dgkai.cn/blog/view-431.html http://m.dgkai.cn/blog/view-431.html#comments Sat, 30 Mar 2013 06:48:24 +0000 lin http://m.dgkai.cn/blog/?p=431 /**
* ���shtml : ����Q�з�,����Ʊ���,ȥ��עጘ�(bi��o)ӛ
* @param $string
* @return ���s���$string
* */
function compress_html($string) {
$string = str_replace("\r\n", '', $string); //����Q�з�
$string = str_replace("\n", '', $string); //����Q�з�
$string = str_replace("\t", '', $string); //����Ʊ���
$pattern = array (
"/> *([^ ]*) *</", //ȥ��עጘ�(bi��o)ӛ
"/[\s]+/",
"/<!--[^!]*-->/",
"/\" /",
"/ \"/",
"'/\*[^*]*\*/'"
);
$replace = array (
">\\1<",
" ",
"",
"\"",
"\"",
""
);
return preg_replace($pattern, $replace, $string);
}

]]>
http://m.dgkai.cn/blog/view-431.html/feed 689
php��ֹˢ�������� http://m.dgkai.cn/blog/view-428.html http://m.dgkai.cn/blog/view-428.html#comments Fri, 29 Mar 2013 10:55:10 +0000 lin http://m.dgkai.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;//��ˢ�•r(sh��)�g
$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://m.dgkai.cn/blog/view-428.html/feed 0
php��S��(sh��)�M������ http://m.dgkai.cn/blog/view-425.html http://m.dgkai.cn/blog/view-425.html#comments Mon, 17 Dec 2012 12:48:04 +0000 lin http://m.dgkai.cn/blog/?p=425 1 php������S��(sh��)�M���Iֵ

����������:

$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 ��ô�M(j��n)�в�������������(g��)�Y(ji��)�������@����(g��)�Y(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)��ȫ�����س��I����(l��i)
$result = array_search_re('bar 3', $foo);

print_r($result);

ݔ���Y(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������S��(sh��)�M���I��

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);

ݔ���Y(ji��)�������£�
?

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

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

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

)

]]>
http://m.dgkai.cn/blog/view-425.html/feed 743
�W(w��ng)վ�����½��r(sh��)�Ƿ����޸��P(gu��n)�I�~�ĕr(sh��)�C(j��) http://m.dgkai.cn/blog/view-422.html http://m.dgkai.cn/blog/view-422.html#comments Tue, 04 Dec 2012 06:34:33 +0000 lin http://m.dgkai.cn/blog/?p=422 ����W(w��ng)վ�������F(xi��n)׃��(d��ng)���ׂ�(g��)����һֱ��(w��n)���ڰٶ�ǰ�����P(gu��n)�I�~���F(xi��n)�½���������ȫ��k����r����(j��ng)�^(gu��)�������l(f��)�F(xi��n)���յ�����朽ӵĠ��B��������(g��)��朾W(w��ng)վ��k����(du��)��朻��ҵ��ǂ�(g��)�P(gu��n)�I�~����ֱ�ӛ](m��i)�С�

������Ҳ��� ��ɽ�W(w��ng)վ���O(sh��)?�@��(g��)�P(gu��n)�I�~�O(sh��)�����P(gu��n)�I�~����ǰ���������~�����������^��(w��n)���������p���޸������������յ�Ӱ푣��@�γô˙C(j��)��(hu��)һ�����������Ч��������(y��n)�Cһ��? �W(w��ng)վ�����½��r(sh��)�Ƿ����޸��P(gu��n)�I�~�ĕr(sh��)�C(j��)��Ҳ�o����վ�L(zh��ng)��һ��(g��)������

]]> http://m.dgkai.cn/blog/view-422.html/feed 310 php�^(gu��)�V�͑��ύ����(sh��)����ע�� http://m.dgkai.cn/blog/view-417.html http://m.dgkai.cn/blog/view-417.html#comments Sat, 24 Nov 2012 09:16:40 +0000 lin http://m.dgkai.cn/blog/?p=417 ���´��a��(sh��)�F(xi��n)�^(gu��)�Vphp��$_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��)�Vjavascript��on�¼�
"/\s+/",//�^(gu��)�V����Ŀհ�
);
$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://m.dgkai.cn/blog/view-417.html/feed 343
phpӋ(j��)����a�\(y��n)�Еr(sh��)�g��ʹ�Ã�(n��i)�� http://m.dgkai.cn/blog/view-415.html http://m.dgkai.cn/blog/view-415.html#comments Wed, 14 Nov 2012 08:28:49 +0000 lin http://m.dgkai.cn/blog/?p=415

<?php

//�_ʼӋ(j��)�r(sh��)


$HeaderTime =
microtime(true);//����(sh��)true��ʾ���ظ��c(di��n)��(sh��)ֵ

//���a

//...

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

total runtime: 1.47 s

memory usage: 77.09 M

]]>
http://m.dgkai.cn/blog/view-415.html/feed 454
select�����ˆΌ�(sh��)�F(xi��n)����朽����D(zhu��n) http://m.dgkai.cn/blog/view-413.html http://m.dgkai.cn/blog/view-413.html#comments Sun, 07 Oct 2012 08:47:40 +0000 lin http://m.dgkai.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>

���ϴ��a��(sh��)�F(xi��n)�x���(xi��ng)���D(zhu��n)��ָ��朽�

]]>
http://m.dgkai.cn/blog/view-413.html/feed 399
mysql STRICT_TRANS_TABLES��(y��n)��ģʽ����ʾField 'id' doesn't have a default value http://m.dgkai.cn/blog/view-411.html http://m.dgkai.cn/blog/view-411.html#comments Wed, 26 Sep 2012 03:42:48 +0000 lin http://m.dgkai.cn/blog/?p=411 �ڄe�ķ���(w��)���\(y��n)���ҵľW(w��ng)վ����ĕr(sh��)�������F(xi��n)��Field 'id' doesn't have a default value ����ʾ����˼���@��(g��)ֵ�қ](m��i)���ύ��(sh��)��(j��)�����Ҕ�(sh��)��(j��)��(k��)�Y(ji��)��(g��u)�](m��i)���O(sh��)��Ĭ�J(r��n)ֵ�����ڌ�(du��)����mysql����(w��)���_����STRICT_TRANS_TABLES��(y��n)��ģʽ�����Ԉ�(b��o)�e(cu��)��

��Q�����ǣ�

����Լ��ķ���(w��)�����Й�(qu��n)���޸�my.ini��Ԓ�����_my.ini������
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

�޸Ğ�

sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

Ȼ���؆�MYSQL

�ڄe�˵�̓�M���g�Ϯ�(d��ng)Ȼ�����܌�(sh��)�F(xi��n)�����Ը����Ľ�Q����߀���޸��Լ��Ĕ�(sh��)��(j��)�Y(ji��)��(g��u)���ѷǿյ��ֶμ���Ĭ�J(r��n)ֵ���Ժ��O(sh��)Ӌ(j��)��(sh��)��(j��)��(k��)Ҫע���@һ�c(di��n)������������ֲ

]]>
http://m.dgkai.cn/blog/view-411.html/feed 431
smartyģ��ʹ��php��(bi��o)������Ϋ@ȡģ��׃�� http://m.dgkai.cn/blog/view-409.html http://m.dgkai.cn/blog/view-409.html#comments Sat, 22 Sep 2012 03:54:23 +0000 lin http://m.dgkai.cn/blog/?p=409 �ѽ�(j��ng)assignһ��(g��)ģ��׃��$assign,����Ҫ�������ѭ�h(hu��n)ݔ����ʹ��forѭ�h(hu��n)�����ʹ�õ���php��(bi��o)��������php�Z(y��)���ģ���Z(y��)���׃���������Dz�ͬ������˲���ֱ�ӫ@ȡ��

{{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}}

��Q�ķ����ǣ�ģ��׃��ȫ������smarty��һ��(g��)��(du��)��������ֻҪ��for֮ǰ�M(j��n)���xֵ��$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://m.dgkai.cn/blog/view-409.html/feed 502