Dragonfly CMS logo Server sponsored and hosted by
DedicatedNOW
CVS logo  
.:: Home :: Dev. Resources :: Forums ::.
Dragonfly CMS CVS Repository
 Location: / cvs / html / includes / classes / cpg_cache.php
This is a web interface to the Dragonfly CMS CVS tree. You can browse the file hierarchy by picking directories. If you pick a file, you will see the revision history for that file.
Selecting a revision number will show that revision of the file. There are links at each revision to display diffs, annotate and download.
Note: Info about CVS and our commits can be found at our CVS Info Forum
File name: html/includes/classes/cpg_cache.php
Revision : 10.0 (3 years 5 months 1 weeks 4 days 7 hours 7 minutes 24 seconds ago) by djmaze
Changed : +2 -2 lines
Comment: Upgraded main revision number


# Author Rev Line
1 djmaze 1.1 <?php
2 djmaze 1.1 /*********************************************
3 djmaze 9.5 CPG Dragonfly™ CMS
4 djmaze 1.1 ********************************************
5 nanocaio 9.12 Copyright © 2004 - 2007 by CPG-Nuke Dev Team
6 djmaze 9.9 http://dragonflycms.org
7 djmaze 1.1  
8 djmaze 1.3 Dragonfly is released under the terms and conditions
9 djmaze 1.1 of the GNU GPL version 2 or any later version
10 djmaze 1.1  
11 djmaze 9.6 $Source: /cvs/html/includes/classes/cpg_cache.php,v $
12 djmaze 10.0 $Revision: 9.18 $
13 nanocaio 9.14 $Author: nanocaiordo $
14 djmaze 10.0 $Date: 2010/07/16 12:22:26 $
15 djmaze 1.3 **********************************************/
16 djmaze 1.1  
17 nanocaio 9.13 abstract class Cache {
18 djmaze 1.1  
19 nanocaio 9.16 public static function clear()
20 nanocaio 9.16 {
21 djmaze 9.8 $cache_dir = BASEDIR.'cache';
22 djmaze 9.8 $cache = dir($cache_dir);
23 djmaze 9.7 while($file = $cache->read()) {
24 nanocaio 9.14 if (!is_dir("$cache_dir/$file") && $file != '.htaccess' && $file != '.cvsignore') {
25 djmaze 9.7 unlink("$cache_dir/$file");
26 djmaze 9.7 }
27 djmaze 9.7 }
28 djmaze 9.7 $cache->close();
29 djmaze 9.7 }
30 djmaze 9.7  
31 nanocaio 9.15 public static function clear_conf()
32 nanocaio 9.15 {
33 nanocaio 9.15 $cache_dir = BASEDIR.'cache';
34 nanocaio 9.15 $cache = dir($cache_dir);
35 nanocaio 9.15 while($file = $cache->read()) {
36 nanocaio 9.15 if (!is_dir("$cache_dir/$file") && 0 === strpos($file, 'config_')) {
37 nanocaio 9.15 unlink("$cache_dir/$file");
38 nanocaio 9.15 }
39 nanocaio 9.15 }
40 nanocaio 9.15 $cache->close();
41 nanocaio 9.15 }
42 nanocaio 9.15  
43 nanocaio 9.18 private static function array_parse($array, $space=' ')
44 nanocaio 9.16 {
45 djmaze 9.5 $return = '';
46 djmaze 9.5 foreach($array as $key => $value) {
47 nanocaio 9.11 $key = is_int($key) ? $key : "'$key'";
48 djmaze 9.5 $return .= "$space$key => ";
49 djmaze 9.5 if (is_array($value)) {
50 nanocaio 9.18 $return .= "array(\n".Cache::array_parse($value, "$space ")."$space),\n";
51 djmaze 9.5 } else {
52 djmaze 9.5 if (!is_int($value)) {
53 nanocaio 9.18 $value = str_replace('\\', "\\\\", trim($value));
54 nanocaio 9.18 $value = "'".str_replace("'", "\\'", $value)."'";
55 djmaze 9.5 }
56 nanocaio 9.18 $return .= $value.",\n";
57 djmaze 9.5 }
58 djmaze 9.5 }
59 djmaze 9.5 return $return;
60 djmaze 9.5 }
61 nanocaio 9.16  
62 nanocaio 9.16 public static function array_save($name, $module_name='config', $array=false)
63 nanocaio 9.16 {
64 djmaze 9.8 $cache_dir = BASEDIR.'cache';
65 djmaze 9.5 $filename = $cache_dir.'/'.$module_name."_$name.php";
66 djmaze 9.5 if (is_dir($cache_dir) && is_writable($cache_dir)) {
67 djmaze 9.5 $data = "<?php\nif (!defined('CPG_NUKE')) { exit; }\n";
68 djmaze 9.5 if (is_array($array)) {
69 nanocaio 9.13 $data .= "\$$name = array(\n".Cache::array_parse($array).");";
70 djmaze 9.5 } else {
71 djmaze 9.5 global $$name;
72 nanocaio 9.13 if (is_array($$name)) { $data .= "\$$name = array(\n".Cache::array_parse($$name).");"; }
73 djmaze 9.5 }
74 djmaze 9.5 file_write($filename, $data);
75 djmaze 9.5 }
76 djmaze 9.5 }
77 nanocaio 9.16  
78 nanocaio 9.16 public static function array_load($name, $module_name='config', $global=true)
79 nanocaio 9.16 {
80 djmaze 9.5 if ($global) global $$name;
81 djmaze 9.8 $filename = BASEDIR.'cache/'.$module_name."_$name.php";
82 djmaze 9.5 if (file_exists($filename)) {
83 djmaze 9.5 include($filename);
84 djmaze 9.5 if (!defined('PHP_AS_NOBODY')) { define_nobody($filename); }
85 djmaze 9.5 return $$name;
86 djmaze 9.5 }
87 djmaze 9.5 return false;
88 djmaze 9.5 }
89 nanocaio 9.16  
90 nanocaio 9.13 public static function array_delete($name, $module_name='config') {
91 djmaze 9.6 Cache::remove($name, $module_name);
92 djmaze 9.6 }
93 djmaze 9.6  
94 nanocaio 9.16 public static function remove($name, $module_name='config')
95 nanocaio 9.16 {
96 djmaze 9.8 $cache_dir = BASEDIR.'cache';
97 djmaze 9.8 $filename = "$cache_dir/$module_name"."_$name.php";
98 djmaze 9.5 if (is_dir($cache_dir) && is_writable($cache_dir) && file_exists($filename)) {
99 djmaze 9.5 unlink($filename);
100 djmaze 9.5 }
101 djmaze 9.5 clearstatcache();
102 djmaze 9.5 }
103 djmaze 1.1  
104 nanocaio 9.16 public static function defines_save($name, $module_name, $defines)
105 nanocaio 9.16 {
106 djmaze 9.8 $cache_dir = BASEDIR.'cache';
107 djmaze 9.6 $filename = $cache_dir.'/'.$module_name."_$name.php";
108 djmaze 9.6 if (is_dir($cache_dir) && is_writable($cache_dir)) {
109 djmaze 9.6 $data = "<?php\nif (!defined('CPG_NUKE')) { exit; }\n";
110 djmaze 9.6 foreach ($defines as $name => $value) {
111 djmaze 9.6 if (!is_int($value)) {
112 djmaze 9.6 $value = str_replace('\\', '\\\\', trim($value));
113 nanocaio 9.13 $value = "'".str_replace("'", "\\'", $value)."'";
114 djmaze 9.6 }
115 djmaze 9.6 $data .= "define('$name', $value);\n";
116 djmaze 9.6 }
117 djmaze 9.6 file_write($filename, $data);
118 djmaze 9.6 }
119 djmaze 9.6 }
120 nanocaio 9.16  
121 nanocaio 9.16 public static function defines_load($name, $module_name)
122 nanocaio 9.16 {
123 djmaze 9.8 $filename = BASEDIR.'cache/'.$module_name."_$name.php";
124 djmaze 9.6 if (file_exists($filename)) {
125 djmaze 9.6 include_once($filename);
126 djmaze 9.6 return true;
127 djmaze 9.6 }
128 djmaze 9.6 return false;
129 djmaze 9.6 }
130 djmaze 9.6  
131 djmaze 1.1 }


Code Credits - Privacy Policy