$today = date('Y-m-d-G');
$today = strftime("%Y-%m-%d-%H", strtotime("$today -5 hour"));
Author Archives: Tim
php调整服务器时间
Posted by Tim
on May 20, 2012
No comments
php获取图片信息
Posted by Tim
on May 5, 2012
No comments
/*
* @param string $file Filepath
* @param string $query Needed information (0 = width, 1 = height, 2 = mime-type)
* @return string Fileinfo
*/
function getImageinfo($file, $query) {
if(!realpath($file)) {
$file = $_SERVER["DOCUMENT_ROOT"].$file;
}
$image = getimagesize($file);
return $image[$query];
}
shell脚本检测一个文件是否为空
Posted by Tim
on April 28, 2012
No comments
php检测文件大小
Posted by Tim
on April 21, 2012
No comments
/*
* @param string $file Filepath
* @param int $digits Digits to display
* @return string|bool Size (KB, MB, GB, TB) or boolean
*/
function getFilesize($file, $digits = 2) {
if(is_file($file)) {
$filePath = $file;
if(!realpath($filePath)) {
$filePath = $_SERVER["DOCUMENT_ROOT"].$filePath;
}
$fileSize = filesize($filePath);
$sizes = array("TB", "GB", "MB", "KB", "B");
$total = count($sizes);
while($total-- && $fileSize > 1024) {
$fileSize /= 1024;
}
return round($fileSize, $digits)." ".$sizes[$total];
}
return false;
}
shell脚本检测一个文件是否存在
Posted by Tim
on April 14, 2012
No comments
php验证邮箱地址是否有效
Posted by Tim
on April 7, 2012
No comments
<?php
$email="test@example.com";
if(isValidEmail($email))
{
echo "Email address is valid.";
}
else
{
echo "Email address is not valid";
}
// Check-Function
function isValidEmail($email)
{
//Perform a basic syntax-check
//If this check fails, there's no need to continue
if(!filter_var($email, FILTER_VALIDATE_EMAIL))
{
return false;
}
//extract host
list($user, $host) = explode("@", $email);
//check, if host is accessible
if(!checkdnsrr($host, "MX") && !checkdnsrr($host, "A"))
{
return false;
}
return true;
}
?>
shell脚本重启apache
Posted by Tim
on March 31, 2012
No comments
shell脚本修改文件名为小写
Posted by Tim
on March 25, 2012
No comments
php获取ip地址
Posted by Tim
on March 17, 2012
2 comments
Recent Comments