예제 #1
0
switch ($method) {
    case "new":
        if (count($argv) == 3) {
            $auth = Authenticator::generate($argv[2]);
            $message = "New Authenticator requested";
        }
        break;
    case "generate":
        if (count($argv) == 4) {
            $auth = Authenticator::factory($argv[2], $argv[3]);
            $message = "Generate codes";
        }
        break;
    case "restore":
        if (count($argv) == 4) {
            $auth = Authenticator::restore($argv[2], $argv[3]);
            $message = "Restore requested";
        }
        break;
}
if ($auth === false) {
    usage();
    exit(1);
}
echo $message . " - Serial: " . $auth->serial() . " Secret: " . $auth->secret() . " Restore: " . $auth->restore_code() . "\r\n\r\n";
while (true) {
    $code = $auth->code();
    echo "key: {$code}\r\n";
    $wait = 1 + ($auth->waitingtime() - $auth->elapsedtime()) / 1000;
    echo 'waiting for ' . $wait . " sec\r\n\r\n";
    sleep($wait);
예제 #2
0
 if (check_data("letters_code")) {
     $postcode = db_iconv("letters_code");
     if (md5(strtolower($postcode)) == $_SESSION['letters_code']) {
         if (check_data('authname') && check_data('region') && check_data('authcodeA3') && check_data('authcodeB3') && check_data('authcodeC3') && check_data('authrestore') && check_data('selectpic')) {
             $region = db_iconv('region', "post", TRUE, true);
             $athcode1 = db_iconv('authcodeA3', "post", TRUE, true);
             $athcode2 = db_iconv('authcodeB3', "post", TRUE, true);
             $athcode3 = db_iconv('authcodeC3', "post", TRUE, true);
             $authname = db_iconv('authname', "post", TRUE, true);
             $selectpic = db_iconv('selectpic', "post", TRUE, true);
             $authrestorecode = db_iconv('authrestore', "post", TRUE, true);
             if (checkauthname($authname) && checkauthregion($region) && checkauthselectpic($selectpic) && checkauthselectcode($athcode1) && checkauthselectcode($athcode2) && checkauthselectcode($athcode3) && checkauthselectrestorecode($authrestorecode)) {
                 try {
                     $region = $strregion[$region];
                     $authserial = "{$region}-{$athcode1}-{$athcode2}-{$athcode3}";
                     $auth = @Authenticator::restore($authserial, $authrestorecode);
                     $authserect = $auth->secret();
                     //$authsynctime = $auth->getsync();
                     if (checkauthname('morenauthset')) {
                         $morenauthset = db_iconv('morenauthset', "post", TRUE, true);
                         if ($morenauthset == "on") {
                             update("UPDATE `authdata` SET `auth_moren`=0 WHERE `user_id`='{$user_id}' AND `auth_moren`=1");
                             $auth_moren = 1;
                         }
                     }
                     if (queryValue("SELECT COUNT(*) FROM `authdata` WHERE `user_id`='{$user_id}' AND `auth_moren`=1") == 0) {
                         $auth_moren = 1;
                     }
                     if (is_null($authserial)) {
                         $authaddbyrestoreerrorid = 5;
                     } else {