Bạn ghé thăm diễn đàn lần đầu? hãy đăng ký ngay bây giờ để tham gia.
  • Đăng nhập:

Chào mừng bạn đến với ITVNN FORUM - Diễn đàn công nghệ thông tin.

Nếu đây là lần đầu tiên bạn tham gia diễn đàn, xin mời bạn xem phần Hỏi/Ðáp để biết cách dùng diễn đàn. Để có thể tham gia thảo luận bạn phải đăng ký làm thành viên, click vào đây để đăng ký.


  • Partner Area
    • ITVNN HOSTING - Thiết kế website, Cung cấp Domain, Hosting, VPS Việt Nam Anh Hùng - Thông tin truyền thông
kết quả từ 1 tới 1 trên 1
Tăng kích thước phông chữ Giảm kích thước phông chữ
  1. #1
    hackerstudent's Avatar

    Trạng thái
    Offline
    Họ tên
    Trịnh Quang Huy
    Tham gia ngày
    Sep 2009
    Thành viên thứ
    325
    Đến từ
    HÀ NỘI
    Tuổi
    28
    Giới tính
    Bài gởi
    60
    Level: 31 [?]
    Experience: 321,875
    Next Level: 369,628
    Cảm ơn 0
    Cảm ơn 1 lần / 1 Bài viết

    Default Bác nào biết về captcha thì cho mình hỏi cái này với  

    Mình có 1 trang admincp, hiện tại mình đang muốn làm phần nhập mã xác nhận mới cho đăng nhập. Mình có search trên google và tìm được 1 code captcha nhưng chưa biết phải add vào web của mình ra sao. Bác nào biết thì giúp mình với. Đây là trang admincp/index.php; admincp/login.php; admincp/captcha/CaptchaSecurityImages.php & 1 code nó bảo lưu vào để kiểm tra, các bạn đọc mà biết thì giúp mình với. Cảm ơn trước.

    Index.php
    PHP Code: 
    <?php
    session_start
    ();
    define('IN_TEENNET'true);
    define('IN_TEENNET_ADMIN'true);
    include(
    '../function/config.php');
    include(
    '../function/fun.php');
    include(
    '../function/string.php');
    include(
    '../function/admin_fun.php');
    include(
    '../function/resize.php');
    ?>
    <html>
    <head>
    <title>Trang quan ly</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="style.css" type=text/css>
    <script language="javascript" src="js/admin.js"></script>
    <script language="javascript" src="../js/mudim.js"></script>
    <script language="javascript" src="../js/wysiwyg/wysiwyg.js"></script>
    </head>

    <body>
    <div align="center">
    <?php
    $level 
    $_SESSION['admin_level'];
    if (!
    $level) {
    $error $_GET['error'];
    ?>
    <br>
    <form method="post" action="login.php">
    <table width="25%" cellpadding="2" cellspacing="0" class="table">
        <tr><td colspan="2" align="center" class="t_cat">Đăng nhập AdminCP</td></tr>
        <?php if($error=="u"){ ?>
        <tr><tr><td width="25%" style="padding-top:5px;" align="right"><img src="images/error.gif"></td><td style="padding-top:5px;"><div class="error" style="padding-top:3px;">Sai tài khoản hoặc mật khẩu.</div></td></tr><?php }else{ ?><?php ?>
        <tr><td align="right">Tài khoản:</td><td><input name="user_name" type="text" size="25"></td></tr>
        <tr><td align="right">Mật khẩu:</td><td><input name="user_password" type="password" size="25"><img src="captcha/CaptchaSecurityImages.php?width=100&height=40&characters=5" /><br />
            <label for="security_code">Security Code: </label><input id="security_code" name="security_code" type="text" /></td></tr>
        <tr><td colspan="2" align="center" style="padding-bottom:5px;"><input type="submit" name="submit" class="btndangnhap" value="&nbsp;"></td></tr>
    </table>
    </form>
    <?php
    }
    else{
        
    $link 'index.php';
        if (
    $_SERVER["QUERY_STRING"]) $link .= '?'.$_SERVER["QUERY_STRING"];
    ?>
    <table width="900px" border="0" cellpadding="0" cellspacing="4">
    <tr><td colspan="2" class="banner">Control Panel</td></tr>
    <tr><td width="20%" valign="top">
    <table cellpadding="1" cellspacing="0" border="0" width="100%"><tr><td class="table"><?php include('menu.php'); ?></td></tr><tr><td style="padding-top:5px; padding-left:15px;"><a href="logout.php"><b>Logout</b></a></td></tr></table>
    </td>
    <td width="80%" valign="top">
    <table cellpadding="1" cellspacing="0" border="0" width="100%"><tr><td class="table"><?php include('content.php'); ?></td></tr></table>
    </td></tr>
    <tr><td colspan="2" class="footer">Copyright (c) 2009 by <b>[W]-News</b><br> (<b>WoW-Teen.Com</b>)</td></tr>
    </table>
    <?php
    }
    ?>
    </div>
    </body>
    </html>
    Login.php
    PHP Code: 
    <?php
    session_start
    ();
    define('IN_TEENNET'true);
    include(
    '../function/config.php');
    include(
    "../function/fun.php");
    if (isset(
    $_POST['submit'])) {
        
    $user_name trim($_POST['user_name']);
        
    $user_name str_replace('|''|'$user_name);
        
    $user_password md5(stripslashes($_POST['user_password']));
        
    $q mysql_query("SELECT * FROM ".$table."user WHERE user_name = '".$user_name."' AND user_password = '".$user_password."' AND (user_level = 1 OR user_level = 2)");
        if (
    mysql_num_rows($q)) {
        
    $r mysql_fetch_array($q);
            
    $_SESSION['admin_id'] = $r['user_id'];
            
    $_SESSION['admin_level'] = $r['user_level'];
            echo 
    "<meta http-equiv='refresh' content='0;url=index.php'>";
        }
        else {echo 
    "<meta http-equiv='refresh' content='0;url=index.php?error=u'>";
        }
    }
    ?>
    CaptchaSecurityImages.php
    PHP Code: 
    <?php
    session_start
    ();

    /*
    * File: CaptchaSecurityImages.php
    * Author: Simon Jarvis
    * Copyright: 2006 Simon Jarvis
    * Date: 03/08/06
    * Updated: 07/02/07
    * Requirements: PHP 4/5 with GD and FreeType libraries
    * Link: http://www.white-hat-web-design.co.uk/articles/php-captcha.php

    * This program is free software; you can redistribute it and/or 
    * modify it under the terms of the GNU General Public License 
    * as published by the Free Software Foundation; either version 2 
    * of the License, or (at your option) any later version.

    * This program is distributed in the hope that it will be useful, 
    * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
    * GNU General Public License for more details: 
    * http://www.gnu.org/licenses/gpl.html
    *
    */

    class CaptchaSecurityImages {

        var 
    $font 'monofont.ttf';

        function 
    generateCode($characters) {
            
    /* list all possible characters, similar looking characters and vowels have been removed */
            
    $possible '23456789bcdfghjkmnpqrstvwxyz';
            
    $code '';
            
    $i 0;
            while (
    $i $characters) { 
                
    $code .= substr($possiblemt_rand(0strlen($possible)-1), 1);
                
    $i++;
            }
            return 
    $code;
        }

        function 
    CaptchaSecurityImages($width='120',$height='40',$characters='6') {
            
    $code $this->generateCode($characters);
            
    /* font size will be 75% of the image height */
            
    $font_size $height 0.75;
            
    $image = @imagecreate($width$height) or die('Cannot initialize new GD image stream');
            
    /* set the colours */
            
    $background_color imagecolorallocate($image255255255);
            
    $text_color imagecolorallocate($image2040100);
            
    $noise_color imagecolorallocate($image100120180);
            
    /* generate random dots in background */
            
    for( $i=0$i<($width*$height)/3$i++ ) {
                
    imagefilledellipse($imagemt_rand(0,$width), mt_rand(0,$height), 11$noise_color);
            }
            
    /* generate random lines in background */
            
    for( $i=0$i<($width*$height)/150$i++ ) {
                
    imageline($imagemt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
            }
            
    /* create textbox and add text */
            
    $textbox imagettfbbox($font_size0$this->font$code) or die('Error in imagettfbbox function');
            
    $x = ($width $textbox[4])/2;
            
    $y = ($height $textbox[5])/2;
            
    imagettftext($image$font_size0$x$y$text_color$this->font $code) or die('Error in imagettftext function');
            
    /* output captcha image to browser */
            
    header('Content-Type: image/jpeg');
            
    imagejpeg($image);
            
    imagedestroy($image);
            
    $_SESSION['security_code'] = $code;
        }

    }

    $width = isset($_GET['width']) ? $_GET['width'] : '120';
    $height = isset($_GET['height']) ? $_GET['height'] : '40';
    $characters = isset($_GET['characters']) && $_GET['characters'] > $_GET['characters'] : '6';

    $captcha = new CaptchaSecurityImages($width,$height,$characters);

    ?>
    Mã kiểm tra:
    PHP Code: 
     <?php 
       session_start
    ();
       if((
    $_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) ) {
          
    // Insert you code for processing the form here, e.g emailing the submission, entering it into a database. 
          
    unset($_SESSION['security_code']);
       } else {
          
    // Insert your code for showing an error message here
       
    }
    ?>


 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Trả lời: 0
    Bài mới gởi: 31-08-2021, 12:12 PM
  2. Trả lời: 1
    Bài mới gởi: 03-12-2012, 05:54 PM
  3. Xin mod Enhanced Captcha Image Verification.zip cho vbb4
    By hoangduykt7990 in forum Hỏi đáp & Thảo luận
    Trả lời: 1
    Bài mới gởi: 26-06-2011, 01:13 PM
  4. Captcha C# ASP.Net source
    By cuongtm in forum Lập trình web
    Trả lời: 2
    Bài mới gởi: 13-11-2010, 06:21 PM
  5. Captcha C# ASP.Net source
    By cuongtm in forum .NET
    Trả lời: 1
    Bài mới gởi: 21-07-2010, 12:36 AM

Tags for this Thread

Bookmarks

Quuyền Hạn Của Bạn

  • Bạn không thể tạo chủ đề mới
  • Bạn không thể trả lời bài viết
  • Bạn không thể gửi file đính kèm
  • Bạn không thể chỉnh sửa bài viết
  •