2024-09-02 17:27:15 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class PHPJSONDB {
|
|
|
|
static function put($db,$table,$item,$data) {
|
|
|
|
global $phpjsondb_dbpath;
|
2024-09-02 17:31:43 +00:00
|
|
|
if ( !isset($phpjsondb_dbpath) ) { $phpjsondb_dbpath="./db"; }
|
2024-09-02 17:27:15 +00:00
|
|
|
if ( !file_exists($phpjsondb_dbpath."/".$db."/".$table."/".md5($item).".data") ) {
|
|
|
|
@mkdir($phpjsondb_dbpath."/".$db."/".$table,0755,TRUE);
|
|
|
|
file_put_contents($phpjsondb_dbpath."/".$db."/".$table."/".md5($item).".json",json_encode($data));
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
static function get($db,$table,$item) {
|
2024-09-02 17:31:43 +00:00
|
|
|
if ( !isset($phpjsondb_dbpath) ) { $phpjsondb_dbpath="./db"; }
|
2024-09-02 17:27:15 +00:00
|
|
|
global $phpjsondb_dbpath;
|
|
|
|
if ( file_exists($phpjsondb_dbpath."/".$db."/".$table."/".md5($item).".json") ) {
|
|
|
|
return json_decode(file_get_contents($phpjsondb_dbpath."/".$db."/".$table."/".md5($item).".json"));
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class PJDB extends PHPJSONDB {
|
|
|
|
}
|