/
index.php
58 lines (42 loc) · 1.28 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
<?php
// Standard include
require_once( dirname( __FILE__ ) . '/../YDFramework2/YDF2_init.php' );
// Includes
require_once( 'YDRequest.php' );
// Class definition
class index extends YDRequest {
// Class constructor
function index() {
$this->YDRequest();
}
// Default action
function actionDefault() {
$this->outputTemplate();
}
// Function to show the highlighted source file
function actionSource() {
// Get the basename of the file
$file = $_GET['id'];
// Filepath should start with the directory of this file
$basePath = strtolower( dirname( __FILE__ ) );
$filePath = strtolower( dirname( realpath( $_GET['id'] ) ) );
// Check if the file is in the right directory
if ( substr( $filePath, 0, strlen( $basePath ) ) != $basePath ) {
$this->forward( 'default' );
return;
}
// Check if the file exists
if ( ! is_file( $file ) ) {
$this->forward( 'default' );
return;
}
// Show the highlighted source
$this->setVar( 'file', $file );
$this->setVar( 'source', highlight_file( $file, 1 ) );
// Output the template
$this->outputTemplate();
}
}
// Process the request
require_once( dirname( __FILE__ ) . '/../YDFramework2/YDF2_process.php' );
?>