[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
if(!$key) {
return $status = "No Key Found";
}
// Check that the key is valid
$this->db->where('key', $key);
$query = $this->db->get('api', 1); // Limit to 1 row for performance
// Check that the key is valid
$this->db->where('key', $key);
$query = $this->db->get('api');
if ($query->num_rows() > 0)
{
foreach ($query->result() as $row)
{
if($row->status == "active") {
return $status = $row->rights;
} else {
return $status = "Key Disabled";
}
}
} else {
return $status = "No Key Found";
}
}
if ($query->num_rows() > 0) {
$row = $query->row();
if ($row->status == "active") {
return $row->rights;
} else {
return "Key Disabled";
}
} else {
return "No Key Found";
}
}
function authorize($key) {
$r = $this->access($key);