get("sync mobile", false); $APPS["sync_mobile"]["icon"] = "mobile"; if (!is_empty($_GET['delsynccode'])) { if ($database->has("mobile_codes", ["AND" => ["uid" => $_SESSION['uid'], "codeid" => $_GET['delsynccode']]])) { $database->delete("mobile_codes", ["AND" => ["uid" => $_SESSION['uid'], "codeid" => $_GET['delsynccode']]]); } } if ($_GET['mobilecode'] == "generate") { if (!is_empty($_GET['showsynccode']) && $database->has("mobile_codes", ["AND" => ["uid" => $_SESSION['uid'], "codeid" => $_GET['showsynccode']]])) { $code = $database->get("mobile_codes", 'code', ["AND" => ["uid" => $_SESSION['uid'], "codeid" => $_GET['showsynccode']]]); } else { $code = strtoupper(substr(md5(mt_rand() . uniqid("", true)), 0, 20)); $database->insert('mobile_codes', ['uid' => $_SESSION['uid'], 'code' => $code]); } if (strpos(URL, "http") !== FALSE) { $url = URL . "mobile/index.php"; } else { $url = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://" . $_SERVER['HTTP_HOST'] . (($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) ? ":" . $_SERVER['SERVER_PORT'] : "") . URL . "mobile/index.php"; } $encodedurl = str_replace("/", "\\", $url); $codeuri = "bizsync://" . $encodedurl . "/" . $_SESSION['username'] . "/" . $code; $qrCode = new QrCode($codeuri); $qrCode->setWriterByName('svg'); $qrCode->setSize(550); $qrCode->setErrorCorrectionLevel(ErrorCorrectionLevel::HIGH); $qrcode = $qrCode->writeDataUri(); $chunk_code = trim(chunk_split($code, 5, ' ')); $lang_done = $Strings->get("done adding sync code", false); $APPS["sync_mobile"]["content"] = '
' . $Strings->get("scan sync qrcode", false) . '
' . << .margintop-15px { margin-top: 15px; } .mono-chunk { text-align: center; font-size: 110%; font-family: monospace; }
END . "" . $Strings->get("manual setup", false) . "
" . '
' . $_SESSION['username'] . '
' . "" . <<$chunk_code
END . "" . <<$url
$lang_done END; } else { $activecodes = $database->select("mobile_codes", ["codeid", "code"], ["uid" => $_SESSION['uid']]); $content = '
' . $Strings->get("sync explained", false) . '
' . '' . $Strings->get("generate sync", false) . ''; $content .= "
" . $Strings->get("active sync codes", false) . ":
"; $content .= "
"; if (count($activecodes) > 0) { foreach ($activecodes as $c) { $content .= "
" . trim(chunk_split($c['code'], 5, ' ')) . "
"; } } else { $content .= "
" . $Strings->get("no active codes", false) . "
"; } $content .= "
"; $content .= << .mobilekey { display: flex; flex-wrap: wrap; justify-content: space-between; } .mobilekey #mobilecode { font-family: Ubuntu Mono,monospace; flex-shrink: 0; } END; $APPS["sync_mobile"]["content"] = $content; } }