mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-14 20:17:14 +01:00
class.remote.php added additional logging
This commit is contained in:
parent
aac159bcb0
commit
d494778fad
@ -2240,13 +2240,12 @@ class Remote {
|
|||||||
$this->app->erp->AuftragProtokoll($orderId, 'Versandmeldung an Shop fehlgeschlagen', $bearbeiter);
|
$this->app->erp->AuftragProtokoll($orderId, 'Versandmeldung an Shop fehlgeschlagen', $bearbeiter);
|
||||||
|
|
||||||
$this->logger->error('Versandmeldung an Shop fehlgeschlagen',
|
$this->logger->error('Versandmeldung an Shop fehlgeschlagen',
|
||||||
[
|
[
|
||||||
'orderId' => $orderId,
|
'orderId' => $orderId,
|
||||||
'shopId' => $shopId,
|
'shopId' => $shopId,
|
||||||
'message' => $response->getMessage()
|
'message' => $response->getMessage()
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2486,7 +2485,21 @@ class Remote {
|
|||||||
$shoptyp = $this->app->DB->Select("SELECT shoptyp FROM shopexport WHERE id='$id' LIMIT 1");
|
$shoptyp = $this->app->DB->Select("SELECT shoptyp FROM shopexport WHERE id='$id' LIMIT 1");
|
||||||
$modulename = trim($this->app->DB->Select("SELECT modulename FROM shopexport WHERE id='$id' LIMIT 1"), '.');
|
$modulename = trim($this->app->DB->Select("SELECT modulename FROM shopexport WHERE id='$id' LIMIT 1"), '.');
|
||||||
$isActionAuth = $action === 'auth';
|
$isActionAuth = $action === 'auth';
|
||||||
|
$exception = null;
|
||||||
|
|
||||||
|
$this->logger->debug(
|
||||||
|
'RemoteCommand (Shop '.$id.") ".$action,
|
||||||
|
[
|
||||||
|
'shop' => $id,
|
||||||
|
'action' => $action,
|
||||||
|
'data' => $data
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
if ($shoptyp === 'custom') {
|
if ($shoptyp === 'custom') {
|
||||||
|
|
||||||
|
$error = null;
|
||||||
|
|
||||||
if ($modulename != '') {
|
if ($modulename != '') {
|
||||||
|
|
||||||
$file = dirname(__DIR__) . '/plugins/external/shopimporter/' . $modulename;
|
$file = dirname(__DIR__) . '/plugins/external/shopimporter/' . $modulename;
|
||||||
@ -2507,29 +2520,37 @@ class Remote {
|
|||||||
$method = $this->getMethod($obj, $action);
|
$method = $this->getMethod($obj, $action);
|
||||||
if (method_exists($obj, $method)) {
|
if (method_exists($obj, $method)) {
|
||||||
$ret = $obj->$method();
|
$ret = $obj->$method();
|
||||||
|
$this->logger->debug('RemoteCommand result (Shop '.$id.') '.$modulename.' '.$action,
|
||||||
|
[
|
||||||
|
'shop' => $id,
|
||||||
|
'action' => $action,
|
||||||
|
'data' => $data,
|
||||||
|
'result' => $ret
|
||||||
|
]
|
||||||
|
);
|
||||||
if (!empty($this->app->stringcleaner)) {
|
if (!empty($this->app->stringcleaner)) {
|
||||||
$this->app->stringcleaner->XMLArray_clean($ret);
|
$this->app->stringcleaner->XMLArray_clean($ret);
|
||||||
}
|
}
|
||||||
} elseif ($isActionAuth) {
|
} elseif ($isActionAuth) {
|
||||||
return 'Fehler: Importer konnte nicht initialisiert werden';
|
$error = 'Fehler: Importer konnte nicht initialisiert werden';
|
||||||
}
|
}
|
||||||
} elseif ($isActionAuth) {
|
} elseif ($isActionAuth) {
|
||||||
return 'Fehler: Importer konnte nicht initialisiert werden';
|
$error = 'Fehler: Importer konnte nicht initialisiert werden';
|
||||||
}
|
}
|
||||||
} elseif ($isActionAuth) {
|
} elseif ($isActionAuth) {
|
||||||
return 'Fehler: Importer konnte nicht initialisiert werden';
|
$error = 'Fehler: Importer konnte nicht initialisiert werden';
|
||||||
}
|
}
|
||||||
} elseif ($isActionAuth) {
|
} elseif ($isActionAuth) {
|
||||||
return 'Fehler: Datei ' . $file . ' existiert nicht';
|
$error = 'Fehler: Datei ' . $file . ' existiert nicht';
|
||||||
}
|
}
|
||||||
} elseif ($isActionAuth) {
|
} elseif ($isActionAuth) {
|
||||||
return 'Fehler: Schnittstelle nicht aktiv';
|
$error = 'Fehler: Schnittstelle nicht aktiv';
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$error = 'Fehler: Kein Modul angegeben';
|
||||||
}
|
}
|
||||||
return '';
|
|
||||||
}
|
}
|
||||||
|
else if ($shoptyp === 'intern') {
|
||||||
if ($shoptyp === 'intern') {
|
|
||||||
if ($modulename != '') {
|
if ($modulename != '') {
|
||||||
if ($this->app->erp->ModulVorhanden($modulename)) {
|
if ($this->app->erp->ModulVorhanden($modulename)) {
|
||||||
$obj = $this->app->erp->LoadModul($modulename);
|
$obj = $this->app->erp->LoadModul($modulename);
|
||||||
@ -2538,94 +2559,57 @@ class Remote {
|
|||||||
$obj->getKonfig($id, $data);
|
$obj->getKonfig($id, $data);
|
||||||
}
|
}
|
||||||
$method = 'Import' . $action;
|
$method = 'Import' . $action;
|
||||||
|
|
||||||
if (method_exists($obj, $method)) {
|
if (method_exists($obj, $method)) {
|
||||||
try {
|
try {
|
||||||
$ret = $obj->$method();
|
$ret = $obj->$method();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
$exception = $e;
|
||||||
if ($isActionAuth) {
|
if ($isActionAuth) {
|
||||||
return 'Fehler Auth: ' . $e->getMessage();
|
$error = 'Fehler Auth: ' . $e->getMessage();
|
||||||
|
} else {
|
||||||
|
$error = 'Fehler: ' . $e->getMessage();
|
||||||
}
|
}
|
||||||
return 'Fehler: ' . $e->getMessage();
|
|
||||||
}
|
}
|
||||||
|
$this->logger->debug('RemoteCommand result (Shop '.$id.') '.$modulename.' '.$action,
|
||||||
|
[
|
||||||
|
'shop' => $id,
|
||||||
|
'action' => $action,
|
||||||
|
'data' => $data,
|
||||||
|
'result' => $ret
|
||||||
|
]
|
||||||
|
);
|
||||||
if (!empty($this->app->stringcleaner)) {
|
if (!empty($this->app->stringcleaner)) {
|
||||||
$this->app->stringcleaner->XMLArray_clean($ret);
|
$this->app->stringcleaner->XMLArray_clean($ret);
|
||||||
}
|
}
|
||||||
$this->parseReturn($ret, $id, $action);
|
$this->parseReturn($ret, $id, $action);
|
||||||
return $ret;
|
|
||||||
} else {
|
} else {
|
||||||
return 'Fehler: Funktion nicht implementiert: ' . $method;
|
$error = 'Fehler: Funktion nicht implementiert: ' . $method;
|
||||||
}
|
}
|
||||||
} elseif ($isActionAuth) {
|
} elseif ($isActionAuth) {
|
||||||
return 'Fehler: Importer konnte nicht initialisiert werden';
|
$error = 'Fehler: Importer konnte nicht initialisiert werden';
|
||||||
}
|
}
|
||||||
} elseif ($isActionAuth) {
|
} elseif ($isActionAuth) {
|
||||||
return 'Fehler: Dieses Modul ist nicht verfügbar';
|
$error = 'Fehler: Dieses Modul ist nicht verfügbar';
|
||||||
}
|
}
|
||||||
} elseif ($isActionAuth) {
|
} elseif ($isActionAuth) {
|
||||||
return 'Fehler: Kein Modul vorhanden';
|
$error = 'Fehler: Kein Modul vorhanden';
|
||||||
|
} else {
|
||||||
|
$error = 'Fehler: Kein Modul angegeben';
|
||||||
}
|
}
|
||||||
return '';
|
|
||||||
}
|
}
|
||||||
$shopexport = $this->app->DB->SelectRow("SELECT * FROM shopexport WHERE id='$id' LIMIT 1");
|
if ($error) {
|
||||||
if ($shopexport) {
|
$this->logger->error('RemoteCommand error (Shop '.$id.') '.$modulename.' '.$action,
|
||||||
if ($shopexport['shoptyp'] === 'intern' || $shopexport['shoptyp'] === 'custom') {
|
[
|
||||||
return '';
|
'error' => $error,
|
||||||
}
|
'exception' => $exception
|
||||||
$token = $shopexport['token'];
|
]
|
||||||
$url = $shopexport['url'];
|
|
||||||
$z = $shopexport['passwort'];
|
|
||||||
$bezeichnung = $shopexport['bezeichnung'];
|
|
||||||
} else {
|
|
||||||
$token = '';
|
|
||||||
$z = '';
|
|
||||||
$url = '';
|
|
||||||
}
|
|
||||||
if ($isActionAuth) {
|
|
||||||
if ($token === '' || strlen($z) < 32 || $url === '') {
|
|
||||||
return 'Fehler: Bitte Zugangsdaten prüfen';
|
|
||||||
}
|
|
||||||
} elseif ($token === '' || strlen($z) < 32 || $url === '' || !$this->app->DB->Select("SELECT id FROM shopexport WHERE id = '$id' AND aktiv = 1 LIMIT 1")) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$tmp = parse_url($url);
|
|
||||||
$tmp['host'] = rtrim($tmp['host'], '/');
|
|
||||||
$tmp['path'] = rtrim($tmp['path'], '/') . '/';
|
|
||||||
|
|
||||||
$aes = new AES($z);
|
|
||||||
$token = base64_encode($aes->encrypt(serialize($token)));
|
|
||||||
$client = new HttpClient($tmp['host'], stripos($url, 'https') === 0 ? 443 : 80);
|
|
||||||
$geturl = $tmp['path'] . 'index.php?module=import&action=' . $action . '&challenge=' . (isset($challenge) ? $challenge : '');
|
|
||||||
//Kein Fragezeichen vor module=import...
|
|
||||||
if (false !== stripos($bezeichnung, 'woocommerce')) {
|
|
||||||
$geturl = $tmp['path'] . 'module=import&action=' . $action . '&challenge=' . (isset($challenge) ? $challenge : '');
|
|
||||||
}
|
|
||||||
if (false !== stripos($bezeichnung, 'shopware plugin')) {
|
|
||||||
$geturl = $tmp['path'] . 'wawisionimporter/?smodule=import&saction=' . $action . '&challenge=' . (isset($challenge) ? $challenge : '');
|
|
||||||
}
|
|
||||||
|
|
||||||
$post_data['token'] = $token;
|
|
||||||
$post_data['data'] = base64_encode(serialize($data));
|
|
||||||
$client->timeout = 120;
|
|
||||||
if (!$client->post($geturl, $post_data)) {
|
|
||||||
|
|
||||||
$this->logger->error('An error occurred',
|
|
||||||
[
|
|
||||||
'error' => $client->getError()
|
|
||||||
]
|
|
||||||
);
|
);
|
||||||
|
return($error);
|
||||||
throw new Exception('An error occurred: ' . $client->getError());
|
}
|
||||||
//return 'Netzwerkverbindung von WaWison zu Shopimporter fehlgeschlagen: '.$client->getError();
|
|
||||||
}
|
|
||||||
$ret = unserialize(base64_decode($client->getContent()));
|
|
||||||
if (!empty($this->app->stringcleaner)) {
|
|
||||||
$this->app->stringcleaner->XMLArray_clean($ret);
|
|
||||||
}
|
|
||||||
$this->parseReturn($ret, $id, $action);
|
|
||||||
return $ret;
|
return $ret;
|
||||||
|
|
||||||
|
// Dead code removed here 2024-09-13
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user