喜悦国际村 
» 游客:  注册 | 登录 | 搜索 | 统计 | 喜悦证交所 | 帮助

RSS 订阅当前论坛  

上一主题 下一主题
 63  3/7  <  1  2  3  4  5  6  7  > 
     
标题: 最近写的代码 仅做交流用  
 
1314ing
新手上路
Rank: 1



UID 90432
精华 0
积分 19
帖子 15
金钱 19 喜悦币
威望 0
人脉 0
阅读权限 10
注册 2007-3-30
状态 离线
收了

另:+1 喜悦币
2007-6-4 09:17 PM#21
查看资料  Blog  发短消息  顶部
 
rjp_ww
注册会员
Rank: 2
初级会员


UID 67694
精华 0
积分 163
帖子 421
金钱 163 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2006-1-2
状态 离线
[推荐阅读] PHP开发工程师
LZ真厉害,这么多代码,看的我头疼,一定好好研究!
2007-6-5 09:33 AM#22
查看资料  发短消息  顶部
 
oghuz
新手上路
Rank: 1



UID 76944
精华 0
积分 5
帖子 5
金钱 5 喜悦币
威望 0
人脉 0
阅读权限 10
注册 2006-7-24
状态 离线
[推荐阅读] 新建上海php交流群
不错
学习了
2007-6-6 01:13 PM#23
查看资料  发短消息  顶部
 
looking_for1
注册会员
Rank: 2


UID 78393
精华 0
积分 112
帖子 304
金钱 112 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2006-8-15
来自 hubei
状态 离线
[推荐阅读] 北京·WEB2.0公司·招多名PHP程序员
赞赞

LZ,你的那个HTTPRequest怎么这么象ajax方法啊。
开始猜想,php以后能囊括ajax吗




爱我的人们,我一定会爱你们
2007-6-18 10:50 AM#24
查看资料  访问主页  Blog  发短消息  QQ  Yahoo!  顶部
 
ml188
新手上路
Rank: 1



UID 94336
精华 0
积分 11
帖子 5
金钱 11 喜悦币
威望 0
人脉 0
阅读权限 10
注册 2007-6-22
状态 离线
[推荐阅读] 同一类商品的进仓和出仓后的总和怎么计算?
ding..............



http://www.ml188.com
2007-6-27 05:20 PM#25
查看资料  发短消息  顶部
 
szphper
新手上路
Rank: 1



UID 94778
精华 0
积分 12
帖子 8
金钱 12 喜悦币
威望 0
人脉 0
阅读权限 10
注册 2007-7-2
状态 离线
[推荐阅读] 请教ADODB和SMARTY的问题
rfc http1.1
2007-7-4 10:26 AM#26
查看资料  发短消息  顶部
 
sanders_yao
版主
Rank: 7Rank: 7Rank: 7
or2 =333


UID 30286
精华 0
积分 2501
帖子 4654
金钱 2498 喜悦币
威望 0
人脉 3
阅读权限 100
注册 2004-7-23
来自 北京 菜户营
状态 离线
[推荐阅读] 根据条件,二级联动菜单怎么做(有数据库结构)
回复 #25 looking_for1 的帖子 & 回复 #27 szphper 的帖子

还没有js的那个xmlHttpRequest对象那么强
不过都是发请求 只不过一个从客户端发 一个从服务器端发

rfc 我还没有仔细研究过 唯一仔细读了的rfc文档是http://www.faqs.org/rfcs/rfc1867.html 这篇 用来模拟上传文件的




最近写的一些代码都会在以下地址发布,有兴趣的来批:
http://www.phpx.com/happy/thread-131368-1-1.html
2007-7-6 05:23 PM#27
查看资料  Blog  发短消息  顶部
 
sanders_yao
版主
Rank: 7Rank: 7Rank: 7
or2 =333


UID 30286
精华 0
积分 2501
帖子 4654
金钱 2498 喜悦币
威望 0
人脉 3
阅读权限 100
注册 2004-7-23
来自 北京 菜户营
状态 离线
[推荐阅读] 寻找上海高速稳定的PHP空间.
今天刚完成的一个缓存类型

今天刚完成的一个缓存类型
这个类型来自自己的类型库计划:oomph(性感)
正在写的一个个人项目叫:C-CUP CMS(C罩杯CMS)目的是在实际应用中检测并充实oomph库中的各个代码

[php]
<?php
/*=============================================
#        类型名称                        : 缓存类型
#        作者                                : Sanders Yao
#        文件名                        : cache.php
#        作用                                : 缓存数据
#        最后修改时间                : 2007-7-6
#        @itsDir                        : 缓存数据所在绝对路径
#        @itsList                : 缓冲列表
#        @itsConfig                : 配置数据
=============================================*/
define("CACHE_CONFIG_FILE", "config");        //配置文件的文件名
define("CACHE_DEFAULT_PERFIX", "c_");        //数据文件的前缀(需要有别于配置文件的文件名的前几个字符)

class CCupCache{
        var $itsDir;
        var $itsList;
        var $itsConfig;
       
        /*=============================================
        #        作用                : 构造函数
        #        @dir        : 缓存文件所在目录
        =============================================*/
        function CCupCache($dir = ""){
                $this->itsDir                = $dir;
                $this->itsList                = array();
                $this->itsConfig        = array();
                $this->ini();
        }
       
        /*=============================================
        #        作用                : 初始化缓存(如果存在config.php文件 则加载缓存配置数据)
        #        return        : 执行结果
        =============================================*/
        function ini(){
                if(!is_dir($this->itsDir)){
                        return false;
                }
                $this->itsDir = false !== strpos($this->itsDir, "./") ? str_replace("\\", "/", realpath($this->itsDir)) : $this->itsDir;
                if(is_file($this->itsDir . "/" . CACHE_CONFIG_FILE . ".php")){
                        $this->itsConfig        = $this->get(CACHE_CONFIG_FILE, "");
                }
                return true;
        }
       
        /*=============================================
        #        作用                : 获取缓存数据
        #        @key        : 缓存的键值
        #        @perfix        : 缓存前缀(默认CACHE_DEFAULT_PERFIX)
        #        return        : 缓存数据或false
        =============================================*/
        function & get($key, $perfix = CACHE_DEFAULT_PERFIX){
                if(isset($this->itsList[$perfix . $key]) && NULL != $this->itsList[$perfix . $key]){
                }elseif(is_file($this->itsDir . "/" . $perfix . $key . ".php")){
                        include($this->itsDir . "/" . $perfix . $key . ".php");
                        $this->itsList[$perfix . $key] = $cacheValue;
                }else{
                        $this->itsList[$perfix . $key] = NULL;
                }
                return $this->itsList[$perfix . $key];
        }
       
        /*=============================================
        #        作用                        : 设定缓存数据
        #        @key                : 缓存的键值
        #        @value                : 缓存的变量值
        #        @perfix                : 缓存前缀(默CACHE_DEFAULT_PERFIX)
        #        @config                : 设定数据(一个关联数组 键值为"ttl", "rebuild", "priority", "last", "description"中的一个或多个)
        #        @is_config        : 当前数据是否是当前缓存的配置数据
        #        return                : 执行结果
        #        Attention!!        : @is_config为false的情况下@perfix.@key不能等于 CACHE_CONFIG_FILE!!
        =============================================*/
        function set($key, $value, $perfix = CACHE_DEFAULT_PERFIX, $config = NULL, $is_config = false){
                if(CACHE_CONFIG_FILE == $perfix . $key && !$is_config){
                        return false;
                }elseif($is_config){
                        $key        = CACHE_CONFIG_FILE;
                        $value        = $this->itsConfig;
                        $perfix        = "";
                        $config        = NULL;
                }
                $filePath = $this->itsDir . "/" . $perfix . $key . ".php";
                if(false !== $fp = fopen($filePath, "w")){
                        $content = "<?php\n\$cacheValue = " . var_export($value, true) . "\n?>";
                        flock($fp, LOCK_EX);
                        fwrite($fp, $content, strlen($content));
                        fclose($fp);
                        $this->itsList[$perfix . $key] = $value;
                        if(NULL != $config){
                                $ttl                        = isset($config["ttl"])                        ? $config["ttl"]                        : NULL;
                                $rebuild                = isset($config["rebuild"])                ? $config["rebuild"]                : NULL;
                                $priority                = isset($config["priority"])        ? $config["priority"]                : NULL;
                                $last                        = isset($config["last"])                ? $config["last"]                        : NULL;
                                $description        = isset($config["description"])        ? $config["description"]        : NULL;
                                $this->setConfig($key, $perfix, $ttl, $rebuild, $priority, $last, $description);
                        }
                        return true;
                }
                return false;
        }
       
        /*=============================================
        #        作用                : 查询缓存设定
        #        @key        : 缓存的键值
        #        @perfix        : 缓存前缀(默认CACHE_DEFAULT_PERFIX)
        #        @fuzzy        : 模糊查询开关
        #        return        : 查询结果
        =============================================*/
        function getConfig($key = NULL, $perfix = CACHE_DEFAULT_PERFIX, $fuzzy = false){
                $config = array();
                if(NULL == $key){
                        $config = $this->itsConfig;
                }elseif($fuzzy){
                        foreach($this->itsConfig as $k => $c){
                                if(false !== strpos($c["name"], $key)){
                                        $config[] = $c;
                                }
                        }
                }elseif(isset($this->itsConfig[$perfix . $key])){
                        $config[] = $this->itsConfig[$perfix . $key];
                }
                return $config;
        }
       
        /*=============================================
        #        作用                        : 设定缓存设置
        #        @key                : 缓存的键值
        #        @perfix                : 缓存前缀(默认CACHE_DEFAULT_PERFIX)
        #        @ttl                : 更新周期
        #        @rebuild        : 重建缓存脚本文件地址
        #        @priority        : 更新优先级
        #        @last                : 上次更新结束的时间(时间戳)
        #        @description: 说明文本
        =============================================*/
        function setConfig($key, $perfix = CACHE_DEFAULT_PERFIX, $ttl = NULL, $priority = NULL, $rebuild = NULL, $last = NULL, $description = NULL){
                $this->itsConfig[$perfix . $key] = isset($this->itsConfig[$perfix . $key]) ? $this->itsConfig[$perfix . $key] : array();
                $this->itsConfig[$perfix . $key]["name"]                        = $key;
                if(NULL === $last && !isset($this->itsConfig[$perfix . $key]["last"])){
                        $this->itsConfig[$perfix . $key]["last"]                = time();
                }elseif(NULL !== $last){
                        $this->itsConfig[$perfix . $key]["last"]                = $last;
                }
                if(NULL === $priority && !isset($this->itsConfig[$perfix . $key]["priority"])){
                        $this->itsConfig[$perfix . $key]["priority"]        = count($this->itsConfig[$perfix . $key]);
                }elseif(NULL !== $priority){
                        $this->itsConfig[$perfix . $key]["priority"]        = $priority;
                }
                if(NULL === $description && !isset($this->itsConfig[$perfix . $key]["description"])){
                        $this->itsConfig[$perfix . $key]["description"]        = "";
                }elseif(NULL !== $description){
                        $this->itsConfig[$perfix . $key]["description"]        = $description;
                }
                $this->itsConfig[$perfix . $key]["ttl"]                                = intval($ttl);
                $this->itsConfig[$perfix . $key]["rebuild"]                        = is_file($rebuild) ? str_replace("\\", "/", realpath($rebuild)) : NULL;
        }
       
        /*=============================================
        #        作用                : 保存缓存设置
        #        return        : 执行结果
        =============================================*/
        function saveConfig(){
                return $this->set(NULL, NULL, NULL, NULL, true);
        }
       
        /*=============================================
        #        作用                : 根据配置数据更新缓存
        #        return        : 更新缓存的数量
        =============================================*/
        function update(){
                $updateStatus = 0;
                uasort($this->itsConfig, "cachePriority");
                foreach($this->itsConfig as $k => $c){
                        if($c["last"] + $c["ttl"] <= time() && is_file($this->itsDir . "/" . $k . ".php")){
                                list($usec, $sec) = explode(" ", microtime());
                                $startTime = (float)$usec + (float)$sec;
                               
                                unlink($this->itsDir . "/" . $k . ".php");
                                if(isset($c["rebuild"]) && is_file($c["rebuild"])){
                                        extract($GLOBALS);
                                        include($c["rebuild"]);
                                }
                               
                                list($usec, $sec) = explode(" ", microtime());
                                $endTime = (float)$usec + (float)$sec;
                                $this->itsConfig[$k]["last"] = time();
                                $this->itsConfig[$k]["runtime"] = $endTime - $startTime;
                                $updateStatus ++;
                        }
                }
                if($updateStatus){
                        $this->saveConfig();
                }
                return $updateStatus;
        }
       
        /*=============================================
        #        作用                : 删除单个缓存
        #        return        : 执行结果
        =============================================*/
        function delete($key, $perfix = CACHE_DEFAULT_PERFIX){
                if(!is_file($this->itsDir . "/" . $perfix . $key . ".php")){
                        return false;
                }
                unlink($this->itsDir . "/" . $perfix . $key . ".php");
                if(isset($this->itsConfig[$perfix . $key])){
                        $this->itsConfig[$perfix . $key]["last"] = time();
                }
                return true;
        }
       
        /*=============================================
        #        作用                : 删除单个缓存
        #        return        : 执行结果
        =============================================*/
        function distroy($key, $perfix = CACHE_DEFAULT_PERFIX){
                if(!is_file($this->itsDir . "/" . $perfix . $key . ".php")){
                        return false;
                }
                unlink($this->itsDir . "/" . $perfix . $key . ".php");
                if(isset($this->itsConfig[$perfix . $key])){
                        unset($this->itsConfig[$perfix . $key]);
                }
                return true;
        }
}

/*=============================================
#        作用                        : 缓存优先级排序的回调函数
#        @a                        : 配置数据a
#        @b                        : 配置数据b
#        return                : 比较结果
=============================================*/
function cachePriority($a, $b){
        if ($a["priority"] == $b["priority"]) {
        return 0;
    }
    return ($a["priority"] < $b["priority"]) ? -1 : 1;
}


/*=============================================
#        测试一                : 存取变量        (*check*)\(^_^)/
=============================================*/
/*$data        = array(1,2,3,"array"=>array("a"=>1,"b"=>2,"c"=>3));
$hahah        = array("hahah","hehehe","Ohohohoho");
$cache        = new CCupCache("../data/cache");
$cache->set("data", $data);
print_r($cache->get("data"));
$cache->set("xixixi", $hahah);
print_r($cache->get("xixixi"));*/

/*=============================================
#        测试二                : 删除单个缓存                (*check*)\(^_^)/
=============================================*/
/*$cache        = new CCupCache("../data/cache");
$cache->delete("xixixi");
print_r($cache->get("xixixi"));*/

/*=============================================
#        测试三                : 配置并保存缓存配置文件        (*check*)\(^_^)/
=============================================*/
/*$hahah        = array("hahah","hehehe","Ohohohoho");
$cache        = new CCupCache("../data/cache");
$config        = array("ttl"=>10);
$cache->set("xixixi", $hahah, "c_", $config);
$cache->saveConfig();*/

/*=============================================
#        测试四                : 查询缓存配置文件                (*check*)\(^_^)/
=============================================*/
/*$cache        = new CCupCache("../data/cache");
print_r($cache->getConfig());
print_r($cache->getConfig("xixixi"));
print_r($cache->getConfig("xixixi", "a_"));
print_r($cache->getConfig("xixixi", "c_"));
print_r($cache->getConfig("xi", "", true));
print_r($cache->getConfig("ha", "", true));*/

/*=============================================
#        测试五                : 自动更新缓存                (*check*)\(^_^)/
=============================================*/
/*$cache        = new CCupCache("../data/cache");
sleep(10);
$cache->update();
$conf = $cache->getConfig();
echo "time:" .date("H:i:s", $conf["c_xixixi"]["last"]);*/
?>
[/php]

和以前一样由于村里的php标签吃斜杠,我把文件上传一下

[[i] 本帖最后由 sanders_yao 于 2007-7-6 05:33 PM 编辑 [/i]]


 附件: 您所在的用户组无法下载或查看附件



最近写的一些代码都会在以下地址发布,有兴趣的来批:
http://www.phpx.com/happy/thread-131368-1-1.html
2007-7-6 05:32 PM#28
查看资料  Blog  发短消息  顶部
 
jonyare
中级会员
Rank: 3Rank: 3


UID 92705
精华 0
积分 406
帖子 365
金钱 406 喜悦币
威望 0
人脉 0
阅读权限 30
注册 2007-5-8
来自 清华王牌计算机系
状态 离线
[推荐阅读] 一个function的问题
楼主强人啊

不知道练了多少年的功了,高深我不能测



务以善小而为之,务以恶小而不为村
2007-7-8 08:40 AM#29
查看资料  Blog  发短消息  顶部
 
浪漫谎言
新手上路
Rank: 1


UID 94748
精华 0
积分 36
帖子 32
金钱 28 喜悦币
威望 0
人脉 8
阅读权限 10
注册 2007-7-1
来自 北京
状态 离线
[推荐阅读] sougou.com 诚招中级PHP程序员(北京)
学习了~~~收下



各类源码、中(英)文帮助手册下载!
2007-7-9 08:45 AM#30
查看资料  访问主页  Blog  发短消息  顶部
 63  3/7  <  1  2  3  4  5  6  7  > 
     


  可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题 | 开通个人空间  


 


Powered by Discuz! 6.1.0  © 2001-2010 Comsenz Inc.
Processed in 0.024123 second(s), 6 queries

(冀ICP备05009913号) 管理员:sadly 邮箱/MSN: sadly@phpx.com QQ:824008(长隐) 清除 Cookies - - Archiver - WAP