123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546 |
- <?php
- use App\Facades\ProApiCacheFacade;
- use App\Helpers\File;
- use App\Helpers\Utils;
- use App\Exports\Type1Export;
- use App\Http\Controllers\BarcodeController;
- use App\Http\Controllers\CaptchaServiceController;
- use App\Http\Controllers\DBUpdateController;
- use App\Http\Controllers\EnvSettingController;
- use App\Imports\Type1Import;
- use App\Services\CallApiService;
- use Illuminate\Http\Request;
- use App\Models\Parameter\FormA;
- use App\Models\Parameter\FormB;
- use App\Models\Parameter\Modal;
- use App\Models\Parameter\Manual;
- use Barryvdh\DomPDF\Facade as PDF;
- use App\Models\Parameter\ListMedia1;
- use Illuminate\Support\Str;
- use Maatwebsite\Excel\Facades\Excel;
- use Illuminate\Support\Facades\Route;
- use Intervention\Image\Facades\Image;
- use Illuminate\Support\Facades\Artisan;
- use Illuminate\Support\Facades\Storage;
- use App\Http\Controllers\Api\ApiController;
- use App\Http\Controllers\DashboardController;
- use App\Http\Controllers\Auth\LoginController;
- use App\Http\Controllers\Auth\SocialController;
- use App\Http\Controllers\CountryCodeController;
- /*
- |--------------------------------------------------------------------------
- | Web Routes
- |--------------------------------------------------------------------------
- |
- | Here is where you can register web routes for your application. These
- | routes are loaded by the RouteServiceProvider within a group which
- | contains the "web" middleware group. Now create something great!
- |
- */
- Route::middleware(['check.logout'])->group(function () {
- Route::get('/checkphp', function () {
- return phpinfo();
- });
- Route::get(env('USER_LOGIN_ROUTE', '/user-login') ?: '/user-login', [LoginController::class, 'index'])->middleware('check.gate.token')->name('user-login');
- Route::post('/login', [LoginController::class, 'login'])->middleware('check.gate.token')->name('login.post');
- Route::get('/db-update', [DBUpdateController::class, 'index'])->name('db-update.index');
- Route::post('/db-update', [DBUpdateController::class, 'store'])->name('db-update.store');
- });
- Route::middleware(['check.login'])->group(function () {
- Route::get('/dabory/erp', [DashboardController::class, 'index'])->name('dashboard');
- Route::get('/user-logout', [LoginController::class, 'logout'])->name('user-logout');
- Route::post('/cert/mail', [\App\Http\Controllers\CertController::class, 'mail']);
- Route::post('/cert/mobile', [\App\Http\Controllers\CertController::class, 'mobile']);
- Route::post('/superuser-email-change', function () {
- $mailCert = session()->get('mailCert');
- $smsCertCurrent = session()->get('smsCert.current');
- $smsCertNew = session()->get('smsCert.new');
- if (request('Type') === 0 && request('EmailVerifyNumber', '??????') != $mailCert['number']) {
- return response()->json(['error' => true, 'message' => '메일 인증번호 오류']);
- }
- if (request('Type') === 1 && request('MobileVerifyNumber', '??????') != $smsCertCurrent['number']) {
- return response()->json(['error' => true, 'message' => '현재 모바일폰에서 확인한 인증번호 오류']);
- }
- if (request('Type') === 2 && request('NewMobileVerifyNumber', '??????') != $smsCertNew['number']) {
- return response()->json(['error' => true, 'message' => '변경 관리자 모바일폰에서 확인한 인증번호 오류']);
- }
- return response()->json(['error' => false, 'message' => 'Success']);
- });
- Route::get('/user-query-turbo/{table}', function ($table) {
- $response = app(CallApiService::class)->callApi([
- 'url' => 'query-turbo',
- 'data' => [
- 'TableName' => $table,
- 'QueryVars' => [
- 'MyFilter' => '',
- 'QueryName' => '',
- 'FilterName' => '',
- 'FilterValue' => '',
- 'SimpleFilter' => 'mx.id between 1 and 10000',
- 'SubSimpleFilter' => '',
- 'IsntPagination' => true,
- 'TestMode' => '',
- ]
- ],
- ]);
- if (app(CallApiService::class)->verifyApiError($response)) {
- return response([
- 'body' => 'Api Server Error',
- 'apiStatus' => 500
- ], 200);
- }
- notify()->success(_e('Action completed'), 'Success', 'bottomRight');
- return redirect()->back();
- })->name('user.query.turbo');
- // Route::post('/ajax/get-data', [ApiController::class, 'getData']);
- Route::get('/country-code', [CountryCodeController::class, 'store']);
- Route::get('/change-sort-menu/{sort_menu_id}', function ($sortMenuId) {
- $sortMenuPage = Utils::getSortMenu()['Page'] ?? [];
- $filterSortMenu = collect($sortMenuPage)->filter(function ($sortMenu) use($sortMenuId) {
- return $sortMenu['Id'] === (int)$sortMenuId;
- })->first();
- session()->put('user.SortMenu', $filterSortMenu);
- return redirect()->to($filterSortMenu['C4']);
- })->name('change-sort-menu');
- });
- // admin, pro 공용
- // Route::get('/dabory/ssologin/callback', [DaborySSOController::class, 'login'])->middleware('check.gate.token')->name('dabory.ssologin.login');
- // Route::get('/dabory/ssologin', [DaborySSOController::class, 'redirectToProvider'])->middleware('check.gate.token')->name('dabory.redirectToProvider');
- Route::get('/social/{provider}/callback', [SocialController::class, 'login'])->middleware('check.gate.token')->name('social.login');
- Route::post('/social/{provider}/callback', [SocialController::class, 'login'])->middleware('check.gate.token');
- Route::get('/social/{provider}', [SocialController::class, 'redirectToProvider'])->middleware('check.gate.token')->name('social.redirectToProvider');
- Route::post('/ajax/get-data', [ApiController::class, 'getData']);
- Route::post('/find-gate-token', function () {
- if (! request()->has('app_name')) {
- return response('error', 500);
- }
- $appName = request('app_name');
- if (session()->has("GateToken.$appName")) {
- return response(session()->get("GateToken.$appName"), 200);
- }
- return response(session()->get("GateToken.$appName"), 200);
- });
- Route::post('/md5', function () {
- return md5(request('str'));
- });
- Route::get('/generate-keys', function () {
- $keyPair = sodium_crypto_box_keypair();
- $publicKey = sodium_crypto_box_publickey($keyPair);
- return array(base64_encode($publicKey),base64_encode($keyPair));
- });
- Route::get('/extract-keys', function () {
- $keyPair = base64_decode(request('key_pair'));
- $publicKey = sodium_crypto_box_publickey($keyPair);
- return base64_encode($publicKey);
- });
- Route::post('/crypto/sodium', function () {
- $data = json_decode(request()->getContent(), true);
- $decrypted = $data['decrypted'];
- if ($data['json_encode']) {
- $decrypted = json_encode( $decrypted );
- }
- return base64_encode(sodium_crypto_box_seal($decrypted,
- base64_decode( $data['public_key'] )));
- });
- Route::get('/user-clear-cache', function () {
- Artisan::call('event:clear');
- Artisan::call('cache:clear');
- Artisan::call('optimize:clear');
- Artisan::call('route:clear');
- Artisan::call('view:clear');
- // Storage::deleteDirectory('dabory-footage/users/' . session('user')['UserId']);
- Storage::deleteDirectory('dabory-footage/users');
- Storage::deleteDirectory('dabory-footage/pro');
- Storage::deleteDirectory('dabory-footage/basic/slip-form-init');
- Storage::deleteDirectory('dabory-footage/members');
- ProApiCacheFacade::deleteCachedDirectory();
- app(\App\Services\CacheService::class)->putMainMenu();
- app(\App\Services\CacheService::class)->putEtcBrand();
- app(\App\Services\CacheService::class)->putSetup();
- return redirect()->back();
- })->name('user.clear.cache');
- Route::post('/clear-menu-cache', function () {
- Storage::deleteDirectory('dabory-footage/users/' . session('user')['UserId'] . '/user-menu');
- });
- Route::get('/506', function () {
- return view('errors.506');
- })->name('506');
- // js에서 에러 예외처리 할 때 사용
- Route::get('/505', function () {
- session()->flush();
- return view('errors.505');
- })->name('505');
- Route::get('/503', function () {
- session()->flush();
- return view('errors.503');
- })->name('503');
- Route::get('/600', function () {
- session()->flush();
- return view('errors.600');
- })->name('600');
- Route::get('/pro-route-std', function () {
- return view('pro-route-std');
- })->name('pro-route-std');
- Route::get('/pro-route-custom', function () {
- return view('pro-route-custom');
- })->name('pro-route-custom');
- Route::get('/captcha-validation', [CaptchaServiceController::class, 'capthcaFormValidate']);
- Route::get('/reload-captcha', [CaptchaServiceController::class, 'reloadCaptcha']);
- Route::get('/test', function () {
- return view('eyetest-more');
- });
- Route::get('/eyetest-more-ui', function () {
- return view('front.dabory.erp.test-ui.eyetest-more-ui');
- });
- // demo gettext
- Route::get('/demo-gettext', function () {
- // return _e('admin');
- // return _e('file moved');
- return _e('%s file moved to %s', 'aaa.php', 'bbb.php');
- });
- // test-tailwind-css
- Route::get('/tailwind-css-test', function () {
- return view('main.tailwind-css-test');
- });
- // 테스트떄문에 에러토큰으로 변경 (GateToken Not Found Test)
- Route::post('/token-change', function () {
- session()->put('GateToken.erp', 'duoICbFSNRRoxXoIaC0G');
- return response('');
- });
- Route::get('/test/image-ui', function () {
- return view('test.image-ui');
- });
- Route::get('/geolocation', function () {
- return view('geolocation');
- });
- Route::get('/barcode/{listToken}', [BarcodeController::class, 'index'])->name('barcode');
- Route::middleware('check.gate.token')->group(function () {
- Route::post('/blades', function () {
- if (request('data')) {
- $key = request('key') ?? 'moealSetFile';
- if (empty(request('class_name'))) {
- return view(request('path_to_blade'), [$key => request('data')]);
- } else {
- return view(request('path_to_blade'), array_merge(request('class_name'), [$key => request('data')]));
- }
- }
- return view(request('path_to_blade'));
- });
- Route::post('/pro-skin-directories', function () {
- $directories = App\Helpers\File::getSkinDirectories();
- return response($directories, 200);
- });
- Route::post('/breadcrumb', function () {
- $breadcrumb = breadcrumb(request('igroup_code'));
- return response($breadcrumb, 200);
- });
- Route::post('/set-general-info', [EnvSettingController::class, 'setGeneralInfo']);
- Route::post('/set-aws-s3', [EnvSettingController::class, 'setAwsS3']);
- Route::post('/set-aligo-text-send', [EnvSettingController::class, 'setAligoTextSend']);
- Route::post('/excel-import', function (Request $request) {
- if (!$request->hasFile('file')) {
- return response('error', 500);
- }
- $data = Excel::toArray(new Type1Import, $request->file('file'));
- return response($data, 200);
- });
- Route::post('/sub-image-upload', function (Request $request) {
- $formExt = pathinfo(request('form_file_path'), PATHINFO_EXTENSION);
- $toExt = pathinfo(request('to_file_path'), PATHINFO_EXTENSION);
- if ($formExt !== $toExt) {
- Storage::disk(getDisk())->delete(request('form_file_path'));
- return response('보정 파일과 이전 파일의 확장자가 다릅니다.', 202);
- }
- Storage::disk(getDisk())->delete(request('to_file_path'));
- Storage::disk(getDisk())->move(request('form_file_path'), request('to_file_path'));
- return response('success', 200);
- });
- Route::post('/sub-image-correction', function (Request $request) {
- if (!$request->hasFile('file')) {
- return response('error', 500);
- }
- $path = '/uploads';
- $response = Storage::disk(getDisk())->put($path, $request->file('file'), ['visibility' => 'public']);
- return response($response, 200);
- });
- Route::post('/file-exists', function () {
- if (Storage::disk(getDisk())->exists(request('file_path'))) {
- return response(true, 200);
- }
- return response(false, 200);
- });
- Route::post('/seo-meta-file-list', function (Request $request) {
- $publicPath = public_path();
- $files = \File::files($publicPath);
- // Filter root files (not in subdirectories)
- $rootFiles = array_filter($files, function ($file) use ($publicPath) {
- return $file->getPath() == $publicPath;
- });
- // Extract only the names of the root files
- $rootFileNames = array_map(function ($file) {
- return $file->getFilename();
- }, $rootFiles);
- return $rootFileNames;
- });
- Route::post('/seo-meta-file-upload', function (Request $request) {
- if (!$request->hasFile('file')) {
- return response('error', 500);
- }
- $file = $request->file('file');
- $file->storeAs('/', request('fileName'), ['disk' => 'erp']);
- return response($file, 201);
- });
- Route::post('/upload-batch', function (Request $request) {
- $mediaList = request('media_list');
- foreach ($mediaList as $media) {
- $mediaPath = substr($media['path'], '1') . $media['name'];
- try {
- $file = File::pathToUploadedFile(Storage::disk(getDisk())->path($mediaPath));
- } catch (Exception $e) {
- return response([
- 'body' => $media['path'] . $media['name'] . ' 파일이 존재하지 않아서 Upload Batch 실행 취소했습니다',
- 'apiStatus' => 501
- ], 200);
- }
- $image = Image::make($file);
- $mediaAct = app(CallApiService::class)->callApi([
- 'url' => 'media-act',
- 'data' => [
- 'Page' => [
- [
- 'Id' => $media['media_id'],
- 'FileUrl' => "/{$mediaPath}",
- 'FileSize' => (int)round($image->filesize() / 1024),
- 'MediaWidth' => $image->width(),
- 'MediaHeight' => $image->height(),
- ]
- ],
- ],
- ]);
- if (app(CallApiService::class)->verifyApiError($mediaAct)) {
- return response([
- 'body' => 'Api Server Error',
- 'apiStatus' => 500
- ], 200);
- }
- $bdPage = app(App\Services\MediaLibraryService::class)
- ->makeImageBd($file, $media, request('is_crop_image'));
- $mediaBdPage = collect($bdPage)->map(function ($item) use ($media) {
- return [
- 'Id' => 0,
- 'MediaId' => $media['media_id'],
- 'ImageType' => $item['ImageType'],
- 'BdFileUrl' => $item['BdFileUrl'],
- 'BdFileSize' => (int)$item['BdFileSize'],
- 'BdWidth' => $item['BdWidth'],
- 'BdHeight' => $item['BdHeight'],
- ];
- })->toArray();
- if (count($mediaBdPage) > 0) {
- $mediaBdAct = app(CallApiService::class)->callApi([
- 'url' => 'media-bd-act',
- 'data' => [
- 'Page' => $mediaBdPage
- ],
- ]);
- if (app(CallApiService::class)->verifyApiError($mediaBdAct)) {
- return response([
- 'body' => 'Api Server Error',
- 'apiStatus' => 500
- ], 200);
- }
- }
- }
- return response('success', 201);
- });
- Route::post('/post-attached-files', function (Request $request) {
- $mediaLibraryService = app(App\Services\MediaLibraryService::class);
- $mediaLibraryService->setGateToken(session('GateToken')['main']);
- $setup = $mediaLibraryService->getSetup('post');
- $path = $mediaLibraryService->getCurrSetupFilePath($setup);
- $attachedFiles = '';
- for ($i = 0; $i < $request['fileCount']; $i++) {
- $file = $request->file('file' . $i);
- $file->storeAs($path, $file->getClientOriginalName(), ['disk' => getDisk()]);
- $attachedFiles .= $path . $file->getClientOriginalName() . '|';
- }
- $attachedFiles = rtrim($attachedFiles, '|');
- return response()->json($attachedFiles);
- });
- Route::post('/file-upload', function (Request $request) {
- if (!$request->hasFile('file')) {
- return response('error', 500);
- }
- $media = json_decode(request('media'), true);
- $file = $request->file('file');
- $file->storeAs($media['path'], $media['name'], ['disk' => getDisk()]);
- $bdPage = [];
- if ($media['type'] == 'image') {
- $fileExtension = Str::lower($file->extension());
- if ($fileExtension === 'gif' || $fileExtension === 'webp' || $fileExtension === 'svg') {
- $bdPage = app(App\Services\MediaLibraryService::class)->makeGifBd($file, $media);
- } else {
- $bdPage = app(App\Services\MediaLibraryService::class)->makeImageBd($file, $media);
- }
- }
- return response($bdPage, 201);
- });
- Route::post('/file-delete', function () {
- $file_path_list = json_decode(request('file_path_list'), true);
- Storage::disk(getDisk())->delete($file_path_list);
- return response('success', 200);
- });
- Route::post('/cache-api', function () {
- $cacheData = Utils::getParamCache(request('menu_code'), request('api_name'));
- if (request('query_name')) {
- $cacheData = Utils::getParamCache(request('menu_code'), request('api_name'), request('query_name'));
- }
- return $cacheData;
- });
- Route::post('/download/report', function () {
- $report = json_decode(request('report'), true);
- switch ($report['type']) {
- case 'pdf':
- $customPaper = array(0, 0, $report['size'], $report['size']);
- $table['head'] = $report['head'];
- $table['body'] = $report['body'];
- $pdf = PDF::loadView('pdf.table', compact('table'))->setPaper($customPaper, 'landscape');
- return $pdf->download("{$report['title']}.pdf");
- case 'excel':
- $report['body'] = collect($report['body'])->prepend($report['head']);
- return Excel::download(new Type1Export($report['body']), "{$report['title']}.xlsx");
- }
- });
- Route::post('/paras', function () {
- $themeDir = request('theme_dir', 'empty');
- $paraType = request('para_type');
- $pathToPara = request('path_to_para');
- $bpa = request('bpa', '');
- try {
- if ($paraType == 'modal') {
- $para = (new Modal($pathToPara, $themeDir))->getData();
- } else if ($paraType == 'formA') {
- $para = (new FormA($bpa, $pathToPara, $themeDir))->getData('data');
- } else if ($paraType == 'formB') {
- $para = (new FormB($bpa, $pathToPara, $themeDir))->getData('data');
- } else if ($paraType == 'manual') {
- $para = (new Manual($pathToPara, $bpa))->getData();
- } else if ($paraType == 'listMedia1') {
- $para = (new ListMedia1($bpa, $pathToPara))->getData('data');
- }
- } catch (Exception $e) {
- return response([
- 'body' => $e->getMessage(),
- 'apiStatus' => 404
- ], 200);
- }
- return $para;
- });
- });
|