forked from jquery/testswarm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
81 lines (72 loc) · 2.5 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
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
<?php
session_start();
require "inc/utilities.php";
$swarmConfig = parse_ini_file("config.ini", true);
// Extend default options
$swarmConfig = array_extend(array(
"database" => array(
"host" => "localhost",
"username" => "root",
"password" => "root",
"database" => "testswarm",
),
"web" => array(
"title" => "Test Swarm",
"contextpath" => "",
),
), $swarmConfig);
// $swarmDebug = true;
require "inc/browser.php";
require "inc/db.php";
// Increase the session timeout to two weeks
ini_set("session.gc_maxlifetime", "1209600");
$state = preg_replace("/[^a-z]/", "", getItem( "state", $_REQUEST, "" ) );
if ( !$state ) {
$state = "home";
}
$logicFile = "logic/$state.php";
$contentFile = "content/$state.php";
if ( $state ) {
if ( file_exists($logicFile) ) {
require $logicFile;
} else if ( !file_exists($contentFile) ) {
header("HTTP/1.0 404 Not Found");
exit();
}
}
if ( $title ) {
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title><?php echo htmlentities( $swarmConfig['web']['title'] . ': ' . $title ); ?></title>
<link rel="stylesheet" href="<?php echo swarmpath( "css/site.css" ); ?>"/>
<?php echo isset($scripts) ? $scripts : ""; ?>
</head>
<body>
<ul class="nav">
<?php if ( $_SESSION["username"] && $_SESSION["auth"] == "yes" ) { ?>
<li><strong><a href="<?php echo swarmpath( "user/{$_SESSION["username"]}/" ); ?>"><?php echo $_SESSION["username"];?></a></strong></li>
<li><a href="<?php echo swarmpath( "run/{$_SESSION["username"]}" );?>">Join the Swarm</a></li>
<li><a href="<?php echo swarmpath( "logout/" ); ?>">Logout</a></li>
<?php } else { ?>
<li><a href="<?php echo swarmpath( "login/" ); ?>">Login</a></li>
<li><a href="<?php echo swarmpath( "signup/" ); ?>">Signup</a></li>
<?php } ?>
<li><a href="http://github.com/jquery/testswarm">Source Code</a></li>
<li><a href="http://github.com/jquery/testswarm/issues">Bug Tracker</a></li>
<li><a href="http://groups.google.com/group/testswarm">Discuss</a></li>
<li><a href="http://twitter.com/testswarm">Updates</a></li>
<li><a href="http://wiki.github.com/jquery/testswarm">About</a></li>
</ul>
<h1><a href="<?php echo swarmpath( "/" ); ?>"><img src="<?php echo swarmpath( "images/testswarm_logo_wordmark.png" ); ?>" alt="TestSwarm" title="TestSwarm"/></a></h1>
<h2><?php echo $title; ?></h2>
<div id="main">
<?php } if ( $state && file_exists($contentFile) ) {
require $contentFile;
} if ( $title ) { ?>
</div>
</body>
</html>
<?php }