forked from tarnus/aatraders2
/
beacon.php
117 lines (104 loc) · 3.4 KB
/
beacon.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
include ("config/config.php");
include ("languages/$langdir/lang_beacon.inc");
include ("globals/clean_words.inc");
get_post_ifset("beacon_text");
$title = $l_beacon_title;
if (checklogin() or $tournament_setup_access == 1)
{
$template_object->enable_gzip = 0;
include ("footer.php");
die();
}
$templatename = "master_template/";
include ("header.php");
$template_object->assign("title", $title);
$template_object->assign("templatename", $templatename);
$allowed_rsw = "N";
if ($shipdevice['dev_beacon']['amount'] > 0)
{
$res = $db->SelectLimit("SELECT allow_beacon FROM {$db_prefix}zones WHERE zone_id='$sectorinfo[zone_id]'", 1);
$zoneinfo = $res->fields;
if ($zoneinfo['allow_beacon'] == 'N')
{
$template_object->assign("error_msg", $l_beacon_notpermitted);
$template_object->assign("gotomain", $l_global_mmenu);
$template_object->display("master_template/beaconsdie.tpl");
include ("footer.php");
die();
}
elseif ($zoneinfo['allow_beacon'] == 'L')
{
$result3 = $db->SelectLimit("SELECT * FROM {$db_prefix}zones WHERE zone_id='$sectorinfo[zone_id]'", 1);
$zoneowner_info = $result3->fields;
$result5 = $db->SelectLimit("SELECT team FROM {$db_prefix}players WHERE player_id='$zoneowner_info[owner]'", 1);
$zoneteam = $result5->fields;
if ($zoneowner_info['owner'] != $playerinfo['player_id'])
{
if (($zoneteam[team] != $playerinfo['team']) || ($playerinfo['team'] == 0))
{
$template_object->assign("error_msg", $l_beacon_notpermitted);
$template_object->assign("gotomain", $l_global_mmenu);
$template_object->display("master_template/beaconsdie.tpl");
include ("footer.php");
die();
}
else
{
$allowed_rsw = "Y";
}
}
else
{
$allowed_rsw = "Y";
}
}
else
{
$allowed_rsw = "Y";
}
if ($allowed_rsw == "Y")
{
if ((!isset($beacon_text)) || ($beacon_text == ''))
{
if ($sectorinfo['beacon'] != "")
{
$template_object->assign("beacon_info", "$l_beacon_reads: \"$sectorinfo[beacon]\"");
}
else
{
$template_object->assign("beacon_info", $l_beacon_none);
}
$template_object->assign("l_beacon_enter", $l_beacon_enter);
$template_object->assign("l_submit", $l_submit);
$template_object->assign("l_reset", $l_reset);
$template_object->assign("gotomain", $l_global_mmenu);
$template_object->display("master_template/beacons.tpl");
include ("footer.php");
die();
}
else
{
$beacon_text = clean_words(trim(strip_tags($beacon_text)));
$debug_query = $db->Execute("UPDATE {$db_prefix}universe SET beacon=" . $db->qstr($beacon_text) . " WHERE sector_id=$sectorinfo[sector_id]");
db_op_result($debug_query,__LINE__,__FILE__);
$debug_query = $db->Execute("UPDATE {$db_prefix}ship_devices SET amount=amount-1 WHERE device_id=" . $shipdevice['dev_beacon']['device_id']);
db_op_result($debug_query,__LINE__,__FILE__);
$template_object->assign("error_msg", "$l_beacon_nowreads: \"$beacon_text\".");
$template_object->assign("gotomain", $l_global_mmenu);
$template_object->display("master_template/beaconsdie.tpl");
include ("footer.php");
die();
}
}
}
else
{
$template_object->assign("error_msg", $l_beacon_donthave);
$template_object->assign("gotomain", $l_global_mmenu);
$template_object->display("master_template/beaconsdie.tpl");
include ("footer.php");
die();
}
close_database();
?>