A PHP Error was encountered

Severity: 8192

Message: Function create_function() is deprecated

Filename: geshi/geshi.php

Line Number: 4698

Backtrace:

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4698
Function: _error_handler

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4621
Function: _optimize_regexp_list_tokens_to_string

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 1655
Function: optimize_regexp_list

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2029
Function: optimize_keyword_group

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2168
Function: build_parse_cache

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/Process.php
Line: 45
Function: parse_code

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/models/Pastes.php
Line: 517
Function: syntax

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 693
Function: getPaste

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once

PHP Datastore - Stikked
From Ben-Lamothe, 12 Years ago, written in PHP.
Embed
  1.  
  2. class DataStore
  3. {
  4.     private $data = array();    
  5.     private $file = null;
  6.    
  7.     /**
  8.      * Constructs a new data store
  9.      *
  10.      * @param PhingFile $file object pointing to the data store on disk
  11.      */
  12.     function __construct(PhingFile $file)
  13.     {
  14.         $this->file = $file;
  15.        
  16.         if ($this->file->exists())
  17.         {
  18.             $this->read();
  19.         }
  20.     }
  21.    
  22.     /**
  23.      * Destructor
  24.      */
  25.     function __destruct()
  26.     {
  27.         $this->commit();
  28.     }
  29.    
  30.     /**
  31.      * Retrieves a value from the data store
  32.      *
  33.      * @param string $key the key
  34.      *
  35.      * @return mixed the value
  36.      */
  37.     public function get($key)
  38.     {
  39.         if (!isset($this->data[$key]))
  40.         {
  41.             return null;
  42.         }
  43.         else
  44.         {
  45.             return $this->data[$key];
  46.         }
  47.     }
  48.    
  49.     /**
  50.      * Adds a value to the data store
  51.      *
  52.      * @param string  $key        the key
  53.      * @param mixed   $value      the value
  54.      * @param boolean $autocommit whether to auto-commit (write)
  55.      *                            the data store to disk
  56.      *
  57.      * @return none
  58.      */
  59.     public function put($key, $value, $autocommit = false)
  60.     {
  61.         $this->data[$key] = $value;
  62.        
  63.         if ($autocommit)
  64.         {
  65.             $this->commit();
  66.         }
  67.     }
  68.    
  69.     /**
  70.      * Commits data store to disk
  71.      *
  72.      * @return none
  73.      */
  74.     public function commit()
  75.     {
  76.         $this->write();
  77.     }
  78.    
  79.     /**
  80.      * Internal function to read data store from file
  81.      *
  82.      * @return none
  83.      */
  84.     private function read()
  85.     {
  86.         if (!$this->file->canRead())
  87.         {
  88.             throw new BuildException("Can't read data store from '" .
  89.                 $file->getPath() . "'");
  90.         }
  91.         else
  92.         {
  93.             $serializedData = $this->file->contents();
  94.            
  95.             $this->data = unserialize($serializedData);
  96.         }
  97.     }
  98.  
  99.     /**
  100.      * Internal function to write data store to file
  101.      *
  102.      * @return none
  103.      */
  104.     private function write()
  105.     {
  106.         if (!$this->file->canWrite())
  107.         {
  108.             throw new BuildException("Can't write data store to '" .
  109.                 $file->getPath() . "'");
  110.         }
  111.         else
  112.         {
  113.             $serializedData = serialize($this->data);
  114.  
  115.             $writer = new FileWriter($this->file);
  116.             $writer->write($serializedData);
  117.             $writer->close();
  118.         }
  119.     }    
  120. };
  121.