login.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <?php
  2. include("../language.php");
  3. require_once('../authorize/mastodon.php');
  4. use HalcyonSuite\HalcyonForMastodon\Mastodon;
  5. if (isset($_POST['acct'])) {
  6. $domain = explode("@", mb_strtolower(htmlspecialchars((string)filter_input(INPUT_POST, 'acct'), ENT_QUOTES)))[2];
  7. $URL= 'https://'.$domain;
  8. $api= new Mastodon();
  9. if(!preg_match('/(^[a-z0-9\-\.\/]+?\.[a-z0-9-]+$)/',$domain) || in_array($domain,json_decode(base64_decode("WyJnYWIuY29tIiwiZ2FiLmFpIl0=")))) {
  10. header('Location: '.$api->clientWebsite.'/login?cause=domain', true, 303);
  11. die();
  12. } else {
  13. try {
  14. $client_id = $api->getInstance($URL)["client_id"];
  15. $authorizeURL= $URL.'/oauth/authorize?client_id='.$client_id.'&response_type=code&scope=read+write+follow&redirect_uri='.urlencode($api->clientWebsite.'/auth?&host='.$domain);
  16. header("Location: {$authorizeURL}", true, 303);
  17. die();
  18. } catch (Exception $e) {
  19. header('Location: '.$api->clientWebsite.'/login?cause=domain', true, 303);
  20. die();
  21. }
  22. }
  23. }
  24. ?>
  25. <!DOCTYPE HTML>
  26. <html lang="en">
  27. <head>
  28. <meta charset="utf-8">
  29. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  30. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  31. <title>Halcyon</title>
  32. <link rel="shortcut icon" href="/assets/images/favicon.ico">
  33. <link rel="stylesheet" href="/login/assets/css/style.css" media="all">
  34. <link rel="stylesheet" href="/assets/css/fontawesome.min.css" media="all">
  35. <link rel="stylesheet" href="/assets/css/cookieconsent.min.css">
  36. <script src="/assets/js/jquery/jquery.min.js"></script>
  37. <script src="/assets/js/cookieconsent/cookieconsent.min.js"></script>
  38. <script src="/assets/js/jquery-cookie/src/jquery.cookie.js"></script>
  39. <script src="/login/assets/js/halcyon_login.js"></script>
  40. <script>
  41. if(
  42. localStorage.getItem("current_id") |
  43. localStorage.getItem("current_instance") |
  44. localStorage.getItem("current_authtoken")
  45. ){
  46. location.href = "/";
  47. };
  48. </script>
  49. </head>
  50. <body>
  51. <header id="header">
  52. <div id="header_wrap">
  53. <div id="header_title_wrap" class="header_box header_right_box">
  54. <div class="header_box_child title_box">
  55. <a href="/">
  56. <img src="/login/assets/images/halcyon-title.png" alt="Halcyon for mastodon">
  57. </a>
  58. </div>
  59. </div>
  60. <div id="header_menu_wrap" class="header_box header_left_box">
  61. <nav class="header_box_child nav_box">
  62. <ul>
  63. <a href="https://social.csswg.org/@halcyon" class="no-underline">
  64. <li>
  65. <span><i class="fa fa-newspaper-o" aria-hidden="true"></i><?=_('News')?></span>
  66. </li>
  67. </a>
  68. <a href="https://notabug.org/halcyon-suite/halcyon" class="no-underline">
  69. <li>
  70. <span><i class="fa fa-code" aria-hidden="true"></i><?=_('Source')?></span>
  71. </li>
  72. </a>
  73. <a href="/terms" class="no-underline">
  74. <li>
  75. <span><i class="fa fa-balance-scale" aria-hidden="true"></i><?=_('Terms')?></span>
  76. </li>
  77. </a>
  78. <a href="/privacy" class="no-underline">
  79. <li>
  80. <span><i class="fa fa-shield" aria-hidden="true"></i><?=_('Privacy')?></span>
  81. </li>
  82. </a>
  83. <?php if(file_exists("../config/imprint.txt")) { ?>
  84. <a href="/imprint" class="no-underline">
  85. <li>
  86. <span><i class="fa fa-id-card-o" aria-hidden="true"></i><?=_('Imprint')?></span>
  87. </li>
  88. </a>
  89. <?php } ?>
  90. <a href="http://www.nikisoft.one/contact.php" class="no-underline">
  91. <li>
  92. <span><i class="fa fa-envelope" aria-hidden="true"></i><?=_('Contact')?></span>
  93. </li>
  94. </a>
  95. <a href="#login_form_wrap" class="no-underline">
  96. <li>
  97. <span><i class="fa fa-user-circle-o" aria-hidden="true"></i><?=_('Login')?></span>
  98. </li>
  99. </a>
  100. </ul>
  101. </nav>
  102. </div>
  103. </div>
  104. </header>
  105. <main id="main">
  106. <div id="login_form_wrap">
  107. <div class="login_form">
  108. <form method="POST" >
  109. <h2><?=_('Login to Halcyon')?></h2>
  110. <p>
  111. <?=_('or')?> <a href="https://instances.social"><?=_('create an account')?></a>
  112. </p>
  113. <div class="session_aleart">
  114. <span></span>
  115. </div>
  116. <div class="login_form_main">
  117. <input name="acct" type="text" class="login_form_input" placeholder="@johndoe@example.com" required>
  118. <label class="login_form_continue pointer">
  119. <i class="fa fa-chevron-circle-right" aria-hidden="true"></i>
  120. <input id="login_continue" type="submit" value="" class="invisible">
  121. </label>
  122. </div>
  123. <div class="login_form_agree">
  124. <input id="agree" type="checkbox" required checked>
  125. <label for="agree" class="login_form_agree_check disallow_select pointer">
  126. <?=_('I agree with the')?> <a href="/terms"><?=_('Terms')?></a>
  127. </label>
  128. </div>
  129. </form>
  130. </div>
  131. </div>
  132. <article id="article">
  133. <h2><?=_('What is Halcyon')?></h2>
  134. <p>
  135. <?=_('Halcyon is a webclient for')?><a href="https://joinmastodon.org"> Mastodon </a><?=_('and')?><a href="https://pleroma.social"> Pleroma </a><?=_('which aims to recreate the simple and beautiful user interface of Twitter while keeping all advantages of decentral networks in focus.')?>
  136. </p>
  137. <div class="image_wrap">
  138. <ul>
  139. <li><img src="/login/assets/images/preview2.png" alt="halcyon_screenshot"></li>
  140. <li><img src="/login/assets/images/preview1.png" alt="halcyon_screenshot"></li>
  141. <li><img src="/login/assets/images/preview0.png" alt="halcyon_screenshot"></li>
  142. </ul>
  143. <button class="prev_button switch_button"><i class="fa fa-angle-left" aria-hidden="true"></i></button>
  144. <button class="next_button switch_button"><i class="fa fa-angle-right" aria-hidden="true"></i></button>
  145. </div>
  146. <h2><?=_('Contact / Feedback')?></h2>
  147. <p>
  148. Mastodon: <a href="https://social.csswg.org/@halcyon" target="_blank">@halcyon@social.csswg.org</a><br/>
  149. Email: <a href="http://www.nikisoft.one/contact.php" target="_blank"><?=_('Use my contact form')?></a><br/>
  150. Git repository: <a href="https://notabug.org/halcyon-suite/halcyon" target="_blank">halcyon-suite/halcyon</a>
  151. </p>
  152. <h2><?=_('Help us')?></h2>
  153. <p>
  154. Bitcoin: 1D6GThQqHQYnruKYrKyW9JC86ZGWxjt1hK<br/>
  155. Liberapay: <a href="https://liberapay.com/nipos">Donate to @nipos</a>
  156. </p>
  157. </article>
  158. </main>
  159. <!-- FOOTER -->
  160. <footer id="footer">
  161. <div class="footer_anchor">
  162. <a href="#">
  163. <i class="fa fa-angle-up" aria-hidden="true"></i>
  164. </a>
  165. </div>
  166. <span>Photo by <a href="https://www.flickr.com/photos/95387826@N08/">Michio Morimoto on Flickr</a> (CC BY 2.0)</span><br/>
  167. <?php
  168. if(file_exists("../config/footerlinks.txt")) {
  169. $footerlinks = json_decode(file_get_contents("../config/footerlinks.txt"));
  170. $haslinks = false;
  171. for($i=0;$i<count($footerlinks);$i++) {
  172. if($footerlinks[$i]->logout == true) {
  173. if($haslinks == false) {
  174. $haslinks = true;
  175. echo "<span>";
  176. }
  177. else {
  178. echo " | ";
  179. }
  180. echo "<a href='".$footerlinks[$i]->link."'>".$footerlinks[$i]->title."</a>";
  181. }
  182. }
  183. if($haslinks == true) {
  184. echo "</span><br/>";
  185. }
  186. }
  187. ?>
  188. <span>Halcyon version <?php echo file_get_contents("../version.txt") ?></span>
  189. </footer>
  190. </body>
  191. <script>
  192. window.cookieconsent.initialise({
  193. "palette": {
  194. "popup": {
  195. "background": "#000"
  196. },
  197. "button": {
  198. "background": "#f1d600"
  199. }
  200. },
  201. "theme": "classic",
  202. "position": "bottom"
  203. });
  204. </script>
  205. <?php if (isset($_GET['cause'])): ?>
  206. <script>
  207. $(function() {
  208. var cause = "<?= htmlspecialchars((string)filter_input(INPUT_GET, 'cause'), ENT_QUOTES) ?>";
  209. if(cause === "domain") {
  210. $('.login_form_main').addClass('error');
  211. $('.session_aleart').removeClass('invisible');
  212. $('.session_aleart > span').text('This instance does not exist.');
  213. }
  214. });
  215. $(document).on('click','.login_form_main', function(e) {
  216. $(this).removeClass('error');
  217. });
  218. </script>
  219. <?php endif; ?>
  220. </html>