qrcode.php 983 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. require_once('common.php');
  3. if (empty($myUser)) exit();
  4. require_once('phpqrcode.php');
  5. $methode = array_keys($_REQUEST)[0];
  6. switch($methode) {
  7. case 'qr': # qrcode.php?qr&label=A&user=B&key=C
  8. Functions::chargeVarRequest('label', 'user', 'key', 'issuer', 'algorithm', 'digits', 'period');
  9. if (empty($key)) {
  10. $key = "**********";
  11. }
  12. $qrCode = "otpauth://totp/{$label}:{$user}?secret={$key}";
  13. foreach (array('issuer', 'algorithm', 'digits', 'period') as $champ)
  14. if (!empty(${$champ}))
  15. $qrCode.="&{$champ}={${$champ}}";
  16. break;
  17. case 'txt': # qrcode.php?txt&TEXTE
  18. $qrCode = substr($_SERVER['QUERY_STRING'], 1+strlen($methode));
  19. break;
  20. default:
  21. $qrCode = '';
  22. }
  23. Functions::chargeVarRequest('_qrSize', '_qrMargin');
  24. if (empty($_qrSize)) $_qrSize = 3;
  25. if (empty($_qrMargin)) $_qrMargin = 4;
  26. QRcode::png($qrCode, false, 'QR_LEVEL_H', $_qrSize, $_qrMargin);