forked from aslan/applicant-site
Compare commits
6 Commits
9a2d736e04
...
72191cbb16
Author | SHA1 | Date |
---|---|---|
ROMANGOLIENKO | 72191cbb16 | |
aslan | 7a585aa3cd | |
aslan | bf232ef382 | |
aslan | 59689d670e | |
aslan | eb64b3df20 | |
aslan | b5ec4e72f6 |
|
@ -44,23 +44,26 @@ class FileController extends Controller
|
||||||
{
|
{
|
||||||
abort_if(Auth::guest(), 403);
|
abort_if(Auth::guest(), 403);
|
||||||
|
|
||||||
$content = $request->file('url');
|
$nameFile = $request->file('url')->getClientOriginalName();
|
||||||
WorkWithFiles::saveFileToUploads($content);
|
$name = Storage::put('public', $request->file('url'));
|
||||||
$newPath = WorkWithFiles::renameFile($content);
|
|
||||||
|
|
||||||
$url = $request->file('file');
|
|
||||||
$return = Storage::put('file.jpg', $content);
|
|
||||||
dd($return);
|
|
||||||
|
|
||||||
$validated = $request->validated();
|
$validated = $request->validated();
|
||||||
$file = new File();
|
$file = new File();
|
||||||
$file->name = $validated['name'];
|
$file->name = $validated['name'];
|
||||||
$file->url = $newPath;
|
$file->file_name = $nameFile;
|
||||||
|
$file->url = Storage::url($name);
|
||||||
$file->position = $validated['position'];
|
$file->position = $validated['position'];
|
||||||
$file->reception_screen_id = $validated['idReceptionScreen'];
|
$file->reception_screen_id = $validated['idReceptionScreen'];
|
||||||
$file->save();
|
$file->save();
|
||||||
|
|
||||||
return redirect()->route('files.index');
|
return redirect()->route('files.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function download($id)
|
||||||
|
{
|
||||||
|
$file = (new File())->find($id);
|
||||||
|
return Storage::url($file->url);
|
||||||
|
}
|
||||||
public function edit(int $idFile)
|
public function edit(int $idFile)
|
||||||
{
|
{
|
||||||
abort_if(Auth::guest(), 403);
|
abort_if(Auth::guest(), 403);
|
||||||
|
|
|
@ -13,8 +13,9 @@ class File extends Model
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'id',
|
'id',
|
||||||
'name',
|
'name',
|
||||||
|
'file_name',
|
||||||
'url',
|
'url',
|
||||||
'description'
|
'description',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function receptionScreen(): BelongsTo
|
public function receptionScreen(): BelongsTo
|
||||||
|
|
|
@ -93,41 +93,56 @@ class PageScrapper
|
||||||
$links = $content->find('a[href]');
|
$links = $content->find('a[href]');
|
||||||
$srclinks = $content->find('img[src]');
|
$srclinks = $content->find('img[src]');
|
||||||
|
|
||||||
|
|
||||||
$html0 = $content->html();
|
$html0 = $content->html();
|
||||||
|
|
||||||
|
preg_match_all('/<a href="(.*)">/isU', $html0, $arr);
|
||||||
|
foreach ($arr[1] as $el) {
|
||||||
|
$html0 = str_replace($el, urldecode($el), $html0);
|
||||||
|
}
|
||||||
|
preg_match_all('/<img src="(.*)">/isU', $html0, $arr2);
|
||||||
|
foreach ($arr2[1] as $el) {
|
||||||
|
$html0 = str_replace($el, urldecode($el), $html0);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($links as $k => $link) {
|
foreach ($links as $k => $link) {
|
||||||
$href = $link->attr('href');
|
$href = $link->attr('href');
|
||||||
|
|
||||||
if (!str_contains($link->attr('href'), "https://")) {
|
if (!str_contains($link->attr('href'), "https://")) {
|
||||||
|
$unchanged = $link->attr('href');
|
||||||
|
$changed = $link->href = 'https://mkgtu.ru' . $href;
|
||||||
$tmp = explode('/', rawurldecode($href));
|
$html0 = str_replace(urldecode($unchanged), $changed, $html0);
|
||||||
foreach ( $tmp as $k => $v) {
|
|
||||||
$tmp[$k] = rawurlencode($v);
|
|
||||||
}
|
|
||||||
$href = implode('/', $tmp);
|
|
||||||
|
|
||||||
|
|
||||||
$html0 = str_replace($href, 'https://mkgtu.ru' . $href, $html0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach ($srclinks as $k => $srclink) {
|
foreach ($srclinks as $k => $srclink) {
|
||||||
$src = $srclink->attr('src');
|
$src = $srclink->attr('src');
|
||||||
|
|
||||||
if (!str_contains($srclink->attr('src'), "https://")) {
|
if (!str_contains($srclink->attr('src'), "https://")) {
|
||||||
|
$unchanged = $srclink->attr('src');
|
||||||
|
$changed = $srclink->src = 'https://mkgtu.ru' . $src;
|
||||||
$tmp = explode('/', rawurldecode($src));
|
$html0 = str_replace(urldecode($unchanged), $changed, $html0);
|
||||||
foreach ( $tmp as $k => $v) {
|
|
||||||
$tmp[$k] = rawurlencode($v);
|
|
||||||
}
|
|
||||||
$src = implode('/', $tmp);
|
|
||||||
|
|
||||||
|
|
||||||
$html0 = str_replace($src, 'https://mkgtu.ru' . $src, $html0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
str_replace('st yle', 'style', $html0);
|
// foreach ($srclinks as $k => $srclink) {
|
||||||
|
// $src = $srclink->attr('src');
|
||||||
|
//
|
||||||
|
// if (!str_contains($srclink->attr('src'), "https://")) {
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// $tmp = explode('/', rawurldecode($src));
|
||||||
|
// foreach ( $tmp as $k => $v) {
|
||||||
|
// $tmp[$k] = rawurlencode($v);
|
||||||
|
// }
|
||||||
|
// $src = implode('/', $tmp);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// $html0 = str_replace($src, 'https://mkgtu.ru' . $src, $html0);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// str_replace('st yle', 'style', $html0);
|
||||||
|
|
||||||
return $html0;
|
return $html0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,25 +10,26 @@
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.1|8.2",
|
"php": "^8.1|8.2",
|
||||||
"guzzlehttp/guzzle": "^7.8.1",
|
"guzzlehttp/guzzle": "^7.8.1",
|
||||||
"imangazaliev/didom": "^2.0",
|
"imangazaliev/didom": "^2.0.1",
|
||||||
"laravel/framework": "^10.41.0",
|
"laravel/framework": "^10.42.0",
|
||||||
"laravel/sanctum": "^3.3.3",
|
"laravel/sanctum": "^3.3.3",
|
||||||
"laravel/tinker": "^2.9.0",
|
"laravel/tinker": "^2.9.0",
|
||||||
"laravel/ui": "^4.4",
|
"laravel/ui": "^4.4.0",
|
||||||
"laravelcollective/html": "^6.4.1"
|
"laravelcollective/html": "^6.4.1",
|
||||||
|
"league/flysystem": "^3.23.1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"fakerphp/faker": "^1.23.1",
|
"fakerphp/faker": "^1.23.1",
|
||||||
"laravel/breeze": "^1.28.1",
|
"laravel/breeze": "^1.28.1",
|
||||||
"laravel/pint": "^1.13.9",
|
"laravel/pint": "^1.13.10",
|
||||||
"laravel/sail": "^1.27.1",
|
"laravel/sail": "^1.27.2",
|
||||||
"mockery/mockery": "^1.6.7",
|
"mockery/mockery": "^1.6.7",
|
||||||
"nunomaduro/collision": "^7.10.0",
|
"nunomaduro/collision": "^7.10.0",
|
||||||
"phpunit/phpunit": "^10.5.8",
|
"phpunit/phpunit": "^10.5.9",
|
||||||
"spatie/laravel-ignition": "^2.4.1",
|
"spatie/laravel-ignition": "^2.4.1",
|
||||||
"barryvdh/laravel-ide-helper": "^2.13.0",
|
"barryvdh/laravel-ide-helper": "^2.13.0",
|
||||||
"squizlabs/php_codesniffer": "^3.8.1",
|
"squizlabs/php_codesniffer": "^3.8.1",
|
||||||
"phpstan/phpstan": "^1.10.56"
|
"phpstan/phpstan": "^1.10.57"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "5bc9c65b7acd466b9ce68980e20268db",
|
"content-hash": "39967a89029d0be1b3179419bf4d8511",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "brick/math",
|
"name": "brick/math",
|
||||||
|
|
|
@ -14,6 +14,7 @@ return new class extends Migration
|
||||||
Schema::create('files', function (Blueprint $table) {
|
Schema::create('files', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->string('name');
|
$table->string('name');
|
||||||
|
$table->string('file_name');
|
||||||
$table->string('description')->nullable();
|
$table->string('description')->nullable();
|
||||||
$table->string('url');
|
$table->string('url');
|
||||||
$table->integer('position');
|
$table->integer('position');
|
||||||
|
|
|
@ -2,9 +2,8 @@
|
||||||
|
|
||||||
use App\Http\Controllers\FileController;
|
use App\Http\Controllers\FileController;
|
||||||
use App\Http\Controllers\PageController;
|
use App\Http\Controllers\PageController;
|
||||||
use App\Http\Controllers\ReceptionScreenController;
|
|
||||||
use App\Http\Controllers\ProfileController;
|
use App\Http\Controllers\ProfileController;
|
||||||
use App\Http\Controllers\UploadFileController;
|
use App\Http\Controllers\ReceptionScreenController;
|
||||||
use App\Http\Controllers\UserController;
|
use App\Http\Controllers\UserController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
@ -31,6 +30,7 @@ Route::get('/files/create/{file?}', [FileController::class, 'create'])->name('fi
|
||||||
Route::patch('/files/{file}', [FileController::class, 'update'])->name('files.update');
|
Route::patch('/files/{file}', [FileController::class, 'update'])->name('files.update');
|
||||||
Route::delete('files/{file}', [FileController::class, 'destroy'])->name('files.destroy');
|
Route::delete('files/{file}', [FileController::class, 'destroy'])->name('files.destroy');
|
||||||
Route::get('/files/edit/{file}', [FileController::class, 'edit'])->name('files.edit');
|
Route::get('/files/edit/{file}', [FileController::class, 'edit'])->name('files.edit');
|
||||||
|
Route::get('/files/download/{file}', [FileController::class, 'download'])->name('files.download');
|
||||||
|
|
||||||
Route::get('/course', function () {
|
Route::get('/course', function () {
|
||||||
return view('menu.course');
|
return view('menu.course');
|
||||||
|
@ -109,9 +109,6 @@ Route::get('/academic-mobility-and-international-cooperation', function () {
|
||||||
})->name('akademicheskaya-mobilnost-i-mezhdunarodnoe-sotrudnichestvo');
|
})->name('akademicheskaya-mobilnost-i-mezhdunarodnoe-sotrudnichestvo');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Route::post('/uploadfile', [UploadFileController::class, 'showUploadFile'])->name('uploadfile');
|
|
||||||
|
|
||||||
Route::get('/dashboard', function () {
|
Route::get('/dashboard', function () {
|
||||||
return view('admin');
|
return view('admin');
|
||||||
})->middleware(['auth', 'verified'])->name('dashboard');
|
})->middleware(['auth', 'verified'])->name('dashboard');
|
||||||
|
|
Loading…
Reference in New Issue