亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? default.c

?? 開發板bios源碼 開發板bios源碼
?? C
字號:
/*
 * default.c -- Default URL handler. Includes support for ASP.
 *
 * Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
 *
 * See the file "license.txt" for usage and redistribution license requirements
 *
 * $Id: default.c,v 1.2 2002/07/29 14:56:28 bporter Exp $
 */

/******************************** Description *********************************/

/*
 *	This module provides default URL handling and Active Server Page support.
 *
 *	In many cases we don't check the return code of calls to websWrite as
 *	it is easier, smaller and non-fatal to continue even when the requesting
 *	browser has gone away.
 */

/********************************* Includes ***********************************/

#include	"wsIntrn.h"

/*********************************** Locals ***********************************/

static char_t	*websDefaultPage;			/* Default page name */
static char_t	*websDefaultDir;			/* Default Web page directory */

/**************************** Forward Declarations ****************************/

static void websDefaultWriteEvent(webs_t wp);

/*********************************** Code *************************************/
/*
 *	Process a default URL request. This will validate the URL and handle "../"
 *	and will provide support for Active Server Pages. As the handler is the
 *	last handler to run, it always indicates that it has handled the URL 
 *	by returning 1. 
 */

int websDefaultHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
						char_t *url, char_t *path, char_t *query)
{
	websStatType	sbuf;
	char_t			*lpath, *tmp, *date;
	int				bytes, flags, nchars;

	a_assert(websValid(wp));
	a_assert(url && *url);
	a_assert(path);
	a_assert(query);

/*
 *	Validate the URL and ensure that ".."s don't give access to unwanted files
 */
	flags = websGetRequestFlags(wp);

	if (websValidateUrl(wp, path) < 0) {
		websError(wp, 500, T("Invalid URL %s"), url);
		return 1;
	}
	lpath = websGetRequestLpath(wp);
	nchars = gstrlen(lpath) - 1;
	if (lpath[nchars] == '/' || lpath[nchars] == '\\') {
		lpath[nchars] = '\0';
	}

/*
 *	If the file is a directory, redirect using the nominated default page
 */
	if (websPageIsDirectory(lpath)) {
		nchars = gstrlen(path);
		if (path[nchars-1] == '/' || path[nchars-1] == '\\') {
			path[--nchars] = '\0';
		}
		nchars += gstrlen(websDefaultPage) + 2;
		fmtAlloc(&tmp, nchars, T("%s/%s"), path, websDefaultPage);
		websRedirect(wp, tmp);
		bfreeSafe(B_L, tmp);
		return 1;
	}

/*
 *	Open the document. Stat for later use.
 */
	if (websPageOpen(wp, lpath, path, SOCKET_RDONLY | SOCKET_BINARY, 
		0666) < 0) {
		websError(wp, 400, T("Cannot open URL <b>%s</b>"), url);
		return 1;
	} 

	if (websPageStat(wp, lpath, path, &sbuf) < 0) {
		websError(wp, 400, T("Cannot stat page for URL <b>%s</b>"), url);
		return 1;
	}

/*
 *	If the page has not been modified since the user last received it and it
 *	is not dynamically generated each time (ASP), then optimize request by
 *	sending a 304 Use local copy response
 */
	websStats.localHits++;
#ifdef WEBS_IF_MODIFIED_SUPPORT
	if (flags & WEBS_IF_MODIFIED && !(flags & WEBS_ASP)) {
		if (sbuf.mtime <= wp->since) {
			websWrite(wp, T("HTTP/1.0 304 Use local copy\r\n"));

/*
 *			by license terms the following line of code must
 *			not be modified.
 */
			websWrite(wp, T("Server: %s\r\n"), WEBS_NAME);

			if (flags & WEBS_KEEP_ALIVE) {
				websWrite(wp, T("Connection: keep-alive\r\n"));
			}
			websWrite(wp, T("\r\n"));
			websSetRequestFlags(wp, flags |= WEBS_HEADER_DONE);
			websDone(wp, 304);
			return 1;
		}
	}
#endif

/*
 *	Output the normal HTTP response header
 */
	if ((date = websGetDateString(NULL)) != NULL) {
		websWrite(wp, T("HTTP/1.0 200 OK\r\nDate: %s\r\n"), date);

/*
 *		By license terms the following line of code must not be modified.
 */
		websWrite(wp, T("Server: %s\r\n"), WEBS_NAME);
		bfree(B_L, date);
	}
	flags |= WEBS_HEADER_DONE;

/*
 *	If this is an ASP request, ensure the remote browser doesn't cache it.
 *	Send back both HTTP/1.0 and HTTP/1.1 cache control directives
 */
	if (flags & WEBS_ASP) {
		bytes = 0;
		websWrite(wp, T("Pragma: no-cache\r\nCache-Control: no-cache\r\n"));

	} else {
		if ((date = websGetDateString(&sbuf)) != NULL) {
			websWrite(wp, T("Last-modified: %s\r\n"), date);
			bfree(B_L, date);
		}
		bytes = sbuf.size;
	}

	if (bytes) {
		websWrite(wp, T("Content-length: %d\r\n"), bytes);
		websSetRequestBytes(wp, bytes);
	}
	websWrite(wp, T("Content-type: %s\r\n"), websGetRequestType(wp));

	if ((flags & WEBS_KEEP_ALIVE) && !(flags & WEBS_ASP)) {
		websWrite(wp, T("Connection: keep-alive\r\n"));
	}
	websWrite(wp, T("\r\n"));

/*
 *	All done if the browser did a HEAD request
 */
	if (flags & WEBS_HEAD_REQUEST) {
		websDone(wp, 200);
		return 1;
	}

/*
 *	Evaluate ASP requests
 */
	if (flags & WEBS_ASP) {
		if (websAspRequest(wp, lpath) < 0) {
			return 1;
		}
		websDone(wp, 200);
		return 1;
	}

#ifdef WEBS_SSL_SUPPORT
	if (wp->flags & WEBS_SECURE) {
		websDefaultWriteEvent(wp);
	} else {
		websSetRequestSocketHandler(wp, SOCKET_WRITABLE, websDefaultWriteEvent);
	}
#else
/*
 *	For normal web documents, return the data via background write
 */
	websSetRequestSocketHandler(wp, SOCKET_WRITABLE, websDefaultWriteEvent);
#endif
	return 1;
}

/******************************************************************************/
/*
 *	Validate the URL path and process ".." path segments. Return -1 if the URL
 *	is bad.
 */

int websValidateUrl(webs_t wp, char_t *path)
{
	char_t	*parts[64];					/* Array of ptr's to URL parts */
	char_t	*token, *dir, *lpath;
	int		i, len, npart;

	a_assert(websValid(wp));
	a_assert(path);

	dir = websGetRequestDir(wp);
	if (dir == NULL || *dir == '\0') {
		return -1;
	}

/*
 *	Copy the string so we don't destroy the original
 */
	path = bstrdup(B_L, path);
	websDecodeUrl(path, path, gstrlen(path));

	len = npart = 0;
	parts[0] = NULL;

   /*
    * 22 Jul 02 -- there were reports that a directory traversal exploit was
    * possible in the WebServer running under Windows if directory paths
    * outside the server's specified root web were given by URL-encoding the
    * backslash character, like:
    *
    *  GoAhead is vulnerable to a directory traversal bug. A request such as
    *  
    *  GoAhead-server/../../../../../../../ results in an error message
    *  'Cannot open URL'.

    *  However, by encoding the '/' character, it is possible to break out of
    *  the
    *  web root and read arbitrary files from the server.
    *  Hence a request like:
    * 
    *  GoAhead-server/..%5C..%5C..%5C..%5C..%5C..%5C/winnt/win.ini returns the
    *  contents of the win.ini file.
    * (Note that the description uses forward slashes (0x2F), but the example
    * uses backslashes (0x5C). In my tests, forward slashes are correctly
    * trapped, but backslashes are not. The code below substitutes forward
    * slashes for backslashes before attempting to validate that there are no
    * unauthorized paths being accessed.
    */
   token = gstrchr(path, '\\');
   while (token != NULL)
   {
      *token = '/';
      token = gstrchr(token, '\\');
   }
   
	token = gstrtok(path, T("/"));

/*
 *	Look at each directory segment and process "." and ".." segments
 *	Don't allow the browser to pop outside the root web. 
 */
	while (token != NULL) {
		if (gstrcmp(token, T("..")) == 0) {
			if (npart > 0) {
				npart--;
			}

		} else if (gstrcmp(token, T(".")) != 0) {
			parts[npart] = token;
			len += gstrlen(token) + 1;
			npart++;
		}
		token = gstrtok(NULL, T("/"));
	}

/*
 *	Create local path for document. Need extra space all "/" and null.
 */
	if (npart || (gstrcmp(path, T("/")) == 0) || (path[0] == '\0')) {
		lpath = balloc(B_L, (gstrlen(dir) + 1 + len + 1) * sizeof(char_t));
		gstrcpy(lpath, dir);

		for (i = 0; i < npart; i++) {
			gstrcat(lpath, T("/"));
			gstrcat(lpath, parts[i]);
		}
		websSetRequestLpath(wp, lpath);
		bfree(B_L, path);
		bfree(B_L, lpath);

	} else {
		bfree(B_L, path);
		return -1;
	}
	return 0;
}

/******************************************************************************/
/*
 *	Do output back to the browser in the background. This is a socket
 *	write handler.
 */

static void websDefaultWriteEvent(webs_t wp)
{
	int		len, wrote, flags, bytes, written;
	char	*buf;

	a_assert(websValid(wp));

	flags = websGetRequestFlags(wp);

	websSetTimeMark(wp);

	wrote = bytes = 0;
	written = websGetRequestWritten(wp);

/*
 *	We only do this for non-ASP documents
 */
	if ( !(flags & WEBS_ASP)) {
		bytes = websGetRequestBytes(wp);
/*
 *		Note: websWriteDataNonBlock may return less than we wanted. It will
 *		return -1 on a socket error
 */
		if ((buf = balloc(B_L, PAGE_READ_BUFSIZE)) == NULL) {
			websError(wp, 200, T("Can't get memory"));
		} else {
			while ((len = websPageReadData(wp, buf, PAGE_READ_BUFSIZE)) > 0) {
				if ((wrote = websWriteDataNonBlock(wp, buf, len)) < 0) {
					break;
				}
				written += wrote;
				if (wrote != len) {
					websPageSeek(wp, - (len - wrote));
					break;
				}
			}
/*
 *			Safety. If we are at EOF, we must be done
 */
			if (len == 0) {
				a_assert(written >= bytes);
				written = bytes;
			}
			bfree(B_L, buf);
		}
	}

/*
 *	We're done if an error, or all bytes output
 */
	websSetRequestWritten(wp, written);
	if (wrote < 0 || written >= bytes) {
		websDone(wp, 200);
	}
}

/******************************************************************************/
/* 
 *	Closing down. Free resources.
 */

void websDefaultClose()
{
	if (websDefaultPage) {
		bfree(B_L, websDefaultPage);
		websDefaultPage = NULL;
	}
	if (websDefaultDir) {
		bfree(B_L, websDefaultDir);
		websDefaultDir = NULL;
	}
}

/******************************************************************************/
/*
 *	Get the default page for URL requests ending in "/"
 */

char_t *websGetDefaultPage()
{
	return websDefaultPage;
}

/******************************************************************************/
/*
 *	Get the default web directory
 */

char_t *websGetDefaultDir()
{
	return websDefaultDir;
}

/******************************************************************************/
/*
 *	Set the default page for URL requests ending in "/"
 */

void websSetDefaultPage(char_t *page)
{
	a_assert(page && *page);

	if (websDefaultPage) {
		bfree(B_L, websDefaultPage);
	}
	websDefaultPage = bstrdup(B_L, page);
}

/******************************************************************************/
/*
 *	Set the default web directory
 */

void websSetDefaultDir(char_t *dir)
{
	a_assert(dir && *dir);
	if (websDefaultDir) {
		bfree(B_L, websDefaultDir);
	}
	websDefaultDir = bstrdup(B_L, dir);
}

/******************************************************************************/

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区四区不卡在线| 欧美日韩一级大片网址| 亚洲少妇最新在线视频| 欧美三级日韩三级| 黄一区二区三区| 亚洲裸体xxx| 欧美成人video| 成人av电影在线网| 午夜日韩在线电影| 久久精品欧美日韩| 欧美日本乱大交xxxxx| 国产一区二区三区综合| 国产欧美精品一区二区三区四区| 99久久免费精品高清特色大片| 亚洲成va人在线观看| 日本一区二区成人在线| 欧美日产在线观看| eeuss鲁一区二区三区| 麻豆高清免费国产一区| 一区二区三区四区激情 | 在线精品视频小说1| 久久精品国产精品亚洲红杏| 伊人色综合久久天天人手人婷| 精品少妇一区二区三区视频免付费| 91久久精品一区二区三区| 久久精品国产99国产精品| 亚洲精品国产品国语在线app| 欧美va在线播放| 欧美日韩色一区| 在线观看日韩精品| 成人av网站在线| 亚洲午夜激情网站| 国产精品久久午夜| 久久一二三国产| 在线免费观看日本一区| 国产a区久久久| 久久精品国产99国产精品| 亚洲国产成人av| 一区二区激情视频| 亚洲欧美在线aaa| 国产精品网站一区| 久久久精品国产免大香伊| 制服丝袜亚洲色图| www.日韩在线| 久久精品99国产精品日本| 亚洲一区二区在线免费看| 亚洲婷婷综合久久一本伊一区| 久久亚洲精精品中文字幕早川悠里| 欧美日韩中文字幕一区| 欧美午夜精品理论片a级按摩| 大胆亚洲人体视频| 九色综合国产一区二区三区| 日韩av二区在线播放| 亚洲成av人片一区二区梦乃| 青青草伊人久久| 久久成人久久鬼色| 国产黄色成人av| 成人免费观看视频| voyeur盗摄精品| 国产黄人亚洲片| 久久se这里有精品| 国产一区二区三区免费在线观看| 精品系列免费在线观看| 精品一区二区av| 国产成人久久精品77777最新版本| 国内成人免费视频| 国产乱码精品一区二区三| 国产精华液一区二区三区| 国产a区久久久| 93久久精品日日躁夜夜躁欧美| 97久久超碰精品国产| 欧美主播一区二区三区美女| 欧美日韩一区三区四区| 日韩一区二区免费在线观看| 精品国产123| 国产精品婷婷午夜在线观看| 樱花影视一区二区| 性久久久久久久| 蜜桃精品视频在线观看| 国内精品国产成人| 国产成a人亚洲精| 欧美日韩国产成人在线91| 精品久久久久香蕉网| 国产三级欧美三级日产三级99| 国产精品久久午夜| 亚洲综合无码一区二区| 人人精品人人爱| 粉嫩蜜臀av国产精品网站| 91麻豆swag| 91美女蜜桃在线| 欧美群妇大交群中文字幕| 日韩精品一区二区三区视频在线观看| 国产亚洲视频系列| 亚洲图片一区二区| 国内精品免费**视频| 91香蕉视频黄| 日韩一区二区在线看片| 国产日产精品一区| 亚洲v日本v欧美v久久精品| 国产在线一区观看| 91麻豆高清视频| 精品免费日韩av| 亚洲另类春色国产| 国产一区 二区 三区一级| 91色porny在线视频| 欧美一区二区三区视频免费播放| 国产亚洲制服色| 中文字幕亚洲一区二区av在线 | 久久av中文字幕片| 色综合视频一区二区三区高清| 欧美一区二区三区免费| 国产精品国产三级国产普通话蜜臀| 性做久久久久久免费观看| 国产精品系列在线观看| 日本大香伊一区二区三区| 欧美精品一区二区三区四区| 亚洲综合视频在线| 不卡影院免费观看| 久久综合九色综合欧美就去吻 | 久久久精品黄色| 午夜精品国产更新| 91亚洲国产成人精品一区二三 | 日本午夜精品视频在线观看 | 亚洲欧美另类久久久精品| 久久国产尿小便嘘嘘| 欧美午夜寂寞影院| 成人欧美一区二区三区白人| 久久狠狠亚洲综合| 色欧美片视频在线观看在线视频| 精品成人佐山爱一区二区| 日韩精品电影在线| 在线一区二区三区四区五区| 国产精品不卡一区二区三区| 国产精品中文有码| 精品国产制服丝袜高跟| 日本美女一区二区| 在线观看不卡一区| 亚洲欧洲日产国码二区| 国产成人午夜99999| 久久久国产精华| 韩国女主播一区| 精品日产卡一卡二卡麻豆| 日韩主播视频在线| 欧美日韩另类一区| 亚洲最新视频在线观看| 色综合视频一区二区三区高清| 久久久久久99久久久精品网站| 日韩精品国产精品| 欧美日韩一区二区欧美激情| 亚洲一二三四区不卡| 欧美私模裸体表演在线观看| 亚洲最新视频在线观看| 欧美在线不卡一区| 亚洲国产视频a| 欧洲精品在线观看| 亚洲国产日韩a在线播放性色| 色天使久久综合网天天| 亚洲欧美日韩成人高清在线一区| 久久国产视频网| 久久亚洲影视婷婷| 国产精品 日产精品 欧美精品| 久久嫩草精品久久久精品一| 国产成人一区在线| 国产精品免费aⅴ片在线观看| 成人午夜免费电影| 樱桃视频在线观看一区| 欧美日韩mp4| 久国产精品韩国三级视频| 精品国产一区二区三区av性色| 国产一区二区三区综合| 国产精品久久久久天堂| av亚洲产国偷v产偷v自拍| 亚洲理论在线观看| 欧美一级xxx| 国产成人在线观看| 一区二区在线观看视频在线观看| 欧美午夜一区二区三区| 麻豆精品新av中文字幕| 26uuuu精品一区二区| 99久久er热在这里只有精品66| 亚洲午夜久久久久久久久久久| 日韩视频一区二区三区| 99久久er热在这里只有精品66| 天堂va蜜桃一区二区三区| 国产精品三级av| 欧美福利视频一区| 99综合电影在线视频| 蜜桃久久精品一区二区| 亚洲欧美日韩久久| 久久久国产精华| 7777精品伊人久久久大香线蕉完整版 | 黄页网站大全一区二区| 亚洲在线一区二区三区| 久久亚洲二区三区| 欧美日韩国产免费| 99国产精品99久久久久久| 久久99精品视频| 五月婷婷激情综合| 亚洲精品少妇30p| 中文字幕的久久|