Skip to content

Commit

Permalink
Merge branch 'release/Version_1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
loulou123546 committed Mar 21, 2017
2 parents bc9a13d + 597bd20 commit a2f5ae7
Show file tree
Hide file tree
Showing 2 changed files with 33 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
30 changes: 30 additions & 0 deletions sources/datas.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,36 @@ public static function find_ITEM ($password, $db, $value) {
}
}

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;
}
}


/*************************************
* *
Expand Down

0 comments on commit a2f5ae7

Please sign in to comment.