captcha fehlermeldung! readdir()

Hier werden Probleme rund um das Zahlen Captcha behandelt

Moderator: frameguard

captcha fehlermeldung! readdir()

Beitragvon Balg » 17.05.2007, 22:32

HeyHo Kollegen

bei mir kommt folgende fehlemedung:
Warning: readdir(): supplied argument is not a valid Directory resource in C:\Programme\xampp\htdocs\huch\gbdata\captcha\captcha_check.php on line 53
Eingabe falsch

Code wäre hier:
Code: Alles auswählen
<?php

/**
*   Captcha Bild Überprüfung
*
*   Systemvoraussetzung:
*   Linux, Windows
*    PHP 4 >= 4.0.0-RC2 , PHP 5
*   GD-Bibliothek ( > gd-1.6 )
*   FreeType-Bibliothek
*
*   Prüft ein Captcha-Bild
*
*    LICENSE: GNU General Public License (GPL)
*   This program is free software; you can redistribute it and/or modify
*   it under the terms of the GNU General Public License version 2,
*   as published by the Free Software Foundation.
*
*   @category   Captcha
*   @author     Damir Enseleit <info@selfphp.de>
*   @copyright  2001-2006 SELFPHP
*   @version    $Id: captcha_check.php,v 0.10 2006/04/07 13:15:30 des1 Exp $
*   @link       http://www.selfphp.de
*/

/**
* Prüft ein Captcha-Bild
*
* @param      string      $codeCaptcha         Hash-Wert
* @param      string      $stringCaptcha      Eingabe durch den User
* @param      string     $dir                     Das Verzeichnis mit den Captcha-Bilder
* @param      integer      $delFile               Die Zeit in Minuten, nachdem ein Captcha-Bild gelöscht wird
*
* @return   bool                                    TRUE / FALSE         
*/


function CheckCaptcha($codeCaptcha,$stringCaptcha,$dir,$delFile=5)
{

   // Setzt den Check erst einmal auf FALSE
   $captchaTrue = FALSE;
   
   // Übergebene Hash-Variable überprüfen
   if(!preg_match('/^[a-f0-9]{32}$/',$codeCaptcha))
      return FALSE;
   
   // Übergebene Captcha-Variable überprüfen
   if(!preg_match('/^[a-zA-Z0-9]{1,6}$/',$stringCaptcha))
      return FALSE;
   
   $handle = @opendir($dir);
   while (false !== ($file = readdir($handle))) !!!zeile mit dem Fehler!!!
  {
      if (preg_match("=^\.{1,2}$=", $file))
    {
       continue;
    }
   
    if (is_dir($dir.$file))
    {
       continue;
    }
    else
    {
       $lastTime = ceil((time() - filemtime($dir.$file)) / 60);
       if($lastTime > $delFile)
       {
          unlink($dir.$file);
       }
       else{
          if(strtolower($file) == strtolower($codeCaptcha.'_'.$stringCaptcha.'.png'))
          {
             $captchaTrue = TRUE;
          } 
          if (preg_match("=^$codeCaptcha=i", $file))
          {
             unlink($dir.$file);
          }
        }
    }
   }   

   @closedir($handle);

   if ($captchaTrue)
      return TRUE;
   else
      return FALSE;

}


// Temporäres Verzeichnis der Captcha-Bilder
$Captchadir = 'huchcaptch/';

// Löschen der alten Captcha-Bilder nach wieviel Minuten
$delFile = 10;

// Überprüfung starten
$resultCaptcha = CheckCaptcha($_POST["codeCaptcha"],$_POST["stringCaptcha"],$captchaDir,$delFile);

?>


ich komme wirklich nicht weiter und drehe langsam durch. kann etwas am server nicht stimmen, irgendwelche rechte?
das script habe ich im übrigen von: http://www.selfphp.info/kochbuch/kochbuch.php?code=22
vielen dank![/b]
Balg
 
Beiträge: 1
Registriert: 17.05.2007, 22:24

Beitragvon frameguard » 18.05.2007, 00:47

Sorry, aber da find ich den Fehler auch nicht. Wird @opendir (eine Zeile vorher) überhaupt korrekt durchgeführt, sprich, ist der übergebene Parameter $dir korrekt?
frameguard
 
Beiträge: 120
Registriert: 05.03.2007, 19:19
Wohnort: Wien

Beitragvon garfield » 29.05.2007, 21:51

Hallo Balg,

nur ein kleiner und gemeiner Tippfehler...

$Captchadir = 'huchcaptch/';
.
.
.
$resultCaptcha = CheckCaptcha($_POST["codeCaptcha"],$_POST["stringCaptcha"],$captchaDir,$delFile);


Hoffe hilft weiter...

wenn nicht, nochmal posten

MFG
garfield
garfield
 
Beiträge: 4
Registriert: 29.05.2007, 21:45


Zurück zu Zahlen Captcha

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 0 Gäste

cron