-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.php
118 lines (85 loc) · 2.2 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
<?php
// How do we write the url of links? (BASEURL)
$protocol = 'http';
$servername = $_SERVER['SERVER_NAME'];
$serverport = ($_SERVER['SERVER_PORT'] == '80') ? '' : ':' . $_SERVER['SERVER_PORT'];
$path = dirname($_SERVER["SCRIPT_NAME"]);
$path = str_replace('\\', '/', $path); // helps with windows
$base = $protocol . '://' . preg_replace('/\/+/', '/', $servername . $serverport . $path);
$base = preg_replace('/application/','', $base); // remove 'application'
define('BASEURL', preg_replace("/\/$/i", '', $base)); // no trailing slashes
// path to the system folder
$system_path = '.';
if (realpath($system_path) !== FALSE)
{
$system_path = realpath($system_path).'/';
}
// ensure there's a trailing slash
$system_path = rtrim($system_path, '/').'/';
// Path to the system folder
define('BASEPATH', str_replace("\\", "/", $system_path));
// Load the common functions
require(BASEPATH.'system/common.php');
// Views path
define('VIEWSPATH', BASEPATH.'views/');
// Calculation path
define('CALPATH', realpath('methods/'));
// Check if call is ajax type
define('AJAX', isset($_POST['ajax']));
/* define('AJAX', True); */
// Load config
$ini = get_config();
// Temp folder
$path = $ini['tmpfolder'];
$path = rtrim($path, '/') . '/';
define('TMPFOLDER', $path);
// Define GAMESS
define('RUNGMS', $ini['rungms']);
// Define Menu
$menu = array(
'editor' => 'New Molecule',
'calculation' => 'Molecule List',
'about' => 'Help'
);
// Parse the request
if(isset($_GET['request']))
{
$request = explode('/', $_GET['request']);
}
else
{
$request = array(0 => '');
}
if(AJAX)
{
if(isset($request[1])) $calculationType = $request[1];
if(isset($calculationType))
{
$type = $calculationType;
$script = 'initialize';
}
else
{
$type = 'initialize';
$script = 'initialize';
}
require(CALPATH.'/'.$type.'/'.$script.'.php');
}
else
{
if($request[0] == '')
{
$view = 'editor';
}
else
{
$view = $request[0];
}
if(isset($request[1]))
{
$hash = $request[1];
if(!is_dir('data/'.$hash)) $view = '404';
}
// Normal view
include('views/main.php');
}