예제 #1
0
 public function create_validate_code()
 {
     session_start();
     $validate = new ValidateCode(60, 20, 3);
     $_SESSION['check_code'] = $validate->getCheckCode();
     $validate->showImage();
 }
예제 #2
0
 /**
  * 生成验证码
  * Enter description here ...
  */
 function create_Code()
 {
     $_vc = new ValidateCode();
     //实例化一个对象
     $_vc->doimg();
     $this->session->set_userdata('code', $_vc->getCode());
     //验证码保存到SESSION中
 }
예제 #3
0
 public function getAgnomen()
 {
     $this->load->library('session');
     $this->load->library('ValidateCode');
     $_vc = new ValidateCode();
     $_vc->doimg();
     $this->session->set_userdata('authnum_session', $_vc->getCode());
 }
예제 #4
0
 public function captcha()
 {
     import('ORG.Util.ValidateCode');
     $_vc = new ValidateCode();
     //实例化一个对象
     $_vc->doimg();
     $_SESSION['verify'] = strtolower($_vc->getCode());
     //验证码保存到SESSION中
 }
예제 #5
0
파일: User.class.php 프로젝트: hhz1084/pyz
 public function actionLogin()
 {
     $username = isset($_POST['username']) ? trim($_POST['username']) : '';
     $password = isset($_POST['password']) ? trim($_POST['password']) : '';
     $validate = isset($_POST['validate']) ? trim($_POST['validate']) : '';
     if (empty($username) || empty($password) || empty($validate)) {
         $this->location('/', array('error' => '参数错误'));
     }
     if (!ValidateCode::checkCode($validate)) {
         $msg = '验证码错误';
         $this->location('/', array('error' => $msg));
     } else {
         $sql = "SELECT * FROM ha_user WHERE usertype=4 and userstatus=1 and userid='{$username}' and password='******'";
         $data = App::db()->getRow($sql);
         if (!empty($data)) {
             $_SESSION['user'] = $data;
             $_SESSION['is_login'] = 1;
             $code = 200;
             $this->location('/', array('m' => 'main'));
         } else {
             $code = 401;
             $msg = '用户名或密码错误';
             $this->location('/', array('error' => $msg));
         }
     }
 }
예제 #6
0
 /**
  * 输出验证输出处理 
  */
 function doCode()
 {
     import('util.ValidateCode');
     $img = new ValidateCode();
     /** 设置字体文件与临时目录 **/
     $img->font_dir = $this->app->cfg['path']['fonts'];
     $img->temp_dir = $this->app->cfg['path']['temp'];
     $img->session_name = 'VALIDATE_CODE';
     $img->background_color(array('#FEFDCF', '#DFFEFF', '#FFEEE1', '#E1F4FF'));
     $img->grid_color(array('#FAD1AD', '#FFD9FB', '#D1D1E0'));
     $img->text_color(array('#801D00', '#5C0497', '#0289B0'));
     $img->overlap_text(false);
     $img->random_y_factor(4);
     $img->string_length(4);
     $img->frame_number(3);
     $img->frame_delay(80);
     $img->generate();
 }
예제 #7
0
 /**
  * 输出验证码并把验证码的值保存的session中
  * 验证码保存到session的格式为: $_SESSION[self::$seKey] = array('code' => '验证码值', 'time' => '验证码创建时间');
  */
 public static function entry()
 {
     // 图片宽(px)
     self::$imageL || (self::$imageL = self::$length * self::$fontSize * 1.5 + self::$fontSize * 1.5);
     // 图片高(px)
     self::$imageH || (self::$imageH = self::$fontSize * 2);
     // 建立一幅 self::$imageL x self::$imageH 的图像
     self::$_image = imagecreate(self::$imageL, self::$imageH);
     // 设置背景
     imagecolorallocate(self::$_image, self::$bg[0], self::$bg[1], self::$bg[2]);
     // 验证码字体随机颜色
     self::$_color = imagecolorallocate(self::$_image, mt_rand(1, 120), mt_rand(1, 120), mt_rand(1, 120));
     // 验证码使用随机字体
     //$ttf = dirname(__FILE__) . '/ttfs/' . mt_rand(1, 20) . '.ttf';  4
     //dump(dirname(__FILE__));exit;
     $ttf = dirname(__FILE__) . '/fonts/MSYHBD.TTC';
     if (self::$useNoise) {
         // 绘杂点
         self::_writeNoise();
     }
     if (self::$useCurve) {
         // 绘干扰线
         self::_writeCurve();
     }
     // 绘验证码
     $code = array();
     // 验证码
     $codeNX = 0;
     // 验证码第N个字符的左边距
     for ($i = 0; $i < self::$length; $i++) {
         $code[$i] = self::$codeSet[mt_rand(0, 27)];
         $codeNX += mt_rand(self::$fontSize * 1.2, self::$fontSize * 1.6);
         // 写一个验证码字符
         imagettftext(self::$_image, self::$fontSize, mt_rand(-40, 70), $codeNX, self::$fontSize * 1.5, self::$_color, $ttf, $code[$i]);
     }
     // 保存验证码
     isset($_SESSION) || session_start();
     $_SESSION[self::$seKey]['code'] = join('', $code);
     // 把校验码保存到session
     $_SESSION[self::$seKey]['time'] = time();
     // 验证码创建时间
     header('Cache-Control: private, max-age=0, no-store, no-cache, must-revalidate');
     header('Cache-Control: post-check=0, pre-check=0', false);
     header('Pragma: no-cache');
     header("content-type: image/png");
     // 输出图像
     imagepng(self::$_image);
     imagedestroy(self::$_image);
 }
예제 #8
0
파일: pin.php 프로젝트: yu07/Pineapple
<?php

header("content-type:image/png");
session_start();
require_once 'class.ValidateCode.php';
$_vc = new ValidateCode();
//实例化一个对象
$_vc->doimg();
$_SESSION['authnum'] = $_vc->getCode();
//验证码保存到SESSION中
예제 #9
0
        $dictionary = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        for ($i = 0; $i < $strLength; $i++) {
            $this->str .= substr($dictionary, mt_rand(0, strlen($dictionary) - 1), 1);
        }
    }
    public function create()
    {
        $this->handle = imagecreate($this->width, $this->height);
        $backGroudColor = imagecolorallocate($this->handle, 255, 255, 255);
        imagefill($this->handle, 0, 0, $backGroudColor);
        $strColor = imagecolorallocate($this->handle, 0, 0, 0);
        imagestring($this->handle, 30, 10, 0, $this->str, $strColor);
        $this->interferce();
        header("Content-Type:image/png");
        imagepng($this->handle);
    }
    private function interferce()
    {
        for ($i = 0; $i < 3; $i++) {
            $lineColor = imagecolorallocate($this->handle, rand(0, 255), rand(0, 255), rand(0, 255));
            imageline($this->handle, rand(0, 80), rand(0, 20), rand(0, 80), rand(0, 20), $lineColor);
        }
        for ($i = 0; $i < 100; $i++) {
            $pxColor = imagecolorallocate($this->handle, rand(0, 255), rand(0, 255), rand(0, 255));
            imagesetpixel($this->handle, rand(0, 80), rand(0, 20), $pxColor);
        }
    }
}
$validateCode = new ValidateCode();
$_SESSION['code'] = $validateCode->str;
$validateCode->create();
예제 #10
0
 function onget_code()
 {
     require TIPASK_ROOT . '/lib/validatecode/validatecode.class.php';
     //先把类包含进来,实际路径根据实际情况进行修改。
     $_vc = new ValidateCode();
     //实例化一个对象
     $_vc->doimg();
     $_SESSION['code'] = $_vc->getCode();
     //验证码保存到SESSION中
 }
예제 #11
0
파일: yzm.php 프로젝트: byvaio/test1
<?php

require 'ValidateCode.class.php';
session_start();
$_vc = new ValidateCode();
//实例化一个对象
$_vc->doimg();
$_SESSION['yzm'] = $_vc->getCode();
//验证码保存到SESSION中
예제 #12
0
파일: captcha.php 프로젝트: gdutgas/Web4.0
<?php

session_start();
require 'ValidateCode.class.php';
//先把类包含进来,实际路径根据实际情况进行修改。
$_vc = new ValidateCode();
//实例化一个对象
$_vc->doimg();
$_SESSION['authnum_session'] = $_vc->getCode();
//验证码保存到SESSION中
예제 #13
0
<?php

require '../init.inc.php';
$code = new ValidateCode();
$code->Show_Img();
$_SESSION['code'] = $code->Get_Code();
예제 #14
0
<?php

require substr(dirname(__FILE__), 0, -7) . '/init.inc.php';
$_vc = new ValidateCode();
$_vc->doimg();
$_SESSION['code'] = $_vc->getCode();
예제 #15
0
        $y = intval($this->height / 1.3);
        for ($i = 0; $i < $this->lenght; $i++) {
            $color = imagecolorallocate($this->img, mt_rand(10, 100), mt_rand(10, 100), mt_rand(10, 100));
            imagettftext($this->img, $this->fontSize, mt_rand(-40, 40), $x * $i + mt_rand(0, 5), $y, $color, $this->fontfile, $this->code[$i]);
        }
    }
    /**
     * [outPut 向浏览器输出png]
     * @return [image] [输出图片]
     */
    private function outPut()
    {
        header('Content-type:image/png');
        imagepng($this->img);
        imagedestroy($this->img);
    }
    /**
     * [create 生成]
     * @return [type] [description]
     */
    public function create()
    {
        $this->createBg();
        $this->createCode();
        $this->createMix();
        $this->createText();
        $this->outPut();
    }
}
$code = new ValidateCode();
$code->create();
예제 #16
0
<?php

/**
 * @author ChenHaihong
 * @desc 生成验证码图片
 * */
session_start();
require '../ValidateCode.class.php';
//先把类包含进来,实际路径根据实际情况进行修改。
$_vc = new ValidateCode();
//实例化一个对象
$_vc->render();
$_SESSION['auth_code_session'] = $_vc->getCode();
//验证码保存到SESSION中
예제 #17
0
<?php

require '../engine/validatecode.php';
$vc = new ValidateCode('C:/windows/fonts/ARIALUNI.TTF');
$vc->doimg();
예제 #18
0
 /**
  *
  * 验证码 
  */
 function verifCode()
 {
     session_start();
     $this->doNotRenderHeader = 1;
     $vc = new ValidateCode();
     //实例化一个对象
     //$vc->setFonts('BambergOutline-Regular.ttf');
     //$vc->setFonts('sketchy.ttf');
     $vc->getCodeImg();
     $_SESSION['verifCode'] = $vc->getCode();
     //echo $_vc->getInfo();
 }
예제 #19
0
 public function codeAction()
 {
     $this->view->disable();
     $vcode = new ValidateCode();
     $vcode->doimg();
     $this->session->set('code', $vcode->getCode());
 }
<?php

/**
 * 带混淆的验证码
 * @date      2015.10.24
 * @author    pant0
**/
session_start();
$_vc = new ValidateCode();
//实例化一个对象
$_vc->doimg();
$_SESSION['youpzt_captcha'] = $_vc->getCode();
//验证码保存到SESSION中
//验证码类
class ValidateCode
{
    private $charset = 'abcdefghkmnprstuvwxyzABCDEFGHKMNPRSTUVWXYZ23456789';
    //随机因子
    private $code;
    //验证码
    private $codelen = 4;
    //验证码长度
    private $width = 90;
    //宽度
    private $height = 43;
    //高度
    private $img;
    //图形资源句柄
    private $font;
    //指定的字体
    private $fontsize = 20;
예제 #21
0
파일: home.php 프로젝트: s137740/lg
 function validate_code()
 {
     $this->load->library("ValidateCode");
     $_vc = new ValidateCode();
     $_vc->create();
 }
예제 #22
0
 public function validateCode()
 {
     $_vc = new ValidateCode();
     $_vc->doimg();
     $_SESSION['code'] = $_vc->getCode();
 }
예제 #23
0
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with WEIPDCRM.  If not, see <http://www.gnu.org/licenses/>.
 */
session_cache_expire(30);
session_cache_limiter("private");
session_start();
session_regenerate_id(true);
define('ROOT_PATH', dirname(__FILE__));
define('ABSPATH', dirname(ROOT_PATH) . '/');
if (isset($_GET['authpic'])) {
    if (trim($_GET['authpic']) == 'png') {
        define('IN_DCRM', true);
        include_once ABSPATH . 'system/class/validatecode.php';
        $_vc = new ValidateCode();
        $_vc->doimg();
        $_SESSION['VCODE'] = $_vc->getCode();
        exit;
    } else {
        exit;
    }
} else {
    $localetype = 'manage';
    include_once ABSPATH . 'system/common.inc.php';
    header("Cache-Control: no-store");
}
if (!isset($_SESSION['try'])) {
    $_SESSION['try'] = 0;
} elseif (isset($_SESSION['lasttry']) && $_SESSION['lasttry'] + DCRM_LOGINFAILRESETTIME <= time()) {
    $_SESSION['try'] = 0;
예제 #24
0
<?php

require 'captcha.class.php';
session_start();
$vc = new ValidateCode();
$vc->doimg();
$vcodes = $vc->getCode();
//生成验证码图片
Header("Content-type:image/PNG");
$_SESSION['Checknum'] = $vcodes;
예제 #25
0
 function ShowValidCode($id = '')
 {
     foreach ($GLOBALS['Filter_Plugin_Zbp_ShowValidCode'] as $fpname => &$fpsignal) {
         return $fpname($id);
         //*
     }
     $_vc = new ValidateCode();
     $_vc->GetImg();
     setcookie('zbpvalidcode' . md5($this->guid . $id), md5($this->guid . date("Ymd") . $_vc->GetCode()), null, $this->cookiespath);
 }
예제 #26
0
        $gray = imagecolorallocate($im, 118, 151, 199);
        $bgcolor = imagecolorallocate($im, 235, 236, 237);
        //画背景
        imagefilledrectangle($im, 0, 0, $w, $h, $bgcolor);
        //画边框
        imagerectangle($im, 0, 0, $w - 1, $h - 1, $gray);
        //imagefill($im, 0, 0, $bgcolor);
        //在画布上随机生成大量点,起干扰作用;
        for ($i = 0; $i < 80; $i++) {
            imagesetpixel($im, rand(0, $w), rand(0, $h), $black);
        }
        //将字符随机显示在画布上,字符的水平间距和位置都按一定波动范围随机生成
        $strx = rand(3, 8);
        for ($i = 0; $i < $num; $i++) {
            $strpos = rand(1, 6);
            imagestring($im, 5, $strx, $strpos, substr($code, $i, 1), $black);
            $strx += rand(8, 14);
        }
        imagepng($im);
        imagedestroy($im);
    }
    //获取验证码
    public function getCode()
    {
        return strtolower($this->code);
    }
}
$ValidateCode = new ValidateCode();
$ValidateCode->doimg();
session_start();
$_SESSION['authnum_session'] = $ValidateCode->getCode();
<?php

/**
 * Created by PhpStorm.
 * User: lujiejie
 * Date: 15-7-17
 * Time: 下午2:52
 */
//    session_start();
require 'class-validate-code.php';
//先把类包含进来,实际路径根据实际情况进行修改。
$_vc = new ValidateCode();
//实例化一个对象
$_vc->doimg();
//    $_SESSION['authnum_session'] = $_vc->getCode();//验证码保存到SESSION中
예제 #28
0
 /**
  * PAGE: index
  * This method handles what happens when you move to http://yourproject/songs/index
  */
 public function index()
 {
     session_start();
     //require dirname(__DIR__) . '/controller/ValidateCode/ValidateCode.class.php';  //先把类包含进来,实际路径根据实际情况进行修改。
     $_vc = new ValidateCode();
     //实例化一个对象
     $_vc->doimg();
     $_SESSION['authnum_session'] = $_vc->getCode();
     //验证码保存到SESSION中
 }
예제 #29
0
 public function actionGet()
 {
     $v = new ValidateCode();
     $v->doimg();
 }
예제 #30
0
<?php

session_start();
//session_destroy();
if (isset($_GET['check'])) {
    echo $_SESSION['author_code'];
} else {
    require "./ValidateCode.php";
    $vcode = new ValidateCode();
    $vcode->doimg();
    $_SESSION['author_code'] = $vcode->getCode();
}