本文整理汇总了PHP中create_captcha函数的典型用法代码示例。如果您正苦于以下问题:PHP create_captcha函数的具体用法?PHP create_captcha怎么用?PHP create_captcha使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_captcha函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
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'));
}
}
示例2: register
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');
}
}
示例3: get_captcha
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'];
}
示例4: index
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);
}
示例5: index
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);
}
}
示例6: setCaptchaDBEntry
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);
}
示例7: captcha_helper
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'];
}
示例8: index
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);
}
}
示例9: index
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');
}
示例10: disclaimer
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();
}
示例11: index
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);
}
示例12: url
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');
}
示例13: index
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();
}
示例14: captcha
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'];
}
示例15: daftar
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);
}
}