Skip to content
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
35 changes: 13 additions & 22 deletions AutoindexController/AutoindexController.cpp
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
#include "AutoindexController.hpp"

std::string
AutoindexController::getAutoIndexBody(
std::string _root,
std::string _path)
{
FileController
_folder = FileController(_root + _path, FileController::READ);
std::stringstream
_msg_body;
std::string AutoindexController::getAutoIndexBody(std::string _root, std::string _path) {
FileController _folder = FileController(_root + _path, FileController::READ);
std::stringstream _msg_body;

_msg_body << "<!DOCTYPE html><html><head>";
_msg_body << "<title>Index of " + _path + "</title><link rel=\"icon\" type=\"image/x-icon\" href=\"assets/favicon.ico\" /></head>";
_msg_body << "<body>";
_msg_body << "<h1>Index of " + _path + "</h1><hr><pre>";
for (int _idx = 0; _idx < _folder.getFilesSize(); _idx++)
{
if (_folder.getFiles(_idx)->_name == std::string("."))

for (int _idx = 0; _idx < _folder.getFilesSize(); _idx++) {
if (_folder.getFiles(_idx)->name == std::string("."))
continue ;
std::string
_file_name;
if (_folder.getFiles(_idx)->_type == FileController::DIRECTORY)
_file_name = _folder.getFiles(_idx)->_name + std::string("/");
std::string _file_name;
if (_folder.getFiles(_idx)->type == FileController::DIRECTORY)
_file_name = _folder.getFiles(_idx)->name + std::string("/");
else
_file_name = _folder.getFiles(_idx)->_name;
_file_name = _folder.getFiles(_idx)->name;
std::cout << "Autoindex test : " << _file_name << std::endl;

// _msg_body << "<a href=\"" + _file_name + "\">";

_msg_body << "<a href=\"http://localhost:";
_msg_body << _config._http._server[1]._dir_map["listen"];
_msg_body << _path;
Expand All @@ -39,12 +30,12 @@ std::string
_msg_body << std::setw(53) << std::setfill(' ');
_msg_body << std::left << (_file_name + std::string("</a>"));
_msg_body << std::right;
_msg_body << _folder.getFiles(_idx)->_genr_time;
_msg_body << _folder.getFiles(_idx)->gen_time;
_msg_body << std::setw(20) << std::setfill(' ');
if (_folder.getFiles(_idx)->_type == FileController::DIRECTORY)
if (_folder.getFiles(_idx)->type == FileController::DIRECTORY)
_msg_body << "-" << std::endl;
else
_msg_body << _folder.getFiles(_idx)->_size << std::endl;
_msg_body << _folder.getFiles(_idx)->size << std::endl;
}
_msg_body << "</pre><hr></body></html>";

Expand Down
4 changes: 1 addition & 3 deletions AutoindexController/AutoindexController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ extern NginxConfig::GlobalConfig _config;

class AutoindexController {
public:
static std::string
getAutoIndexBody(
std::string root_path, std::string dir_path);
static std::string getAutoIndexBody(std::string root_path, std::string dir_path);
};

#endif
193 changes: 0 additions & 193 deletions CGI/CGIData.cpp

This file was deleted.

Loading