File indexing completed on 2024-05-12 17:26:16

0001 <?php
0002 
0003 /*
0004  *   GFX 4
0005  * 
0006  *   support: happy.snizzo@gmail.com
0007  *   website: http://trt-gfx.googlecode.com
0008  *   credits: Claudio Desideri
0009  *   
0010  *   This software is released under the MIT License.
0011  *   http://opensource.org/licenses/mit-license.php
0012  */ 
0013 
0014 /*
0015  * This class stores elements of a list in an APC cache.
0016  * 
0017  * example:
0018  * 
0019  * var1|data1
0020  * var2|data2
0021  * var3|data3
0022  * 
0023  */
0024 
0025 class ECacheVar {
0026   
0027   private $name = false;
0028   
0029   private $debug = true;
0030   
0031   public function __construct($name=false){
0032     
0033     $this->name = "gfx3varcache_$name";
0034   }
0035   
0036   public static function exists($name){
0037     //return apc_exists($name);
0038     return false;
0039   }
0040   
0041   //returns the value associate to $var
0042   public function get($var){
0043     /*
0044     $content = apc_fetch($this->name);
0045     $content = explode("\n", $content);
0046     foreach($content as $line){
0047       $line = explode("|", $line);
0048       if($line[0]==$var){
0049         return rtrim($line[1], "\n");
0050       }
0051     }
0052     */
0053   }
0054   
0055   public function set($var, $value){
0056     /*
0057     $content = apc_fetch($this->name);
0058     $content = explode("\n", $content);
0059     
0060     $has_been_inserted = false;
0061     $l = count($content);
0062     for($i=0;$i<$l;$i++){
0063       $line = explode("|", $content[$i]);
0064       if($line[0]==$var){
0065         $content[$i] = $var."|".$value;
0066         $has_been_inserted = true;
0067       }
0068     }
0069     
0070     if(!$has_been_inserted){
0071       $content[] = $var."|".$value;
0072     }
0073     
0074     $str = implode("\n", $content);
0075     apc_store($this->name, $str);
0076     * */
0077   }
0078   
0079   public function get_array_assoc(){
0080     /*
0081     $content = apc_fetch($this->name);
0082     $content = explode("\n", $content);
0083     
0084     $assoc = array();
0085     $l = count($content);
0086     for($i=0;$i<$l;$i++){
0087       if(!empty($content[$i])){
0088         $line = explode("|", $content[$i]);
0089         $assoc[$line[0]] = rtrim($line[1], "\n");
0090       }
0091     }
0092     return $assoc;
0093     */
0094   }
0095   
0096   public function del($var){
0097     /*
0098     $content = apc_fetch($this->name);
0099     $content = explode("\n", $content);
0100     
0101     $l = count($content);
0102     for($i=0;$i<$l;$i++){
0103       $line = explode("|", $content[$i]);
0104       if($line[0]==$var){
0105         unset($content[$i]);
0106       }
0107     }
0108     
0109     $str = implode("\n", $content);
0110     apc_store($this->name, $str);
0111     * */
0112   }
0113   
0114   public function print_raw_cache(){
0115     /*
0116     echo apc_fetch($this->name);
0117     * */
0118   }
0119   
0120 }
0121 
0122 ?>