From 00d8e51be0719874f2d67532ad30f77721e658a8 Mon Sep 17 00:00:00 2001 From: Holiienko Roman Date: Mon, 22 Jan 2024 11:02:21 +0300 Subject: [PATCH 1/5] changes from "login page redesign" --- resources/views/auth/login.blade.php | 7 +------ .../views/layouts/applicant-layout.blade.php | 18 +----------------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index bd61e94..23893c0 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -44,11 +44,6 @@ - {{--
- @if (Route::has('register')) - Нет аккаунта? - Зарегистрируйтесь - @endif -
--}} + diff --git a/resources/views/layouts/applicant-layout.blade.php b/resources/views/layouts/applicant-layout.blade.php index dd0ab46..1022be4 100644 --- a/resources/views/layouts/applicant-layout.blade.php +++ b/resources/views/layouts/applicant-layout.blade.php @@ -135,23 +135,7 @@ Контакты - {{-- Добавляет на хедер страницы кнопку "вход", имя которой меняется, если вы уже авторизованы -
  • - @if (Route::has('login')) - - @auth - {{ Auth::user()->name }} - @else - Вход - - - - @endauth - - @endif - -
  • - --}} + From 195561c2eb4821bb236fa977a2c8f21d88e814b9 Mon Sep 17 00:00:00 2001 From: Holiienko Roman Date: Mon, 22 Jan 2024 15:31:39 +0300 Subject: [PATCH 2/5] scraping data from mkgtu and making new pages --- resources/views/home.blade.php | 2 +- resources/views/pages/abitur.blade.php | 3 +- resources/views/pages/course.blade.php | 36 ++++++++++++++++++- .../views/pages/web-consultations.blade.php | 36 +++++++++++++++++++ routes/web.php | 4 +++ 5 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 resources/views/pages/web-consultations.blade.php diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 2e3c737..6547279 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -26,7 +26,7 @@
    - +
    diff --git a/resources/views/pages/abitur.blade.php b/resources/views/pages/abitur.blade.php index 64e1f27..f319136 100644 --- a/resources/views/pages/abitur.blade.php +++ b/resources/views/pages/abitur.blade.php @@ -16,7 +16,7 @@ @endsection diff --git a/resources/views/pages/web-consultations.blade.php b/resources/views/pages/web-consultations.blade.php new file mode 100644 index 0000000..4edd57c --- /dev/null +++ b/resources/views/pages/web-consultations.blade.php @@ -0,0 +1,36 @@ +@extends('layouts.applicant-layout') +@section('content') +
    Веб-консультации для абитуриентов и их родителей
    +
    + +
    (.*)<\/div>/isU',$page,$arr); + //echo '
    '.print_r($arr[1]).'
    '; + + + //$tmp = explode("
    " , $page); + //$content = $tmp[4].$tmp[5].$tmp[6]; + + $content = $arr[1][0].'
    '; + $rez = preg_match_all('/href="(.*)"/isU',$content,$arr); + //echo '
    '.print_r($arr,1).'
    '; + foreach ($arr[1] as $el) { + //if (strpos($el, '/abitur') !== false) { + if (strpos($el, 'http') !== 0) { + //str_replace('/abitur', 'https://mkgtu.ru/abitur',$el); + $content = str_replace($el,'https://mkgtu.ru'.$el,$content); + } + } + //$content = $arr[1][0].'
    '; + //$content = preg_replace('/href="(?!http|#)/is', 'https:\/\/mkgtu.ru', $content, -1, $count); + + //$content = str_replace('href="','href="https://mkgtu.ru',$content); + //$pos = strripos($content,'/abitur'); + //echo substr_replace($content, 'https://mkgtu.ru',$pos,0) + + echo $content; + ?> +
    +
    +@endsection diff --git a/routes/web.php b/routes/web.php index 7ed14af..8b83871 100644 --- a/routes/web.php +++ b/routes/web.php @@ -34,6 +34,10 @@ Route::get('/abitur', function () { return view('pages.abitur'); })->name('applicant'); +Route::get('/web-consultations', function () { + return view('pages.web-consultations'); +})->name('web-consultations'); + Route::post('/uploadfile', [UploadFileController::class, 'showUploadFile'])->name('uploadfile'); Route::get('/dashboard', function () { From 574e300006adbe427fff1f4aa55a8bdc1ad1b51f Mon Sep 17 00:00:00 2001 From: Holiienko Roman Date: Mon, 22 Jan 2024 15:53:10 +0300 Subject: [PATCH 3/5] adding menu/*section* logic in file system --- config/auth.php | 2 +- config/database.php | 4 ++-- config/session.php | 2 +- config/view.php | 2 +- resources/views/{pages => menu}/abitur.blade.php | 0 .../{pages => menu/abitur}/web-consultations.blade.php | 0 resources/views/{pages => menu}/course.blade.php | 0 routes/web.php | 6 +++--- 8 files changed, 8 insertions(+), 8 deletions(-) rename resources/views/{pages => menu}/abitur.blade.php (100%) rename resources/views/{pages => menu/abitur}/web-consultations.blade.php (100%) rename resources/views/{pages => menu}/course.blade.php (100%) diff --git a/config/auth.php b/config/auth.php index 9548c15..4fa3d6d 100644 --- a/config/auth.php +++ b/config/auth.php @@ -24,7 +24,7 @@ return [ |-------------------------------------------------------------------------- | | Next, you may define every authentication guard for your application. - | Of course, a great default configuration has been defined for you + | Of abitur, a great default configuration has been defined for you | here which uses session storage and the Eloquent user provider. | | All authentication drivers have a user provider. This defines how the diff --git a/config/database.php b/config/database.php index 137ad18..580947f 100644 --- a/config/database.php +++ b/config/database.php @@ -10,7 +10,7 @@ return [ |-------------------------------------------------------------------------- | | Here you may specify which of the database connections below you wish - | to use as your default connection for all database work. Of course + | to use as your default connection for all database work. Of abitur | you may use many connections at once using the Database library. | */ @@ -23,7 +23,7 @@ return [ |-------------------------------------------------------------------------- | | Here are each of the database connections setup for your application. - | Of course, examples of configuring each database platform that is + | Of abitur, examples of configuring each database platform that is | supported by Laravel is shown below to make development simple. | | diff --git a/config/session.php b/config/session.php index e738cb3..2698d3d 100644 --- a/config/session.php +++ b/config/session.php @@ -80,7 +80,7 @@ return [ |-------------------------------------------------------------------------- | | When using the "database" session driver, you may specify the table we - | should use to manage the sessions. Of course, a sensible default is + | should use to manage the sessions. Of abitur, a sensible default is | provided for you; however, you are free to change this as needed. | */ diff --git a/config/view.php b/config/view.php index 22b8a18..4942d72 100644 --- a/config/view.php +++ b/config/view.php @@ -8,7 +8,7 @@ return [ |-------------------------------------------------------------------------- | | Most templating systems load templates from disk. Here you may specify - | an array of paths that should be checked for your views. Of course + | an array of paths that should be checked for your views. Of abitur | the usual Laravel view path has already been registered for you. | */ diff --git a/resources/views/pages/abitur.blade.php b/resources/views/menu/abitur.blade.php similarity index 100% rename from resources/views/pages/abitur.blade.php rename to resources/views/menu/abitur.blade.php diff --git a/resources/views/pages/web-consultations.blade.php b/resources/views/menu/abitur/web-consultations.blade.php similarity index 100% rename from resources/views/pages/web-consultations.blade.php rename to resources/views/menu/abitur/web-consultations.blade.php diff --git a/resources/views/pages/course.blade.php b/resources/views/menu/course.blade.php similarity index 100% rename from resources/views/pages/course.blade.php rename to resources/views/menu/course.blade.php diff --git a/routes/web.php b/routes/web.php index 8b83871..7592924 100644 --- a/routes/web.php +++ b/routes/web.php @@ -27,15 +27,15 @@ Route::resources([ ]); Route::get('/course', function () { - return view('pages.course'); + return view('menu.course'); })->name('course'); Route::get('/abitur', function () { - return view('pages.abitur'); + return view('menu.abitur'); })->name('applicant'); Route::get('/web-consultations', function () { - return view('pages.web-consultations'); + return view('menu.abitur.web-consultations'); })->name('web-consultations'); Route::post('/uploadfile', [UploadFileController::class, 'showUploadFile'])->name('uploadfile'); From 10d18f6bf3e1fbf16c0dfc13e1b646cf6e084922 Mon Sep 17 00:00:00 2001 From: Holiienko Roman Date: Mon, 22 Jan 2024 17:08:45 +0300 Subject: [PATCH 4/5] adding new service PageScrapper.php --- app/Services/PageScrapper.php | 59 +++++++++++++++++++ .../menu/abitur/web-consultations.blade.php | 34 +++-------- 2 files changed, 67 insertions(+), 26 deletions(-) create mode 100644 app/Services/PageScrapper.php diff --git a/app/Services/PageScrapper.php b/app/Services/PageScrapper.php new file mode 100644 index 0000000..ac858df --- /dev/null +++ b/app/Services/PageScrapper.php @@ -0,0 +1,59 @@ +') + { + $this->url = $url; + $this->contentMarker = $contentMarker; + } + + public function getHTML() + { +// echo($this->url); +// echo($this->contentMarker); + $page = file_get_contents($this->url); + $strForPregMatch = "/" . "{$this->contentMarker}" . "(.*)<\/div>/isU"; + $arr = []; + $rez = preg_match_all($strForPregMatch, $page, $arr); + //echo '
    '.print_r($arr[1]).'
    '; + + + //$tmp = explode("
    " , $page); + //$content = $tmp[4].$tmp[5].$tmp[6]; + + + + + return $content = $arr[1][0].'
    '; + + } + + public function normalizeURLFile($content) + { + + + $rez = preg_match_all('/href="(.*)"/isU',$content,$arr); + //echo '
    '.print_r($arr,1).'
    '; + foreach ($arr[1] as $el) { + //if (strpos($el, '/abitur') !== false) { + if (strpos($el, 'http') !== 0) { + //str_replace('/abitur', 'https://mkgtu.ru/abitur',$el); + $content = str_replace($el,'https://mkgtu.ru'.$el,$content); + } + } + //$content = $arr[1][0].''; + //$content = preg_replace('/href="(?!http|#)/is', 'https:\/\/mkgtu.ru', $content, -1, $count); + + //$content = str_replace('href="','href="https://mkgtu.ru',$content); + //$pos = strripos($content,'/abitur'); + //echo substr_replace($content, 'https://mkgtu.ru',$pos,0) + + return $content; + } +} diff --git a/resources/views/menu/abitur/web-consultations.blade.php b/resources/views/menu/abitur/web-consultations.blade.php index 4edd57c..efaa0a8 100644 --- a/resources/views/menu/abitur/web-consultations.blade.php +++ b/resources/views/menu/abitur/web-consultations.blade.php @@ -3,34 +3,16 @@
    Веб-консультации для абитуриентов и их родителей
    -
    (.*)<\/div>/isU',$page,$arr); - //echo '
    '.print_r($arr[1]).'
    '; +
    +@php + use App\Services\PageScrapper; + $pageScrapper = new PageScrapper("https://www.mkgtu.ru/postuplenie/web-consultations/", '
    '); + $row = $pageScrapper->getHTML(); + $content = $pageScrapper->normalizeURLFile($row); + echo $content; + @endphp - //$tmp = explode("
    " , $page); - //$content = $tmp[4].$tmp[5].$tmp[6]; - - $content = $arr[1][0].'
    '; - $rez = preg_match_all('/href="(.*)"/isU',$content,$arr); - //echo '
    '.print_r($arr,1).'
    '; - foreach ($arr[1] as $el) { - //if (strpos($el, '/abitur') !== false) { - if (strpos($el, 'http') !== 0) { - //str_replace('/abitur', 'https://mkgtu.ru/abitur',$el); - $content = str_replace($el,'https://mkgtu.ru'.$el,$content); - } - } - //$content = $arr[1][0].'
    '; - //$content = preg_replace('/href="(?!http|#)/is', 'https:\/\/mkgtu.ru', $content, -1, $count); - - //$content = str_replace('href="','href="https://mkgtu.ru',$content); - //$pos = strripos($content,'/abitur'); - //echo substr_replace($content, 'https://mkgtu.ru',$pos,0) - - echo $content; - ?>
    @endsection From f65fbda4a70c88f78f06db13d81bf0da4d43f5ef Mon Sep 17 00:00:00 2001 From: Holiienko Roman Date: Tue, 23 Jan 2024 11:05:43 +0300 Subject: [PATCH 5/5] fixing previous commit --- app/Services/PageScrapper.php | 23 ------ config/auth.php | 2 +- config/database.php | 4 +- config/session.php | 2 +- config/view.php | 2 +- resources/views/menu/course.blade.php | 105 ++------------------------ 6 files changed, 13 insertions(+), 125 deletions(-) diff --git a/app/Services/PageScrapper.php b/app/Services/PageScrapper.php index ac858df..bd86bad 100644 --- a/app/Services/PageScrapper.php +++ b/app/Services/PageScrapper.php @@ -15,45 +15,22 @@ class PageScrapper public function getHTML() { -// echo($this->url); -// echo($this->contentMarker); $page = file_get_contents($this->url); $strForPregMatch = "/" . "{$this->contentMarker}" . "(.*)<\/div>/isU"; $arr = []; $rez = preg_match_all($strForPregMatch, $page, $arr); - //echo '
    '.print_r($arr[1]).'
    '; - - - //$tmp = explode("
    " , $page); - //$content = $tmp[4].$tmp[5].$tmp[6]; - - - - return $content = $arr[1][0].''; } public function normalizeURLFile($content) { - - $rez = preg_match_all('/href="(.*)"/isU',$content,$arr); - //echo '
    '.print_r($arr,1).'
    '; foreach ($arr[1] as $el) { - //if (strpos($el, '/abitur') !== false) { if (strpos($el, 'http') !== 0) { - //str_replace('/abitur', 'https://mkgtu.ru/abitur',$el); $content = str_replace($el,'https://mkgtu.ru'.$el,$content); } } - //$content = $arr[1][0].''; - //$content = preg_replace('/href="(?!http|#)/is', 'https:\/\/mkgtu.ru', $content, -1, $count); - - //$content = str_replace('href="','href="https://mkgtu.ru',$content); - //$pos = strripos($content,'/abitur'); - //echo substr_replace($content, 'https://mkgtu.ru',$pos,0) - return $content; } } diff --git a/config/auth.php b/config/auth.php index 4fa3d6d..9548c15 100644 --- a/config/auth.php +++ b/config/auth.php @@ -24,7 +24,7 @@ return [ |-------------------------------------------------------------------------- | | Next, you may define every authentication guard for your application. - | Of abitur, a great default configuration has been defined for you + | Of course, a great default configuration has been defined for you | here which uses session storage and the Eloquent user provider. | | All authentication drivers have a user provider. This defines how the diff --git a/config/database.php b/config/database.php index 580947f..137ad18 100644 --- a/config/database.php +++ b/config/database.php @@ -10,7 +10,7 @@ return [ |-------------------------------------------------------------------------- | | Here you may specify which of the database connections below you wish - | to use as your default connection for all database work. Of abitur + | to use as your default connection for all database work. Of course | you may use many connections at once using the Database library. | */ @@ -23,7 +23,7 @@ return [ |-------------------------------------------------------------------------- | | Here are each of the database connections setup for your application. - | Of abitur, examples of configuring each database platform that is + | Of course, examples of configuring each database platform that is | supported by Laravel is shown below to make development simple. | | diff --git a/config/session.php b/config/session.php index 2698d3d..e738cb3 100644 --- a/config/session.php +++ b/config/session.php @@ -80,7 +80,7 @@ return [ |-------------------------------------------------------------------------- | | When using the "database" session driver, you may specify the table we - | should use to manage the sessions. Of abitur, a sensible default is + | should use to manage the sessions. Of course, a sensible default is | provided for you; however, you are free to change this as needed. | */ diff --git a/config/view.php b/config/view.php index 4942d72..22b8a18 100644 --- a/config/view.php +++ b/config/view.php @@ -8,7 +8,7 @@ return [ |-------------------------------------------------------------------------- | | Most templating systems load templates from disk. Here you may specify - | an array of paths that should be checked for your views. Of abitur + | an array of paths that should be checked for your views. Of course | the usual Laravel view path has already been registered for you. | */ diff --git a/resources/views/menu/course.blade.php b/resources/views/menu/course.blade.php index af7c928..05fdcd0 100644 --- a/resources/views/menu/course.blade.php +++ b/resources/views/menu/course.blade.php @@ -29,109 +29,20 @@ background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg width='16' height='16' xmlns='http://www.w3.org/2000/svg' fill='%230c63e4'%3e%3cg%3e%3ctitle%3eLayer 1%3c/title%3e%3cpath fill='%23396849' fill-rule='evenodd' d='m1.646,4.646a0.5,0.5 0 0 1 0.708,0l5.646,5.647l5.646,-5.647a0.5,0.5 0 0 1 0.708,0.708l-6,6a0.5,0.5 0 0 1 -0.708,0l-6,-6a0.5,0.5 0 0 1 0,-0.708z' id='svg_1'/%3e%3c/g%3e%3c/svg%3e"); } - - - - - -
    Подача документов онлайн
    -
    (.*)<\/div>/isU',$page,$arr); - //echo '
    '.print_r($arr[1]).'
    '; +
    + @php + use App\Services\PageScrapper; + $pageScrapper = new PageScrapper("https://www.mkgtu.ru/postuplenie/web-consultations/", '
    '); + $row = $pageScrapper->getHTML(); + $content = $pageScrapper->normalizeURLFile($row); + echo $content; + @endphp - //$tmp = explode("
    " , $page); - //$content = $tmp[4].$tmp[5].$tmp[6]; - - $content = $arr[1][0].'
    '; - $rez = preg_match_all('/href="(.*)"/isU',$content,$arr); - //echo '
    '.print_r($arr,1).'
    '; - foreach ($arr[1] as $el) { - //if (strpos($el, '/abitur') !== false) { - if (strpos($el, 'http') !== 0) { - //str_replace('/abitur', 'https://mkgtu.ru/abitur',$el); - $content = str_replace($el,'https://mkgtu.ru'.$el,$content); - } - } - //$content = $arr[1][0].'
    '; - //$content = preg_replace('/href="(?!http|#)/is', 'https:\/\/mkgtu.ru', $content, -1, $count); - - //$content = str_replace('href="','href="https://mkgtu.ru',$content); - //$pos = strripos($content,'/abitur'); - //echo substr_replace($content, 'https://mkgtu.ru',$pos,0) - - echo $content; - ?>