-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
165 lines (146 loc) · 4.56 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
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
159
160
161
162
163
164
<?php
/*
* TODO:
* Upgrade Screenshots page with some snazzy JQuery
*
*/
//PRINT ERRORS TO THE PAGE NOT JUST YOUR PHP.INI
//error_reporting(E_ALL);
//ini_set('display_errors', 1);
//ini_set('display_startup_errors',1);
//error_reporting(-1);
function rewrite($body)
/*
* The purpose of this function is to convert the text in the sidebar
* into valid links.
*/
{
$content = $body;
$terms="!-=+\\\"$%^\(\)@ \w";
$content=preg_replace (
["/\[([$terms]+)\]/", "/\[([$terms]+)\|([$terms]+)\]/"],
["<a href=\"index.php?title=\\1\">\\1</a>", "<a href=\"index.php?title=\\2\">\\1</a>"], (string) $content);
return $content;
}
/*
* Content is buffered so that [foo|bar] links can be parsed afterwards.
*/
ob_start('rewrite');
require "includes/config.inc.php"; // Initializes Database and Login
require "includes/header.inc.php"; // Includes sidebar
if(isset($_GET['logout'])){
$auth->LogOut();
}
// If it's an admin user, add the admin menu
if ( $auth->IsLoggedOn() ){
echo "<h3>Welcome " . $auth->GetName() . "</h3>";
include "includes/adminmenu.inc.php";
}
if (isset($_GET['title']) == false){
$title = "news_show";
}
else{
$title= $_GET['title'];
}
$lightboxRequires = " <script src='js/jquery-1.7.2.min.js'></script>
<script src='js/lightbox.js'></script>
<link href='css/lightbox.css' rel='stylesheet' />
<link href='css/gallery.css' rel='stylesheet' /> ";
//change the images depending on which page is loaded
if ($title=='news_show') {
$image1 = 'sshots/MAME_ARCADE1.png';
$image1Small = 'sshots/SMALL/MAME_ARCADE1.png';
$image2 = 'sshots/MESS2.png';
$image2Small = 'sshots/SMALL/MESS2.png';
$image3 = 'sshots/MESS3.png';
$image3Small = 'sshots/SMALL/MESS3.png';
$image4 = 'sshots/MAME_EMBDEDDED1.png';
$image4Small = 'sshots/SMALL/MAME_EMBDEDDED1.png';
$image5 = 'sshots/MAME_ARCADE2.png';
$image5Small = 'sshots/SMALL/MAME_ARCADE2.png';
$image6 = 'sshots/MAME_ARCADE4.png';
$image6Small = 'sshots/SMALL/MAME_ARCADE4.png';
//this is the resulting block we'll add to the pages
$imageHeader = "
$lightboxRequires.
<div id='images'>
<ul class='gallery'>
<a href=$image1 data-lightbox='page-images'>
<li><img src=$image1Small></li>.
</a>
<a href=$image2 data-lightbox='page-images'>
<li><img src=$image2Small></li>.
</a>
<a href=$image3 data-lightbox='page-images'>
<li><img src=$image3Small></li>.
</a>
</ul>
</div>
</div>
";
$imageFooter = "
<div id='images'>
<ul class='gallery'>
<a href=$image4 data-lightbox='page-images'>
<li><img src=$image4Small></li>.
</a>
<a href=$image5 data-lightbox='page-images'>
<li><img src=$image5Small></li>.
</a>
<a href=$image6 data-lightbox='page-images'>
<li><img src=$image6Small></li>.
</a>
</ul>
</div>
</div>
";
}
if ($title=='login'){
$auth->GenerateLogin();
}
// File management section. Sort of hack-ish..
else if ($title=='manage') // For managing upload (needs authentication!)
{
require "includes/edit_dir.php";
}
else if ($title=='upload')
{
require "includes/uploader.php";
}
else if ($title=='displaychanges')
{
require "displaychanges.php";
}
else
{
if ($DBo->WikiPageExists($title) == true) // Pulls pages out of database
{
$pgrec = $DBo->WikiGetPage($title); // Holds page id, name, and body
if ($pgrec != False)
{
$text = StripSlashes((string) $pgrec[0]['p_body']); // For escaped characters
$text = html_entity_decode($text, ENT_QUOTES); // Because the editor converts HTML to character entities
ob_start(); // Buffering this eval circumvents the issue of double SQL output.
eval("?> <div class=fenix-content>".$imageHeader.$text.$imageFooter."</div><?"); // Short tag used, as <?php throws errors.
$eval_buffer = ob_get_contents();
ob_end_clean();
$body = $eval_buffer;
echo $body;//change to $text to spit out the db calls made into the page
}
else
{
echo "Failed to read page from database";
}
}
else
{
echo "<div>This page does not exist. Return to the <a href=\"index.php\">index</a>.</div>";
}
}
if (!$auth->IsLoggedOn() ) {
if ($title!='login') {
require("includes/footer.inc.php");
}
}
ob_end_flush(); // Immediately calls rewrite
?>