Merge remote-tracking branch 'origin/fara' into roman

This commit is contained in:
3lswear
2022-02-20 20:07:47 +03:00
51 changed files with 15989 additions and 86 deletions

77
config/def.toml Normal file
View File

@@ -0,0 +1,77 @@
[[server]]
name = "localhost"
host = "127.0.0.1"
port = 8080
body_size_limit = 100
[server.error_page]
403 = "www/def/errorFolder/error_403.html"
404 = "www/def/errorFolder/error_404.html"
405 = "www/def/errorFolder/error_405.html"
[[server.location]]
location = "/"
root = "www/def/"
methods = ["GET"]
autoindex = true
directory_file = "index.html"
[[server.location]]
location = "/put_file"
root = "www/def/upload"
body_size_limit = 1000000000
methods = ["PUT", "GET"]
autoindex = true
upload_dir = "www/def/upload/"
upload_accept = true
[[server.location]]
location = "/delete_file"
root = "www/def/upload"
methods = ["DELETE"]
[[server.location]]
location = "/docs"
root = "www/def/docs"
methods = ["GET"]
autoindex = true
[[server.location]]
location = "/document"
redirect = ["301", "http://localhost:8080/docs/$request_file"]
[[server.location]]
location = "/cgi-bin"
root = "www/def/script"
methods = ["GET", "POST"]
directory_file = "cgi_default.html"
[[server.location]]
location = "*.php"
cgi_pass = "/bin/php-cgi"
[[server.location]]
location = "/script"
redirect = ["301", "http://localhost:8080/cgi-bin/$request_file"]
[[server.location]]
location = "*.jpeg"
root = "www/def/images/jpegImg"
methods = ["GET"]
[[server.location]]
location = "*.png"
root = "www/def/images/pngImg"
methods = ["GET"]
[[server]]
name = "pohek1.org"
host = "127.0.0.1"
port = 8080
body_size_limit = 100
[server.error_page]
404 = "www/def/errorFolder/error_404.html"
[[server.location]]
location = "/"
root = "www/def/"
methods = ["GET"]
directory_file = "index.html"
[[server.location]]
location = "/cgi-bin"
root = "www/def/script"
methods = ["GET", "POST"]
directory_file = "cgi_default.html"
[[server.location]]
location = "*.php"
cgi_pass = "/bin/php-cgi"
[[server.location]]
location = "/script"
redirect = ["301", "http://localhost:8080/cgi-bin"]

View File

@@ -4,18 +4,18 @@
port = 8080 # check num, (0, 65536)
body_size_limit = 10000000 #(pofig and > 0)
[server.error_page]
"404" = "www/errorFolder/error_404.html" # throw exception if not string
"404" = "www/real/errorFolder/error_404.html" # throw exception if not string
[[server.location]]
location = "/" # mandatory
root = "www/" # check valid
root = "www/real/" # check valid
methods = ["GET", "POST", "DELETE"]
autoindex = true #check if bool
directory_file = "index.html"
upload_accept = true #throw exception if not bool
upload_dir = "www/upload" # check valid
upload_dir = "www/real/upload" # check valid
[[server.location]]
location = "/images"
root = "www/images"
root = "www/real/images"
methods = ["GET"]
autoindex = true
[[server.location]]
@@ -26,20 +26,20 @@
redirect = ["301", "http://127.0.0.1:8080/168.png"]
[[server.location]]
location = "*.jpeg"
root = "www/images/jpegImg"
root = "www/real/images/jpegImg"
methods = ["GET", "PUT"]
[[server.location]]
location = "*.png"
root = "www/images/pngImg"
root = "www/real/images/pngImg"
methods = ["GET"]
[[server.location]]
location = "/errorFolder"
root = "www/errorFolder"
root = "www/real/errorFolder"
methods = ["GET", "POST"]
autoindex = true
[[server.location]]
location = "*.php"
root = "www/script"
root = "www/real/script"
autoindex = false
cgi_pass = "/usr/bin/php-cgi" #check valid
[[server]]
@@ -59,7 +59,7 @@
autoindex = true
directory_file = "index.html"
upload_accept = false
upload_dir = "www/upload"
upload_dir = "www/real/upload"
[[server]]
name = "localhost"
host = "127.0.0.1"
@@ -77,4 +77,4 @@
autoindex = true
directory_file = "index.html"
upload_accept = false
upload_dir = "www/upload"
upload_dir = "www/real/upload"

View File

@@ -1,70 +0,0 @@
[[server]]
name = "Edu"
host = "127.0.0.1"
port = 8080
body_size_limit = 100000
[server.error_page]
400 = "/var/www/poheck/Edu/errorPages/error_400.html"
403 = "/var/www/poheck/Edu/errorPages/error_403.html"
404 = "/var/www/poheck/Edu/errorPages/error_404.html"
[[server.location]]
location = "/"
root = "/var/www/poheck/Edu/"
methods = ["GET"]
autoindex = false
directory_file = "index.html"
[[server.location]]
location = "/errorlist"
root = "/var/www/poheck/Edu/errorPages/"
methods = ["GET"]
autoindex = false
directory_file = "this.html"
[[server.location]]
location = "/images"
root = "/var/www/poheck/Edu/images/"
methods = ["GET", "POST", "DELETE"]
autoindex = true
directory_file = "oops.html"
[[server.location]]
location = "/cats"
root = "/var/www/poheck/Edu/images/cats/"
methods = ["GET", "POST", "DELETE"]
autoindex = true
[[server.location]]
location = "/dogs"
root = "/var/www/poheck/Edu/images/dogs/"
methods = ["GET", "POST", "DELETE"]
autoindex = true
[[server.location]]
location = "/docs"
root = "/var/www/poheck/Edu/docs/"
redirect = ["301","http::/127.0.0.1::8080/documents"]
[[server.location]]
location = "/documents"
root = "/var/www/poheck/Edu/documents/"
methods = ["GET", "DELETE"]
autoindex = true
upload_accept = true
upload_dir = "/var/www/poheck/Edu/upload/"
[[server.location]]
location = "/upload"
root = "/var/www/poheck/Edu/upload/"
methods = ["POST", "DELETE"]
autoindex = true
upload_accept = true
upload_dir = "/var/www/poheck/Edu/upload/"
[[server]]
name = "2222"
host = "localhost"
port = 8081
body_size_limit = 65356
[server.error_page]
404 = "/var/www/poheck/errorPages/error_404.html"
[[server.location]]
location = "/root2/"
root = "/var/www/html/jopa.html"
methods = ["GET", "POST"]
autoindex = true
directory_file = "its_a_directory.html"
upload_accept = false
upload_dir = "/var/www/html/upload"

View File

@@ -5,26 +5,27 @@
body_size_limit = 100000000
[[server.location]]
location = "/"
root = "tester/"
root = "www/tester/"
methods = ["GET"]
autoindex = true
directory_file = "index.html"
[[server.location]]
location = "/put_test"
root = "tester/"
root = "www/tester/"
methods = ["PUT"]
autoindex = true
upload_dir = "tester/upload_here/"
upload_accept = true
upload_dir = "www/tester/upload_here/"
[[server.location]]
location = "*.bla"
cgi_pass = "ubuntu_cgi_tester"
[[server.location]]
location = "/post_body"
root = "tester/"
root = "www/tester/"
methods = ["POST"]
body_size_limit = 100
[[server.location]]
location = "/directory"
methods = ["GET"]
root = "tester/YoupiBanane/"
root = "www/tester/YoupiBanane/"
directory_file = "youpi.bad_extension"

View File

@@ -118,7 +118,16 @@ void Response::setCacheControl(void)
void Response::setLocation(void)
{
if (_code == 301)
_locationSTR = _location->redirect[_code];
{
_redirect_location = _location->redirect[_code];
unsigned long pos = _redirect_location.rfind("$request_file");
if (pos != std::string::npos)
{
_redirect_location.erase(pos);
_redirect_location += _request_file;
}
_locationSTR = _redirect_location;
}
}
serverListen Response::getListen()
@@ -237,6 +246,7 @@ std::string Response::getFullURI(void)
int pos = 0;
pos = _request.getURI().rfind("/");
tmp = _request.getURI().substr(pos);
_request_file = tmp;
if (!_location->uploadDir.empty())
_upload_dir = _location->uploadDir + tmp;
tmp = _location->root + tmp;
@@ -244,6 +254,7 @@ std::string Response::getFullURI(void)
else
{
tmp = _request.getURI().substr(len);
_request_file = tmp;
if (!_location->uploadDir.empty())
_upload_dir = _location->uploadDir + tmp;
tmp = _location->root + tmp;
@@ -380,6 +391,8 @@ void Response::generate2(serverListen &l)
bool Response::isRedirect()
{
if (_location == NULL)
return (false);
if (!_location->redirect.empty())
{
_code = 301;
@@ -464,6 +477,12 @@ void Response::methodPost(void)
void Response::methodPut(void)
{
_code = 201;
if (!_location->uploadAccept)
{
_code = 403;
invalidClient();
return;
}
if (_request.isFile(_upload_dir) == 0)
_code = 204;
std::ofstream file(_upload_dir.c_str(), std::ios::out | std::ios::binary);

View File

@@ -22,6 +22,9 @@ private:
serverListen _hostPort;
std::string _method;
std::string _request_file;
std::string _redirect_location;
private:
std::string _contentType;
ssize_t _contentLength;

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

View File

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

View File

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 381 KiB

After

Width:  |  Height:  |  Size: 381 KiB

View File

@@ -0,0 +1 @@
Please select the required program to run.

15492
www/real/docs/Voina_i_mir.txt Normal file

File diff suppressed because one or more lines are too long

BIN
www/real/docs/rfc2818.pdf Normal file

Binary file not shown.

View File

@@ -0,0 +1,7 @@
<html>
<head><title>403 Forbidden</title></head>
<body>
<center><h1>403 Forbidden</h1></center>
<hr><center>Poheck/1.0.0 (Ubuntu)</center>
</body>
</html>

View File

@@ -0,0 +1,7 @@
<html>
<head><title>404 Not Found</title></head>
<body background="../images/jpegImg/index.jpeg">
<center><h1>404 Not Found</h1></center>
<hr><center>Poheck/1.0.0 (Ubuntu)</center>
</body>
</html>

View File

@@ -0,0 +1,7 @@
<html>
<head><title>405 Method Not Allowed</title></head>
<body>
<center><h1>405 Method Not Allowed</h1></center>
<hr><center>Poheck/1.0.0 (Ubuntu)</center>
</body>
</html>

View File

@@ -0,0 +1,164 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8" />
<title>Название сайта</title>
</head>
<body>
<!--Создаём таблицу контейнер, которой задаём следующее
оформление:
border="1" - рамка вокруг контейнера. Увеличив число, можно увеличить толщину рамки.
align="center" - размещаем контейнер по центру экрана.
rules="rows" - убираем двойную рамку.
style="width:60%;" - добавляем стилевое свойства, делающее
контейнер и весь сайт "резиновым".
Сделать полноценный адаптивный дизайн, этим способом невозможно.-->
<table
border="1"
align="center"
rules="rows"
style="width:60%;">
<!--Создаём строку-->
<tr>
<!--Создаём ячейку строки-->
<td>
<!--ШАПКА САЙТА-->
<!--В ячейке строки создаём ещё одну таблицу для шапки сайта.
Оформление:
border="1" - двойная рамка толщиной в 1px
background="images/168.png" - картинка в шапке сайта, если требуется.
Адрес картинки вы должны вставить свой.
bgcolor="#7FFFD4" - фоновый цвет в шапке, если нет картинки.
cellpadding="10" - отступ содержимого от рамки не менее 10px.
style="width:100%; border-radius:5px;" - добавляем "резиновость"
и закругляем уголки рамки-->
<table
border="1"
background="images/168.png"
bgcolor="#7FFFD4"
cellpadding="10"
style="width:100%; border-radius:5px;">
<!--Создаём строку таблицы-->
<tr>
<!--Создаём столбец таблицы-->
<th>
<!--Содержание ячейки столбца-->
<h1>Название сайта (организации)</h1>
<h3>Описание сайта</h3>
<!--Закрываем таблицу-->
</th>
</tr>
</table>
<!--ОСНОВНОЙ КОНТЕНТ-->
<!--В этой же ячейке контейнера создаём ещё одну таблицу
для основного контента.
Оформление как и в предыдущей таблице-->
<table
border="1"
bgcolor="#e6e6fa"
cellpadding="10"
style="width:100%; border-radius:5px;">
<!--Создаём строку-->
<tr>
<!--Создаём ячейку
Оформление:
rowspan="2" - объединяем две ячейки в одну.
Число объединяемых ячеек по числу ячеек в сайдбаре.
style="width:80%" - основной контент занимает 80% всей площади,
оставшиеся 20% для сайдбара-->
<td
rowspan="2"
style="width:80%">
<h2>Страница</h2>
<!--Начинаем абзац с красной строки-->
<p style="text-indent:20px">
Здравствуйте уважаемые будущие веб-мастера!
Мне 55 лет и я рад приветствовать Вас на своём сайте.
Этот сайт первый, который я разработал самостоятельно,
а до этого умел только входить в интернет.</p>
<p style="text-indent:20px">Почему я решил его сделать?
За те 3 месяца, пока разбирался в
сайтостроении и создавал этот ресурс обнаружилось,
что авторы руководств по созданию
сайтов считают многие нюансы само собой разумеющимися
и не обращают на них внимание
А мне, учитывая возраст и «опыт», было не просто
понять как раз эти нюансы, они отнимали больше всего
времени.</p>
<!--Закрываем ячейку-->
</td>
<!--САЙДБАР-->
<!--Создаём ячейку сайдбара-->
<td bgcolor="#e6e6fa">
<h3>Меню</h3>
<!--Абзац для ссылки на страницу сайта-->
<p>
<!--Ссылка на страницу сайта-->
<a href="">
<!--Картинка маркера перед названием страницы-->
<img src="http://trueimages.ru/img/00/06/f4fffdb5.png">
<!--Название страницы
style="margin-left:5px;" - отступ названия от маркера-->
<span style="margin-left:5px;">Страница</span></a>
<!--Закрываем абзац-->
</p>
<p>
<a href="">
<img src="http://trueimages.ru/img/31/ab/4dcb087c2ae4305edcd15171696.jpg">
<span style="margin-left:5px;">Страница 1</span;></a>
</p>
<p>
<a href="">
<img src="http://trueimages.ru/img/31/ab/4dcb087c2ae4305edcd15171696.jpg">
<span style="margin-left:5px;">Страница 2</span></a>
</p>
<!--Закрываем строку Меню-->
</td>
</tr>
<!--Создаём строку с дополнительной информацией-->
<tr>
<!--Ячейка с дополнительной информацией-->
<td
bgcolor="#e6e6fa"
align="center">
<h3>Общая информация</h3>
<p>Текст общей информации или реклама</p>
<!--Закрываем ячейку с общей информацией
и таблицу основного контента-->
</td>
</tr>
</table>
<!--ПОДВАЛ-->
<!--Создаём таблицу подвала-->
<table
border="1"
bgcolor="#7FFFD4"
height="100"
cellpadding="10"
style="width:100%; border-radius:5px;">
<!--Создаём строку.-->
<tr>
<!--Создаём столбец-->
<th>
<h3>Подвал</h3>
<!--Закрываем таблицу подвала. При желании в подвале можно
сделать несколько строк и столбцов-->
</th>
</tr>
</table>
<!--Закрываем таблицу контейнера-->
</td>
</tr>
</table>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 KiB

164
www/real/index.html Normal file
View File

@@ -0,0 +1,164 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8" />
<title>Название сайта</title>
</head>
<body>
<!--Создаём таблицу контейнер, которой задаём следующее
оформление:
border="1" - рамка вокруг контейнера. Увеличив число, можно увеличить толщину рамки.
align="center" - размещаем контейнер по центру экрана.
rules="rows" - убираем двойную рамку.
style="width:60%;" - добавляем стилевое свойства, делающее
контейнер и весь сайт "резиновым".
Сделать полноценный адаптивный дизайн, этим способом невозможно.-->
<table
border="1"
align="center"
rules="rows"
style="width:60%;">
<!--Создаём строку-->
<tr>
<!--Создаём ячейку строки-->
<td>
<!--ШАПКА САЙТА-->
<!--В ячейке строки создаём ещё одну таблицу для шапки сайта.
Оформление:
border="1" - двойная рамка толщиной в 1px
background="images/168.png" - картинка в шапке сайта, если требуется.
Адрес картинки вы должны вставить свой.
bgcolor="#7FFFD4" - фоновый цвет в шапке, если нет картинки.
cellpadding="10" - отступ содержимого от рамки не менее 10px.
style="width:100%; border-radius:5px;" - добавляем "резиновость"
и закругляем уголки рамки-->
<table
border="1"
background="images/168.png"
bgcolor="#7FFFD4"
cellpadding="10"
style="width:100%; border-radius:5px;">
<!--Создаём строку таблицы-->
<tr>
<!--Создаём столбец таблицы-->
<th>
<!--Содержание ячейки столбца-->
<h1>Название сайта (организации)</h1>
<h3>Описание сайта</h3>
<!--Закрываем таблицу-->
</th>
</tr>
</table>
<!--ОСНОВНОЙ КОНТЕНТ-->
<!--В этой же ячейке контейнера создаём ещё одну таблицу
для основного контента.
Оформление как и в предыдущей таблице-->
<table
border="1"
bgcolor="#e6e6fa"
cellpadding="10"
style="width:100%; border-radius:5px;">
<!--Создаём строку-->
<tr>
<!--Создаём ячейку
Оформление:
rowspan="2" - объединяем две ячейки в одну.
Число объединяемых ячеек по числу ячеек в сайдбаре.
style="width:80%" - основной контент занимает 80% всей площади,
оставшиеся 20% для сайдбара-->
<td
rowspan="2"
style="width:80%">
<h2>Страница</h2>
<!--Начинаем абзац с красной строки-->
<p style="text-indent:20px">
Здравствуйте уважаемые будущие веб-мастера!
Мне 55 лет и я рад приветствовать Вас на своём сайте.
Этот сайт первый, который я разработал самостоятельно,
а до этого умел только входить в интернет.</p>
<p style="text-indent:20px">Почему я решил его сделать?
За те 3 месяца, пока разбирался в
сайтостроении и создавал этот ресурс обнаружилось,
что авторы руководств по созданию
сайтов считают многие нюансы само собой разумеющимися
и не обращают на них внимание
А мне, учитывая возраст и «опыт», было не просто
понять как раз эти нюансы, они отнимали больше всего
времени.</p>
<!--Закрываем ячейку-->
</td>
<!--САЙДБАР-->
<!--Создаём ячейку сайдбара-->
<td bgcolor="#e6e6fa">
<h3>Меню</h3>
<!--Абзац для ссылки на страницу сайта-->
<p>
<!--Ссылка на страницу сайта-->
<a href="">
<!--Картинка маркера перед названием страницы-->
<img src="http://trueimages.ru/img/00/06/f4fffdb5.png">
<!--Название страницы
style="margin-left:5px;" - отступ названия от маркера-->
<span style="margin-left:5px;">Страница</span></a>
<!--Закрываем абзац-->
</p>
<p>
<a href="">
<img src="http://trueimages.ru/img/31/ab/4dcb087c2ae4305edcd15171696.jpg">
<span style="margin-left:5px;">Страница 1</span;></a>
</p>
<p>
<a href="">
<img src="http://trueimages.ru/img/31/ab/4dcb087c2ae4305edcd15171696.jpg">
<span style="margin-left:5px;">Страница 2</span></a>
</p>
<!--Закрываем строку Меню-->
</td>
</tr>
<!--Создаём строку с дополнительной информацией-->
<tr>
<!--Ячейка с дополнительной информацией-->
<td
bgcolor="#e6e6fa"
align="center">
<h3>Общая информация</h3>
<p>Текст общей информации или реклама</p>
<!--Закрываем ячейку с общей информацией
и таблицу основного контента-->
</td>
</tr>
</table>
<!--ПОДВАЛ-->
<!--Создаём таблицу подвала-->
<table
border="1"
bgcolor="#7FFFD4"
height="100"
cellpadding="10"
style="width:100%; border-radius:5px;">
<!--Создаём строку.-->
<tr>
<!--Создаём столбец-->
<th>
<h3>Подвал</h3>
<!--Закрываем таблицу подвала. При желании в подвале можно
сделать несколько строк и столбцов-->
</th>
</tr>
</table>
<!--Закрываем таблицу контейнера-->
</td>
</tr>
</table>
</body>
</html>

14
www/real/script/index.php Normal file
View File

@@ -0,0 +1,14 @@
<?php
phpinfo();
// echo ("Content-type:text/html\r\n\r\n");
// echo ("<html>\n");
// echo ("<head>\n");
// echo ("<title>Hello World - First CGI Program</title>\n");
// echo ("</head>\n");
// echo ("<body>\n");
// echo ("<h2>Hello World! This is my first CGI program</h2>\n");
// echo ("</body>\n");
// echo ("</html>\n");
?>

View File

@@ -0,0 +1,17 @@
<?php
header('Content-type: image/png', true);
$entityBody = file_get_contents('php://input');
echo($entityBody);
// phpinfo();
// echo ("Content-type:text/html\r\n\r\n");
// echo ("<html>\n");
// echo ("<head>\n");
// echo ("<title>Hello World - First CGI Program</title>\n");
// echo ("</head>\n");
// echo ("<body>\n");
// echo ("<h2>Hello World! This is my first CGI program</h2>\n");
// echo ("</body>\n");
// echo ("</html>\n");
?>