user shops + shipping

This commit is contained in:
Kevin Adametz 2019-01-06 01:40:44 +01:00
parent ccc2af4bf7
commit d4f6a774d0
53 changed files with 2326 additions and 814 deletions

View file

@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use Input;
use Session;
use \SoapClient;
class KasController extends Controller
@ -17,6 +18,7 @@ class KasController extends Controller
private $session_lifetime = 600; // Gültigkeit des Tokens in Sek. bis zur neuen Authentifizierung
private $session_update_lifetime = 'Y'; // bei N läuft die Session nach <$session_lifetime> Sekunden ab, bei Y verlängert sich die Session mit jeder Benutzung
private $CredentialToken = false;
private $kas_flood_delay = 2;
/**
* Create a new controller instance.
@ -31,6 +33,7 @@ class KasController extends Controller
public function action($func, $para = array()){
$this->checkSession($func);
try
{
$Params = array(); // Parameter für die API-Funktion
@ -42,6 +45,8 @@ class KasController extends Controller
'KasRequestType' => $func, // API-Funktion
'KasRequestParams' => $para // Parameter an die API-Funktion
)));
Session::put('flood_protection.'.$func, time() + $this->kas_flood_delay + 0.2);
if(isset($req['Response']['ReturnString']) && $req['Response']['ReturnString'] == "TRUE"){
return $req['Response']['ReturnInfo'];
}
@ -60,8 +65,11 @@ class KasController extends Controller
private function login(){
$this->checkSession('auth');
try
{
$SoapLogon = new SoapClient('https://kasapi.kasserver.com/soap/wsdl/KasAuth.wsdl');
$this->CredentialToken = $SoapLogon->KasAuth(json_encode(array(
'KasUser' => $this->kas_user,
@ -70,6 +78,8 @@ class KasController extends Controller
'SessionLifeTime' => $this->session_lifetime,
'SessionUpdateLifeTime' => $this->session_update_lifetime
)));
Session::put('flood_protection.auth', time() + $this->kas_flood_delay + 0.2);
}
// Fehler abfangen und ausgeben
@ -83,7 +93,19 @@ class KasController extends Controller
}
private function checkSession($func)
{
$name = 'flood_protection.'.$func;
if(Session::exists($name)){
$time_to_wait = (float)Session::get($name) - time();
Session::forget($name);
}else {
$time_to_wait = 0;
}
if ( $time_to_wait >= 0 ) {
usleep( intval( $time_to_wait*1000000 ) );
}
}
}