moduleManager->get('Exchange'); $response = new HttpResponse(); $request = new HttpRequest(); $contents = \file_get_contents($path . '/interface.json'); if ($contents === false) { return (new NullInterfaceManager())->toArray(); } $data = \json_decode($contents, true); if (!\is_array($data)) { return (new NullInterfaceManager())->toArray(); } $request->header->account = 1; $request->setData('title', $data['name']); $request->setData('export', (int) $data['export']); $request->setData('import', (int) $data['import']); $request->setData('website', $data['website']); if (!\is_dir($tmpPath = __DIR__ . '/../../../temp/' . $data['name'] . '/')) { \mkdir($tmpPath, 0755, true); } $exchangeFiles = \scandir($path); if ($exchangeFiles === false) { return (new NullInterfaceManager())->toArray(); } foreach ($exchangeFiles as $filePath) { if ($filePath === '..' || $filePath === '.') { continue; } if (\is_dir($path . '/' . $filePath)) { $subdir = \scandir($path . '/' . $filePath); if ($subdir === false) { continue; } foreach ($subdir as $subPath) { if (!\is_file($path . '/' . $filePath . '/' . $subPath)) { continue; } \copy( $path . '/' . $filePath . '/' . $subPath, $tmpPath . $subPath ); $request->addFile([ 'error' => \UPLOAD_ERR_OK, 'type' => \substr($subPath, \strrpos($subPath, '.') + 1), 'name' => $filePath . '/' . $subPath, 'tmp_name' => $tmpPath . $subPath, 'size' => \filesize($tmpPath . $subPath), ]); } } else { if (!\is_file($path . '/' . $filePath)) { continue; } \copy($path . '/' . $filePath, $tmpPath . $filePath); $request->addFile([ 'error' => \UPLOAD_ERR_OK, 'type' => \substr($filePath, \strrpos($filePath, '.') + 1), 'name' => $filePath, 'tmp_name' => $tmpPath . $filePath, 'size' => \filesize($tmpPath . $filePath), ]); } } $module->apiInterfaceInstall($request, $response); \rmdir($tmpPath); $responseData = $response->getData(''); if (!\is_array($responseData)) { return []; } return \is_array($responseData['response']) ? $responseData['response'] : $responseData['response']->toArray(); } }