From 155cf6aeea9ba7ecbc39face6442d3ce1b03ad8e Mon Sep 17 00:00:00 2001 From: Nils Schwabe Date: Wed, 4 Jun 2014 14:27:03 +0200 Subject: Add webinterface with functionallity --- management-interface/lib/db/jig.php | 133 ++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 management-interface/lib/db/jig.php (limited to 'management-interface/lib/db/jig.php') diff --git a/management-interface/lib/db/jig.php b/management-interface/lib/db/jig.php new file mode 100644 index 0000000..16f2255 --- /dev/null +++ b/management-interface/lib/db/jig.php @@ -0,0 +1,133 @@ +dir.$file)) + return array(); + $raw=$fw->read($dst); + switch ($this->format) { + case self::FORMAT_JSON: + $data=json_decode($raw,TRUE); + break; + case self::FORMAT_Serialized: + $data=$fw->unserialize($raw); + break; + } + return $data; + } + + /** + * Write data to file + * @return int + * @param $file string + * @param $data array + **/ + function write($file,array $data=NULL) { + $fw=\Base::instance(); + switch ($this->format) { + case self::FORMAT_JSON: + $out=json_encode($data,@constant('JSON_PRETTY_PRINT')); + break; + case self::FORMAT_Serialized: + $out=$fw->serialize($data); + break; + } + return $fw->write($this->dir.$file,$out); + } + + /** + * Return directory + * @return string + **/ + function dir() { + return $this->dir; + } + + /** + * Return UUID + * @return string + **/ + function uuid() { + return $this->uuid; + } + + /** + * Return SQL profiler results + * @return string + **/ + function log() { + return $this->log; + } + + /** + * Jot down log entry + * @return NULL + * @param $frame string + **/ + function jot($frame) { + if ($frame) + $this->log.=date('r').' '.$frame.PHP_EOL; + } + + /** + * Clean storage + * @return NULL + **/ + function drop() { + if ($glob=@glob($this->dir.'/*',GLOB_NOSORT)) + foreach ($glob as $file) + @unlink($file); + } + + /** + * Instantiate class + * @param $dir string + * @param $format int + **/ + function __construct($dir,$format=self::FORMAT_JSON) { + if (!is_dir($dir)) + mkdir($dir,\Base::MODE,TRUE); + $this->uuid=\Base::instance()->hash($this->dir=$dir); + $this->format=$format; + } + +} -- cgit v1.2.3-55-g7522