mb_substr修正函数

不支持mb_substr函数的环境中使用了mb_substr函数会出现“Fatal error: Call to undefined function mb_substr()”的提示,下面的函数是定义的替代mb_substr的函数,作用是一样的,用于不支持mb_substr的地方。

// Patch in multibyte support
if (!function_exists('mb_substr')) {
    function mb_substr($str, $start, $len = '', $encoding="UTF-8"){
        $limit = strlen($str);

        for ($s = 0; $start > 0;--$start) {// found the real start
            if ($s >= $limit)
                break;

            if ($str[$s] <= "\x7F")
                ++$s;
            else {
                ++$s; // skip length

                while ($str[$s] >= "\x80" && $str[$s] <= "\xBF")
                    ++$s;
            }
        }

        if ($len == '')
            return substr($str, $s);
        else
            for ($e = $s; $len > 0; --$len) {//found the real end
                if ($e >= $limit)
                    break;

                if ($str[$e] <= "\x7F")
                    ++$e;
                else {
                    ++$e;//skip length

                    while ($str[$e] >= "\x80" && $str[$e] <= "\xBF" && $e < $limit)
                        ++$e;
                }
            }

        return substr($str, $s, $e - $s);
    }
}

eAccelerator-0.9.6安装笔记

cd tmp
wget http://bart.eaccelerator.net/source/0.9.6/eaccelerator-0.9.6.tar.bz2
tar -jxvf eaccelerator-0.9.6.tar.bz2
cd eaccelerator-0.9.6
/usr/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/bin/php-config
make
make install

(注:以上文中“phpize”以及“php-config”的路径如果不知道可以使用find命令事先查找一下。)
安装完毕编辑php.ini将其安装为 PHP extension 模式
在php.ini中添加如下:

extension="eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.log_file = "/var/log/httpd/eaccelerator_log"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

最后创建/tmp/eaccelerator目录

mkdir /tmp/eaccelerator
chmod 0777 /tmp/eaccelerator

91kds.com

免费电影电视剧在线观看

http://www.91kds.com

欢迎多多捧场 :grin: 

SEO WordPress

WordPress 在撰写日志的时候,可以给日志添加摘要(excerpt)和标签(tag),我的做法就是,就如给日志添加了摘要就把摘要做为 Description,如果没有设置摘要的话,则截取文章的前 220 个字作为 Description,而标签直接作为 Keywords。代码如下:

<?if (is_home()){
     $description = "默认desc";
     $keywords = "默认keywords";
 } elseif (is_single()){
     if ($post->post_excerpt) {
         $description     = $post->post_excerpt;
     } else {
         $description = substr(strip_tags($post->post_content),0,220);
     }       $keywords = "";
            $tags = wp_get_post_tags($post->ID);
     foreach ($tags as $tag ) {
         $keywords = $keywords . $tag->name . ", ";
     } } ?>
 <meta name="keywords" content="<?=$keywords?>" />
 <meta name="description" content="<?=$description?>" />

上面代码请放到 header.php 相应的位置

the nearest works,keep

e文垃圾站by HBcms 待测 火车头
ent垃圾站by wordpress,2栏960px themes,暂定aokhost测试,类似yzm、F.B.I
stock,QQ by Google AdWords 暂定费用$20/day
TV站 程序初定马克斯or dedecms
ad from perfspot

我看看我到底有多拖拉
4-7-2008

Page 1 of 612345»...Last »