]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/primera_functions.php
Rewritten to use str_replace() instead of preg_replace()
[mailer.git] / inc / libs / primera_functions.php
index e1c6fc57e2eeb79877818085ed43e6f41f5f4163..0ca43bcfecf08d0937f1c4b793186238612b8f4b 100644 (file)
@@ -105,25 +105,25 @@ class PrimeraApi {
        /**
         * URL für das Interface auf dem Primusserver:
         */
-       private $host = "http://www.primusportal.de";
-       private $path = "/transfer.interface.2.0.php";
+       var $host = "http://www.primusportal.de";
+       var $path = "/transfer.interface.2.0.php";
 
-       private $errno = 0;
-       private $err = "";
+       var $errno = 0;
+       var $err = "";
 
-       private $seperator = ":";
+       var $seperator = ":";
 
-       private $username = "";
-       private $password = "";
+       var $username = "";
+       var $password = "";
 
-       private $data = array();
+       var $data = array();
 
-       private $headers = "";
+       var $headers = "";
 
        /**
         * Konstruktor
         */
-       public function PrimeraApi ($PPUsername, $PPPassword) {
+       function PrimeraApi ($PPUsername, $PPPassword) {
                // Set data
                $this->username = $PPUsername;
                $this->password = $PPPassword;
@@ -132,7 +132,7 @@ class PrimeraApi {
        /**
         * Anfrage senden und Rückgabecode in Variable speichern
         */
-       private function queryApi ( $data = array() ) {
+       function queryApi ( $data = array() ) {
                // Base64-encode username and password hash
                $data["PrimusInterface_Username"] = base64_encode($this->username);
                $data["PrimusInterface_Password"] = base64_encode($this->password);
@@ -173,7 +173,7 @@ class PrimeraApi {
         * @param int $Amount Betrag in ganzzahligen Primera
         * @param string $Description Beschreibung (Sichtbar in Einzelauflistung)
         */
-       public function payPrimera ($Receiver, $Amount, $Description = "") {
+       function payPrimera ($Receiver, $Amount, $Description = "") {
                $valid = false;
                $postData = array("PrimusInterface_Action" => "Pay",
                        "PrimusInterface_Receiver" => base64_encode($Receiver),
@@ -195,7 +195,7 @@ class PrimeraApi {
         * - ist er aktiv
         * @param string/int $User Userid / Username
         */
-       public function CheckPrimusUser($User) {
+       function CheckPrimusUser($User) {
                $valid = false;
                $postData = array("PrimusInterface_Action"=> "CheckPrimusUser",
                        "PrimusInterface_CheckPrimusUser" => $User);
@@ -213,7 +213,7 @@ class PrimeraApi {
        /**
         * Die Funktion liefer den aktuellen Primerastand
         */
-       public function getPrimera() {
+       function getPrimera() {
                $primera = false;
                $postData = array( "PrimusInterface_Action" => "GetPrimera" );
                $postReturn = $this->parseContent( $this->queryApi($postData) );
@@ -227,7 +227,7 @@ class PrimeraApi {
        /**
         * Getter fuer data
         */
-       public function getData () {
+       function getData () {
                return $this->data;
        }
 }
@@ -236,15 +236,13 @@ class PrimeraApi {
 // is not false the API data is valid, else invalid
 function PRIMERA_TEST_API () {
        // Get new instance
-       $api = new PrimeraApi($_POST['primera_api_name'], $_POST['primera_api_md5']);
+       $api = new PrimeraApi(REQUEST_POST('primera_api_name'), REQUEST_POST('primera_api_md5'));
 
        // Was that fine?
        return ($api->getPrimera() !== false);
 }
 // Execute the withdraw of a sponsor only!
 function PRIMERA_EXECUTE_WITHDRAW ($primusNick, $userMd5, $amount) {
-       global $_CONFIG;
-
        // Is the sponsor extension installed?
        if (!EXT_IS_ACTIVE("sponsor")) {
                // No, abort here
@@ -258,7 +256,7 @@ function PRIMERA_EXECUTE_WITHDRAW ($primusNick, $userMd5, $amount) {
        $api = new PrimeraApi($primusNick, $userMd5);
 
        // Prepare purpose
-       $eval = "\$purpose = \"".COMPILE_CODE(sprintf(PRIMERA_API_PURPOSE_WITHDRAW, $_COOKIE['sponsorid']))."\";";
+       $eval = "\$purpose = \"".COMPILE_CODE(sprintf(getMessage('PRIMERA_API_PURPOSE_WITHDRAW'), get_session('sponsorid')))."\";";
        eval($eval);
 
        // Pay the Primera
@@ -266,13 +264,11 @@ function PRIMERA_EXECUTE_WITHDRAW ($primusNick, $userMd5, $amount) {
 }
 // Execute the payout
 function PRIMERA_EXECUTE_PAYOUT ($primusNick, $userMd5, $amount) {
-       global $_CONFIG;
-
        // Get new instance
-       $api = new PrimeraApi($_CONFIG['primera_api_name'], $_CONFIG['primera_api_md5']);
+       $api = new PrimeraApi(getConfig('primera_api_name'), getConfig('primera_api_md5'));
 
        // Prepare purpose
-       $eval = "\$purpose = \"".COMPILE_CODE(sprintf(PRIMERA_API_PURPOSE_PAYOUT, $GLOBALS['userid']))."\";";
+       $eval = "\$purpose = \"".COMPILE_CODE(sprintf(getMessage('PRIMERA_API_PURPOSE_PAYOUT'), getUserId()))."\";";
        eval($eval);
 
        // Pay the Primera