Skip to content

Commit d1938fe

Browse files
author
Famaxis
committed
v 1.2 (more comments, deleted unused methods)
1 parent a1f7240 commit d1938fe

File tree

7 files changed

+12
-16
lines changed

7 files changed

+12
-16
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@
1818
+ авторизация теперь осуществляется через проверку юзера из базы данных, а не из файла конфига, и через email, а не login;
1919
+ добавлена регистрация новых пользователей, хеширование паролей включено;
2020
+ при первом запуске главной страницы автоматически создаётся таблица пользователей и добавляется демо-аккаунт, теперь не нужно качать никаких дампов базы;
21-
+ создан свой шаблон с каруселью на Bootstrap 4 в двух версиях — тёмной и светлой. В некоторых местах использовались готовые сниппеты.
21+
+ создан свой шаблон с каруселью на Bootstrap 4 в двух версиях — тёмной и светлой. В некоторых местах использовались готовые сниппеты;
22+
+ на странице логина (а также регистрации) ошибки выводятся средствами php, а не javascript.

app/base/Controller.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ public function __construct($route)
2020
$this->model = $this->loadModel($route['controller']);
2121
}
2222

23-
public function redirect($url)
24-
{
25-
header('location: ' . $url);
26-
exit;
27-
}
28-
2923
public function loadModel($name)
3024
{
3125
$path = 'app\models\\' . ucfirst($name);

app/base/View.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ public function render($title, $vars = [])
2626
}
2727
}
2828

29+
// render error pages
2930
public static function error($code)
3031
{
3132
http_response_code($code);
3233
$path = 'app/views/errors/' . $code . '.php';
3334
if (file_exists($path)) {
34-
// require $path;
3535
ob_start();
3636
require $path;
3737
$content = ob_get_clean();
@@ -40,6 +40,7 @@ public static function error($code)
4040
exit;
4141
}
4242

43+
// messages in form.js
4344
public function message($status, $message)
4445
{
4546
exit(json_encode(['status' => $status, 'message' => $message]));
@@ -49,10 +50,4 @@ public function location($url)
4950
{
5051
exit(json_encode(['url' => $url]));
5152
}
52-
53-
public function redirect($url)
54-
{
55-
header('location: /'.$url);
56-
exit;
57-
}
5853
}

app/config/db.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55
'dbname' => 'landing_mvc',
66
'username' => 'root',
77
'password' => '',
8-
];
8+
];
9+
10+
// more settings in app/base/Database in method __construct()

app/config/routes.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
// urls
34
return [
45
'' => [
56
'controller' => 'main',

app/models/Main.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class Main extends Model
1010
{
1111
public $error;
1212

13+
// login form on page /login
1314
public function emailValidate()
1415
{
1516
$query = $this->db->checkEmail();
@@ -21,6 +22,7 @@ public function emailValidate()
2122
}
2223
}
2324

25+
// contact form on main page
2426
public function contactValidate()
2527
{
2628
$nameLength = strlen($_POST['name']);

app/models/User.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,16 @@ public function createTable()
2929
$this->db->query($sql);
3030
}
3131

32+
// creates demo user
3233
public function fillTable()
3334
{
34-
// demo user
3535
$password = password_hash('1234', PASSWORD_DEFAULT);
3636
$sql = 'INSERT INTO users (login, email, password)
3737
VALUES(:login, :email, :password)';
3838
$this->db->query($sql, ['login' => 'admin', 'email' => '[email protected]', 'password' => $password]);
3939
}
4040

41+
// register users
4142
public function addUser()
4243
{
4344
$password = password_hash($_POST['password'], PASSWORD_DEFAULT);

0 commit comments

Comments
 (0)