PoC for public search
这个提交包含在:
父节点
f3ad81fef8
当前提交
41239df4c4
共有 2 个文件被更改,包括 37 次插入 和 6 次删除
|
|
@ -458,15 +458,20 @@ class Visitor extends CI_Controller {
|
||||||
|
|
||||||
public function search() {
|
public function search() {
|
||||||
$slug = $this->security->xss_clean($this->uri->segment(3));
|
$slug = $this->security->xss_clean($this->uri->segment(3));
|
||||||
$data['slug'] = $slug;
|
|
||||||
$callsign = $this->security->xss_clean($this->uri->segment(4));
|
$callsign = $this->security->xss_clean($this->uri->segment(4));
|
||||||
$data['callsign'] = $callsign;
|
$this->load->model('publicsearch');
|
||||||
$this->search_result($data);
|
$result = $this->publicsearch->search($slug, $callsign);
|
||||||
|
$this->search_result($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function search_result($data) {
|
private function search_result($search_results) {
|
||||||
echo "TEST".$data['slug']."<br />";
|
if ($search_results->num_rows() > 0) {
|
||||||
echo "CALL".strtoupper($data['callsign']);
|
echo "Result found";
|
||||||
|
$data['results'] = $search_results;
|
||||||
|
$this->load->view('view_log/partial/log_ajax.php', $data);
|
||||||
|
} else {
|
||||||
|
echo "No results found";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class Publicsearch extends CI_Model {
|
||||||
|
|
||||||
|
function search($slug, $callsign) {
|
||||||
|
$userid = $this->get_userid_for_slug($slug);
|
||||||
|
$this->db->where('COL_CALL', $callsign);
|
||||||
|
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
|
||||||
|
$this->db->join('lotw_users', 'lotw_users.callsign = '.$this->config->item('table_name').'.col_call', 'left outer');
|
||||||
|
$this->db->where('station_profile.user_id', $userid);
|
||||||
|
$query = $this->db->get($this->config->item('table_name'));
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_userid_for_slug($slug) {
|
||||||
|
$this->db->select('user_id');
|
||||||
|
$this->db->where('public_slug', $slug);
|
||||||
|
$query = $this->db->get('station_logbooks');
|
||||||
|
|
||||||
|
return $query->result_array()[0]['user_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
正在加载…
在新工单中引用