Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Полнотекстовый поиск #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions 404.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* @var $categories array - Категории из БД
*/
require_once 'init.php';

$page_content = include_template('404.php', Array(
'categories' => $categories,
));

$layout = Array(
'title' => 'Ошибка 404',
'content' => $page_content,
'categories'=> $categories
);

$page = include_template('layout.php', $layout);
echo $page;

5 changes: 2 additions & 3 deletions connection_params.php.dist → ACCESSES.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<?php

$con_params = [
'host' => '127.0.0.1',
'user' => 'root',
'password' => '',
'db_name' => 'yeticave'
'password' => '78vitefe',
'db_name' => 'yeti'
];

return $con_params;
42 changes: 0 additions & 42 deletions Contributing.md

This file was deleted.

56 changes: 1 addition & 55 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,55 +1 @@
# Личный проект «YetiCave»

* Студент: [Михаил Данюшин](https://up.htmlacademy.ru/php/12/user/225742).
* Наставник: [Антон Попов](https://htmlacademy.ru/profile/id78239).

---

**Обратите внимание на файл:**

- [Contributing.md](Contributing.md) — руководство по внесению изменений.

--

_Не удаляйте и не обращайте внимание на файлы:_<br>
_`.editorconfig`, `.gitattributes`, `.gitignore`._

---

### Памятка

#### 1. Зарегистрируйтесь на Гитхабе

Если у вас ещё нет аккаунта на [github.com](https://github.com/join), скорее зарегистрируйтесь.

#### 2. Создайте форк

Откройте репозиторий и нажмите кнопку «Fork» в правом верхнем углу. Репозиторий из Академии будет скопирован в ваш аккаунт.

<img width="769" alt="" src="https://user-images.githubusercontent.com/10909/35516424-ce867188-051c-11e8-86a4-a15271522046.png">

Получится вот так:

<img width="769" alt="" src="https://user-images.githubusercontent.com/10909/35516426-cea57ef2-051c-11e8-8367-5d13468301bf.png">

#### 3. Клонируйте репозиторий на свой компьютер

Будьте внимательны: нужно клонировать свой репозиторий (форк), а не репозиторий Академии. Также обратите внимание, что клонировать репозиторий нужно через SSH, а не через HTTPS. Нажмите зелёную кнопку в правой части экрана, чтобы скопировать SSH-адрес вашего репозитория:

<img width="769" alt="" src="https://user-images.githubusercontent.com/10909/35516427-cec04e08-051c-11e8-8a2f-ae02263585d3.png">

Клонировать репозиторий можно так:

```
git clone SSH-адрес_вашего_форка
```

Команда клонирует репозиторий на ваш компьютер и подготовит всё необходимое для старта работы.

#### 4. Начинайте обучение!

---

<a href="https://htmlacademy.ru/intensive/php"><img align="left" width="50" height="50" alt="HTML Academy" src="https://up.htmlacademy.ru/static/img/intensive/php/logo-for-github-2.png"></a>

Репозиторий создан для обучения на профессиональном онлайн‑курсе «[PHP, уровень 1](https://htmlacademy.ru/intensive/php)» от [HTML Academy](https://htmlacademy.ru).
# Учебный проект по PHP.
102 changes: 74 additions & 28 deletions add.php
Original file line number Diff line number Diff line change
@@ -1,36 +1,82 @@
<?php
/**
* @var $con mysqli - Ресурс соединения
* @var $categories array - Категории из БД
*/

require_once('helpers.php');
require_once('functions.php');
require_once('validation_helpers.php');
require_once 'init.php';
require_once 'validation.php';

$is_auth = 1; //Временно
$user_name = 'Михаил Данюшин';
$title = 'YetiCave || Добавить лот';
$is_need_flatpickr = true;
$con = get_connection();
if(!isset($user)) {
http_response_code(403);
exit();
}

$cats = get_cats($con);

$content_data = ['cats' => $cats];
$args = Array(
'lot-name' => FILTER_SANITIZE_SPECIAL_CHARS,
'category' => FILTER_SANITIZE_NUMBER_INT,
'message' => FILTER_SANITIZE_SPECIAL_CHARS,
'lot-rate' => FILTER_SANITIZE_NUMBER_INT,
'lot-step' => FILTER_SANITIZE_NUMBER_INT,
'lot-date' => FILTER_SANITIZE_SPECIAL_CHARS
);

$page_data = Array(
'categories' => $categories
);

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$data = validate_form($con);
if (array_filter($data, 'filter_err')) {
$content_data['errors'] = array_filter($data, 'filter_err');
} else if (save_user_data($con, array_filter($data, 'filter_values'))) {
header('Location:' . $success_url);
$input = filter_input_array(INPUT_POST, $args);

if ($input) {
$lot_image = $_FILES['lot-img'];
$input['img'] = $lot_image;
$errors = validate_fields($input, $validation_rules);
$errors = array_filter($errors);
if (!empty($errors)) {
$page_data['errors'] = $errors;
} else {
$file_url = save_file($input['img']);

$data = Array(
$input['lot-name'],
$_SESSION['user']['id'],
date('Y-m-d H:m:s'),
$input['category'],
$input['message'],
$file_url,
$input['lot-rate'],
$input['lot-step'],
$input['lot-date']
);
$sql = 'INSERT INTO lots (
title,
user_id,
creation_date,
category_id,
description,
image_url,
initial_cost,
bid_step,
completion_date)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)';

$stmt = db_get_prepare_stmt($GLOBALS['con'], $sql, $data);
mysqli_stmt_execute($stmt);
$id = mysqli_insert_id($GLOBALS['con']);
header('Location: lot.php?id='.$id);
exit();
}
};

$content = include_template('add-lot.php', $content_data);
$layout_data = ['is_auth' => $is_auth,
'content' => $content,
'title' => $title,
'user_name' => $user_name,
'cats' => $cats,
'is_need_flatpickr' => $is_need_flatpickr
];
$layout_content = include_template('layout.php', $layout_data);
print($layout_content);
}

$page_content = include_template('add-lot.php', $page_data);

$layout = Array(
'title' => 'Добавление лота',
'categories'=> $categories,
'content'=>$page_content,
);

$page = include_template('layout.php', $layout);

echo $page;
18 changes: 10 additions & 8 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,14 @@ main.container {
color: #727b7f;
}

.main-header .button {
height: 40px;
padding: 0;
min-width: 130px;
display: inline-grid;
place-items: center;
}

/**/

.user-menu {
Expand Down Expand Up @@ -864,12 +872,6 @@ input:invalid .form__error{
display: block;
}

.form__item--invalid .form__error--image {
display: inline-block;
margin-left: 15px;
}


.form__item--invalid textarea,
.form__item--invalid input {
background: #ffffff url("../img/error.svg") 97% 11px no-repeat;
Expand Down Expand Up @@ -908,15 +910,15 @@ input:invalid .form__error{
display: inline-block;
width: 95px;
box-sizing: border-box;
margin: 0 0 0 0px;
margin: 0 0 0 -4px;
padding: 7px 0 8px 5px;
border: 1px solid #fff;
background: #fff;
text-align: center;
cursor: pointer;
}

.form__input-file label:hover {
.form__input-file:hover label {
background-color: #45abde;
color: #fff;
}
Expand Down
Loading