[API] Access function improved to speed function up
这个提交包含在:
父节点
20491702a3
当前提交
1729aaaa69
共有 1 个文件被更改,包括 19 次插入 和 23 次删除
|
|
@ -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);
|
||||
|
|
|
|||
正在加载…
在新工单中引用