summaryrefslogtreecommitdiff
path: root/forum/htdocs/index.php
blob: 0608f935701670339dbc507dcd6b783a9d8e1e0b (plain)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
header("Content-Type: text/html; charset=UTF-8");
session_cache_limiter('nocache');

include_once("config.php");

// Check login
include_once($UTIL_DIR . "/login.php");
checklogin();

if($yeah) {
include_once($UTIL_DIR . "/cache.php");
$cache = new Cache($DATA_DIR . "/cache.xml");
$cache->rebuild();
}

// Catch the modes that must not output any html.
if($current_user) {
	switch($mode) {
	case "imagecache":
		include_once($UTIL_DIR. "/imagecache.php");
		getCachedImage($uri);
		return;

	case "file":
		include_once($UTIL_DIR. "/file.php");
		if($preview) getFilePreview($fid);
		else getFile($fid);
		return;
	}
}

include_once($UTIL_DIR . "/clientinfo.php");
?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title><?php echo $FORUM_TITLE; ?></title>
    <meta name="MSSmartTagsPreventParsing" content="true"/>
    <meta http-equiv="Content-Type" content="text/html"/>
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="-1">
    <link rel="author" title="Bent Bisballe Nyeng" href="http://www.aasimon.org"/>
    <link rel="stylesheet" type="text/css" href="forum.css"/>
<?php if($mode == "editor") {?>    <script language="javascript" src="lib.js" type="text/javascript"></script><?php } ?>
  </head>
  <body>
<?php
	function menu($pos, $unread)
{
	global $current_user;

	if($unread) $newposts = "newposts";
	else $newposts = "nonewposts";

	$str .="    <div id=\"menu_".$pos."\" class=\"menu\">\n";
	$str .="       <a href=\"?mode=forum\"><span class=\"".$newposts."\">&nbsp;</span>Forum</a>\n";
	$str .="       <a href=\"?mode=filehandler\">Filehandler</a>\n";
	$str .="       <a href=\"?mode=calendar\">Calendar</a>\n";
	$str .="       <a href=\"?mode=addressbook\">Addressbook</a>\n";
	$str .="       <a href=\"?mode=profile\">Profile</a>\n";
	$str .="       <a href=\"?mode=tasks\">Tasks</a>\n";
	if($current_user->uid == 0)
		$str .="       <a href=\"?mode=diagnostics\">Diagnostics</a>\n";
	$str .="     </div>\n";
	return $str;
}

// Globals:
// $fid
// $tid
// $pid
// $task

if($current_user) {
	$str = "";

	$str .= "    <p>Logged in as: " . $current_user->name . " - <a href=\"?action=logout\">Logout</a></p>\n";

	switch($mode) {
	case "profile":
		include_once($UTIL_DIR. "/profile.php");
		$str .= profile();
		break;

	case "tasks":
		include_once($UTIL_DIR. "/tasks.php");
		$str .= tasks();
		break;

	case "calendar":
		include_once($UTIL_DIR. "/calendar.php");
		$str .= calendar();
		break;

	case "addressbook":
		include_once($UTIL_DIR. "/addressbook.php");
		$str .= addressbook();
		break;

	case "editor":
		include_once($UTIL_DIR. "/editor.php");
		$str .= editor();
		break;
		
	case "edit":
		include_once($UTIL_DIR. "/edit.php");
		$str .= "";
		break;
		
	case "filehandler":
		include_once($UTIL_DIR. "/filehandler.php");
		$str .= filehandler();
		break;

	case "diagnostics":
		include_once($UTIL_DIR. "/diagnostics.php");
		$str .= "";
		break;

	default:
	case "view":
		include_once($UTIL_DIR. "/view.php");
	  $str .= viewForum();
		if(!isset($GLOBALS['fid'])) {
			include_once($UTIL_DIR. "/calendar.php");
			$str .= calendar();
		}
		break;
	}
	if($mode != "edit") {
		include_once($UTIL_DIR . "/forums.php");
		
		$forums = new Forums($FORUMS_DIR . "/forums.xml");
		
		$unreadPosts = false;
		foreach($forums->forums as $forum) {
			$unreadPosts |= $forum->newStuff;
		}
		
		echo menu("top", $unreadPosts). $str. menu("bottom", $unreadPosts);
	} else {
		echo $str;
	}

} else {
?>
    <form action="?action=login" method="post">
      <p>UserID: <input name="current_username"/></p>
      <p>Password: <input name="current_password" type="password"/></p>
      <p><button type="submit">Login</button></p>
    </form>
<?php
}
?>
  </body>
</html>