EZBOY的工作日誌
PHP,MySQL,APACHE,JQUERY,AJAX,UBUNTU
2011-01-20
ubuntu查閱主機記錄
查閱想非法入侵的記錄(被拒)
more /var/log/auth.log |grep "refused"
查閱主機連線的記錄(允許)
more /var/log/auth.log |grep "Accepted"
當然您的主機在/etc/hosts.allow ,與/etc/hosts.deny
要事先設定好連線範圍
http://free.chc.edu.tw/~chi/blog/index.php?load=read&id=36
php連接mssql2005
<?php
$serverName = "127.0.0.1";
$connectionInfo = array("Database"=>"TestDB","UID"=>"test","PWD"=>"test");
$conn = sqlsrv_connect($serverName, $connectionInfo);
if($conn) {
echo "Connection established.<br>";
} else {
echo "Connection could not be established.<br>";
die(print_r(sqlsrv_errors(), true));
exit();
}
$sql = "select * from T_Employee";
$result = sqlsrv_query($conn,$sql);
$data = array();
while($row=sqlsrv_fetch_array($result)) {
$data[] = $row;
}
foreach($data as $p) {
echo $p['Name']."<br>";
}
sqlsrv_close($conn);
echo "<br> Done <br>";
echo date("Y-m-d h:i:s");
?>
php自動產生隨機密碼
该算法主要用到了两个函数,
mt_rand ( int $min , int $max )
函数用于生成随机整数,其中 $min – $max 为 ASCII 码的范围,这里取 33 -126 ,可以根据需要调整范围,如ASCII码表中 97 – 122 位对应 a – z 的英文字母,具体可参考
ASCII码表
;
chr ( int $ascii )
函数用于将对应整数 $ascii 转换成对应的字符
function create_password($pw_length = 8)
{
$randpwd = '';
for ($i = 0; $i < $pw_length; $i++)
{
$randpwd .= chr(mt_rand(33, 126));
}
return $randpwd;
}
// 调用该函数,传递长度参数$pw_length = 6
echo create_password(6);
php防止sql注入函数-discuz版本
$magic_quotes_gpc = get_magic_quotes_gpc();
@extract(daddslashes($_COOKIE));
@extract(daddslashes($_POST));
@extract(daddslashes($_GET));
if(!$magic_quotes_gpc) {
$_FILES = daddslashes($_FILES);
}
function daddslashes($string, $force = 0) {
if(!$GLOBALS['magic_quotes_gpc'] || $force) {
if(is_array($string)) {
foreach($string as $key => $val) {
$string[$key] = daddslashes($val, $force);
}
} else {
$string = addslashes($string);
}
}
return $string;
}
2011-01-19
JS判斷IE瀏覽器最簡短方法
<script type=
'text/javascript'
>
// Option from Dean Edwards:
var
ie =
/*@cc_on!@*/
false
;
// Use the commented line:
var
ie
//@cc_on=1;
// Variation (shorter variable):
var
ie =
'\v'
==
'v'
;
/ / Option to Gareth Hayes (former record-holder):
var
ie = !+
"\v1"
;
</script>
較新的文章
較舊的文章
首頁