| 
									
										
										
										
											2024-06-28 17:05:32 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-01 09:45:07 +00:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Jilo web logs observer | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Description: A web interface to Jilo (JItsi Logs Observer), written in PHP | 
					
						
							|  |  |  |  * Author: Yasen Pramatarov | 
					
						
							|  |  |  |  * License: GPLv2 | 
					
						
							|  |  |  |  * Project URL: https://lindeas.com/jilo | 
					
						
							|  |  |  |  * Year: 2024 | 
					
						
							| 
									
										
										
										
											2024-07-25 16:10:53 +00:00
										 |  |  |  * Version: 0.1.1 | 
					
						
							| 
									
										
										
										
											2024-07-01 09:45:07 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-19 10:25:09 +00:00
										 |  |  | // we start output buffering and.
 | 
					
						
							|  |  |  | // flush it later only when there is no redirect
 | 
					
						
							|  |  |  | ob_start(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-04 19:14:12 +00:00
										 |  |  | // error reporting, comment out in production
 | 
					
						
							|  |  |  | ini_set('display_errors', 1); | 
					
						
							|  |  |  | ini_set('display_startup_errors', 1); | 
					
						
							|  |  |  | error_reporting(E_ALL); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-01 09:45:07 +00:00
										 |  |  | // list of available pages
 | 
					
						
							|  |  |  | // edit accordingly, add 'pages/PAGE.php'
 | 
					
						
							|  |  |  | $allowed_urls = [ | 
					
						
							|  |  |  |     'front', | 
					
						
							|  |  |  |     'login', | 
					
						
							|  |  |  |     'logout', | 
					
						
							|  |  |  |     'register', | 
					
						
							|  |  |  |     'profile', | 
					
						
							|  |  |  |     'config', | 
					
						
							| 
									
										
										
										
											2024-07-04 09:04:27 +00:00
										 |  |  |     'conferences', | 
					
						
							| 
									
										
										
										
											2024-07-07 09:10:41 +00:00
										 |  |  |     'participants', | 
					
						
							| 
									
										
										
										
											2024-07-08 09:17:35 +00:00
										 |  |  |     'components', | 
					
						
							| 
									
										
										
										
											2024-07-01 09:45:07 +00:00
										 |  |  | ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // cnfig file
 | 
					
						
							| 
									
										
										
										
											2024-08-01 08:20:31 +00:00
										 |  |  | // possible locations, in order of preference
 | 
					
						
							|  |  |  | $config_file_locations = [ | 
					
						
							| 
									
										
										
										
											2024-08-12 11:12:24 +00:00
										 |  |  |     __DIR__ . '/../app/config/jilo-web.conf.php', | 
					
						
							| 
									
										
										
										
											2024-08-01 08:20:31 +00:00
										 |  |  |     __DIR__ . '/../jilo-web.conf.php', | 
					
						
							|  |  |  |     '/srv/jilo-web/jilo-web.conf.php', | 
					
						
							|  |  |  |     '/opt/jilo-web/jilo-web.conf.php' | 
					
						
							|  |  |  | ]; | 
					
						
							|  |  |  | $config_file = null; | 
					
						
							|  |  |  | // try to find the config file
 | 
					
						
							|  |  |  | foreach ($config_file_locations as $location) { | 
					
						
							|  |  |  |     if (file_exists($location)) { | 
					
						
							|  |  |  |         $config_file = $location; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | // if found, use it
 | 
					
						
							|  |  |  | if ($config_file) { | 
					
						
							| 
									
										
										
										
											2024-08-13 14:53:52 +00:00
										 |  |  |     $config = require $config_file; | 
					
						
							| 
									
										
										
										
											2024-07-01 09:45:07 +00:00
										 |  |  | } else { | 
					
						
							|  |  |  |     die('Config file not found'); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-05 08:23:31 +00:00
										 |  |  | $app_root = $config['folder']; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-10 18:42:44 +00:00
										 |  |  | session_name('jilo'); | 
					
						
							| 
									
										
										
										
											2024-07-01 09:45:07 +00:00
										 |  |  | session_start(); | 
					
						
							| 
									
										
										
										
											2024-06-28 17:05:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-15 07:31:26 +00:00
										 |  |  | if (isset($_REQUEST['page'])) { | 
					
						
							|  |  |  |     $page = $_REQUEST['page']; | 
					
						
							| 
									
										
										
										
											2024-06-28 17:05:32 +00:00
										 |  |  | } else { | 
					
						
							|  |  |  |     $page = 'front'; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-03 06:37:35 +00:00
										 |  |  | // check if logged in
 | 
					
						
							| 
									
										
										
										
											2024-08-06 07:40:52 +00:00
										 |  |  | unset($user); | 
					
						
							| 
									
										
										
										
											2024-07-03 06:37:35 +00:00
										 |  |  | if (isset($_COOKIE['username'])) { | 
					
						
							|  |  |  |     if ( !isset($_SESSION['username']) ) { | 
					
						
							|  |  |  |         $_SESSION['username'] = $_COOKIE['username']; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-07-01 09:45:07 +00:00
										 |  |  |     $user = htmlspecialchars($_SESSION['username']); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2024-06-28 17:05:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-01 09:45:07 +00:00
										 |  |  | // redirect to login
 | 
					
						
							| 
									
										
										
										
											2024-07-03 15:15:32 +00:00
										 |  |  | if ( !isset($_COOKIE['username']) && ($page !== 'login' && $page !== 'register') ) { | 
					
						
							| 
									
										
										
										
											2024-06-28 17:05:32 +00:00
										 |  |  |     header('Location: index.php?page=login'); | 
					
						
							|  |  |  |     exit(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-01 09:45:07 +00:00
										 |  |  | // we use 'notice' for all non-critical messages and 'error' for errors
 | 
					
						
							|  |  |  | if (isset($_SESSION['notice'])) { | 
					
						
							|  |  |  |     $notice = $_SESSION['notice']; | 
					
						
							| 
									
										
										
										
											2024-06-28 17:05:32 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2024-07-01 09:45:07 +00:00
										 |  |  | if (isset($_SESSION['error'])) { | 
					
						
							|  |  |  |     $error = $_SESSION['error']; | 
					
						
							| 
									
										
										
										
											2024-06-28 17:05:32 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-17 08:20:08 +00:00
										 |  |  | // by default we connect ot the first configured platform
 | 
					
						
							|  |  |  | $platform_id = $_REQUEST['platform'] ?? '0'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-01 09:45:07 +00:00
										 |  |  | // page building
 | 
					
						
							|  |  |  | if (in_array($page, $allowed_urls)) { | 
					
						
							|  |  |  |     // logout is a special case, as we can't use session vars for notices
 | 
					
						
							|  |  |  |     if ($page == 'logout') { | 
					
						
							| 
									
										
										
										
											2024-06-28 17:05:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-01 09:45:07 +00:00
										 |  |  |         // clean up session
 | 
					
						
							|  |  |  |         session_unset(); | 
					
						
							|  |  |  |         session_destroy(); | 
					
						
							| 
									
										
										
										
											2024-07-03 06:37:35 +00:00
										 |  |  |         setcookie('username', "", time() - 100, $config['folder'], $config['domain'], isset($_SERVER['HTTPS']), true); | 
					
						
							| 
									
										
										
										
											2024-06-28 17:05:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-01 09:45:07 +00:00
										 |  |  |         $notice = "You were logged out.<br />You can log in again."; | 
					
						
							| 
									
										
										
										
											2024-08-12 11:12:24 +00:00
										 |  |  |         include '../app/templates/page-header.php'; | 
					
						
							|  |  |  |         include '../app/templates/page-menu.php'; | 
					
						
							|  |  |  |         include '../app/templates/block-message.php'; | 
					
						
							|  |  |  |         include '../app/pages/login.php'; | 
					
						
							| 
									
										
										
										
											2024-07-01 09:45:07 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // all other normal pages
 | 
					
						
							|  |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2024-08-12 11:12:24 +00:00
										 |  |  |         include '../app/templates/page-header.php'; | 
					
						
							|  |  |  |         include '../app/templates/page-menu.php'; | 
					
						
							|  |  |  |         include '../app/templates/block-message.php'; | 
					
						
							| 
									
										
										
										
											2024-08-06 07:40:52 +00:00
										 |  |  |         if (isset($user)) { | 
					
						
							| 
									
										
										
										
											2024-08-12 11:12:24 +00:00
										 |  |  |             include '../app/templates/page-sidebar.php'; | 
					
						
							| 
									
										
										
										
											2024-08-06 07:40:52 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2024-08-12 11:12:24 +00:00
										 |  |  |         include "../app/pages/{$page}.php"; | 
					
						
							| 
									
										
										
										
											2024-07-01 09:45:07 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // the page is not in allowed urls, loading front page
 | 
					
						
							| 
									
										
										
										
											2024-06-28 17:05:32 +00:00
										 |  |  | } else { | 
					
						
							| 
									
										
										
										
											2024-08-06 07:40:52 +00:00
										 |  |  |     $error = 'The page "' . $page . '" is not found'; | 
					
						
							| 
									
										
										
										
											2024-08-12 11:12:24 +00:00
										 |  |  |     include '../app/templates/page-header.php'; | 
					
						
							|  |  |  |     include '../app/templates/page-menu.php'; | 
					
						
							|  |  |  |     include '../app/templates/block-message.php'; | 
					
						
							| 
									
										
										
										
											2024-08-06 07:40:52 +00:00
										 |  |  |     if (isset($user)) { | 
					
						
							| 
									
										
										
										
											2024-08-12 11:12:24 +00:00
										 |  |  |         include '../app/templates/page-sidebar.php'; | 
					
						
							| 
									
										
										
										
											2024-08-06 07:40:52 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-08-12 11:12:24 +00:00
										 |  |  |     include '../app/pages/front.php'; | 
					
						
							| 
									
										
										
										
											2024-06-28 17:05:32 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2024-08-12 11:12:24 +00:00
										 |  |  | include '../app/templates/page-footer.php'; | 
					
						
							| 
									
										
										
										
											2024-06-28 17:05:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-19 10:25:09 +00:00
										 |  |  | // flush the output buffer and show the page
 | 
					
						
							|  |  |  | ob_end_flush(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-01 09:45:07 +00:00
										 |  |  | // clear errors and notices before next page just in case
 | 
					
						
							|  |  |  | unset($_SESSION['error']); | 
					
						
							|  |  |  | unset($_SESSION['notice']); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-28 17:05:32 +00:00
										 |  |  | ?>
 |