photos/people.php
2023-08-02 20:14:32 +00:00

79 lines
2.4 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>asxpi // People</title>
<link rel="preconnect" href="https://fonts.gstatic.com">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="navbar">
<div class="container" id="asd">
<div class="logo">
<a href="index.html">
asxpi/<h1>People</h1>
</a>
</div>
<ul class="menu" id="navmenu">
<li>
<a href="nature.php">
NATURE
</a>
</li>
<li>
<a href="people.php">
PEOPLE
</a>
</li>
<li>
<a href="streets.php">
STREETS
</a>
</li>
<li>
<a href="objects.php">
OBJECTS
</a>
</li>
</ul>
</div>
</div>
<div class="pix">
<?php
$directory = 'people'; //название папки с изображениями
$allowed_types=array('jpg','jpeg','gif','png'); //разрешеные типы изображений
$file_parts=array();
$ext='';
$title='';
$i=0;
//пробуем открыть папку
$dir_handle = @opendir($directory) or die("There is an error with your image directory!");
while ($file = readdir($dir_handle)) //поиск по файлам
{
if($file=='.' || $file == '..') continue; //пропустить ссылки на другие папки
$file_parts = explode('.',$file); //разделить имя файла и поместить его в массив
$ext = strtolower(array_pop($file_parts)); //последsний элеменет - это расширение
$title = implode('.',$file_parts);
$title = htmlspecialchars($title);
$nomargin='';
if(in_array($ext,$allowed_types))
{
if(($i+1)%4==0) $nomargin='nomargin'; //последнему изображению в ряде присваевается CSS класс "nomargin"
echo '
<div class="pic '.$nomargin.'" style="background:url('.$directory.'/'.$file.') no-repeat; background-size: cover; background-position: center;">
<a href="'.$directory.'/'.$file.'" title="'.$title.'" target="_blank">'.$title.'</a>
</div>';
$i++;
}
}
closedir($dir_handle); //закрыть папку
?>
</div>
</body>
</html>