2009-11-04 21:16:50 +00:00
|
|
|
#include "quakedef.h"
|
2005-02-28 07:16:19 +00:00
|
|
|
|
2004-08-23 01:40:25 +00:00
|
|
|
#ifdef WEBSERVER
|
|
|
|
|
|
|
|
#include "iweb.h"
|
|
|
|
|
|
|
|
#ifdef WEBSVONLY //we need some functions from quake
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
qboolean SV_AllowDownload (const char *name)
|
|
|
|
{
|
2016-08-25 00:12:14 +00:00
|
|
|
if (strstr(name, ".."))
|
|
|
|
return false;
|
|
|
|
if (strchr(name, ':'))
|
|
|
|
return false;
|
|
|
|
if (*name == '/' || *name == '\\')
|
|
|
|
return false;
|
2009-11-04 21:16:50 +00:00
|
|
|
return true;
|
|
|
|
}
|
2014-09-08 23:47:19 +00:00
|
|
|
char com_token[sizeof(com_token)];
|
2009-11-04 21:16:50 +00:00
|
|
|
com_tokentype_t com_tokentype;
|
|
|
|
int com_argc;
|
|
|
|
const char **com_argv;
|
|
|
|
|
|
|
|
vfsfile_t *IWebGenerateFile(char *name, char *content, int contentlength)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-06-23 02:17:02 +00:00
|
|
|
vfsfile_t *VFSSTDIO_Open(const char *osname, const char *mode, qboolean *needsflush);
|
2009-11-04 21:16:50 +00:00
|
|
|
vfsfile_t *FS_OpenVFS(const char *filename, const char *mode, enum fs_relative relativeto)
|
|
|
|
{
|
2013-06-23 02:17:02 +00:00
|
|
|
return VFSSTDIO_Open(filename, mode, NULL);
|
2009-11-04 21:16:50 +00:00
|
|
|
}
|
|
|
|
void Q_strncpyz(char *d, const char *s, int n)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
n--;
|
|
|
|
if (n < 0)
|
|
|
|
return; //this could be an error
|
|
|
|
|
|
|
|
for (i=0; *s; i++)
|
|
|
|
{
|
|
|
|
if (i == n)
|
|
|
|
break;
|
|
|
|
*d++ = *s++;
|
|
|
|
}
|
|
|
|
*d='\0';
|
|
|
|
}
|
|
|
|
|
2004-08-23 01:40:25 +00:00
|
|
|
/*char *va(char *format, ...)
|
|
|
|
{
|
|
|
|
#define VA_BUFFERS 2 //power of two
|
|
|
|
va_list argptr;
|
|
|
|
static char string[VA_BUFFERS][1024];
|
|
|
|
static int bufnum;
|
|
|
|
|
|
|
|
bufnum++;
|
|
|
|
bufnum &= (VA_BUFFERS-1);
|
|
|
|
|
|
|
|
va_start (argptr, format);
|
|
|
|
_vsnprintf (string[bufnum],sizeof(string[bufnum])-1, format,argptr);
|
|
|
|
va_end (argptr);
|
|
|
|
|
|
|
|
return string[bufnum];
|
|
|
|
}*/
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
#undef _vsnprintf
|
|
|
|
void Sys_Error(const char *format, ...)
|
2004-08-23 01:40:25 +00:00
|
|
|
{
|
|
|
|
va_list argptr;
|
|
|
|
char string[1024];
|
2009-11-04 21:16:50 +00:00
|
|
|
|
2004-08-23 01:40:25 +00:00
|
|
|
va_start (argptr, format);
|
2016-07-12 00:40:13 +00:00
|
|
|
#ifdef _WIN32
|
2004-08-23 01:40:25 +00:00
|
|
|
_vsnprintf (string,sizeof(string)-1, format,argptr);
|
2009-11-04 21:16:50 +00:00
|
|
|
string[sizeof(string)-1] = 0;
|
2016-07-12 00:40:13 +00:00
|
|
|
#else
|
|
|
|
vsnprintf (string,sizeof(string), format,argptr);
|
|
|
|
#endif
|
2004-08-23 01:40:25 +00:00
|
|
|
va_end (argptr);
|
|
|
|
|
|
|
|
printf("%s", string);
|
|
|
|
getchar();
|
|
|
|
exit(1000);
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
int COM_CheckParm(const char *parm)
|
2004-08-23 01:40:25 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *authedusername;
|
|
|
|
char *autheduserpassword;
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2015-04-14 23:12:17 +00:00
|
|
|
int httpport = 80;
|
|
|
|
int arg = 1;
|
2016-07-12 00:40:13 +00:00
|
|
|
#ifdef _WIN32
|
2004-08-23 01:40:25 +00:00
|
|
|
WSADATA pointlesscrap;
|
|
|
|
WSAStartup(2, &pointlesscrap);
|
2016-07-12 00:40:13 +00:00
|
|
|
#endif
|
2004-08-23 01:40:25 +00:00
|
|
|
|
2015-04-14 23:12:17 +00:00
|
|
|
if (arg < argc && atoi(argv[arg]))
|
|
|
|
httpport = atoi(argv[arg++]);
|
|
|
|
if (arg < argc)
|
|
|
|
authedusername = argv[arg++];
|
|
|
|
if (arg < argc)
|
|
|
|
autheduserpassword = argv[arg++];
|
|
|
|
|
|
|
|
printf("http port %i\n", httpport);
|
|
|
|
if (authedusername || autheduserpassword)
|
2004-08-23 01:40:25 +00:00
|
|
|
printf("Username = \"%s\"\nPassword = \"%s\"\n", authedusername, autheduserpassword);
|
|
|
|
else
|
|
|
|
printf("Server is read only\n");
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
{
|
2012-01-21 07:53:49 +00:00
|
|
|
// FTP_ServerRun(1, 21);
|
2015-04-14 23:12:17 +00:00
|
|
|
if (httpport)
|
|
|
|
HTTP_ServerPoll(1, httpport);
|
2016-07-12 00:40:13 +00:00
|
|
|
#ifdef _WIN32
|
2004-08-23 01:40:25 +00:00
|
|
|
Sleep(1);
|
2016-07-12 00:40:13 +00:00
|
|
|
#else
|
|
|
|
usleep(1000000);
|
|
|
|
#endif
|
2004-08-23 01:40:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-12 00:40:13 +00:00
|
|
|
#ifdef _WIN32
|
2016-08-25 00:12:14 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#define ULL(x) x##ui64
|
|
|
|
#else
|
|
|
|
#define ULL(x) x##ull
|
|
|
|
#endif
|
|
|
|
|
2015-04-14 23:12:17 +00:00
|
|
|
static time_t Sys_FileTimeToTime(FILETIME ft)
|
|
|
|
{
|
|
|
|
ULARGE_INTEGER ull;
|
|
|
|
ull.LowPart = ft.dwLowDateTime;
|
|
|
|
ull.HighPart = ft.dwHighDateTime;
|
2016-08-25 00:12:14 +00:00
|
|
|
return ull.QuadPart / ULL(10000000) - ULL(11644473600);
|
2015-04-14 23:12:17 +00:00
|
|
|
}
|
|
|
|
void COM_EnumerateFiles (const char *match, int (*func)(const char *, qofs_t, time_t mtime, void *, searchpathfuncs_t *f), void *parm)
|
2004-08-23 01:40:25 +00:00
|
|
|
{
|
|
|
|
HANDLE r;
|
2015-11-18 07:37:39 +00:00
|
|
|
WIN32_FIND_DATAA fd;
|
2004-08-23 01:40:25 +00:00
|
|
|
char apath[MAX_OSPATH];
|
|
|
|
char file[MAX_OSPATH];
|
|
|
|
char *s;
|
|
|
|
int go;
|
|
|
|
strcpy(apath, match);
|
|
|
|
// sprintf(apath, "%s%s", gpath, match);
|
|
|
|
for (s = apath+strlen(apath)-1; s>= apath; s--)
|
|
|
|
{
|
|
|
|
if (*s == '/')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
s++;
|
|
|
|
*s = '\0';
|
|
|
|
|
|
|
|
strcpy(file, match);
|
2015-11-18 07:37:39 +00:00
|
|
|
r = FindFirstFileA(file, &fd);
|
2004-08-23 01:40:25 +00:00
|
|
|
if (r==(HANDLE)-1)
|
|
|
|
return;
|
2015-11-18 07:37:39 +00:00
|
|
|
go = true;
|
2004-08-23 01:40:25 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (*fd.cFileName == '.');
|
2005-05-30 12:30:41 +00:00
|
|
|
else if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) //is a directory
|
2004-08-23 01:40:25 +00:00
|
|
|
{
|
2005-05-30 12:30:41 +00:00
|
|
|
sprintf(file, "%s%s/", apath, fd.cFileName);
|
2015-04-14 23:12:17 +00:00
|
|
|
go = func(file, fd.nFileSizeLow, Sys_FileTimeToTime(fd.ftLastWriteTime), parm, NULL);
|
2004-08-23 01:40:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-05-30 12:30:41 +00:00
|
|
|
sprintf(file, "%s%s", apath, fd.cFileName);
|
2015-04-14 23:12:17 +00:00
|
|
|
go = func(file, fd.nFileSizeLow, Sys_FileTimeToTime(fd.ftLastWriteTime), parm, NULL);
|
2004-08-23 01:40:25 +00:00
|
|
|
}
|
|
|
|
}
|
2015-11-18 07:37:39 +00:00
|
|
|
while(FindNextFileA(r, &fd) && go);
|
2004-08-23 01:40:25 +00:00
|
|
|
FindClose(r);
|
|
|
|
}
|
2016-07-12 00:40:13 +00:00
|
|
|
#endif
|
2004-08-23 01:40:25 +00:00
|
|
|
|
2015-04-14 23:12:17 +00:00
|
|
|
char *COM_ParseType (const char *data, char *out, int outlen, com_tokentype_t *toktype)
|
2004-08-23 01:40:25 +00:00
|
|
|
{
|
|
|
|
int c;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
len = 0;
|
|
|
|
out[0] = 0;
|
|
|
|
|
|
|
|
if (!data)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
// skip whitespace
|
|
|
|
skipwhite:
|
|
|
|
while ( (c = *data) <= ' ')
|
|
|
|
{
|
|
|
|
if (c == 0)
|
|
|
|
return NULL; // end of file;
|
|
|
|
data++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// skip // comments
|
|
|
|
if (c=='/')
|
|
|
|
{
|
|
|
|
if (data[1] == '/')
|
|
|
|
{
|
|
|
|
while (*data && *data != '\n')
|
|
|
|
data++;
|
|
|
|
goto skipwhite;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// handle quoted strings specially
|
|
|
|
if (c == '\"')
|
|
|
|
{
|
|
|
|
com_tokentype = TTP_STRING;
|
|
|
|
data++;
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if (len >= outlen-1)
|
2009-11-04 21:16:50 +00:00
|
|
|
return (char*)data;
|
2004-08-23 01:40:25 +00:00
|
|
|
|
|
|
|
c = *data++;
|
|
|
|
if (c=='\"' || !c)
|
|
|
|
{
|
|
|
|
out[len] = 0;
|
2009-11-04 21:16:50 +00:00
|
|
|
return (char*)data;
|
2004-08-23 01:40:25 +00:00
|
|
|
}
|
|
|
|
out[len] = c;
|
|
|
|
len++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
com_tokentype = TTP_UNKNOWN;
|
|
|
|
|
|
|
|
// parse a regular word
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (len >= outlen-1)
|
2009-11-04 21:16:50 +00:00
|
|
|
return (char*)data;
|
2004-08-23 01:40:25 +00:00
|
|
|
|
|
|
|
out[len] = c;
|
|
|
|
data++;
|
|
|
|
len++;
|
|
|
|
c = *data;
|
|
|
|
} while (c>32);
|
|
|
|
|
|
|
|
out[len] = 0;
|
2009-11-04 21:16:50 +00:00
|
|
|
return (char*)data;
|
2004-08-23 01:40:25 +00:00
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
char *COM_ParseToken (const char *data, const char *punctuation)
|
2004-08-23 01:40:25 +00:00
|
|
|
{
|
|
|
|
int c;
|
|
|
|
int len;
|
2016-07-12 00:40:13 +00:00
|
|
|
#ifndef WEBSVONLY
|
|
|
|
COM_AssertMainThread("COM_ParseToken");
|
|
|
|
#endif
|
2004-08-23 01:40:25 +00:00
|
|
|
len = 0;
|
|
|
|
com_token[0] = 0;
|
|
|
|
|
|
|
|
if (!data)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
// skip whitespace
|
|
|
|
skipwhite:
|
|
|
|
while ( (c = *data) <= ' ')
|
|
|
|
{
|
|
|
|
if (c == 0)
|
|
|
|
return NULL; // end of file;
|
|
|
|
data++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// skip // comments
|
|
|
|
if (c=='/')
|
|
|
|
{
|
|
|
|
if (data[1] == '/')
|
|
|
|
{
|
|
|
|
while (*data && *data != '\n')
|
|
|
|
data++;
|
|
|
|
goto skipwhite;
|
|
|
|
}
|
|
|
|
else if (data[1] == '*')
|
|
|
|
{
|
|
|
|
data+=2;
|
|
|
|
while (*data && (*data != '*' || data[1] != '/'))
|
|
|
|
data++;
|
|
|
|
data+=2;
|
|
|
|
goto skipwhite;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// handle quoted strings specially
|
|
|
|
if (c == '\"')
|
|
|
|
{
|
|
|
|
com_tokentype = TTP_STRING;
|
|
|
|
data++;
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
c = *data++;
|
|
|
|
if (c=='\"' || !c)
|
|
|
|
{
|
|
|
|
com_token[len] = 0;
|
2009-11-04 21:16:50 +00:00
|
|
|
return (char*)data;
|
2004-08-23 01:40:25 +00:00
|
|
|
}
|
|
|
|
com_token[len] = c;
|
|
|
|
len++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
com_tokentype = TTP_UNKNOWN;
|
|
|
|
|
|
|
|
// parse single characters
|
|
|
|
if (c==',' || c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' || c==':' || c==';' || c == '=' || c == '!' || c == '>' || c == '<' || c == '&' || c == '|' || c == '+')
|
|
|
|
{
|
|
|
|
com_token[len] = c;
|
|
|
|
len++;
|
|
|
|
com_token[len] = 0;
|
2009-11-04 21:16:50 +00:00
|
|
|
return (char*)data+1;
|
2004-08-23 01:40:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// parse a regular word
|
|
|
|
do
|
|
|
|
{
|
|
|
|
com_token[len] = c;
|
|
|
|
data++;
|
|
|
|
len++;
|
|
|
|
c = *data;
|
|
|
|
if (c==',' || c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' || c==':' || c==';' || c == '=' || c == '!' || c == '>' || c == '<' || c == '&' || c == '|' || c == '+')
|
|
|
|
break;
|
|
|
|
} while (c>32);
|
|
|
|
|
|
|
|
com_token[len] = 0;
|
2009-11-04 21:16:50 +00:00
|
|
|
return (char*)data;
|
2004-08-23 01:40:25 +00:00
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
/*
|
2004-08-23 01:40:25 +00:00
|
|
|
IWEBFILE *IWebFOpenRead(char *name) //fread(name, "rb");
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
char name2[512];
|
|
|
|
if (strstr(name, ".."))
|
|
|
|
return NULL;
|
|
|
|
sprintf(name2, "%s/%s", com_gamedir, name);
|
|
|
|
f = fopen(name2, "rb");
|
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
IWEBFILE *ret = IWebMalloc(sizeof(IWEBFILE));
|
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
fclose(f);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
ret->f = f;
|
|
|
|
ret->start = 0;
|
|
|
|
|
|
|
|
fseek(f, 0, SEEK_END);
|
|
|
|
ret->end = ftell(f);//ret->start+ret->length;
|
|
|
|
fseek(f, 0, SEEK_SET);
|
|
|
|
|
|
|
|
ret->length = ret->end - ret->start;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2009-11-04 21:16:50 +00:00
|
|
|
*/
|
2004-08-23 01:40:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#ifndef CLIENTONLY
|
2016-09-08 19:04:35 +00:00
|
|
|
cvar_t ftpserver = CVAR("sv_ftp", "0");
|
|
|
|
cvar_t ftpserver_port = CVAR("sv_ftp_port", "21");
|
|
|
|
cvar_t httpserver = CVAR("sv_http", "0");
|
|
|
|
cvar_t httpserver_port = CVAR("sv_http_port", "80");
|
|
|
|
cvar_t sv_readlevel = CVAR("sv_readlevel", "0"); //default to allow anyone
|
|
|
|
cvar_t sv_writelevel = CVAR("sv_writelevel", "35"); //allowed to write to uploads/uname
|
|
|
|
cvar_t sv_fulllevel = CVAR("sv_fulllevel", "51"); //allowed to write anywhere, replace any file...
|
2004-08-23 01:40:25 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
//this file contains functions called from each side.
|
|
|
|
|
|
|
|
void VARGS IWebDPrintf(char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list argptr;
|
|
|
|
char msg[4096];
|
|
|
|
|
|
|
|
if (!developer.value)
|
|
|
|
return;
|
|
|
|
|
|
|
|
va_start (argptr,fmt);
|
2006-03-06 01:41:09 +00:00
|
|
|
vsnprintf (msg,sizeof(msg)-10, fmt,argptr); //catch any nasty bugs... (this is hopefully impossible)
|
2004-08-23 01:40:25 +00:00
|
|
|
va_end (argptr);
|
|
|
|
|
|
|
|
Con_Printf("%s", msg);
|
|
|
|
}
|
|
|
|
void VARGS IWebPrintf(char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list argptr;
|
|
|
|
char msg[4096];
|
|
|
|
|
|
|
|
va_start (argptr,fmt);
|
2006-03-06 01:41:09 +00:00
|
|
|
vsnprintf (msg,sizeof(msg)-10, fmt,argptr); //catch any nasty bugs... (this is hopefully impossible)
|
2004-08-23 01:40:25 +00:00
|
|
|
va_end (argptr);
|
|
|
|
|
|
|
|
Con_Printf("%s", msg);
|
|
|
|
}
|
|
|
|
void VARGS IWebWarnPrintf(char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list argptr;
|
|
|
|
char msg[4096];
|
|
|
|
|
|
|
|
va_start (argptr,fmt);
|
2006-03-06 01:41:09 +00:00
|
|
|
vsnprintf (msg,sizeof(msg)-10, fmt,argptr); //catch any nasty bugs... (this is hopefully impossible)
|
2004-08-23 01:40:25 +00:00
|
|
|
va_end (argptr);
|
|
|
|
|
2007-09-23 15:28:06 +00:00
|
|
|
Con_Printf(CON_WARNING "%s", msg);
|
2004-08-23 01:40:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void IWebInit(void)
|
|
|
|
{
|
|
|
|
#ifdef WEBSERVER
|
|
|
|
Cvar_Register(&sv_fulllevel, "Internet Server Access");
|
|
|
|
Cvar_Register(&sv_writelevel, "Internet Server Access");
|
|
|
|
Cvar_Register(&sv_readlevel, "Internet Server Access");
|
|
|
|
|
|
|
|
Cvar_Register(&ftpserver, "Internet Server Access");
|
2007-09-17 20:35:39 +00:00
|
|
|
Cvar_Register(&ftpserver_port, "Internet Server Access");
|
2004-08-23 01:40:25 +00:00
|
|
|
Cvar_Register(&httpserver, "Internet Server Access");
|
2007-09-17 20:35:39 +00:00
|
|
|
Cvar_Register(&httpserver_port, "Internet Server Access");
|
|
|
|
|
|
|
|
//don't allow these to be changed easily
|
|
|
|
//this basically blocks these from rcon / stuffcmd
|
|
|
|
ftpserver.restriction = RESTRICT_MAX;
|
|
|
|
httpserver.restriction = RESTRICT_MAX;
|
|
|
|
sv_fulllevel.restriction = RESTRICT_MAX;
|
|
|
|
sv_writelevel.restriction = RESTRICT_MAX;
|
|
|
|
sv_readlevel.restriction = RESTRICT_MAX;
|
2004-08-23 01:40:25 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
void IWebRun(void)
|
|
|
|
{
|
|
|
|
#ifdef WEBSERVER
|
2006-03-14 02:54:54 +00:00
|
|
|
extern qboolean httpserverfailed, ftpserverfailed;
|
2006-03-14 02:50:56 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
FTP_ServerRun(ftpserver.ival!= 0, ftpserver_port.ival);
|
|
|
|
HTTP_ServerPoll(httpserver.ival!=0, httpserver_port.ival);
|
2006-03-14 02:54:54 +00:00
|
|
|
if (ftpserverfailed)
|
|
|
|
{
|
|
|
|
Con_Printf("FTP Server failed to load, setting %s to 0\n", ftpserver.name);
|
|
|
|
Cvar_SetValue(&ftpserver, 0);
|
|
|
|
ftpserverfailed = false;
|
|
|
|
}
|
2006-03-14 02:50:56 +00:00
|
|
|
if (httpserverfailed)
|
|
|
|
{
|
|
|
|
Con_Printf("HTTP Server failed to load, setting %s to 0\n", httpserver.name);
|
|
|
|
Cvar_SetValue(&httpserver, 0);
|
|
|
|
httpserverfailed = false;
|
|
|
|
}
|
2004-08-23 01:40:25 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
void IWebShutdown(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WEBSVONLY
|
|
|
|
//replacement for Z_Malloc. It simply allocates up to a reserve ammount.
|
|
|
|
void *IWebMalloc(int size)
|
|
|
|
{
|
2008-05-09 14:22:37 +00:00
|
|
|
void *mem = BZF_Malloc(size);
|
|
|
|
memset(mem, 0, size);
|
|
|
|
return mem;
|
2004-08-23 01:40:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void *IWebRealloc(void *old, int size)
|
|
|
|
{
|
2008-05-09 14:22:37 +00:00
|
|
|
return BZF_Realloc(old, size);
|
2004-08-23 01:40:25 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int IWebAuthorize(char *name, char *password)
|
|
|
|
{
|
|
|
|
#ifdef WEBSVONLY
|
|
|
|
if (authedusername)
|
|
|
|
if (!strcmp(name, authedusername))
|
|
|
|
if (!strcmp(password, autheduserpassword))
|
|
|
|
return IWEBACC_FULL;
|
|
|
|
return IWEBACC_READ;
|
|
|
|
#else
|
|
|
|
#ifndef CLIENTONLY
|
2011-09-03 03:49:43 +00:00
|
|
|
int id = Rank_GetPlayerID(NULL, name, atoi(password), false, true);
|
2004-08-23 01:40:25 +00:00
|
|
|
rankinfo_t info;
|
|
|
|
if (!id)
|
|
|
|
{
|
|
|
|
if (!sv_readlevel.value)
|
|
|
|
return IWEBACC_READ; //read only anywhere
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Rank_GetPlayerInfo(id, &info);
|
|
|
|
|
|
|
|
if (info.s.trustlevel >= sv_fulllevel.value)
|
|
|
|
return IWEBACC_READ | IWEBACC_WRITE | IWEBACC_FULL; //allowed to read and write anywhere to the quake filesystem
|
|
|
|
if (info.s.trustlevel >= sv_writelevel.value)
|
|
|
|
return IWEBACC_READ | IWEBACC_WRITE; //allowed to read anywhere write to specific places
|
|
|
|
if (info.s.trustlevel >= sv_readlevel.value)
|
|
|
|
return IWEBACC_READ; //read only anywhere
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
iwboolean IWebAllowUpLoad(char *fname, char *uname) //called for partial write access
|
|
|
|
{
|
|
|
|
if (strstr(fname, ".."))
|
|
|
|
return false;
|
|
|
|
if (!strncmp(fname, "uploads/", 8))
|
|
|
|
{
|
|
|
|
if (!strncmp(fname+8, uname, strlen(uname)))
|
|
|
|
if (fname[8+strlen(uname)] == '/')
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-03-28 00:11:59 +00:00
|
|
|
iwboolean FTP_StringToAdr (const char *s, qbyte ip[4], qbyte port[2])
|
2004-08-23 01:40:25 +00:00
|
|
|
{
|
2005-08-26 22:56:51 +00:00
|
|
|
s = COM_ParseToken(s, NULL);
|
2004-08-23 01:40:25 +00:00
|
|
|
ip[0] = atoi(com_token);
|
|
|
|
|
2005-08-26 22:56:51 +00:00
|
|
|
s = COM_ParseToken(s, NULL);
|
2004-08-23 01:40:25 +00:00
|
|
|
if (*com_token != ',')
|
|
|
|
return false;
|
|
|
|
|
2005-08-26 22:56:51 +00:00
|
|
|
s = COM_ParseToken(s, NULL);
|
2004-08-23 01:40:25 +00:00
|
|
|
ip[1] = atoi(com_token);
|
|
|
|
|
2005-08-26 22:56:51 +00:00
|
|
|
s = COM_ParseToken(s, NULL);
|
2004-08-23 01:40:25 +00:00
|
|
|
if (*com_token != ',')
|
|
|
|
return false;
|
|
|
|
|
2005-08-26 22:56:51 +00:00
|
|
|
s = COM_ParseToken(s, NULL);
|
2004-08-23 01:40:25 +00:00
|
|
|
ip[2] = atoi(com_token);
|
|
|
|
|
2005-08-26 22:56:51 +00:00
|
|
|
s = COM_ParseToken(s, NULL);
|
2004-08-23 01:40:25 +00:00
|
|
|
if (*com_token != ',')
|
|
|
|
return false;
|
|
|
|
|
2005-08-26 22:56:51 +00:00
|
|
|
s = COM_ParseToken(s, NULL);
|
2004-08-23 01:40:25 +00:00
|
|
|
ip[3] = atoi(com_token);
|
|
|
|
|
2005-08-26 22:56:51 +00:00
|
|
|
s = COM_ParseToken(s, NULL);
|
2004-08-23 01:40:25 +00:00
|
|
|
if (*com_token != ',')
|
|
|
|
return false;
|
|
|
|
|
2005-08-26 22:56:51 +00:00
|
|
|
s = COM_ParseToken(s, NULL);
|
2004-08-23 01:40:25 +00:00
|
|
|
port[0] = atoi(com_token);
|
|
|
|
|
2005-08-26 22:56:51 +00:00
|
|
|
s = COM_ParseToken(s, NULL);
|
2004-08-23 01:40:25 +00:00
|
|
|
if (*com_token != ',')
|
|
|
|
return false;
|
|
|
|
|
2005-08-26 22:56:51 +00:00
|
|
|
s = COM_ParseToken(s, NULL);
|
2004-08-23 01:40:25 +00:00
|
|
|
port[1] = atoi(com_token);
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
char *Q_strcpyline(char *out, const char *in, int maxlen)
|
2004-08-23 01:40:25 +00:00
|
|
|
{
|
|
|
|
char *w = out;
|
|
|
|
while (*in && maxlen > 0)
|
|
|
|
{
|
|
|
|
if (*in == '\r' || *in == '\n')
|
|
|
|
break;
|
|
|
|
*w = *in;
|
|
|
|
in++;
|
|
|
|
w++;
|
|
|
|
maxlen--;
|
|
|
|
}
|
|
|
|
*w = '\0';
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|