]> git.mxchange.org Git - friendica-addons.git/blob - jappixmini/jappix/php/manager.php
Merge branch '3.6-release'
[friendica-addons.git] / jappixmini / jappix / php / manager.php
1 <?php
2
3 /*
4
5 Jappix - An open social platform
6 This is the Jappix Manager PHP/HTML code
7
8 -------------------------------------------------
9
10 License: AGPL
11 Author: Vanaryon
12 Last revision: 26/08/11
13
14 */
15
16 // Someone is trying to hack us?
17 if(!defined('JAPPIX_BASE'))
18         exit;
19
20 // Get the manager functions
21 require_once(JAPPIX_BASE.'/php/functions-manager.php');
22
23 // Session manager
24 $id = 0;
25 $login_fired = false;
26 $logout_fired = false;
27 $form_parent = 'manager';
28 $user_password = '';
29 $user_remember = '';
30 $user = '';
31 $password = '';
32 $user_meta = T_("unknown");
33 $user_name = '';
34 $add_button = false;
35 $remove_button = false;
36 $save_button = false;
37 $check_updates = false;
38
39 // Start the session
40 session_start();
41
42 // Force the updates check?
43 if(isset($_GET['p']) && ($_GET['p'] == 'check'))
44         $check_updates = true;
45
46 // Login form is sent
47 if(isset($_POST['login'])) {
48         // Form sent pointer
49         $login_fired = true;
50         
51         // Extract the user name
52         if(isset($_POST['admin_name']) && !empty($_POST['admin_name']))
53                 $user = trim($_POST['admin_name']);
54         
55         if($user && (isset($_POST['admin_password']) && !empty($_POST['admin_password']))) {
56                 // Get the password values
57                 $password = genStrongHash(trim($_POST['admin_password']));
58                 
59                 // Write the session
60                 $_SESSION['jappix_user'] = $user;
61                 $_SESSION['jappix_password'] = $password;
62         }
63 }
64
65 // Session is set
66 else if((isset($_SESSION['jappix_user']) && !empty($_SESSION['jappix_user'])) && (isset($_SESSION['jappix_password']) && !empty($_SESSION['jappix_password']))) {
67         // Form sent pointer
68         $login_fired = true;
69         
70         // Get the session values
71         $user = $_SESSION['jappix_user'];
72         $password = $_SESSION['jappix_password'];
73 }
74
75 // Validate the current session
76 if($login_fired && isAdmin($user, $password))
77         $id = 1;
78
79 // Any special page requested (and authorized)?
80 if(($id != 0) && isset($_GET['a']) && !empty($_GET['a'])) {
81         // Extract the page name
82         $page_requested = $_GET['a'];
83         
84         switch($page_requested) {
85                 // Logout request
86                 case 'logout':
87                         // Remove the session
88                         unset($_SESSION['jappix_user']);
89                         unset($_SESSION['jappix_password']);
90                         
91                         // Set a logout marker
92                         $logout_fired = true;
93                         
94                         // Page ID
95                         $id = 0;
96                         
97                         break;
98                 
99                 // Configuration request
100                 case 'configuration':
101                         // Allowed buttons
102                         $save_button = true;
103                         
104                         // Page ID
105                         $id = 2;
106                         
107                         break;
108                 
109                 // Hosts request
110                 case 'hosts':
111                         // Allowed buttons
112                         $save_button = true;
113                         
114                         // Page ID
115                         $id = 3;
116                         
117                         break;
118                 
119                 // Storage request
120                 case 'storage':
121                         // Allowed buttons
122                         $remove_button = true;
123                         
124                         // Page ID
125                         $id = 4;
126                         
127                         break;
128                 
129                 // Design request
130                 case 'design':
131                         // Allowed buttons
132                         $save_button = true;
133                         $remove_button = true;
134                         
135                         // Page ID
136                         $id = 5;
137                         
138                         break;
139                 
140                 // Users request
141                 case 'users':
142                         // Allowed buttons
143                         $add_button = true;
144                         $remove_button = true;
145                         
146                         // Page ID
147                         $id = 6;
148                         
149                         break;
150                 
151                 // Updates request
152                 case 'updates':
153                         // Page ID
154                         $id = 7;
155                         
156                         break;
157                 
158                 // Default page when authorized (statistics)
159                 default:
160                         // Page ID
161                         $id = 1;
162         }
163 }
164
165 // Page server-readable names
166 $identifiers = array(
167         'login',
168         'statistics',
169         'configuration',
170         'hosts',
171         'storage',
172         'design',
173         'users',
174         'updates'
175 );
176
177 // Page human-readable names
178 $names = array(
179         T_("Manager access"),
180         T_("Statistics"),
181         T_("Configuration"),
182         T_("Hosts"),
183         T_("Storage"),
184         T_("Design"),
185         T_("Users"),
186         T_("Updates")
187 );
188
189 // Any user for the meta?
190 if($user && ($id != 0))
191         $user_meta = $user;
192
193 // Define current page identifier & name
194 $page_identifier = $identifiers[$id];
195 $page_name = $names[$id];
196
197 // Define the current page form action
198 if($id == 0)
199         $form_action = keepGet('(m|a|p|k)', false);
200 else
201         $form_action = keepGet('(m|p|k)', false);
202
203 ?>
204 <!DOCTYPE html>
205 <?php htmlTag($locale); ?>
206
207 <head>
208         <meta http-equiv="content-type" content="text/html; charset=utf-8" />
209         <meta name="robots" content="none" />
210         <title><?php _e("Jappix manager"); ?> &bull; <?php echo($page_name); ?></title>
211         <link rel="shortcut icon" href="./favicon.ico" />
212         <?php echoGetFiles($hash, '', 'css', 'manager.xml', ''); echo "\n"; ?>
213         <!--[if lt IE 9]><?php echoGetFiles($hash, '', 'css', '', 'ie.css'); ?><![endif]-->
214 </head>
215
216 <body class="body-images">
217         <form id="manager" enctype="multipart/form-data" method="post" action="./?m=manager<?php echo $form_action; ?>">
218                 <div id="manager-top">
219                         <div class="logo manager-images"><?php _e("Manager"); ?></div>
220                         
221                         <div class="meta">
222                                 <span><?php echo(htmlspecialchars($user_meta)); ?></span>
223                                 
224                                 <?php if($id != 0) {
225                                 
226                                         // Keep get
227                                         $keep_get = keepGet('(a|p|b|s|k)', false);
228                                 
229                                 ?>
230                                         <a class="logout manager-images" href="./?a=logout<?php echo $keep_get; ?>"><?php _e("Disconnect"); ?></a>
231                                 <?php } ?>
232                                 
233                                 <a class="close manager-images" href="./<?php echo keepGet('(m|a|p|b|s|k)', true); ?>"><?php _e("Close"); ?></a>
234                         </div>
235                         
236                         <div class="clear"></div>
237                 </div>
238                 
239                 <?php if($id != 0) { ?>
240                         <div id="manager-tabs">
241                                 <a<?php currentTab('statistics', $page_identifier); ?> href="./?a=statistics<?php echo $keep_get; ?>"><?php _e("Statistics"); ?></a>
242                                 <a<?php currentTab('configuration', $page_identifier); ?> href="./?a=configuration<?php echo $keep_get; ?>"><?php _e("Configuration"); ?></a>
243                                 <a<?php currentTab('hosts', $page_identifier); ?> href="./?a=hosts<?php echo $keep_get; ?>"><?php _e("Hosts"); ?></a>
244                                 <a<?php currentTab('storage', $page_identifier); ?> href="./?a=storage<?php echo $keep_get; ?>"><?php _e("Storage"); ?></a>
245                                 <a<?php currentTab('design', $page_identifier); ?> href="./?a=design<?php echo $keep_get; ?>"><?php _e("Design"); ?></a>
246                                 <a<?php currentTab('users', $page_identifier); ?> href="./?a=users<?php echo $keep_get; ?>"><?php _e("Users"); ?></a>
247                                 <a<?php currentTab('updates', $page_identifier); ?> class="last" href="./?a=updates<?php echo $keep_get; ?>"><?php _e("Updates"); ?></a>
248                         </div>
249                 <?php } ?>
250                 
251                 <div id="manager-content">
252                         <?php
253                         
254                         if($id != 0) {
255                                 if(!storageWritable()) { ?>
256                                         <p class="info bottomspace fail"><?php _e("Your storage folders are not writable, please apply the good rights!"); ?></p>
257                                 <?php }
258                                 
259                                 if(BOSHProxy() && extension_loaded('suhosin') && (ini_get('suhosin.get.max_value_length') < 1000000)) { ?>
260                                         <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>
261                                 <?php }
262                                 
263                                 if(newUpdates($check_updates)) { ?>
264                                         <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>
265                                 <?php }
266                         }
267                         
268                         // Authorized and statistics page requested
269                         if($id == 1) { ?>
270                                 <h3 class="statistics manager-images"><?php _e("Statistics"); ?></h3>
271                                 
272                                 <p><?php _e("Basic statistics are processed by Jappix about some important things, you can find them below."); ?></p>
273                                 
274                                 <h4><?php _e("Access statistics"); ?></h4>
275                                 
276                                 <?php
277                                 
278                                 // Read the visits values
279                                 $visits = getVisits();
280                                 
281                                 ?>
282                                 
283                                 <ul class="stats">
284                                         <li class="total"><b><?php _e("Total"); ?></b><span><?php echo $visits['total']; ?></span></li>
285                                         <li><b><?php _e("Daily"); ?></b><span><?php echo $visits['daily']; ?></span></li>
286                                         <li><b><?php _e("Weekly"); ?></b><span><?php echo $visits['weekly']; ?></span></li>
287                                         <li><b><?php _e("Monthly"); ?></b><span><?php echo $visits['monthly']; ?></span></li>
288                                         <li><b><?php _e("Yearly"); ?></b><span><?php echo $visits['yearly']; ?></span></li>
289                                 </ul>
290                                 
291                                 <object class="stats" type="image/svg+xml" data="./php/stats-svg.php?l=<?php echo $locale; ?>&amp;g=access"></object>
292                                 
293                                 <?php
294                                 
295                                 // Get the share stats
296                                 $share_stats = shareStats();
297                                 
298                                 // Any share stats to display?
299                                 if(count($share_stats)) { ?>
300                                         <h4><?php _e("Share statistics"); ?></h4>
301                                         
302                                         <ol class="stats">
303                                                 <?php
304                                                 
305                                                 // Display the users who have the largest share folder
306                                                 $share_users = largestShare($share_stats, 8);
307                                                 
308                                                 foreach($share_users as $current_user => $current_value)
309                                                         echo('<li><b><a href="xmpp:'.$current_user.'">'.$current_user.'</a></b><span>'.formatBytes($current_value).'</span></li>');
310                                                 
311                                                 ?>
312                                         </ol>
313                                         
314                                         <object class="stats" type="image/svg+xml" data="./php/stats-svg.php?l=<?php echo $locale; ?>&amp;g=share"></object>
315                                 <?php } ?>
316                                 
317                                 <h4><?php _e("Other statistics"); ?></h4>
318                                 
319                                 <ul class="stats">
320                                         <li class="total"><b><?php _e("Total"); ?></b><span><?php echo formatBytes(sizeDir(JAPPIX_BASE.'/store/')); ?></span></li>
321                                         
322                                         <?php
323                                         
324                                         // Append the human-readable array values
325                                         $others_stats = otherStats();
326                                         
327                                         foreach($others_stats as $others_name => $others_value)
328                                                 echo('<li><b>'.$others_name.'</b><span>'.formatBytes($others_value).'</span></li>');
329                                         
330                                         ?>
331                                 </ul>
332                                 
333                                 <object class="stats" type="image/svg+xml" data="./php/stats-svg.php?l=<?php echo $locale; ?>&amp;g=others"></object>
334                         <?php }
335                         
336                         // Authorized and configuration page requested
337                         else if($id == 2) { ?>
338                                 <h3 class="configuration manager-images"><?php _e("Configuration"); ?></h3>
339                                 
340                                 <p><?php _e("Change your Jappix node configuration with this tool."); ?></p>
341                                 
342                                 <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>
343                                 
344                                 <?php
345                                 
346                                 // Define the main configuration variables
347                                 include(JAPPIX_BASE.'/php/vars-main.php');
348                                 
349                                 // Read the main configuration POST
350                                 if(isset($_POST['save'])) {
351                                         include(JAPPIX_BASE.'/php/post-main.php');
352                                         
353                                         // Show a success alert
354                                         ?>
355                                                 <p class="info smallspace success"><?php _e("Changes saved!"); ?></p>
356                                         <?php
357                                 }
358                                 
359                                 // Include the main configuration form
360                                 include(JAPPIX_BASE.'/php/form-main.php');
361                         }
362                         
363                         // Authorized and hosts page requested
364                         else if($id == 3) { ?>
365                                 <h3 class="hosts manager-images"><?php _e("Hosts"); ?></h3>
366                                 
367                                 <p><?php _e("Change the XMPP hosts that this Jappix node serve with this tool."); ?></p>
368                                 
369                                 <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>
370                                 
371                                 <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>
372                                 
373                                 <?php
374                                 
375                                 // Define the hosts configuration variables
376                                 include(JAPPIX_BASE.'/php/vars-hosts.php');
377                                 
378                                 // Read the hosts configuration POST
379                                 if(isset($_POST['save'])) {
380                                         include(JAPPIX_BASE.'/php/post-hosts.php');
381                                         
382                                         // Show a success alert
383                                         ?>
384                                                 <p class="info smallspace success"><?php _e("Changes saved!"); ?></p>
385                                         <?php
386                                 }
387                                 
388                                 // Include the hosts configuration form
389                                 include(JAPPIX_BASE.'/php/form-hosts.php');
390                         }
391                         
392                         // Authorized and storage page requested
393                         else if($id == 4) { ?>
394                                 <h3 class="storage manager-images"><?php _e("Storage"); ?></h3>
395                                 
396                                 <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>
397                                 
398                                 <?php
399                                 
400                                         // Include the store configuration vars
401                                         include(JAPPIX_BASE.'/php/vars-store.php');
402                                         
403                                         // Include the store configuration POST handler
404                                         include(JAPPIX_BASE.'/php/post-store.php');
405                                         
406                                         // Include the store configuration GET handler
407                                         include(JAPPIX_BASE.'/php/get-store.php');
408                                         
409                                 ?>
410                                 
411                                 <h4><?php _e("Maintenance"); ?></h4>
412                                 
413                                 <p><?php _e("Keep your Jappix node fresh and fast, clean the storage folders regularly!"); ?></p>
414                                 
415                                 <?php
416                                 
417                                         // Keep get
418                                         $keep_get = keepGet('p', false);
419                                 
420                                 ?>
421                                 
422                                 <ul>
423                                         <li class="total"><a href="./?p=everything<?php echo $keep_get; ?>"><?php _e("Clean everything"); ?></a></li>
424                                         <li><a href="./?p=cache<?php echo $keep_get; ?>"><?php _e("Purge cache"); ?></a></li>
425                                         <li><a href="./?p=logs<?php echo $keep_get; ?>"><?php _e("Purge logs"); ?></a></li>
426                                         <li><a href="./?p=send<?php echo $keep_get; ?>"><?php _e("Purge sent files"); ?></a></li>
427                                         <li><a href="./?p=updates<?php echo $keep_get; ?>"><?php _e("Purge updates"); ?></a></li>
428                                 </ul>
429                                 
430                                 <h4><?php _e("Share"); ?></h4>
431                                 
432                                 <p><?php _e("Stay tuned in what your users store on your server and remove undesired content with this tool."); ?></p>
433                                 
434                                 <fieldset>
435                                         <legend><?php _e("Browse"); ?></legend>
436                                         
437                                         <div class="browse">
438                                                 <?php
439                                                 
440                                                 // List the share files
441                                                 browseFolder($share_folder, 'share');
442                                                 
443                                                 ?>
444                                         </div>
445                                 </fieldset>
446                                 
447                                 <h4><?php _e("Music"); ?></h4>
448                                 
449                                 <p><?php _e("Upload your music (Ogg Vorbis, MP3 or WAV) to be able to listen to it in Jappix!"); ?></p>
450                                 
451                                 <p><?php printf(T_("The file you want to upload must be smaller than %s."), formatBytes(uploadMaxSize()).''); ?></p>
452                                 
453                                 <fieldset>
454                                         <legend><?php _e("New"); ?></legend>
455                                         
456                                         <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo(uploadMaxSize().''); ?>">
457                                         
458                                         <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)); ?>" />
459                                         
460                                         <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)); ?>" />
461                                         
462                                         <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)); ?>" />
463                                         
464                                         <label for="music_file"><?php _e("File"); ?></label><input id="music_file" type="file" name="music_file" accept="audio/*" />
465                                         <label for="music_upload"><?php _e("Upload"); ?></label><input id="music_upload" type="submit" name="upload" value="<?php _e("Upload"); ?>" />
466                                 </fieldset>
467                                 
468                                 <fieldset>
469                                         <legend><?php _e("Browse"); ?></legend>
470                                         
471                                         <div class="browse">
472                                                 <?php
473                                                 
474                                                 // List the music files
475                                                 browseFolder($music_folder, 'music');
476                                                 
477                                                 ?>
478                                         </div>
479                                 </fieldset>
480                         <?php }
481                         
482                         // Authorized and design page requested
483                         else if($id == 5) { ?>
484                                 <h3 class="design manager-images"><?php _e("Design"); ?></h3>
485                                 
486                                 <p><?php _e("Jappix is fully customisable: you can change its design right here."); ?></p>
487                                 
488                                 <?php
489                                 
490                                         // Include the design configuration vars
491                                         include(JAPPIX_BASE.'/php/vars-design.php');
492                                         
493                                         // Include the design configuration POST handler
494                                         include(JAPPIX_BASE.'/php/post-design.php');
495                                         
496                                         // Include the design configuration reader
497                                         include(JAPPIX_BASE.'/php/read-design.php');
498                                         
499                                         // Folder view?
500                                         if(isset($_GET['b']) && isset($_GET['s']) && ($_GET['b'] == 'backgrounds'))
501                                                 $backgrounds_folder = urldecode($_GET['s']);
502                                 
503                                 ?>
504                                 
505                                 <h4><?php _e("Logo"); ?></h4>
506                                 
507                                 <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>
508                                 
509                                 <div class="sub">
510                                         <p><?php _e("Upload each logo with the recommended maximum pixel size."); ?></p>
511                                         <p><?php _e("Your logo format must be PNG. Leave a field empty and the logo will not be changed."); ?></p>                                      
512                                         
513                                         <label for="logo_own_1_location">Jappix Desktop, <em>311×113</em></label><?php logoFormField('1', 'desktop_home'); ?>
514                                         <label for="logo_own_2_location">Jappix Desktop, <em>90×25</em></label><?php logoFormField('2', 'desktop_app'); ?>
515                                         <label for="logo_own_3_location">Jappix Mobile, <em>83×30</em></label><?php logoFormField('3', 'mobile'); ?>
516                                         <label for="logo_own_4_location">Jappix Mini, <em>81×22</em></label><?php logoFormField('4', 'mini'); ?>
517                                         
518                                         <label for="logo_own_upload"><?php _e("Upload"); ?></label><input id="logo_own_upload" type="submit" name="logo_upload" value="<?php _e("Upload"); ?>" />
519                                         
520                                         <div class="clear"></div>
521                                 </div>
522                                 
523                                 <h4><?php _e("Background"); ?></h4>
524                                 
525                                 <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>
526                                 
527                                 <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>
528                                 
529                                 <?php if($backgrounds_number) { ?>
530                                         <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>
531                                 
532                                         <div class="sub">
533                                                 <p><?php _e("Select a background to use and change the display options."); ?></p>
534                                                 
535                                                 <label for="background_image_file"><?php _e("Image"); ?></label><select id="background_image_file" name="background_image_file">
536                                                         <?php
537                                                         
538                                                                 // List the background files
539                                                                 foreach($backgrounds as $backgrounds_current) {
540                                                                         // Check this is the selected background
541                                                                         if($backgrounds_current == $background['image_file'])
542                                                                                 $backgrounds_selected = ' selected=""';
543                                                                         else
544                                                                                 $backgrounds_selected = '';
545                                                                         
546                                                                         // Encode the current background name
547                                                                         $backgrounds_current = htmlspecialchars($backgrounds_current);
548                                                                         
549                                                                         echo('<option value="'.$backgrounds_current.'"'.$backgrounds_selected.'>'.$backgrounds_current.'</option>');
550                                                                 }
551                                                         
552                                                         ?>
553                                                 </select>
554                                                 
555                                                 <label for="background_image_repeat"><?php _e("Repeat"); ?></label><select id="background_image_repeat" name="background_image_repeat">
556                                                         <option value="no-repeat"<?php echo($background_image_repeat_no); ?>><?php _e("No"); ?></option>
557                                                         <option value="repeat"<?php echo($background_image_repeat_all); ?>><?php _e("All"); ?></option>
558                                                         <option value="repeat-x"<?php echo($background_image_repeat_x); ?>><?php _e("Horizontal"); ?></option>
559                                                         <option value="repeat-y"<?php echo($background_image_repeat_y); ?>><?php _e("Vertical"); ?></option>
560                                                 </select>
561                                                 
562                                                 <label for="background_image_horizontal"><?php _e("Horizontal"); ?></label><select id="background_image_horizontal" name="background_image_horizontal">
563                                                         <option value="center"<?php echo($background_image_horizontal_center); ?>><?php _e("Center"); ?></option>
564                                                         <option value="left"<?php echo($background_image_horizontal_left); ?>><?php _e("Left"); ?></option>
565                                                         <option value="right"<?php echo($background_image_horizontal_right); ?>><?php _e("Right"); ?></option>
566                                                 </select>
567                                                 
568                                                 <label for="background_image_vertical"><?php _e("Vertical"); ?></label><select id="background_image_vertical" name="background_image_vertical">
569                                                         <option value="center"<?php echo($background_image_vertical_center); ?>><?php _e("Center"); ?></option>
570                                                         <option value="top"<?php echo($background_image_vertical_top); ?>><?php _e("Top"); ?></option>
571                                                         <option value="bottom"<?php echo($background_image_vertical_bottom); ?>><?php _e("Bottom"); ?></option>
572                                                 </select>
573                                                 
574                                                 <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); ?> />
575                                                 
576                                                 <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'])); ?>" />
577                                                 
578                                                 <div class="clear"></div>
579                                         </div>
580                                 <?php } ?>
581                                 
582                                 <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>
583                                 
584                                 <div class="sub">
585                                         <p><?php _e("Type the hexadecimal color value you want to use as a background."); ?></p>
586                                         
587                                         <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'])); ?>" />
588                                         
589                                         <div class="clear"></div>
590                                 </div>
591                                 
592                                 <h4><?php _e("Manage backgrounds"); ?></h4>
593                                 
594                                 <p><?php _e("You can add a new background to the list with this tool. Please send a valid image."); ?></p>
595                                 
596                                 <div class="sub">
597                                         <p><?php printf(T_("The file you want to upload must be smaller than %s."), formatBytes(uploadMaxSize()).''); ?></p>
598                                         
599                                         <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo(uploadMaxSize().''); ?>">
600                                         
601                                         <label for="background_image_location"><?php _e("File"); ?></label><input id="background_image_location" type="file" name="background_image_upload" accept="image/*" />
602                                         <label for="background_image_upload"><?php _e("Upload"); ?></label><input id="background_image_upload" type="submit" name="background_upload" value="<?php _e("Upload"); ?>" />
603                                         
604                                         <div class="clear"></div>
605                                 </div>
606                                 
607                                 <p><?php _e("If you want to remove some backgrounds, use the browser below."); ?></p>
608                                 
609                                 <fieldset>
610                                         <legend><?php _e("List"); ?></legend>
611                                         
612                                         <div class="browse">
613                                                 <?php
614                                                 
615                                                 // List the background files
616                                                 browseFolder($backgrounds_folder, 'backgrounds');
617                                                 
618                                                 ?>
619                                         </div>
620                                 </fieldset>
621                                 
622                                 <h4><?php _e("Notice"); ?></h4>
623                                 
624                                 <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>
625                                 
626                                 <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>
627                                 
628                                 <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>
629                                 
630                                 <div class="sub">
631                                         <p><?php _e("This notice only needs simple text to be displayed, but no code is allowed!"); ?></p>
632                                 </div>
633                                 
634                                 <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>
635                                 
636                                 <div class="sub">
637                                         <p><?php _e("You can customize your notice with embedded HTML, CSS and JavaScript, but you need to code the style."); ?></p>
638                                 </div>
639                                 
640                                 <div class="clear"></div>
641                                 
642                                 <textarea class="notice-text" name="notice_text" rows="8" cols="60"><?php echo(htmlspecialchars($notice_text)); ?></textarea>
643                         <?php }
644                         
645                         // Authorized and users page requested
646                         else if($id == 6) { ?>
647                                 <h3 class="users manager-images"><?php _e("Users"); ?></h3>
648                                 
649                                 <p><?php _e("You can define more than one administrator for this Jappix node. You can also change a password with this tool."); ?></p>
650                                 
651                                 <?php
652                                 
653                                 // Add an user?
654                                 if(isset($_POST['add'])) {
655                                         // Include the users POST handler
656                                         include(JAPPIX_BASE.'/php/post-users.php');
657                                         
658                                         if($valid_user) { ?>
659                                                 <p class="info smallspace success"><?php _e("The user has been added!"); ?></p>
660                                         <?php }
661                                         
662                                         else { ?>
663                                                 <p class="info smallspace fail"><?php _e("Oops, you missed something or the two passwords do not match!"); ?></p>
664                                 <?php }
665                                 }
666                                 
667                                 // Remove an user?
668                                 else if(isset($_POST['remove'])) {
669                                         // Initialize the match
670                                         $users_removed = false;
671                                         $users_remove = array();
672                                         
673                                         // Try to get the users to remove
674                                         foreach($_POST as $post_key => $post_value) {
675                                                 // Is it an admin user?
676                                                 if(preg_match('/^admin_(.+)$/i', $post_key)) {
677                                                         // Update the marker
678                                                         $users_removed = true;
679                                                         
680                                                         // Push the value to the global array
681                                                         array_push($users_remove, $post_value);
682                                                 }
683                                         }
684                                         
685                                         // Somebody has been removed
686                                         if($users_removed) {
687                                         
688                                                 // Remove the users!
689                                                 manageUsers('remove', $users_remove);
690                                         
691                                         ?>
692                                                 <p class="info smallspace success"><?php _e("The chosen users have been removed."); ?></p>
693                                         <?php }
694                                         
695                                         // Nobody has been removed
696                                         else { ?>
697                                                 <p class="info smallspace fail"><?php _e("You must select one or more users to be removed!"); ?></p>
698                                 <?php }
699                                 } ?>
700                                 
701                                 <h4><?php _e("Add"); ?></h4>
702                                 
703                                 <p><?php _e("Add a new user with this tool, or change a password (type an existing username). Please submit a strong password!"); ?></p>
704                                 
705                                 <?php
706                                 
707                                 // Include the user add form
708                                 include(JAPPIX_BASE.'/php/form-users.php');
709                                 
710                                 ?>
711                                 
712                                 <h4><?php _e("Manage"); ?></h4>
713                                 
714                                 <p><?php _e("Remove users with this tool. Note that you cannot remove an user if he is the only one remaining."); ?></p>
715                                 
716                                 <fieldset>
717                                         <legend><?php _e("List"); ?></legend>
718                                         
719                                         <div class="browse">
720                                                 <?php
721                                                 
722                                                 // List the users
723                                                 browseUsers();
724                                                 
725                                                 ?>
726                                         </div>
727                                 </fieldset>
728                         <?php }
729                         
730                         // Authorized and updates page requested
731                         else if($id == 7) { ?>
732                                 <h3 class="updates manager-images"><?php _e("Updates"); ?></h3>
733                                 
734                                 <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>
735                                 
736                                 <?php
737                                 
738                                 // Using developer mode (no need to update)?
739                                 if(isDeveloper()) { ?>
740                                         <h4><?php _e("Check for updates"); ?></h4>
741                                         
742                                         <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>svn up</em>'); ?></p>
743                                 <?php }
744                                 
745                                 // New updates available?
746                                 else if(newUpdates($check_updates)) {
747                                         // Get the update informations
748                                         $update_infos = updateInformations();
749                                         
750                                         // We can launch the update!
751                                         if(isset($_GET['p']) && ($_GET['p'] == 'update')) { ?>
752                                                 <h4><?php _e("Update in progress"); ?></h4>
753                                                 
754                                                 <?php if(processUpdate($update_infos['url'])) { ?>
755                                                         <p class="info smallspace success"><?php _e("Jappix has been updated: you are now running the latest version. Have fun!"); ?></p>
756                                                 <?php } else { ?>
757                                                         <p class="info smallspace fail"><?php _e("The update has failed! Please try again later."); ?></p>
758                                                 <?php }
759                                         }
760                                         
761                                         // We just show a notice
762                                         else {
763                                 ?>
764                                                 <h4><?php _e("Available updates"); ?></h4>
765                                                 
766                                                 <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>
767                                                 
768                                                 <h4><?php _e("What's new?"); ?></h4>
769                                                 
770                                                 <div><?php echo $update_infos['description']; ?></div>
771                                 <?php }
772                                 
773                                 // No new update
774                                 } else { ?>
775                                         <h4><?php _e("Check for updates"); ?></h4>
776                                         
777                                         <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>
778                                 <?php } ?>
779                         <?php }
780                         
781                         // Not authorized, show the login form
782                         else { ?>
783                                 <h3 class="login manager-images"><?php _e("Manager access"); ?></h3>
784                                 
785                                 <p><?php _e("This is a restricted area: only the authorized users can manage this Jappix node."); ?></p>
786                                 <p><?php _e("Please use the form below to login to the administration panel."); ?></p>
787                                 <p><?php _e("To improve security, sessions are limited in time and when your browser will be closed, you will be logged out."); ?></p>
788                                 
789                                 <fieldset>
790                                         <legend><?php _e("Credentials"); ?></legend>
791                                         
792                                         <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="" />
793                                         
794                                         <label for="admin_password"><?php _e("Password"); ?></label><input id="admin_password" class="icon manager-images" type="password" name="admin_password" required="" />
795                                 </fieldset>
796                                 
797                                 <?php
798                                 
799                                 // Disconnected
800                                 if($logout_fired) { ?>
801                                         <p class="info bigspace success"><?php _e("You have been logged out. Goodbye!"); ?></p>
802                                 <?php }
803                                 
804                                 // Login error
805                                 else if($login_fired) { ?>
806                                         <p class="info bigspace fail"><?php _e("Oops, you could not be recognized as a valid administrator. Check your credentials!"); ?></p>
807                                 <?php
808                                 
809                                         // Remove the session
810                                         unset($_SESSION['jappix_user']);
811                                         unset($_SESSION['jappix_password']);
812                                 
813                                 }
814                         } ?>
815                         
816                         <div class="clear"></div>
817                 </div>
818                 
819                 <div id="manager-buttons">
820                         <?php if($id == 0) { ?>
821                                 <input type="submit" name="login" value="<?php _e("Here we go!"); ?>" />
822                         <?php } else { ?>
823                                 <?php } if($add_button) { ?>
824                                         <input type="submit" name="add" value="<?php _e("Add"); ?>" />
825                                 <?php } if($save_button) { ?>
826                                         <input type="submit" name="save" value="<?php _e("Save"); ?>" />
827                                 <?php } if($remove_button) { ?>
828                                         <input type="submit" name="remove" value="<?php _e("Remove"); ?>" />
829                         <?php } ?>
830                         
831                         <div class="clear"></div>
832                 </div>
833                 
834         </form>
835 </body>
836
837 </html>
838
839 <!-- Jappix Manager <?php echo $version; ?> - An open social platform -->