1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-05 18:13:12 +02:00

+- Commited the web server prototype made by Stskeeps, web design by WildChild

This commit is contained in:
stskeeps
2001-07-14 21:04:16 +00:00
parent 9b6a674d9c
commit a4b63af2e1
21 changed files with 1358 additions and 0 deletions
+1
View File
@@ -687,3 +687,4 @@ seen. gmtime warning still there
- Documentation bug fix
- Changed version to -beta1
- Various preparitions for beta1
- Commited the web server prototype made by Stskeeps, web design by WildChild
Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

+107
View File
@@ -0,0 +1,107 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title>
$ TITLE
</title>
<style type="text/css" media="screen">
<!--
BODY, TABLE {
scrollbar-base-color : Black;
scrollbar-3d-light-color : #D3D3D3;
scrollbar-dark-shadow-color : #D3D3D3;
scrollbar-shadow-color : #D3D3D3;
scrollbar-highlight-color : #D3D3D3;
scrollbar-arrow-color : Black;
scrollbar-face-color : #D3D3D3;
background-color : #FFFFFF;
font-size : 8pt;
font-family : "Trebuchet MS", Arial, Tahoma;
}
BODY, TABLE, DIV {
scrollbar-base-color : Black;
scrollbar-3d-light-color : #D3D3D3;
scrollbar-dark-shadow-color : #D3D3D3;
scrollbar-shadow-color : #D3D3D3;
scrollbar-highlight-color : #D3D3D3;
scrollbar-arrow-color : Black;
scrollbar-face-color : #D3D3D3;
font-size : 8pt;
font-family : "Trebuchet MS", Arial, Tahoma;
}
SELECT, .textbox {
font-family : "Trebuchet MS", Arial, Tahoma;
font-size : 8pt;
scrollbar-base-color : Black;
scrollbar-3d-light-color : #D3D3D3;
scrollbar-dark-shadow-color : #D3D3D3;
scrollbar-shadow-color : #D3D3D3;
scrollbar-highlight-color : #D3D3D3;
scrollbar-arrow-color : Black;
scrollbar-face-color : #D3D3D3;
border : 1px solid #D3D3D3;
background-color : #F4f4F4;
}
.button {
font-family : Tahoma;
border : 1px solid #C8C8C8;
font-size : 11px;
cursor : hand;
background-color : #E5E5E5;
}
#background { position: absolute; z-index: 0; top: 0px; left: 0px; width: 800px; height: 600px; visibility: visible }
#buttons { position: absolute; top: 420px; left: 6px; width: 470px; height: 21px; visibility: visible }
#content { position: absolute; top: 77px; left: 133px; width: 399px; height: 283px; visibility: visible }
#unrealIRCdLink { font-size: 8pt; font-family: "Trebuchet MS", Arial, Tahoma; position: absolute; top: 364px; left: 559px; width: 89px; height: 16px; visibility: visible; scrollbar-3d-light-color: #D3D3D3; scrollbar-arrow-color: Black; scrollbar-base-color: Black; scrollbar-dark-shadow-color: #D3D3D3; scrollbar-face-color: #D3D3D3; scrollbar-highlight-color: #D3D3D3; scrollbar-shadow-color: #D3D3D3 }
#background { position: absolute; z-index: -10; top: 0px; left: 0px; width: 800px; height: 600px; visibility: visible }
#icon { z-index: 1; font-size: 8pt; font-family: "Trebuchet MS", Arial, Tahoma; position: absolute; top: 13px; left: 22px; width: 72px; height: 73px; visibility: visible; scrollbar-3d-light-color: #D3D3D3; scrollbar-arrow-color: Black; scrollbar-base-color: Black; scrollbar-dark-shadow-color: #D3D3D3; scrollbar-face-color: #D3D3D3; scrollbar-highlight-color: #D3D3D3; scrollbar-shadow-color: #D3D3D3 }
#button1img {z-index: 1; font-size: 8pt; font-family: "Trebuchet MS", Arial, Tahoma; position: absolute; top: 150px; left: 11px; width: 111px; height: 23px; visibility: visible; scrollbar-3d-light-color: #D3D3D3; scrollbar-arrow-color: Black; scrollbar-base-color: Black; scrollbar-dark-shadow-color: #D3D3D3; scrollbar-face-color: #D3D3D3; scrollbar-highlight-color: #D3D3D3; scrollbar-shadow-color: #D3D3D3 }
#button1text { font-size: 8pt; font-family: "Trebuchet MS", Arial, Tahoma; position: absolute; z-index: 2; top: 150px; left: 11px; width: 111px; height: 23px; visibility: visible; scrollbar-3d-light-color: #D3D3D3; scrollbar-arrow-color: Black; scrollbar-base-color: Black; scrollbar-dark-shadow-color: #D3D3D3; scrollbar-face-color: #D3D3D3; scrollbar-highlight-color: #D3D3D3; scrollbar-shadow-color: #D3D3D3; padding: 1px; }
#button2img {z-index: 1; font-size: 8pt; font-family: "Trebuchet MS", Arial, Tahoma; position: absolute; top: 180px; left: 11px; width: 111px; height: 23px; visibility: visible; scrollbar-3d-light-color: #D3D3D3; scrollbar-arrow-color: Black; scrollbar-base-color: Black; scrollbar-dark-shadow-color: #D3D3D3; scrollbar-face-color: #D3D3D3; scrollbar-highlight-color: #D3D3D3; scrollbar-shadow-color: #D3D3D3 }
#button2text { font-size: 8pt; font-family: "Trebuchet MS", Arial, Tahoma; position: absolute; z-index: 2; top: 180px; left: 11px; width: 111px; height: 23px; visibility: visible; scrollbar-3d-light-color: #D3D3D3; scrollbar-arrow-color: Black; scrollbar-base-color: Black; scrollbar-dark-shadow-color: #D3D3D3; scrollbar-face-color: #D3D3D3; scrollbar-highlight-color: #D3D3D3; scrollbar-shadow-color: #D3D3D3; padding: 1px; }
</style>
</head>
<body bgcolor="#ffffff" text="black" link="black" vlink="black" alink="black">
<div id="button1img" OnClick="location.href='/section/opers'" onMouseOver="document.body.style.cursor = 'hand'; document.button1.src='/sections/active.gif';" onMouseOut="document.body.style.cursor = 'auto'; document.button1.src='/sections/inactive.gif';"> <img src="/sections/inactive.gif" name="button1" border="0"></div>
<div id="button1text" align="center" OnClick="location.href='/section/opers'" onMouseOver="document.body.style.cursor = 'hand'; document.button1.src='../sections/active.gif';" onMouseOut="document.body.style.cursor = 'auto'; document.button1.src='../sections/inactive.gif';">Operators</div>
<div id="button2img" OnClick="location.href='/section/stats'" onMouseOver="document.body.style.cursor = 'hand'; document.button2.src='/sections/active.gif';" onMouseOut="document.body.style.cursor = 'auto'; document.button2.src='/sections/inactive.gif';"> <img src="/sections/inactive.gif" name="button2" border="0"></div>
<div id="button2text" align="center" OnClick="location.href='/section/stats'" onMouseOver="document.body.style.cursor = 'hand'; document.button2.src='/sections/active.gif';" onMouseOut="document.body.style.cursor = 'auto'; document.button2.src='/sections/inactive.gif';">Stats</div>
<div id="icon">
<img
$ ICON
width="72" height="73" border="0"></div>
<div id="background">
<img src="/back/background.jpg" width="650" height="450" border="0">
<div id="unrealIRCdLink">
<a target="_blank"href="http://www.unrealircd.com/" onMouseOver="document.unreallink.src='/unrealircd.com/active.gif';" onMouseOut="document.unreallink.src='/unrealircd.com/inactive.gif';"> <img src="/unrealircd.com/inactive.gif" name="unreallink" border="0"> </a> </div>
</div>
<div id="buttons">
<div align="left">
<input type="submit" class="textbox" name="submitButtonName" value="save and close"> <input class="textbox" type="submit" name="submitButtonName" value="discard and close"> <input class="textbox" type="submit" name="submitButtonName" value="reset to original values"></div>
</div>
<div id="content">
<div align="left">
<i><font size="+2">
$ SECTION
</font></i>
<p></p>
</div>
<div align="center">
<table border="1" cellpadding="20" cellspacing="0" width="309" height="161" borderColorDark="black" borderColorLight="black">
<tr>
<td borderColorDark="#ffffff" borderColorLight="#ffffff">
$ DATA
</td>
</tr>
</table>
</div>
<p></p>
</div>
<p></p>
</body>
</html>
+107
View File
@@ -0,0 +1,107 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title>UnrealIRCdConfig</title>
<style type="text/css" media="screen">
<!--
BODY, TABLE {
scrollbar-base-color : Black;
scrollbar-3d-light-color : #D3D3D3;
scrollbar-dark-shadow-color : #D3D3D3;
scrollbar-shadow-color : #D3D3D3;
scrollbar-highlight-color : #D3D3D3;
scrollbar-arrow-color : Black;
scrollbar-face-color : #D3D3D3;
background-color : #FFFFFF;
font-size : 8pt;
font-family : "Trebuchet MS", Arial, Tahoma;
}
BODY, TABLE, DIV {
scrollbar-base-color : Black;
scrollbar-3d-light-color : #D3D3D3;
scrollbar-dark-shadow-color : #D3D3D3;
scrollbar-shadow-color : #D3D3D3;
scrollbar-highlight-color : #D3D3D3;
scrollbar-arrow-color : Black;
scrollbar-face-color : #D3D3D3;
font-size : 8pt;
font-family : "Trebuchet MS", Arial, Tahoma;
}
SELECT, .textbox {
font-family : "Trebuchet MS", Arial, Tahoma;
font-size : 8pt;
scrollbar-base-color : Black;
scrollbar-3d-light-color : #D3D3D3;
scrollbar-dark-shadow-color : #D3D3D3;
scrollbar-shadow-color : #D3D3D3;
scrollbar-highlight-color : #D3D3D3;
scrollbar-arrow-color : Black;
scrollbar-face-color : #D3D3D3;
border : 1px solid #D3D3D3;
background-color : #F4f4F4;
}
.button {
font-family : Tahoma;
border : 1px solid #C8C8C8;
font-size : 11px;
cursor : hand;
background-color : #E5E5E5;
}
#background { position: absolute; z-index: 0; top: 0px; left: 0px; width: 800px; height: 600px; visibility: visible }
#buttons { position: absolute; top: 420px; left: 6px; width: 470px; height: 21px; visibility: visible }
#content { position: absolute; top: 77px; left: 133px; width: 399px; height: 283px; visibility: visible }
#unrealIRCdLink { font-size: 8pt; font-family: "Trebuchet MS", Arial, Tahoma; position: absolute; top: 364px; left: 559px; width: 89px; height: 16px; visibility: visible; scrollbar-3d-light-color: #D3D3D3; scrollbar-arrow-color: Black; scrollbar-base-color: Black; scrollbar-dark-shadow-color: #D3D3D3; scrollbar-face-color: #D3D3D3; scrollbar-highlight-color: #D3D3D3; scrollbar-shadow-color: #D3D3D3 }
#background { position: absolute; z-index: -10; top: 0px; left: 0px; width: 800px; height: 600px; visibility: visible }
#icon { z-index: 1; font-size: 8pt; font-family: "Trebuchet MS", Arial, Tahoma; position: absolute; top: 13px; left: 22px; width: 72px; height: 73px; visibility: visible; scrollbar-3d-light-color: #D3D3D3; scrollbar-arrow-color: Black; scrollbar-base-color: Black; scrollbar-dark-shadow-color: #D3D3D3; scrollbar-face-color: #D3D3D3; scrollbar-highlight-color: #D3D3D3; scrollbar-shadow-color: #D3D3D3 }
#button1img {z-index: 1; font-size: 8pt; font-family: "Trebuchet MS", Arial, Tahoma; position: absolute; top: 150px; left: 11px; width: 111px; height: 23px; visibility: visible; scrollbar-3d-light-color: #D3D3D3; scrollbar-arrow-color: Black; scrollbar-base-color: Black; scrollbar-dark-shadow-color: #D3D3D3; scrollbar-face-color: #D3D3D3; scrollbar-highlight-color: #D3D3D3; scrollbar-shadow-color: #D3D3D3 }
#button1text { font-size: 8pt; font-family: "Trebuchet MS", Arial, Tahoma; position: absolute; z-index: 2; top: 150px; left: 11px; width: 111px; height: 23px; visibility: visible; scrollbar-3d-light-color: #D3D3D3; scrollbar-arrow-color: Black; scrollbar-base-color: Black; scrollbar-dark-shadow-color: #D3D3D3; scrollbar-face-color: #D3D3D3; scrollbar-highlight-color: #D3D3D3; scrollbar-shadow-color: #D3D3D3; padding: 1px; }
#button2img {z-index: 1; font-size: 8pt; font-family: "Trebuchet MS", Arial, Tahoma; position: absolute; top: 180px; left: 11px; width: 111px; height: 23px; visibility: visible; scrollbar-3d-light-color: #D3D3D3; scrollbar-arrow-color: Black; scrollbar-base-color: Black; scrollbar-dark-shadow-color: #D3D3D3; scrollbar-face-color: #D3D3D3; scrollbar-highlight-color: #D3D3D3; scrollbar-shadow-color: #D3D3D3 }
#button2text { font-size: 8pt; font-family: "Trebuchet MS", Arial, Tahoma; position: absolute; z-index: 2; top: 180px; left: 11px; width: 111px; height: 23px; visibility: visible; scrollbar-3d-light-color: #D3D3D3; scrollbar-arrow-color: Black; scrollbar-base-color: Black; scrollbar-dark-shadow-color: #D3D3D3; scrollbar-face-color: #D3D3D3; scrollbar-highlight-color: #D3D3D3; scrollbar-shadow-color: #D3D3D3; padding: 1px; }
</style>
</head>
<body bgcolor="#ffffff" text="black" link="black" vlink="black" alink="black">
<div id="button1img" OnClick="location.href='http://www.whatever.org'" onMouseOver="document.body.style.cursor = 'hand'; document.button1.src='../sections/active.gif';" onMouseOut="document.body.style.cursor = 'auto'; document.button1.src='../sections/inactive.gif';"> <img src="../sections/inactive.gif" name="button1" border="0"></div>
<div id="button1text" align="center" OnClick="location.href='http://www.whatever.org'" onMouseOver="document.body.style.cursor = 'hand'; document.button1.src='../sections/active.gif';" onMouseOut="document.body.style.cursor = 'auto'; document.button1.src='../sections/inactive.gif';">Operators</div>
<div id="button2img" OnClick="location.href='http://www.whatever.org'" onMouseOver="document.body.style.cursor = 'hand'; document.button2.src='../sections/active.gif';" onMouseOut="document.body.style.cursor = 'auto'; document.button2.src='../sections/inactive.gif';"> <img src="../sections/inactive.gif" name="button2" border="0"></div>
<div id="button2text" align="center" OnClick="location.href='http://www.whatever.org'" onMouseOver="document.body.style.cursor = 'hand'; document.button2.src='../sections/active.gif';" onMouseOut="document.body.style.cursor = 'auto'; document.button2.src='../sections/inactive.gif';">Stats</div>
<div id="icon">
<img src="../icons/opers.jpg" width="72" height="73" border="0"></div>
<div id="background">
<img src="../back/background.jpg" width="650" height="450" border="0">
<div id="unrealIRCdLink">
<a target="_blank"href="http://www.unrealircd.com/" onMouseOver="document.unreallink.src='../unrealircd.com/active.gif';" onMouseOut="document.unreallink.src='../unrealircd.com/inactive.gif';"> <img src="../unrealircd.com/inactive.gif" name="unreallink" border="0"> </a> </div>
</div>
<div id="buttons">
<div align="left">
<input type="submit" class="textbox" name="submitButtonName" value="save and close"> <input class="textbox" type="submit" name="submitButtonName" value="discard and close"> <input class="textbox" type="submit" name="submitButtonName" value="reset to original values"></div>
</div>
<div id="content">
<div align="left">
<i><font size="+2">Section Title </font></i>
<p></p>
</div>
<div align="center">
<table border="1" cellpadding="20" cellspacing="0" width="309" height="161" borderColorDark="black" borderColorLight="black">
<tr>
<td borderColorDark="#ffffff" borderColorLight="#ffffff">
<p><input type="radio" value="radioValue" name="default">Radio one <input type="radio" value="radioValue" name="default">Radio two</p>
<p><select name="selectName" size="4" multiple>
<option value="one">First</option>
<option value="two">Second</option>
<option value="three">Third</option>
</select></p>
<p><input class="textbox" type="text" name="textfieldName" size="24" value="Textbox to enter text values"></p>
</td>
</tr>
</table>
</div>
<p></p>
</div>
<p></p>
</body>
</html>
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

+56
View File
@@ -0,0 +1,56 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title>loader</title>
<csactions>
<csaction name="3093F4DA0" class="Open Window" type="onevent" val0="/section/opers" val1="" val2="650" val3="450" val4="false" val5="false" val6="false" val7="false" val8="false" val9="false" val10="false">
</csactions>
<csscriptdict>
<script><!--
function CSClickReturn () {
var bAgent = window.navigator.userAgent;
var bAppName = window.navigator.appName;
if ((bAppName.indexOf("Explorer") >= 0) && (bAgent.indexOf("Mozilla/3") >= 0) && (bAgent.indexOf("Mac") >= 0))
return true; // dont follow link
else return false; // dont follow link
}
CSStopExecution = false;
function CSAction(array) {
return CSAction2(CSAct, array);
}
function CSAction2(fct, array) {
var result;
for (var i=0;i<array.length;i++) {
if(CSStopExecution) return false;
var actArray = fct[array[i]];
if(actArray == null) return false;
var tempArray = new Array;
for(var j=1;j<actArray.length;j++) {
if((actArray[j] != null) && (typeof(actArray[j]) == "object") && (actArray[j].length == 2)) {
if(actArray[j][0] == "VAR") {
tempArray[j] = CSStateArray[actArray[j][1]];
}
else {
if(actArray[j][0] == "ACT") {
tempArray[j] = CSAction(new Array(new String(actArray[j][1])));
}
else
tempArray[j] = actArray[j];
}
}
else
tempArray[j] = actArray[j];
}
result = actArray[0](tempArray);
}
return result;
}
CSAct = new Object;
function CSOpenWindow(action) {
var wf = "";
wf = wf + "width=" + action[3];
wf = wf + ",height=" + action[4];
wf = wf + ",resizable=" + (action[5] ? "yes" : "no");
wf = wf + ",scrollbars=" + (action[6] ? "yes" : "no");
Binary file not shown.

After

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 B

+64
View File
@@ -0,0 +1,64 @@
/*
UnrealIRCd internal webserver - httpd.h
Copyright (c) 2001, The UnrealIRCd Team
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions
and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
and the following disclaimer in the documentation and/or other materials provided with the
distribution.
* Neither the name of the The UnrealIRCd Team nor the names of its contributors may be used
to endorse or promote products derived from this software without specific prior written permission.
* The source code may not be redistributed for a fee or in closed source
programs, without expressed oral consent by the UnrealIRCd Team, however
for operating systems where binary distribution is required, if URL
is passed with the package to get the full source
* No warranty is given unless stated so by the The UnrealIRCd Team
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
typedef struct _httpd_header HTTPd_Header;
struct _httpd_header
{
char *name;
char *value;
HTTPd_Header *next;
};
typedef struct _httpd_request HTTPd_Request;
struct _httpd_request
{
SOCKET fd;
char inbuf[1024];
short pos;
/* 0 = gimme head request 1 = getting head */
unsigned state : 2;
/* 1 = GET 0 = POST */
unsigned method : 1;
char *url;
HTTPd_Header *headers;
long content_length;
HTTPd_Header *dataheaders;
};
char *GetField(HTTPd_Header *header, char *name);
char *GetHeader(HTTPd_Request *request, char *name);
void httpd_standard_header(HTTPd_Request *request, char *type);
void httpd_badrequest(HTTPd_Request *request, char *reason);
void sockprintf(SOCKET fd, char *format, ...);
void httpd_sendfile(HTTPd_Request *r, char *filename);
+5
View File
@@ -91,5 +91,10 @@ scan_socks.so: scan_socks.c $(INCLUDES)
$(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \
-o scan_socks.so scan_socks.c
web/httpd.so: web/httpd.c web/u_stats.c web/vfs.c web/phtml.c $(INCLUDES)
$(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \
-o web/httpd.so web/httpd.c web/u_stats.c web/vfs.c web/phtml.c
clean:
$(RM) -f *.o *.so *~ core
+617
View File
@@ -0,0 +1,617 @@
/*
UnrealIRCd internal webserver
Copyright (c) 2001, The UnrealIRCd Team
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions
and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
and the following disclaimer in the documentation and/or other materials provided with the
distribution.
* Neither the name of the The UnrealIRCd Team nor the names of its contributors may be used
to endorse or promote products derived from this software without specific prior written permission.
* The source code may not be redistributed for a fee or in closed source
programs, without expressed oral consent by the UnrealIRCd Team, however
for operating systems where binary distribution is required, if URL
is passed with the package to get the full source
* No warranty is given unless stated so by the The UnrealIRCd Team
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "struct.h"
#include "common.h"
#include "sys.h"
#include "numeric.h"
#include "msg.h"
#include "channel.h"
#include <time.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#include <io.h>
#else
#include <sys/socket.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/resource.h>
#endif
#include <fcntl.h>
#include "h.h"
#ifdef STRIPBADWORDS
#include "badwords.h"
#endif
#ifdef _WIN32
#include "version.h"
#endif
#include "threads.h"
#include "modules/web/httpd.h"
SOCKET httpdfd = -1;
void httpd_socketthread(void *req);
void httpd_acceptthread(void *p);
int h_u_stats(HTTPd_Request *r);
int h_u_vfs(HTTPd_Request *r);
int h_u_phtml(HTTPd_Request *r);
#ifndef DYNAMIC_LINKING
ModuleInfo httpd_info
#else
#define httpd_info mod_header
ModuleInfo mod_header
#endif
= {
2,
"httpd", /* Name of module */
"$Id$", /* Version */
"httpd", /* Short description of module */
NULL, /* Pointer to our dlopen() return value */
NULL
};
void httpd_sendfile(HTTPd_Request *r, char *filename)
{
int xfd = open(filename, O_RDONLY);
if (xfd)
{
while (read(xfd, &r->inbuf[0], 1))
{
FDwrite(r->fd,&r->inbuf[0], 1);
}
}
close(xfd);
}
/*
* Helper function
*/
void sockprintf(SOCKET fd, char *format, ...)
{
va_list ap;
char buffer[1024];
char *ptr;
va_start(ap, format);
vsprintf(buffer, format, ap);
strcat(buffer, "\r\n");
va_end(ap);
FDwrite(fd, buffer, strlen(buffer));
}
/* The purpose of these ifdefs, are that we can "static" link the ircd if we
* want to
*/
/* This is called on module init, before Server Ready */
#ifdef DYNAMIC_LINKING
DLLFUNC int mod_init(int module_load)
#else
int httpd_init(int module_load)
#endif
{
add_HookX(HOOKTYPE_HTTPD_URL, h_u_stats, NULL);
add_HookX(HOOKTYPE_HTTPD_URL, h_u_vfs, NULL);
add_HookX(HOOKTYPE_HTTPD_URL, h_u_phtml, NULL);
}
/* Is first run when server is 100% ready */
#ifdef DYNAMIC_LINKING
DLLFUNC int mod_load(int module_load)
#else
int httpd_load(int module_load)
#endif
{
THREAD thread;
THREAD_ATTR attr;
struct SOCKADDR_IN sin;
if ((httpdfd = socket(AFINET, SOCK_STREAM, 0)) == -1)
{
config_error("httpd: could not create socket");
httpdfd = -1;
return -1;
}
sin.SIN_ADDR.S_ADDR = inet_addr("0.0.0.0");
sin.SIN_PORT = htons(8091);
sin.SIN_FAMILY = AFINET;
if (bind(httpdfd, (struct SOCKADDR *)&sin, sizeof(sin)))
{
config_error("httpd: could not bind: %s",
strerror(ERRNO));
CLOSE_SOCK(httpdfd);
httpdfd = -1;
return -1;
}
listen(httpdfd, LISTEN_SIZE);
IRCCreateThread(thread, attr, httpd_acceptthread, NULL);
return 0;
}
/* Called when module is unloaded */
#ifdef DYNAMIC_LINKING
DLLFUNC void mod_unload(void)
#else
void httpd_unload(void)
#endif
{
del_HookX(HOOKTYPE_HTTPD_URL, h_u_stats, NULL);
del_HookX(HOOKTYPE_HTTPD_URL, h_u_vfs, NULL);
del_HookX(HOOKTYPE_HTTPD_URL, h_u_phtml, NULL);
}
/*
* copyright (c) 2000 Todor Prokopov
* from the CGI library, under the GPL
*/
static int urldecode(char *s)
{
char *p = s;
while (*s != '\0')
{
if (*s == '%')
{
s++;
if (!isxdigit(*s))
return 0;
*p = (isalpha(*s) ? (*s & 0xdf) - 'A' + 10 : *s - '0') << 4;
s++;
if (!isxdigit(*s))
return 0;
*p += isalpha(*s) ? (*s & 0xdf) - 'A' + 10 : *s - '0';
}
else if (*s == '+')
*p = ' ';
else
*p = *s;
s++;
p++;
}
*p = '\0';
return 1;
}
int parse_urlenc(HTTPd_Request *request)
{
unsigned int i;
unsigned int p;
int param_count;
int content_length;
char **tempheaders;
char **tempvalues;
HTTPd_Header *h;
char *buf;
content_length = request->content_length;
buf = request->inbuf;
if (content_length != 0)
{
param_count = 1;
for (i = 0; i < content_length; i++)
if (buf[i] == '&')
param_count++;
i = 0;
p = 0;
tempheaders = (char **)MyMallocEx(sizeof(char *) * param_count);
tempvalues = (char **)MyMallocEx(sizeof(char *) * param_count);
while (i < content_length)
{
tempheaders[p] = buf + i;
while (i < content_length && buf[i] != '=' && buf[i] != '&')
i++;
if (i >= content_length || buf[i] != '=')
{
MyFree(tempheaders);
MyFree(tempvalues);
return 0;
}
buf[i] = '\0';
i++;
tempvalues[p] = buf + i;
while (i < content_length && buf[i] != '=' && buf[i] != '&')
i++;
if (i < content_length)
{
if (buf[i] != '&')
{
MyFree(tempheaders);
MyFree(tempvalues);
return 0;
}
buf[i] = '\0';
i++;
}
if (!urldecode(tempheaders[p]) || !urldecode(tempvalues[p]))
{
MyFree(tempheaders);
MyFree(tempvalues);
return 0;
}
p++;
}
}
for (i = 0; i < p; i++)
{
h = (HTTPd_Header *) MyMallocEx(sizeof(HTTPd_Header));
h->name = strdup(tempheaders[i]);
h->value = strdup(tempvalues[i]);
h->next = request->dataheaders;
request->dataheaders = h;
}
MyFree(tempheaders);
MyFree(tempvalues);
return 1;
}
/* Normal copyright applies here */
char *GetField(HTTPd_Header *header, char *name)
{
HTTPd_Header *p;
for (p = header; p; p = p->next)
if (!strcasecmp(p->name, name))
return (p->value);
return NULL;
}
char *GetHeader(HTTPd_Request *request, char *name)
{
HTTPd_Header *p;
for (p = request->headers; p; p = p->next)
if (!strcasecmp(p->name, name))
return (p->value);
return NULL;
}
void httpd_standard_headerX(HTTPd_Request *request, char *type, int extra)
{
char datebuf[100];
sockprintf(request->fd, "HTTP/1.1 200 OK");
sockprintf(request->fd, "Server: UnrealIRCd HTTPd");
sockprintf(request->fd, "Connection: close");
sockprintf(request->fd, "Date: %s", (char *) rfctime(time(NULL), datebuf));
sockprintf(request->fd, "Content-Type: %s", type);
if (extra != 1)
sockprintf(request->fd, "");
}
void httpd_standard_header(HTTPd_Request *request, char *type)
{
httpd_standard_headerX(request, type, 0);
}
void httpd_404_header(HTTPd_Request *request, char *path)
{
char datebuf[100];
sockprintf(request->fd, "HTTP/1.1 404 Not Found");
sockprintf(request->fd, "Server: UnrealIRCd HTTPd");
sockprintf(request->fd, "Connection: close");
sockprintf(request->fd, "Date: %s", (char *) rfctime(time(NULL), datebuf));
sockprintf(request->fd, "Content-Type: text/html");
sockprintf(request->fd, "");
sockprintf(request->fd, "<b>Not Found</b><br>Could not find %s<br>",
path);
}
void httpd_304_header(HTTPd_Request *request)
{
char datebuf[100];
sockprintf(request->fd, "HTTP/1.1 304 Not Modified");
sockprintf(request->fd, "Server: UnrealIRCd HTTPd");
sockprintf(request->fd, "Connection: close");
sockprintf(request->fd, "Date: %s", (char *) rfctime(time(NULL), datebuf));
sockprintf(request->fd, "Content-Type: text/html");
sockprintf(request->fd, "");
}
void httpd_400_header(HTTPd_Request *request, char *why)
{
char datebuf[100];
sockprintf(request->fd, "HTTP/1.1 400 Internal Server Error");
sockprintf(request->fd, "Server: UnrealIRCd HTTPd");
sockprintf(request->fd, "Connection: close");
sockprintf(request->fd, "Date: %s", (char *) rfctime(time(NULL), datebuf));
sockprintf(request->fd, "Content-Type: text/html");
sockprintf(request->fd, "");
sockprintf(request->fd, "%s<br>",
why);
}
void httpd_parse_final(HTTPd_Request *request)
{
if (request->method == 0)
{
char *cl;
cl = GetHeader(request, "Content-Length:");
if (!cl)
{
sockprintf(request->fd, "Missing content-length header..");
return;
}
request->content_length = atoi(cl);
if (request->content_length <= 1023)
{
request->state = 2;
}
}
else
{
RunHookReturn(HOOKTYPE_HTTPD_URL, request, >0);
httpd_404_header(request, request->url);
return;
}
}
void httpd_badrequest(HTTPd_Request *request, char *reason)
{
sockprintf(request->fd, "HTTP/1.1 400 Bad Request");
sockprintf(request->fd, "Server: UnrealIRCd HTTPd");
sockprintf(request->fd, "Connection: close");
sockprintf(request->fd, "Content-Type: text/plain");
sockprintf(request->fd, "");
sockprintf(request->fd, "%s", reason);
}
int httpd_parse(HTTPd_Request *request)
{
if (request->state == 0)
{
char *cmd;
cmd = strtok(request->inbuf, " ");
if (!cmd)
{
httpd_badrequest(request, "Bad protocol start");
return -1;
}
else
{
if (!strcmp(cmd, "GET") || !strcmp(cmd, "POST"))
{
char *url;
url = strtok(NULL, " ");
if (!url)
{
httpd_badrequest(request, "Missing parameter");
return -1;
}
else
{
request->url = strdup(url);
request->state = 1;
request->method = !strcmp(cmd, "GET") ? 1 : 0;
return 1;
}
}
else
httpd_badrequest(request, cmd);
return -1;
}
return 1;
}
else if (request->state == 1)
{
char *headername;
char *headerdata;
headername = strtok(request->inbuf, " ");
if (!headername)
{
httpd_parse_final(request);
if (request->state > 1)
{
return 1;
}
else
return -1;
}
else
{
headerdata = strtok(NULL, "");
if (!headerdata)
{
httpd_badrequest(request, "Malformed headers");
return -1;
}
else
{
HTTPd_Header *header;
header = (HTTPd_Header *) MyMalloc(sizeof(HTTPd_Header));
header->name = strdup(headername);
header->value = strdup(headerdata);
header->next = request->headers;
request->headers = header;
return 1;
}
}
} else if (request->state == 2)
{
if (parse_urlenc(request))
{
RunHookReturn(HOOKTYPE_HTTPD_URL, request, >0) -1;
httpd_404_header(request, request->url);
return -1;
}
else
{
httpd_badrequest(request, "Bad encoding");
}
return -1;
}
}
void httpd_acceptthread(void *p)
{
SOCKET callerfd;
HTTPd_Request *req;
THREAD thread;
THREAD_ATTR thread_attr;
while (1)
{
callerfd = accept(httpdfd, NULL, NULL);
if (callerfd >= 0)
{
req = (HTTPd_Request *)MyMallocEx(sizeof(HTTPd_Request));
req->fd = callerfd;
IRCCreateThread(thread, thread_attr, httpd_socketthread, (void *)req);
}
}
}
void httpd_socketthread(void *req)
{
HTTPd_Request *request = (HTTPd_Request *)req;
HTTPd_Header *hp, *hp2;
fd_set rfds;
struct timeval tv;
int retval, retval2;
tv.tv_sec = 10;
tv.tv_usec = 0;
FD_ZERO(&rfds);
FD_SET(request->fd, &rfds);
while (request->pos < 1024)
{
if (retval = select(request->fd + 1, &rfds, NULL, NULL, &tv))
{
while ((retval2 = recv(request->fd, &request->inbuf[request->pos], 1, 0)) >= 0)
{
if (request->state != 2)
{
if (request->inbuf[request->pos] == '\n')
{
request->inbuf[request->pos + 1] = '\0';
iCstrip(request->inbuf);
if (httpd_parse(request) < 0)
{
request->pos = 1024;
break;
}
else
request->pos = 0;
}
else
{
request->pos++;
}
if (request->pos >= 1024)
{
break;
}
}
else
{
request->pos++;
if (request->pos >= 1024)
break;
if (request->pos == request->content_length)
{
request->inbuf[request->pos + 1] = '\0';
request->pos = 1024;
httpd_parse(request);
break;
}
}
}
if (request->pos >= 1024)
break;
if (retval2 < 0)
request->pos = 1024;
else
request->pos += retval2;
}
else
{
if (retval < 0)
{
request->pos = 1024;
}
}
}
end:
CLOSE_SOCK(request->fd);
if (request->url)
MyFree(request->url);
hp = request->headers;
while (hp)
{
if (hp->name)
MyFree(hp->name);
if (hp->value)
MyFree(hp->value);
hp2 = hp;
hp = hp->next;
MyFree(hp2);
}
hp = request->dataheaders;
while (hp)
{
if (hp->name)
MyFree(hp->name);
if (hp->value)
MyFree(hp->value);
hp2 = hp;
hp = hp->next;
MyFree(hp2);
}
MyFree(request);
IRCExitThread(NULL);
return;
}
+184
View File
@@ -0,0 +1,184 @@
/*
UnrealIRCd internal webserver - Prototype HTML
Copyright (c) 2001, The UnrealIRCd Team
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions
and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
and the following disclaimer in the documentation and/or other materials provided with the
distribution.
* Neither the name of the The UnrealIRCd Team nor the names of its contributors may be used
to endorse or promote products derived from this software without specific prior written permission.
* The source code may not be redistributed for a fee or in closed source
programs, without expressed oral consent by the UnrealIRCd Team, however
for operating systems where binary distribution is required, if URL
is passed with the package to get the full source
* No warranty is given unless stated so by the The UnrealIRCd Team
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "struct.h"
#include "common.h"
#include "sys.h"
#include "numeric.h"
#include "msg.h"
#include "channel.h"
#include <time.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#include <io.h>
#else
#include <sys/socket.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/resource.h>
#endif
#include <fcntl.h>
#include "h.h"
#ifdef STRIPBADWORDS
#include "badwords.h"
#endif
#ifdef _WIN32
#include "version.h"
#endif
#include "threads.h"
#include "modules/web/httpd.h"
DLLFUNC int h_u_phtml(HTTPd_Request *r);
#define soprintf sockprintf
#define SECTION_OPERS 1
#define SECTION_STATS 2
char *Titles[] =
{
"<NULL>",
"Operators",
"IRC Server Stats"
};
char *Icons[] =
{
"<NULL>",
"/icons/opers.jpg",
"/icons/stats.jpg"
};
char *Sections[] =
{
"<NULL>",
"IRC Operators",
"IRC Server Stats"
};
char *ButtonTexts[] =
{
"<NULL>",
"Operators",
"Stats"
};
char *ButtonURLs[] =
{
"<NULL>",
"/section/opers",
"/section/stats"
};
DLLFUNC int h_u_phtml(HTTPd_Request *r)
{
int section = 0;
char buf[1024];
char bbuf[1024];
char *s;
FILE *f = NULL;
f = fopen("html/html/index.phtml", "r");
if (!f)
return 0;
if (!match("/section/opers", r->url))
section = SECTION_OPERS;
if (!match("/section/stats", r->url))
section = SECTION_STATS;
if (section < 1)
return 0;
httpd_standard_header(r, "text/html");
while (fgets(buf, 1023, f))
{
iCstrip(buf);
strcpy(bbuf, buf);
if (*buf == '$' && (buf[1] == ' '))
{
s = strtok(buf, " ");
if (s)
{
s = strtok(NULL, " ");
if (s)
{
if (!strcmp(s, "TITLE"))
{
sockprintf(r->fd, "%s", Titles[section]);
}
else
if (!strcmp(s, "ICON"))
{
sockprintf(r->fd, " src=\"%s\" ",
Icons[section]);
}
else
if (!strcmp(s, "SECTION"))
{
sockprintf(r->fd, "%s",
Sections[section]);
}
else
if (!strcmp(s, "DATA"))
{
sockprintf(r->fd, "TEST<br>");
sockprintf(r->fd, "TEST<br>");
sockprintf(r->fd, "TEST<br>");
sockprintf(r->fd, "TEST<br>");
sockprintf(r->fd, "TEST<br>");
sockprintf(r->fd, "TEST<br>");
sockprintf(r->fd, "TEST<br>");
sockprintf(r->fd, "TEST<br>");
sockprintf(r->fd, "TEST<br>");
sockprintf(r->fd, "TEST<br>");
sockprintf(r->fd, "TEST<br>");
sockprintf(r->fd, "TEST<br>");
sockprintf(r->fd, "TEST<br>");
sockprintf(r->fd, "TEST<br>");
sockprintf(r->fd, "TEST<br>");
sockprintf(r->fd, "TEST<br>");
sockprintf(r->fd, "TEST<br>");
}
}
else
sockprintf(r->fd, "%s", bbuf);
}
else
sockprintf(r->fd, "%s", bbuf);
}
else
sockprintf(r->fd, "%s", bbuf);
}
return 1;
}
+88
View File
@@ -0,0 +1,88 @@
/*
UnrealIRCd internal webserver - /stats
Copyright (c) 2001, The UnrealIRCd Team
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions
and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
and the following disclaimer in the documentation and/or other materials provided with the
distribution.
* Neither the name of the The UnrealIRCd Team nor the names of its contributors may be used
to endorse or promote products derived from this software without specific prior written permission.
* The source code may not be redistributed for a fee or in closed source
programs, without expressed oral consent by the UnrealIRCd Team, however
for operating systems where binary distribution is required, if URL
is passed with the package to get the full source
* No warranty is given unless stated so by the The UnrealIRCd Team
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "struct.h"
#include "common.h"
#include "sys.h"
#include "numeric.h"
#include "msg.h"
#include "channel.h"
#include <time.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#include <io.h>
#else
#include <sys/socket.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/resource.h>
#endif
#include <fcntl.h>
#include "h.h"
#ifdef STRIPBADWORDS
#include "badwords.h"
#endif
#ifdef _WIN32
#include "version.h"
#endif
#include "threads.h"
#include "modules/web/httpd.h"
extern ircstats IRCstats;
int h_u_stats(HTTPd_Request *r);
#define soprintf sockprintf
DLLFUNC int h_u_stats(HTTPd_Request *r)
{
HTTPd_Header *p;
if (!match("/stats", r->url))
{
httpd_standard_header(r, "text/html");
soprintf(r->fd, "<title>Current user stats on %s</title>", me.name);
soprintf(r->fd, "Clients: %li Invisible: %li Servers: %li<br>",
IRCstats.clients, IRCstats.invisible, IRCstats.servers);
soprintf(r->fd, "Unknown: %li My clients: %li My Servers: %li<br>",
IRCstats.unknown, IRCstats.me_clients, IRCstats.me_servers);
soprintf(r->fd, "My Peak: %li Global Peak: %li<br>",
IRCstats.me_max, IRCstats.global_max);
for (p = r->headers; p; p = p->next)
{
soprintf(r->fd, "%s = %s<br>",
p->name, p->value);
}
return 1;
}
return 0;
}
+129
View File
@@ -0,0 +1,129 @@
/*
UnrealIRCd internal webserver - Virtual File System
Copyright (c) 2001, The UnrealIRCd Team
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions
and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
and the following disclaimer in the documentation and/or other materials provided with the
distribution.
* Neither the name of the The UnrealIRCd Team nor the names of its contributors may be used
to endorse or promote products derived from this software without specific prior written permission.
* The source code may not be redistributed for a fee or in closed source
programs, without expressed oral consent by the UnrealIRCd Team, however
for operating systems where binary distribution is required, if URL
is passed with the package to get the full source
* No warranty is given unless stated so by the The UnrealIRCd Team
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "struct.h"
#include "common.h"
#include "sys.h"
#include "numeric.h"
#include "msg.h"
#include "channel.h"
#include <time.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#include <io.h>
#else
#include <sys/socket.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/resource.h>
#endif
#include <fcntl.h>
#include "h.h"
#ifdef STRIPBADWORDS
#include "badwords.h"
#endif
#ifdef _WIN32
#include "version.h"
#endif
#include "threads.h"
#include "modules/web/httpd.h"
int h_u_vfs(HTTPd_Request *r);
typedef struct _vfs_table VFStable;
struct _vfs_table
{
char *filename;
char *realfile;
char *ct;
};
VFStable vfsTable[] =
{
{"/sections/active.gif", "html/sections/active.gif", "image/gif"},
{"/sections/inactive.gif", "html/sections/inactive.gif", "image/gif"},
{"/html/main.html", "html/html/main.html", "text/html"},
{"/icons/conffiles.jpg", "html/icons/conffiles.jpg", "image/jpeg"},
{"/icons/modules.jpg", "html/icons/modules.jpg", "image/jpeg"},
{"/icons/opers.jpg", "html/icons/opers.jpg", "image/jpeg"},
{"/icons/settings.jpg", "html/icons/settings.jpg", "image/jpeg"},
{"/icons/stats.jpg", "html/icons/stats.jpg", "image/jpeg"},
{"/icons/users.jpg", "html/icons/users.jpg", "image/jpeg"},
{"/back/background.jpg", "html/back/background.jpg", "image/jpeg"},
{"/unrealircd.com/active.gif", "html/unrealircd.com/active.gif", "image/jpeg"},
{"/unrealircd.com/inactive.gif", "html/unrealircd.com/inactive.gif", "image/jpeg"},
{"/", "html/index.html", "text/html"},
{NULL, NULL, NULL}
};
#define soprintf sockprintf
DLLFUNC int h_u_vfs(HTTPd_Request *r)
{
VFStable *p = &vfsTable[0];
struct stat statf;
char *ims;
time_t tmt;
char datebuf[100];
ims = GetHeader(r, "if-modified-since");
while (p->filename)
{
if (!match(p->filename, r->url))
{
stat(p->realfile, &statf);
if (ims)
{
if (tmt = rfc2time(ims) < 0)
{
httpd_400_header(r, "Bad date");
return 1;
}
if (statf.st_mtime < tmt)
{
httpd_304_header(r);
return 1;
}
}
httpd_standard_headerX(r, p->ct, 1);
soprintf(r->fd, "Last-Modified: %s",
rfctime(statf.st_mtime, r->inbuf));
soprintf(r->fd, "");
httpd_sendfile(r, p->realfile);
return 1;
}
p++;
}
return 0;
}