Skip to content
Permalink
Browse files

Photo album

  • Loading branch information...
ivashkevitch committed Apr 3, 2018
1 parent a069b98 commit 50081a71c59feb80687e2a6eaf4a4e1fce041539
Showing with 41 additions and 25 deletions.
  1. +14 −14 www/index.php
  2. +1 −1 www/login.php
  3. +5 −0 www/logout.php
  4. +21 −10 www/upload.php
@@ -1,20 +1,20 @@
<?php
require __DIR__ . '/auth.php';
$login = getUserLogin();
?>
<html>
<head>
<title>Главная страница</title>
<title>Фотоальбом</title>
</head>
<body>
<?php if ($login === null): ?>
<a href="/www/login.php">Авторизуйтесь</a>
<?php else: ?>
Добро пожаловать, <?= $login ?>
<br>
<a href="/logout.php">Выйти</a>
<?php endif; ?>
<?php
$files = scandir(__DIR__ . '/uploads');
$links = [];
foreach ($files as $fileName) {
if ($fileName === '.' || $fileName === '..') {
continue;
}
$links[] = 'http://myproject.loc/uploads/' . $fileName;
}
foreach ($links as $link):?>
<a href="<?= $link ?>"><img src="<?= $link ?>" height="80px"></a>
<?php endforeach; ?>
</body>
</html>
@@ -26,7 +26,7 @@
</span>
<?php endif; ?>

<form action="/www/login.php" method="post">
<form action="/login.php" method="post">
<label for="login">Имя пользователя: </label><input type="text" name="login" id="login">
<br>
<label for="password">Пароль: </label><input type="password" name="password" id="password">
@@ -0,0 +1,5 @@
<?php
setcookie('login', '', -10, '/');
setcookie('password', '', -10, '/');
header('Location: /index.php');
@@ -1,5 +1,9 @@
<?php
if (!empty($_FILES['attachment'])) {
require __DIR__ . '/auth.php';
$login = getUserLogin();
if ($login !== null && !empty($_FILES['attachment'])) {
$file = $_FILES['attachment'];
$srcFileName = $file['name'];
@@ -25,15 +29,22 @@
<title>Загрузка файла</title>
</head>
<body>
<?php if (!empty($error)): ?>
<?= $error ?>
<?php elseif (!empty($result)): ?>
<?= $result ?>
<?php if ($login === null): ?>
<a href="/login.php">Авторизуйтесь</a>
<?php else: ?>
Добро пожаловать, <?= $login ?> |
<a href="/logout.php">Выйти</a>
<br>
<?php if (!empty($error)): ?>
<?= $error ?>
<?php elseif (!empty($result)): ?>
<?= $result ?>
<?php endif; ?>
<br>
<form action="/upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="attachment">
<input type="submit">
</form>
<?php endif; ?>
<br>
<form action="/upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="attachment">
<input type="submit">
</form>
</body>
</html>

0 comments on commit 50081a7

Please sign in to comment.
You can’t perform that action at this time.