当前位置: 首页>>代码示例>>PHP>>正文


PHP code_generic函数代码示例

本文整理汇总了PHP中code_generic函数的典型用法代码示例。如果您正苦于以下问题:PHP code_generic函数的具体用法?PHP code_generic怎么用?PHP code_generic使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了code_generic函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: display

 public function display()
 {
     if (isset($_GET['action']) && esc_html($_GET['action']) == 'formmakerwdcaptcha') {
         $i = isset($_GET["i"]) ? esc_html($_GET["i"]) : '';
         $r2 = isset($_GET["r2"]) ? (int) $_GET["r2"] : 0;
         $rrr = isset($_GET["rrr"]) ? (int) $_GET["rrr"] : 0;
         $randNum = 0 + $r2 + $rrr;
         $digit = isset($_GET["digit"]) ? (int) $_GET["digit"] : 6;
         $cap_width = $digit * 10 + 15;
         $cap_height = 26;
         $cap_quality = 100;
         $cap_length_min = $digit;
         $cap_length_max = $digit;
         $cap_digital = 1;
         $cap_latin_char = 1;
         function code_generic($_length, $_digital = 1, $_latin_char = 1)
         {
             $dig = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
             $lat = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
             $main = array();
             if ($_digital) {
                 $main = array_merge($main, $dig);
             }
             if ($_latin_char) {
                 $main = array_merge($main, $lat);
             }
             shuffle($main);
             $pass = substr(implode('', $main), 0, $_length);
             return $pass;
         }
         $l = rand($cap_length_min, $cap_length_max);
         $code = code_generic($l, $cap_digital, $cap_latin_char);
         if (session_id() == '' || function_exists('session_status') && session_status() == PHP_SESSION_NONE) {
             @session_start();
         }
         $_SESSION[$i . '_wd_captcha_code'] = md5($code);
         $canvas = imagecreatetruecolor($cap_width, $cap_height);
         $c = imagecolorallocate($canvas, rand(150, 255), rand(150, 255), rand(150, 255));
         imagefilledrectangle($canvas, 0, 0, $cap_width, $cap_height, $c);
         $count = strlen($code);
         $color_text = imagecolorallocate($canvas, 0, 0, 0);
         for ($it = 0; $it < $count; $it++) {
             $letter = $code[$it];
             imagestring($canvas, 6, 10 * $it + 10, $cap_height / 4, $letter, $color_text);
         }
         for ($c = 0; $c < 150; $c++) {
             $x = rand(0, $cap_width - 1);
             $y = rand(0, 29);
             $col = '0x' . rand(0, 9) . '0' . rand(0, 9) . '0' . rand(0, 9) . '0';
             imagesetpixel($canvas, $x, $y, $col);
         }
         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
         header('Cache-Control: no-store, no-cache, must-revalidate');
         header('Cache-Control: post-check=0, pre-check=0', FALSE);
         header('Pragma: no-cache');
         header('Content-Type: image/jpeg');
         imagejpeg($canvas, NULL, $cap_quality);
     }
     die('');
 }
开发者ID:RA2WP,项目名称:RA2WP,代码行数:60,代码来源:FMViewFormmakerwdcaptcha.php

示例2: array

{
    $dig = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
    $lat = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
    $main = array();
    if ($_digital) {
        $main = array_merge($main, $dig);
    }
    if ($_latin_char) {
        $main = array_merge($main, $lat);
    }
    shuffle($main);
    $pass = substr(implode('', $main), 0, $_length);
    return $pass;
}
$l = rand($cap_length_min, $cap_length_max);
$code = code_generic($l, $cap_digital, $cap_latin_char);
@session_start();
$_SESSION[$i . '_wd_captcha_code'] = $code;
$canvas = imagecreatetruecolor($cap_width, $cap_height);
$c = imagecolorallocate($canvas, rand(150, 255), rand(150, 255), rand(150, 255));
imagefilledrectangle($canvas, 0, 0, $cap_width, $cap_height, $c);
$count = strlen($code);
$color_text = imagecolorallocate($canvas, 0, 0, 0);
for ($it = 0; $it < $count; $it++) {
    $letter = $code[$it];
    imagestring($canvas, 6, 10 * $it + 10, $cap_height / 4, $letter, $color_text);
}
for ($c = 0; $c < 150; $c++) {
    $x = rand(0, $cap_width - 1);
    $y = rand(0, 29);
    $col = '0x' . rand(0, 9) . '0' . rand(0, 9) . '0' . rand(0, 9) . '0';
开发者ID:roycocup,项目名称:enclothed,代码行数:31,代码来源:wd_captcha.php

示例3: spider_catalog_wd_captcha

function spider_catalog_wd_captcha()
{
    $cap_width = 80;
    $cap_height = 30;
    $cap_quality = 100;
    $cap_length_min = 6;
    $cap_length_max = 6;
    $cap_digital = 1;
    $cap_latin_char = 1;
    function code_generic($_length, $_digital = 1, $_latin_char = 1)
    {
        $dig = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
        $lat = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
        $main = array();
        if ($_digital) {
            $main = array_merge($main, $dig);
        }
        if ($_latin_char) {
            $main = array_merge($main, $lat);
        }
        shuffle($main);
        $pass = substr(implode('', $main), 0, $_length);
        return $pass;
    }
    if (isset($_GET['checkcap']) == '1') {
        if ($_GET['checkcap'] == '1') {
            @session_start();
            if (isset($_GET['cap_code'])) {
                if ($_GET['cap_code'] == $_SESSION['captcha_code']) {
                    echo 1;
                }
            } else {
                echo 0;
            }
        }
    } else {
        $l = rand($cap_length_min, $cap_length_max);
        $code = code_generic($l, $cap_digital, $cap_latin_char);
        @session_start();
        $_SESSION['captcha_code'] = $code;
        $canvas = imagecreatetruecolor($cap_width, $cap_height);
        $c = imagecolorallocate($canvas, rand(150, 255), rand(150, 255), rand(150, 255));
        imagefilledrectangle($canvas, 0, 0, $cap_width, $cap_height, $c);
        $count = strlen($code);
        $color_text = imagecolorallocate($canvas, 0, 0, 0);
        for ($it = 0; $it < $count; $it++) {
            $letter = $code[$it];
            imagestring($canvas, 6, 10 * $it + 10, $cap_height / 4, $letter, $color_text);
        }
        for ($c = 0; $c < 150; $c++) {
            $x = rand(0, 79);
            $y = rand(0, 29);
            $col = '0x' . rand(0, 9) . '0' . rand(0, 9) . '0' . rand(0, 9) . '0';
            imagesetpixel($canvas, $x, $y, $col);
        }
        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
        header('Cache-Control: no-store, no-cache, must-revalidate');
        header('Cache-Control: post-check=0, pre-check=0', false);
        header('Pragma: no-cache');
        header('Content-Type: image/jpeg');
        imagejpeg($canvas, null, $cap_quality);
    }
    die('');
}
开发者ID:Kennytroll,项目名称:partsbeta,代码行数:64,代码来源:catalog.php


注:本文中的code_generic函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。