Dec 12 2008

Smarty生成静态页面

Published by Jone under PHP

记录一个,Smarty是很聪明的

ob_start();//开启缓冲区
$smarty->assign(“a”,$a);
$smarty->display(”temp.html”);
$html_content= ob_get_contents(); //读取缓冲区的数据
ob_end_clean();//关闭缓冲区

$htm_content里头的东西就是想要的东西了,将它写入页面就可以了。

comments(0)

Oct 5 2008

phpMyAdmin 3.0的安装配置

Published by Jone under PHP

郁闷,我不会用phpMyAdmin自带的那个setup步骤配置,一直都是直接通过改config.ini.php来配置的

过程如下:

1.从phpMyAdmin/libraries/下拷贝config.default.php到phpMyAdmin下,并改名为config.ini.php

2.用editplus或其它编辑器打开phpMyAdmin/config.ini.php,修改:

$cfg['PmaAbsoluteUri'] = 'http://127.0.0.1/phpMyAdmin';//phpMyAdmin的安装路径
$cfg['blowfish_secret'] = 'hejone';//加密密匙,可随意更改。
$cfg['Servers'][$i]['host'] = 'localhost'; // MySQL的主机名称或者IP地址
$cfg['Servers'][$i]['port'] = '3306′; // MySQL端口 - 空白将用默认端口3306
$cfg['Servers'][$i]['auth_type'] = 'cookie'; // 认证方式 (config, http or cookie based)?
$cfg['Servers'][$i]['user'] = 'root'; // MySQL用户,如 root
$cfg['Servers'][$i]['password'] = 'pswd'; // MySQL用户密码

3:保存

搞定 !

 

comments(0)

Aug 24 2008

Enabling URL Rewrite for PhpLD 3.3.0

Published by Jone under PHP

Nginx :
Here's my configure in nginx.conf:

if (!-e $request_filename) {
        rewrite ^/latest-links/.htm[l]?$ /index.php?list=latest last;
                rewrite ^/top-hits/.htm[l]?$ /index.php?list=top last;
                rewrite ^/latest-articles/.htm[l]?$ /index.php?list=latestarticles last;
        rewrite ^/(.*)detail/link-(.*)\.htm[l]?$ /detail.php last;
        rewrite ^/(.*)articles/article-(.*)/.htm[l]?$ /article.php last;
        rewrite ^/(.*)authors/author-(.*)\.htm[l]?$ /author.php last;
        rewrite ^/(.*)page-[0-9]+\.html$  /index.php last;
        rewrite ^/(.+)\.html$ /page.php?name=$1 last;
        rewrite ^/(.*)$ /index.php last;
 }

Apache:
Here’s my modified .htaccess file:

#################################################
##           Apache Server Settings            ##
#################################################

# Prevent .htaccess and .htpasswd files from being viewed by web clients
<Files "^\.ht">
    Order allow,deny
    Deny from all
</Files>

# Protect files
<Files ~ "^(.*)\.(inc|inc\.php|tpl|sql)$">
  Order deny,allow
  Deny from all
</Files>

# Protect directories
<Files ~ "^(backup|files|images|include|lang|libs(/.+)?|temp(/.+)?|templates(/.+)?|javascripts(/.+)?)$">
  Order deny,allow
  Deny from all
</Files>

# Disable directory browsing
Options -Indexes

# Follow symbolic links in this directory
Options +FollowSymLinks

# Override PHP settings that cannot be changed at runtime
# (If your server supports PHP settings via htaccess you can comment following two lines off)
# php_value register_globals   0
# php_value session.auto_start 0

# Customized error messages
# ( If you are running in a subfolder please add it, example: "directory/index.php?httpstatus=404" )
ErrorDocument 404 index.php?httpstatus=404

# Set the default handler
DirectoryIndex index.php

# URL rewrite rules
<IfModule mod_rewrite.c>
   RewriteEngine On


   #Make sure RewriteBase points to the directory where you installed phpLD.
   #Example: "/phpld" if your installation is in a "phpld" subdirectory.

   #RewriteBase /

   ##Latest Links Rewrite
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-l
   RewriteRule ^latest-links\.htm[l]?$ index.php?list=latest [QSA,NC,L]

   ##Top Hits Rewrite
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-l
   RewriteRule ^top-hits\.htm[l]?$ index.php?list=top [QSA,NC,L]

   ##Latest Articles Rewrite
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-l
   RewriteRule ^latest-articles\.htm[l]?$ index.php?list=latestarticles [QSA,NC,L]

   ##Details Link Page Rewrite
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-l
   RewriteRule (.*)detail/link-(.*)\.htm[l]?$ detail.php [QSA,NC]

   ##Article Page Rewrite
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-l
   RewriteRule (.*)articles/article-(.*)\.htm[l]?$ article.php [QSA,NC]

   ##Author Page Rewrite
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-l
   RewriteRule (.*)authors/author-(.*)\.htm[l]?$ author.php [QSA,NC]

   ##Pagination Rewrite
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-l
   RewriteRule (.*)page-[0-9]+\.html$  index.php [QSA,NC,L]

##Pages redirect
   RewriteCond %{REQUEST_URI} !page-[0-9]+\.html?$
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-l
   RewriteRule ^(.+)\.html$ page.php?name=$1 [NC,QSA,L]

   ##Category redirect
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-l
   RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

comments(0)