Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 32 | class siloFull { |
||
|
|
|||
| 33 | /** |
||
| 34 | * @var |
||
| 35 | */ |
||
| 36 | var $config; |
||
| 37 | /** |
||
| 38 | * @var |
||
| 39 | */ |
||
| 40 | var $discord; |
||
| 41 | /** |
||
| 42 | * @var |
||
| 43 | */ |
||
| 44 | var $logger; |
||
| 45 | /** |
||
| 46 | * @var |
||
| 47 | */ |
||
| 48 | var $toDiscordChannel; |
||
| 49 | public $guild; |
||
| 50 | public $towerRace; |
||
| 51 | protected $keyID; |
||
| 52 | protected $vCode; |
||
| 53 | protected $prefix; |
||
| 54 | /** |
||
| 55 | * @param $config |
||
| 56 | * @param $discord |
||
| 57 | * @param $logger |
||
| 58 | */ |
||
| 59 | View Code Duplication | function init($config, $discord, $logger) |
|
| 60 | { |
||
| 61 | $this->config = $config; |
||
| 62 | $this->discord = $discord; |
||
| 63 | $this->logger = $logger; |
||
| 64 | $this->guild = $config["bot"]["guild"]; |
||
| 65 | $this->toDiscordChannel = $config["plugins"]["siloFull"]["channelID"]; |
||
| 66 | $this->keyID = $config["plugins"]["siloFull"]["keyID"]; |
||
| 67 | $this->vCode = $config["plugins"]["siloFull"]["vCode"]; |
||
| 68 | $this->towerRace = $config["plugins"]["siloFull"]["towerRace"]; |
||
| 69 | $lastCheck = getPermCache("siloLastChecked{$this->keyID}"); |
||
| 70 | if ($lastCheck == NULL) { |
||
| 71 | // Schedule it for right now if first run |
||
| 72 | setPermCache("siloLastChecked{$this->keyID}", time() - 5); |
||
| 73 | } |
||
| 74 | } |
||
| 75 | /** |
||
| 76 | * |
||
| 77 | */ |
||
| 78 | function tick() |
||
| 79 | { |
||
| 80 | $lastChecked = getPermCache("siloLastChecked{$this->keyID}"); |
||
| 81 | $keyID = $this->keyID; |
||
| 82 | $vCode = $this->vCode; |
||
| 83 | if ($lastChecked <= time()) { |
||
| 84 | $this->logger->addInfo("Checking API Key {$keyID} for full silos"); |
||
| 85 | $this->checkTowers($keyID, $vCode); |
||
| 86 | } |
||
| 87 | } |
||
| 88 | function checkTowers($keyID, $vCode) |
||
| 89 | { |
||
| 90 | $discord = $this->discord; |
||
| 91 | |||
| 92 | $url = "https://api.eveonline.com/corp/AssetList.xml.aspx?keyID={$keyID}&vCode={$vCode}"; |
||
| 93 | $xml = makeApiRequest($url); |
||
| 94 | $siloCount = 0; |
||
| 95 | $towerMulti = 0; |
||
| 96 | $towerFull = 20000; |
||
| 97 | $cleanFull = number_format($towerFull); |
||
| 98 | View Code Duplication | if ($this->towerRace == 1) { |
|
| 99 | $towerMulti = 0.50; |
||
| 100 | $towerFull = 30000; |
||
| 101 | $cleanFull = number_format($towerFull); |
||
| 102 | } |
||
| 103 | View Code Duplication | if ($this->towerRace == 2) { |
|
| 104 | $towerMulti = 1; |
||
| 105 | $towerFull = 40000; |
||
| 106 | $cleanFull = number_format($towerFull); |
||
| 107 | } |
||
| 108 | foreach ($xml->result->rowset->row as $structures) { |
||
| 109 | //Check silos |
||
| 110 | if ($structures->attributes()->typeID == 14343) { |
||
| 111 | if (isset($structures->rowset->row)) { |
||
| 112 | foreach ($structures->rowset->row as $silo) { |
||
| 113 | $moonGoo = $silo->attributes()->typeID; |
||
| 114 | switch ($moonGoo) { |
||
| 115 | View Code Duplication | case 16634: |
|
| 116 | $typeName = dbQueryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => 16634), "ccp"); |
||
| 117 | $systemName = dbQueryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $structures->attributes()->locationID), "ccp"); |
||
| 118 | $towerWarn = 180000 + (180000 * $towerMulti); |
||
| 119 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 120 | $gooAmount = $silo->attributes()->quantity; |
||
| 121 | $gooVolume = 0.1; |
||
| 122 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 123 | $cleanNumber = number_format($gooCurrent); |
||
| 124 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 125 | if ($gooCurrent == $towerFull) { |
||
| 126 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 127 | } |
||
| 128 | $msg .= "**System: **{$systemName}\n"; |
||
| 129 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 130 | $this->logger->addInfo("{$typeName} Silo nearing capacity in {$systemName}"); |
||
| 131 | // Send the msg to the channel; |
||
| 132 | $channelID = $this->toDiscordChannel; |
||
| 133 | $guild = $discord->guilds->get('id', $this->guild); |
||
| 134 | $channel = $guild->channels->get('id', $channelID); |
||
| 135 | $channel->sendMessage($msg, false); |
||
| 136 | $siloCount++; |
||
| 137 | sleep(1); |
||
| 138 | } |
||
| 139 | break; |
||
| 140 | View Code Duplication | case 16643: |
|
| 141 | $typeName = dbQueryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => 16643), "ccp"); |
||
| 142 | $systemName = dbQueryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $structures->attributes()->locationID), "ccp"); |
||
| 143 | $towerWarn = 45000 + (45000 * $towerMulti); |
||
| 144 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 145 | $gooAmount = $silo->attributes()->quantity; |
||
| 146 | $gooVolume = 0.4; |
||
| 147 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 148 | $cleanNumber = number_format($gooCurrent); |
||
| 149 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 150 | if ($gooCurrent == $towerFull) { |
||
| 151 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 152 | } |
||
| 153 | $msg .= "**System: **{$systemName}\n"; |
||
| 154 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 155 | $this->logger->addInfo("{$typeName} Silo nearing capacity in {$systemName}"); |
||
| 156 | // Send the msg to the channel; |
||
| 157 | $channelID = $this->toDiscordChannel; |
||
| 158 | $guild = $discord->guilds->get('id', $this->guild); |
||
| 159 | $channel = $guild->channels->get('id', $channelID); |
||
| 160 | $channel->sendMessage($msg, false); |
||
| 161 | $siloCount++; |
||
| 162 | sleep(1); |
||
| 163 | } |
||
| 164 | break; |
||
| 165 | View Code Duplication | case 16647: |
|
| 166 | $typeName = dbQueryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => 16647), "ccp"); |
||
| 167 | $systemName = dbQueryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $structures->attributes()->locationID), "ccp"); |
||
| 168 | $towerWarn = 22500 + (22500 * $towerMulti); |
||
| 169 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 170 | $gooAmount = $silo->attributes()->quantity; |
||
| 171 | $gooVolume = 0.8; |
||
| 172 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 173 | $cleanNumber = number_format($gooCurrent); |
||
| 174 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 175 | if ($gooCurrent == $towerFull) { |
||
| 176 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 177 | } |
||
| 178 | $msg .= "**System: **{$systemName}\n"; |
||
| 179 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 180 | $this->logger->addInfo("{$typeName} Silo nearing capacity in {$systemName}"); |
||
| 181 | // Send the msg to the channel; |
||
| 182 | $channelID = $this->toDiscordChannel; |
||
| 183 | $guild = $discord->guilds->get('id', $this->guild); |
||
| 184 | $channel = $guild->channels->get('id', $channelID); |
||
| 185 | $channel->sendMessage($msg, false); |
||
| 186 | $siloCount++; |
||
| 187 | sleep(1); |
||
| 188 | } |
||
| 189 | break; |
||
| 190 | View Code Duplication | case 16641: |
|
| 191 | $typeName = dbQueryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => 16641), "ccp"); |
||
| 192 | $systemName = dbQueryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $structures->attributes()->locationID), "ccp"); |
||
| 193 | $towerWarn = 30000 + (30000 * $towerMulti); |
||
| 194 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 195 | $gooAmount = $silo->attributes()->quantity; |
||
| 196 | $gooVolume = 0.6; |
||
| 197 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 198 | $cleanNumber = number_format($gooCurrent); |
||
| 199 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 200 | if ($gooCurrent == $towerFull) { |
||
| 201 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 202 | } |
||
| 203 | $msg .= "**System: **{$systemName}\n"; |
||
| 204 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 205 | $this->logger->addInfo("{$typeName} Silo nearing capacity in {$systemName}"); |
||
| 206 | // Send the msg to the channel; |
||
| 207 | $channelID = $this->toDiscordChannel; |
||
| 208 | $guild = $discord->guilds->get('id', $this->guild); |
||
| 209 | $channel = $guild->channels->get('id', $channelID); |
||
| 210 | $channel->sendMessage($msg, false); |
||
| 211 | $siloCount++; |
||
| 212 | sleep(1); |
||
| 213 | } |
||
| 214 | break; |
||
| 215 | View Code Duplication | case 16640: |
|
| 216 | $typeName = dbQueryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => 16640), "ccp"); |
||
| 217 | $systemName = dbQueryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $structures->attributes()->locationID), "ccp"); |
||
| 218 | $towerWarn = 45000 + (45000 * $towerMulti); |
||
| 219 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 220 | $gooAmount = $silo->attributes()->quantity; |
||
| 221 | $gooVolume = 0.4; |
||
| 222 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 223 | $cleanNumber = number_format($gooCurrent); |
||
| 224 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 225 | if ($gooCurrent == $towerFull) { |
||
| 226 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 227 | } |
||
| 228 | $msg .= "**System: **{$systemName}\n"; |
||
| 229 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 230 | $this->logger->addInfo("{$typeName} Silo nearing capacity in {$systemName}"); |
||
| 231 | // Send the msg to the channel; |
||
| 232 | $channelID = $this->toDiscordChannel; |
||
| 233 | $guild = $discord->guilds->get('id', $this->guild); |
||
| 234 | $channel = $guild->channels->get('id', $channelID); |
||
| 235 | $channel->sendMessage($msg, false); |
||
| 236 | $siloCount++; |
||
| 237 | sleep(1); |
||
| 238 | } |
||
| 239 | break; |
||
| 240 | View Code Duplication | case 16635: |
|
| 241 | $typeName = dbQueryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => 16635), "ccp"); |
||
| 242 | $systemName = dbQueryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $structures->attributes()->locationID), "ccp"); |
||
| 243 | $towerWarn = 180000 + (180000 * $towerMulti); |
||
| 244 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 245 | $gooAmount = $silo->attributes()->quantity; |
||
| 246 | $gooVolume = 0.1; |
||
| 247 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 248 | $cleanNumber = number_format($gooCurrent); |
||
| 249 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 250 | if ($gooCurrent == $towerFull) { |
||
| 251 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 252 | } |
||
| 253 | $msg .= "**System: **{$systemName}\n"; |
||
| 254 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 255 | $this->logger->addInfo("{$typeName} Silo nearing capacity in {$systemName}"); |
||
| 256 | // Send the msg to the channel; |
||
| 257 | $channelID = $this->toDiscordChannel; |
||
| 258 | $guild = $discord->guilds->get('id', $this->guild); |
||
| 259 | $channel = $guild->channels->get('id', $channelID); |
||
| 260 | $channel->sendMessage($msg, false); |
||
| 261 | $siloCount++; |
||
| 262 | sleep(1); |
||
| 263 | } |
||
| 264 | break; |
||
| 265 | View Code Duplication | case 16648: |
|
| 266 | $typeName = dbQueryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => 16648), "ccp"); |
||
| 267 | $systemName = dbQueryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $structures->attributes()->locationID), "ccp"); |
||
| 268 | $towerWarn = 22500 + (22500 * $towerMulti); |
||
| 269 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 270 | $gooAmount = $silo->attributes()->quantity; |
||
| 271 | $gooVolume = 0.8; |
||
| 272 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 273 | $cleanNumber = number_format($gooCurrent); |
||
| 274 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 275 | if ($gooCurrent == $towerFull) { |
||
| 276 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 277 | } |
||
| 278 | $msg .= "**System: **{$systemName}\n"; |
||
| 279 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 280 | $this->logger->addInfo("{$typeName} Silo nearing capacity in {$systemName}"); |
||
| 281 | // Send the msg to the channel; |
||
| 282 | $channelID = $this->toDiscordChannel; |
||
| 283 | $guild = $discord->guilds->get('id', $this->guild); |
||
| 284 | $channel = $guild->channels->get('id', $channelID); |
||
| 285 | $channel->sendMessage($msg, false); |
||
| 286 | $siloCount++; |
||
| 287 | sleep(1); |
||
| 288 | } |
||
| 289 | break; |
||
| 290 | View Code Duplication | case 16633: |
|
| 291 | $typeName = dbQueryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => 16633), "ccp"); |
||
| 292 | $systemName = dbQueryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $structures->attributes()->locationID), "ccp"); |
||
| 293 | $towerWarn = 180000 + (180000 * $towerMulti); |
||
| 294 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 295 | $gooAmount = $silo->attributes()->quantity; |
||
| 296 | $gooVolume = 0.1; |
||
| 297 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 298 | $cleanNumber = number_format($gooCurrent); |
||
| 299 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 300 | if ($gooCurrent == $towerFull) { |
||
| 301 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 302 | } |
||
| 303 | $msg .= "**System: **{$systemName}\n"; |
||
| 304 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 305 | $this->logger->addInfo("{$typeName} Silo nearing capacity in {$systemName}"); |
||
| 306 | // Send the msg to the channel; |
||
| 307 | $channelID = $this->toDiscordChannel; |
||
| 308 | $guild = $discord->guilds->get('id', $this->guild); |
||
| 309 | $channel = $guild->channels->get('id', $channelID); |
||
| 310 | $channel->sendMessage($msg, false); |
||
| 311 | $siloCount++; |
||
| 312 | sleep(1); |
||
| 313 | } |
||
| 314 | break; |
||
| 315 | View Code Duplication | case 16646: |
|
| 316 | $typeName = dbQueryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => 16646), "ccp"); |
||
| 317 | $systemName = dbQueryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $structures->attributes()->locationID), "ccp"); |
||
| 318 | $towerWarn = 22500 + (22500 * $towerMulti); |
||
| 319 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 320 | $gooAmount = $silo->attributes()->quantity; |
||
| 321 | $gooVolume = 0.8; |
||
| 322 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 323 | $cleanNumber = number_format($gooCurrent); |
||
| 324 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 325 | if ($gooCurrent == $towerFull) { |
||
| 326 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 327 | } |
||
| 328 | $msg .= "**System: **{$systemName}\n"; |
||
| 329 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 330 | $this->logger->addInfo("{$typeName} Silo nearing capacity in {$systemName}"); |
||
| 331 | // Send the msg to the channel; |
||
| 332 | $channelID = $this->toDiscordChannel; |
||
| 333 | $guild = $discord->guilds->get('id', $this->guild); |
||
| 334 | $channel = $guild->channels->get('id', $channelID); |
||
| 335 | $channel->sendMessage($msg, false); |
||
| 336 | $siloCount++; |
||
| 337 | sleep(1); |
||
| 338 | } |
||
| 339 | break; |
||
| 340 | View Code Duplication | case 16651: |
|
| 341 | $typeName = dbQueryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => 16651), "ccp"); |
||
| 342 | $systemName = dbQueryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $structures->attributes()->locationID), "ccp"); |
||
| 343 | $towerWarn = 18000 + (18000 * $towerMulti); |
||
| 344 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 345 | $gooAmount = $silo->attributes()->quantity; |
||
| 346 | $gooVolume = 1; |
||
| 347 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 348 | $cleanNumber = number_format($gooCurrent); |
||
| 349 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 350 | if ($gooCurrent == $towerFull) { |
||
| 351 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 352 | } |
||
| 353 | $msg .= "**System: **{$systemName}\n"; |
||
| 354 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 355 | $this->logger->addInfo("{$typeName} Silo nearing capacity in {$systemName}"); |
||
| 356 | // Send the msg to the channel; |
||
| 357 | $channelID = $this->toDiscordChannel; |
||
| 358 | $guild = $discord->guilds->get('id', $this->guild); |
||
| 359 | $channel = $guild->channels->get('id', $channelID); |
||
| 360 | $channel->sendMessage($msg, false); |
||
| 361 | $siloCount++; |
||
| 362 | sleep(1); |
||
| 363 | } |
||
| 364 | break; |
||
| 365 | View Code Duplication | case 16650: |
|
| 366 | $typeName = dbQueryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => 16650), "ccp"); |
||
| 367 | $systemName = dbQueryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $structures->attributes()->locationID), "ccp"); |
||
| 368 | $towerWarn = 18000 + (18000 * $towerMulti); |
||
| 369 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 370 | $gooAmount = $silo->attributes()->quantity; |
||
| 371 | $gooVolume = 1; |
||
| 372 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 373 | $cleanNumber = number_format($gooCurrent); |
||
| 374 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 375 | if ($gooCurrent == $towerFull) { |
||
| 376 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 377 | } |
||
| 378 | $msg .= "**System: **{$systemName}\n"; |
||
| 379 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 380 | $this->logger->addInfo("{$typeName} Silo nearing capacity in {$systemName}"); |
||
| 381 | // Send the msg to the channel; |
||
| 382 | $channelID = $this->toDiscordChannel; |
||
| 383 | $guild = $discord->guilds->get('id', $this->guild); |
||
| 384 | $channel = $guild->channels->get('id', $channelID); |
||
| 385 | $channel->sendMessage($msg, false); |
||
| 386 | $siloCount++; |
||
| 387 | sleep(1); |
||
| 388 | } |
||
| 389 | break; |
||
| 390 | View Code Duplication | case 16644: |
|
| 391 | $typeName = dbQueryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => 16644), "ccp"); |
||
| 392 | $systemName = dbQueryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $structures->attributes()->locationID), "ccp"); |
||
| 393 | $towerWarn = 18000 + (18000 * $towerMulti); |
||
| 394 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 395 | $gooAmount = $silo->attributes()->quantity; |
||
| 396 | $gooVolume = 1; |
||
| 397 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 398 | $cleanNumber = number_format($gooCurrent); |
||
| 399 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 400 | if ($gooCurrent == $towerFull) { |
||
| 401 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 402 | } |
||
| 403 | $msg .= "**System: **{$systemName}\n"; |
||
| 404 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 405 | $this->logger->addInfo("{$typeName} Silo nearing capacity in {$systemName}"); |
||
| 406 | // Send the msg to the channel; |
||
| 407 | $channelID = $this->toDiscordChannel; |
||
| 408 | $guild = $discord->guilds->get('id', $this->guild); |
||
| 409 | $channel = $guild->channels->get('id', $channelID); |
||
| 410 | $channel->sendMessage($msg, false); |
||
| 411 | $siloCount++; |
||
| 412 | sleep(1); |
||
| 413 | } |
||
| 414 | break; |
||
| 415 | View Code Duplication | case 16652: |
|
| 416 | $typeName = dbQueryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => 16652), "ccp"); |
||
| 417 | $systemName = dbQueryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $structures->attributes()->locationID), "ccp"); |
||
| 418 | $towerWarn = 18000 + (18000 * $towerMulti); |
||
| 419 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 420 | $gooAmount = $silo->attributes()->quantity; |
||
| 421 | $gooVolume = 1; |
||
| 422 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 423 | $cleanNumber = number_format($gooCurrent); |
||
| 424 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 425 | if ($gooCurrent == $towerFull) { |
||
| 426 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 427 | } |
||
| 428 | $msg .= "**System: **{$systemName}\n"; |
||
| 429 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 430 | $this->logger->addInfo("{$typeName} Silo nearing capacity in {$systemName}"); |
||
| 431 | // Send the msg to the channel; |
||
| 432 | $channelID = $this->toDiscordChannel; |
||
| 433 | $guild = $discord->guilds->get('id', $this->guild); |
||
| 434 | $channel = $guild->channels->get('id', $channelID); |
||
| 435 | $channel->sendMessage($msg, false); |
||
| 436 | $siloCount++; |
||
| 437 | sleep(1); |
||
| 438 | } |
||
| 439 | break; |
||
| 440 | View Code Duplication | case 16639: |
|
| 441 | $typeName = dbQueryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => 16639), "ccp"); |
||
| 442 | $systemName = dbQueryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $structures->attributes()->locationID), "ccp"); |
||
| 443 | $towerWarn = 45000 + (45000 * $towerMulti); |
||
| 444 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 445 | $gooAmount = $silo->attributes()->quantity; |
||
| 446 | $gooVolume = 0.4; |
||
| 447 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 448 | $cleanNumber = number_format($gooCurrent); |
||
| 449 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 450 | if ($gooCurrent == $towerFull) { |
||
| 451 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 452 | } |
||
| 453 | $msg .= "**System: **{$systemName}\n"; |
||
| 454 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 455 | $this->logger->addInfo("{$typeName} Silo nearing capacity in {$systemName}"); |
||
| 456 | // Send the msg to the channel; |
||
| 457 | $channelID = $this->toDiscordChannel; |
||
| 458 | $guild = $discord->guilds->get('id', $this->guild); |
||
| 459 | $channel = $guild->channels->get('id', $channelID); |
||
| 460 | $channel->sendMessage($msg, false); |
||
| 461 | $siloCount++; |
||
| 462 | sleep(1); |
||
| 463 | } |
||
| 464 | break; |
||
| 465 | View Code Duplication | case 16636: |
|
| 466 | $typeName = dbQueryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => 16636), "ccp"); |
||
| 467 | $systemName = dbQueryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $structures->attributes()->locationID), "ccp"); |
||
| 468 | $towerWarn = 180000 + (180000 * $towerMulti); |
||
| 469 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 470 | $gooAmount = $silo->attributes()->quantity; |
||
| 471 | $gooVolume = 0.1; |
||
| 472 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 473 | $cleanNumber = number_format($gooCurrent); |
||
| 474 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 475 | if ($gooCurrent == $towerFull) { |
||
| 476 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 477 | } |
||
| 478 | $msg .= "**System: **{$systemName}\n"; |
||
| 479 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 480 | $this->logger->addInfo("{$typeName} Silo nearing capacity in {$systemName}"); |
||
| 481 | // Send the msg to the channel; |
||
| 482 | $channelID = $this->toDiscordChannel; |
||
| 483 | $guild = $discord->guilds->get('id', $this->guild); |
||
| 484 | $channel = $guild->channels->get('id', $channelID); |
||
| 485 | $channel->sendMessage($msg, false); |
||
| 486 | $siloCount++; |
||
| 487 | sleep(1); |
||
| 488 | } |
||
| 489 | break; |
||
| 490 | View Code Duplication | case 16649: |
|
| 491 | $typeName = dbQueryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => 16649), "ccp"); |
||
| 492 | $systemName = dbQueryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $structures->attributes()->locationID), "ccp"); |
||
| 493 | $towerWarn = 18000 + (18000 * $towerMulti); |
||
| 494 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 495 | $gooAmount = $silo->attributes()->quantity; |
||
| 496 | $gooVolume = 1; |
||
| 497 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 498 | $cleanNumber = number_format($gooCurrent); |
||
| 499 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 500 | if ($gooCurrent == $towerFull) { |
||
| 501 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 502 | } |
||
| 503 | $msg .= "**System: **{$systemName}\n"; |
||
| 504 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 505 | $this->logger->addInfo("{$typeName} Silo nearing capacity in {$systemName}"); |
||
| 506 | // Send the msg to the channel; |
||
| 507 | $channelID = $this->toDiscordChannel; |
||
| 508 | $guild = $discord->guilds->get('id', $this->guild); |
||
| 509 | $channel = $guild->channels->get('id', $channelID); |
||
| 510 | $channel->sendMessage($msg, false); |
||
| 511 | $siloCount++; |
||
| 512 | sleep(1); |
||
| 513 | } |
||
| 514 | break; |
||
| 515 | View Code Duplication | case 16653: |
|
| 516 | $typeName = dbQueryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => 16653), "ccp"); |
||
| 517 | $systemName = dbQueryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $structures->attributes()->locationID), "ccp"); |
||
| 518 | $towerWarn = 18000 + (18000 * $towerMulti); |
||
| 519 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 520 | $gooAmount = $silo->attributes()->quantity; |
||
| 521 | $gooVolume = 1; |
||
| 522 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 523 | $cleanNumber = number_format($gooCurrent); |
||
| 524 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 525 | if ($gooCurrent == $towerFull) { |
||
| 526 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 527 | } |
||
| 528 | $msg .= "**System: **{$systemName}\n"; |
||
| 529 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 530 | $this->logger->addInfo("{$typeName} Silo nearing capacity in {$systemName}"); |
||
| 531 | // Send the msg to the channel; |
||
| 532 | $channelID = $this->toDiscordChannel; |
||
| 533 | $guild = $discord->guilds->get('id', $this->guild); |
||
| 534 | $channel = $guild->channels->get('id', $channelID); |
||
| 535 | $channel->sendMessage($msg, false); |
||
| 536 | $siloCount++; |
||
| 537 | sleep(1); |
||
| 538 | } |
||
| 539 | break; |
||
| 540 | View Code Duplication | case 16638: |
|
| 541 | $typeName = dbQueryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => 16638), "ccp"); |
||
| 542 | $systemName = dbQueryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $structures->attributes()->locationID), "ccp"); |
||
| 543 | $towerWarn = 45000 + (45000 * $towerMulti); |
||
| 544 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 545 | $gooAmount = $silo->attributes()->quantity; |
||
| 546 | $gooVolume = 0.4; |
||
| 547 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 548 | $cleanNumber = number_format($gooCurrent); |
||
| 549 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 550 | if ($gooCurrent == $towerFull) { |
||
| 551 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 552 | } |
||
| 553 | $msg .= "**System: **{$systemName}\n"; |
||
| 554 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 555 | $this->logger->addInfo("{$typeName} Silo nearing capacity in {$systemName}"); |
||
| 556 | // Send the msg to the channel; |
||
| 557 | $channelID = $this->toDiscordChannel; |
||
| 558 | $guild = $discord->guilds->get('id', $this->guild); |
||
| 559 | $channel = $guild->channels->get('id', $channelID); |
||
| 560 | $channel->sendMessage($msg, false); |
||
| 561 | $siloCount++; |
||
| 562 | sleep(1); |
||
| 563 | } |
||
| 564 | break; |
||
| 565 | View Code Duplication | case 16637: |
|
| 566 | $typeName = dbQueryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => 16637), "ccp"); |
||
| 567 | $systemName = dbQueryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $structures->attributes()->locationID), "ccp"); |
||
| 568 | $towerWarn = 45000 + (45000 * $towerMulti); |
||
| 569 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 570 | $gooAmount = $silo->attributes()->quantity; |
||
| 571 | $gooVolume = 0.4; |
||
| 572 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 573 | $cleanNumber = number_format($gooCurrent); |
||
| 574 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 575 | if ($gooCurrent == $towerFull) { |
||
| 576 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 577 | } |
||
| 578 | $msg .= "**System: **{$systemName}\n"; |
||
| 579 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 580 | $this->logger->addInfo("{$typeName} Silo nearing capacity in {$systemName}"); |
||
| 581 | // Send the msg to the channel; |
||
| 582 | $channelID = $this->toDiscordChannel; |
||
| 583 | $guild = $discord->guilds->get('id', $this->guild); |
||
| 584 | $channel = $guild->channels->get('id', $channelID); |
||
| 585 | $channel->sendMessage($msg, false); |
||
| 586 | $siloCount++; |
||
| 587 | sleep(1); |
||
| 588 | } |
||
| 589 | break; |
||
| 590 | View Code Duplication | case 16642: |
|
| 591 | $typeName = dbQueryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => 16642), "ccp"); |
||
| 592 | $systemName = dbQueryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $structures->attributes()->locationID), "ccp"); |
||
| 593 | $towerWarn = 18000 + (18000 * $towerMulti); |
||
| 594 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 595 | $gooAmount = $silo->attributes()->quantity; |
||
| 596 | $gooVolume = 1; |
||
| 597 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 598 | $cleanNumber = number_format($gooCurrent); |
||
| 599 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 600 | if ($gooCurrent == $towerFull) { |
||
| 601 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 602 | } |
||
| 603 | $msg .= "**System: **{$systemName}\n"; |
||
| 604 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 605 | $this->logger->addInfo("{$typeName} Silo nearing capacity in {$systemName}"); |
||
| 606 | // Send the msg to the channel; |
||
| 607 | $channelID = $this->toDiscordChannel; |
||
| 608 | $guild = $discord->guilds->get('id', $this->guild); |
||
| 609 | $channel = $guild->channels->get('id', $channelID); |
||
| 610 | $channel->sendMessage($msg, false); |
||
| 611 | $siloCount++; |
||
| 612 | sleep(1); |
||
| 613 | } |
||
| 614 | break; |
||
| 615 | } |
||
| 616 | } |
||
| 617 | } |
||
| 618 | } |
||
| 619 | } |
||
| 620 | $cached = $xml->cachedUntil[0]; |
||
| 621 | $baseUnix = strtotime($cached); |
||
| 622 | $cacheClr = $baseUnix - 13500; |
||
| 623 | View Code Duplication | if ($cacheClr <= time()) { |
|
| 624 | $weirdTime = time() + 21700; |
||
| 625 | $cacheTimer = gmdate("Y-m-d H:i:s", $weirdTime); |
||
| 626 | setPermCache("siloLastChecked{$keyID}", $weirdTime); |
||
| 627 | } else { |
||
| 628 | $cacheTimer = gmdate("Y-m-d H:i:s", $cacheClr); |
||
| 629 | setPermCache("siloLastChecked{$keyID}", $cacheClr); |
||
| 630 | } |
||
| 631 | |||
| 632 | View Code Duplication | if ($siloCount > 0) { |
|
| 633 | $msg = "Next Silo Check At: {$cacheTimer} EVE Time"; |
||
| 634 | // Send the msg to the channel; |
||
| 635 | $channelID = $this->toDiscordChannel; |
||
| 636 | $guild = $discord->guilds->get('id', $this->guild); |
||
| 637 | $channel = $guild->channels->get('id', $channelID); |
||
| 638 | $channel->sendMessage($msg, false); |
||
| 639 | } |
||
| 640 | $this->logger->addInfo("Silo Check Complete Next Check At {$cacheTimer}"); |
||
| 641 | return null; |
||
| 642 | |||
| 643 | /** |
||
| 644 | * @return array |
||
| 645 | */ |
||
| 646 | function information() |
||
| 654 | } |
||
| 655 | } |
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.