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 | * @property message |
||
30 | */ |
||
31 | class charInfo |
||
0 ignored issues
–
show
|
|||
32 | { |
||
33 | public $config; |
||
34 | public $discord; |
||
35 | public $logger; |
||
36 | private $excludeChannel; |
||
37 | private $message; |
||
38 | private $triggers; |
||
39 | |||
40 | /** |
||
41 | * @param $config |
||
42 | * @param $discord |
||
43 | * @param $logger |
||
44 | */ |
||
45 | View Code Duplication | public function init($config, $discord, $logger) |
|
0 ignored issues
–
show
This method seems to be duplicated in 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. ![]() |
|||
46 | { |
||
47 | $this->config = $config; |
||
48 | $this->discord = $discord; |
||
49 | $this->logger = $logger; |
||
50 | $this->excludeChannel = $this->config['bot']['restrictedChannels']; |
||
51 | $this->triggers[] = $this->config['bot']['trigger'] . 'char'; |
||
52 | $this->triggers[] = $this->config['bot']['trigger'] . 'Char'; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @param $msgData |
||
57 | * @param $message |
||
58 | * @return null |
||
59 | */ |
||
60 | public function onMessage($msgData, $message) |
||
61 | { |
||
62 | $channelID = (int) $msgData['message']['channelID']; |
||
63 | |||
64 | if (in_array($channelID, $this->excludeChannel, true)) |
||
65 | { |
||
66 | return null; |
||
67 | } |
||
68 | |||
69 | $this->message = $message; |
||
70 | |||
71 | $message = $msgData['message']['message']; |
||
72 | $user = $msgData['message']['from']; |
||
73 | |||
74 | $data = command($message, $this->information()['trigger'], $this->config['bot']['trigger']); |
||
75 | if (isset($data['trigger'])) { |
||
76 | |||
77 | // Most EVE players on Discord use their ingame name, so lets support @highlights |
||
78 | $messageString = strstr($data['messageString'], '@') ? str_replace('<@', '', str_replace('>', '', $data['messageString'])) : $data['messageString']; |
||
79 | if (is_numeric($messageString)) { |
||
80 | // The person used @highlighting, so now we got a discord id, lets map that to a name |
||
81 | $messageString = dbQueryField('SELECT name FROM usersSeen WHERE id = :id', 'name', array(':id' => $messageString)); |
||
82 | } |
||
83 | |||
84 | $cleanString = urlencode($messageString); |
||
85 | $characterID = urlencode(characterID($cleanString)); |
||
86 | |||
87 | if (empty($characterID)) { |
||
88 | return $this->message->reply('**Error:** no data available'); |
||
89 | } |
||
90 | |||
91 | //Get details |
||
92 | $characterDetails = characterDetails($characterID); |
||
93 | if (null === $characterDetails) { |
||
94 | return $this->message->reply('**Error:** ESI is down. Try again later.'); |
||
95 | } |
||
96 | $corporationID = $characterDetails['corporation_id']; |
||
97 | $corporationName = corpName($corporationID); |
||
98 | if (null === $corporationName) { |
||
99 | return $this->message->reply('**Error:** ESI is down. Try again later.'); |
||
100 | } |
||
101 | $corporationDetails = corpDetails($corporationID); |
||
102 | $allianceID = @$corporationDetails['alliance_id']; |
||
103 | if (null !== $allianceID) { |
||
104 | $allianceName = allianceName($allianceID); |
||
105 | } else { |
||
106 | $allianceName = ''; |
||
107 | } |
||
108 | $characterName = $characterDetails['name']; |
||
109 | $dateOfBirth = $characterDetails['birthday']; |
||
110 | |||
111 | if ($characterName === null || $characterName === '') { |
||
112 | return $this->message->reply('**Error:** No character found.'); |
||
113 | } |
||
114 | |||
115 | //ZKill lookup |
||
116 | $url = "https://zkillboard.com/api/orderDirection/desc/limit/1/no-items/characterID/{$characterID}/xml/"; |
||
117 | $xml = makeApiRequest($url); |
||
118 | if (empty($xml)) { |
||
119 | return $this->message->reply('**Error:** ZKill is down. Try again later.'); |
||
120 | } |
||
121 | foreach ($xml->result->rowset->row as $kill) { |
||
122 | $lastSeenSystemID = @$kill->attributes()->solarSystemID; |
||
123 | $lastSeenDate = @$kill->attributes()->killTime; |
||
124 | if (null === $lastSeenSystemID || null === $lastSeenDate) { |
||
125 | $lastSeenSystem = 'No activity reported.'; |
||
126 | $lastSeenDate = 'No activity reported.'; |
||
127 | } else { |
||
128 | $lastSeenSystem = getSystemName($lastSeenSystemID); |
||
129 | } |
||
130 | } |
||
131 | foreach ($xml->result->rowset->row->rowset->row as $attacker) { |
||
132 | if ($attacker->attributes()->characterID == $characterID) { |
||
133 | $lastSeenShipID = $attacker->attributes()->shipTypeID; |
||
134 | $lastSeenShip = getTypeName($lastSeenShipID); |
||
135 | } else { |
||
136 | $lastSeenShip = 'No activity reported.'; |
||
137 | } |
||
138 | } |
||
139 | $url = "https://zkillboard.com/character/{$characterID}/"; |
||
140 | |||
141 | $msg = "```Name: {$characterName} |
||
142 | DOB: {$dateOfBirth} |
||
143 | |||
144 | Corporation Name: {$corporationName} |
||
145 | Alliance Name: {$allianceName} |
||
146 | |||
147 | Last Seen In System: {$lastSeenSystem} |
||
0 ignored issues
–
show
The variable
$lastSeenSystem does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
![]() |
|||
148 | Last Seen Flying a: {$lastSeenShip} |
||
0 ignored issues
–
show
The variable
$lastSeenShip does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
![]() |
|||
149 | Last Seen On: {$lastSeenDate}``` |
||
0 ignored issues
–
show
The variable
$lastSeenDate does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
![]() |
|||
150 | |||
151 | For more info, visit: $url"; |
||
152 | |||
153 | $this->logger->addInfo("charInfo: Sending character info to {$user}"); |
||
154 | $this->message->reply($msg); |
||
155 | } |
||
156 | return null; |
||
157 | } |
||
158 | |||
159 | /** |
||
160 | * @return array |
||
161 | */ |
||
162 | public function information() |
||
163 | { |
||
164 | return array( |
||
165 | 'name' => 'char', |
||
166 | 'trigger' => $this->triggers, |
||
167 | 'information' => 'Returns basic EVE Online data about a character. To use simply type !char character_name' |
||
168 | ); |
||
169 | } |
||
170 | |||
171 | } |
||
172 |
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.