X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Flibs%2Fprimera_functions.php;h=baf88c8796b5bf106a82eef3da02119d7e957a9e;hp=0ca43bcfecf08d0937f1c4b793186238612b8f4b;hb=0715fa7aa8e5e70bcf1d957fb09ae655c3896c4e;hpb=452578b5bf17d14099ee44956deb4e4dc0832874 diff --git a/inc/libs/primera_functions.php b/inc/libs/primera_functions.php index 0ca43bcfec..baf88c8796 100644 --- a/inc/libs/primera_functions.php +++ b/inc/libs/primera_functions.php @@ -3,7 +3,7 @@ * PrimeraApi * ------------------------------------------- * Mit dieser Klasse ist ein einfacher Primeratransfer von Ihrem Account - * zu dem Account eines bei Primusportal.de registrierten Mitglieds möglich. + * zu dem Account eines bei Primusportal.de registrierten Mitglieds m�glich. * *------------------ Aenderungen durch Roland Haeder 09.08.2008 ---------------- * Klasse umbenannt nach PrimeraApi, damit sie in das Framework besser passt. @@ -14,7 +14,7 @@ * die Methoden Pay,Query und Parse umbenannt. *------------------ Aenderungen durch Roland Haeder 09.08.2008 ---------------- * - * Die Einbindung des Interfaces geschieht folgendermaßen: + * Die Einbindung des Interfaces geschieht folgenderma�en: * 1. Einbindung der Klasse in Ihr PHP-Auszahlungsskript: * CODE: * require_once( "PFAD/ZU/DER/KLASSE/PrimeraApi.class.php" ); @@ -22,31 +22,31 @@ * $PPPassword = "passwort"; // Ihr Passwort bei Primusportal * * $Interface = new PrimeraApi($PPUsername, $PPPassword); - * 2. Durchführen einer Auszahlung: + * 2. Durchf�hren einer Auszahlung: * CODE: * $Status = $Interface->payPrimera($PayReceiver, $PayAmount, $PayDescription); * - * Wobei $PayReicer der Username des Empfängers bei + * Wobei $PayReicer der Username des Empf�ngers bei * Primusportal.de ist. $PayAmount ist der gerundete( !! ) Betrag an Primera, - * die der Empfänger erhalten soll. $PayDescription ist eine von Ihnen - * festgelegte kurze Beschreibung. Die Länge dieses Textes darf 100 Zeichen - * nicht überschreiten. Beispiel: - * $status = $Interface->payPrimera("garbage", 10000, "Auszahlung IhreSeite.de - ID: 12345"); - * 3. Überprüfung des Status (Rückgabecode): + * die der Empf�nger erhalten soll. $PayDescription ist eine von Ihnen + * festgelegte kurze Beschreibung. Die L�nge dieses Textes darf 100 Zeichen + * nicht �berschreiten. Beispiel: + * $status = $Interface->payPrimera("garbage", 10000, "Auszahlung IhreSeite.de - id: 12345"); + * 3. �berpr�fung des Status (R�ckgabecode): * CODE: * if (!$status) { * // Ein Fehler ist aufgetreten - * // Fehlerbehandlung hier einfügen... + * // Fehlerbehandlung hier einf�gen... * }else { - * // Auszahlung erfolgreich durchgeführt - * // Führen Sie hier Ihre Datenbankabfragen durch, um die Auszahlung zu - * // bestätigen... + * // Auszahlung erfolgreich durchgef�hrt + * // F�hren Sie hier Ihre Datenbankabfragen durch, um die Auszahlung zu + * // best�tigen... * } * - * Die komplette Rückgabe des Interfaces wird als assoziatives Array in der Klassen- + * Die komplette R�ckgabe des Interfaces wird als assoziatives Array in der Klassen- * variable __data gespeichert: - * __data => array("status" => Rückgabecode (PI_DONE, PI_SENDER_ERROR, ...), - * "statustext" => Status in Worten (z.B.: "Transaktion erfolgreich durchgeführt"), + * __data => array('status' => R�ckgabecode (PI_DONE, PI_SENDER_ERROR, ...), + * "statustext" => Status in Worten (z.B.: "Transaktion erfolgreich durchgef�hrt"), * ") * * @@ -55,6 +55,7 @@ * @version 1.0 - beta * @copyright (c) 2007 by Primusportal.de * @copyright (c) 2008 by Roland Haeder + * @copyright 2009, 2010 by Mailer Developer Team */ class PrimeraApi { /** @@ -63,7 +64,7 @@ class PrimeraApi { const PI_ERROR = -1; /** - * Statuscode für erfolgreich ausgeführte Transaktion + * Statuscode f�r erfolgreich ausgef�hrte Transaktion */ const PI_DONE = 200; @@ -103,22 +104,22 @@ class PrimeraApi { const PI_GET_PRIMERA_DONE = 701; /** - * URL für das Interface auf dem Primusserver: + * URL f�r das Interface auf dem Primusserver: */ var $host = "http://www.primusportal.de"; var $path = "/transfer.interface.2.0.php"; - var $errno = 0; - var $err = ""; + var $errno = '0'; + var $err = ''; - var $seperator = ":"; + var $seperator = ':'; - var $username = ""; - var $password = ""; + var $username = ''; + var $password = ''; var $data = array(); - var $headers = ""; + var $headers = ''; /** * Konstruktor @@ -130,21 +131,21 @@ class PrimeraApi { } /** - * Anfrage senden und Rückgabecode in Variable speichern + * Anfrage senden und R�ckgabecode in Variable speichern */ function queryApi ( $data = array() ) { // Base64-encode username and password hash - $data["PrimusInterface_Username"] = base64_encode($this->username); - $data["PrimusInterface_Password"] = base64_encode($this->password); + $data['PrimusInterface_Username'] = base64_encode($this->username); + $data['PrimusInterface_Password'] = base64_encode($this->password); // Send POST request - $return = POST_URL($this->host.$this->path, $data); + $return = sendPostRequest($this->host.$this->path, $data); // Convert the array into a full string $returnStr = implode("\n", $return); // Extract the real content, strip header away - $content = explode("", $returnStr); + $content = explode('', $returnStr); // Store headers away for debugging $this->headers = $content[0]; @@ -154,13 +155,13 @@ class PrimeraApi { } /** - * Funktion parst die Rückgabe vom Transferskript: + * Funktion parst die R�ckgabe vom Transferskript: */ function parseContent ( $content ) { $x = explode("\n", $content); $return = array(); foreach($x as $currentLine) { - $line_exploded = explode(":", $currentLine,2); + $line_exploded = explode(':', $currentLine,2); if (count($line_exploded) > 1) { $return[$line_exploded[0]] = $line_exploded[1]; } @@ -169,42 +170,42 @@ class PrimeraApi { } /** - * @param int/string $Receiver UserID / Username des Empfängers + * @param int/string $Receiver UserID / Username des Empf�ngers * @param int $Amount Betrag in ganzzahligen Primera * @param string $Description Beschreibung (Sichtbar in Einzelauflistung) */ - function payPrimera ($Receiver, $Amount, $Description = "") { + function payPrimera ($Receiver, $Amount, $Description = '') { $valid = false; - $postData = array("PrimusInterface_Action" => "Pay", - "PrimusInterface_Receiver" => base64_encode($Receiver), - "PrimusInterface_Amount" => base64_encode($Amount), - "PrimusInterface_Description" => base64_encode($Description) ); + $postData = array('PrimusInterface_Action' => 'Pay', + 'PrimusInterface_Receiver' => base64_encode($Receiver), + 'PrimusInterface_Amount' => base64_encode($Amount), + 'PrimusInterface_Description' => base64_encode($Description) ); $postReturn = $this->parseContent( $this->queryApi($postData) ); $this->data = $postReturn; - if ($postReturn["status"] == "200") { + if ($postReturn['status'] == '200') { $valid = true; } return $valid; } /** - * Überprüft den Status eines Primus-Users + * �berpr�ft den Status eines Primus-Users * - existiert der User * - ist er aktiv * @param string/int $User Userid / Username */ function CheckPrimusUser($User) { $valid = false; - $postData = array("PrimusInterface_Action"=> "CheckPrimusUser", - "PrimusInterface_CheckPrimusUser" => $User); + $postData = array('PrimusInterface_Action'=> 'CheckPrimusUser', + 'PrimusInterface_CheckPrimusUser' => $User); $postReturn = $this->parseContent( $this->queryApi($postData) ); $this->data = $postReturn; - if ($postReturn["status"] == self::PI_USER_CHECK_OK) { + if ($postReturn['status'] == self::PI_USER_CHECK_OK) { $valid = true; } return $valid; @@ -215,12 +216,12 @@ class PrimeraApi { */ function getPrimera() { $primera = false; - $postData = array( "PrimusInterface_Action" => "GetPrimera" ); + $postData = array( 'PrimusInterface_Action' => 'GetPrimera' ); $postReturn = $this->parseContent( $this->queryApi($postData) ); $this->data = $postReturn; - if ($postReturn["status"] == self::PI_GET_PRIMERA_DONE) { - $primera = $postReturn["primera"]; + if ($postReturn['status'] == self::PI_GET_PRIMERA_DONE) { + $primera = $postReturn['primera']; } return $primera; } @@ -234,20 +235,21 @@ class PrimeraApi { // Function to test the Primera API by getting the amount. If the returned value // is not false the API data is valid, else invalid -function PRIMERA_TEST_API () { +function testPrimeraApi () { // Get new instance - $api = new PrimeraApi(REQUEST_POST('primera_api_name'), REQUEST_POST('primera_api_md5')); + $api = new PrimeraApi(postRequestParameter('primera_api_name'), postRequestParameter('primera_api_md5')); // Was that fine? return ($api->getPrimera() !== false); } + // Execute the withdraw of a sponsor only! -function PRIMERA_EXECUTE_WITHDRAW ($primusNick, $userMd5, $amount) { +function executePrimeraWithdraw ($primusNick, $userMd5, $amount) { // Is the sponsor extension installed? - if (!EXT_IS_ACTIVE("sponsor")) { + if (!isExtensionActive('sponsor')) { // No, abort here return false; - } elseif (!IS_SPONSOR()) { + } elseif (!isSponsor()) { // No sponsor, not allowed to withdraw! return false; } @@ -256,23 +258,23 @@ function PRIMERA_EXECUTE_WITHDRAW ($primusNick, $userMd5, $amount) { $api = new PrimeraApi($primusNick, $userMd5); // Prepare purpose - $eval = "\$purpose = \"".COMPILE_CODE(sprintf(getMessage('PRIMERA_API_PURPOSE_WITHDRAW'), get_session('sponsorid')))."\";"; - eval($eval); + eval('$purpose = "' . preCompileCode(getMaskedMessage('PRIMERA_API_PURPOSE_WITHDRAW', getSession('sponsorid'))) . '";'); // Pay the Primera return $api->payPrimera($primusNick, $amount, $purpose); } + // Execute the payout -function PRIMERA_EXECUTE_PAYOUT ($primusNick, $userMd5, $amount) { +function executePrimeraPayout ($primusNick, $userMd5, $amount) { // Get new instance $api = new PrimeraApi(getConfig('primera_api_name'), getConfig('primera_api_md5')); // Prepare purpose - $eval = "\$purpose = \"".COMPILE_CODE(sprintf(getMessage('PRIMERA_API_PURPOSE_PAYOUT'), getUserId()))."\";"; - eval($eval); + eval('$purpose = "' . preCompileCode(getMaskedMessage('PRIMERA_API_PURPOSE_PAYOUT', getMemberId())) . '";'); // Pay the Primera return $api->payPrimera($primusNick, $amount, $purpose); } + // [EOF] ?>