X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=inc%2Fclasses%2Fthird_party%2Fapi%2Fwernisportal%2Fclass_WernisApi.php;h=9e863a6afe62499501f207794373c748bd215e57;hp=5600032c28de1f12d4b37f64be6cacf9c96da3e3;hb=89f25725096fa51850e2d4d0a2ed57906c0b23e0;hpb=f5cf5211620c1813c76d8231819b63a585fb2689 diff --git a/inc/classes/third_party/api/wernisportal/class_WernisApi.php b/inc/classes/third_party/api/wernisportal/class_WernisApi.php index 5600032c..9e863a6a 100644 --- a/inc/classes/third_party/api/wernisportal/class_WernisApi.php +++ b/inc/classes/third_party/api/wernisportal/class_WernisApi.php @@ -7,6 +7,7 @@ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org + * @todo Out-dated since 0.6-BETA * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -116,7 +117,7 @@ class WernisApi extends BaseFrameworkSystem { $amount = isset($amount) ? $amount+0 : 0; if ($amount < $this->config['mineinsatz']) { - $this->setStatusMessage('low_stakes', sprintf("Dein Einsatz muss mindestens %d Wernis betragen.", $this->config['mineinsatz'])); + $this->setStatusMessage('low_stakes', sprintf('Dein Einsatz muss mindestens %d Wernis betragen.', $this->config['mineinsatz'])); return false; } @@ -129,7 +130,7 @@ class WernisApi extends BaseFrameworkSystem { $amount = isset($amount) ? $amount+0 : 0; if ($amount < $this->config['mineinsatz']) { - $this->setStatusMessage('low_stakes', sprintf("Dein Einsatz muss mindestens %d Wernis betragen.", $this->config['mineinsatz'])); + $this->setStatusMessage('low_stakes', sprintf('Dein Einsatz muss mindestens %d Wernis betragen.', $this->config['mineinsatz'])); return false; } @@ -140,8 +141,8 @@ class WernisApi extends BaseFrameworkSystem { // Script abbrechen mit Zurueck-Buttom public function ende () { global $_CONFIG; - include "templates/zurueck.html"; - include "templates/fuss.html"; + include 'templates/zurueck.html'; + include 'templates/fuss.html'; exit(); } @@ -164,7 +165,7 @@ class WernisApi extends BaseFrameworkSystem { return $this->statusArray['message']; } else { // Fall-back to status - return sprintf("Fehler-Code %s ist keiner Nachricht zugewiesen.", $this->getErrorCode()); + return sprintf('Fehler-Code %s ist keiner Nachricht zugewiesen.', $this->getErrorCode()); } } @@ -185,8 +186,8 @@ class WernisApi extends BaseFrameworkSystem { if (!is_array($requestData)) { // Then abort here! return array( - 'status' => "failed_general", - 'message' => "API-Daten in config sind ungültig!" + 'status' => 'failed_general', + 'message' => 'API-Daten in config sind ungültig!' ); } @@ -194,13 +195,13 @@ class WernisApi extends BaseFrameworkSystem { if ((empty($this->config['wernis_api_id'])) || (empty($this->config['wernis_api_key']))) { // Abort here... return array( - 'status' => "failed_general", - 'message' => "API-Daten in config.php sind leer!" + 'status' => 'failed_general', + 'message' => 'API-Daten in config.php sind leer!' ); } // Construct the request string - $requestString = $this->config['api_url'] . $scriptName."?api_id=".$this->config['wernis_api_id']."&api_key=".$this->config['wernis_api_key']; + $requestString = $this->config['api_url'] . $scriptName . '?api_id=' . $this->config['wernis_api_id'] . '&api_key='.$this->config['wernis_api_key']; foreach ($requestData as $key => $value) { $requestString .= '&' . $key . '=' . $value; } @@ -212,8 +213,8 @@ class WernisApi extends BaseFrameworkSystem { if (strpos($response[0], '200') === FALSE) { // Something bad happend... :( return array( - 'status' => "request_error", - 'message' => sprintf("Servermeldung %s von WDS66-API erhalten.", $response[0]) + 'status' => 'request_error', + 'message' => sprintf('Servermeldung %s von WDS66-API erhalten.', $response[0]) ); } @@ -239,51 +240,51 @@ class WernisApi extends BaseFrameworkSystem { $return = array(); // We use only the first two entries (which shall be fine) - if ($data[0] === "error") { + if ($data[0] === 'error') { // The request has failed... :( switch ($data[1]) { - case "404": // Invalid API ID - case "AUTH": // Authorization has failed + case '404': // Invalid API ID + case 'AUTH': // Authorization has failed $return = array( - 'status' => "auth_failed", - 'message' => "API-Daten scheinen nicht zu stimmen! (Access Denied)" + 'status' => 'auth_failed', + 'message' => 'API-Daten scheinen nicht zu stimmen! (Access Denied)' ); break; - case "LOCKED": // User account is locked! - case "PASS": // Bad passphrase entered - case "USER": // Missing account or invalid password + case 'LOCKED': // User account is locked! + case 'PASS': // Bad passphrase entered + case 'USER': // Missing account or invalid password $return = array( - 'status' => "user_failed", - 'message' => "Dein eingegebener WDS66-Username stimmt nicht, ist gesperrt oder du hast ein falsches Passwort eingegeben." + 'status' => 'user_failed', + 'message' => 'Dein eingegebener WDS66-Username stimmt nicht, ist gesperrt oder du hast ein falsches Passwort eingegeben.' ); break; - case "OWN": // Transfer to own account + case 'OWN': // Transfer to own account $return = array( - 'status' => "own_failed", - 'message' => "Du darfst dein eigenes Spiel leider nicht spielen." + 'status' => 'own_failed', + 'message' => 'Du darfst dein eigenes Spiel leider nicht spielen.' ); break; - case "AMOUNT": // Amount is depleted + case 'AMOUNT': // Amount is depleted $return = array( - 'status' => "amount_failed", - 'message' => "Dein Guthaben reicht nicht aus, um das Spiel zu spielen." + 'status' => 'amount_failed', + 'message' => 'Dein Guthaben reicht nicht aus, um das Spiel zu spielen.' ); break; - case "AMOUNT-SEND": // API amount is depleted + case 'AMOUNT-SEND': // API amount is depleted $return = array( - 'status' => "api_amount_failed", - 'message' => "Nicht genügend Guthaben auf dem API-Account." + 'status' => 'api_amount_failed', + 'message' => 'Nicht genügend Guthaben auf dem API-Account.' ); break; default: // Unknown error (maybe new?) $return = array( - 'status' => "request_failed", - 'message' => sprintf("Unbekannter Fehler %s von API erhalten.", $data[1]) + 'status' => 'request_failed', + 'message' => sprintf('Unbekannter Fehler %s von API erhalten.', $data[1]) ); break; } @@ -312,13 +313,13 @@ class WernisApi extends BaseFrameworkSystem { 'sub_request' => 'receive', 't_uid' => $this->w_id, 't_md5' => $this->w_md5, - 'r_uid' => (int)$this->config['wernis_refid'], - 'amount' => (int)$amount, + 'r_uid' => (int) $this->config['wernis_refid'], + 'amount' => (int) $amount, 'purpose' => urlencode(base64_encode($purpose)) ); // Return the result from the lower functions - $return = $this->sendRequest("book.php", $requestData); + $return = $this->sendRequest('book.php', $requestData); if ($return['status'] == $this->statusOkay) { // All fine! @@ -345,8 +346,8 @@ class WernisApi extends BaseFrameworkSystem { 'sub_request' => 'send', 't_uid' => $this->w_id, 't_md5' => $this->w_md5, - 'r_uid' => (int)$this->config['wernis_refid'], - 'amount' => (int)$amount, + 'r_uid' => (int) $this->config['wernis_refid'], + 'amount' => (int) $amount, 'purpose' => urlencode(base64_encode($purpose)) ); @@ -375,7 +376,7 @@ class WernisApi extends BaseFrameworkSystem { $url = $extract[0]; // Extract host name - $host = str_replace("http://", '', $url); + $host = str_replace('http://', '', $url); if (ereg('/', $host)) $host = substr($host, 0, strpos($host, '/')); // Generate relative URL @@ -390,8 +391,8 @@ class WernisApi extends BaseFrameworkSystem { } // Generate request header - $request = "GET /".trim($script)." HTTP/1.0\r\n"; - $request .= "Host: ".$host."\r\n"; + $request = "GET /" . trim($script) . " HTTP/1.0\r\n"; + $request .= "Host: " . $host . "\r\n"; $request .= sprintf("User-Agent: WernisApi/1.0 by Quix0r [Spieler: %d]\r\n\r\n", $this->w_id); // Initialize array