| Server IP : 103.48.194.25 / Your IP : 216.73.217.33 Web Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.33 System : Linux VMHostDefault 3.10.0-1160.42.2.el7.x86_64 #1 SMP Tue Sep 7 14:49:57 UTC 2021 x86_64 User : sieuthimay ( 1016) PHP Version : 8.2.20 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/galaxynail.com/site/controllers/ |
Upload File : |
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Contact extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('Contact_model','contact');
$this->lang->load('contact');
$this->lang->load('mail');
}
public function index()
{
//trit($_POST);
if(isset($_POST['bt_submit']))
{
$csrf = $this->input->post('csrf');
$ses_csrf = isset($_SESSION['ses_csrf']) ? $_SESSION['ses_csrf'] : '';
$captcha = $this->input->post('captcha');
$ses_csrf = isset($_SESSION['ses_captcha']) ? $_SESSION['ses_captcha'] : ''; //trit($captcha .'='.$ses_csrf);
if(($ses_csrf == $csrf) && ($ses_csrf == $captcha))
{
$this->form_validation->set_rules('cusname',lang('your_name'),'trim|required');
$this->form_validation->set_rules('phone',lang('phone'),'trim|required');
if($this->form_validation->run() == FALSE)
{
$this->pre_message = validation_errors();
}
else
{
$req = $this->build_data();
if($this->contact->save("contact",$req))
{
//send mail to admin
$subject = lang('mail_title');
$content = $this->load->view("contact/mail_contact", $req, true);
$this->load->helper('mail') ;
sendmail("Tim Gia Dung|timgiadung@gmail.com", "","Trieu Thang|tritigi@gmail.com", $subject, $content) ;
$this->session->set_flashdata('message','Lưu thành công');
redirect('contact-sucessful');
}
else
{
$this->pre_message = lang('contact_unsucessful');
}
}
}
/*else
{
}*/
}
$data['csrf'] = $_SESSION['ses_csrf'] = create_csrf();
$data['ses_captcha'] = $_SESSION['ses_captcha'] = substr($data['csrf'],rand(1,10),5);
$data['title'] = "Liên hệ" ;
//$data['link_catpcha'] = site.'capchaimage/securimage/';
$data['cfg'] = $cfg = get_cauhinh();
$data['metatitle'] = $cfg->site_title;
$data['metadesc'] = $cfg->site_desc;
$data['metakey'] = $cfg->site_keyword;
$data['metaimg'] = ''; //$cfg->metatitle;
$data['canonical'] = site.'contact-us.html';
$data['page'] = 'contact/index';
$this->load->view('skin_home',$data);
}
private function build_data($flag=0)
{
$req["cusname"] = $this->input->post("cusname");
$req["address"] = $this->input->post("address");
$req["phone"] = $this->input->post("phone");
$req["cusmail"] = $this->input->post("cusmail");
$req["content"] = $this->input->post("content");
$req["dt_create"] = date('Y-m-d H:i:s');
$req["bl_active"] = 0;
return $req;
}
public function sucessful()
{
$data['title'] = lang('contact_sucessful');
$data['cont'] = lang('contact_sucessful') ;
$data['cfg'] = $cfg = get_cauhinh();
$data['metatitle'] = $cfg->site_title;
$data['metadesc'] = $cfg->site_desc;
$data['metakey'] = $cfg->site_keyword;
$data['metaimg'] = ''; //$cfg->metatitle;
$data['canonical'] = site.'contact-sucessful.html';
$data['page'] = 'contact/successful';
$this->load->view("skin", $data);
}
}