PageRenderTime 53ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/jappixmini/jappix/php/manager.php

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