From 0dd96b04cd8d0e95ec63bac5f3b391def4481140 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 18 Aug 2008 22:35:07 +0000 Subject: [PATCH] Links in all templates reworked, Primera API (see www.primusportal.de for details) added (UNFINISHED!) --- .gitattributes | 1 + .../templates/de/code/action_login_logout.ctp | 23 +- .../templates/de/code/block_persona_data.ctp | 2 +- .../blog/templates/de/code/confirm_link.ctp | 14 +- .../blog/templates/de/code/login_failed.ctp | 14 +- .../blog/templates/de/code/login_form.ctp | 11 +- .../blog/templates/de/code/login_main.ctp | 12 +- .../blog/templates/de/code/logout_done.ctp | 14 +- .../templates/de/code/action_login_logout.ctp | 23 +- .../templates/de/code/block_persona_data.ctp | 2 +- .../templates/de/code/confirm_link.ctp | 14 +- .../templates/de/code/login_failed.ctp | 14 +- .../templates/de/code/login_form.ctp | 11 +- .../templates/de/code/login_main.ctp | 12 +- .../templates/de/code/logout_done.ctp | 14 +- .../api/primusportal/class_PrimeraApi.php | 240 ++++++++++++++++++ 16 files changed, 405 insertions(+), 16 deletions(-) create mode 100644 inc/classes/third_party/api/primusportal/class_PrimeraApi.php diff --git a/.gitattributes b/.gitattributes index bd57ad4..c980720 100644 --- a/.gitattributes +++ b/.gitattributes @@ -674,6 +674,7 @@ inc/classes/middleware/io/class_FileIoHandler.php -text inc/classes/third_party/.htaccess -text inc/classes/third_party/api/.htaccess -text inc/classes/third_party/api/primusportal/.htaccess -text +inc/classes/third_party/api/primusportal/class_PrimeraApi.php -text inc/classes/third_party/api/wernisportal/.htaccess -text inc/classes/third_party/api/wernisportal/class_WernisApi.php -text inc/classes/third_party/php_mailer/.htaccess -text diff --git a/application/blog/templates/de/code/action_login_logout.ctp b/application/blog/templates/de/code/action_login_logout.ctp index 5d1dd3b..671b44f 100644 --- a/application/blog/templates/de/code/action_login_logout.ctp +++ b/application/blog/templates/de/code/action_login_logout.ctp @@ -1,9 +1,30 @@ +setLinkTextById('logout_now_link_text'); + +// Flush the content +$helper->flushContent(); + +// Get helper instance +$helper = WebLinkHelper::createWebLinkHelper($this, 'return_login_link', 'index.php?app=blog&page=login_area'); + +// Set link text +$helper->setLinkTextById('return_login_link_text'); + +// Flush the content +$helper->flushContent(); + +// [EOF] +?>
Willst du dich wirklich aus dem Blog aussloggen?
diff --git a/application/blog/templates/de/code/block_persona_data.ctp b/application/blog/templates/de/code/block_persona_data.ctp index cd203e8..5911ed7 100644 --- a/application/blog/templates/de/code/block_persona_data.ctp +++ b/application/blog/templates/de/code/block_persona_data.ctp @@ -6,7 +6,7 @@ $helperInstance = WebLinkHelper::createWebLinkHelper($this, 'profile_link', 'ind $helperInstance->prefetchValueInstance('user'); // Flush the content out -//$helperInstance->flushContent(); +$helperInstance->flushContent(); // End of PHP commands ?> diff --git a/application/blog/templates/de/code/confirm_link.ctp b/application/blog/templates/de/code/confirm_link.ctp index f7f35c5..95039ec 100644 --- a/application/blog/templates/de/code/confirm_link.ctp +++ b/application/blog/templates/de/code/confirm_link.ctp @@ -1,3 +1,15 @@ +setLinkTextById('direct_login_link_text'); + +// Flush the content +$helper->flushContent(); + +// [EOF] +?>
Bestätigung Deiner Email-Adresse:
@@ -9,5 +21,5 @@ diff --git a/application/blog/templates/de/code/login_failed.ctp b/application/blog/templates/de/code/login_failed.ctp index a818ba8..10d0727 100644 --- a/application/blog/templates/de/code/login_failed.ctp +++ b/application/blog/templates/de/code/login_failed.ctp @@ -1,3 +1,15 @@ +setLinkTextById('login_retry_link_text'); + +// Flush the content +$helper->flushContent(); + +// [EOF] +?>
Du bist nicht mehr im Blog eingeloggt!
@@ -22,7 +34,7 @@ diff --git a/application/blog/templates/de/code/logout_done.ctp b/application/blog/templates/de/code/logout_done.ctp index 76d44ed..106b228 100644 --- a/application/blog/templates/de/code/logout_done.ctp +++ b/application/blog/templates/de/code/logout_done.ctp @@ -1,7 +1,19 @@ +setLinkTextById('relogin_link_text'); + +// Flush the content +$helper->flushContent(); + +// [EOF] +?>
Du bist jetzt aus dem Blog ausgeloggt!
- Du kannst dich nun [erneut einloggen] oder weiter auf unseren Seiten bleiben. ;-) + Du kannst dich nun {?relogin_link}? oder weiter auf unseren Seiten bleiben. ;-)
diff --git a/application/ship-simu/templates/de/code/action_login_logout.ctp b/application/ship-simu/templates/de/code/action_login_logout.ctp index aa4ca11..459d305 100644 --- a/application/ship-simu/templates/de/code/action_login_logout.ctp +++ b/application/ship-simu/templates/de/code/action_login_logout.ctp @@ -1,9 +1,30 @@ +setLinkTextById('logout_now_link_text'); + +// Flush the content +$helper->flushContent(); + +// Get helper instance +$helper = WebLinkHelper::createWebLinkHelper($this, 'return_login_link', 'index.php?app=ship-simu&page=login_area'); + +// Set link text +$helper->setLinkTextById('return_login_link_text'); + +// Flush the content +$helper->flushContent(); + +// [EOF] +?>
Willst du dich wirklich aus dem Spiel aussloggen?
diff --git a/application/ship-simu/templates/de/code/block_persona_data.ctp b/application/ship-simu/templates/de/code/block_persona_data.ctp index 003bcf4..45923dc 100644 --- a/application/ship-simu/templates/de/code/block_persona_data.ctp +++ b/application/ship-simu/templates/de/code/block_persona_data.ctp @@ -6,7 +6,7 @@ $helperInstance = WebLinkHelper::createWebLinkHelper($this, 'profile_link', 'ind $helperInstance->prefetchValueInstance('user'); // Flush the content out -//$helperInstance->flushContent(); +$helperInstance->flushContent(); // End of PHP commands ?> diff --git a/application/ship-simu/templates/de/code/confirm_link.ctp b/application/ship-simu/templates/de/code/confirm_link.ctp index 75a1885..91ae0dc 100644 --- a/application/ship-simu/templates/de/code/confirm_link.ctp +++ b/application/ship-simu/templates/de/code/confirm_link.ctp @@ -1,3 +1,15 @@ +setLinkTextById('direct_login_link_text'); + +// Flush the content +$helper->flushContent(); + +// [EOF] +?>
Bestätigung Deiner Email-Adresse:
@@ -9,5 +21,5 @@ diff --git a/application/ship-simu/templates/de/code/login_failed.ctp b/application/ship-simu/templates/de/code/login_failed.ctp index 9facf08..e134fb2 100644 --- a/application/ship-simu/templates/de/code/login_failed.ctp +++ b/application/ship-simu/templates/de/code/login_failed.ctp @@ -1,3 +1,15 @@ +setLinkTextById('login_retry_text'); + +// Flush the content +$helper->flushContent(); + +// [EOF] +?>
Du bist nicht mehr im Spiel eingeloggt!
@@ -22,7 +34,7 @@ diff --git a/application/ship-simu/templates/de/code/logout_done.ctp b/application/ship-simu/templates/de/code/logout_done.ctp index 9d441da..b956f23 100644 --- a/application/ship-simu/templates/de/code/logout_done.ctp +++ b/application/ship-simu/templates/de/code/logout_done.ctp @@ -1,7 +1,19 @@ +setLinkTextById('relogin_link_text'); + +// Flush the content +$helper->flushContent(); + +// [EOF] +?>
Du bist jetzt aus dem Spiel ausgeloggt!
- Du kannst dich nun [erneut einloggen] oder weiter auf unseren Seiten bleiben. ;-) + Du kannst dich nun {?relogin_link?} oder weiter auf unseren Seiten bleiben. ;-)
diff --git a/inc/classes/third_party/api/primusportal/class_PrimeraApi.php b/inc/classes/third_party/api/primusportal/class_PrimeraApi.php new file mode 100644 index 0000000..fba7463 --- /dev/null +++ b/inc/classes/third_party/api/primusportal/class_PrimeraApi.php @@ -0,0 +1,240 @@ +payPrimera($PayReceiver, $PayAmount, $PayDescription); + * + * 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): + * CODE: + * if (!$status) { + * // Ein Fehler ist aufgetreten + * // Fehlerbehandlung hier einfügen... + * }else { + * // 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- + * variable __data gespeichert: + * __data => array("status" => Rückgabecode (PI_DONE, PI_SENDER_ERROR, ...), + * "statustext" => Status in Worten (z.B.: "Transaktion erfolgreich durchgeführt"), + * ") + * + * + * @author Andreas Schmidt + * @author Roland Haeder + * @version 1.0 - beta + * @copyright (c) 2007 by Primusportal.de + * @copyright (c) 2008 by Roland Haeder + */ +class PrimeraApi { + /** + * Fehler - Interfacebenutzer + */ + const PI_ERROR = -1; + + /** + * Statuscode für erfolgreich ausgeführte Transaktion + */ + const PI_DONE = 200; + + /** + * Fehler - User existiert nicht oder ist gesperrt + */ + const PI_RECEIVER_ERROR = 301; + + /** + * Sender-Account Fehler (User nicht existent, gesperrt, ...) + */ + const PI_SENDER_ERROR = 401; + + /** + * Betrag fehler + */ + const PI_AMOUNT_ERROR = 501; + + /** + * Zu wenig Primera + */ + const PI_TOO_LESS_PRIMERA = 502; + + /** + * User nicht aktiv oder existiert nicht + */ + const PI_USER_CHECK_ERROR = 601; + + /** + * User aktiv + */ + const PI_USER_CHECK_OK = 602; + + /** + * Primerastand erfolgreich geholt + */ + const PI_GET_PRIMERA_DONE = 701; + + /** + * URL für das Interface auf dem Primusserver: + */ + private $host = "www.primusportal.de"; + private $path = "/transfer.interface.2.0.php"; + + private $errno = 0; + private $err = ""; + + private $seperator = ":"; + + private $username = ""; + private $password = ""; + + private $data = array(); + + /** + * Konstruktor + */ + public function __construct ($PPUsername, $PPPassword) { + // Call parent constructor + parent::__construct(); + + // Clean up a little + $this->removeSystemArray(); + $this->removeNumberFormaters(); + + // Set data (DEPRECATED!) + $this->username = $PPUsername; + $this->password = $PPPassword; + } + + /** + * Anfrage senden und Rückgabecode in Variable speichern + */ + function queryApi ( $data = array() ) { + $fp = fsockopen($this->host, 80, $this->errno, $this->_err); + if (!$fp) return false; + + $data["PrimusInterface_Username"] = base64_encode($this->username); + $data["PrimusInterface_Password"] = base64_encode(md5($this->password)); + + // POST-Daten übermitteln: + $data = http_build_query($data, '', '&'); + + fputs($fp, "POST {$this->path}HTTP/1.1\r\n"); + fputs($fp, "Host: {$this->host}\r\n"); + fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); + fputs($fp, "Content-length: ". strlen($data) ."\r\n"); + fputs($fp, "Connection: close\r\n\r\n"); + fputs($fp, $data); + + $return = ""; + while (!feof($fp)) { + $return.=fgets($fp,128); + } + + $content = explode("", $return); + return $content[1]; + } + + /** + * 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); + if (count($line_exploded) > 1) { + $return[$line_exploded[0]] = $line_exploded[1]; + } + } + return $return; + } + + /** + * @param int/string $Receiver UserID / Username des Empfängers + * @param int$Amount Betrag in ganzzahligen Primera + * @param string $Description Beschreibung (Sichtbar in Einzelauflistung) + */ + public 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) ); + + $PostReturn = $this->parseContent( $this->queryApi($PostData) ); + + $this->data = $PostReturn; + if ($PostReturn["status"] == "200") { + $valid = true; + } + return $valid; + } + + /** + * Ü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); + + $PostReturn = $this->parseContent( $this->queryApi($PostData) ); + + $this->data = $PostReturn; + + if ($PostReturn["status"] == self::PI_USER_CHECK_OK) { + $valid = true; + } + return $valid; + } + + /** + * Die Funktion liefer den aktuellen Primerastand + */ + function getPrimera() { + $primera = false; + $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"]; + } + return $primera; + } +} + +// [EOF] +?> \ No newline at end of file -- 2.30.2