-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
101 lines (87 loc) · 2.88 KB
/
index.php
File metadata and controls
101 lines (87 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/**
* Main index for the NetworkCurator system.
* All user interaction should got through here.
*
*/
/* --------------------------------------------------------------------------
* Housekeeping
* -------------------------------------------------------------------------- */
// load the settings for the website
include_once "nc-admin/config/nc-config-local.php";
include_once "nc-admin/config/nc-constants.php";
// load helper functions
$PP = $_SERVER['DOCUMENT_ROOT'] . NC_PHP_PATH;
$UP = $_SERVER['DOCUMENT_ROOT'] . NC_UI_PATH;
include_once "nc-api/helpers/GeneralApiCaller.php";
include_once "nc-api/helpers/nc-generic.php";
include_once $PP . "/NCApiCaller.php";
include_once $PP . "/nc-sessions.php";
include_once $PP . "/nc-helpers.php";
// get two common fields from the url
$page = '';
if (isset($_REQUEST['page'])) {
$page = $_REQUEST['page'];
}
$network = '';
if (isset($_REQUEST['network'])) {
$network = $_REQUEST['network'];
$page = 'network';
}
// collect information about the user from the session
session_start();
if (!isset($_SESSION['uid'])) {
$uid = "guest";
$upw = "guest";
} else {
$uid = $_SESSION['uid'];
$upw = $_SESSION['upw'];
}
$NCapi = new NCApiCaller($uid, $upw);
try {
$userin = $NCapi->checkLogin();
} catch (Exception $ex) {
ncSignout();
header("Refresh: 0; ?page=front");
exit();
}
if (!$userin) {
$uid = "guest";
}
$userip = $_SERVER['REMOTE_ADDR'];
// determine permission levels for this user
try {
$upermissions = $NCapi->querySelfPermissions($network);
} catch (Exception $ex) {
$upermissions = 0;
}
$iscurator = 0 + ($upermissions >= NC_PERM_CURATE);
$iscommentator = 0 + ($upermissions >= NC_PERM_COMMENT);
$iseditor = 0 + ($upermissions >= NC_PERM_EDIT);
/* --------------------------------------------------------------------------
* Create user-viewable page
* -------------------------------------------------------------------------- */
if ($page == "logout") {
ncSignout();
header("Refresh: 0; ?page=front");
}
// create a basic structure for all pages with header, navbar
include_once ncGetLocalFile("$UP/nc-ui-header.php");
include_once ncGetLocalFile("$UP/nc-ui-navbar.php");
// the middle portion of the page is generated by scripts in nc-ui
if ($page == "login" || $page == "admin" || $page=="user") {
// these are pages that require only a user id
include_once ncGetLocalFile("$UP/nc-ui-$page.php");
} else if ($page == "network" && $network) {
// these are pages that require a network name
include_once ncGetLocalFile("$UP/nc-ui-$page.php");
} else if ($page == "front" || $page=='') {
include_once ncGetLocalFile("$UP/nc-ui-front.php");
} else {
include_once ncGetLocalFile("$UP/nc-ui-custom.php");
}
// the footer is common to all pages
include_once ncGetLocalFile("$UP/nc-ui-prefooter.php");
include_once ncGetLocalFile("$UP/nc-ui-footer.php");
exit();
?>