Welcome to mirror list, hosted at ThFree Co, Russian Federation.

manager.php « server - github.com/jappix/jappix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9559c5635e69d0233fd46187494725f48cbc379b (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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
<?php

/*

Jappix - An open social platform
This is the Jappix Manager PHP/HTML code

-------------------------------------------------

License: AGPL
Authors: Valérian Saliou, Cyril "Kyriog" Glapa

*/

// Someone is trying to hack us?
if(!defined('JAPPIX_BASE')) {
    exit;
}

// Get the manager functions
require_once(JAPPIX_BASE.'/server/functions-manager.php');

// Session manager
$id = 0;
$login_fired = false;
$logout_fired = false;
$form_parent = 'manager';
$user_password = '';
$user_remember = '';
$user = '';
$password = '';
$user_meta = T_("unknown");
$user_name = '';
$add_button = false;
$remove_button = false;
$save_button = false;
$check_updates = false;

// Start the session
session_start();

// Force the updates check?
if(isset($_GET['p']) && ($_GET['p'] == 'check')) {
    $check_updates = true;
}

// Login form is sent
if(isset($_POST['login'])) {
    // Form sent pointer
    $login_fired = true;

    // Extract the user name
    if(isset($_POST['admin_name']) && !empty($_POST['admin_name'])) {
        $user = trim($_POST['admin_name']);
    }

    if($user && (isset($_POST['admin_password']) && !empty($_POST['admin_password']))) {
        // Get the password values
        $password = genStrongHash(trim($_POST['admin_password']));

        // Write the session
        $_SESSION['jappix_user'] = $user;
        $_SESSION['jappix_password'] = $password;
    }
}

// Session is set
else if((isset($_SESSION['jappix_user']) && !empty($_SESSION['jappix_user'])) && (isset($_SESSION['jappix_password']) && !empty($_SESSION['jappix_password']))) {
    // Form sent pointer
    $login_fired = true;

    // Get the session values
    $user = $_SESSION['jappix_user'];
    $password = $_SESSION['jappix_password'];
}

// Validate the current session
if($login_fired && isAdmin($user, $password)) {
    $id = 1;
}

// Any special page requested (and authorized)?
if(($id != 0) && isset($_GET['a']) && !empty($_GET['a'])) {
    // Extract the page name
    $page_requested = $_GET['a'];

    switch($page_requested) {
        // Logout request
        case 'logout':
            // Remove the session
            unset($_SESSION['jappix_user']);
            unset($_SESSION['jappix_password']);

            // Set a logout marker
            $logout_fired = true;

            // Page ID
            $id = 0;

            break;

        // Configuration request
        case 'configuration':
            // Allowed buttons
            $save_button = true;

            // Page ID
            $id = 2;

            break;

        // Hosts request
        case 'hosts':
            // Allowed buttons
            $save_button = true;

            // Page ID
            $id = 3;

            break;

        // Storage request
        case 'storage':
            // Allowed buttons
            $remove_button = true;

            // Page ID
            $id = 4;

            break;

        // Design request
        case 'design':
            // Allowed buttons
            $save_button = true;
            $remove_button = true;

            // Page ID
            $id = 5;

            break;

        // Users request
        case 'users':
            // Allowed buttons
            $add_button = true;
            $remove_button = true;

            // Page ID
            $id = 6;

            break;

        // Updates request
        case 'updates':
            // Page ID
            $id = 7;

            break;

        // Default page when authorized (statistics)
        default:
            // Page ID
            $id = 1;
    }
}

// Page server-readable names
$identifiers = array(
    'login',
    'statistics',
    'configuration',
    'hosts',
    'storage',
    'design',
    'users',
    'updates'
);

// Page human-readable names
$names = array(
    T_("Manager access"),
    T_("Statistics"),
    T_("Configuration"),
    T_("Hosts"),
    T_("Storage"),
    T_("Design"),
    T_("Users"),
    T_("Updates")
);

// Any user for the meta?
if($user && ($id != 0)) {
    $user_meta = $user;
}

// Define current page identifier & name
$page_identifier = $identifiers[$id];
$page_name = $names[$id];

// Define the current page form action
if($id == 0) {
    $form_action = keepGet('(m|a|p|k)', false);
} else {
    $form_action = keepGet('(m|p|k)', false);
}

?>
<!DOCTYPE html>
<?php htmlTag($locale); ?>

<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta name="robots" content="noindex, follow" />
    <title><?php _e("Jappix manager"); ?> &bull; <?php echo($page_name); ?></title>
    <link rel="shortcut icon" href="./favicon.ico" />
    <?php echoGetFiles($hash, '', 'css', 'manager.xml', ''); echo "\n"; ?>
    <!--[if lt IE 9]><?php echoGetFiles($hash, '', 'css', '', 'ie.css'); ?><![endif]-->
</head>

<body class="body-images">
    <form id="manager" enctype="multipart/form-data" method="post" action="./?m=manager<?php echo $form_action; ?>">
        <div id="manager-top">
            <div class="logo manager-images"><?php _e("Manager"); ?></div>

            <div class="meta">
                <span><?php echo(htmlspecialchars($user_meta)); ?></span>

                <?php if($id != 0) {

                    // Keep get
                    $keep_get = keepGet('(a|p|b|s|k)', false);

                ?>
                    <a class="logout manager-images" href="./?a=logout<?php echo $keep_get; ?>"><?php _e("Disconnect"); ?></a>
                <?php } ?>

                <a class="close manager-images" href="./<?php echo keepGet('(m|a|p|b|s|k)', true); ?>"><?php _e("Close"); ?></a>
            </div>

            <div class="clear"></div>
        </div>

        <?php if($id != 0) { ?>
            <div id="manager-tabs">
                <a<?php currentTab('statistics', $page_identifier); ?> href="./?a=statistics<?php echo $keep_get; ?>"><?php _e("Statistics"); ?></a>
                <a<?php currentTab('configuration', $page_identifier); ?> href="./?a=configuration<?php echo $keep_get; ?>"><?php _e("Configuration"); ?></a>
                <a<?php currentTab('hosts', $page_identifier); ?> href="./?a=hosts<?php echo $keep_get; ?>"><?php _e("Hosts"); ?></a>
                <a<?php currentTab('storage', $page_identifier); ?> href="./?a=storage<?php echo $keep_get; ?>"><?php _e("Storage"); ?></a>
                <a<?php currentTab('design', $page_identifier); ?> href="./?a=design<?php echo $keep_get; ?>"><?php _e("Design"); ?></a>
                <a<?php currentTab('users', $page_identifier); ?> href="./?a=users<?php echo $keep_get; ?>"><?php _e("Users"); ?></a>
                <a<?php currentTab('updates', $page_identifier); ?> class="last" href="./?a=updates<?php echo $keep_get; ?>"><?php _e("Updates"); ?></a>
            </div>
        <?php } ?>

        <div id="manager-content">
            <?php

            if($id != 0) {
                if(!storageWritable()) { ?>
                    <p class="info bottomspace fail"><?php _e("Your storage folders are not writable, please apply the good rights!"); ?></p>
                <?php }

                if(BOSHProxy() && extension_loaded('suhosin') && (ini_get('suhosin.get.max_value_length') < 1000000)) { ?>
                    <p class="info bottomspace neutral"><?php printf(T_("%1s may cause problems to the proxy, please increase %2s value up to %3s!"), 'Suhosin', '<em>suhosin.get.max_value_length</em>', '1000000'); ?></p>
                <?php }

                if(newUpdates($check_updates)) { ?>
                    <a class="info bottomspace neutral" href="./?a=updates<?php echo $keep_get; ?>"><?php _e("A new Jappix version is available! Check what is new and launch the update!"); ?></a>
                <?php }
            }

            // Authorized and statistics page requested
            if($id == 1) { ?>
                <h3 class="statistics manager-images"><?php _e("Statistics"); ?></h3>

                <p><?php _e("Basic statistics are processed by Jappix about some important things, you can find them below."); ?></p>
                <?php if(!hasStatistics()): ?>
                  <p><?php _e("Statistics are currently disabled in the settings."); ?></p>
                <?php else: ?>
                <h4><?php _e("Access statistics"); ?></h4>

                <?php

                // Read the visits values
                $visits = getVisits();

                ?>

                <ul class="stats">
                    <li class="total"><b><?php _e("Total"); ?></b><span><?php echo $visits['total']; ?></span></li>
                    <li><b><?php _e("Daily"); ?></b><span><?php echo $visits['daily']; ?></span></li>
                    <li><b><?php _e("Weekly"); ?></b><span><?php echo $visits['weekly']; ?></span></li>
                    <li><b><?php _e("Monthly"); ?></b><span><?php echo $visits['monthly']; ?></span></li>
                    <li><b><?php _e("Yearly"); ?></b><span><?php echo $visits['yearly']; ?></span></li>
                </ul>

                <object class="stats" type="image/svg+xml" data="./server/stats-svg.php?l=<?php echo $locale; ?>&amp;g=access"></object>

                <?php

                // Get the share stats
                $share_stats = shareStats();

                // Any share stats to display?
                if(count($share_stats)) { ?>
                    <h4><?php _e("Share statistics"); ?></h4>

                    <ol class="stats">
                        <?php

                        // Display the users who have the largest share folder
                        $share_users = largestShare($share_stats, 8);

                        foreach($share_users as $current_user => $current_value)
                            echo('<li><b><a href="xmpp:'.$current_user.'">'.$current_user.'</a></b><span>'.formatBytes($current_value).'</span></li>');

                        ?>
                    </ol>

                    <object class="stats" type="image/svg+xml" data="./server/stats-svg.php?l=<?php echo $locale; ?>&amp;g=share"></object>
                <?php } ?>

                <h4><?php _e("Other statistics"); ?></h4>

                <ul class="stats">
                    <li class="total"><b><?php _e("Total"); ?></b><span><?php echo formatBytes(sizeDir(JAPPIX_BASE.'/store/')); ?></span></li>

                    <?php

                    // Append the human-readable array values
                    $others_stats = otherStats();

                    foreach($others_stats as $others_name => $others_value)
                        echo('<li><b>'.$others_name.'</b><span>'.formatBytes($others_value).'</span></li>');

                    ?>
                </ul>

                <object class="stats" type="image/svg+xml" data="./server/stats-svg.php?l=<?php echo $locale; ?>&amp;g=others"></object>
            <?php endif ?>
            <?php }

            // Authorized and configuration page requested
            else if($id == 2) { ?>
                <h3 class="configuration manager-images"><?php _e("Configuration"); ?></h3>

                <p><?php _e("Change your Jappix node configuration with this tool."); ?></p>

                <p><?php _e("Note that if you don't specify a value which is compulsory, it will be automatically completed with the default one."); ?></p>

                <?php

                // Define the main configuration variables
                include(JAPPIX_BASE.'/server/vars-main.php');

                // Read the main configuration POST
                if(isset($_POST['save'])) {
                    include(JAPPIX_BASE.'/server/post-main.php');

                    // Show a success alert
                    ?>
                        <p class="info smallspace success"><?php _e("Changes saved!"); ?></p>
                    <?php
                }

                // Include the main configuration form
                include(JAPPIX_BASE.'/server/form-main.php');
            }

            // Authorized and hosts page requested
            else if($id == 3) { ?>
                <h3 class="hosts manager-images"><?php _e("Hosts"); ?></h3>

                <p><?php _e("Change the XMPP hosts that this Jappix node serves with this tool."); ?></p>

                <p><?php _e("Maybe you don't know what a BOSH server is? In fact, this is a relay between a Jappix client and a XMPP server, which is necessary because of technical limitations."); ?></p>

                <p><?php _e("Note that if you don't specify a value which is compulsory, it will be automatically completed with the default one."); ?></p>

                <?php

                // Define the hosts configuration variables
                include(JAPPIX_BASE.'/server/vars-hosts.php');

                // Read the hosts configuration POST
                if(isset($_POST['save'])) {
                    include(JAPPIX_BASE.'/server/post-hosts.php');

                    // Show a success alert
                    ?>
                        <p class="info smallspace success"><?php _e("Changes saved!"); ?></p>
                    <?php
                }

                // Include the hosts configuration form
                include(JAPPIX_BASE.'/server/form-hosts.php');
            }

            // Authorized and storage page requested
            else if($id == 4) { ?>
                <h3 class="storage manager-images"><?php _e("Storage"); ?></h3>

                <p><?php _e("All this Jappix node stored files can be managed with this tool: please select a sub-folder and start editing its content!"); ?></p>

                <?php

                    // Include the store configuration vars
                    include(JAPPIX_BASE.'/server/vars-store.php');

                    // Include the store configuration POST handler
                    include(JAPPIX_BASE.'/server/post-store.php');

                    // Include the store configuration GET handler
                    include(JAPPIX_BASE.'/server/get-store.php');

                ?>

                <h4><?php _e("Maintenance"); ?></h4>

                <p><?php _e("Keep your Jappix node fresh and fast, clean the storage folders regularly!"); ?></p>

                <?php

                    // Keep get
                    $keep_get = keepGet('p', false);

                ?>

                <ul>
                    <li class="total"><a href="./?p=everything<?php echo $keep_get; ?>"><?php _e("Clean everything"); ?></a></li>
                    <li><a href="./?p=cache<?php echo $keep_get; ?>"><?php _e("Purge cache"); ?></a></li>
                    <li><a href="./?p=archives<?php echo $keep_get; ?>"><?php _e("Purge logs"); ?></a></li>
                    <li><a href="./?p=send<?php echo $keep_get; ?>"><?php _e("Purge sent files"); ?></a></li>
                    <li><a href="./?p=updates<?php echo $keep_get; ?>"><?php _e("Purge updates"); ?></a></li>
                </ul>

                <h4><?php _e("Share"); ?></h4>

                <p><?php _e("Stay tuned in what your users store on your server and remove undesired content with this tool."); ?></p>

                <fieldset>
                    <legend><?php _e("Browse"); ?></legend>

                    <div class="browse">
                        <?php

                        // List the share files
                        browseFolder($share_folder, 'share');

                        ?>
                    </div>
                </fieldset>

                <h4><?php _e("Music"); ?></h4>

                <p><?php _e("Upload your music (Ogg Vorbis, MP3 or WAV) to be able to listen to it in Jappix!"); ?></p>

                <p><?php printf(T_("The file you want to upload must be smaller than %s."), formatBytes(uploadMaxSize()).''); ?></p>

                <fieldset>
                    <legend><?php _e("New"); ?></legend>

                    <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo(uploadMaxSize().''); ?>">

                    <label for="music_title"><?php _e("Title"); ?></label><input id="music_title" class="icon manager-images" type="text" name="music_title" value="<?php echo(htmlspecialchars($music_title)); ?>" />

                    <label for="music_artist"><?php _e("Artist"); ?></label><input id="music_artist" class="icon manager-images" type="text" name="music_artist" value="<?php echo(htmlspecialchars($music_artist)); ?>" />

                    <label for="music_album"><?php _e("Album"); ?></label><input id="music_album" class="icon manager-images" type="text" name="music_album" value="<?php echo(htmlspecialchars($music_album)); ?>" />

                    <label for="music_file"><?php _e("File"); ?></label><input id="music_file" type="file" name="music_file" accept="audio/*" />
                    <label for="music_upload"><?php _e("Upload"); ?></label><input id="music_upload" type="submit" name="upload" value="<?php _e("Upload"); ?>" />
                </fieldset>

                <fieldset>
                    <legend><?php _e("Browse"); ?></legend>

                    <div class="browse">
                        <?php

                        // List the music files
                        browseFolder($music_folder, 'music');

                        ?>
                    </div>
                </fieldset>
            <?php }

            // Authorized and design page requested
            else if($id == 5) { ?>
                <h3 class="design manager-images"><?php _e("Design"); ?></h3>

                <p><?php _e("Jappix is fully customisable: you can change its design right here."); ?></p>

                <?php

                    // Include the design configuration vars
                    include(JAPPIX_BASE.'/server/vars-design.php');

                    // Include the design configuration POST handler
                    include(JAPPIX_BASE.'/server/post-design.php');

                    // Include the design configuration reader
                    include(JAPPIX_BASE.'/server/read-design.php');

                    // Folder view?
                    if(isset($_GET['b']) && isset($_GET['s']) && ($_GET['b'] == 'backgrounds'))
                        $backgrounds_folder = urldecode($_GET['s']);

                ?>

                <h4><?php _e("Logo"); ?></h4>

                <p><?php _e("You can set your own service logo to replace the default one. Take care of the size and the main color of each logo!"); ?></p>

                <div class="sub">
                    <p><?php _e("Upload each logo with the recommended maximum pixel size."); ?></p>
                    <p><?php _e("Your logo format must be PNG. Leave a field empty and the logo will not be changed."); ?></p>

                    <label for="logo_own_1_location">Jappix Desktop, <em>311×113</em></label><?php logoFormField('1', 'desktop_home'); ?>
                    <label for="logo_own_2_location">Jappix Desktop, <em>90×25</em></label><?php logoFormField('2', 'desktop_app'); ?>
                    <label for="logo_own_3_location">Jappix Mobile, <em>83×30</em></label><?php logoFormField('3', 'mobile'); ?>
                    <label for="logo_own_4_location">Jappix Mini, <em>81×22</em></label><?php logoFormField('4', 'mini'); ?>

                    <label for="logo_own_upload"><?php _e("Upload"); ?></label><input id="logo_own_upload" type="submit" name="logo_upload" value="<?php _e("Upload"); ?>" />

                    <div class="clear"></div>
                </div>

                <h4><?php _e("Background"); ?></h4>

                <p><?php _e("Change your Jappix node background with this tool. You can either set a custom color or an uploaded image. Let your creativity flow!"); ?></p>

                <label class="master" for="background_default"><input id="background_default" type="radio" name="background_type" value="default"<?php echo($background_default); ?> /><?php _e("Use default background"); ?></label>

                <?php if($backgrounds_number) { ?>
                    <label class="master" for="background_image"><input id="background_image" type="radio" name="background_type" value="image"<?php echo($background_image); ?> /><?php _e("Use your own image"); ?></label>

                    <div class="sub">
                        <p><?php _e("Select a background to use and change the display options."); ?></p>

                        <label for="background_image_file"><?php _e("Image"); ?></label><select id="background_image_file" name="background_image_file">
                            <?php

                                // List the background files
                                foreach($backgrounds as $backgrounds_current) {
                                    // Check this is the selected background
                                    if($backgrounds_current == $background['image_file'])
                                        $backgrounds_selected = ' selected=""';
                                    else
                                        $backgrounds_selected = '';

                                    // Encode the current background name
                                    $backgrounds_current = htmlspecialchars($backgrounds_current);

                                    echo('<option value="'.$backgrounds_current.'"'.$backgrounds_selected.'>'.$backgrounds_current.'</option>');
                                }

                            ?>
                        </select>

                        <label for="background_image_repeat"><?php _e("Repeat"); ?></label><select id="background_image_repeat" name="background_image_repeat">
                            <option value="no-repeat"<?php echo($background_image_repeat_no); ?>><?php _e("No"); ?></option>
                            <option value="repeat"<?php echo($background_image_repeat_all); ?>><?php _e("All"); ?></option>
                            <option value="repeat-x"<?php echo($background_image_repeat_x); ?>><?php _e("Horizontal"); ?></option>
                            <option value="repeat-y"<?php echo($background_image_repeat_y); ?>><?php _e("Vertical"); ?></option>
                        </select>

                        <label for="background_image_horizontal"><?php _e("Horizontal"); ?></label><select id="background_image_horizontal" name="background_image_horizontal">
                            <option value="center"<?php echo($background_image_horizontal_center); ?>><?php _e("Center"); ?></option>
                            <option value="left"<?php echo($background_image_horizontal_left); ?>><?php _e("Left"); ?></option>
                            <option value="right"<?php echo($background_image_horizontal_right); ?>><?php _e("Right"); ?></option>
                        </select>

                        <label for="background_image_vertical"><?php _e("Vertical"); ?></label><select id="background_image_vertical" name="background_image_vertical">
                            <option value="center"<?php echo($background_image_vertical_center); ?>><?php _e("Center"); ?></option>
                            <option value="top"<?php echo($background_image_vertical_top); ?>><?php _e("Top"); ?></option>
                            <option value="bottom"<?php echo($background_image_vertical_bottom); ?>><?php _e("Bottom"); ?></option>
                        </select>

                        <label for="background_image_adapt"><?php _e("Adapt"); ?></label><input id="background_image_adapt" type="checkbox" name="background_image_adapt"<?php echo($background_image_adapt); ?> />

                        <label for="background_image_color"><?php _e("Color"); ?></label><input id="background_image_color" class="icon manager-images" type="color" name="background_image_color" value="<?php echo(htmlspecialchars($background['image_color'])); ?>" />

                        <div class="clear"></div>
                    </div>
                <?php } ?>

                <label class="master" for="background_color"><input id="background_color" type="radio" name="background_type" value="color"<?php echo($background_color); ?> /><?php _e("Use your own color"); ?></label>

                <div class="sub">
                    <p><?php _e("Type the hexadecimal color value you want to use as a background."); ?></p>

                    <label for="background_color_color"><?php _e("Color"); ?></label><input id="background_color_color" class="icon manager-images" type="color" name="background_color_color" value="<?php echo(htmlspecialchars($background['color_color'])); ?>" />

                    <div class="clear"></div>
                </div>

                <h4><?php _e("Manage backgrounds"); ?></h4>

                <p><?php _e("You can add a new background to the list with this tool. Please send a valid image."); ?></p>

                <div class="sub">
                    <p><?php printf(T_("The file you want to upload must be smaller than %s."), formatBytes(uploadMaxSize()).''); ?></p>

                    <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo(uploadMaxSize().''); ?>">

                    <label for="background_image_location"><?php _e("File"); ?></label><input id="background_image_location" type="file" name="background_image_upload" accept="image/*" />
                    <label for="background_image_upload"><?php _e("Upload"); ?></label><input id="background_image_upload" type="submit" name="background_upload" value="<?php _e("Upload"); ?>" />

                    <div class="clear"></div>
                </div>

                <p><?php _e("If you want to remove some backgrounds, use the browser below."); ?></p>

                <fieldset>
                    <legend><?php _e("List"); ?></legend>

                    <div class="browse">
                        <?php

                        // List the background files
                        browseFolder($backgrounds_folder, 'backgrounds');

                        ?>
                    </div>
                </fieldset>

                <h4><?php _e("Notice"); ?></h4>

                <p><?php _e("Define a homepage notice for all your users, such as a warn, an important message or an advert with this tool."); ?></p>

                <label class="master" for="notice_none"><input id="notice_none" type="radio" name="notice_type" value="none"<?php echo($notice_none); ?> /><?php _e("None"); ?></label>

                <label class="master" for="notice_simple"><input id="notice_simple" type="radio" name="notice_type" value="simple"<?php echo($notice_simple); ?> /><?php _e("Simple notice"); ?></label>

                <div class="sub">
                    <p><?php _e("This notice only needs simple text to be displayed, but no code is allowed!"); ?></p>
                </div>

                <label class="master" for="notice_advanced"><input id="notice_advanced" type="radio" name="notice_type" value="advanced"<?php echo($notice_advanced); ?> /><?php _e("Advanced notice"); ?></label>

                <div class="sub">
                    <p><?php _e("You can customize your notice with embedded HTML, CSS and JavaScript, but you need to code the style."); ?></p>
                </div>

                <div class="clear"></div>

                <textarea class="notice-text" name="notice_text" rows="8" cols="60"><?php echo(htmlspecialchars($notice_text)); ?></textarea>
            <?php }

            // Authorized and users page requested
            else if($id == 6) { ?>
                <h3 class="users manager-images"><?php _e("Users"); ?></h3>

                <p><?php _e("You can define more than one administrator for this Jappix node. You can also change a password with this tool."); ?></p>

                <?php

                // Add an user?
                if(isset($_POST['add'])) {
                    // Include the users POST handler
                    include(JAPPIX_BASE.'/server/post-users.php');

                    if($valid_user) { ?>
                        <p class="info smallspace success"><?php _e("The user has been added!"); ?></p>
                    <?php }

                    else { ?>
                        <p class="info smallspace fail"><?php _e("Oops, you missed something or the two passwords do not match!"); ?></p>
                <?php }
                }

                // Remove an user?
                else if(isset($_POST['remove'])) {
                    // Initialize the match
                    $users_removed = false;
                    $users_remove = array();

                    // Try to get the users to remove
                    foreach($_POST as $post_key => $post_value) {
                        // Is it an admin user?
                        if(preg_match('/^admin_(.+)$/i', $post_key)) {
                            // Update the marker
                            $users_removed = true;

                            // Push the value to the global array
                            array_push($users_remove, $post_value);
                        }
                    }

                    // Somebody has been removed
                    if($users_removed) {

                        // Remove the users!
                        manageUsers('remove', $users_remove);

                    ?>
                        <p class="info smallspace success"><?php _e("The chosen users have been removed."); ?></p>
                    <?php }

                    // Nobody has been removed
                    else { ?>
                        <p class="info smallspace fail"><?php _e("You must select one or more users to be removed!"); ?></p>
                <?php }
                } ?>

                <h4><?php _e("Add"); ?></h4>

                <p><?php _e("Add a new user with this tool, or change a password (type an existing username). Please submit a strong password!"); ?></p>

                <?php

                // Include the user add form
                include(JAPPIX_BASE.'/server/form-users.php');

                ?>

                <h4><?php _e("Manage"); ?></h4>

                <p><?php _e("Remove users with this tool. Note that you cannot remove a user if he is the only one remaining."); ?></p>

                <fieldset>
                    <legend><?php _e("List"); ?></legend>

                    <div class="browse">
                        <?php

                        // List the users
                        browseUsers();

                        ?>
                    </div>
                </fieldset>
            <?php }

            // Authorized and updates page requested
            else if($id == 7) { ?>
                <h3 class="updates manager-images"><?php _e("Updates"); ?></h3>

                <p><?php _e("Update your Jappix node with this tool, or check if a new one is available. Informations about the latest version are also displayed (in english)."); ?></p>

                <?php

                // Using developer mode (no need to update)?
                if(isDeveloper()) { ?>
                    <h4><?php _e("Check for updates"); ?></h4>

                    <p class="info smallspace neutral"><?php printf(T_("You are using a development version of Jappix. Update it through our repository by executing: %s."), '<em>git pull</em>'); ?></p>
                <?php }

                // New updates available?
                else if(newUpdates($check_updates)) {
                    // Get the update informations
                    $update_infos = updateInformations();

                    // We can launch the update!
                    if(isset($_GET['p']) && ($_GET['p'] == 'update')) { ?>
                        <h4><?php _e("Update in progress"); ?></h4>

                        <?php if(processUpdate($update_infos['url'])) { ?>
                            <p class="info smallspace success"><?php _e("Jappix has been updated: you are now running the latest version. Have fun!"); ?></p>
                        <?php } else { ?>
                            <p class="info smallspace fail"><?php _e("The update has failed! Please try again later."); ?></p>
                        <?php }
                    }

                    // We just show a notice
                    else {
                ?>
                        <h4><?php _e("Available updates"); ?></h4>

                        <a class="info smallspace fail" href="./?p=update<?php echo keepGet('(p|b|s)', false); ?>"><?php printf(T_("Your version is out to date. Update it now to %s by clicking here!"), '<em>'.$update_infos['id'].'</em>'); ?></a>

                        <h4><?php _e("What's new?"); ?></h4>

                        <div><?php echo $update_infos['description']; ?></div>
                <?php }

                // No new update
                } else { ?>
                    <h4><?php _e("Check for updates"); ?></h4>

                    <a class="info smallspace success" href="./?p=check<?php echo keepGet('(p|b|s)', false); ?>"><?php _e("Your version seems to be up to date, but you can check updates manually by clicking here."); ?></a>
                <?php } ?>
            <?php }

            // Not authorized, show the login form
            else { ?>
                <h3 class="login manager-images"><?php _e("Manager access"); ?></h3>

                <p><?php _e("This is a restricted area: only the authorized users can manage this Jappix node."); ?></p>
                <p><?php _e("Please use the form below to login to the administration panel."); ?></p>
                <p><?php _e("To improve security, sessions are limited in time and when your browser will be closed, you will be logged out."); ?></p>

                <fieldset>
                    <legend><?php _e("Credentials"); ?></legend>

                    <label for="admin_name"><?php _e("User"); ?></label><input id="admin_name" class="icon manager-images" type="text" name="admin_name" value="<?php echo(htmlspecialchars($user)); ?>" required="" />

                    <label for="admin_password"><?php _e("Password"); ?></label><input id="admin_password" class="icon manager-images" type="password" name="admin_password" required="" />
                </fieldset>

                <?php

                // Disconnected
                if($logout_fired) { ?>
                    <p class="info bigspace success"><?php _e("You have been logged out. Goodbye!"); ?></p>
                <?php }

                // Login error
                else if($login_fired) { ?>
                    <p class="info bigspace fail"><?php _e("Oops, you could not be recognized as a valid administrator. Check your credentials!"); ?></p>
                <?php

                    // Remove the session
                    unset($_SESSION['jappix_user']);
                    unset($_SESSION['jappix_password']);

                }
            } ?>

            <div class="clear"></div>
        </div>

        <div id="manager-buttons">
            <?php if($id == 0) { ?>
                <input type="submit" name="login" value="<?php _e("Here we go!"); ?>" />
            <?php } else { ?>
                <?php } if($add_button) { ?>
                    <input type="submit" name="add" value="<?php _e("Add"); ?>" />
                <?php } if($save_button) { ?>
                    <input type="submit" name="save" value="<?php _e("Save"); ?>" />
                <?php } if($remove_button) { ?>
                    <input type="submit" name="remove" value="<?php _e("Remove"); ?>" />
            <?php } ?>

            <div class="clear"></div>
        </div>

    </form>
</body>

</html>

<!-- Jappix Manager <?php echo $version; ?> - An open social platform -->