[API] Access function improved to speed function up

这个提交包含在:
Peter Goodhall 2024-11-21 16:29:42 +00:00
父节点 20491702a3
当前提交 1729aaaa69

查看文件

@ -86,31 +86,27 @@ class API_Model extends CI_Model {
} }
function access($key) { function access($key) {
// No key = no access
if (!$key) {
return "No Key Found";
}
// No key = no access, mate // Check that the key is valid
if(!$key) { $this->db->where('key', $key);
return $status = "No Key Found"; $query = $this->db->get('api', 1); // Limit to 1 row for performance
}
// Check that the key is valid if ($query->num_rows() > 0) {
$this->db->where('key', $key); $row = $query->row();
$query = $this->db->get('api'); if ($row->status == "active") {
return $row->rights;
if ($query->num_rows() > 0) } else {
{ return "Key Disabled";
foreach ($query->result() as $row) }
{ } else {
if($row->status == "active") { return "No Key Found";
return $status = $row->rights; }
} else { }
return $status = "Key Disabled";
}
}
} else {
return $status = "No Key Found";
}
}
function authorize($key) { function authorize($key) {
$r = $this->access($key); $r = $this->access($key);