Archive for 3月, 2010

昨天研究了 Google Sitemap Generator  这一由 Google 自身推出的seo工具包。
其不是一个网页脚本或插件。而是一个安装完后即可单独运行的服务。
用于配合 Apache & 其日志更有效地规划站点 Sitemap 地图供 google 以及其他搜索引擎的分析。
现在已经有 For Windows ,Linux,LinuxX64 的版本可供选择。
首页:http://code.google.com/p/googlesitemapgenerator/
下载:http://code.google.com/p/googlesitemapgenerator/downloads/list
以下以 RedHat As5.4 X64  +  Apache 2.2.11 为例,从安装到部署给大家讲解一次。
1,直接从google下载该软件
# wget http://googlesitemapgenerator.googlecode.com/files/sitemap_linux-x86_64-beta1-20091231.tar.gz# tar zxvf sitemap_linux-x86_64-beta1-20091231.tar.gz# cd sitemap-install# ./install.sh
按2下回车,然后阅读协议,按 Y 接受,开始安装向导。
# What is the location of the Apache binary or control script? []输入 apachectl 的路径,这对应你 Apache 安装的路径。例 /usr/local/apache2/bin/apachectl
回车后返回以下检测到的信息:
The following information about [...]

or more than 10 years the SSL protocol has been widely used for the purpose of securing web transactions over the Internet. One can only guess how many millions or billions of dollars in transactions are processed per a day using SSL. Unfortunately, the simple fact we use SSL does not necessarily mean that the [...]

最近在公司一边自学一边写PHP程序,由于公司对程序的运行效率要求很高,而自己又是个新手,一开始就注意程序的效率很重要,这里就结合网上的一些资料,总结下php程序效率优化的一些策略:1.在可以用file_get_contents替代file、fopen、feof、fgets等系列方法的情况下,尽量用file_get_contents,因为他的效率高得多!但是要注意file_get_contents在打开一个URL文件时候的PHP版本问题;(对这于这一点kimi不敢苟同,详细请查阅http://www.ccvita.com/index.php/163.html)2.尽量的少进行文件操作,虽然PHP的文件操作效率也不低的;3.优化Select SQL语句,在可能的情况下尽量少的进行Insert、Update操作(在update上,我被恶批过);4.尽可能的使用PHP内部函数(但是我却为了找个PHP里面不存在的函数,浪费了本可以写出一个自定义函数的时间,经验问题啊!);5.循环内部不要声明变量,尤其是大变量:对象(这好像不只是PHP里面要注意的问题吧?);6.多维数组尽量不要循环嵌套赋值;7.在可以用PHP内部字符串操作函数的情况下,不要用正则表达式;8.foreach效率更高,尽量用foreach代替while和for循环;9.用单引号替代双引号引用字符串;10.“用i+=1代替i=i+1。符合c/c++的习惯,效率还高”;11.对global变量,应该用完就unset()掉

class FtpGet {    private $config;    private $retry = 15;    private $errors = array();        function __construct($config = array()) {        if (empty ( $config )) {            $this->config = array (                 ‘path_local’ => ‘/local/path’,                  ‘path_remote’ => ‘/remote/path’,                  ’server’ => ‘ftp.server.com’,            [...]


以前在找了 MIME 的一些资料,只显示 doc、xls 等 office 2002 之类的格式有 MIME
如 .doc MIME 就设置成 application/msword 就可以了。在网页里面docx 文件是没问题,但是下载下来了之后就变成doc格式了,虽然打开是没问题,但总感觉有点不爽。今天我又搜索了一些。搜到了:
原文网址
.dotx,application/vnd.openxmlformats-officedocument.wordprocessingml.template.docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document.xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.pptx,application/vnd.openxmlformats-officedocument.presentationml.presentation
.doc,application/msword
.dot,application/msword
.xls,application/vnd.ms-excel

文件的大小函数为:filesize()
文件是否存在的函数为:file_exits();
但是这两个函数只针对本地
那么:远程文件是否存在,远程文件大小 如何得知呢?
搜索了一下,有人居然说,把远程文件下载过来再判断这个远程文件的大小,这是什么歪理。
庆幸大部分人还是清醒的,一般应该使用判断header反馈的信息进行判断。
php中如何获得header信息呢? php的函数真多,这个也不例外
1.最简单的获取远程文件大小办法
$a_array = get_headers(url,true);
url就是网址了,至于第二个参数
就可以得到类似下面的这个数组
Array
(
[0] => HTTP/1.1 200 OK
[Date] => Sat, 29 May 2004 12:28:14 GMT
[Server] => Apache/1.3.27 (Unix) (Red-Hat/Linux)
[Last-Modified] => Wed, 08 Jan 2003 23:11:55 GMT
[ETag] => “3f80f-1b6-3e1cb03b”
[Accept-Ranges] => bytes
[Content-Length] => 438
[Connection] => close
[Content-Type] => text/html
)
所以,你可以很舒服的拿到远程文件的大小
$file_sizeofurl = a_array['Content-Length'];
2.用curl获取远程文件大小
如果服务器禁止get_headers 怎么办?
换一种办法,用curl
我总觉得curl就像一个虚拟的用户,什么都能模仿
下面直接给出一个老外的函数
请注意
echo ‘
head–>’.$head.’<—-end
‘;
这句是我加的,为了知道header里面到底包含了什么东西
function remote_filesize($uri,$user=”,$pw=”)
{
// start output buffering
ob_start();
// initialize curl with given uri
$ch = curl_init($uri);
// make sure [...]

分类

 

3月 2010
« 7   4 »
1234567
891011121314
15161718192021
22232425262728
293031  

Blogroll