This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * The MIT License (MIT) |
||
4 | * |
||
5 | * Copyright (c) 2016 Robert Sardinia |
||
6 | * |
||
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
||
8 | * of this software and associated documentation files (the "Software"), to deal |
||
9 | * in the Software without restriction, including without limitation the rights |
||
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||
11 | * copies of the Software, and to permit persons to whom the Software is |
||
12 | * furnished to do so, subject to the following conditions: |
||
13 | * |
||
14 | * The above copyright notice and this permission notice shall be included in all |
||
15 | * copies or substantial portions of the Software. |
||
16 | * |
||
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||
23 | * SOFTWARE. |
||
24 | */ |
||
25 | |||
26 | use discord\discord; |
||
27 | |||
28 | /** |
||
29 | * Class fleetUpOperations |
||
30 | * @property userID |
||
31 | * @property apiKey |
||
32 | * @property groupID |
||
33 | */ |
||
34 | class fleetUpOperations |
||
0 ignored issues
–
show
|
|||
35 | { |
||
36 | public $config; |
||
37 | public $discord; |
||
38 | public $logger; |
||
39 | protected $keyID; |
||
40 | protected $vCode; |
||
41 | protected $prefix; |
||
42 | private $toDiscordChannel; |
||
43 | private $userID; |
||
44 | private $groupID; |
||
45 | private $apiKey; |
||
46 | private $guild; |
||
47 | |||
48 | /** |
||
49 | * @param $config |
||
50 | * @param $discord |
||
51 | * @param $logger |
||
52 | */ |
||
53 | public function init($config, $discord, $logger) |
||
54 | { |
||
55 | $this->config = $config; |
||
56 | $this->discord = $discord; |
||
57 | $this->logger = $logger; |
||
58 | $this->toDiscordChannel = $config['plugins']['fleetUp']['channelID']; |
||
59 | $this->userID = $config['plugins']['fleetUp']['userID']; |
||
60 | $this->groupID = $config['plugins']['fleetUp']['groupID']; |
||
61 | $this->apiKey = $config['plugins']['fleetUp']['apiKey']; |
||
62 | $this->guild = $config['bot']['guild']; |
||
63 | $lastCheck = getPermCache('fleetUpPostLastChecked'); |
||
64 | if ($lastCheck === NULL) { |
||
65 | // Schedule it for right now if first run |
||
66 | setPermCache('fleetUpPostLastChecked', time() - 5); |
||
67 | } |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * |
||
72 | */ |
||
73 | public function tick() |
||
74 | { |
||
75 | $lastChecked = getPermCache('fleetUpPostLastChecked'); |
||
76 | |||
77 | if ($lastChecked <= time()) { |
||
78 | $this->postFleetUp(); |
||
79 | $this->checkFleetUp(); |
||
80 | } |
||
81 | } |
||
82 | |||
83 | private function postFleetUp() |
||
84 | { |
||
85 | date_default_timezone_set('UTC'); |
||
86 | $eveTime = time(); |
||
87 | //fleetUp post upcoming operations |
||
88 | $currentID = getPermCache('fleetUpLastPostedOperation'); |
||
89 | $fleetUpOperations = json_decode(downloadData("http://api.fleet-up.com/Api.svc/tlYgBRjmuXj2Yl1lEOyMhlDId/{$this->userID}/{$this->apiKey}/Operations/{$this->groupID}"), true); |
||
90 | View Code Duplication | foreach ($fleetUpOperations['Data'] as $operation) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
91 | $name = $operation['Subject']; |
||
92 | $startTime = $operation['StartString']; |
||
93 | preg_match_all('!\d+!', $operation['Start'], $epochStart); |
||
94 | $startTimeUnix = substr($epochStart[0][0], 0, -3); |
||
95 | $destination = $operation['Location']; |
||
96 | $formUp = $operation['LocationInfo']; |
||
97 | $info = $operation['Details']; |
||
98 | $id = $operation['Id']; |
||
99 | $link = "https://fleet-up.com/Operation#{$id}"; |
||
100 | $timeDifference = $startTimeUnix - $eveTime; |
||
101 | if ($currentID !== $id) { |
||
102 | if ($timeDifference < 900 && $timeDifference > 1) { |
||
103 | $msg = "@everyone |
||
104 | **Upcoming Operation** |
||
105 | Title - {$name} |
||
106 | Form Up Time - {$startTime} |
||
107 | Form Up System - {$formUp} |
||
108 | Target System - {$destination} |
||
109 | Details - {$info} |
||
110 | |||
111 | Link - {$link}"; |
||
112 | $channelID = $this->toDiscordChannel; |
||
113 | priorityQueueMessage($msg, $channelID, $this->guild); |
||
114 | setPermCache('fleetUpLastPostedOperation', $id); |
||
115 | $this->logger->addInfo('FleetUp: Upcoming Operation Queued for Posting'); |
||
116 | } |
||
117 | } |
||
118 | } |
||
119 | setPermCache('fleetUpPostLastChecked', time() + 910); |
||
120 | } |
||
121 | |||
122 | private function checkFleetUp() |
||
123 | { |
||
124 | date_default_timezone_set('UTC'); |
||
125 | $eveTime = time(); |
||
126 | |||
127 | $lastChecked = getPermCache('fleetUpLastChecked'); |
||
128 | |||
129 | if ($lastChecked <= time()) { |
||
130 | |||
131 | //fleetUp check for new operations |
||
132 | $currentID = getPermCache('fleetUpLastOperation'); |
||
133 | $fleetUpOperations = json_decode(downloadData("http://api.fleet-up.com/Api.svc/tlYgBRjmuXj2Yl1lEOyMhlDId/{$this->userID}/{$this->apiKey}/Operations/{$this->groupID}"), true); |
||
134 | View Code Duplication | foreach ($fleetUpOperations['Data'] as $operation) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
135 | $name = $operation['Subject']; |
||
136 | $startTime = $operation['StartString']; |
||
137 | preg_match_all('!\d+!', $operation['Start'], $epochStart); |
||
138 | $startTimeUnix = substr($epochStart[0][0], 0, -3); |
||
139 | $desto = $operation['Location']; |
||
140 | $formUp = $operation['LocationInfo']; |
||
141 | $info = $operation['Details']; |
||
142 | $id = $operation['Id']; |
||
143 | $link = "https://fleet-up.com/Operation#{$id}"; |
||
144 | $timeDifference = $startTimeUnix - $eveTime; |
||
145 | if ($currentID < $id && $timeDifference > 1) { |
||
146 | $msg = " |
||
147 | **New Operation Posted** |
||
148 | Title - {$name} |
||
149 | Form Up Time - {$startTime} |
||
150 | Form Up System - {$formUp} |
||
151 | Target System - {$desto} |
||
152 | Details - {$info} |
||
153 | |||
154 | Link - {$link}"; |
||
155 | $channelID = $this->toDiscordChannel; |
||
156 | queueMessage($msg, $channelID, $this->guild); |
||
157 | $this->logger->addInfo('FleetUp: Newest FleetUp operation queued for posting'); |
||
158 | } |
||
159 | if ($id > $currentID) { |
||
160 | setPermCache('fleetUpLastOperation', $id); |
||
161 | $this->logger->addInfo('FleetUp: Newest FleetUp operation'); |
||
162 | } |
||
163 | } |
||
164 | setPermCache('fleetUpLastChecked', time() + 300); |
||
165 | } |
||
166 | } |
||
167 | |||
168 | } |
||
169 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.