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.1 (2 years 3 weeks 3 days 2 hours 28 minutes 52 seconds ago) by nanocaiordo
Changed : +18 -21 lines
Comment: Use of CACHE_PATH and unlink Dragonfly_Config


# 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 nanocaio 10.1 $Revision: 10.0 $
13 nanocaio 10.1 $Author: djmaze $
14 nanocaio 10.1 $Date: 2010/11/05 01:03:14 $
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 nanocaio 10.1 $cache = dir(CACHE_PATH);
22 djmaze 9.7 while($file = $cache->read()) {
23 nanocaio 10.1 if (!is_dir(CACHE_PATH.$file) && $file != '.htaccess' && $file != '.cvsignore') {
24 nanocaio 10.1 unlink(CACHE_PATH.$file);
25 djmaze 9.7 }
26 djmaze 9.7 }
27 djmaze 9.7 $cache->close();
28 djmaze 9.7 }
29 djmaze 9.7  
30 nanocaio 9.15 public static function clear_conf()
31 nanocaio 9.15 {
32 nanocaio 10.1 if (is_file(CACHE_PATH.'Dragonfly_Config')) unlink(CACHE_PATH.'Dragonfly_Config');
33 nanocaio 10.1 $cache = dir(CACHE_PATH);
34 nanocaio 9.15 while($file = $cache->read()) {
35 nanocaio 10.1 if (!is_dir(CACHE_PATH.$file) && 0 === strpos($file, 'config_')) {
36 nanocaio 10.1 unlink(CACHE_PATH.$file);
37 nanocaio 9.15 }
38 nanocaio 9.15 }
39 nanocaio 9.15 $cache->close();
40 nanocaio 9.15 }
41 nanocaio 9.15  
42 nanocaio 9.18 private static function array_parse($array, $space=' ')
43 nanocaio 9.16 {
44 djmaze 9.5 $return = '';
45 djmaze 9.5 foreach($array as $key => $value) {
46 nanocaio 9.11 $key = is_int($key) ? $key : "'$key'";
47 djmaze 9.5 $return .= "$space$key => ";
48 djmaze 9.5 if (is_array($value)) {
49 nanocaio 9.18 $return .= "array(\n".Cache::array_parse($value, "$space ")."$space),\n";
50 djmaze 9.5 } else {
51 djmaze 9.5 if (!is_int($value)) {
52 nanocaio 9.18 $value = str_replace('\\', "\\\\", trim($value));
53 nanocaio 9.18 $value = "'".str_replace("'", "\\'", $value)."'";
54 djmaze 9.5 }
55 nanocaio 9.18 $return .= $value.",\n";
56 djmaze 9.5 }
57 djmaze 9.5 }
58 djmaze 9.5 return $return;
59 djmaze 9.5 }
60 nanocaio 9.16  
61 nanocaio 9.16 public static function array_save($name, $module_name='config', $array=false)
62 nanocaio 9.16 {
63 nanocaio 10.1 if (is_dir(CACHE_PATH) && is_writable(CACHE_PATH)) {
64 nanocaio 10.1 $filename = CACHE_PATH.$module_name."_$name.php";
65 djmaze 9.5 $data = "<?php\nif (!defined('CPG_NUKE')) { exit; }\n";
66 djmaze 9.5 if (is_array($array)) {
67 nanocaio 9.13 $data .= "\$$name = array(\n".Cache::array_parse($array).");";
68 djmaze 9.5 } else {
69 djmaze 9.5 global $$name;
70 nanocaio 9.13 if (is_array($$name)) { $data .= "\$$name = array(\n".Cache::array_parse($$name).");"; }
71 djmaze 9.5 }
72 djmaze 9.5 file_write($filename, $data);
73 djmaze 9.5 }
74 djmaze 9.5 }
75 nanocaio 9.16  
76 nanocaio 9.16 public static function array_load($name, $module_name='config', $global=true)
77 nanocaio 9.16 {
78 djmaze 9.5 if ($global) global $$name;
79 nanocaio 10.1 $filename = CACHE_PATH."{$module_name}_{$name}.php";
80 djmaze 9.5 if (file_exists($filename)) {
81 djmaze 9.5 include($filename);
82 djmaze 9.5 if (!defined('PHP_AS_NOBODY')) { define_nobody($filename); }
83 djmaze 9.5 return $$name;
84 djmaze 9.5 }
85 djmaze 9.5 return false;
86 djmaze 9.5 }
87 nanocaio 9.16  
88 nanocaio 9.13 public static function array_delete($name, $module_name='config') {
89 djmaze 9.6 Cache::remove($name, $module_name);
90 djmaze 9.6 }
91 djmaze 9.6  
92 nanocaio 9.16 public static function remove($name, $module_name='config')
93 nanocaio 9.16 {
94 nanocaio 10.1 $filename = CACHE_PATH.($name == 'MAIN_CFG' ? 'Dragonfly_Config' : "{$module_name}_{$name}.php");
95 nanocaio 10.1 if (is_dir(CACHE_PATH) && is_writable(CACHE_PATH) && file_exists($filename)) {
96 djmaze 9.5 unlink($filename);
97 djmaze 9.5 }
98 djmaze 9.5 clearstatcache();
99 djmaze 9.5 }
100 djmaze 1.1  
101 nanocaio 9.16 public static function defines_save($name, $module_name, $defines)
102 nanocaio 9.16 {
103 djmaze 9.8 $cache_dir = BASEDIR.'cache';
104 nanocaio 10.1 if (is_dir(CACHE_PATH) && is_writable(CACHE_PATH)) {
105 nanocaio 10.1 $filename = CACHE_PATH."{$module_name}_{$name}.php";
106 djmaze 9.6 $data = "<?php\nif (!defined('CPG_NUKE')) { exit; }\n";
107 djmaze 9.6 foreach ($defines as $name => $value) {
108 djmaze 9.6 if (!is_int($value)) {
109 djmaze 9.6 $value = str_replace('\\', '\\\\', trim($value));
110 nanocaio 9.13 $value = "'".str_replace("'", "\\'", $value)."'";
111 djmaze 9.6 }
112 djmaze 9.6 $data .= "define('$name', $value);\n";
113 djmaze 9.6 }
114 djmaze 9.6 file_write($filename, $data);
115 djmaze 9.6 }
116 djmaze 9.6 }
117 nanocaio 9.16  
118 nanocaio 9.16 public static function defines_load($name, $module_name)
119 nanocaio 9.16 {
120 nanocaio 10.1 $filename = CACHE_PATH."{$module_name}_{$name}.php";
121 djmaze 9.6 if (file_exists($filename)) {
122 djmaze 9.6 include_once($filename);
123 djmaze 9.6 return true;
124 djmaze 9.6 }
125 djmaze 9.6 return false;
126 djmaze 9.6 }
127 djmaze 9.6  
128 djmaze 1.1 }


Code Credits - Privacy Policy