/
index.php
65 lines (46 loc) · 1.75 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
<?php
// Standard include
include_once( dirname( __FILE__ ) . '/../YDFramework2/YDF2_init.php' );
// Includes
YDInclude( 'YDRequest.php' );
YDInclude( 'YDTemplate.php' );
// Class definition
class index extends YDRequest {
// Class constructor
function index() {
// Initialize the parent
$this->YDRequest();
// Initialize the template object
$this->template = new YDTemplate();
}
// Default action
function actionDefault() {
$this->template->display();
}
// 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->template->assign( 'file', $file );
$this->template->assign( 'source', highlight_file( $file, 1 ) );
// Output the template
$this->template->display();
}
}
// Process the request
YDInclude( 'YDF2_process.php' );
?>