Vergleich inc/3rdparty/2fa/GoogleAuthenticator.php - 1.8.4 - 1.8.10

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 71Zeile 71
     *
* @param string $name
* @param string $secret

     *
* @param string $name
* @param string $secret

 
     * @param string $title

     * @return string
*/

     * @return string
*/

    public function getQRCodeGoogleUrl($name, $secret) {

    public function getQRCodeGoogleUrl($name, $secret, $title = null) {

        $urlencoded = urlencode('otpauth://totp/'.$name.'?secret='.$secret.'');

        $urlencoded = urlencode('otpauth://totp/'.$name.'?secret='.$secret.'');

 
	if(isset($title)) {
$urlencoded .= urlencode('&issuer='.urlencode($title));
}

        return 'https://chart.googleapis.com/chart?chs=200x200&chld=M|0&cht=qr&chl='.$urlencoded.'';
}


        return 'https://chart.googleapis.com/chart?chs=200x200&chld=M|0&cht=qr&chl='.$urlencoded.'';
}


Zeile 84Zeile 88
     * @param string $secret
* @param string $code
* @param int $discrepancy This is the allowed time drift in 30 second units (8 means 4 minutes before or after)

     * @param string $secret
* @param string $code
* @param int $discrepancy This is the allowed time drift in 30 second units (8 means 4 minutes before or after)

 
     * @param int|null $currentTimeSlice time slice if we want use other that time()

     * @return bool
*/

     * @return bool
*/

    public function verifyCode($secret, $code, $discrepancy = 1)

    public function verifyCode($secret, $code, $discrepancy = 1, $currentTimeSlice = null)

    {

    {

        $currentTimeSlice = floor(time() / 30);



        if ($currentTimeSlice === null) {
$currentTimeSlice = floor(time() / 30);
}


for ($i = -$discrepancy; $i <= $discrepancy; $i++) {
$calculatedCode = $this->getCode($secret, $currentTimeSlice + $i);


for ($i = -$discrepancy; $i <= $discrepancy; $i++) {
$calculatedCode = $this->getCode($secret, $currentTimeSlice + $i);