KaineBennett Posted January 6, 2014 Share Posted January 6, 2014 (edited) 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 January 6, 2014 by KaineBennett Quote Link to comment Share on other sites More sharing options...
Script47 Posted January 6, 2014 Share Posted January 6, 2014 Please format code to make it easier for others to read by using the [php*] [/php*] tags without the "*". Quote Link to comment Share on other sites More sharing options...
Seker Posted January 6, 2014 Share Posted January 6, 2014 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. Quote Link to comment Share on other sites More sharing options...
KaineBennett Posted January 6, 2014 Author Share Posted January 6, 2014 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? Quote Link to comment Share on other sites More sharing options...
Script47 Posted January 6, 2014 Share Posted January 6, 2014 (edited) 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 January 6, 2014 by Script47 Quote Link to comment Share on other sites More sharing options...
KaineBennett Posted January 6, 2014 Author Share Posted January 6, 2014 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);" Quote Link to comment Share on other sites More sharing options...
Seker Posted January 6, 2014 Share Posted January 6, 2014 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. Quote Link to comment Share on other sites More sharing options...
KaineBennett Posted January 6, 2014 Author Share Posted January 6, 2014 (edited) Now its saying this Parse error: syntax error, unexpected end of file in /home/jaykaine/public_html/reg_captcha.php on line 1 :/ Edited January 6, 2014 by KaineBennett Quote Link to comment Share on other sites More sharing options...
Lithium Posted January 6, 2014 Share Posted January 6, 2014 First of, those who are saying about the missing imagettftext() function, this is a php function. As off... by any chance you deleted the font file from the server, or moved it to another folder? Other than that, http://cz1.php.net/imagettftext the script seems pretty much default, so take a look there to see the examples. :) Quote Link to comment Share on other sites More sharing options...
jcvenom Posted January 7, 2014 Share Posted January 7, 2014 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 Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted January 7, 2014 Share Posted January 7, 2014 (edited) 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 January 7, 2014 by KyleMassacre Quote Link to comment Share on other sites More sharing options...
jcvenom Posted January 7, 2014 Share Posted January 7, 2014 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 Quote Link to comment Share on other sites More sharing options...
Legaci Posted January 11, 2014 Share Posted January 11, 2014 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 Quote Link to comment Share on other sites More sharing options...
jcvenom Posted January 11, 2014 Share Posted January 11, 2014 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 Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted January 11, 2014 Share Posted January 11, 2014 (edited) 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 January 11, 2014 by KyleMassacre fixed a double underscore Quote Link to comment Share on other sites More sharing options...
Legaci Posted January 11, 2014 Share Posted January 11, 2014 (edited) 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 January 11, 2014 by Legaci Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted January 11, 2014 Share Posted January 11, 2014 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. Quote Link to comment Share on other sites More sharing options...
Barrikor Posted January 11, 2014 Share Posted January 11, 2014 file Jezus!!!!! "File Jesus"? Is it like MegaUpload? :D (Sorry for the off-topic) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.