account.php (2788B)
1 <?php
2
3 function show_account(
4 string $user,
5 string $token
6 ) {
7
8 /* generate token path */
9 $tokens_storage = $GLOBALS["data_dir"] . "/" . $user . "/tokens.json";
10
11 /* Read from file */
12 if (file_exists($tokens_storage)) {
13 $tokens = json_decode(file_get_contents($tokens_storage));
14 } else {
15 die();
16 }
17
18 ?>
19
20 <!-- Headline -->
21 <h4><?php echo $GLOBALS["i18n_account"] . ": " . $user; ?></h4>
22
23 <!-- Bookmarklet -->
24 <section id="bookmarklet">
25 <h5><?php echo $GLOBALS["i18n_bookmarklet"]; ?></h5>
26 <p><?php echo $GLOBALS["i18n_bookmarklet_tp"]; ?></p>
27 <a
28 class="button"
29 href="<?php echo bookmarklet(); ?>"
30 onclick="window.alert('<?php echo $GLOBALS["i18n_bookmarklet_tp"];?>');"
31 title="<?php echo $GLOBALS["i18n_bookmarklet_tp"]; ?>"
32 >
33 Rememori
34 </a>
35 <br><br>
36 <a href="https://src.jayvii.de/pub/rememori/#faqs" target="_blank">
37 <?php echo $GLOBALS["i18n_howto"]; ?>
38 </a>
39 </section>
40
41 <!-- Tokens -->
42 <section id="tokens">
43 <h5><?php echo $GLOBALS["i18n_tokens"]; ?></h5>
44 <p><?php echo $GLOBALS["i18n_tokens_info"]; ?></p>
45 <form action="/" target="_self" method="post">
46 <input
47 id="action"
48 name="action"
49 type="hidden"
50 value="update_tokens"
51 >
52 <?php
53
54 /* cycle through each token and list it in the form */
55 for ($i = 0; $i < count($tokens); $i++) {
56
57 /* mark token as "current" if the user is auth'ed with it */
58 if ($token == $tokens[$i]) {
59 $class="marked";
60 } else {
61 $class = "";
62 }
63
64 ?>
65 <label for="token_<?php echo $i; ?>">
66 Token <?php echo ($i + 1); ?>
67 </label>
68 <stretch style="font-size:66%;">
69 <?php if ($token == $tokens[$i]) { echo " " . $GLOBALS["i18n_tokens_curr"]; } ?>
70 </stretch>
71 <input
72 id="token_<?php echo $i; ?>"
73 name="token_<?php echo $i; ?>"
74 class="<?php echo $class; ?>"
75 type="text"
76 value="<?php echo $tokens[$i]; ?>"
77 >
78 <br>
79 <?php
80 } // for-loop
81 ?>
82 <input type="submit" value="<?php echo $GLOBALS["i18n_save"]; ?>">
83 </form>
84 </section>
85
86 <!-- New token -->
87 <section id="new_token">
88 <h5><?php echo $GLOBALS["i18n_tokens_add"]; ?></h5>
89 <p><?php echo $GLOBALS["i18n_tokens_add_info"]; ?></p>
90 <form action="/" target="_self" method="post">
91 <input
92 id="action"
93 name="action"
94 type="hidden"
95 value="add_password"
96 >
97 <input id="new_pass" name="new_pass" type="text" placeholder="secret123">
98 <input type="submit" value="<?php echo $GLOBALS["i18n_save"]; ?>">
99 </form>
100 </section>
101
102 <?php
103
104 } // function
105
106 ?>