-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.php
305 lines (285 loc) · 14 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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
<?php
/*
index.php
Copyright 2013-2018 by Juan Antonio Martinez ( juansgaviota at gmail dot 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 2 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.
You should have received a copy of the GNU General Public License along with this program;
if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
* This file acts as first an main entry point for webhosting install
* WebHosting install lacks of system.ini file
*
* If system.ini file already exits act like normal (public) entry point
* else re-create according web host info and user preferences
*/
if (file_exists(__DIR__ . "/../config/system.ini")) {
// just a simple redirector to public/index.php
// from: https://stackoverflow.com/questions/15110355/how-to-safely-get-full-url-of-parent-directory-of-current-php-page
$url = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
$url .= $_SERVER['SERVER_NAME'];
$path= parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$res=str_replace("index.php","public/index.php",$path,$count);
if ($count===0) $url .= $res ."public/index.php";
else $url .= $res;
header("Location: {$url}",false);
die();
}
require_once(__DIR__."/server/tools.php");
require_once(__DIR__."/server/auth/Config.php");
$myconf=Config::getInstance(); // just to load i18n settings. Notice that system.ini does not exist yet
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="application-name" content="Agility Contest" />
<meta name="copyright" content="© 2013-2018 Juan Antonio Martinez" />
<meta name="author" lang="en" content="Juan Antonio Martinez" />
<meta name="description"
content="A web client-server (xampp) app to organize, register and show results for FCI Dog Agility Contests" />
<meta name="distribution"
content="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 2 of the License,
or (at your option) any later version." />
<!-- try to disable zoom in tablet on double click -->
<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1.0, maximum-scale=2.0, minimum-scale=0.5, user-scalable=yes"/>
<title>AgilityContest (WebHost install)</title>
<link rel="stylesheet" type="text/css" href="lib/jquery-easyui-1.4.2/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="lib/jquery-easyui-1.4.2/themes/icon.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="stylesheet" type="text/css" href="css/datagrid.css" />
<script src="lib/jquery-2.2.4.min.js" type="text/javascript" charset="utf-8" > </script>
<script src="lib/jquery-easyui-1.4.2/jquery.easyui.min.js" type="text/javascript" charset="utf-8" ></script>
<script src="scripts/common.js.php" type="text/javascript" charset="utf-8" > </script>
<script src="scripts/webhost.js.php" type="text/javascript" charset="utf-8" > </script>
</head>
<body style="margin:0;padding:0">
<h2>AgilityContest WebHost install</h2>
<div id="install-window" class="easyui-window" style="width:800px;height:500px;padding:10px 20px" data-options="fit:false">
<form id="install_form" name="install_form" class="easyui-form">
<div id="install_header">
<img src="images/AgilityContest.png"
width="150" height="100" alt="AgilityContest Logo"
style="border:1px solid #000000;margin:10px;float:right;padding:5px">
<dl>
<dt>
<strong><?php _e('Version'); ?>: </strong><span id="reg_version">version</span> - <span id="reg_date">date</span>
</dt>
<dt>
<strong>AgilityContest</strong> <?php _e('is Copyright © 2013-2018 by'); ?> <em> Juan Antonio Martínez <juansgaviota@gmail.com></em>
</dt>
<dd>
<?php _e('Source code is available at'); ?> <a href="https://github.com/jonsito/AgilityContest">https://github.com/jonsito/AgilityContest</a><br />
<?php _e('You can use, copy, modify and re-distribute under terms of'); ?>
<a target="license" href="License"><?php _e('GNU General Public License'); ?></a>
</dd>
</dl>
<p>
<?php _e('Registered at'); ?> 'Registro Territorial de la Propiedad Intelectual de Madrid'. <em>Expediente: 09-RTPI-09439.4/2014</em>
</p>
</div>
<hr />
<div id="database_data">
<h3><?php _e("Server and Database information");?> </h3>
<div class="fitem">
<label for="install_host" style="width:275px;margin-top:5px"><?php _e("Server name");?>: </label>
<input type="text" class="easyui-textbox" id="install_host" name="install_host">
<br/>
</div>
<div class="fitem">
<label for="install_dbname" style="width:275px;margin-top:5px"><?php _e("Database name");?>: </label>
<input type="text" class="easyui-textbox" id="install_dbname" name="install_dbname">
<br/>
</div>
<div class="fitem">
<label for="install_dbuser" style="width:275px;margin-top:5px"><?php _e("Database admin user");?>: </label>
<input type="text" class="easyui-textbox" id="install_dbuser" name="install_dbuser">
<br/>
</div>
<div class="fitem">
<label for="install_dbpass" style="width:275px;margin-top:5px"><?php _e("Database admin password");?>: </label>
<input type="password" class="easyui-textbox" id="install_dbpass" name="install_dbpass">
<br/>
</div>
<div class="fitem">
<label for="install-dbCheck" style="width:275px;margin-top:5px"><?php _e("Check database connection");?>: </label>
<a id="install-dbCheck" href="#" class="easyui-linkbutton"
data-options="iconCls:'icon-help'" onclick="wh_check_dbAccess(null)"><?php _e('Check'); ?></a>
<span id="install_dbpass_match"> </span>
</div>
</div>
<hr/>
<div id="install_data" style="display:none">
<h3><?php _e("AgilityContest default users:");?> </h3>
<div class="fitem">
<label for="install_admin" style="width:275px;margin-top:5px"><?php _e("Enter password for 'admin' user");?>: </label>
<input type="password" class="easyui-textbox" id="install_admin" name="install_admin">
<span id="install_admin_strength"> </span>
<br/>
</div>
<div class="fitem">
<label for="install_admin2" style="width:275px;margin-top:5px"><?php _e("Enter password (again) for 'admin'");?>: </label>
<input type="password" class="easyui-textbox" id="install_admin2" name="install_admin2">
<span id="install_admin2_match"> </span>
<br/> <br/>
</div>
<div class="fitem">
<label for="install_operator" style="width:275px;margin-top:5px"><?php _e("Enter password for 'operator' user");?>: </label>
<input type="password" class="easyui-textbox" id="install_operator" name="install_operator">
<span id="install_operator_strength"> </span>
<br/>
</div>
<div class="fitem">
<label for="install_operator2" style="width:275px;margin-top:5px"><?php _e("Enter password (again) for 'operator'");?>: </label>
<input type="password" class="easyui-textbox" id="install_operator2" name="install_operator2">
<span id="install_operator2_match"> </span>
<br/> <br/>
</div>
<div class="fitem">
<label for="install_assistant" style="width:275px;margin-top:5px"><?php _e("Enter password for 'assistant' user");?>: </label>
<input type="password" class="easyui-textbox" id="install_assistant" name="install_assistant">
<span id="install_assistant_strength"> </span>
<br/>
</div>
<div class="fitem">
<label for="install_assistant2" style="width:275px;margin-top:5px"><?php _e("Enter password (again) for 'assistant'");?>: </label>
<input type="password" class="easyui-textbox" id="install_assistant2" name="install_assistant2">
<span id="install_assistant2_match"> </span>
<br/> <br/>
</div>
<hr/>
<h3><?php _e("Licensing and registration");?> </h3>
<div class="fitem">
<label for="install_accept" style="width:400px;margin-top:5px"><?php _e("I've read, understand and accept License terms");?>: </label>
<input type="checkbox" class="easyui-checkbox" id="install_accept" name="install_accept">
<br/>
</div>
<div class="fitem">
<label for="install_license" style="width:275px;margin-top:5px"><?php _e("Enter registration license file");?>: </label>
<input name="install_license" id="install_license" style="width:350px;" onchange="wh_read_registrationFile(this)"/>
<input id="install_regdata" type="hidden" name="Data" value="">
</div>
<span style="float:right">
<a id="install-okButton" href="#" class="easyui-linkbutton"
data-options="iconCls:'icon-ok'"
onclick="wh_checkAndInstall();"><?php _e('Aceptar'); ?></a>
<br/> <br/>
</span>
</div>
</form>
</div>
<script type="text/javascript">
$('#install_host').textbox({width:300,required:true,value:'www.server.domain',validType:'length[1,255]'});
$('#install_dbname').textbox({width:300,required:true,value:'dbname',validType:'length[1,255]'});
$('#install_dbuser').textbox({width:300,required:true,value:'dbuser',validType:'length[1,255]',iconCls:'icon-man'});
$('#install_dbpass').textbox({width:300,required:true,value:'dbpassword',validType:'length[1,255]',iconCls:'icon-lock'});
$('#install_admin').textbox({
width:300,
required:true,
value:'admin',
validType:'length[6,32]',
iconCls:'icon-lock',
inputEvents:$.extend({},$.fn.textbox.defaults.inputEvents,{
keyup:function(e){
var t = $(e.data.target).textbox('getText');
passwordStrength(t,$('#install_admin_strength'));
}
})
});
$('#install_admin2').textbox({
width:300,
required:true,
value:'admin',
iconCls:'icon-lock',
inputEvents:$.extend({},$.fn.textbox.defaults.inputEvents,{
keyup:function(e){
var p1 = $('#install_admin').textbox('getText');
var p2 = $(e.data.target).textbox('getText');
passwordMatch(p1,p2,$('#install_admin2_match'));
}
})
});
$('#install_operator').textbox({
width:300,
required:true,
value:'operator',
validType:'length[6,32]',
iconCls:'icon-lock',
inputEvents:$.extend({},$.fn.textbox.defaults.inputEvents,{
keyup:function(e){
var t = $(e.data.target).textbox('getText');
passwordStrength(t,$('#install_operator_strength'));
}
})
});
$('#install_operator2').textbox({
width:300,
required:true,
value:'operator',
iconCls:'icon-lock',
inputEvents:$.extend({},$.fn.textbox.defaults.inputEvents,{
keyup:function(e){
var p1 = $('#install_operator').textbox('getText');
var p2 = $(e.data.target).textbox('getText');
passwordMatch(p1,p2,$('#install_operator2_match'));
}
})
});
$('#install_assistant').textbox({
width:300,
required:true,
value:'assistant',
validType:'length[6,32]',
iconCls:'icon-lock',
inputEvents:$.extend({},$.fn.textbox.defaults.inputEvents,{
keyup:function(e){
var t = $(e.data.target).textbox('getText');
passwordStrength(t,$('#install_assistant_strength'));
}
})
});
$('#install_assistant2').textbox({
width:300,
required:true,
value:'assistant',
iconCls:'icon-lock',
inputEvents:$.extend({},$.fn.textbox.defaults.inputEvents,{
keyup:function(e){
var p1 = $('#install_assistant').textbox('getText');
var p2 = $(e.data.target).textbox('getText');
passwordMatch(p1,p2,$('#install_assistant2_match'));
}
})
});
var fb=$('#install_license');
fb.filebox({
accept: ".info",
buttonText: '<?php _e("Select"); ?>',
buttonAlign: 'left',
buttonIcon: 'icon-search',
onChange: function(newfile,oldfile) {
wh_read_registrationFile(fb.next().find('.textbox-value')[0]); // locate real input text
}
});
fb.next().find('.textbox-value').attr('accept', '.info');
$('#install-window').window({
title: '<?php _e("AgilityContest setup"); ?>',
collapsible:false,
minimizable:false,
maximizable:false,
resizable:false,
closable:false, // do not allow close: use "Accept" button
modal:true,
iconCls: 'icon-dog'
});
addTooltip($('#install-dbCheck').linkbutton(),'<?php _e("Check server/database conectivity"); ?>');
addTooltip($('#install-okButton').linkbutton(),'<?php _e("Accept System Parameters. Start install"); ?>');
</script>
</body>
</html>