Ergebnis 1 bis 10 von 10

Baum-Darstellung

  1. #1
    Anfänger
    Registriert seit
    23.11.2011
    Beiträge
    10

    Standard PHP Captcha Script ohne MYSQL

    Ich hab mal ein kleines Formular mit captcha abfrage programmiert.
    Die captcha wird errechnet aus der ip adresse und wie multipliziert mit einer random zahl.
    Ist ganz praktisch wenn man keine lust hat mit datenbanken etc zu arbeiten.
    Ihr solltet ne font ".ttf" im ordner haben und die zeile var $font = 'monofont.ttf'; dann entsprechend ersetzen.
    Funktioniert nicht auf jedem Webspace da irgendwelche gdi bzw sachen aktiviert sein müssen viel spaß!


    sehe grad dass der code hier im forum buggy angezeigt wird hier richtig :
    http://pastebin.com/iceXxdm7


    PHP-Code:
    <?php
    $multiplikator 
    rand(1001000);


    function 
    styler() {
    ?><style> body {color:white;text-shadow:0 1px 0 rgba(0, 0, 0, 0.5);font-family:arial;font-size:12px !important;}
    input {background:none repeat scroll 0 0 rgba(0, 0, 0, 0.25);border:0;color:white;text-shadow:0 1px 0 rgba(0, 0, 0, 0.5);} 
    td {color:white;font-size:11px}
    .two {box-shadow: 0 0 4px 0 rgba(255, 255, 255, 0.4);border:0;background:none repeat scroll 0 0 rgba(0, 0, 0, 0.25);color:rgba(255,255,255,0.88);font-family:arial;text-shadow:0 1px 0 rgba(0, 0, 0, 0.5);}
    img {background:rgba(0,0,0,0.7);position:relative;top:4px;left:2px;}
     </style><?php
    }

    if(isset(
    $_GET["img"])) {} else { if(isset($_GET["write"])) {} else {  styler();
    ?><form name="input" action="?write=1&code=<?php echo $multiplikator?>" method="post">
    <table><tr><td>
    Titel :</td><td> <input style="width:570px;" type="text" name="title"></td></tr><tr><td>
    <br>Beschreibung : </td><td><TEXTAREA type="text" class="two" style="height:200px;width:570px;" name="desc"></TEXTAREA></td></tr><tr><td>
    <br>Embedcode/Filehoster : </td><td><TEXTAREA class="two" type="text" style="height:200px;width:570px;" name="hoster"></TEXTAREA></td></tr><tr><td>
    <br>Bild url : </td><td><input style="width:570px;" type="text" name="image"></td></tr><tr><td>
    <br>captcha Code: </td><td><input type="text" name="captcha"><?php echo "<img src=?img=$multiplikator>"?></td></tr><tr><td>
    <br>Optional Uploader Name: </td><td><input type="text" name="namer"></td></tr><tr><td>
    <br><input type="submit" value="Eintragen" /></td></tr>
    </tr></table></form>
    <?php
    }}
    if(isset(
    $_GET["write"]) and isset($_GET["code"])) {
    styler();
    if(
    strlen($_POST["image"]) > and strlen($_POST["captcha"]) > and strlen($_POST["hoster"]) > and strlen($_POST["desc"]) > 0  and strlen($_POST["title"]) > 0) {
    $captcha_input $_POST["captcha"];
    if (
    is_numeric($captcha_input)) { //CHECK CAPTCHA
    $code "1"$multiplikator =$_GET["code"];
            
    $code .= $multiplikator substr(ereg_replace("\."""$_SERVER['REMOTE_ADDR']),1,2);
    if (
    $code == $captcha_input) { //CAPTCHA RICHTIG -->eintragen

    $timestamp time();$datum date("d_m_Y",$timestamp);$uhrzeit date("H_i_s",$timestamp);
    $datei fopen("$datum.$uhrzeit.txt","a+");

    rewind($datei);
    fwrite($datei$_POST["title"]."\n\n\n------------".$_POST["desc"]."\n\n------------".$_POST["hoster"]."\n\n------------".$_POST["image"]."\n\n------------".$_POST["namer"]);
    fclose($datei);
    echo 
    "Danke für deinen Eintrag! Er wird in kürze überprüft..";
    } else {echo 
    "falsche Captcha eingabe!";}


    } else {echo 
    "falsche Captcha eingabe!";}

    }
    else {
    echo 
    "Unvollständig!";
    }
    }

    ?><?php 
    if(isset($_GET["img"])) {

    class 
    CaptchaSecurityImages {

        var 
    $font 'monofont.ttf';

        function 
    CaptchaSecurityImages($width='120',$height='30',$characters='6') {$zufallszahl rand(1000100000);
            
    $code "1"$multiplikator =$_GET["img"];
            
    $code .= $multiplikator substr(ereg_replace("\."""$_SERVER['REMOTE_ADDR']),1,2);//$this->generateCode($characters);

       
    $imgA imagecreate(9018);
     
    // $colorA['lime'] = imagecolorallocate($imgA, 0x00, 0xFF, 0x00);
      
    $colorA['red'] = imagecolorallocate($imgA0x000x000x00);
       
    $colorA =ImageColorAllocate($imgA757575); 
       
    $ttfA "monofont.ttf"
       
    $ttfsizeA 20;
       
    $angleA =rand(0,5); 
       
    $t_xA 0;rand(5,30); 
       
    $t_yA 20
       
    imagettftext($imgA$ttfsizeA$angleA$t_xA$t_yA$colorA$ttfA$code); 
       
    imagecolortransparent($imgA$colorA['red']);
      
    header("Content-type: image/png");
        
    imagepng($imgA);
      
    //  imagedestory($imgA);

        
    }
    }
    $captcha = new CaptchaSecurityImages(20323);
    }
    ?>
    Geändert von Collapz (16.12.2011 um 01:39 Uhr)

Ähnliche Themen

  1. [S] Gästebuch ohne php & mysql
    Von boehser enkel im Forum (X)HTML & CSS
    Antworten: 10
    Letzter Beitrag: 28.07.2009, 03:53
  2. Script-Baze ll UndergroundImagez ll Script-load hacked !
    Von gf0x im Forum Globale News / Szene News
    Antworten: 3
    Letzter Beitrag: 17.04.2009, 12:39
  3. Php Mysql script:?
    Von Topmaster im Forum PHP
    Antworten: 2
    Letzter Beitrag: 18.12.2007, 05:22
  4. PHP Script für Auslesung von MySql Daten
    Von dokdobler im Forum PHP
    Antworten: 0
    Letzter Beitrag: 06.10.2007, 22:29

Stichworte

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •