From 597bd207c313297a3c09a0446f4dcfa241e9ff66 Mon Sep 17 00:00:00 2001 From: loulou123546 Date: Tue, 21 Mar 2017 22:22:45 +0100 Subject: [PATCH] Adds Keys functionality ready to push --- DOWNLOAD/source/Datas.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DOWNLOAD/source/Datas.php b/DOWNLOAD/source/Datas.php index d0fdd9e..36f1528 100644 --- a/DOWNLOAD/source/Datas.php +++ b/DOWNLOAD/source/Datas.php @@ -15,6 +15,9 @@ public static function get_ITEM ($password,$db,$ID){if(self::connect($password)) public static function set_ITEM ($password,$db,$ID,$value,$isJSON = false){if(self::connect($password)){$content = json_decode(self::get_content($db),true);if($isJSON){$content['DATA'][$ID] = json_decode($value,true);}else{$content['DATA'][$ID] = $value;}self::set_content($db,json_encode($content));return true;}else{return false;}} public static function find_ID ($password,$db,$value){if(self::connect($password)){$content = json_decode(self::get_content($db),true);$result = array();foreach($content['DATA'] as $ID => $item){$valid = true;foreach($value as $rule){if(eval("if(\$item".$rule."){return true;}else{return false;}") == false){$valid = false;}}if($valid){$result[] = $ID;}}return $result;}else{return false;}} public static function find_ITEM ($password,$db,$value){if(self::connect($password)){$content = json_decode(self::get_content($db),true);$result = array();foreach($content['DATA'] as $ID => $item){$valid = true;foreach($value as $rule){if(eval("if(\$item".$rule."){return true;}else{return false;}") == false){$valid = false;}}if($valid){$result[] = $item;}}return $result;}else{return false;}} +public static function setKey ($password,$key,$value){if(self::connect($password)){$content = json_decode(self::get_content("__keys__"),true);$content[$key] = $value;self::set_content("__keys__",json_encode($content));return true;}else{return false;}} +public static function getKey ($password,$key){if(self::connect($password)){$keys = json_decode(self::get_content("__keys__"),true);return $keys[$key];}else{return false;}} +public static function isKey ($password,$key){if(self::connect($password)){$keys = json_decode(self::get_content("__keys__"),true);return isset($keys[$key]);}else{return false;}} private static function connect ($password){if(self::$config['password'] === $password){return true;}else{return false;}} private static function get_content ($db){if(file_exists(self::$config['path'].$db.".json")){$file = fopen(self::$config['path'].$db.".json","r");$content = fread($file,filesize(self::$config['path'].$db.".json"));fclose($file);return $content;}else{return false;}} private static function set_content ($db,$value = ""){$file = fopen(self::$config['path'].$db.".json","w");fwrite($file,$value);fclose($file);return true;}}