public function PHPGangsta_GoogleAuthenticator::getQRCodeGoogleUrl in TFA Basic plugins 7
Get QR-Code URL for image, from google charts.
Parameters
string $name:
string $secret:
string $title:
array $params:
Return value
string
File
- includes/
googleauthenticator/ GoogleAuthenticator.php, line 101
Class
- PHPGangsta_GoogleAuthenticator
- PHP Class for handling Google Authenticator 2-factor authentication.
Code
public function getQRCodeGoogleUrl($name, $secret, $title = null, $params = array()) {
$width = !empty($params['width']) && (int) $params['width'] > 0 ? (int) $params['width'] : 200;
$height = !empty($params['height']) && (int) $params['height'] > 0 ? (int) $params['height'] : 200;
$level = !empty($params['level']) && array_search($params['level'], array(
'L',
'M',
'Q',
'H',
)) !== false ? $params['level'] : 'M';
$urlencoded = urlencode('otpauth://totp/' . $name . '?secret=' . $secret . '');
if (isset($title)) {
$urlencoded .= urlencode('&issuer=' . urlencode($title));
}
return 'https://chart.googleapis.com/chart?chs=' . $width . 'x' . $height . '&chld=' . $level . '|0&cht=qr&chl=' . $urlencoded . '';
}