コード例 #1
0
ファイル: umui.c プロジェクト: BackupGGCode/faceaip
static void formAddAccessLimit(webs_t wp, char_t *path, char_t *query)
{
	char_t			*url, *method, *group, *secure, *ok;
	int				nCheck;
	accessMeth_t	am;
	short			nSecure;

	a_assert(wp);

	url = websGetVar(wp, T("url"), T("")); 
	group = websGetVar(wp, T("group"), T("")); 
	method = websGetVar(wp, T("method"), T("")); 
	secure = websGetVar(wp, T("secure"), T("")); 
	ok = websGetVar(wp, T("ok"), T("")); 

	websHeader(wp);
	websMsgStart(wp);

	if (gstricmp(ok, T("ok")) != 0) {
		websWrite(wp, T("Add Access Limit Cancelled."));
	} else if ((url == NULL) || (*url == 0)) {
		websWrite(wp, T("ERROR:  No URL was entered."));
	} else if (umAccessLimitExists(url)) {
		websWrite(wp, T("ERROR:  An Access Limit for [%s] already exists."),
			url);
	} else {
		if (method && *method) {
			am = (accessMeth_t) gatoi(method);
		} else {
			am = AM_FULL;
		}

		if (secure && *secure) {
			nSecure = (short) gatoi(secure);
		} else {
			nSecure = 0;
		}

		nCheck = umAddAccessLimit(url, am, nSecure, group);
		if (nCheck != 0) {
			websWrite(wp, T("Unable to add Access Limit for [%s]"),	url);
		} else {
			websWrite(wp, T("Access limit for [%s], was successfully added."),
				url);
		}
	}

	websMsgEnd(wp);
	websFooter(wp);
	websDone(wp, 200);
}
コード例 #2
0
ファイル: um.c プロジェクト: challinan/webserver-demo
char_t *umGetAccessLimit(char_t *url)
{
	char_t	*urlRet, *urlCheck, *lastChar;
	int		len;
	
	a_assert(url && *url);
	urlRet = NULL;
	urlCheck = bstrdup(B_L, url);
	a_assert(urlCheck);
	len = gstrlen(urlCheck);
/*
 *	Scan back through URL to see if there is a "parent" access limit
 */
	while (len && !urlRet) {
		if (umAccessLimitExists(urlCheck)) {
			urlRet = bstrdup(B_L, urlCheck);
		} else {
/*
 *	Trim the end portion of the URL to the previous directory marker
 */
			lastChar = urlCheck + len;
			lastChar--;

			while ((lastChar >= urlCheck) && ((*lastChar == '/') || 
				(*lastChar == '\\'))) {
				*lastChar = 0;
				lastChar--;
			}

			while ((lastChar >= urlCheck) && (*lastChar != '/') && 
				(*lastChar != '\\')) {
				*lastChar = 0;
				lastChar--;
			}

			len = gstrlen(urlCheck);
		}
	}
	bfree (B_L, urlCheck);

	return urlRet;
}
コード例 #3
0
ファイル: um.c プロジェクト: challinan/webserver-demo
int	umAddAccessLimit(char_t *url, accessMeth_t am, short secure, char_t *group)
{
	int row;

	a_assert(url && *url);
	trace(3, T("UM: Adding Access Limit for <%s>\n"), url);

/*
 *	Do not allow duplicates
 */
	if (umAccessLimitExists(url)) {
		return UM_ERR_DUPLICATE;
	}

/*
 *	Add a new row to the table
 */
	if ((row = dbAddRow(didUM, UM_ACCESS_TABLENAME)) < 0) {
		return UM_ERR_GENERAL;
	}

/*
 *	Write the key field
 */
	if(dbWriteStr(didUM, UM_ACCESS_TABLENAME, UM_NAME, row, url) < 0) {
		return UM_ERR_GENERAL;
	}

/*
 *	Write the remaining fields
 */
	dbWriteInt(didUM, UM_ACCESS_TABLENAME, UM_METHOD, row, (int)am);
	dbWriteInt(didUM, UM_ACCESS_TABLENAME, UM_SECURE, row, (int)secure);
	dbWriteStr(didUM, UM_ACCESS_TABLENAME, UM_GROUP, row, group);

	return 0;
}