forked from leonardoxc/leonardoxc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GUI_EXT_download_igc.php
120 lines (100 loc) · 3.85 KB
/
GUI_EXT_download_igc.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
<?
//************************************************************************
// Leonardo XC Server, https://github.com/leonardoxc/leonardoxc
//
// Copyright (c) 2004-2010 by Andreadakis Manolis
//
// 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.
//
// $Id: GUI_EXT_download_igc.php,v 1.1 2011/05/18 13:31:48 manolis Exp $
//
//************************************************************************
// nice exmple in action
//http://onerutter.com/open-source/jquery-facebook-like-plugin.html
require_once dirname(__FILE__)."/EXT_config_pre.php";
require_once dirname(__FILE__)."/config.php";
require_once dirname(__FILE__)."/EXT_config.php";
require_once dirname(__FILE__)."/CL_flightScore.php";
require_once dirname(__FILE__)."/CL_flightData.php";
require_once dirname(__FILE__)."/FN_functions.php";
require_once dirname(__FILE__)."/FN_UTM.php";
require_once dirname(__FILE__)."/FN_waypoint.php";
require_once dirname(__FILE__)."/FN_output.php";
require_once dirname(__FILE__)."/FN_pilot.php";
require_once dirname(__FILE__)."/FN_flight.php";
require_once dirname(__FILE__)."/templates/".$PREFS->themeName."/theme.php";
setDEBUGfromGET();
require_once dirname(__FILE__)."/language/".CONF_LANG_ENCODING_TYPE."/lang-".$currentlang.".php";
require_once dirname(__FILE__)."/language/".CONF_LANG_ENCODING_TYPE."/countries-".$currentlang.".php";
$filename=makeSane($_REQUEST['file'],2);
$flightID=makeSane($_REQUEST['flightID'],1);
if ($flightID<=0 && !$filename ) exit;
$clientIP=getClientIpAddr();
if ( $flightID ) {
$flight=new flight();
$flight->getFlightFromDB($flightID);
$authOK=0;
if ( $flight->belongsToUser($userID) || L_auth::isModerator($userID) || L_auth::canDownloadIGC($clientIP) ) {
$authOK=1;
}
} else if ($filename){
$authOK=0;
$base_name=basename($filename);
// echo $base_name."#";
if ( L_auth::isModerator($userID) || L_auth::canDownloadIGC($clientIP) || $_SESSION['di'.$base_name] ) {
$authOK=1;
}
}
if ($authOK ) {
$type='igc';
require_once dirname(__FILE__).'/download_igc.php';
return;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?=$CONF_ENCODING?>">
<? if (!$authOK) {?>
<style type="text/css">
#igcLink {
display:block;
position:absolute;
top:50px;
left:100px;
z-index:-100;
}
body, * {
margin:0;
padding:0;
}
</style>
<link href="<?=moduleRelPath()?>/js/sexy-captcha/css/styles.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript" src="<?=moduleRelPath()?>/js/jquery.js"></script>
<script type="text/javascript" src="<?=moduleRelPath()?>/js/sexy-captcha/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript" src="<?=moduleRelPath()?>/js/sexy-captcha/jquery.sexy-captcha-0.1.js"></script>
<script language="javascript">
$(document).ready(function(){
$('.myCaptcha').sexyCaptcha('<?=moduleRelPath()?>/js/sexy-captcha/captcha.process.php');
$('#downloadForm').submit(function() {
$("#captchaStr").val( $("#captcha").val() );
return true;
});
});
</script>
<? } ?>
</head>
<body>
<form action="<?=$moduleRelPath?>/download_igc.php" method="post" id="downloadForm">
<input type="hidden" id="captchaStr" name="captchaStr" value="" />
<input type="hidden" id="type" name="type" value="igc" />
<input type="hidden" id="file" name="file" value="<?=$filename?>" />
<input type="hidden" id="flightID" name="flightID" value="<?=$flightID?>" />
<div class="myCaptcha"></div>
<div id="igcLink"><input type="submit" class='submit' value="Download IGC File" /></div>
</form>
</div>
</body>
</html>