Skip to content

Commit

Permalink
Adds Keys functionality
Browse files Browse the repository at this point in the history
ready to push
  • Loading branch information
loulou123546 committed Mar 21, 2017
1 parent d0c9d8d commit 597bd20
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions DOWNLOAD/source/Datas.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;}}
Expand Down

0 comments on commit 597bd20

Please sign in to comment.