captcha werkt niet
ik heb een beveiliging voor een formuliertje (niet zelf geschreven, maar van iemand anders. Die heeft hem denk ik ergens van internet gehaald).
hiermee roep ik hem aan:
Code (php)
in de construct functie van Securimage() staat niks.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
function check($code)
{
$this->code_entered = $code;
$this->validate();
return $this->correct_code;
}
function validate()
{
if ( isset($_SESSION['securimage_code_value']) && !empty($_SESSION['securimage_code_value']) ) {
if ( $_SESSION['securimage_code_value'] == strtolower(trim($this->code_entered)) ) {
$this->correct_code = true;
$_SESSION['securimage_code_value'] = '';
} else {
$this->correct_code = false;
}
} else {
$this->correct_code = false;
}
}
?>
function check($code)
{
$this->code_entered = $code;
$this->validate();
return $this->correct_code;
}
function validate()
{
if ( isset($_SESSION['securimage_code_value']) && !empty($_SESSION['securimage_code_value']) ) {
if ( $_SESSION['securimage_code_value'] == strtolower(trim($this->code_entered)) ) {
$this->correct_code = true;
$_SESSION['securimage_code_value'] = '';
} else {
$this->correct_code = false;
}
} else {
$this->correct_code = false;
}
}
?>
Nu is het zo dat $valid steevast false teruggeeft, ongeacht de invoer.
Hoe kan dit komen? Heeft iemand ervaring met zulke dingen?
Gewijzigd op 19/07/2010 13:11:40 door Niek van Milligen
je returnt nu de code die hij eerder via de POST meekrijgt
edit: stukje voorbeeld:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
function check($code)
{
$this->code_entered = $code;
return $this->validate();
}
function validate()
{
if ( isset($_SESSION['securimage_code_value']) && !empty($_SESSION['securimage_code_value']) ) {
if ( $_SESSION['securimage_code_value'] == strtolower(trim($this->code_entered)) ) {
return true;
$_SESSION['securimage_code_value'] = '';
} else {
return false;
}
} else {
return false;
}
}
?>
function check($code)
{
$this->code_entered = $code;
return $this->validate();
}
function validate()
{
if ( isset($_SESSION['securimage_code_value']) && !empty($_SESSION['securimage_code_value']) ) {
if ( $_SESSION['securimage_code_value'] == strtolower(trim($this->code_entered)) ) {
return true;
$_SESSION['securimage_code_value'] = '';
} else {
return false;
}
} else {
return false;
}
}
?>
Gewijzigd op 19/07/2010 13:34:12 door Mick ForSure
Vervolgens kijkt validate() naar: if ( $_SESSION['securimage_code_value'] == strtolower(trim($this->code_entered)) )
Zo ja: $this->correct_code = true
Zo nee: $this->correct_code = false
Hij returnt vervolgens $this->correct_code en dus niet $this->code_entered
@Mick ForSure:
werkt ook niet. Ik ben er inmiddels achter dat hij bij het schrijven van de image helemaal de waarde niet in de sessie zet.
Ik zet het plaatje zo op de site:
secureimage_show.php:
Code (php)
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
<?php
include 'securimage.php';
$img = new Securimage();
$img->show(); // alternate use: $img->show('/path/to/background.jpg');
?>
include 'securimage.php';
$img = new Securimage();
$img->show(); // alternate use: $img->show('/path/to/background.jpg');
?>
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
function show($background_image = "")
{
if($background_image != "" && is_readable($background_image)) {
$this->bgimg = $background_image;
}
$this->doImage();
}
function doImage()
{
if($this->use_transparent_text == true || $this->bgimg != "") {
$this->im = imagecreatetruecolor($this->image_width, $this->image_height);
$bgcolor = imagecolorallocate($this->im, hexdec(substr($this->image_bg_color, 1, 2)), hexdec(substr($this->image_bg_color, 3, 2)), hexdec(substr($this->image_bg_color, 5, 2)));
imagefilledrectangle($this->im, 0, 0, imagesx($this->im), imagesy($this->im), $bgcolor);
} else { //no transparency
$this->im = imagecreate($this->image_width, $this->image_height);
$bgcolor = imagecolorallocate($this->im, hexdec(substr($this->image_bg_color, 1, 2)), hexdec(substr($this->image_bg_color, 3, 2)), hexdec(substr($this->image_bg_color, 5, 2)));
}
if($this->bgimg != "") { $this->setBackground(); }
$this->createCode();
if (!$this->draw_lines_over_text && $this->draw_lines) $this->drawLines();
$this->drawWord();
if ($this->arc_linethrough == true) $this->arcLines();
if ($this->draw_lines_over_text && $this->draw_lines) $this->drawLines();
$this->output();
}
function createCode()
{
$this->code = false;
if ($this->use_wordlist && is_readable($this->wordlist_file)) {
$this->code = $this->readCodeFromFile();
}
if ($this->code == false) {
$this->code = $this->generateCode($this->code_length);
}
}
function generateCode($len)
{
$code = '';
for($i = 1, $cslen = strlen($this->charset); $i <= $len; ++$i) {
$code .= strtoupper( $this->charset{rand(0, $cslen - 1)} );
}
return $code;
}
?>
function show($background_image = "")
{
if($background_image != "" && is_readable($background_image)) {
$this->bgimg = $background_image;
}
$this->doImage();
}
function doImage()
{
if($this->use_transparent_text == true || $this->bgimg != "") {
$this->im = imagecreatetruecolor($this->image_width, $this->image_height);
$bgcolor = imagecolorallocate($this->im, hexdec(substr($this->image_bg_color, 1, 2)), hexdec(substr($this->image_bg_color, 3, 2)), hexdec(substr($this->image_bg_color, 5, 2)));
imagefilledrectangle($this->im, 0, 0, imagesx($this->im), imagesy($this->im), $bgcolor);
} else { //no transparency
$this->im = imagecreate($this->image_width, $this->image_height);
$bgcolor = imagecolorallocate($this->im, hexdec(substr($this->image_bg_color, 1, 2)), hexdec(substr($this->image_bg_color, 3, 2)), hexdec(substr($this->image_bg_color, 5, 2)));
}
if($this->bgimg != "") { $this->setBackground(); }
$this->createCode();
if (!$this->draw_lines_over_text && $this->draw_lines) $this->drawLines();
$this->drawWord();
if ($this->arc_linethrough == true) $this->arcLines();
if ($this->draw_lines_over_text && $this->draw_lines) $this->drawLines();
$this->output();
}
function createCode()
{
$this->code = false;
if ($this->use_wordlist && is_readable($this->wordlist_file)) {
$this->code = $this->readCodeFromFile();
}
if ($this->code == false) {
$this->code = $this->generateCode($this->code_length);
}
}
function generateCode($len)
{
$code = '';
for($i = 1, $cslen = strlen($this->charset); $i <= $len; ++$i) {
$code .= strtoupper( $this->charset{rand(0, $cslen - 1)} );
}
return $code;
}
?>
Nu heb ik de volgende functie nog:
Code (php)
1
2
3
4
5
6
2
3
4
5
6
<?php
function saveData()
{
$_SESSION['securimage_code_value'] = strtolower($this->code);
}
?>
function saveData()
{
$_SESSION['securimage_code_value'] = strtolower($this->code);
}
?>
Deze wordt echter nergens aangeroepen (dus zet hij de code niet in de sessie. Waar zou ik die neer moeten zetten?
Gewijzigd op 19/07/2010 13:42:56 door Niek van Milligen
session_start();
Volgens mij moet hij dat geval in de sessie zetten als hij het plaatje maakt. Maar wat ik ook probeer, hij doet het niet :S