[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
|
// 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);
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用