亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

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圖像的功能。

  • 加載這個(gè)幫手

  • 使用CAPTCHA助手

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

  • 可用功能

加載這個(gè)幫手

這個(gè)幫助器使用下面的代碼加載:

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

使用CAPTCHA助手

一旦加載,你可以生成這樣的驗(yàn)證碼:

$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'];
  • 驗(yàn)證碼功能需要GD圖像庫(kù)。

  • 只有img_pathimg_url是必需的。

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

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

  • “captcha”目錄必須是可寫(xiě)的

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

  • word_length默認(rèn)為8,默認(rèn)為'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'

  • font_size默認(rèn)為16,原生GD字體的大小限制。指定更大尺寸的“真實(shí)類(lèi)型”字體。

  • img_id將被設(shè)置為驗(yàn)證碼圖像的“身份證”。

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

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

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

這是一個(gè)表格原型:

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`));

這是一個(gè)數(shù)據(jù)庫(kù)使用的例子。在顯示CAPTCHA的頁(yè)面上,您會(huì)看到如下所示的內(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="" />';

然后,在接受提交的頁(yè)面上,您將擁有如下所示的內(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(字符串) - 字體的服務(wù)器路徑

返回:

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

返回類(lèi)型:

排列

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

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

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

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

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

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

圖像是實(shí)際的圖像標(biāo)簽:

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

時(shí)間是用作不文件擴(kuò)展名的圖像名稱(chēng)微時(shí)間戳。這將是一個(gè)這樣的數(shù)字:1139612155.3422

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

Previous article: Next article: