-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.php
268 lines (232 loc) · 8.59 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
<?php
/********************************************************************
DiSCuS - Database System for Compound Selection
Copyright (C) 2012-2013 Maciej Wojcikowski <[email protected]>
This file is part of DiSCuS.
DiSCuS 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 2 of the License, or
(at your option) any later version.
DiSCuS 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.
You should have received a copy of the GNU General Public License
along with DiSCuS. If not, see <http://www.gnu.org/licenses/>.
********************************************************************/
include_once 'class/mysql.php';
include_once 'class/timer.php';
//Marking time of parsing start
$Timer = new Timer;
// enable autoload of controllers
spl_autoload_register(function ($module) {
#include 'modules/base.php';
if(file_exists('modules/'.$module.'.php')) {
include_once 'modules/'.$module.'.php';
}
elseif(file_exists('plugins/'.$module.'.php')) {
include_once 'plugins/'.$module.'.php';
}
});
//Including config and classes vital for script
if(file_exists('config.php')) {
define('IN_DISCUS', true);
# define ajax for future reference
define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
include_once 'config.php';
include_once 'class/login.php';
//Starting MySQL class
$Database = new Database($CONFIG['db_user'], $CONFIG['db_pass'], $CONFIG['db_host'], $CONFIG['db_name']);
//log in
$User = new User;
$module = $_GET['module'];
$mode = $_GET['mode'];
if($User -> logged()) {
if(empty($module)) {
$module = 'molecules';
}
$mod = new $module($mode);
#check if mode wasn't changed internally
if($mode != $mod -> mode) {
$mode = $mod -> mode;
}
# for ajax
if(IS_AJAX) {
$view = 'view_'.$mode;
if(method_exists($mod,$view)) {
$mod -> $view();
}
exit;
}
}
}
else {
define('IN_DISCUS', false);
$module = 'install';
$mod = new $module();
$mode = $mod -> mode;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>DiSCuS</title>
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="style.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="common.js"></script>
<script type="text/javascript" src="//www.google.com/jsapi"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="jsmol/JSmol.min.nojq.js"></script>
<script type="text/javascript" language="javascript" src="jsme/jsme/jsme.nocache.js"></script>
<script>
//this function will be started after the JavaScriptApplet code has been loaded
function drawJsme() {
if($('#smiles').val() != "") {
var startingStructure = convert_smi2sdf($('#smiles').val());
}
else {
var startingStructure = "";
}
//Instantiate a new JSME:
//arguments: HTML id, width, height (must be string not number!)
if($('#jsme-container:visible').length > 0) {
jsmeApplet = new JSApplet.JSME("jsme-container", "500px", "400px", {
//optional parameters
"options" : "query,hydrogens,removehs,noreaction,oldlook"
});
if(jsmeApplet) {
document.JSME = jsmeApplet;
//notify on changes
document.JSME.setNotifyStructuralChangeJSfunction('JSME_update');
document.JSME.setMolecularAreaAntiAlias(true);
}
}
}
function jsmeOnLoad() {
drawJsme()
}
</script>
</head>
<body>
<div id="loading"><div id="processing">Processing, please wait...</br><div class="progress progress-success progress-striped active"><div class="bar" style="width: 100%;"></div></div></div></div>
<div id="modal" class="modal hide fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>Modal header</h3>
</div>
<div class="modal-body">
<div class="progress progress-striped active"><div class="bar" style="width: 100%;"></div></div>
</div>
<div class="modal-footer">
<button class="btn btn-large btn-success">Submit</button>
</div>
</div>
<script>
$(function() {
$('#modal > .modal-footer > button').click(function() {
var button = $(this);
if($('#modal > .modal-body > form').length > 0) {
if(!$(this).hasClass('disabled')) {
$('#modal > .modal-body > form').ajaxSubmit( {
target : $('#modal > .modal-body'),
success: function() {
if($('#modal > .modal-body > form').length > 0) {
button.removeClass('disabled').addClass('btn-success').html('Submit');
// check for autoreload
if($('#modal > .modal-body > form > input[name="timeout"]').val() > 0) {
setTimeout(function() {
$('#modal > .modal-footer > button').trigger( "click" );
}, $('#modal > .modal-body > form > input[name="timeout"]').val())
}
}
else {
button.removeClass('disabled').addClass('btn-success').html('Close');
}
}
});
// add progress bar
$('#modal > .modal-body').html('<div class="progress progress-striped active"><div class="bar" style="width: 100%;"></div></div>');
}
$(this).addClass('disabled').removeClass('btn-success').html('loading...');
}
else {
$('#modal').modal('hide');
}
});
$('#modal').on('shown', function () {
if($('#modal > .modal-body > form').length == 0) {
$('#modal > .modal-footer > button').html('Close');
}
})
// modal header modification
$('a[data-toggle="modal"]').click(function() {
if($(this).text() != '') {
$('#modal > .modal-header > h3').text($(this).text());
}
$('#modal > .modal-footer > button').addClass('btn-success').removeClass('disabled').html('Submit').show();
});
// disable modal toggles inside modal
$('#modal').on('shown', function () {
$("a[data-target=#modal]", $('#modal > .modal-body')).click(function(e) {
e.preventDefault();
$("#modal > .modal-body").load($(this).attr("href"), function () {
if($('#modal > .modal-body > form').length > 0) {
$('#modal > .modal-footer > button').addClass('btn-success').removeClass('disabled').html('Submit').show();
}
});
});
});
// destroy modal when hidden
$('body').on('hidden', '.modal', function () {
$(this).removeData('modal');
});
});
</script>
<div id="header">
<div id="header-logo">
<h1><a href="./index.php<?=(!empty($_GET['project']) ? '?project='.$_GET['project'] : '')?>">DiSCuS</a></h1><a href="./index.php?project=<?=$_GET['project']?>">Database System for Compounds Selection</a>
</div>
<div id="toolbar">
<?php
if(IN_DISCUS && is_object($User) && $User -> logged()) {
if(method_exists($mod, 'toolbar')){
echo $mod -> toolbar();
}
echo ' <a href="./index.php?logout=1" class="btn btn-danger" type="button">Logout <i class="icon-off icon-white"></i></a>';
}
?>
</div>
</div>
<?php
if(IN_DISCUS && !$User -> logged()) {
?>
<div class="container">
<form class="form-signin" method="POST">
<h2 class="form-signin-heading">Please sign in</h2>
<input type="text" name="login" class="input-block-level" placeholder="User name">
<input type="password" name="password" class="input-block-level" placeholder="Password">
<label class="checkbox"><input type="checkbox" name="remember"> Remember me</label>
<button class="btn btn-large" type="submit">Sign in</button>
</form>
</div>
<?php
}
elseif(!IN_DISCUS || IN_DISCUS && $User -> logged() && $module) {
$mod -> view();
}
# show times
if(is_object($Timer)) {
?>
<div id="footer">Execution time: <?php echo $Timer -> overallTimer(); ?> s</br>MySQL queries: <?php echo $Timer -> mysqlTimer()?> s</br>PHP execution: <?php echo round($Timer -> overallTimer() - $Timer -> mysqlTimer(), 5);?> s</div>
<?php
}
?>
<script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="jquery/jquery.form.min.js"></script>
<script type="text/javascript" src="common_jquery.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
</body>
</html>