Thank you for coming Limxyz'Blog.
limxyz→趋近未知
lim:数学术语,无限趋近 xyz:通常表示未知数
趋近未知?是无知,还是博识?!
limxyz→趋近未知
lim:数学术语,无限趋近 xyz:通常表示未知数
趋近未知?是无知,还是博识?!
seo之CSS代码优化[观念篇]
[
2009/05/14 03:17 | by limxyz ]
2009/05/14 03:17 | by limxyz ]
要开始做切片了,公司的网页设计师问我针对seo方面代码有没什么特殊要求,我思考了很久,最后还是决定做一下“分外事”,虽然说是分外事有点不负责任,但我一向做事的原则是,把分内事做到极致,对分外事只看不碰.
这个处事原则我沿用了很久,有时候也觉得不妥偶尔似乎多管了一点“闲事”,但这次一心想着项目成功,就不理哪么多,还有一个理由是:友情协助,想到这点,于是书写如下:
这个处事原则我沿用了很久,有时候也觉得不妥偶尔似乎多管了一点“闲事”,但这次一心想着项目成功,就不理哪么多,还有一个理由是:友情协助,想到这点,于是书写如下:
Mysql 错误代码 释意
[
2007/12/11 03:09 | by limxyz ]
2007/12/11 03:09 | by limxyz ]
最近在做站,数据库用Mysql 于是有了这篇...
如何用PHP实现下载
[
2007/12/05 01:18 | by limxyz ]
2007/12/05 01:18 | by limxyz ]
下面这段程序是我从我一个系统里摘出来的,可以实现重命名下载文件(包括中文名)。
其中 $attachment 是附件相关信息的一个关联数组。ABSPATH 是系统路径,UPLOAD_DIR 是上传目录的路径(这里就是从上传目录取文件,然后提供给用户下载,而上传目录本身是没有读权限的,这样就可以保证用户无法直接下载到没有权限访问的文件了),这两个常量都是自己定义的,不是系统的。
引用
function is_ie() {
$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
if ((strpos($useragent, 'opera') !== false) ||
(strpos($useragent, 'konqueror') !== false)) return false;
if (strpos($useragent, 'msie ') !== false) return true;
return false;
}
function download($attachment) {
$realpath = ABSPATH . UPLOAD_DIR . '/' . $attachment['path'] . '/' . $attachment['savename'];
$content_len = sprintf("%u", filesize($realpath));
if (is_ie()) {
// leave $filename alone so it can be accessed via the hook below as expected.
$filename = rawurlencode($attachment['filename']);
}
else {
$filename = &$attachment['filename'];
}
while(ob_get_length() !== false) @ob_end_clean();
header('Pragma: public');
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: pre-check=0, post-check=0, max-age=0');
header('Content-Transfer-Encoding: binary');
header('Content-Encoding: none');
header('Content-type: ' . $attachment['type']);
header('Content-Disposition: attachment; filename="' . $filename . '"');
header("Content-length: $content_len");
echo file_get_contents($realpath);
exit();
}
$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
if ((strpos($useragent, 'opera') !== false) ||
(strpos($useragent, 'konqueror') !== false)) return false;
if (strpos($useragent, 'msie ') !== false) return true;
return false;
}
function download($attachment) {
$realpath = ABSPATH . UPLOAD_DIR . '/' . $attachment['path'] . '/' . $attachment['savename'];
$content_len = sprintf("%u", filesize($realpath));
if (is_ie()) {
// leave $filename alone so it can be accessed via the hook below as expected.
$filename = rawurlencode($attachment['filename']);
}
else {
$filename = &$attachment['filename'];
}
while(ob_get_length() !== false) @ob_end_clean();
header('Pragma: public');
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: pre-check=0, post-check=0, max-age=0');
header('Content-Transfer-Encoding: binary');
header('Content-Encoding: none');
header('Content-type: ' . $attachment['type']);
header('Content-Disposition: attachment; filename="' . $filename . '"');
header("Content-length: $content_len");
echo file_get_contents($realpath);
exit();
}
其中 $attachment 是附件相关信息的一个关联数组。ABSPATH 是系统路径,UPLOAD_DIR 是上传目录的路径(这里就是从上传目录取文件,然后提供给用户下载,而上传目录本身是没有读权限的,这样就可以保证用户无法直接下载到没有权限访问的文件了),这两个常量都是自己定义的,不是系统的。



