index.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. $uas = $_SERVER['HTTP_USER_AGENT'];
  3. $os = "Linux";
  4. if (str_contains($uas, "Windows")) {
  5. $os = "Windows";
  6. } elseif (str_contains($uas, "Android") || str_contains($uas, "CrOS")) {
  7. $os = "Android";
  8. } elseif (str_contains($uas, "iPad") || str_contains($uas, "iPhone")) {
  9. $os = "iOS";
  10. } elseif (str_contains($uas, "Mac OS X") || str_contains($uas, "Macintosh")) {
  11. $os = "OSX";
  12. } elseif (str_contains($uas, "Tizen")) {
  13. $os = "Tizen";
  14. }
  15. $clients = json_decode(file_get_contents("clients_{$os}.json"));
  16. $lang = json_decode(file_get_contents("lang/en.json"));
  17. $uri = $_SERVER['QUERY_STRING'];
  18. if (substr($uri, 0, 7) == 'xmpp%3a') {
  19. $uri = urldecode($uri);
  20. }
  21. if ( substr($uri, 0, 5) != "xmpp:") {
  22. $uri = "xmpp:" . $uri;
  23. }
  24. // TODO: Better invitation type detection.
  25. $parsed = parse_url($uri);
  26. $action = $lang->chat;
  27. if ( str_contains($uri, '?join') ) {
  28. $action = $lang->muc;
  29. } elseif ( str_contains($uri, '?register;') ) {
  30. $action = $lang->register;
  31. if ( str_contains($uri, "@") ) {
  32. $action = $lang->register_name;
  33. }
  34. } elseif ( str_contains($parsed['query'], 'ibr=y') ) {
  35. $action = $lang->ibr;
  36. }
  37. $name = explode("@", $parsed['path'])[0];
  38. $server = explode("@", $parsed['path'])[1] ?? $name;
  39. function t($template) {
  40. GLOBAL $name;
  41. GLOBAL $os;
  42. GLOBAL $server;
  43. $template = str_replace('{{name}}', $name, $template);
  44. $template = str_replace('{{Name}}', ucfirst($name), $template);
  45. $template = str_replace('{{os}}', $os, $template);
  46. $template = str_replace('{{server}}', $server, $template);
  47. return $template;
  48. }
  49. ?>
  50. <!DOCTYPE html>
  51. <html>
  52. <head>
  53. <meta charset="utf-8">
  54. <meta content="IE=edge" http-equiv="X-UA-Compatible">
  55. <meta content="width=device-width, initial-scale=1, user-scalable=0" name="viewport">
  56. <title><?= t($action->title) ?></title>
  57. <link href="stylesheets/styles.css" rel="stylesheet">
  58. <link href="stylesheets/i.css" rel="stylesheet">
  59. <style>
  60. .main {
  61. padding-top: 0px;
  62. max-width: 600px;
  63. width: 90%;
  64. margin: 0 auto;
  65. }
  66. </style>
  67. </head>
  68. <body>
  69. <div class="main">
  70. <h3 class="text-center" id="heading"><?= t($action->heading) ?></h3>
  71. <p class="text-center"><a class="btn btn-primary" id="button" href="<?= $uri ?>"><?= t($action->button)?></a></p>
  72. <input type="url" class="form-control text-center" id="url_in" value="<?= $uri ?>" readonly/>
  73. <!--div class="qrcode" id="qrcode">TODO</div-->
  74. <p class="lead text-center" id="clients"><?= $lang->clients; ?></p>
  75. <p class="lead text-center" id="recommend"><?= t($lang->recommend); ?></p>
  76. <p class="lead img-center text-center" id="client_list">
  77. <?php
  78. foreach ( $clients as $client ) {
  79. echo $client;
  80. }
  81. ?>
  82. </p>
  83. <i>
  84. <p class="hint text-center" id="checkfulllist"><?= $lang->checkfulllist ?></p>
  85. <p class="hint text-center" id="xmppis"><?= $lang->xmppis ?></p>
  86. </i>
  87. <p class="hint text-center" id="xmpp"></p>
  88. </div>
  89. </body>
  90. </html>