存档

文章标签 ‘php’

刚改VPS出问题了,现在刚解决好,原来打算多写几篇关于dedeims的文件,无奈现在太晚了,先写一篇 给dedeims添加在线支付的功能之数据库设置 ,页面代码等改天整理好再发。

–为会员添加余额
ALTER TABLE `dede_member` ADD `money` DOUBLE(11,2) Default 0 NOT NULL AFTER `scores`
ALTER TABLE `dede_member` ADD `moneyto` DOUBLE(11,2) Default 0 NOT NULL AFTER `money`

–添加充值记录
–paytype 0:在线充值;1:提现;2:积分兑换
DROP TABLE IF EXISTS `dede_paylog`;
CREATE TABLE IF NOT EXISTS `dede_paylog` (
`id` mediumint(8) NOT NULL auto_increment,
`mid` mediumint(8) NOT NULL,
`paytype` smallint(5) NOT [...]

三 23rd, 2010 | Filed under Experience(经验), PHP, Share(分享)

phpCache,现在更新到了0.11。
2010-1-31 Vesion 0.11
修复了每次读取字符不能超过128KB的限制
去除了nocahce模式存储的文件的功能
增加了读取失败的错误提示符
有需要的朋友请到http://www.catseven.cn/phpCache/下载。

< ?php
/*
CatSeven phpCache Vesion 0.11

======CopyRight======
Home:http://www.catseven.cn/phpCache/
Design:Miao Qiyuan[miaoqiyuan.cn]
*/

class cache404{
public $K,$P,$V;
public function __construct($URI,$P='blog',$Par='./404cache/'){
$this->U = $URI;
$this->K = md5($URI);
$this->P = $P;
$this->Par = $Par;
$this->E = ‘.tmp_miaoqiyuan’;
$this->F = $this->Par . $this->P . ‘/’ . $this->K . $this->E;
$this->V = ‘CatSeven phpCache Error.’;
}
public function getHtml($u){
return file_get_contents($u,NULL,NULL,-1,1000000);
}
public function getCache(){
if(!!($fp=@fopen($this->F,’r'))){
$html=fread($fp,102400);
}else{
if($html=$this->getHtml($this->U)){
$this->addIndex();
$fp=fopen($this->F,’w');
fwrite($fp,$html);
}else{
$html=$this->V;
}
}
if($fp)fclose($fp);
return $html;
}
public function noCache(){
if(!$html=$this->getHtml($this->U))$html=$this->V;
return $html;
}
public function flushCache(){
unlink($this->F);
}
public function addIndex(){
$fpidx=fopen($this->Par . $this->P . ‘.rtf’,'a’);
fwrite($fpidx,$this->K . [...]

二 1st, 2010 | Filed under PHP, Share(分享)
标签: , ,

前几天写过一篇巧用404.php解决Wordpress耗资源的问题,给Wordpress加个缓存功能(http://www.miaoqiyuan.cn/p/wordpress-haoziyuan-wordpress-cache)中提到了PHP缓存的方法,总感觉不是很方便,现在我又写了一个新的。

< ?php
class cache404{
public $K,$P;
public function __construct($URI,$P='blog',$Par='./cache/'){
$this->U = $URI;
$this->K = md5($URI);
$this->P = $P;
$this->Par = $Par;
$this->E = ‘.tmp_miaoqiyuan’;
$this->F = $this->Par . $this->P . ‘/’ . $this->K . $this->E;
}
public function getCache(){
if(!!($fp=@fopen($this->F,’r'))){
$html=fread($fp,102400);
}else{
$html=file_get_contents($this->U);
$this->addIndex();
$fp=fopen($this->F,’w');
fwrite($fp,$html);
}
fclose($fp);
return $html;
}
public function noCache(){
$html=file_get_contents($this->U);
$fp=fopen($this->F,’w');
fwrite($fp,$html);
fclose($fp);
return $html;
}
public function flushCache(){
unlink($this->F);
}
public function addIndex(){
$fpidx=fopen($this->Par . $this->P . ‘.rtf’,'a’);
fwrite($fpidx,$this->K . ‘ ‘ .$this->U);
fclose($fpidx);
}
}
?>

用的时候很简单

require_once(‘./inc/404cache.php’);
$Cache=new cache404($URI,$Path);
#echo $Cache->noCache();
echo $Cache->getCache();

< ?php
require_once('./inc/404cache.php');
$q=explode("/",$URI=substr(($qs = strtolower($_SERVER['QUERY_STRING'])),strpos($qs, ':80')+4));
$URI="/".$URI;
switch($q[0]){
case 'test':
#/test -> /seo_test/test.asp
if(preg_match(‘/^\/test(\/)?$/’,$URI)){
$URI=’http:’.'//’.$_SERVER['SERVER_NAME'].’/seo_test/test.asp’;
}

#/test/[a-z]\.html -> /seo_test/test.asp?key=$1
else [...]

一 22nd, 2010 | Filed under Experience(经验), PHP, Share(分享), Thinks(想法)
标签: , , ,

刚开始搭建博客的时候,看中了wordpress的功能强大,经过两年的不懈努力,我的小博已经从pr0到pr4(最近降到pr3),有的时候每日pv竟然能到3万,这时idc那边就提醒我好资源了。自己购买了台西数的VPS,配置好后,cpu也是居高不下,首页竟然要4秒钟才能打开。当时考虑到seo,路径使用了http://www.miaoqiyuan.cn/p/wordpress-plus-chc(注意,不是文件夹)的模式,生成静态,路径就变了http://www.miaoqiyuan.cn/p/wordpress-plus-chc/。第一,我不想耗资源,第二,我不想改变路径。
我博客的现在的路径是怎样实现的呢?这个问题请看我以前的一篇文章WordPress无Rewrite用cos-html-cache实现静态化(http://www.miaoqiyuan.cn/p/wordpress-plus-chc)。既然一切皆由404.php起,那么现在就从404.php找切入点,比如在404.php上加个缓存。声明:本文由苗启源发表在他的博客,一切思想皆为苗启源原创,转帖请注明出处。
这个换成怎样加呢?改动源程序也不现实,而且文件太多,太麻烦。这时我想到了前几天写的一篇文章Python 之 XML与文本操作(http://www.miaoqiyuan.cn/p/python-xml-file),在那篇文章中,也是使用了缓存,比如请求http://www.miaoqiyuan.cn/products/,因为没有用到数据库,把请求过的网址记录到一个文本文件,少了还好说,多了就。。。最好的办吧就是把每个URL地址返回的内容保存到MD5(URL)的文件中,如果读取的时候该文件存在,说明已经读取过了,有缓存。python源码请见Python 之 XML与文本操作(http://www.miaoqiyuan.cn/p/python-xml-file)。
这样就好办了,直接按以前说的那种方法。404.php返回的请求路径,我没给md5下,如果存在,就直接读取,不存在,执行程序,然后保存到缓存文件中。下面给出404.php的代码,如果觉得本文对您有所帮助,请Ctrl+D收藏我的博客地址,我最近准备写一个php的缓存类哦。

< ?php
$qs = $_SERVER['QUERY_STRING'];
$_SERVER['REQUEST_URI'] = substr($qs, strpos($qs, ':80')+3);
$CacheStr = md5($_SERVER['REQUEST_URI']);

if(!$fp=@fopen("./404cache/".$CacheStr.".tmp","r")){
$getHtml=file_get_contents("http://www.miaoqiyuan.cn/index.php".$_SERVER['REQUEST_URI']);
$fp=fopen("./404cache/".$CacheStr.".tmp","w");
fwrite($fp,$getHtml);
echo $getHtml;
}
echo fread($fp,1100000);
?>

基本功能都实现了。不过更新是个问题,还有缓存数据,我会分别用Mysql数据库,XML文件,文本文件分别存取,关于速率我还要进一步进行测试。文本文件的存储缓存的一个致命的缺点就是最后更新时间,缓存的有效时间不好控制。如果用xml或数据库,这个问题就简单了。好了,现在时间太晚了,就此结笔(键盘)。

一 16th, 2010 | Filed under PHP, Share(分享), Thinks(想法)

      因为是两期完成,所有界面有所不同。

详情页面,可以添加站点信息。修改网站状态,添加客户需求。如果已完成网站,添加完需求,自动保存到修改(验收后),否则保存到修改(开发中)。

添加修改业务详情。

另外,还有一个远程调用接口(API),通过JSON传递信息。PHP写的。

< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<title>猫七导航</title>
<base target="_blank" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style type="text/css">
html{background:#666}
h1{margin:0px;text-align:center;font-size:28px;padding:5px 10px;color:#C00}
h2{margin:0px;font-size:16px;padding:5px 10px;color:#060}
body{width:938px;margin:auto;border:solid 5px #000;background:#EEE;padding:20px;margin-top:10px;}
.dh a{margin:0px 5px;text-decoration:none;font-size:12px;color:#000}
.dh a:hover{text-decoration:underline}
dl{width:300px;height:200px;overflow:hidden;float:left;border:solid 1px #000;margin:5px;}
dt{margin:0px;color:#FFF;background:#060;padding:5px;}
/*录入完毕|制作中|等待客户确认|客户确认|修改(开发中)|修改(验收后)*/
.site_0{background:#0000CC;}
.site_1{background:#CCCC00;}
.site_2{background:#00CCCC;}
.site_3{background:#00CC00;}
.site_4{background:#FF0000;}
.site_5{background:#CC0000;}
.site_all{background:#666666}
dt a{color:#FFF;text-decoration:none;font-weight:800;font-size:18px;}
dd{margin:0px;font-size:12px;color:#000;padding:3px;background:#CCC;height:168px;overflow:auto;}
.ColorBox div{padding:5px;margin:5px;float:left;border:solid 1px #000;font-weight:800}
.ColorBox div a{color:#FFF;text-decoration:none}
</style>
</head><body>
< [...]

十一 11th, 2009 | Filed under PHP, Share(分享), Show(展示)
标签: , , ,

今天在CSDN上看到一篇文章,彻底被雷,分享一下
Jadu: 将 PHP 编译成 .NET
内容管理公司 Jadu 最近发布了一个工具,可以让 PHP 和 .NET 这对冤家和平共处。他们开发了一个叫做 Phalanger PHP compiler 的工具,可以将 PHP 程序编译成本地 .NET 程序执行。他们还准备将这一工具开源。
据 Jadu CEO Suraj Kika 介绍,这个工具对 PHP 程序进行编译,编译成 .NET 框架下下的本地程序。比如,你想用 WordPress,但你属于微软阵营,你可以将 WordPress 编译成可执行文件,放到 .NET 中并在 Visual Studio 中针对这个编译过的 WordPress 做进一步开发。
这个工具将为 PHP 和 .NET 开发工程师带来职业上的便利,避免在各自对方的技术领域内再培训。Kika 表示,我们会看到大量 PHP 开发者在微软阵营找到客户群。
Kika 还表示,开源和商业软件之间向来泾渭分明,这一工具将让这两个阵营的开发者走到一起。
原文:http://www.itnews.com.au/News/90129,jadu-brings-php-and-net-closer-together.aspx
Jadu brings PHP and .NET closer together
Content management firm Jadu [...]

十二 28th, 2008 | Filed under Share(分享)
标签: ,