/** * Obsługa DBC - rozwiązywanie captcha * @param string $captchaUrl */ public static function fixCaptcha($captchaUrl) { $captchaFile = dirname(__FILE__) . '/captcha/' . uniqid('captcha') . '.png'; file_put_contents($captchaFile, PlayMobile::curl($captchaUrl)); if (PlayMobile::$captchaService == 'deathbycaptcha.com') { require_once 'vendor/deathbycaptcha.php'; $client = new DeathByCaptcha_SocketClient(PlayMobile::$dbcUser, PlayMobile::$dbcPass); $captcha = $client->decode($captchaFile, DeathByCaptcha_Client::DEFAULT_TIMEOUT); $captcha = $captcha['text']; } else { require_once 'vendor/Captcha.php'; $client = new Captcha(); $client->domain = PlayMobile::$captchaService; $client->setApiKey(PlayMobile::$captchaApiKey); if ($client->run($captchaFile)) { $captcha = $client->result(); } else { $captcha = NULL; } } if ($captcha) { @unlink($captchaFile); print "Captcha: {$captcha}\n"; return $captcha; } else { @unlink($captchaFile); return FALSE; } }
<?php require_once "random.php"; require_once "Captcha.php"; $Captcha = new Captcha(); $Captcha->generate(new Random()); echo $Captcha->result() . "\n";