新增开机启动:
insserv nginx
删除开机启动:
insserv -r nginx
发布时间:December 5, 2013 // 分类:Debian // No Comments
新增开机启动:
insserv nginx
删除开机启动:
insserv -r nginx
发布时间:December 5, 2013 // 分类:Debian // No Comments
使用apt-get安装工具但是又不知道在哪个软件包中用apt-file解决:
apt-get install apt-file
apt-file update
apt-file search /usr/bin/dig
发布时间:December 3, 2013 // 分类:PHP // No Comments
<?php
function arr_foreach ($arr)
{
static $tmp=array();
if (!is_array ($arr))
{
return false;
}
foreach ($arr as $val )
{
if (is_array ($val))
{
arr_foreach ($val);
}
else
{
$tmp[]=$val;
}
}
return $tmp;
}
$a = array(1,2=>array(3,4=>array(5,6)),7);
print_r(arr_foreach($a));
?>
使用for循环,只能遍历数字下标的数组:
<?php
function arr_foreach($arr)
{
static $tmp=array();
for($i=0; $i<count($arr); $i++)
{
if(is_array($arr[$i]))
{
arr_foreach($arr[$i]);
}else{
$tmp[]=$arr[$i];
}
}
return $tmp;
}
$a = array(1,array(3,array(5,6)),7);
print_r(arr_foreach($a));
?>
发布时间:December 3, 2013 // 分类:PHP // No Comments
<?php
function url_base64_encode($string) {
$data = base64_encode($string);
$data = str_replace(array('+','/','='),array('-','_',''),$data);
return $data;
}
function url_base64_decode($string) {
$data = str_replace(array('-','_'),array('+','/'),$string);
$mod4 = strlen($data) % 4;
if ($mod4) {
$data .= substr('====', $mod4);
}
return base64_decode($data);
}
function encrypt($key, $str) {
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128,MCRYPT_MODE_ECB),MCRYPT_DEV_URANDOM);
$str_encrypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_128,$key,$str,MCRYPT_MODE_ECB,$iv);
return trim(url_base64_encode($str_encrypt));
}
function decrypt($key, $str_encrypt) {
$str_encrypt = trim(url_base64_decode($str_encrypt));
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128,MCRYPT_MODE_ECB),MCRYPT_DEV_URANDOM);
$str_decrypt = mcrypt_decrypt(MCRYPT_RIJNDAEL_128,$key,$str_encrypt,MCRYPT_MODE_ECB,$iv);
return trim($str_decrypt);
}
echo encrypt('key','http://www.baidu.com////aaaa/bbbb/ccd//ddd')."\n";
echo decrypt('key','zPsrxzCmqAAvlLwv4E7AlI346XTbaw1hAOoPZhtD3sKw__EIxmWpyHTEp4u2skGM')."\n";
?>
发布时间:December 3, 2013 // 分类:PHP // No Comments
<?php
if (getmxrr("qq.com", $mxhosts, $mxweights)) {
foreach ($mxhosts as $host) {
$hosts[] = dns_get_record($host, DNS_A);
}
}
function getall_by_key(array $arr, $key){
if (!trim($key)) return false;
preg_match_all("/\"$key\";\w{1}:(?:\d+:|)(.*?);/", serialize($arr), $output);
return $output[1];
}
print_r(getall_by_key($hosts, 'ip'));
?>