shibdib /
Dramiel
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 | /** |
||
| 27 | * @param $url |
||
| 28 | * |
||
| 29 | * @return SimpleXMLElement|null |
||
| 30 | */ |
||
| 31 | function makeApiRequest($url) |
||
| 32 | { |
||
| 33 | try { |
||
| 34 | // Initialize a new request for this URL |
||
| 35 | $ch = curl_init($url); |
||
| 36 | // Set the options for this request |
||
| 37 | curl_setopt_array($ch, [ |
||
| 38 | CURLOPT_FOLLOWLOCATION => true, // Yes, we want to follow a redirect |
||
| 39 | CURLOPT_RETURNTRANSFER => true, // Yes, we want that curl_exec returns the fetched data |
||
| 40 | CURLOPT_SSL_VERIFYPEER => false, // Do not verify the SSL certificate |
||
| 41 | CURLOPT_TIMEOUT => 15, |
||
| 42 | ]); |
||
| 43 | // Fetch the data from the URL |
||
| 44 | $data = curl_exec($ch); |
||
| 45 | // Close the connection |
||
| 46 | curl_close($ch); |
||
| 47 | // Return a new SimpleXMLElement based upon the received data |
||
| 48 | return new SimpleXMLElement($data); |
||
| 49 | } catch (Exception $e) { |
||
| 50 | var_dump('EVE API Error: '.$e->getMessage()); |
||
| 51 | |||
| 52 | return; |
||
| 53 | } |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @return mixed|null |
||
| 58 | */ |
||
| 59 | function serverStatus() |
||
| 60 | { |
||
| 61 | try { |
||
| 62 | // Initialize a new request for this URL |
||
| 63 | $ch = curl_init('https://api.eveonline.com/server/ServerStatus.xml.aspx'); |
||
| 64 | // Set the options for this request |
||
| 65 | curl_setopt_array($ch, [ |
||
| 66 | CURLOPT_FOLLOWLOCATION => true, // Yes, we want to follow a redirect |
||
| 67 | CURLOPT_RETURNTRANSFER => true, // Yes, we want that curl_exec returns the fetched data |
||
| 68 | CURLOPT_TIMEOUT => 8, |
||
| 69 | CURLOPT_SSL_VERIFYPEER => false, // Do not verify the SSL certificate |
||
| 70 | ]); |
||
| 71 | // Fetch the data from the URL |
||
| 72 | $data = curl_exec($ch); |
||
| 73 | // Close the connection |
||
| 74 | curl_close($ch); |
||
| 75 | |||
| 76 | $true = 'true'; |
||
| 77 | //If server is down return false |
||
| 78 | if ($data->serverOpen != 'True') { |
||
| 79 | return false; |
||
| 80 | } |
||
| 81 | //If server is up return true |
||
| 82 | return $true; |
||
| 83 | } catch (Exception $e) { |
||
| 84 | var_dump('EVE API Error: '.$e->getMessage()); |
||
|
0 ignored issues
–
show
Security
Debugging Code
introduced
by
Loading history...
|
|||
| 85 | |||
| 86 | return; |
||
| 87 | } |
||
| 88 | } |
||
| 89 |