From ae24b8b3335f25f2aec34ce2e703e63f4a2fb15c Mon Sep 17 00:00:00 2001 From: kanoi Date: Sat, 30 Jan 2016 03:15:45 +1100 Subject: [PATCH] php - add a qrcode of the API key --- pool/page_userset.php | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/pool/page_userset.php b/pool/page_userset.php index bfed9cdf..6b02bc04 100644 --- a/pool/page_userset.php +++ b/pool/page_userset.php @@ -17,12 +17,20 @@ function uset($data, $user, $api, $err) $pg .= ''; $pg .= '"; + $pg .= ''; $pg .= '
'; if ($api === false) + { $pg .= "You don't have an API Key setup yet"; + $draw = false; + } else { + addQR(); $pg .= 'Your current API Key is:'; $pg .= '
'; - $pg .= "$api"; + $pg .= "$api
'; + $pg .= 'A qrcode will show here if your browser supports html5/canvas'; + $pg .= "
"; + $draw = true; } $pg .= '
'; $pg .= 'Click to generate a new API key'; @@ -49,6 +57,25 @@ function uset($data, $user, $api, $err) $pg .= '
'; + if ($draw !== false) + { + $qr = shell_exec("../pool/myqr.sh '$api'"); + if ($qr !== null and strlen($qr) > 30) + { + $pg .= "\n"; + + if (strpos($qr, 'var tw=1,fa=0,qrx=') === false) + error_log("QR error for '$user' res='$qr'"); + } + else + { + if ($qr === null) + $qr = 'null'; + error_log("QR failed for '$user' res='$qr'"); + } + } + return $pg; } #