国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

directory search
Array Array Helper Benchmarking Benchmarking Class Caching Caching Driver Calendaring Calendaring Class CAPTCHA CAPTCHA Helper Config Config Class Cookie Cookie Helper Database Connecting to your Database Custom Function Calls Database Caching Class Database Configuration Database Forge Class Database Metadata Database Quick Start: Example Code Database Reference Database Utility Class DB Driver Reference Generating Query Results Queries Query Builder Class Query Helper Methods Transactions Date Date Helper Directory Directory Helper Download Download Helper Email Email Class Email Helper Encrypt Encrypt Class Encryption Encryption Library File File Helper File Uploading File Uploading Class Form Form Helper Form Validation Form Validation FTP FTP Class Functions compatibility_functions common_functions HTML HTML Helper HTML Table HTML Table Class Image Manipulation Image Manipulation Class Inflector Inflector Helper Input Input Class Javascript Javascript Class Language Language Class Language Helper Loader Loader Class Migrations Migrations Class Number Number Helper Output Output Class Pagination Pagination Class Path Path Helper Security Security Class Security Helper Session Session Library Shopping Cart Shopping Cart Class Smiley Smiley Helper String String Helper Template Parser Template Parser Class Text Text Helper Trackback Trackback Class Typography Typography Class Typography Helper Unit Testing Unit Testing Class URI URL User Agent XML XML-RPC and XML-RPC Server Zip Encoding Zip Encoding Class XML-RPC and XML-RPC Server Classes XML Helper User Agent Class URL Helper URI Class
characters

CAPTCHA幫助程序文件包含幫助創(chuàng)建CAPTCHA圖像的功能。

  • 加載這個幫手

  • 使用CAPTCHA助手

    • 添加數(shù)據(jù)庫

  • 可用功能

加載這個幫手

這個幫助器使用下面的代碼加載:

$this->load->helper('captcha');

使用CAPTCHA助手

一旦加載,你可以生成這樣的驗證碼:

$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,        
'word_length'   => 8,        
'font_size'     => 16,        
'img_id'        => 'Imageid',        
'pool'          => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',        
// White background and border, black text and red grid        
'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'];
  • 驗證碼功能需要GD圖像庫。

  • 只有img_pathimg_url是必需的。

  • 如果沒有提供一個單詞,該函數(shù)將生成一個隨機的ASCII字符串。你可以把你自己的詞庫放在一起,你可以從中隨機抽取。

  • 如果不指定TRUE TYPE字體的路徑,則將使用本機丑陋的GD字體。

  • “captcha”目錄必須是可寫的

  • 到期(秒)表示的圖像將多久保留在驗證碼文件夾之前將被刪除。默認值是兩個小時。

  • word_length默認為8,默認為'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'

  • font_size默認為16,原生GD字體的大小限制。指定更大尺寸的“真實類型”字體。

  • img_id將被設置為驗證碼圖像的“身份證”。

  • 如果任何顏色值丟失,它將被替換為默認值。

添加數(shù)據(jù)庫

為了使驗證碼功能防止某人提交,您需要添加從create_captcha()數(shù)據(jù)庫返回的信息。然后,當用戶提交表單中的數(shù)據(jù)時,您需要驗證數(shù)據(jù)是否存在于數(shù)據(jù)庫中并且沒有過期。

這是一個表格原型:

CREATE TABLE captcha (
        captcha_id bigint(13) unsigned NOT NULL auto_increment,
        captcha_time int(10) unsigned NOT NULL,
        ip_address varchar(45) NOT NULL,
        word varchar(20) NOT NULL,
        PRIMARY KEY `captcha_id` (`captcha_id`),
        KEY `word` (`word`));

這是一個數(shù)據(jù)庫使用的例子。在顯示CAPTCHA的頁面上,您會看到如下所示的內(nèi)容:

$this->load->helper('captcha');
$vals = array(        
'img_path'      => './captcha/',        
'img_url'       => ' 
$cap = create_captcha($vals);
$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);
echo 'Submit the word you see below:';
echo $cap['image'];
echo '<input type="text" name="captcha" value="" />';

然后,在接受提交的頁面上,您將擁有如下所示的內(nèi)容:

// First, delete old captchas
$expiration = time() - 7200; 
// Two hour limit
$this->db->where('captcha_time < ', $expiration)->delete('captcha');
// 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){
        echo 'You must submit the word that appears in the image.';
        }

可用功能

以下功能可用:

create_captcha([$data = ''[, $img_path = ''[, $img_url = ''[, $font_path = '']]]])

參數(shù):

$ data(array) - 用于CAPTCHA的數(shù)據(jù)數(shù)組$ img_path(字符串) - 在$ img_url中創(chuàng)建圖像的路徑(字符串) -  CAPTCHA圖像文件夾的URL $ font_path(字符串) - 字體的服務器路徑

返回:

數(shù)組('word'=> $ word,'time'=> $ now,'image'=> $ img)

返回類型:

排列

  • $ dataarray) -  CAPTCHA的數(shù)據(jù)數(shù)組

  • $ img_path字符串) - 在中創(chuàng)建圖像的路徑

  • $ img_url字符串) -  CAPTCHA圖像文件夾的URL

  • $ font_path字符串) - 字體的服務器路徑

Returns:  array(‘word’ => $word, ‘time’ => $now, ‘image’ => $img)
返回類型:數(shù)組
獲取一系列信息以生成CAPTCHA作為輸入,并根據(jù)您的規(guī)范創(chuàng)建圖像,并返回關于圖像的一組關聯(lián)數(shù)據(jù)。

array(         'image' => IMAGE TAG         'time'  => TIMESTAMP (in microtime)         'word'  => CAPTCHA WORD )

圖像是實際的圖像標簽:

<img src =“http://example.com/captcha/12345.jpg”width =“140”height =“50”/>

時間是用作不文件擴展名的圖像名稱微時間戳。這將是一個這樣的數(shù)字:1139612155.3422

是在出現(xiàn)的驗證碼圖像,其中,如果未提供的功能,可以是隨機字符串中的字。

Previous article: Next article: