-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
78 lines (69 loc) · 2.89 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
<?php
/**
* Project: Indechse Pste
*
* Copyright (C) 2012 Nicolas Krueger <nicolas.krueger@gmail.com>
* Copyright (C) 2010 EcKstasy <eckstasy@escriptirc.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
// Includes
require_once('classes/bootstrap.php');
date_default_timezone_set($CONF['timezone']);
error_reporting(-1);
ini_set('display_errors', '1');
$request = \Pste\Request::getInstance();
$config = \Pste\Registry::getInstance()->config;
try {
// authentication
$auth = new \Pste\Auth($request);
if (!$auth->isAuthenticated()) {
\Pste\Registry::getInstance()->authenticated = false;
} else {
\Pste\Registry::getInstance()->authenticated = true;
\Pste\Registry::getInstance()->user = $auth->getUser();
}
/// Clean up older posts
// $pastebin->doGarbageCollection();
// Process new posting
$errors = array();
if ($request->hasParam('paste')) { /* Process posting and redirect */
$pastebin = new Pastebin($CONF);
$id = $pastebin->doPost($_POST);
if ($id) {
$pastebin->redirectToPost($id);
exit;
}
}
if ($request->hasParam('show') && (($config->restrict_show && \Pste\Registry::getInstance()->authenticated) || !$config->restrict_show)) {
$content = \Pste\Component::add(new \Pste\Component\SinglePaste(array('pid' => $request->getParam('show'), 'request' => $request)));
} else if ($request->hasParam('archive')) {
require_once('components/PasteArchive.php');
$content = \Pste\Component::add(new \Pste\Component\PasteArchive(array('page' => $request->getParam('page'), 'request' => $request)));
} else if ($request->hasParam('submit', 'GET')) {
$content = \Pste\Component::add(new \Pste\Component\PasteForm(array('request' => $request)));
} else if ($request->hasParam('info', 'GET') && \Pste\Registry::getInstance()->authenticated) {
phpinfo();die();
} else {
$content = \Pste\Component::add(new \Pste\Component\StaticPage(array('template' => 'components/frontpage.php', 'request' => $request)));
}
$layout = new \Pste\Layout(array('request' => $request));
$layout->setContent($content);
$layout->setTemplate('theme.php');
ob_start();
echo $layout->render();
ob_end_flush();
} catch (Exception $ex) {
header('Content-type: text/plain');
echo "An error occured\n";
echo $ex->getMessage() . "\n";
echo $ex->getTraceAsString();
}