forked from neonelephantstudio/nemex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·44 lines (38 loc) · 1.11 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
define( 'NX_PATH', realpath('./').'/' );
require_once(NX_PATH.'config.php');
require_once(NX_PATH.'lib/session.php');
require_once(NX_PATH.'lib/utils.php');
require_once(NX_PATH.'lib/project.php');
header( 'Content-type: text/html; Charset=UTF-8' );
$session = new Session('nemex', NX_PATH, CONFIG::USER, CONFIG::PASSWORD);
// Attempting to login?
if( !empty($_POST['username']) && !empty($_POST['password']) ) {
if( $session->login($_POST['username'], $_POST['password']) ) {
header('location: ./');
exit();
}
}
// Not authed for this nemex? Show login form
if( !$session->isAuthed() ) {
include( NX_PATH.'media/templates/login.html.php');
}
// Show project or project list
else {
if( !empty($_GET) ) {
$projectName = key($_GET);
$project = Project::open($projectName);
if( $project ) {
$nodes = $project->getNodes();
include( NX_PATH.'media/templates/project.html.php');
}
else {
header( "HTTP/1.1 404 Not Found" );
echo 'No Such Project: '.htmlspecialchars($projectName);
}
}
else {
$projects = Project::getProjectList();
include( NX_PATH.'media/templates/project-list.html.php');
}
}