웹모아 
웹모아  로그인  회원가입   
웹모아
 
폼태그(입력)
 


mod_url.c 소스
  등록: 2007-03-14 23:09:08 조회:1257
http://web.landmoa.net/?acmode=b_s&curjong=web001001&no=3817


#define WANT_BASENAME_MATCH
/* ====================================================================
* Copyright (c) 1996-1999 The Apache Group. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. 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.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the Apache Group
* for use in the Apache HTTP server project (http://www.apache.org/)."
*
* 4. The names "Apache Server" and "Apache Group" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the Apache Group
* for use in the Apache HTTP server project (http://www.apache.org/)."
*
* THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ''AS IS'' AND ANY
* EXPRESSED 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 APACHE GROUP OR
* ITS 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.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Group and was originally based
* on public domain software written at the National Center for
* Supercomputing Applications, University of Illinois, Urbana-Champaign.
* For more information on the Apache Group and the Apache HTTP server
* project, please see <http://www.apache.org/>.
*
*/

#include "httpd.h"
#include "http_core.h"
#include "http_config.h"
#include "http_log.h"

#include <iconv.h>

/* mod_url.c - by Won-kyu Park <wkpark@chem.skku.ac.kr>
*
* based mod_speling.c Alexei Kosut <akosut@organic.com> June, 1996
*
* Activate it with "CheckURL encoding On"
*/

MODULE_VAR_EXPORT module redurl_module;

typedef struct {
int enabled;
} urlconfig;

/*
* Create a configuration specific to this module for a server or directory
* location, and fill it with the default settings.
*
* The API says that in the absence of a merge function, the record for the
* closest ancestor is used exclusively. That's what we want, so we don't
* bother to have such a function.
*/

static void *mkconfig(pool *p)
{
urlconfig *cfg = ap_pcalloc(p, sizeof(urlconfig));

cfg->enabled = 0;
return cfg;
}

/*
* Respond to a callback to create configuration record for a server or
* vhost environment.
*/
static void *create_mconfig_for_server(pool *p, server_rec *s)
{
return mkconfig(p);
}

/*
* Respond to a callback to create a config record for a specific directory.
*/
static void *create_mconfig_for_directory(pool *p, char *dir)
{
return mkconfig(p);
}

/*
* Handler for the CheckURL encoding directive, which is FLAG.
*/
static const char *set_redurl(cmd_parms *cmd, void *mconfig, int arg)
{
urlconfig *cfg = (urlconfig *) mconfig;

cfg->enabled = arg;
return NULL;
}

/*
* Define the directives specific to this module. This structure is referenced
* later by the 'module' structure.
*/
static const command_rec redurl_cmds[] =
{
{ "CheckURL", set_redurl, NULL, OR_OPTIONS, FLAG,
"whether or not to fix mis-encoded URL requests" },
{ NULL }
};

static int check_redurl(request_rec *r)
{
urlconfig *cfg;
char *good, *bad, *postgood, *url;
int filoc, dotloc, urlen, pglen;
DIR *dirp;
struct DIR_TYPE *dir_entry;
array_header *candidates = NULL;

cfg = ap_get_module_config(r->per_dir_config, &redurl_module);
if (!cfg->enabled) {
return DECLINED;
}

/* We only want to worry about GETs */
if (r->method_number != M_GET) {
return DECLINED;
}

/* We've already got a file of some kind or another */
if (r->proxyreq || (r->finfo.st_mode != 0)) {
return DECLINED;
}

/* This is a sub request - don't mess with it */
if (r->main) {
return DECLINED;
}

/*
* The request should end up looking like this:
* r->uri: /correct-url/mispelling/more
* r->filename: /correct-file/mispelling r->path_info: /more
*
* So we do this in steps. First break r->filename into two pieces
*/

filoc = ap_rind(r->filename, '/');
/*
* Don't do anything if the request doesn't contain a slash, or
* requests "/"
*/
if (filoc == -1 || strcmp(r->uri, "/") == 0) {
return DECLINED;
}

/* good = /correct-file */
good = ap_pstrndup(r->pool, r->filename, filoc);
/* bad = mispelling */
bad = ap_pstrdup(r->pool, r->filename + filoc + 1);
/* postgood = mispelling/more */
postgood = ap_pstrcat(r->pool, bad, r->path_info, NULL);

urlen = strlen(r->uri);
pglen = strlen(postgood);

/* Check to see if the URL pieces add up */
if (strcmp(postgood, r->uri + (urlen - pglen))) {
return DECLINED;
}

/* url = /correct-url */
url = ap_pstrndup(r->pool, r->uri, (urlen - pglen));

/* 시작 */
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_INFO, r,
"Orig URL: %s %s url:%s",
r->uri, good, url);

{
static iconv_t cd = 0;
// const char *src = "안녕하세요";
// const char *src = "&#55071;&#53021;襤8?T";

/*
* glibc 2.2 patch by JoungKyun Kim
* -> 2th argument of iconv() is removed const
*/
// const char *src = r->uri;
char *src = r->uri;
char buf[2048]="\0", *to; /* XXX */
size_t len,flen, tlen,t;
if (cd == 0) {
cd = iconv_open("EUCKR", "UTF-8");
}
flen = len = strlen(src);
tlen = 2*flen;
to= buf;
// to = malloc(tlen);
t=iconv(cd, &src, &flen, &to, &tlen);

tlen=strlen(buf);
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_INFO, r,
"ICONV: from uri %s to %s(%d->%d): CHECK CODE '%d'",
r->uri,buf,len,tlen,t);
if (t >= 0
#if __GLIBC_MINOR__ == 2
&& t == 0
#endif
&& len != 0 && tlen != len) {
/* CHECK CODE 't' 에 대한 설명 */
/* t ==-1
URL이 이미 정상적인 EUCKR 인 경우:변환 필요 없는 경우 */
/* t == 0
정상적으로 UTF8 이 EUCKR 로 변환된 경우 */
/* t > 0
glibc 2.1.[2,3] 의 경우 변환된 문자열의 갯수를 돌려줌 */
/* flen == tlen 인 경우는 URL이 ascii일 경우 */
char *nuri;

nuri = ap_pstrcat(r->pool, buf,
r->parsed_uri.query ? "?" : "",
r->parsed_uri.query ? r->parsed_uri.query : "",
NULL);

ap_table_setn(r->headers_out, "Location",
ap_construct_url(r->pool, nuri, r));

ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_INFO, r,
"Fixed URL: %s to %s",
r->uri, nuri);

return HTTP_MOVED_PERMANENTLY;
} else
return DECLINED;
}
/* 끝 */

return OK;
}

module MODULE_VAR_EXPORT redurl_module =
{
STANDARD_MODULE_STUFF,
NULL, /* initializer */
create_mconfig_for_directory, /* create per-dir config */
NULL, /* merge per-dir config */
create_mconfig_for_server, /* server config */
NULL, /* merge server config */
redurl_cmds, /* command table */
NULL, /* handlers */
NULL, /* filename translation */
NULL, /* check_user_id */
NULL, /* check auth */
NULL, /* check access */
NULL, /* type_checker */
check_redurl, /* fixups */
NULL, /* logger */
NULL, /* header parser */
NULL, /* child_init */
NULL, /* child_exit */
NULL /* post read-request */
};


 

 





폼태그(입력)
페이지: 1 / 2   

   select박스에 텍스트 벨류를요 카페에서 메뉴를 484
   iframe 에서 text field 값 얻어 오기601
   select 상자 그룹 예제497
    숫자만, 영문만, 한글만 입력하고 싶을 때878
   INPUT : 숫자만 입력하기571
   입력박스에 특수문자 입력못하게 하려면540
   row 추가 2552
     [RE] row 추가 2 - 테이블이름 지정547
       [RE] row 추가 2 - 테이블이름 지정-삭제492
   추가, 삭제 누르면서 테이블 행추가, 삭제하기 스크526
   row 추가586
   테이불 추가 스크립트652
   입력박스에 안내메세지 넣기(홈마스타)668
   동적으로 객체를 변경하는 자바스크립트(홈마스타)590
   자바스크립트를 써서 폼구문안에 전송(submit)하(홈마스타)502
     [RE] 자바스크립트를 써서 폼구문안에 전송(sub(홈마스타)496
   테이블(표)의 셀 여백 삭제 [border-coll(홈마스타)(1) 721
   폼 양식 요소들의 글자 색상 지정 [font-col(홈마스타)534
   폼 양식 요소안의 글자 정렬 지정 [text-ali(홈마스타)566
   폼 양식 요소들의 글자 크기 지정 [font-siz(홈마스타)511
   아이프레임의 배경을 투명처리하기[allowTrans(홈마스타)616
   iframe의 배경을 투명하게 하는법(홈마스타)521
     [RE] iframe의 배경을 투명하게 하는법(홈마스타)453
   레이어의 현재 마우스 위치(홈마스타)495
   레이어 감추기와 보이기 다른 예제(홈마스타)512
   레이어 감추기와 보이기 - select박스 보이기와(홈마스타)538
     [RE] 레이어 감추기와 보이기 - select박스(홈마스타)727
       [RE] 레이어 감추기와 보이기 - select박(홈마스타)561
     [RE] 레이어 사용시 Select객체에 가려지는 (홈마스타)484
   body 태그 예제(홈마스타)385
≪ [1]  [2]   ≫

복수단어 검색은 공백(space)로 구분해 주세요.



 
최근 글 자료
40
40
57
35
26
34
2775
667
652
825
741
3837
3274
3333
3690
 
인기글 자료
6108
4244
3711
9618
4690
4420
7021
9834
4495
4841
3880
5544
6594
10212
3818