當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Authenticator::factory方法代碼示例

本文整理匯總了PHP中Authenticator::factory方法的典型用法代碼示例。如果您正苦於以下問題:PHP Authenticator::factory方法的具體用法?PHP Authenticator::factory怎麽用?PHP Authenticator::factory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Authenticator的用法示例。


在下文中一共展示了Authenticator::factory方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: queryRow

}
if (!is_null($user_id) && !is_null($authid)) {
    $sql = "SELECT * FROM `authdata` WHERE `user_id`='{$user_id}' AND `auth_id`='{$authid}'";
    $row = queryRow($sql);
}
if ($row) {
    $time = date('Y-m-d H:i:s');
    $region = $row['region'];
    if ($region != "CN" && $region != "EU") {
        $region = "US";
    }
    $sql = "SELECT * FROM `synctime` WHERE `region`='{$region}'";
    $rowSYNC = queryRow($sql);
    if (strtotime($time) - strtotime($rowSYNC['last_sync']) > 86400) {
        $auth = Authenticator::factory($row['serial'], $row['secret']);
        $sql = "UPDATE `synctime` SET `sync`=\"" . $auth->getsync() . "\" ,`last_sync`=\"{$time}\" WHERE `region`='{$region}'";
        update($sql);
    } else {
        $auth = Authenticator::factory($row['serial'], $row['secret'], $rowSYNC['sync']);
    }
    //顯示數據
    header('Content-type: text/json');
    $wait = $auth->sleeptime() / 1000;
    $arr = array('code' => $auth->code(), 'time' => $wait);
    echo json_encode($arr);
} else {
    header('Content-type: text/json');
    $wait = 0;
    $arr = array('code' => "@@@@@@", 'time' => $wait);
    echo json_encode($arr);
}
開發者ID:wooberlong,項目名稱:myauth.us,代碼行數:31,代碼來源:auth_normal_get.php

示例2: isset

    echo "\tphp php-bma.php new region\r\n";
    echo "\tphp php-bma.php generate serial secret\r\n";
    echo "\tphp php-bma.php restore serial restore_code\r\n\r\n";
}
$auth = false;
$method = isset($argv[1]) ? $argv[1] : null;
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";
開發者ID:FelipeSouzaRamos,項目名稱:php-bma,代碼行數:31,代碼來源:php-bma.php


注:本文中的Authenticator::factory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。