VanDerSaAr Posted August 24, 2012 Share Posted August 24, 2012 Hello! I want to place captcha on the registration page of my own forum in PHP, but my free hoster does not support any graphic library. Now I can not to change my hoster. So, I tried to search text capcha and found those several examples: 1) http://textcaptcha.com Probably, it uses WordNet and Prolog. This captcha is remote and require to sign up on the site. I do not like such program, because, imho, secure captcha must be local. 2) http://www.smiffysplace.com/textcaptcha_example.php This captcha is local, but, I guess, it can be overcame easily, if database of questions and answers will be known. That's why, I do not like this captcha too. So, what PHP local captcha without graphics can you recommend to use? Quote Link to comment https://forums.phpfreaks.com/topic/267539-php-captcha-without-graphics/ Share on other sites More sharing options...
Davie33 Posted August 24, 2012 Share Posted August 24, 2012 Hi don't know if this is any good to you but here you go any way. http://www.xaprb.com/blog/2006/01/28/captchas-done-better/ Its not captcha but help abit. Quote Link to comment https://forums.phpfreaks.com/topic/267539-php-captcha-without-graphics/#findComment-1372203 Share on other sites More sharing options...
VanDerSaAr Posted August 24, 2012 Author Share Posted August 24, 2012 Hi don't know if this is any good to you but here you go any way. http://www.xaprb.com/blog/2006/01/28/captchas-done-better/ Its not captcha but help abit. <?php $captchas = Array(); # Create a single entry $captchas[] = array( "question" => "What color is the sky?", "answer" => "blue", "options" => array("blue", "red", "orange")); # Create as many as desired by copy-and-paste... ?> Yes, it can be temporary solution of problem, but those variants of answers will be bruteforced by spamer, and captcha will be ovecame. Quote Link to comment https://forums.phpfreaks.com/topic/267539-php-captcha-without-graphics/#findComment-1372211 Share on other sites More sharing options...
scootstah Posted August 24, 2012 Share Posted August 24, 2012 Use Recaptcha. You don't need the graphic libraries to use it. Quote Link to comment https://forums.phpfreaks.com/topic/267539-php-captcha-without-graphics/#findComment-1372215 Share on other sites More sharing options...
VanDerSaAr Posted August 24, 2012 Author Share Posted August 24, 2012 Use Recaptcha. You don't need the graphic libraries to use it. Google's ReCaptcha is remote. I want local captcha. Quote Link to comment https://forums.phpfreaks.com/topic/267539-php-captcha-without-graphics/#findComment-1372217 Share on other sites More sharing options...
scootstah Posted August 24, 2012 Share Posted August 24, 2012 You're not going to get captcha without GD, sorry. The whole idea of captcha is supposed to be hard for computers to read, but easy for humans to read. As OCR software gets better and better, this is slowly turning the other way around. But, if you have straight up text on your website it's not really going to do anything for you. There are a number of other solutions like answering questions or solving math problems. You could maybe randomly generate a little colored box and ask what color it is. Although, that might not work for color blind people. Quote Link to comment https://forums.phpfreaks.com/topic/267539-php-captcha-without-graphics/#findComment-1372219 Share on other sites More sharing options...
VanDerSaAr Posted August 25, 2012 Author Share Posted August 25, 2012 You're not going to get captcha without GD, sorry. The whole idea of captcha is supposed to be hard for computers to read, but easy for humans to read. As OCR software gets better and better, this is slowly turning the other way around. But, if you have straight up text on your website it's not really going to do anything for you. There are a number of other solutions like answering questions or solving math problems. You could maybe randomly generate a little colored box and ask what color it is. Although, that might not work for color blind people. I will not surrender. I will try to write my own open source text captcha. Quote Link to comment https://forums.phpfreaks.com/topic/267539-php-captcha-without-graphics/#findComment-1372227 Share on other sites More sharing options...
Christian F. Posted August 25, 2012 Share Posted August 25, 2012 Math problems are the one thing computers can do a lot better than humans, every time. So it's even less useful than a CAPTCHA test. Reading comprehension, on the other hand, is something which computers cannot simulate. At least not without a proper AI. Sure, hardcoded questions can be collected and made a database out of, but that requires human intervention specific for said site. So if you really want to secure your page, do something that requires actually intelligence to solve. Quote Link to comment https://forums.phpfreaks.com/topic/267539-php-captcha-without-graphics/#findComment-1372230 Share on other sites More sharing options...
floridaflatlander Posted August 25, 2012 Share Posted August 25, 2012 You're not going to get captcha without GD, sorry. As a note I saw a web site one time that had a question like "What is the second word in the sentence at the top of the page?" or something like that. I also had a pic of a manual captchua I did (just one) and it worked, the numbers were 4321 on a jpg with some lines through it and if you're a small site that may be all you'll need. But the question above worked very good. Quote Link to comment https://forums.phpfreaks.com/topic/267539-php-captcha-without-graphics/#findComment-1372233 Share on other sites More sharing options...
Jessica Posted August 25, 2012 Share Posted August 25, 2012 If the math problem is "What is one plus three" Is that still effective as a captcha? What's the one PHP Freaks uses? Isn't it a text based one? I haven't had to do it in a while Quote Link to comment https://forums.phpfreaks.com/topic/267539-php-captcha-without-graphics/#findComment-1372242 Share on other sites More sharing options...
scootstah Posted August 25, 2012 Share Posted August 25, 2012 If the math problem is "What is one plus three" Is that still effective as a captcha? The text can be parsed into "1 + 3", which is then easily solvable. Some people work 9-5 cracking CAPTCHA's, this kind of stuff is trivial. Quote Link to comment https://forums.phpfreaks.com/topic/267539-php-captcha-without-graphics/#findComment-1372255 Share on other sites More sharing options...
Mahngiel Posted August 25, 2012 Share Posted August 25, 2012 There's the 'select the [random] image' where a few images are randomly picked from a database and order. Quote Link to comment https://forums.phpfreaks.com/topic/267539-php-captcha-without-graphics/#findComment-1372258 Share on other sites More sharing options...
PFMaBiSmAd Posted August 25, 2012 Share Posted August 25, 2012 There's the 'select the [random] image' where a few images are randomly picked from a database and order. Because each actual image is static, you can get a 'signature' for them (filename, filesize, and/or actual binary data of the image) that lets you map the question to the correct image. You would need to dynamically alter the images each time they are output, varying the size/color/name... so that any one actual image has a random signature each time it is used. Quote Link to comment https://forums.phpfreaks.com/topic/267539-php-captcha-without-graphics/#findComment-1372261 Share on other sites More sharing options...
scootstah Posted August 25, 2012 Share Posted August 25, 2012 There's the 'select the [random] image' where a few images are randomly picked from a database and order. Because each actual image is static, you can get a 'signature' for them (filename, filesize, and/or actual binary data of the image) that lets you map the question to the correct image. You would need to dynamically alter the images each time they are output, varying the size/color/name... so that any one actual image has a random signature each time it is used. And even then, if enough effort was exerted, you could probably write something that could trace the images and choose that way. Even if you change colors or size, the outline would be roughly the same. Quote Link to comment https://forums.phpfreaks.com/topic/267539-php-captcha-without-graphics/#findComment-1372264 Share on other sites More sharing options...
Mahngiel Posted August 25, 2012 Share Posted August 25, 2012 And even then, if enough effort was exerted, ... ... You could crack windows ... you could "land a man" on the moon ... you could run for president :ahem: There's a way to break everything with enough effort. Captcha / verification codes / and the like are only a menial way to slow down the enemy. There is no de facto fool-proof way to stop the baddies - all you can do is through enough shit in their way. Quote Link to comment https://forums.phpfreaks.com/topic/267539-php-captcha-without-graphics/#findComment-1372270 Share on other sites More sharing options...
floridaflatlander Posted August 25, 2012 Share Posted August 25, 2012 There is no de facto fool-proof way to stop the baddies - all you can do is through enough shit in their way. change enough to some Quote Link to comment https://forums.phpfreaks.com/topic/267539-php-captcha-without-graphics/#findComment-1372284 Share on other sites More sharing options...
VanDerSaAr Posted August 28, 2012 Author Share Posted August 28, 2012 I will not surrender. I will try to write my own open source text captcha. I wrote my own open source text captcha. ConsoleCaptcha © Version: 1.0 (2012-08-27) Author: VanDerSaAr License: MIT ConsoleCaptcha generates text based images with symbols, which enough easily can be read by humans, but difficulty can be read by OCR systems or other robots. It does not require any graphic library (GD, etc), any database of questions, etc. It does not use much resources and more faster. It can be used with telnet, ssh, etc. See examples: 1) standart size, small font, medium deviation: http://cryptbb.site40.net/reg.php?v=1 2) huge size, small font, large deviation: http://cryptbb.site40.net/reg.php?v=2 3) standart size, smallest font, medium deviation: http://cryptbb.site40.net/reg.php?v=3 <?php /*============================================================================================= ConsoleCaptcha (c) Version: 1.0 (2012-08-27) Author: VanDerSaAr See example: http://cryptbb.site40.net/reg.php?v=1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ License: MIT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------------------------------------------------------------------------------------------- How to use ConsoleCaptcha v1.0: <code> <?php include("console-captcha-v1.php"); echo ConsoleCaptchaV1( "EFHLN", # random captcha text = string of 1..30 symbols from EFHLNTXZ + space 4, # defined font size = 1..24 pixels 21, # defined canvas height = 13..100 symbols 120, # minimal canvas width = 0..600 symbols 12, # minimal strike line height = 12..min_canvas_width 50, # minimal strike line width = 50..100 symbols 30, # maximal add strike line height = 0..50 symbols 15, # maximal inverval between strike lines = 0..25 symbols 10, # minimal letter size = 10..canvas_height-3 100, # maximal letter size = min_letter_size..canvas_height-3 0, # minimal interval between letters = 0..100 symbols 4, # maximal interval between letters = min_interval_letter..100 10); # maximal deviation of letter from vertical line = 0..30 degrees ?> </code> To check captcha you can use hashes, sessions, etc. *///=========================================================================================== function ConsoleCaptchaV1( $CaptchaText, // = "EFHLN" # random captcha text = 1..30 symbols from EFHLNTXZ + space $FontSize, // = 4 # defined font size = 1..24 $CanvasHeight, // = 21 # defined canvas height = 13..100 $MinCanvasWidth, // = 120 # minimal canvas width = 0..600 $MinStrikeHeight, // = 12 # minimal strike line height = 12..$MinCanvasWidth $MinStrikeLength, // = 50 # minimal strike line width = 50..100 $AddStrikeLength, // = 30 # maximal add strike line height = 30..50 $MaxStrikeInterval, // = 15 # maximal inverval between strike lines = 15..25 $MinLetterSize, // = 10 # minimal symbol size = 10..$CanvasHeight-3 $MaxLetterSize, // = 100 # maximal symbol size = 100..$CanvasHeight-3 $MinLetterInterval, // = 0 # minimal interval between minimal symbol size = 0..100 $MaxLetterInterval, // = 4 # maximal interval between minimal symbol size = 4..100 $MaxLetterAngle // = 10 # maximal deviation of symbol from vertical line = 0..30 ) { #============================================================================================== function FuncAngleX($FuncX, $FuncAngle, $FuncSize) { # func (origin x, pos angle, pos length) if (($FuncAngle >= (M_PI / 2)) and ($FuncAngle < (3 * M_PI / 2))) { # if angle = PI/2 .. 3*PI/2 $FuncX = $FuncX - round($FuncSize * cos($FuncAngle)); # set position x } else { # if (($FuncAngle >= (M_PI / 2)) and ($FuncAngle < (3 * M_PI / 2))) # if angle = 0..PI/2 + 3*PI/2..2*PI if ($FuncAngle < (M_PI / 2)) { # if angle = 0 .. PI/2 $FuncX = $FuncX + round($FuncSize * cos(M_PI - $FuncAngle)); # set position x } else { # if ($FuncAngle < (M_PI / 2)) # if angle = 3*PI/2 .. 2*PI $FuncX = $FuncX + round($FuncSize * cos($FuncAngle - M_PI)); # set position x } # if ($FuncAngle < (M_PI / 2)) else } # if (($FuncAngle >= (M_PI / 2)) and ($FuncAngle < (3 * M_PI / 2))) else return $FuncX; # return position x } # function FuncAngleX ($FuncX, $FuncAngle, $FuncSize) #---------------------------------------------------------------------------------------------- function FuncPointPos($FuncOriginX, $FuncOriginY, $FuncRatio, $FuncSize1, $FuncAngle1, $FuncSize2, $FuncAngle2) { # func (origin x, y; factor y; positions length, angle of degrees) $FuncA = ($FuncAngle1 / 180) * M_PI; # set position1 angle if ($FuncA > (2 * M_PI)) { # if angle more 2*PI $FuncA = $FuncA - (2 * M_PI); # decrease angle } # if ($FuncA > (2 * M_PI)) if ($FuncA < 0) { # if angle less 0 $FuncA = $FuncA + (2 * M_PI); # increase angle } # if ($FuncA < 0) $FuncX1 = FuncAngleX($FuncOriginX, $FuncA, $FuncSize1); # set position1 x $FuncY1 = $FuncOriginY + round(($FuncSize1 * sin($FuncA)) / $FuncRatio); # set position1 y $FuncA = ($FuncAngle2 / 180) * M_PI; # set position2 angle if ($FuncA > (2 * M_PI)) { # if angle more 2*PI $FuncA = $FuncA - (2 * M_PI); # decrease angle } # if ($FuncA > (2 * M_PI)) if ($FuncA < 0) { # if angle less 0 $FuncA = $FuncA + (2 * M_PI); # increase angle } # if ($FuncA < 0) $FuncX2 = FuncAngleX($FuncOriginX, $FuncA, $FuncSize2); # set position2 x $FuncY2 = $FuncOriginY + round(($FuncSize2 * sin($FuncA)) / $FuncRatio); # set position2 y return array ($FuncX1, $FuncY1, $FuncX2, $FuncY2); # return positions x1, y1, x2, y2 } # function FuncPointPos() #============================================================================================== $NeedDebug = false; # if need to print tech info #$FontSize = 4; // 4 # get font size // debug if ($FontSize < 1) {$FontSize = 1;} # if value less min value then set min value if ($FontSize > 24) {$FontSize = 24;} # if value more max value then set max value #$CanvasHeight = 21; // 21 # get canvas height // debug if ($CanvasHeight < 13) {$CanvasHeight = 13;} # if value less min value then set min value if ($CanvasHeight > 100) {$CanvasHeight = 100;} # if value more max value then set max value #$MinCanvasWidth = 120; // 120 # get minimal canvas width // debug if ($MinCanvasWidth < 0) {$MinCanvasWidth = 0;} # if value less min value then set min value if ($MinCanvasWidth > 600) {$MinCanvasWidth = 600;} # if value more max value then set max value #$MinStrikeHeight = 12; // 12 # get minimal strike line height // debug if ($MinStrikeHeight < 12) {$MinStrikeHeight = 12;} # if value less min value then set min value if ($MinStrikeHeight > $CanvasHeight) {$MinStrikeHeight = $CanvasHeight;} # if value more max value then set max value #$MinStrikeLength = 50; // 50 # get minimal strike line length // debug if ($MinStrikeLength < 50) {$MinStrikeLength = 50;} # if value less min value then set min value if ($MinStrikeLength > 100) {$MinStrikeLength = 100;} # if value more max value then set max value #$AddStrikeLength = 30; // 30 # get maximal add strike line height // debug if ($AddStrikeLength < 0) {$AddStrikeLength = 0;} # if value less min value then set min value if ($AddStrikeLength > 50) {$AddStrikeLength = 50;} # if value more max value then set max value #$MaxStrikeInterval = 15; // 15 # get maximal inverval between strike lines // debug if ($MaxStrikeInterval < 0) {$MaxStrikeInterval = 0;} # if value less min value then set min value if ($MaxStrikeInterval > 25) {$MaxStrikeInterval = 25;} # if value more max value then set max value #$MinLetterSize = 10; // 10 # get minimal symbol size // debug if ($MinLetterSize < 10) {$MinLetterSize = 10;} # if value less min value then set min value if ($MinLetterSize > $CanvasHeight - 3) {$MinLetterSize = $CanvasHeight - 3;} # if value more max value then set max value #$MaxLetterSize = 100; // 100 # get maximal symbol size // debug if ($MaxLetterSize < $MinLetterSize) {$MaxLetterSize = $MinLetterSize;} # if value less min value then set min value if ($MaxLetterSize > $CanvasHeight - 3) {$MaxLetterSize = $CanvasHeight - 3;} # if value more max value then set max value #$MinLetterInterval = 0; // 0 # get minimal interval between minimal symbol size // debug if ($MinLetterInterval < 0) {$MinLetterInterval = 0;} # if value less min value then set min value if ($MinLetterInterval > 100) {$MinLetterInterval = 100;} # if value more max value then set max value #$MaxLetterInterval = 4; // 4 # get maximal interval between minimal symbol size // debug if ($MaxLetterInterval < $MinLetterInterval) {$MaxLetterInterval = $MinLetterInterval;} # if value less min value then set min value if ($MaxLetterInterval > 100) {$MaxLetterInterval = 100;} # if value more max value then set max value #$MaxLetterAngle = 10; // 10 # get maximal deviation of symbol from vertical line // debug if ($MaxLetterAngle < 0) {$MaxLetterAngle = 0;} # if value less min value then set min value if ($MaxLetterAngle > 30) {$MaxLetterAngle = 30;} # if value more max value then set max value #---------------------------------------------------------------------------------------------- if ($FontSize < 3) { # if letters too small $CanvasBackChars = " "; # set canvas background chars } else { # if ($FontSize < 3) $CanvasBackChars = ".,' "; # set canvas background chars } # if ($FontSize < 3) else $CanvasFrontChars = "#@&"; # set canvas front chars $DrawChar = "*"; # set temp draw char $SpaceChar = " "; # set temp space char $Ratio = "1.73"; # set ratio between width and height of symbols for ($For1 = 1; $For1 <= $CanvasHeight; $For1++) { # cycle lines of canvas if ($NeedDebug === true) { # if need to debug $Line[$For1] = sprintf('%1$02d', $For1); # set line number } else { # if ($NeedDebug === true) # if not need to debug $Line[$For1] = $SpaceChar; # set space } # if ($NeedDebug === true) else } # for ($For1 = 1; $For1 <= $CanvasHeight; $For1++) $DrawCount = 0; # clear draw lines count $OriginX = 2; # set start symbol position $PointX1 = array(); # assign array of x1 point of draw line $PointY1 = array(); # assign array of y1 point of draw line $PointX2 = array(); # assign array of x2 point of draw line $PointY2 = array(); # assign array of y2 point of draw line for ($For1 = (strlen($CaptchaText) - 1); $For1 >= 0; $For1--) { # cycle symbols of captcha text if (strpos('EFHLNTXZ ', $CaptchaText[$For1]) === false) { # if captcha symbol is unknown and not space $CaptchaText = substr_replace($CaptchaText, "", $For1, 1); # delete symbol } # if (strpos('EFHLNTXZ ', $CaptchaText[$For1]) === false) } # for ($For1 = (strlen($CaptchaText) - 1); $For1 >= 0; $For1--) if (strlen($CaptchaText) > 30) { # if length of captcha text more value $CaptchaText = substr($CaptchaText, 0, 30); # cut captcha text from right side } # if (strlen($CaptchaText) > 30) #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for ($For1 = 0; $For1 < strlen($CaptchaText); $For1++) { # cycle symbols of captcha $OriginX = $OriginX + rand($MinLetterInterval, $MaxLetterInterval); # increase origin x plus random interval $MainSize = rand($MinLetterSize, $MaxLetterSize); # randomize letter size #$MainSize = 7; # debug $DeltaA = rand(0, $MaxLetterAngle * 2) - $MaxLetterAngle; # randomize angle delta #$DeltaA = 0; # debug $OriginY = rand(ceil($MainSize / 2) + 2, $CanvasHeight - ceil($MainSize / 2) - 1); # randomize origin y = 08..14 $OriginX = $OriginX + ceil($MainSize / 2) + 1; # increase origin x plus half letter size #---------------------------------------------------------------------------------------------- if (strpos('EFHLN', $CaptchaText[$For1]) !== false) { # left column begin $DrawCount = $DrawCount + 1; # increase line count list ($PointX1[$DrawCount], $PointY1[$DrawCount], $PointX2[$DrawCount], $PointY2[$DrawCount]) = FuncPointPos($OriginX, $OriginY, $Ratio, $MainSize, 300 + $DeltaA, $MainSize, 60 + $DeltaA); } # left column end if (strpos('EFTZ', $CaptchaText[$For1]) !== false) { # top row begin $DrawCount = $DrawCount + 1; # increase line count list ($PointX1[$DrawCount], $PointY1[$DrawCount], $PointX2[$DrawCount], $PointY2[$DrawCount]) = FuncPointPos($OriginX, $OriginY, $Ratio, $MainSize, 300 + $DeltaA, $MainSize, 240 + $DeltaA); } # top row end if (strpos('EFH', $CaptchaText[$For1]) !== false) { # middle row begin $DrawCount = $DrawCount + 1; # increase line count list ($PointX1[$DrawCount], $PointY1[$DrawCount], $PointX2[$DrawCount], $PointY2[$DrawCount]) = FuncPointPos($OriginX, $OriginY, $Ratio, $MainSize / 2.1, 0 + $DeltaA, $MainSize / 2.1, 180 + $DeltaA); } # middle row end if (strpos('ELZ', $CaptchaText[$For1]) !== false) { # bottom row begin $DrawCount = $DrawCount + 1; # increase line count list ($PointX1[$DrawCount], $PointY1[$DrawCount], $PointX2[$DrawCount], $PointY2[$DrawCount]) = FuncPointPos($OriginX, $OriginY, $Ratio, $MainSize, 60 + $DeltaA, $MainSize, 120 + $DeltaA); } # # bottom row end if (strpos('HN', $CaptchaText[$For1]) !== false) { # right column begin $DrawCount = $DrawCount + 1; # increase line count list ($PointX1[$DrawCount], $PointY1[$DrawCount], $PointX2[$DrawCount], $PointY2[$DrawCount]) = FuncPointPos($OriginX, $OriginY, $Ratio, $MainSize, 240 + $DeltaA, $MainSize, 120 + $DeltaA); } # right column end if (strpos('T', $CaptchaText[$For1]) !== false) { # middle column begin $DrawCount = $DrawCount + 1; # increase line count list ($PointX1[$DrawCount], $PointY1[$DrawCount], $PointX2[$DrawCount], $PointY2[$DrawCount]) = FuncPointPos($OriginX, $OriginY, $Ratio, $MainSize / 1.2, 270 + $DeltaA, $MainSize / 1.2, 90 + $DeltaA); } # middle column end if (strpos('NX', $CaptchaText[$For1]) !== false) { # diagonal \ begin $DrawCount = $DrawCount + 1; # increase line count list ($PointX1[$DrawCount], $PointY1[$DrawCount], $PointX2[$DrawCount], $PointY2[$DrawCount]) = FuncPointPos($OriginX, $OriginY, $Ratio, $MainSize, 300 + $DeltaA, $MainSize, 120 + $DeltaA); } # diagonal \ end if (strpos('XZ', $CaptchaText[$For1]) !== false) { # diagonal / begin $DrawCount = $DrawCount + 1; # increase line count list ($PointX1[$DrawCount], $PointY1[$DrawCount], $PointX2[$DrawCount], $PointY2[$DrawCount]) = FuncPointPos($OriginX, $OriginY, $Ratio, $MainSize, 240 + $DeltaA, $MainSize, 60 + $DeltaA); } # diagonal / begin #---------------------------------------------------------------------------------------------- $OriginX = $OriginX + ceil($MainSize / 2) + 1; # increase origin x plus half letter size } # for ($For1 = 0; $For1 < strlen($CaptchaText); $For1++) #============================================================================================== $OriginX = $OriginX + 2; # increase origin x $MarginX = 0; # clear margin x if ($OriginX < $MinCanvasWidth) { # if origin x less minimal canvas width $MarginX = rand(0, $MinCanvasWidth - $OriginX); # randomize margin x $OriginX = $MinCanvasWidth; # set margin x } # if ($OriginX < $MinCanvasWidth) for ($For1 = 1; $For1 <= $DrawCount; $For1++) { # cycle draw lines $PointX1[$For1] = $PointX1[$For1] + $MarginX; # shift position x1 of draw line point $PointX2[$For1] = $PointX2[$For1] + $MarginX; # shift position x2 of draw line point } # for ($For1 = 1; $For1 <= $DrawCount; $For1++) #---------------------------------------------------------------------------------------------- $DotX1 = 1; # clear dot x1 while ($DotX1 < $OriginX) { # while dot x1 less right side of canvas $DotX2 = $DotX1 + $MinStrikeLength + rand(0, $AddStrikeLength); # set dot x2 if ($DotX2 >= ($OriginX - $MinStrikeLength)) { # if dot x2 near right side $DotX2 = $OriginX; # set origin x to dot x2 } # if ($DotX2 >= ($OriginX - $MinStrikeLength)) if ($DotX1 != 1) { # if it is not left side if (($DotX2 - $DotX1) > ($MinStrikeLength + $AddStrikeLength)) { # if x1 x2 delta more strike line length $DotX1 = $DotX2 - ($MinStrikeLength + $AddStrikeLength); # set dot x1 } # if (($DotX2 - $DotX1) > ($MinStrikeLength + $AddStrikeLength)) } # if ($DotX1 != 1) #---------------------------------------------------------------------------------------------- if (($MinStrikeHeight * 2) > $CanvasHeight) { # if canvas height less doubled minimal strike line height if (rand(0, 1) == 1) { # if 50%/50% $DotY1 = rand(1, $CanvasHeight - $MinStrikeHeight + 1); # randomize left position of strike line } else { # if (rand(0, 1) == 1) $DotY1 = rand($MinStrikeHeight, $CanvasHeight); # randomize left position of strike line } # if (rand(0, 1) == 1) else } else { # if (($MinStrikeHeight * 2) > $CanvasHeight) $DotY1 = rand(1, $CanvasHeight); # randomize left position of strike line } # if (($MinStrikeHeight * 2) > $CanvasHeight) else if (($DotY1 - $MinStrikeHeight + 1) < 1) { # if left position of strike line near top of canvas $DotY2 = rand($DotY1 + $MinStrikeHeight - 1, $CanvasHeight); # randomize right position of strike line } else { # if (($DotY1 - $MinStrikeHeight + 1) < 1) if (($DotY1 + $MinStrikeHeight - 1) > $CanvasHeight) { # if left position of strike line near bottom of canvas $DotY2 = rand(1, $DotY1 - $MinStrikeHeight + 1); # randomize right position of strike line } else { # if (($DotY1 + $MinStrikeHeight - 1) > $CanvasHeight) if (rand(0, 1) == 1) { # if 50%/50% $DotY2 = rand($DotY1 + $MinStrikeHeight - 1, $CanvasHeight); # randomize right position of strike line } else { # if (rand(0, 1) == 1) $DotY2 = rand(1, $DotY1 - $MinStrikeHeight + 1); # randomize right position of strike line } # if (rand(0, 1) == 1) else } # if (($DotY1 + $MinStrikeHeight - 1) > $CanvasHeight) else } # if (($DotY1 - $MinStrikeHeight + 1) < 1) else #---------------------------------------------------------------------------------------------- $DrawCount = $DrawCount + 1; # increase draw line count $PointX1[$DrawCount] = $DotX1; # set point x1 $PointY1[$DrawCount] = $DotY1; # set point y1 $PointX2[$DrawCount] = $DotX2; # set point x2 $PointY2[$DrawCount] = $DotY2; # set point y2 $DotX1 = $DotX2 + rand(0, $MaxStrikeInterval); # increase dot x1 } # while ($DotX1 < $OriginX) #============================================================================================== // draw lines on canvas for ($For1 = 1; $For1 <= $DrawCount; $For1++) { # cycle draw lines $DotX1 = $PointX1[$For1]; # get dot x1 $DotY1 = $PointY1[$For1]; # get dot y1 $DotX2 = $PointX2[$For1]; # get dot x2 $DotY2 = $PointY2[$For1]; # get dot y2 if ($NeedDebug == true) { # if need to debug echo 'DotX1=' . $DotX1 . ', DotY1=' . $DotY1 . ';' . ' DotX2=' . $DotX2 . ', DotY2=' . $DotY2 . ': '; # print coordinates } # if ($NeedDebug == true) if ($DotX1 < $DotX2) { # if need to debug $FromX = $DotX1; # set left position x } else { # if ($DotX1 < $DotX2) $FromX = $DotX2; # set right position x } # if ($DotX1 < $DotX2) else if ($DotY1 < $DotY2) { # if need to debug $FromY = $DotY1; # set top position y } else { # if ($DotY1 < $DotY2) $FromY = $DotY2; # set bottom position y } # if ($DotY1 < $DotY2) else if ($NeedDebug == true) { # if need to debug echo 'FromX=' . $FromX . ', FromY=' . $FromY . '; '; # print coordinates } # if ($NeedDebug == true) $DeltaX = abs($DotX1 - $DotX2); # set delta x $DeltaY = abs($DotY1 - $DotY2); # set delta y if ($NeedDebug == true) { # if need to debug then print coordinates echo 'DeltaX=' . $DeltaX . ', DeltaY=' . $DeltaY . '.<BR>'; # print coodinates } # if ($NeedDebug == true) #---------------------------------------------------------------------------------------------- if ($DeltaX > $DeltaY) { # if width of letter more height for ($For2 = 0; $For2 <= $DeltaX; $For2++) { # cycle points of width if ($DotX1 >= $DotX2) { # if position x1 more or equal position x2 if ($DotY1 < $DotY2) { # if position y1 less position y2 $TmpInt = round($DeltaY * (($DeltaX - $For2) / $DeltaX)); # set y coodinate } else { # if ($DotY1 < $DotY2) $TmpInt = round($DeltaY * ($For2 / $DeltaX)); # set y coodinate } # if ($DotY1 < $DotY2) else } else { # if ($DotX1 >= $DotX2) if ($DotY1 >= $DotY2) { # if position y1 more position y2 $TmpInt = round($DeltaY * (($DeltaX - $For2) / $DeltaX)); # set y coodinate } else { # if ($DotY1 >= $DotY2) $TmpInt = round($DeltaY * ($For2 / $DeltaX)); # set y coodinate } # if ($DotY1 >= $DotY2) else } # if ($DotX1 >= $DotX2) else if ($NeedDebug == true) { # if need to debug echo 'Y' . $For2 . '=' . $TmpInt . ', '; # print y coodinate } # if ($NeedDebug == true) $Line[$FromY + $TmpInt][$FromX + $For2 - 1] = $DrawChar; # draw char on canvas } # for ($For2 = 0; $For2 <= $DeltaX; $For2++) } else { # if ($DeltaX > $DeltaY) for ($For2 = 0; $For2 <= $DeltaY; $For2++) { # cycle points of height if ($DotY1 >= $DotY2) { # if position y1 more or equal position y2 if ($DotX1 < $DotX2) { # if position x1 less position x2 $TmpInt = round($DeltaX * (($DeltaY - $For2) / $DeltaY)); # set x coodinate } else { # if ($DotX1 < $DotX2) $TmpInt = round($DeltaX * ($For2 / $DeltaY)); # set x coodinate } # if ($DotX1 < $DotX2) else } else { # if ($DotY1 >= $DotY2) if ($DotX1 >= $DotX2) { # if position x1 more or equal position x2 $TmpInt = round($DeltaX * (($DeltaY - $For2) / $DeltaY)); # set x coodinate } else { # if ($DotX1 >= $DotX2) $TmpInt = round($DeltaX * ($For2 / $DeltaY)); # set x coodinate } # if ($DotX1 >= $DotX2) else } # if ($DotY1 >= $DotY2) else if ($NeedDebug == true) { # if need to debug echo 'X' . $For2 . '=' . $TmpInt . ', '; # print x coodinate } # if ($NeedDebug == true) $Line[$FromY + $For2][$FromX + $TmpInt - 1] = $DrawChar; # draw char on canvas } # for ($For2 = 0; $For2 <= $DeltaY; $For2++) } # if ($DeltaX > $DeltaY) else #---------------------------------------------------------------------------------------------- if ($NeedDebug == true) { # if need to debug echo '<BR>'; # print line break } # if ($NeedDebug == true) } # for ($For1 = 1; $For1 <= $DrawCount; $For1++) #============================================================================================== $FuncString = ""; # clear canvas line for ($For1 = 1; $For1 <= $CanvasHeight; $For1++) { # cycle draw lines $TmpString = $Line[$For1]; # set draw line $TmpInt = strlen($TmpString); # set length of draw line if ($TmpInt < $OriginX) { # if length of draw line less right side of canvas for ($For2 = $TmpInt; $For2 < $OriginX; $For2++) { # cycle symbols of draw line $TmpString = $TmpString . $SpaceChar; # add space to draw line } # for ($For2 = $TmpInt; $For2 < $OriginX; $For2++) } # if ($TmpInt < $OriginX) $TmpInt = strlen($CanvasBackChars) - 1; # set length of background string of symbols for ($For2 = 0; $For2 < $OriginX; $For2++) { # cycle symbols of draw line if ($TmpString[$For2] == $SpaceChar) { # if symbol is space char $TmpString[$For2] = $CanvasBackChars[rand(0, $TmpInt)]; # randomize space char } # if ($TmpString[$For2] == $SpaceChar) } # for ($For2 = 0; $For2 < $OriginX; $For2++) $TmpInt = strlen($CanvasFrontChars) - 1; # set length of front string of symbols for ($For2 = 0; $For2 < $OriginX; $For2++) { # cycle symbols of draw line if ($TmpString[$For2] == $DrawChar) { # if symbol is draw char $TmpString[$For2] = $CanvasFrontChars[rand(0, $TmpInt)]; # randomize draw char } # if ($TmpString[$For2] == $DrawChar) } # for ($For2 = 0; $For2 < $OriginX; $For2++) $TmpString = str_replace(" ", " ", $TmpString); # change spaces to idents $FuncString = $FuncString . $TmpString . '<BR>'; # add draw line to canvas line } # for ($For1 = 1; $For1 <= $CanvasHeight; $For1++) return '<SPAN STYLE="font-family: Lucida Console, Terminal, Courier; font-size: ' . $FontSize . '">' . $FuncString . '</SPAN>'; # return canvas line } # function ShowCaptcha($CaptchaText) #============================================================================================== ?> If ConsoleCaptcha was usefull for you, please comment here. 18909_.zip Quote Link to comment https://forums.phpfreaks.com/topic/267539-php-captcha-without-graphics/#findComment-1373376 Share on other sites More sharing options...
xyph Posted August 28, 2012 Share Posted August 28, 2012 I doubt any OCR software would have issues with that CAPTCHA. Neat idea though. Quote Link to comment https://forums.phpfreaks.com/topic/267539-php-captcha-without-graphics/#findComment-1373379 Share on other sites More sharing options...
Christian F. Posted August 28, 2012 Share Posted August 28, 2012 I think you need to re-examine your solution... This was even less useful than the worst picture-based CAPTCHA I've seen. Opera 12.01 on Xubuntu 8.04, btw. Quote Link to comment https://forums.phpfreaks.com/topic/267539-php-captcha-without-graphics/#findComment-1373381 Share on other sites More sharing options...
Jessica Posted August 28, 2012 Share Posted August 28, 2012 That's weird, I also looked at it and they all worked fine for me. I agree with xyph but still they didn't look anything like what Christian posted. Quote Link to comment https://forums.phpfreaks.com/topic/267539-php-captcha-without-graphics/#findComment-1373382 Share on other sites More sharing options...
Christian F. Posted August 28, 2012 Share Posted August 28, 2012 My guess is that both of you are using Windows, and thus has the same font that the OP relies upon for the formatting. Quote Link to comment https://forums.phpfreaks.com/topic/267539-php-captcha-without-graphics/#findComment-1373386 Share on other sites More sharing options...
VanDerSaAr Posted August 28, 2012 Author Share Posted August 28, 2012 I think you need to re-examine your solution... This was even less useful than the worst picture-based CAPTCHA I've seen. Opera 12.01 on Xubuntu 8.04, btw. return '<SPAN STYLE="[b]font-family: Lucida Console, Terminal, Courier;[/b] font-size: ' . $FontSize . '">' . $FuncString . '</SPAN>'; # return canvas line Do you have any of those fonts? Quote Link to comment https://forums.phpfreaks.com/topic/267539-php-captcha-without-graphics/#findComment-1373388 Share on other sites More sharing options...
xyph Posted August 28, 2012 Share Posted August 28, 2012 How it displays could vary from system to system, because it relies on client-side rendering to be visible. If you don't have Lucida Console, Terminal or Courier fonts installed, it will flat out break. Using <pre> tags might help with this, but it still depends on the font the browser decides to use for that tag. Quote Link to comment https://forums.phpfreaks.com/topic/267539-php-captcha-without-graphics/#findComment-1373389 Share on other sites More sharing options...
Jessica Posted August 28, 2012 Share Posted August 28, 2012 You should add monospace to the end of the list. http://en.wikipedia.org/wiki/Font_family_%28HTML%29#Generic_font_families Quote Link to comment https://forums.phpfreaks.com/topic/267539-php-captcha-without-graphics/#findComment-1373390 Share on other sites More sharing options...
VanDerSaAr Posted August 28, 2012 Author Share Posted August 28, 2012 My guess is that both of you are using Windows, and thus has the same font that the OP relies upon for the formatting. Yes, I am on Windows 7. What console font in your operation system? I can add this font name in my forum right now. Quote Link to comment https://forums.phpfreaks.com/topic/267539-php-captcha-without-graphics/#findComment-1373391 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.