/**
  * 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;
     }
 }
Example #2
0
    $group['id'] = $row['idGroup'];
    $group['name'] = $row['name'];
    $group['module'] = $row['module'];
    $group['options'] = empty($row['options']) ? array() : json_decode($row['options'], true);
    $group['keywords'] = $keywords;
    $group['sites'] = $sites;
    $allGroups[] = $group;
    $totalUnit += $modules[$row['module']]->getTotalProgressBarUnit($group);
}
d('Cron', 'display total unit ' . $totalUnit);
$dbc = null;
$captchaBrokenCurrentRun = 0;
if (!empty($options['general']['dbc_user']) && !empty($options['general']['dbc_pass'])) {
    $balance = 0;
    try {
        $dbc = new DeathByCaptcha_SocketClient($options['general']['dbc_user'], $options['general']['dbc_pass']);
        $balance = $dbc->get_balance();
    } catch (Exception $ex) {
        $balance = 0;
    }
    if ($balance == 0) {
        $dbc = null;
        e('Cron', 'DeathByCaptcha balance is to low');
    } else {
        l('Cron', 'DeathByCaptcha balance = ' . $balance);
    }
} else {
    l('Cron', 'DeathByCaptcha not configured, skipping');
}
l('Cron', 'Clearing the cache (force=' . strval(CACHE_RUN_CLEAR) . ')...');
clear_cache(CACHE_RUN_CLEAR);