Форум по Delphi программированию

Delphi Sources



Вернуться   Форум по Delphi программированию > Все о Delphi > Интернет и сети
Ник
Пароль
Регистрация <<         Правила форума         >> FAQ Пользователи Календарь Поиск Сообщения за сегодня Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
  #4  
Старый 05.09.2009, 16:52
Аватар для Casper-Hacker
Casper-Hacker Casper-Hacker вне форума
Начинающий
 
Регистрация: 19.05.2008
Сообщения: 147
Версия Delphi: x
Репутация: 15
По умолчанию

Код:
procedure TForm1.IdHTTPServer1CommandGet(AThread: TIdPeerThread;
  ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
begin
//INDEX
if (ARequestInfo.Document='') or (ARequestInfo.Document='/') then begin
AResponseInfo.ContentType:='text/html';
IdHTTPServer1.ServeFile(AThread, AResponseinfo,Edit2.Text+'\'+Edit1.Text) end else
//ERROR 404
if (ARequestInfo.Document<>'') or (ARequestInfo.Document<>'/') then
if fileexists(Edit2.Text+'\'+ARequestInfo.Document)=false then
IdHTTPServer1.ServeFile(AThread, AResponseinfo,Edit2.Text+'\'+Edit3.Text) else
//CONTENT TYPE
begin
if Pos('.GIF',ANSIUPPERCASE(ARequestInfo.Document))>0 then AResponseInfo.ContentType:='image/gif'
else if Pos('.JPG',ANSIUPPERCASE(ARequestInfo.Document))>0 then AResponseInfo.ContentType:='image/jpg'
else if Pos('.JPEG',ANSIUPPERCASE(ARequestInfo.Document))>0 then AResponseInfo.ContentType:='image/jpeg'
else if Pos('.BMP',ANSIUPPERCASE(ARequestInfo.Document))>0 then AResponseInfo.ContentType:='image/bmp'
else if Pos('.PNG',ANSIUPPERCASE(ARequestInfo.Document))>0 then AResponseInfo.ContentType:='image/png'
else if (Pos('.HTML',ANSIUPPERCASE(ARequestInfo.Document))>0) or
(Pos('.HTM',ANSIUPPERCASE(ARequestInfo.Document))>0) or
(Pos('.PHP',ANSIUPPERCASE(ARequestInfo.Document))>0) or
(Pos('.CSS',ANSIUPPERCASE(ARequestInfo.Document))>0) or
(Pos('.TXT',ANSIUPPERCASE(ARequestInfo.Document))>0) or
(Pos('.XML',ANSIUPPERCASE(ARequestInfo.Document))>0) or
(Pos('.JS',ANSIUPPERCASE(ARequestInfo.Document))>0) then AResponseInfo.ContentType:='text/html'
else AResponseInfo.ContentType:='application/octet-stream';
IdHTTPServer1.ServeFile(AThread, AResponseinfo,Edit2.Text+'\'+ARequestInfo.Document);
end;

Edit2 - это путь главного каталога. Edit1 - это главный файл (index.htm, index.php). Edit3 - это файл ошибки 404.
Ответить с цитированием
 


Delphi Sources

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать темы
Вы не можете отвечать на сообщения
Вы не можете прикреплять файлы
Вы не можете редактировать сообщения

BB-коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход


Часовой пояс GMT +3, время: 17:36.


 

Сайт

Форум

FAQ

Соглашения

Прочее

 

Copyright © Форум "Delphi Sources" by BrokenByte Software, 2004-2025