function index() { $this->load->helper('file'); delete_files('images/captcha/'); $this->load->helper('captcha'); $this->load->database(); $this->load->library('session'); $username = $this->session->userdata('username'); if ($username = "" || $username == null) { /*$img = $this->session->userdata('captcha'); if($img!=null&&$img!="") { $imgsrc = $img['imgsrc']; if($imgsrc!=null||imgsrc!="") { unlink($imgsrc); } }*/ $vals = array('img_path' => 'images/captcha/', 'img_url' => base_url('images/captcha') . '/', 'img_width' => '60', 'img_height' => '32'); $cap = create_captcha($vals); $data = array('image' => $cap['image'], 'word' => $cap['word'], 'imgsrc' => $cap['imgsrc'], 'menu' => 0, 'smenu' => 0); $this->session->set_userdata('captcha', $data); $data = array('title' => '后台登陆-' . $this->config->item('title'), 'cap' => $cap['image']); $this->load->view('admin/login', $data); } else { header('Location:' . site_url('admin/index')); } }
public function register() { if ($this->session->userdata('logged_in') == false) { $data['view'] = 'register/register'; $data['title'] = 'Đăng kí tài khoản'; $data['left_hidden'] = true; $data['right_hidden'] = true; ///////////////// $this->load->helper('captcha'); $vals = array('word' => '', 'img_path' => './asset/captcha/', 'img_url' => asset_url() . 'captcha', 'img_width' => '200', 'img_height' => 40, 'expiration' => 600, 'word_length' => 8, 'font_size' => 16, 'img_id' => 'Imageid', 'pool' => '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'colors' => array('background' => array(255, 255, 255), 'border' => array(255, 255, 255), 'text' => array(0, 0, 0), 'grid' => array(255, 40, 40))); $cap = create_captcha($vals); $data['content']['cap'] = $cap; $data_captcha = array('captcha_time' => $cap['time'], 'ip_address' => $this->input->ip_address(), 'word' => $cap['word']); $this->muser->save_captcha($data_captcha); //////////////////// $rules = array(array('field' => 'register-username', 'rules' => 'trim|required|min_length[3]|callback_check_username'), array('field' => 'register-password', 'rules' => 'trim|required|min_length[5]'), array('field' => 'register-repassword', 'rules' => 'trim|required|min_length[5]|matches[register-password]'), array('field' => 'register-email', 'rules' => 'trim|required|valid_email|callback_check_email'), array('field' => 'captcha', 'rules' => 'trim|required|callback_check_captcha')); $this->form_validation->set_rules($rules); if ($this->input->post('register')) { if ($this->form_validation->run()) { $info = array('register' => array('username' => $this->input->post('register-username'), 'email' => $this->input->post('register-email'), 'password' => md5($this->input->post('register-password')), 'role' => 'ROLE_USER'), 'avatar' => $_FILES); $id = $this->muser->create_user($info); $data['view'] = 'register/success'; $data['content']['test'] = $_FILES; } } $this->load->view(LAYOUT, $data); } else { redirect('', 'refresh'); } }
public function get_captcha() { $vals = array('img_path' => './././captcha/', 'img_url' => base_url() . 'captcha/', 'ip_address' => $this->input->ip_address(), 'word' => rand(1000, 9999), 'img_width' => 108, 'img_height' => 34, 'expiration' => 300); $cap = create_captcha($vals); $this->session->set_userdata('captcha', $cap['word']); echo $cap['image']; }
public function index() { $this->load->library('form_validation'); // Получаем меню для сайдбара $this->load->model('commerce/commerce_m'); $data['subcategory'] = $this->commerce_m->get_all_subcategories(); $data['category'] = $this->commerce_m->get_all_categories(); /* Блок авторизации */ $data['auth_form'] = $this->load->module('auth')->auth_block_generator(); $this->load->helper('captcha'); $string_for_captcha = random_string('numeric', 6); $vals = array('word' => $string_for_captcha, 'img_path' => './img/captcha/', 'img_url' => base_url() . 'img/captcha/', 'font_path' => './system/fonts/texb.ttf', 'img_width' => '150', 'img_height' => '50', 'expiration' => '50'); $cap = create_captcha($vals); $cap['random_string_for_captcha'] = $string_for_captcha; $cookie = array('name' => 'captcha', 'value' => $string_for_captcha, 'expire' => '7200'); set_cookie($cookie); if ($this->input->post('submit_contacts')) { } else { } $data['contacts'] = $this->load->view('contacts/contacts_v.php', $cap, true); /* Метатэги */ $data['seo_title'] = 'Контакты '; $data['seo_description'] = 'Контакты seo_description'; $data['seo_keywords'] = 'Контакты seo_keywords'; $this->load->view('main/index_v', $data); }
public function index() { $data = array(); if (isset($_POST['submit'])) { /*$captcha1=$this->input->post('word'); $captcha2=$this->session->userdata('word'); if($captcha1!=$captcha2) { $this->session->set_flashdata('loginstatus', 'Please enter correct captcha value'); redirect('admin/','refresh'); } else { */ $email = mysql_real_escape_string(trim($_REQUEST['email'])); $password = md5(mysql_real_escape_string(trim($_REQUEST['password']))); $userstatus = $this->adminhelper->check_user($email, $password); if ($userstatus == false) { $this->session->set_flashdata('loginstatus', 'Incorrect Login'); redirect('admin/index', 'refresh'); } else { $this->session->set_userdata('user', $userstatus); redirect('admin/dashboard', 'refresh'); } } else { $this->load->helper('captcha'); $captchaimageurl = base_url() . "captcha/"; $vals = array('img_path' => './captcha/', 'img_url' => $captchaimageurl, 'img_width' => '100', 'img_height' => 30, 'border' => 0, 'expiration' => 7200); $cap = create_captcha($vals); $data['image'] = $cap['image']; $this->session->set_userdata('word', $cap['word']); $this->load->view('admin/index', $data); } }
function setCaptchaDBEntry(&$vals, &$cap) { /*--------------------------------------------------------------------- $vals = array( 'word' => 'Random word', 'img_path' => './captcha/', 'img_url' => 'http://example.com/captcha/', 'font_path' => './path/to/fonts/texb.ttf', 'img_width' => '150', 'img_height' => 30, 'expiration' => 7200 ); image html returned in $cap['image'] --------------------------------------------------------------------- */ $cap = create_captcha($vals); // thanks to http://stackoverflow.com/questions/1703320/remove-excess-whitespace-from-within-a-string // the reason the word is being modified is to assist the user if he/she // is confused by blanks and case $cap['word'] = strtolower(preg_replace('/\\s+/', '', $cap['word'])); $data = array('captcha_time' => $cap['time'], 'ip_address' => $this->input->ip_address(), 'word' => $cap['word']); $query = $this->db->insert_string('captcha', $data); $this->db->query($query); }
public function captcha_helper() { $this->load->helper('captcha'); $vals = array('word' => 'Random word', 'img_path' => './captcha/', 'img_url' => base_url('/captcha'), 'font_path' => './path/to/fonts/texb.ttf', 'img_width' => '150', 'img_height' => 30, 'expiration' => 7200, 'word_length' => 8, 'font_size' => 16, 'img_id' => 'Imageid', 'pool' => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'colors' => array('background' => array(255, 255, 255), 'border' => array(255, 255, 255), 'text' => array(0, 0, 0), 'grid' => array(255, 40, 40))); $cap = create_captcha($vals); echo $cap['image']; }
public function index() { /* Set form validation rules */ $this->form_validation->set_rules('name', "Name", 'required'); $this->form_validation->set_rules('captcha', "Captcha", 'required'); /* Get the user's entered captcha value from the form */ $userCaptcha = set_value('captcha'); /* Get the actual captcha value that we stored in the session (see below) */ $word = $this->session->userdata('captchaWord'); /* Check if form (and captcha) passed validation */ if ($this->form_validation->run() == TRUE && strcmp(strtolower($userCaptcha), strtolower($word)) == 0) { /** Validation was successful; show the Success view * */ /* Clear the session variable */ $this->session->unset_userdata('captchaWord'); /* Get the user's name from the form */ $name = set_value('name'); /* Pass in the user input to the success view for display */ $data = array('name' => $name); // do as your requirement print_r($data); } else { /** Validation was not successful - Generate a captcha * */ /* Setup vals to pass into the create_captcha function */ $vals = array('img_path' => './captcha/', 'img_url' => 'http://localhost/captcha/', 'img_width' => '150', 'img_height' => 30, 'expiration' => 7200); /* Generate the captcha */ $captcha = create_captcha($vals); /* Store the captcha value (or 'word') in a session to retrieve later */ $this->session->set_userdata('captchaWord', $captcha['word']); /* Load the captcha view containing the form (located under the 'views' folder) */ $this->load->view('captcha-view', $captcha); } }
public function index() { $reasons = $this->Contact_us_model->get_reason_list(); $this->template_lite->assign('reasons', $reasons); if ($this->input->post('btn_save')) { $post_data = array("id_reason" => $this->input->post('id_reason', true), "user_name" => $this->input->post('user_name', true), "user_email" => $this->input->post('user_email', true), "subject" => $this->input->post('subject', true), "message" => $this->input->post('message', true), "captcha_code" => $this->input->post('captcha_code', true)); $validate_data = $this->Contact_us_model->validate_contact_form($post_data); if (!empty($validate_data["errors"])) { $this->system_messages->add_message('error', $validate_data["errors"]); $data = $validate_data["data"]; } else { $return = $this->Contact_us_model->send_contact_form($validate_data["data"]); if (!empty($return["errors"])) { $this->system_messages->add_message('error', $return["errors"]); } else { $this->system_messages->add_message('success', l('success_send_form', 'contact_us')); } redirect(site_url() . "contact_us"); } } $this->load->plugin('captcha'); $vals = array('img_path' => TEMPPATH . '/captcha/', 'img_url' => SITE_VIRTUAL_PATH . 'temp/captcha/', 'font_path' => BASEPATH . 'fonts/arial.ttf', 'img_width' => '200', 'img_height' => '30', 'expiration' => 7200); $cap = create_captcha($vals); $data["captcha"] = $cap['image']; $_SESSION["captcha_word"] = $cap['word']; $this->template_lite->assign('data', $data); $this->load->model('Menu_model'); $this->Menu_model->breadcrumbs_set_active(l('header_contact_us_form', 'contact_us')); $this->template_lite->view('form'); }
public function disclaimer($group_id = "") { // set page rules $this->_set_page_rule("R"); // set template content $this->smarty->assign("template_content", "member/registration_internasional/disclaimer.html"); // detail group $group = $this->m_izin->get_detail_group_by_id(array($group_id)); if (empty($group)) { redirect('member/registration_internasional'); } $this->smarty->assign("group", $group); // get disclaimer list $this->smarty->assign("rs_id", $this->m_disclaimer->get_list_disclaimer()); //set captcha $this->load->helper("captcha"); $vals = array('img_path' => FCPATH . '/resource/doc/captcha/', 'img_url' => base_url() . '/resource/doc' . '/captcha/', 'img_width' => '150', 'font_path' => FCPATH . '/resource/doc/font/COURIER.TTF', 'font_size' => 60, 'img_height' => 70, 'expiration' => 7200); $captcha = create_captcha($vals); $data = array('captcha_time' => $captcha['time'], 'ip_address' => $_SERVER["REMOTE_ADDR"], 'word' => $captcha['word']); $this->session->set_userdata($data); $this->smarty->assign("captcha", $captcha); // notification $this->tnotification->display_notification(); $this->tnotification->display_last_field(); // output parent::display(); }
function index() { $this->load->library('user_agent'); $this->load->library('session'); $this->load->helper('form'); if ($this->settings->item('captcha_enabled')) { $this->rules["captcha"] = "trim|required|callback__CheckCaptcha"; // load captcha $this->load->plugin('captcha'); $vals = array('img_path' => $this->settings->item('captcha_folder'), 'img_url' => base_url() . $this->settings->item('captcha_folder')); $this->data->captcha = create_captcha($vals); $this->session->set_flashdata('captcha_' . $this->data->captcha['time'], $this->data->captcha['word']); } // If the user has provided valid information and isnt a robot if (!empty($_POST) && $this->_validate()) { // The try to send the email if ($this->_send_email()) { // Store this session to limit useage $this->session->set_flashdata('sent_contact_form', TRUE); // Now redirec redirect('contact/sent'); } } $this->data->subjects =& $this->subjects; // Set the values for the form inputs foreach (array_keys($this->rules) as $field_name) { $this->data->form_values->{$field_name} = isset($this->validation->{$field_name}) ? $this->validation->{$field_name} : ''; } $this->layout->create('index', $this->data); }
function url() { $csses = array('reset', 'header', 'admin', 'footer'); $jses = array('jquery-1.7.2.min'); $head_data['csses'] = $csses; $head_data['jses'] = $jses; $this->load->view('all_header', $head_data); $this->load->helper(array('form', 'url', 'captcha')); $this->load->library('form_validation'); $this->form_validation->set_rules('url-addr', 'URL地址', 'trim|required|prep_url'); $this->form_validation->set_rules('cap', '验证码', "trim|required|strtolower|callback_expire_check[{$this->input->post('cap-time')}]|callback_cap_check[{$this->input->post('cap-time')},{$this->input->post('cap-hash')}]"); if ($this->form_validation->run() == FALSE) { $vals = array('img_path' => './tmp/captcha/', 'img_url' => base_url('tmp/captcha/') . '/', 'img_width' => 120, 'img_height' => 35, 'expiration' => 120); $cap = create_captcha($vals); $hash = sha1($this->input->ip_address() . '!NPNAV!' . strtolower($cap['word']) . $cap['time']); $form_date = array('cap_url' => $cap['image'], 'cap_ts' => $cap['time'], 'cap_hash' => $hash); $this->load->view('submiturl', $form_date); } else { $this->load->driver('cache', array('adapter' => 'file')); $foo = $this->cache->get($this->input->post('cap-hash')); if (!$foo) { $this->cache->save($this->input->post('cap-hash'), '1', '120'); $this->load->model('submit_url_m'); $this->submit_url_m->insert_one($this->input->post('url-addr'), $this->input->ip_address()); } $this->load->view('submiturlsuccess'); } $this->load->view('all_footer'); }
public function index($status = "") { // set template content $this->smarty->assign("template_content", "login/operator/form.html"); // role $this->load->model('m_settings'); $this->smarty->assign("rs_role", $this->m_settings->get_all_roles()); //set CSRF token $csrf_token_nm = $this->security->get_csrf_token_name(); $csrf_token = $this->security->get_csrf_hash(); $this->tsession->set_userdata("token", $csrf_token); $this->smarty->assign("token_nm", $csrf_token_nm); $this->smarty->assign("token", $csrf_token); //set captcha $this->load->helper("captcha"); $vals = array('img_path' => FCPATH . '/resource/doc/captcha/', 'img_url' => base_url() . '/resource/doc' . '/captcha/', 'img_width' => '150', 'font_path' => FCPATH . '/resource/doc/font/COURIER.TTF', 'font_size' => 60, 'img_height' => 50, 'expiration' => 7200); $captcha = create_captcha($vals); $data = array('captcha_time' => $captcha['time'], 'ip_address' => $_SERVER["REMOTE_ADDR"], 'word' => $captcha['word']); $this->tsession->set_userdata("data", $data); $this->smarty->assign("captcha", $captcha); // bisnis proses if (!empty($this->com_user)) { // still login redirect('dashboard/welcome'); } else { $this->smarty->assign("login_st", $status); } // output parent::display(); }
public function captcha() { $this->load->helper('captcha'); $vals = array('img_path' => './runtime/captcha/', 'img_url' => $this->config->item('base_url') . 'runtime/captcha/', 'word' => 'this is captcha', 'img_width' => '300', 'img_height' => '42'); $cap = create_captcha($vals); return $cap['image']; }
function daftar() { $this->load->helper(array('captcha', 'url')); if ($this->input->post() && $this->input->post('secutity_code') == $this->session->userdata('mycaptcha')) { $database = array('user_id' => load_model("akun", "akun_model", "generate_iduser"), 'username' => $this->input->post('username'), 'email' => $this->input->post('email'), 'password' => $this->input->post('password'), 'status_id' => 0, 'no_hp' => $this->input->post('no_hp'), 'alamat' => $this->input->post('alamat')); $this->db->insert('users', $database); echo "<script>alert('Registrasi Berhasil, Silahkan Login!!')</script>"; redirect('akun/masuk', 'refresh'); } else { $this->session->unset_userdata('mycaptcha'); $this->load->helper('captcha'); $vals = array('img_path' => './captcha/', 'img_url' => base_url() . 'captcha/', 'img_width' => '200', 'img_height' => 30, 'border' => 1, 'word_length' => 4, 'pool' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'expiration' => 7200); $cap = create_captcha($vals); if ($this->input->post()) { $this->session->set_userdata('mycaptcha', $cap['word']); $this->session->set_flashdata('message', 'Captcha yang anda masukan salah!!'); } $data_param['image'] = $cap['image']; echo load_controller("web", "web", "web_header", $data_param); echo load_controller("web", "web", "web_open_content", $data_param); echo load_model("akun", "akun_model", "generate_iduser"); $this->load->view("akun/daftar", $data_param); echo load_controller("web", "web", "web_close_content", $data_param); echo load_controller("web", "web", "web_footer", $data_param); } }
/** * 注册生成验证码 * * */ public function yzm_img() { $this->load->helper('captcha'); $vals = array('word' => random_string('alnum', 4), 'img_path' => './views/captcha/', 'img_url' => base_url() . 'views/captcha/', 'font_path' => '././system/fonts/texb.ttf', 'img_width' => 100, 'img_height' => 30, 'expiration' => 3600); $cap = create_captcha($vals); echo $cap['image']; }
public function captcha_refresh() { $values = array('word' => '', 'word_length' => 8, 'img_path' => './images/', 'img_url' => base_url() . 'images/', 'font_path' => base_url() . 'system/fonts/texb.ttf', 'img_width' => '150', 'img_height' => 50, 'expiration' => 3600); $data = create_captcha($values); $_SESSION['captchaWord'] = $data['word']; echo $data['image']; }
public function index() { //$this->rand = substr(number_format(time() * rand(),0,'',''),0,6); $vals = array('word' => 'Random word', 'img_path' => './captcha/', 'img_url' => base_url() . 'captcha/', 'img_width' => '150', 'img_height' => 30, 'expiration' => 7200); $cap = create_captcha($vals); echo $cap['image']; }
public function register() { $vals = array('word' => '', 'img_path' => './captcha/', 'img_url' => 'http://example.com/captcha/', 'font_path' => FCPATH . '/system/fonts/texb.ttf', 'img_width' => '190', 'img_height' => 60, 'expiration' => 7200, 'word_length' => 4, 'font_size' => 30, 'img_id' => 'Imageid', 'pool' => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'colors' => array('background' => array(255, 255, 255), 'border' => array(255, 255, 255), 'text' => array(0, 0, 255), 'grid' => array(255, 40, 40))); $data['country_list'] = $this->Common_model->country_list(); $data['error'] = ""; if ($this->input->post('reg_submit') == "") { $data['captcha_img'] = create_captcha($vals); $_SESSION['captchaWord'] = $data['captcha_img']['word']; } else { $form_data = array('FULL_NAME' => $this->input->post('full_name'), 'COUNTRY_ID' => $this->input->post('country'), 'ZONE_ID' => $this->input->post('city'), 'BIRTHDAY' => $this->input->post('birthdate'), 'MARITAL_STATUS' => $this->input->post('mstat'), 'GENDER' => $this->input->post('sex'), 'ADDRESS' => $this->input->post('address'), 'ZIP' => $this->input->post('zip'), 'EMAIL_ID' => $this->input->post('email'), 'MOBILE' => $this->input->post('mobile'), 'LOG_PASS' => $this->input->post('pass'), 'DATE_CREATED' => date('Y-m-d h:i:s'), 'ACT_CODE' => $this->Common_model->get_code()); if (strcasecmp($_SESSION['captchaWord'], $this->input->post('captcha')) == 0) { $msg = $this->user_model->register($form_data); if ($msg['error'] == "") { redirect(base_url() . 'user/success/' . md5($msg['user_id'])); } else { $data['captcha_img'] = create_captcha($vals); $data['msg'] = "<div class='alert alert-danger alert-dismissable fade in' roll='alert'><button aria-label='Close' data-dismiss='alert' class='close' type='button'><span aria-hidden='true'>x</span></button>" . $msg['error'] . "</div>"; $_SESSION['captchaWord'] = $data['captcha_img']['word']; } } else { $data['captcha_img'] = create_captcha($vals); $data['form_data'] = $form_data; $_SESSION['captchaWord'] = $data['captcha_img']['word']; $data['msg'] = "<div class='alert alert-danger alert-dismissable fade in' roll='alert'><button aria-label='Close' data-dismiss='alert' class='close' type='button'><span aria-hidden='true'>x</span></button>Invalid Captcha</div>"; } } $this->load->view('register', $data); }
public function index() { if ($this->session->userdata('user_islogin')) { redirect(base_url('admin')); } $this->load->helper('captcha'); $vals = array('word' => strtoupper(random_string('alnum', 4)), 'img_path' => './media/captcha/', 'img_url' => base_url() . 'media/captcha/', 'img_width' => '150', 'img_height' => 35, 'expiration' => 720); $data = create_captcha($vals); if ($this->input->post()) { $post = $this->input->post(); #echo sha1($post['user_id'].md5($post['user_id'].$post['user_pass'])); die; $this->_userid = $post['user_id']; $this->_userpass = $post['user_pass']; $this->form_validation->set_rules('captcha', 'Captcha', 'required'); $this->form_validation->set_rules('user_id', 'User Id', 'trim|required|min_length[5]|max_length[8]|xss_clean'); $this->form_validation->set_rules('user_pass', 'Password', 'required|callback_signin_check|xss_clean'); if ($this->form_validation->run('Login') != false) { $this->general->writelog('LOGR', 'Berhasil Login'); redirect(base_url('admin')); } } $data['menu'] = anchor(base_url(), 'Home', 'title="Home"'); $data['nav'] = 'Admin'; $data['sub'] = 'Dashboard'; $data['contain'] = $this->load->View('sample/blank', $data, true); $this->header = $this->load->view('fo/header', $data, true); $this->js = $this->load->view('fo/js', array(), true); $this->load->view('bo/login/index', $data); }
/** * 캡차 세션 생성후 보여주는 함수입니다. */ function show($width = '', $height = '') { $this->output->set_content_type('application/json'); if (!$width) { $width = 150; } if (!$height) { $height = 40; } $img_path = FCPATH . 'uploads/captcha/'; if (!is_dir($img_path)) { @mkdir($img_path, 0755); @chmod($img_path, 0755); $file = $img_path . 'index.php'; $f = @fopen($file, 'w'); @fwrite($f, ''); @fclose($f); @chmod($file, 0644); } $data = array('img_path' => $img_path, 'img_url' => site_url('uploads/captcha') . '/', 'img_width' => $width, 'img_height' => $height, 'font_size' => 15, 'font_path' => './assets/fonts/BreeSerif-Regular.ttf', 'pool' => '23456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ', 'word_length' => '8', 'img_id' => 'captcha'); $cap = create_captcha($data); $save = array('captcha_time' => $cap['time'], 'ip_address' => $this->input->ip_address(), 'word' => $cap['word']); $this->session->set_userdata('captcha', $save); exit(json_encode($cap)); }
/** * 获取验证码 * @return 图片地址的html代码 */ private function _get_cap_image() { $this->load->helper('captcha'); $vals = array('img_path' => './captcha/', 'img_url' => base_url() . 'captcha/', 'font_path' => './system/fonts/texb.ttf', 'img_width' => '100', 'img_height' => 30, 'expiration' => 7200); $cap = create_captcha($vals); $this->session->set_userdata('captcha', $cap['word']); return $cap['image']; }
function create_my_captcha() { $img_url = base_url() . 'captcha/'; $data = array('img_path' => 'captcha/', 'img_url' => $img_url, 'img_width' => '83', 'img_height' => '25', 'font_path' => BASEPATH . 'fonts/texb.ttf'); $return = create_captcha($data); $return["img_url"] = $img_url . $return['time'] . ".jpg"; return $return; }
function createCaptcha() { $cap = array('img_path' => './captcha/', 'img_url' => base_url() . 'captcha/', 'img_width' => '150', 'img_height' => '30', 'expiration' => '7200'); $captchaOutput = create_captcha($cap); $this->ci->session->set_userdata(array('word' => $this->word, 'image' => $captchaOutput['time'] . '.jpg')); //set data to session for compare return $captchaOutput['image']; }
public function captcha() { //configuramos el captcha $conf_captcha = array('word' => $this->rand, 'img_path' => './captcha/', 'img_url' => base_url() . 'captcha/', 'font_path' => './fonts/AlfaSlabOne-Regular.ttf', 'img_width' => '250', 'img_height' => '60', 'expiration' => 600); $cap = create_captcha($conf_captcha); $this->captcha_modelo->insert_captcha($cap); return $cap; }
public function index() { $vals = array('img_path' => './resources/captcha/', 'img_url' => base_url() . '/resources/captcha/'); $data->cap = create_captcha($vals); $captcha = array('captcha_time' => $data->cap['time'], 'ip_address' => $this->input->ip_address(), 'word' => $data->cap['word']); $query = $this->db->insert_string('captcha', $captcha); $this->db->query($query); $this->load->view('/validation/contact_us'); if ($this->form_validation->run() == TRUE) { // First, delete old captchas $expiration = time() - 7200; // Two hour limit $this->db->query("DELETE FROM captcha WHERE captcha_time < " . $expiration); // Then see if a captcha exists: $sql = "SELECT COUNT(*) AS count FROM captcha WHERE word = ? AND ip_address = ? AND captcha_time > ?"; $binds = array($_POST['captcha'], $this->input->ip_address(), $expiration); $query = $this->db->query($sql, $binds); $row = $query->row(); if ($row->count != 0) { $name = $this->input->post('name', TRUE); $sender = $this->input->post('sender', TRUE); $phone = $this->input->post('phone', TRUE); $subject = $this->input->post('subject', TRUE); $message = $this->input->post('message', TRUE); $this->email->from('*****@*****.**', 'Contact Us Form'); //$this->email->to('*****@*****.**'); $this->email->to('*****@*****.**'); $this->email->subject('Contact Form Submitted: ' . $subject); $this->email->message('Contact: ' . $name . ' Message : ' . $message . ' Phone : ' . $phone . ' Email: ' . $sender); $this->email->send(); $this->email->from('*****@*****.**', 'The Law Offices of Richard G. Wendel'); $this->email->to($sender); $this->email->subject('Thank you for contacting us.'); $this->email->message('Dear ' . $name . ', Thank you for contacting us. We will be in touch with you shortly to address your needs. Sincerley, The Law Offices of Richard G. Wendel'); $this->email->send(); $this->session->set_flashdata('message', '<p style="color:green;">Your form has been submitted, a representative will contact you shortly!</p>'); redirect('/contact_us/'); } else { $this->session->set_flashdata('message', '<p style="color:red;">Please try again.</p>'); redirect('/contact_us/'); } } else { $layout->body_class = 'contact'; $layout->content = $this->load->view('contact_us/index', $data, true); //these are the "pieces" of the sidebar you want to load $piece->sb_one = $this->load->view('contact_us/office', null, true); $piece->sb_two = $this->load->view('sidebar/social', null, true); //this is loading all those "pieces" into the view "sidebar/index" so they appear in the order you wanted $layout->sidebar = $this->load->view('sidebar/index', $piece, true); $this->load->view('layouts/html5', $layout); } }
function createCaptcha() { $this->ci->load->helper('captcha'); $code = substr(md5(date("Y-m-d H:i:s") . "h-o-l-y-s-p-i-r-i-t"), 0, 6); $this->ci->session->set_userdata("security_code", $code); $vals = array('word' => $code, 'img_path' => './captcha/', 'img_url' => BASE_URL . '/captcha/', 'font_path' => './captcha/fonts/arial.ttf', 'img_width' => '120', 'img_height' => 30, 'expiration' => 7200); $cap = create_captcha($vals); return $cap['image']; }
function create_img() { $this->load->plugin('captcha'); $this->load->config('config'); $vals = array('img_path' => '/captcha/', 'img_url' => $this->config->item('base_url')); $vals = array('img_path' => './captcha/', 'img_url' => $this->config->item('base_url') . 'captcha/', 'img_width' => '150', 'img_height' => 30, 'expiration' => 50); $cap = create_captcha($vals); echo $cap['image']; }
public function get_captcha($word) { $CI =& get_instance(); $CI->load->helper('captcha'); $vals = array('word' => $word, 'img_path' => $_SERVER["DOCUMENT_ROOT"] . '/assets/images/captcha/', 'img_url' => 'http://www.thebestdealone.local/assets/images/captcha/', 'font_path' => $_SERVER["DOCUMENT_ROOT"] . '/fonts/SIXTY.TTF', 'img_width' => '120', 'img_height' => 30, 'border' => 0, 'expiration' => 7200); // create captcha image $cap = create_captcha($vals); return $cap; }
public function create_captcha() { $data['title'] = '登录页面'; $data['image'] = 'images/login_12.png'; //生成验证码 $vals = array('img_path' => './www/captcha/', 'img_url' => 'http://localhost/www/captcha/', 'img_width' => '120', 'img_height' => 30); $cap = create_captcha($vals); return $cap; }