Gitlab@Informatics

Skip to content
Snippets Groups Projects
Commit b3e723c4 authored by Woraprat's avatar Woraprat
Browse files

update captcha

parent 2f548f4e
No related branches found
No related tags found
No related merge requests found
......@@ -279,14 +279,34 @@ class general extends Exhibition_Controller
echo json_encode($data);
}
public function insert_comment()
{
public function insert_comment(){
$data['message'] = true;
$sender = $this->input->post('sender');
$detail = $this->input->post('detail');
$id = $this->input->post('id');
$google_url = "https://www.google.com/recaptcha/api/siteverify";
$secret_key = '6Lec8uckAAAAALcbXBS1XQ36NNrY8ztqPtwuPM8W';
$response = $this->input->post('captcha');
if(!empty($response))
{
$url = $google_url."?secret=".$secret_key."&response=".$response;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
$res= json_decode($output, true);
if($res['success'] == 'true')
$data['message'] = true;
else
$data['message'] = false;
}else{
$data['message'] = false;
}
$this->load->model('general/M_general', 'general');
if($data['message'] == true){
$this->general->insert_comment($sender, $detail, date("Y-m-d"), $id);
$data['message'] = true;
}
echo json_encode($data);
}
}
......@@ -15,7 +15,7 @@ class M_company extends Da_company
public function get_all()
{
$sql = "SELECT * FROM {$this->db_name}.company
Where is_delete = 0";
Where is_delete = 0 order by company_id DESC";
$query = $this->db->query($sql);
return $query;
}
......
......@@ -192,7 +192,7 @@ class M_general extends Da_general
public function get_comment_all($id)
{
$sql = "SELECT * FROM {$this->db_name}.comment
Where project_id = $id";
Where project_id = $id order by comment_id DESC";
$query = $this->db->query($sql);
return $query;
}
......
......@@ -15,7 +15,7 @@ class M_instructor extends Da_instructor
public function get_all()
{
$sql = "SELECT * FROM {$this->db_name}.instructor
Where is_delete = 0 and instructor_id != 0";
Where is_delete = 0 and instructor_id != 0 order by instructor_id DESC";
$query = $this->db->query($sql);
return $query;
}
......
......@@ -14,7 +14,8 @@ class M_project extends Da_project
public function get_all()
{
$sql = "SELECT * FROM {$this->db_name}.project";
$sql = "SELECT * FROM {$this->db_name}.project
order by project_id DESC";
$query = $this->db->query($sql);
return $query;
}
......@@ -30,7 +31,7 @@ class M_project extends Da_project
public function get_all_user($id)
{
$sql = "SELECT * FROM {$this->db_name}.project
Where user_id = $id";
Where user_id = $id order by project_id DESC";
$query = $this->db->query($sql);
return $query;
}
......
......@@ -15,7 +15,7 @@ class M_tag extends Da_tag
public function get_all()
{
$sql = "SELECT * FROM {$this->db_name}.tag
Where is_delete = 0";
Where is_delete = 0 order by tag_id DESC";
$query = $this->db->query($sql);
return $query;
}
......
......@@ -24,7 +24,7 @@ class M_user extends Da_user
public function get_all()
{
$sql = "SELECT * FROM {$this->db_name}.user
Where is_delete = 0";
Where is_delete = 0 order by user_id DESC";
$query = $this->db->query($sql);
return $query;
}
......
<link rel="stylesheet" href="https://cdn.datatables.net/1.11.4/css/jquery.dataTables.min.css" />
<!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.css" /> -->
<!-- <link rel="stylesheet" href="https://cdn.datatables.net/1.11.4/css/dataTables.bootstrap4.min.css" /> -->
<script src="https://cdn.datatables.net/1.11.4/js/jquery.dataTables.min.js"></script>
<link href="<?php echo base_url().'assets/plugins/page.css'?>" rel="stylesheet" />
......@@ -326,6 +321,7 @@ span{
<input type="text" id="sender" value="" placeholder="ชื่อ-นามสกุล" class="form-control">
</div>
<textarea class="form-control ml-1 shadow-none textarea" placeholder="เขียนความคิดเห็น..." id="detail"></textarea></div>
<div class="g-recaptcha" data-sitekey="6Lec8uckAAAAABGZ4_CaawpSb9hXgbDlwnhXaJco"></div>
<div class="mt-2 text-right"><button class="btn btn-info btn-sm shadow-none" type="button" onclick="insert_comment()">เพิ่มความคิดเห็น</button></div>
</div>
<div class="data-container"></div>
......@@ -361,6 +357,7 @@ span{
</div>
</footer>
<script src="<?php echo base_url()?>assets/plugins/page.js"></script>
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<script>
$(document).ready(function() {
......@@ -464,7 +461,8 @@ span{
data: {
'sender': sender,
'detail': detail,
'id': '<?php echo $project->project_id ?>'
'id': '<?php echo $project->project_id ?>',
'captcha': grecaptcha.getResponse()
},
dataType: 'json',
success: function(data) {
......@@ -476,6 +474,7 @@ span{
get_comment()
$('#sender').val('')
$('#detail').val('')
grecaptcha.reset();
})
}else{
Toast.fire({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment