-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathmapform.php
355 lines (331 loc) · 10.2 KB
/
mapform.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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
<?php
session_start([
//'read_and_close' => true,
]);
if (empty($_SESSION['loggedin'])) {
header("Location: login.php");
exit(0);
}
require_once("config.inc.php");
$user = fetch_user($_SESSION['mylogin']);
if ($user === false){
header("Location: login.php");
printf("<h1>無登入資訊, 請重新登入</h1>");
exit;
}
if (isset($_GET['recreate'])) {
// 填入參數, from list.php 重新產生
$_SESSION['makeparam'] = $_GET;
$recreate_flag = 1;
} else if (isset($_GET['recreate_gpx'])) {
// 重新產生 gpx
$_SESSION['makeparam2'] = $_GET;
$recreate_flag = 1;
} else {
$recreate_flag = 0;
}
if (disk_free_space($diskfullchk) < 500000000) {
printf("<h1>磁碟空間已滿</h1>");
exit;
}
//if (count($maps) >= $user['limit'] ) {
if (map_full($_SESSION['uid'], $user['limit'], $recreate_flag)) {
printf("<h1>已經達到產生數量限制".$user['limit']."</h1>");
exit;
}
$smarty->assign("aashiftx", array(5,10,15,20,25,30,35));
$smarty->assign("aashifty", array(7,14,21,28,35));
$data = array();
for($i=1;$i<=36;$i++) $data[] = $i;
$smarty->assign("anyshiftx", $data);
$data = array();
for($i=1;$i<=36;$i++) $data[] = $i;
$smarty->assign("anyshifty", $data);
$data = array();
for($i=7;$i<=35;$i+=7) $data[] = $i;
$smarty->assign("aarshiftx", $data);
$data = array();
for($i=5; $i<=35; $i+=5) $data[] = $i;
$smarty->assign("aarshifty", $data);
$data = array();
// 產生 unique form id
$smarty->assign("formid", md5($_SESSION['mylogin']['email'] . uniqid(rand(), true)));
$smarty->assign("title", "產生地圖");
echo $smarty->fetch('mapform.html');
echo $smarty->fetch('analytics.html');
?>
<script type="text/javascript">
var called = 0;
<?php
// 自動填入參數
// 兩條路徑, 1: from main.php?GET
// 2. from list.php SESSION
if (isset($_SESSION['makeparam']) && isset($_SESSION['makeparam']['x'])) {
// 選取範圍 TWD97 的 X 剛好多1km
if ( $_SESSION['makeparam']['datum'] == 'TWD97' && !isset($_SESSION['makeparam']['recreate']) )
$_SESSION['makeparam']['x']++;
?>
called = 1;
$("#mapform input[name=startx]").val("<?php echo $_SESSION['makeparam']['x'];?>");
$("#mapform input[name=starty]").val("<?php echo $_SESSION['makeparam']['y'];?>");
$("#mapform select[name=anyshiftx]").val("<?php echo $_SESSION['makeparam']['shiftx']; ?>");
$("#mapform select[name=anyshifty]").val("<?php echo $_SESSION['makeparam']['shifty']; ?>");
$("#mapform input[name=startx]").attr("readonly", true);
$("#mapform input[name=starty]").attr("readonly", true);
$("#mapform select[name=anyshiftx]").attr("disabled", true);
$("#mapform select[name=anyshifty]").attr("disabled", true);
$("#mapform select[name=version]").val("<?php echo $_SESSION['makeparam']['version']; ?>");
$("#mapform select[name=ph]").val("<?php echo $_SESSION['makeparam']['ph']; ?>");
$("#mapform input[name=ph]").attr("readonly", true);
$("#mapform input[name=97datum]").attr("checked", <?php echo ($_SESSION['makeparam']['datum'] == 'TWD97')?"true":"false"; ?> );
<?php
if (isset($_SESSION['makeparam']['title'])) {
?>
$("#mapform input[name=title]").val("<?php echo str_replace('"','\"',$_SESSION['makeparam']['title']); ?>");
$("#dialog-message").hide();
<?php
} else {
?>
$("#mapform input[name=title]").focus();
$("#dialog-message").dialog({
modal: true,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
<?php
}
unset($_SESSION['makeparam']);
} else if (isset($_SESSION['makeparam2'])) { // gpx重新產生
?>
called = 2;
$("#mapform input[name=title]").val("<?php echo $_SESSION['makeparam2']['title']; ?>");
$("#mapform input[name=gpxmid]").val("<?php echo $_SESSION['makeparam2']['mid']; ?>");
$("#mapform input[name=gpxfilename]").val("<?php echo str_replace(".tag.png",".gpx",basename($_SESSION['makeparam2']['filename'])); ?>");
<?php
unset($_SESSION['makeparam2']);
} // makeparam2
?>
$('#a3').click(function(){
alert("A3 打勾後面輸出 5x7變7x10,4x6變6x8,3x4變6x4,2x3變3x4。");
});
$('#bt1').unbind('click').click(function() {
if ($("#mapform button[name=bt1]").html() == '輸入座標產生') {
$("#mapform button[name=bt1]").html('上傳航跡檔產生');
$(".gpx_mode").show();
$("#create2").show();
//blinking('create2',1);
//blinking('create3',0);
//blinking('create',0);
$("#create").hide();
$("#create3").hide();
$(".normal_mode").hide();
$(".gpx_recreate_mode").hide();
$("#mapform input[name=gps]").val(1);
// tips
$('#step_version').text("4");
$('#step_other').text("5");
$('#step_go').text("6");
} else {
$("#mapform button[name=bt1]").html('輸入座標產生');
$(".gpx_mode").hide();
$(".normal_mode").show();
$("#create").show();
//blinking('create',1);
//blinking('create3',0);
//blinking('create2',0);
$("#create2").hide();
$("#create3").hide();
$(".gpx_recreate_mode").hide();
$("#mapform input[name=gps]").val(0);
$('#step_x').text("2");
$('#step_y').text("3");
$('#step_bound').text("4");
$('#step_area').text("5");
$('#step_version').text("6");
$('#step_other').text("7");
$('#step_go').text("8");
}
});
$('#create').unbind('click').click(function() {
//if (!$("#mapform").valid()) return false;
// 不用 validate plugin 了
// 先 block 再 ajax
console.log($('#formid').val());
if ($("#mapform input[name=title]").val().length < 2) {
alert("請輸入標題喔(多一點字)");
return false;
}
if ($("#mapform input[name=startx]").val().length < 3) {
alert("請輸入 X 座標");
return false;
}
if ($("#mapform input[name=starty]").val().length < 4) {
alert("請輸入 Y 座標");
return false;
}
$("#mapform select[name=anyshiftx]").attr("disabled", false);
$("#mapform select[name=anyshifty]").attr("disabled", false);
$.blockUI({ css: {
border: 'none',
padding: '15px',
backgroundColor: '#000',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
opacity: .5,
color: '#fff'
}, message: '<h1>讓我來慢慢產生,您去喝杯茶做做體操再回來!</h1>' });
globalxdr = $.post("backend_make.php", $("#mapform").serialize(),function(data){
$.unblockUI();
if (data.status == "ok") {
clearProgress();
var $tabs = $('#tabs').tabs();
$("#tabs li").eq(0).data("loaded", false).find('a').attr("href","mapform.php");
$("#tabs li").eq(3).data("loaded", false).find('a').attr("href","show.php?tab=1&mid="+data.id);
$tabs.tabs('option',"active",3);
}
else
alert("error: "+data.error);
},"json");
});
$('#create2').unbind('click').click(function() {
//$("#mapform").attr('action', "backend_make.php");
if (!$('input:file').val()) {
alert("請選擇檔案");
return false;
}
if ($("#mapform input[name=title]").val().length < 2) {
alert("請輸入標題喔(多一點字)");
return false;
}
$.blockUI({ css: {
border: 'none',
padding: '15px',
backgroundColor: '#000',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
opacity: .5,
color: '#fff'
}, message: '<h1>讓我來慢慢產生,您去喝杯越南咖啡做做體操再回來!</h1>' });
if (! window.FormData)
document.mapform.submit();
else { // use HTML5 ajax file upload
var form = $('#mapform')[0]; // You need to use standart javascript object here
var formData = new FormData(form);
$.ajax({
url: 'backend_make.php',
data: formData,
type: 'POST',
dataType : 'json',
contentType: false,
processData: false,
success : function(data){
$.unblockUI();
if (data.status == "ok") {
clearProgress();
var $tabs = $('#tabs').tabs();
$("#tabs li").eq(0).data("loaded", false).find('a').attr("href","mapform.php");
$("#tabs li").eq(3).data("loaded", false).find('a').attr("href","show.php?tab=1&mid="+data.id);
$tabs.tabs('option',"active",3);
}
else
alert("error: "+data.error);
}
});
} // end of else
});
$('#create3').unbind('click').click(function() {
$("#mapform input[name=gps]").val(2);
if ($("#mapform input[name=title]").val().length < 2) {
alert("請輸入標題喔(多一點字)");
return false;
}
$.blockUI({ css: {
border: 'none',
padding: '15px',
backgroundColor: '#000',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
opacity: .5,
color: '#fff'
}, message: '<h1>讓我來慢慢產生,您去喝杯好了啦做做瑜伽再回來!</h1>' });
globalxdr = $.post("backend_make.php", $("#mapform").serialize(),function(data){
$.unblockUI();
if (data.status == "ok") {
clearProgress();
var $tabs = $('#tabs').tabs();
$("#tabs li").eq(0).data("loaded", false).find('a').attr("href","mapform.php");
$("#tabs li").eq(3).data("loaded", false).find('a').attr("href","show.php?tab=1&mid="+data.id);
$tabs.tabs('option',"active",3);
}
else
alert("error: "+data.error);
},"json");
});
$('#switch_bt1').click(function() {
$('#bt1').trigger('click');
});
$(document).ready(function(){
//alert("here");
//if (called != 1 )
$("#dialog-message").hide();
$("#mapform").validate();
$(".gpx_mode").hide();
// tips
$('#step_x').text("2");
$('#step_y').text("3");
$('#step_bound').text("4");
$('#step_area').text("5");
$('#step_version').text("6");
$('#step_other').text("7");
$('#step_go').text("8");
// blinking('bt1',1);
if (called == 1 ) {
$(".method").hide();
$("#mapform_note").hide();
$('#step_go').text("這裡");
//blinking('create',1);
//blinking('create2',0);
//blinking('create3',0);
$("#create3").hide();
$("#create2").hide();
}
if (called == 2 ) {
//alert(called);
$(".normal_mode").hide();
$(".gpx_mode").hide();
$(".gpx_recreate_mode").show();
$(".method").hide();
$("#mapform_note").hide();
$("#create3").show();
//blinking('create3',1);
//blinking('create2',0);
//blinking('create',0);
$("#create").hide();
$("#create2").hide();
//alert(called);
//alert(called);
// tip
$('#step_version').text("3");
$('#step_go').text("這裡");
} else {
$(".gpx_recreate_mode").hide();
//blinking('create',1);
//blinking('create2',0);
//blinking('create3',0);
$("#create2").hide();
$("#create3").hide();
}
wsServer = 'wss://ws.happyman.idv.tw:443/twmap_' + $("#formid").val();
connect_ws();
// progressbar stuff
makeprogress = $("#makeprogress");
makeprogress.progressbar({
"value": 0
}).show();
makeprogress.children().css("background", "lightgreen");
$( ".psLabel" ).css("background","");
});
</script>