diff --git a/config/config.php b/config/config.php new file mode 100644 index 0000000..f49f632 --- /dev/null +++ b/config/config.php @@ -0,0 +1,11 @@ +image_type = $image_info[2]; + if( $this->image_type == IMAGETYPE_JPEG ) { + $this->image = imagecreatefromjpeg($filename); + } elseif( $this->image_type == IMAGETYPE_GIF ) { + $this->image = imagecreatefromgif($filename); + } elseif( $this->image_type == IMAGETYPE_PNG ) { + $this->image = imagecreatefrompng($filename); + } + } + function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) { + if( $image_type == IMAGETYPE_JPEG ) { + imagejpeg($this->image,$filename,$compression); + } elseif( $image_type == IMAGETYPE_GIF ) { + imagegif($this->image,$filename); + } elseif( $image_type == IMAGETYPE_PNG ) { + imagepng($this->image,$filename); + } + if( $permissions != null) { + chmod($filename,$permissions); + } + } + function output($image_type=IMAGETYPE_JPEG) { + if( $image_type == IMAGETYPE_JPEG ) { + imagejpeg($this->image); + } elseif( $image_type == IMAGETYPE_GIF ) { + imagegif($this->image); + } elseif( $image_type == IMAGETYPE_PNG ) { + imagepng($this->image); + } + } + function getWidth() { + return imagesx($this->image); + } + function getHeight() { + return imagesy($this->image); + } + function resizeToHeight($height) { + $ratio = $height / $this->getHeight(); + $width = $this->getWidth() * $ratio; + $this->resize($width,$height); + } + function resizeToWidth($width) { + $ratio = $width / $this->getWidth(); + $height = $this->getheight() * $ratio; + $this->resize($width,$height); + } + function scale($scale) { + $width = $this->getWidth() * $scale/100; + $height = $this->getheight() * $scale/100; + $this->resize($width,$height); + } + function resize($width,$height) { + $new_image = imagecreatetruecolor($width, $height); + imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight()); + $this->image = $new_image; + } +} \ No newline at end of file diff --git a/engine/functions.php b/engine/functions.php new file mode 100644 index 0000000..1b8d9ef --- /dev/null +++ b/engine/functions.php @@ -0,0 +1,26 @@ + renderTemplate($page, $params), + 'menu' => renderTemplate('menu'), + ] + ); +} + +function renderTemplate($page, $params = []){ + ob_start(); + + if (!is_null($params)) + extract($params); + + $fileName = TEMPLATES_DIR . $page . ".php"; + + if (file_exists($fileName)) { + include $fileName; + } else { + Die("Страницы {$fileName} не существует."); + } + + return ob_get_clean(); +} \ No newline at end of file diff --git a/engine/gallery.php b/engine/gallery.php new file mode 100644 index 0000000..643cbd4 --- /dev/null +++ b/engine/gallery.php @@ -0,0 +1,40 @@ +"; + exit; + } + + if ($_FILES['image']['size'] > 1024 * 5 * 1024) { + echo "Размер файла не более 5 Мб
"; + exit; + } + + $blacklist = ['.php', '.phtml', '.php3', '.php4']; + foreach ($blacklist as $item) { + if(preg_match("/$item\$/i", $_FILES['image']['name'])){ + echo "Загрузка php-файлов запрещена
"; + exit; + } + } + + if (move_uploaded_file($_FILES['image']['tmp_name'], $path_big)) { + + $image = new SimpleImage(); + $image->load($path_big); + $image->resizeToWidth(250); + $image->save($path_small); + header("Location: /?page=gallery"); + } else { + echo "Ошибка ресайза файла
"; + } +} \ No newline at end of file diff --git a/engine/log.php b/engine/log.php new file mode 100644 index 0000000..e69de29 diff --git a/public/images/gallery_img/big/n_70.jpg b/public/images/gallery_img/big/n_70.jpg new file mode 100644 index 0000000..d1c5b21 Binary files /dev/null and b/public/images/gallery_img/big/n_70.jpg differ diff --git a/public/images/gallery_img/big/n_72.jpg b/public/images/gallery_img/big/n_72.jpg new file mode 100644 index 0000000..aa1d97c Binary files /dev/null and b/public/images/gallery_img/big/n_72.jpg differ diff --git a/public/images/gallery_img/big/n_73.jpg b/public/images/gallery_img/big/n_73.jpg new file mode 100644 index 0000000..e36fb36 Binary files /dev/null and b/public/images/gallery_img/big/n_73.jpg differ diff --git a/public/images/gallery_img/big/n_76.jpg b/public/images/gallery_img/big/n_76.jpg new file mode 100644 index 0000000..cff5f93 Binary files /dev/null and b/public/images/gallery_img/big/n_76.jpg differ diff --git a/public/images/gallery_img/big/n_82.jpg b/public/images/gallery_img/big/n_82.jpg new file mode 100644 index 0000000..7b92921 Binary files /dev/null and b/public/images/gallery_img/big/n_82.jpg differ diff --git a/public/images/gallery_img/big/n_95.jpg b/public/images/gallery_img/big/n_95.jpg new file mode 100644 index 0000000..b6929b1 Binary files /dev/null and b/public/images/gallery_img/big/n_95.jpg differ diff --git a/public/images/gallery_img/small/n_70.jpg b/public/images/gallery_img/small/n_70.jpg new file mode 100644 index 0000000..3184065 Binary files /dev/null and b/public/images/gallery_img/small/n_70.jpg differ diff --git a/public/images/gallery_img/small/n_72.jpg b/public/images/gallery_img/small/n_72.jpg new file mode 100644 index 0000000..f6105c7 Binary files /dev/null and b/public/images/gallery_img/small/n_72.jpg differ diff --git a/public/images/gallery_img/small/n_73.jpg b/public/images/gallery_img/small/n_73.jpg new file mode 100644 index 0000000..e14dfb8 Binary files /dev/null and b/public/images/gallery_img/small/n_73.jpg differ diff --git a/public/images/gallery_img/small/n_76.jpg b/public/images/gallery_img/small/n_76.jpg new file mode 100644 index 0000000..4a8ee15 Binary files /dev/null and b/public/images/gallery_img/small/n_76.jpg differ diff --git a/public/images/gallery_img/small/n_82.jpg b/public/images/gallery_img/small/n_82.jpg new file mode 100644 index 0000000..0636790 Binary files /dev/null and b/public/images/gallery_img/small/n_82.jpg differ diff --git a/public/images/gallery_img/small/n_95.jpg b/public/images/gallery_img/small/n_95.jpg new file mode 100644 index 0000000..88e8903 Binary files /dev/null and b/public/images/gallery_img/small/n_95.jpg differ diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..f145234 --- /dev/null +++ b/public/index.php @@ -0,0 +1,31 @@ + { + if (e.target.classList.contains('gallery_img')) { + e.target.classList.toggle('active'); + } + }); +} +handleEvents(); \ No newline at end of file diff --git a/public/styles/style.css b/public/styles/style.css new file mode 100644 index 0000000..eee1b7e --- /dev/null +++ b/public/styles/style.css @@ -0,0 +1,227 @@ +@import url(https://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500,500italic,700,700italic,900,900italic); +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +body { + font-family: 'Roboto', Arial, sans-serif; + background-color: #ebebeb; + overflow-x: hidden; + text-align: center; +} + +header { + display: flex; + align-items: center; + justify-content: space-around; + width: 100%; + height: 80px; + background-color: #6b6d79c7; + box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23); +} + +.nav-li { + line-height: 30px; + display: flex; +} + +.nav-ul { + display: flex; +} + +.nav-link:hover { + background-color: rgba(0, 0, 0, 0.1); + cursor: pointer; +} +.nav-link { + font-size: 15px; + font-weight: 300; + text-transform: uppercase; + text-decoration: none; + padding: 8px 10px; + width: 150px; + margin: 2%; + text-align: center; + background-color: #4c4848b8; + color: #fbfbfb; + border-radius: 2px; + transition: background-color 0.2s ease; +} + +.nav-link:hover { + background-color: #212121; + cursor: pointer; +} + +h1 { + font-weight: 100; + margin-bottom: 25px; +} + +p { + text-align: center; + padding: 10px; + color: #aaa; + font-weight: 500; +} + +.container { + margin-top: 50px; + min-width: 900px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; +} + +.block { + margin: 10px; + border: 1px solid black; +} + +.block_flex-wrapper { + padding: 15px; +} + +.block_main { + display: flex; + justify-content: space-between; +} + +.block_exp { + padding: 5px; +} + +.block_exp-border-none { + border-right: none; +} + +.header_3 { + margin: 20px; +} + +.ul-hidden { + display: none; +} + +.hover:hover > .ul-hidden { + display: block; + position: absolute; + top: 65px; +} + +.gallery_wrapper { + display: flex; + justify-content: space-between; + flex-wrap: wrap; + max-width: 900px; + margin-bottom: 70px; +} + +.gallery_img { + width: inherit; + border-radius: 4px; + border: 1px solid black; +} + +.gallery_block { + width: 250px; + margin-bottom: 15px; + -webkit-transition: -webkit-transform 0.7s; + transition: transform 0.7s; +} + +.gallery_block:hover { + -webkit-transform: scale(1.1); + transform: scale(1.1); +} + +.modal { + -webkit-transition: -webkit-transform 0.7s; + transition: transform 0.7s; +} + +.active { + -webkit-transform: scale(2); + transform: scale(2); +} + +.upload_image { + display: flex; + align-items: center; + justify-content: center; + width: 100%; + height: 80px; + background-color: #747578; + box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23); +} + +.form-group { + padding: 1em; + margin: 1em; +} + +input[type="file"] { + outline: 0; + opacity: 0; + pointer-events: none; + user-select: none; +} + +.label { + height: 60px; + width: 190px; + border: 2px dashed #fbfbfb; + border-radius: 5px; + display: flex; + padding: 1em; + align-items: center; + transition: border 300ms ease; + cursor: pointer; + text-align: center; +} +.label i { + display: block; + font-size: 42px; +} +.label i, +.label .title { + font-weight: 400; + color: #fbfbfb; + transition: 200ms color; +} +.label:hover { + border: 2px solid black; +} +.label:hover i, +.label:hover .title { + color: black; +} + +.submit_button:hover { + background-color: rgba(0, 0, 0, 0.1); + cursor: pointer; +} +.submit_button { + border: none; + line-height: 30px; + font-size: 15px; + font-weight: 300; + text-transform: uppercase; + text-decoration: none; + padding: 8px 10px; + width: 150px; + margin: 2%; + text-align: center; + background-color: #4c4848b8; + color: #fbfbfb; + border-radius: 2px; + transition: background-color 0.2s ease; +} + +.submit_button:hover { + background-color: #212121; + cursor: pointer; +} \ No newline at end of file diff --git a/templates/gallery.php b/templates/gallery.php new file mode 100644 index 0000000..808dcb7 --- /dev/null +++ b/templates/gallery.php @@ -0,0 +1,15 @@ + +
+
+ +
+ +
\ No newline at end of file diff --git a/templates/homework_3.php b/templates/homework_3.php new file mode 100644 index 0000000..e69de29 diff --git a/templates/index.php b/templates/index.php new file mode 100644 index 0000000..e69de29 diff --git a/templates/layouts/gallery.php b/templates/layouts/gallery.php new file mode 100644 index 0000000..01e24f2 --- /dev/null +++ b/templates/layouts/gallery.php @@ -0,0 +1,20 @@ + + + + + Галерея + + + + + +
+ +
+
+

Галерея

+ +
+ + \ No newline at end of file diff --git a/templates/layouts/homework_3.php b/templates/layouts/homework_3.php new file mode 100644 index 0000000..2b75a6b --- /dev/null +++ b/templates/layouts/homework_3.php @@ -0,0 +1,17 @@ + + + + + Homework 3 + + + +
+ +
+
+

Домашняя работа №3

+ +
+ + \ No newline at end of file diff --git a/templates/layouts/main.php b/templates/layouts/main.php new file mode 100644 index 0000000..45194d2 --- /dev/null +++ b/templates/layouts/main.php @@ -0,0 +1,17 @@ + + + + + Главная + + + +
+ +
+
+

PHP Курс 1

+ +
+ + \ No newline at end of file diff --git a/templates/menu.php b/templates/menu.php new file mode 100644 index 0000000..9bc5a20 --- /dev/null +++ b/templates/menu.php @@ -0,0 +1,69 @@ + 'Главная', + 'href' => '/', + 'style' => 'nav-li', + 'styleLink' => 'nav-link' + ], + [ + 'title' => 'Дз 3', + 'href' => '?page=homework_3', + 'style' => 'nav-li', + 'hover' => 'hover', + 'styleLink' => 'nav-link', + 'subHidden' => 'ul-hidden', + 'subMenu' => [ + [ + 'title' => 'Задание 1', + 'href' => '?page=task_1', + 'style' => 'nav-li', + 'styleLink' => 'nav-link' + ], + [ + 'title' => 'Задание 2', + 'href' => '?page=task_2', + 'style' => 'nav-li', + 'styleLink' => 'nav-link' + ], + [ + 'title' => 'Задание 3 и 8', + 'href' => '?page=task_3_8', + 'style' => 'nav-li', + 'styleLink' => 'nav-link' + ], + [ + 'title' => 'Задание 4, 5 и 9', + 'href' => '?page=task_4_5_9', + 'style' => 'nav-li', + 'styleLink' => 'nav-link' + ], + ] + ], + [ + 'title' => 'Галерея', + 'href' => '?page=gallery', + 'style' => 'nav-li', + 'styleLink' => 'nav-link' + ] +]; + +function renderMenu($menuList, $params = []) { + $res = ""; + return $res; +} + +echo renderMenu($menuList) +?> \ No newline at end of file diff --git a/templates/task_1.php b/templates/task_1.php new file mode 100644 index 0000000..6971b6e --- /dev/null +++ b/templates/task_1.php @@ -0,0 +1,12 @@ +
+

Задание 1

+
+

С помощью цикла while вывести все числа в промежутке от 0 до 100, которые делятся на 3 без остатка.


+ + + +
+
\ No newline at end of file diff --git a/templates/task_2.php b/templates/task_2.php new file mode 100644 index 0000000..6f81cb7 --- /dev/null +++ b/templates/task_2.php @@ -0,0 +1,19 @@ +
+

Задание 2

+
+

С помощью цикла do…while написать функцию для вывода чисел от 0 до 10.


+ '; + } else if($i & 1) { + echo "{$i} - не чётное
"; + } else { + echo "{$i} - чётное
"; + } + $i++; + } while ( $i <= 10); + ?> +
+
\ No newline at end of file diff --git a/templates/task_3_8.php b/templates/task_3_8.php new file mode 100644 index 0000000..f630f43 --- /dev/null +++ b/templates/task_3_8.php @@ -0,0 +1,53 @@ + [ + 'Москва', + 'Зеленоград', + 'Клин' + ], + 'Ленинградская область' => [ + 'Санкт-Петербург', + 'Всеволожск', + 'Павловск', + 'Кронштадт' + ], + 'Рязанская область' => [ + 'Рязань', + 'Касимов', + 'Скопин', + 'Сасово', + 'Ряжск', + 'Рыбное' + ] + ]; + // знаю, что выводить таким образом - плохой тон, но что-то я так и не понял как мне из цикла извлечь эти переменные и отобразить как мне надо в шаблоне + function printAreas($areas){ + foreach ($areas as $area => $city) { + $city = implode(', ', $city) . "."; + echo "
$area:
"; + echo "
$city

"; + } + } + + + // Города начинающиеся с буквы "К". + + // function printCitiesStartsWithChar($areas){ + // foreach ($areas as $area => $city) { + // echo "
$area:
"; + // foreach ($city as $value) { + // if(preg_match('/^(к|К)/', $value)){ + // echo "
$value

"; + // } + // } + // } + // } +?> +
+

Задания 3 и 8

+
+

Объявить массив, в котором в качестве ключей будут использоваться названия областей, а в качестве значений – массивы с названиями городов из соответствующей области. Вывести в цикле значения массива. + Вывести на экран только города, начинающиеся с буквы «К»


+ +
+
\ No newline at end of file diff --git a/templates/task_4_5_9.php b/templates/task_4_5_9.php new file mode 100644 index 0000000..3a818b5 --- /dev/null +++ b/templates/task_4_5_9.php @@ -0,0 +1,62 @@ + 'а', + 'б' => 'b', + 'в' => 'v', + 'г' => 'g', + 'д' => 'd', + 'е' => 'e', + 'ё' => 'e', + 'ж' => 'j', + 'з' => 'z', + 'и' => 'i', + 'к' => 'k', + 'л' => 'l', + 'м' => 'm', + 'н' => 'n', + 'о' => 'o', + 'п' => 'p', + 'р' => 'r', + 'с' => 's', + 'т' => 't', + 'у' => 'u', + 'ф' => 'f', + 'х' => 'h', + 'ц' => 'c', + 'ч' => '4', + 'ш' => 'sh', + 'щ' => 'shc', + 'ъ' => '', + 'ы' => 'y', + 'ь' => '', + 'э' => 'e', + 'ю' => 'yu', + 'я' => '9', + ' ' => '_' + ]; + } + + function translit($str){ + $dictionary = getDictionary(); + $res = ''; + + for ($i = 0; $i < mb_strLen($str); $i++) { + $char = mb_substr($str, $i, 1); + if (empty($dictionary[$char])) { + $char = mb_strtolower($char); + $res .= mb_strtoupper($dictionary[$char]); + } else { + $res .= $dictionary[$char]; + } + } + return $res; + } +?> +
+

Задание 4, 5 и 9

+
+

Объявить массив, индексами которого являются буквы русского языка, а значениями – соответствующие латинские буквосочетания.


+ +
+
\ No newline at end of file