ordersprinter/webapp/php/utilities/osqrcode.php

59 lines
1.3 KiB
PHP
Raw Normal View History

2020-11-19 23:13:57 +01:00
<?php
error_reporting(E_ERROR);
require_once (__DIR__. '/../3rdparty/phpqrcode.php');
2020-11-19 23:14:02 +01:00
require_once (__DIR__. '/../commonutils.php');
2020-11-19 23:13:57 +01:00
class OsQrcode {
public static function createQrCodeForLink($text) {
QRcode::png($text);
}
2020-11-19 23:14:02 +01:00
public static function createUserLgin() {
if(session_id() == '') {
session_start();
}
$userid = $_SESSION['userid'];
$pdo = DbUtils::openDbAndReturnPdoStatic();
$serverurl = CommonUtils::getConfigValue($pdo, 'serverurl', null);
if (is_null($serverurl)) {
header('Content-Type: image/png');
readfile(__DIR__. '/../../img/oops.png');
return;
}
$lastchar = substr($serverurl, -1);
if ($lastchar == "/") {
$serverurl = substr($serverurl, 0, strlen($serverurl) - 1);
}
$sql = "SELECT userpassword as value FROM %user% WHERE id=?";
$passhash = CommonUtils::getFirstSqlQuery($pdo, $sql, array($userid),null);
if (is_null($passhash)) {
header('Content-Type: image/png');
readfile(__DIR__. '/../../img/oops.png');
return;
} else {
$text = $serverurl . "/nfclogin.php?a=" . $passhash . "_" . $userid . "v=1.6.3";
QRcode::png($text);
}
}
2020-11-19 23:13:57 +01:00
}
$cmd = $_GET["cmd"];
$arg = $_GET["arg"];
switch($cmd) {
case "link":
OsQrcode::createQrCodeForLink($arg);
break;
2020-11-19 23:14:02 +01:00
case "userlogin":
OsQrcode::createUserLgin();
break;
2020-11-19 23:13:57 +01:00
default:
break;
}