aboutsummaryrefslogtreecommitdiff
path: root/app/view/templates/user.php
blob: faa44aa5174b22f3636de484f25aecf6096acb03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<?php

use Wcms\Model;

$this->layout('layout', ['title' => 'user', 'stylesheets' => [$css . 'home.css']]) ?>


<?php $this->start('page') ?>

<?php $this->insert('backtopbar', ['user' => $user, 'tab' => 'user', 'pagelist' => $pagelist]) ?>


<main class="user">

    <section id="user">
        <div class="block">

            
            <h1>User : <?= $user->id() ?></h1>
            
            <div class="scroll">


                <h2>Infos</h2>


                <p>Connections count : <?= $getuser->connectcount() ?></p>

                <p>Account will expire in : <?= $getuser->expiredate('hrdi') ?></p>



                <h2>Preferences</h2>

                <div id="preferences">

                    <form action="<?= $this->url('userpref') ?>" method="post">

                        <input type="number" name="cookie" value="<?= $getuser->cookie() ?>" id="cookie" min="0" max="<?= Model::MAX_COOKIE_CONSERVATION ?>">
                        <label for="cookie">Cookie conservation time <i>(In days)</i></label>
                        <p>When you tick the <em>remember-me</em> checkbox during login, you can choose how much time <strong>W</strong> will remember you.</p>

                        <input type="password" name="password" id="password" minlength="<?= Wcms\Model::PASSWORD_MIN_LENGTH ?>" maxlength="<?= Wcms\Model::PASSWORD_MAX_LENGTH ?>">
                        <label for="password">New password</label>
                        
                        <input type="hidden" name="passwordhash" value="1">

                        <p>Password have to be between <?= Wcms\Model::PASSWORD_MIN_LENGTH ?> and <?= Wcms\Model::PASSWORD_MAX_LENGTH ?> characters long.</p>

                        <input type="submit" value="update preferences">
                        
                    </form>

                </div>



                <h2>Sessions Tokens</h2>

                <ul>

                <?php foreach ($tokenlist as $token ) {
                    ?>
                    <li >
                        <code>
                            ip : <?= $token->ip ?> | date : <?= $token->date['date'] ?> | conservation : <?= $token->conservation ?> days | user agent : <?= $token->useragent ?>
                        </code>
                        <form action="<?= $this->url('usertoken') ?>" method="post">
                        <input type="hidden" name="tokendelete" value="<?= $token->getId() ?>" >
                        <input type="submit" value="delete">
                        </form>

                    </li>
                <?php
                } ?>
                </ul>

            </div>


        </div>

    </section>

    
    <?php if($user->isadmin()) { ?>
    
    <section>
        
        <div class="block">

            <h1>Admin panel</h1>
            
            <div class="scroll">

                <table>
                <tr>
                <th>id</th><th>password</th><th>hash</th><th>level</th><th>set expiration date</th><th>action</th><th>expire</th><th>connect</th>
                </tr>

                <tr>
                    <form action="<?= $this->url('useradd') ?>" method="post">
                    <td>
                            <input type="text" name="id" maxlength="<?= Wcms\Model::MAX_ID_LENGTH ?>" required>
                    </td>
                    <td>
                        <input type="password" name="password" id="password" minlength="<?= Wcms\Model::PASSWORD_MIN_LENGTH ?>" maxlength="<?= Wcms\Model::PASSWORD_MAX_LENGTH ?>" required>
                    </td>

                    <td>
                    <input type="hidden" name="passwordhashed" value="0">
                    <input type="checkbox" name="passwordhashed" value="1">
                    </td>

                    <td>
                        <select name="level" id="level">
                            <option value="1">reader</option>
                            <option value="2">invite</option>
                            <option value="3">editor</option>
                            <option value="4">super editor</option>
                            <option value="10">admin</option>
                        </select>
                    </td>
                    <td>
                        <input type="date" name="expiredate" id="expiredate" min="<?= $now->format('Y-m-d'); ?>">
                    </td>
                    <td>
                        <input type="submit" value="add">
                    </td>
                    <td>

                    </td>
                    <td>

                    </td>
                    
                    </form>
                </tr>


                <?php
                foreach ($userlist as $user ) {
                    ?>
                    
                    <tr>
                    <form action="<?= $this->url('userupdate') ?>" method="post">

                    <td>
                    <?= $user->id() ?>
                    </td>

                    <td>
                    <input type="password" name="password" minlength="<?= Wcms\Model::PASSWORD_MIN_LENGTH ?>" maxlength="<?= Wcms\Model::PASSWORD_MAX_LENGTH ?>" >
                    </td>

                    <td>
                    <?= $user->passwordhashed() ? '🔑' : '<input type="hidden" name="passwordhashed" value="0"><input type="checkbox" name="passwordhashed" value="1">' ?>
                    </td>

                    <td>
                    <select name="level" id="level">
                            <option value="1" <?= $user->level() === 1 ? 'selected' : '' ?>>reader</option>
                            <option value="2" <?= $user->level() === 2 ? 'selected' : '' ?>>invite</option>
                            <option value="3" <?= $user->level() === 3 ? 'selected' : '' ?>>editor</option>
                            <option value="4" <?= $user->level() === 4 ? 'selected' : '' ?>>super editor</option>
                            <option value="10" <?= $user->level() === 10 ? 'selected' : '' ?>>admin</option>
                    </select>
                    </td>


                    <td>
                        <input type="date" name="expiredate" id="expiredate"<?= $user->expiredate() !== false ?  'value="' . $user->expiredate('string') . '"' : '' ?>  min="<?= $now->format('Y-m-d'); ?>">
                        <span>reset<input type="checkbox" name="expiredate" id="expiredate" value="null"></span>
                        
                    </td>

                    <td>
                    <input type="hidden" name="id" value="<?= $user->id() ?>">
                    <input type="submit" name="action" value="update">
                    <input type="submit" name="action" value="delete">
                    </form>

                    </td>



                    <td>
                        <?= $user->expiredate('hrdi') ?>
                    </td>

                    <td>
                        <?= $user->connectcount() ?>
                    </td>


                    </tr>

                    <?php
                    }
                ?>

                </table>


            </div>

        </div>


    </section>

    <?php } ?>



</main>

<?php $this->stop('page') ?>