Jump to content
MakeWebGames

Need help with my reg_captcha.php


KaineBennett

Recommended Posts

Hello, I am using the RuthlessCity Engine, and yes its fully licensed. But my reg_captha wont show up when trying to sign up, I have connected it to the DB and so on, this is the file i shall paste it below, if anyone knows what is wrong with it then please let me know, thank you!

It says this below!

Warning: imageline() expects parameter 6 to be long, array given in /home/*******/public_html/reg_captcha.php on line 90

Fatal error: Call to undefined function imagettftext() in /home/******/public_html/reg_captcha.php on line 98

 

<?php
session_start();
define('CAPTCHA_NUMCHARS', 4);

$pass_phrase = "";
for($i = 0; $i < CAPTCHA_NUMCHARS; $i++) {

   $pass_phrase .= chr(rand(97, 122)); 

}
$_SESSION['cap_code'] = $pass_phrase;

define('CAPTCHA_WIDTH', 70); define('CAPTCHA_HEIGHT', 20);

$img = array();

$img = imagecreatetruecolor(CAPTCHA_WIDTH, CAPTCHA_HEIGHT);

$bg_color = array();

$text_color = array();

$graphic_line_color = array();

$graphic_dot_color = array();

$gc = rand(1, 1);

if($gc == '1')
{
//blue bg 30-144-255
//white text 225-225-225
$bg_color = imagecolorallocate($img, 105,105,105);
$text_color = imagecolorallocate($img, 192,192,192);
}

if($gc == '2')
{
//green bg 124-252-0
//black text 0-0-0
//red lines 255-0-0
//green dots 124-252-0
$bg_color = imagecolorallocate($img, 124, 252, 0);
$text_color = imagecolorallocate($img, 0, 0, 0);
$graphic_line_color = imagecolorallocate($img, 225, 0, 0);
$graphic_dot_color = imagecolorallocate($img, 124, 252, 0);
}

if($gc == '3')
{
//red bg 255-0-0
//blue text 30-144-255
//black lines 0-0-0
//green dots 124-252-0
$bg_color = imagecolorallocate($img, 225, 0, 0);
$text_color = imagecolorallocate($img, 30, 144, 255);
$graphic_line_color = imagecolorallocate($img, 0, 0, 0);
$graphic_dot_color = imagecolorallocate($img, 124, 252, 0);
}

if($gc == '4')
{
//yellow bg 255-255-0
//red text 255-0-0
//blue lines 30-144-255
//black dots 0-0-0
$bg_color = imagecolorallocate($img, 225, 225, 0);
$text_color = imagecolorallocate($img, 225, 0, 0);
$graphic_line_color = imagecolorallocate($img, 30, 144, 255);
$graphic_dot_color = imagecolorallocate($img, 0, 0, 0);
}

if($gc == '5')
{
//blue bg 30-144-255
//yellow text 255-255-0
//green lines 124-252-0
//red dots 255-0-0
$bg_color = imagecolorallocate($img, 30, 144, 255);
$text_color = imagecolorallocate($img, 225, 225, 0);
$graphic_line_color = imagecolorallocate($img, 124, 252, 0);
$graphic_dot_color = imagecolorallocate($img, 225, 0, 0);
}


imagefilledrectangle($img, 0, 0, CAPTCHA_WIDTH, CAPTCHA_HEIGHT, $bg_color);

for($i = 0; $i < 15; $i++) {

   imageline($img, 0, rand() % CAPTCHA_HEIGHT, CAPTCHA_WIDTH, rand() % CAPTCHA_HEIGHT, $graphic_line_color);
}

for($i = 0; $i < 150; $i++) {

   imagesetpixel($img, rand() % CAPTCHA_WIDTH, rand() % CAPTCHA_HEIGHT, $graphic_dot__color);
}

imagettftext($img, 13, 0, rand(12,22),  CAPTCHA_HEIGHT - rand(5, 10), $text_color, 'ariblk.ttf', $pass_phrase);

header('Content-type: image/png');
imagepng($img);
destroyimage($img);

?>
Edited by KaineBennett
Link to comment
Share on other sites

Thing is it was working a few week ago when I made a backup and now its not working :/ any idea how to fully fix it? and what function?

Well from what Seker has said, the function imagettftext() is missing or cannot be found, maybe you removed something? Look for it in the other file from the back up maybe?

Edited by Script47
Link to comment
Share on other sites

First off..

 

$gc = rand(1, 1);

 

What?

Secondly, this: Fatal error: Call to undefined function imagettftext() in /home/******/public_html/reg_captcha.php on line 98

I'd say that's fairly obvious. You're missing a function.

So what should i do with the $gc = rand(1, 1);? and on the imagettftext() it says this"($img, 24, 0, rand(5,12), CAPTCHA_HEIGHT - rand(10, 15), $text_color, 'ariblk.ttf', $pass_phrase);"

Link to comment
Share on other sites

So what should i do with the $gc = rand(1, 1);? and on the imagettftext() it says this"($img, 24, 0, rand(5,12), CAPTCHA_HEIGHT - rand(10, 15), $text_color, 'ariblk.ttf', $pass_phrase);"

That's calling the function, not defining it...

Do you have any clue what you're doing? Be honest here.

Link to comment
Share on other sites

nope your.all wrong its either your includes/connections.php is wrong or session_start(); is missing from home.php can i see your home.php and register please

how does that explain an undefined php function that comes with the GD lib? Since it looks to me that no variables are coming from an outside file I believe kind sir that you may be incorrect. Granted I don't see what is really wrong with his imageline () function but if you look at lithiums link he was so gracious enough to provide us it seems like his GD library may need to be compiled with some extra features (first user submitted post) by a Mr. Paul Reinheimer.

For your variables lines 15-25 maybe get rid of the ones that say $your_variable = array (); because your really not making them an array? That may solve your imageline problem (hence your array error).

EDIT:

I just wanted to point something out that really bothers the hell out of me and I see it all the time when people post anything with the RC engine and its about these so called "arrays".

If you are going to tell php something is an array, make it an array for example:

$my_var = array ();
//I just told php that this variable is an array
$my_var = 10;
//is that an array?
$my_var["my_key"] = 10;
//now I made my variable an array

I have seen this in tons RC scripts where they say a variable is an array and its not, or they do the same, then query the db, then do mysql_fetch_array. The great thing about php is once you fetch the array, guess what? Its an array.

RANT OVER

Edited by KyleMassacre
Link to comment
Share on other sites

how does that explain an undefined php function that comes with the GD lib? Since it looks to me that no variables are coming from an outside file I believe kind sir that you may be incorrect. Granted I don't see what is really wrong with his imageline () function but if you look at lithiums link he was so gracious enough to provide us it seems like his GD library may need to be compiled with some extra features (first user submitted post) by a Mr. Paul Reinheimer.

For your variables lines 15-25 maybe get rid of the ones that say $your_variable = array (); because your really not making them an array? That may solve your imageline problem (hence your array error).

EDIT:

I just wanted to point something out that really bothers the hell out of me and I see it all the time when people post anything with the RC engine and its about these so called "arrays".

If you are going to tell php something is an array, make it an array for example:

$my_var = array ();
//I just told php that this variable is an array
$my_var = 10;
//is that an array?
$my_var["my_key"] = 10;
//now I made my variable an array

I have seen this in tons RC scripts where they say a variable is an array and its not, or they do the same, then query the db, then do mysql_fetch_array. The great thing about php is once you fetch the array, guess what? Its an array.

RANT OVER

nice work kyle :) #respect

Link to comment
Share on other sites

jcvenom your wrong why would it require a connection file nothing in this file requires any database settings ( think about it)

you have to define getimagetext on line 98

could try this

$pass_phrase="";
$graphic_dot__color="";

bad fix but should work

i have completed this fix before

Link to comment
Share on other sites

jcvenom your wrong why would it require a connection file nothing in this file requires any database settings ( think about it)

you have to define getimagetext on line 98

could try this

$pass_phrase="";
$graphic_dot__color="";

bad fix but should work

i have completed this fix before

ha because this happen to me before its either your wrong of he has a dodgy code

Link to comment
Share on other sites

done bickering yet???

<?php
session_start();
define('CAPTCHA_NUMCHARS', 4);
$pass_phrase = "";

for ($i = 0; $i < CAPTCHA_NUMCHARS; $i++)
{
   $pass_phrase.= chr(rand(97, 122));
}

$_SESSION['cap_code'] = $pass_phrase;
define('CAPTCHA_WIDTH', 70);
define('CAPTCHA_HEIGHT', 20);
$img = array();
$img = imagecreatetruecolor(CAPTCHA_WIDTH, CAPTCHA_HEIGHT);
$bg_color = array();
$text_color = array();
$graphic_line_color = array();
$graphic_dot_color = array();
$gc = rand(1, 5);

if ($gc == 1)
{

   // blue bg 30-144-255
   // white text 225-225-225

   $bg_color = imagecolorallocate($img, 105, 105, 105);
   $text_color = imagecolorallocate($img, 192, 192, 192);
}

if ($gc == 2)
{

   // green bg 124-252-0
   // black text 0-0-0
   // red lines 255-0-0
   // green dots 124-252-0

   $bg_color = imagecolorallocate($img, 124, 252, 0);
   $text_color = imagecolorallocate($img, 0, 0, 0);
   $graphic_line_color = imagecolorallocate($img, 225, 0, 0);
   $graphic_dot_color = imagecolorallocate($img, 124, 252, 0);
}

if ($gc == 3)
{

   // red bg 255-0-0
   // blue text 30-144-255
   // black lines 0-0-0
   // green dots 124-252-0

   $bg_color = imagecolorallocate($img, 225, 0, 0);
   $text_color = imagecolorallocate($img, 30, 144, 255);
   $graphic_line_color = imagecolorallocate($img, 0, 0, 0);
   $graphic_dot_color = imagecolorallocate($img, 124, 252, 0);
}

if ($gc == 4)
{

   // yellow bg 255-255-0
   // red text 255-0-0
   // blue lines 30-144-255
   // black dots 0-0-0

   $bg_color = imagecolorallocate($img, 225, 225, 0);
   $text_color = imagecolorallocate($img, 225, 0, 0);
   $graphic_line_color = imagecolorallocate($img, 30, 144, 255);
   $graphic_dot_color = imagecolorallocate($img, 0, 0, 0);
}

if ($gc == 5)
{

   // blue bg 30-144-255
   // yellow text 255-255-0
   // green lines 124-252-0
   // red dots 255-0-0

   $bg_color = imagecolorallocate($img, 30, 144, 255);
   $text_color = imagecolorallocate($img, 225, 225, 0);
   $graphic_line_color = imagecolorallocate($img, 124, 252, 0);
   $graphic_dot_color = imagecolorallocate($img, 225, 0, 0);
}

imagefilledrectangle($img, 0, 0, CAPTCHA_WIDTH, CAPTCHA_HEIGHT, $bg_color);

for ($i = 0; $i < 15; $i++)
{
   imageline($img, 0, rand() % CAPTCHA_HEIGHT, CAPTCHA_WIDTH, rand() % CAPTCHA_HEIGHT, $graphic_line_color);
}

for ($i = 0; $i < 150; $i++)
{
   imagesetpixel($img, rand() % CAPTCHA_WIDTH, rand() % CAPTCHA_HEIGHT, $graphic_dot_color);
}

imagettftext($img, 13, 0, rand(12, 22) , CAPTCHA_HEIGHT - rand(5, 10) , $text_color, 'ariblk.ttf', $pass_phrase);
header('Content-type: image/png');
imagepng($img);
imagedestroy($img);
?>

the problem was that you had '' around your numbers in your if statements try that and see if it works

Edited by KyleMassacre
fixed a double underscore
Link to comment
Share on other sites

Venom please Tell me where i would connect to the database in this file Jezus!!!!!

Nothing "Dodgy" just he running this with error_reporting on in php.ini

Shows all warnings ect

If he was to turn it off it would work but i would rather fix warnings...

 

Karl i have fixed this before i cant remember the exact fix but im sure it was just simply defining those to variables cant remember i will test you code and check it for you ;)

Edited by Legaci
Link to comment
Share on other sites

Venom please Tell me where i would connect to the database in this file Jezus!!!!!

Nothing "Dodgy" just he running this with error_reporting on in php.ini

Shows all warnings ect

If he was to turn it off it would work but i would rather fix warnings...

 

Karl i have fixed this before i cant remember the exact fix but im sure it was just simply defining those to variables cant remember i will test you code and check it for you ;)

*Ahem*

The name is Kyle and there is no need for you to test it since I already have this as a working copy but thanks for wanted to check it for me.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...