加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
yaf_request.c 39.24 KB
一键复制 编辑 原始数据 按行查看 历史
惠新宸 提交于 2020-06-11 15:44 . Fixed build under 7.3
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437
/*
+----------------------------------------------------------------------+
| Yet Another Framework |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Xinchen Hui <laruence@php.net> |
+----------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "main/SAPI.h"
#include "standard/php_string.h" /* for php_basename */
#include "Zend/zend_exceptions.h" /* for zend_exception_get_default */
#include "Zend/zend_interfaces.h" /* for zend_class_serialize_deny */
#include "Zend/zend_smart_str.h"
#include "php_yaf.h"
#include "yaf_application.h"
#include "yaf_request.h"
#include "yaf_namespace.h"
#include "yaf_exception.h"
#include "yaf_loader.h"
#include "yaf_router.h"
#include "requests/yaf_request_simple.h"
#include "requests/yaf_request_http.h"
zend_class_entry *yaf_request_ce;
static zend_object_handlers yaf_request_obj_handlers;
/** {{{ ARG_INFO
*/
ZEND_BEGIN_ARG_INFO_EX(yaf_request_void_arginfo, 0, 0, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(yaf_request_set_routed_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, flag)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(yaf_request_set_module_name_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, module)
ZEND_ARG_INFO(0, format_name)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(yaf_request_set_controller_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, controller)
ZEND_ARG_INFO(0, format_name)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(yaf_request_set_action_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, action)
ZEND_ARG_INFO(0, format_name)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(yaf_request_set_baseuri_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, uri)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(yaf_request_set_request_uri_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, uri)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(yaf_request_set_param_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, name)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(yaf_request_get_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, name)
ZEND_ARG_INFO(0, default)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(yaf_request_set_dispatched_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, dispatched)
ZEND_END_ARG_INFO()
/* }}} */
static zend_object *yaf_request_new(zend_class_entry *ce) /* {{{ */ {
yaf_request_object *req = emalloc(sizeof(yaf_request_object) + zend_object_properties_size(ce));
memset(req, 0, XtOffsetOf(yaf_request_object, std));
zend_object_std_init(&req->std, ce);
if (ce->default_properties_count) {
object_properties_init(&req->std, ce);
}
req->std.handlers = &yaf_request_obj_handlers;
req->uri = ZSTR_EMPTY_ALLOC();
return &req->std;
}
/* }}} */
static void yaf_request_object_free(zend_object *object) /* {{{ */ {
yaf_request_object *req = php_yaf_request_fetch_object(object);
if (req->method) {
zend_string_release(req->method);
}
if (req->module) {
zend_string_release(req->module);
}
if (req->controller) {
zend_string_release(req->controller);
}
if (req->action) {
zend_string_release(req->action);
}
if (req->uri) {
zend_string_release(req->uri);
}
if (req->base_uri) {
zend_string_release(req->base_uri);
}
if (req->language) {
zend_string_release(req->language);
}
if (req->params) {
if (GC_DELREF(req->params) == 0) {
GC_REMOVE_FROM_BUFFER(req->params);
zend_array_destroy(req->params);
}
}
if (req->properties) {
if (GC_DELREF(req->properties) == 0) {
GC_REMOVE_FROM_BUFFER(req->properties);
zend_array_destroy(req->properties);
}
}
zend_object_std_dtor(object);
}
/* }}} */
static HashTable *yaf_request_get_gc(zval *object, zval **table, int *n) /* {{{ */
{
yaf_request_object *request = Z_YAFREQUESTOBJ_P(object);
*table = NULL;
*n = 0;
return request->params;
}
/* }}} */
static HashTable *yaf_request_get_properties(zval *object) /* {{{ */ {
zval rv;
HashTable *ht;
yaf_request_object *request = Z_YAFREQUESTOBJ_P(object);
if (!request->properties) {
ALLOC_HASHTABLE(request->properties);
zend_hash_init(request->properties, 16, NULL, ZVAL_PTR_DTOR, 0);
YAF_ALLOW_VIOLATION(request->properties);
}
ht = request->properties;
ZVAL_STR_COPY(&rv, request->method);
zend_hash_str_update(ht, "method", sizeof("method") - 1, &rv);
if (request->module) {
ZVAL_STR_COPY(&rv, request->module);
} else {
ZVAL_NULL(&rv);
}
zend_hash_str_update(ht, "module", sizeof("module") - 1, &rv);
if (request->controller) {
ZVAL_STR_COPY(&rv, request->controller);
} else {
ZVAL_NULL(&rv);
}
zend_hash_str_update(ht, "controller", sizeof("controller") - 1, &rv);
if (request->action) {
ZVAL_STR_COPY(&rv, request->action);
} else {
ZVAL_NULL(&rv);
}
zend_hash_str_update(ht, "action", sizeof("action") - 1, &rv);
if (request->uri) {
ZVAL_STR_COPY(&rv, request->uri);
} else {
ZVAL_NULL(&rv);
}
zend_hash_str_update(ht, "uri:protected", sizeof("uri:protected") - 1, &rv);
if (request->base_uri) {
ZVAL_STR_COPY(&rv, request->base_uri);
} else {
ZVAL_NULL(&rv);
}
zend_hash_str_update(ht, "base_uri:protected", sizeof("base_uri:protected") - 1, &rv);
ZVAL_BOOL(&rv, yaf_request_is_dispatched(request));
zend_hash_str_update(ht, "dispatched:protected", sizeof("dispatched:protected") - 1, &rv);
ZVAL_BOOL(&rv, yaf_request_is_routed(request));
zend_hash_str_update(ht, "routed:protected", sizeof("routed:protected") - 1, &rv);
if (request->language) {
ZVAL_STR_COPY(&rv, request->language);
} else {
ZVAL_EMPTY_STRING(&rv);
}
zend_hash_str_update(ht, "language:protected", sizeof("language:protected") - 1, &rv);
if (request->params) {
ZVAL_ARR(&rv, request->params);
GC_ADDREF(request->params);
} else {
#if PHP_VERSION_ID < 70400
array_init(&rv);
#else
ZVAL_EMPTY_ARRAY(&rv);
#endif
}
zend_hash_str_update(ht, "params:protected", sizeof("params:protected") - 1, &rv);
return ht;
}
/* }}} */
static zend_always_inline zend_string *yaf_request_get_method(yaf_request_object *request) /* {{{ */ {
return zend_string_copy(request->method);
}
/* }}} */
static zend_always_inline zend_string *yaf_request_get_module(yaf_request_object *request) /* {{{ */ {
if (request->module) {
return zend_string_copy(request->module);
}
return NULL;
}
/* }}} */
static zend_always_inline zend_string *yaf_request_get_controller(yaf_request_object *request) /* {{{ */ {
if (request->controller) {
return zend_string_copy(request->controller);
}
return NULL;
}
/* }}} */
static zend_always_inline zend_string *yaf_request_get_action(yaf_request_object *request) /* {{{ */ {
if (request->action) {
return zend_string_copy(request->action);
}
return NULL;
}
/* }}} */
static zend_always_inline zend_string *yaf_request_get_uri(yaf_request_object *request) /* {{{ */ {
if (request->uri) {
return zend_string_copy(request->uri);
}
return NULL;
}
/* }}} */
static zend_always_inline zend_string *yaf_request_get_base_uri(yaf_request_object *request) /* {{{ */ {
if (request->base_uri) {
return zend_string_copy(request->base_uri);
}
return NULL;
}
/* }}} */
zend_string *yaf_request_get_language(yaf_request_object *request) /* {{{ */ {
if (!request->language) {
zval *accept_langs = yaf_request_query_str(YAF_GLOBAL_VARS_SERVER, ZEND_STRL("HTTP_ACCEPT_LANGUAGE"));
if (!accept_langs) {
return NULL;
} else if (UNEXPECTED(IS_STRING != Z_TYPE_P(accept_langs) || !Z_STRLEN_P(accept_langs))) {
return NULL;
} else {
char *seg;
char *ptrptr = NULL;
unsigned prefer_len = 0;
double max_qvlaue = 0;
char *prefer = NULL;
char *langs = estrndup(Z_STRVAL_P(accept_langs), Z_STRLEN_P(accept_langs));
seg = php_strtok_r(langs, ",", &ptrptr);
while (seg) {
char *qvalue;
while (*(seg) == ' ') {
seg++;
}
/* Accept-Language: da, en-gb;q=0.8, en;q=0.7 */
if ((qvalue = strstr(seg, "q="))) {
float qval = strtod(qvalue + 2, NULL);
if (qval > max_qvlaue) {
max_qvlaue = qval;
prefer_len = qvalue - seg - 1;
prefer = seg;
}
} else {
if (max_qvlaue < 1) {
max_qvlaue = 1;
prefer_len = strlen(seg);
prefer = seg;
}
}
seg = php_strtok_r(NULL, ",", &ptrptr);
}
if (prefer) {
request->language = zend_string_init(prefer, prefer_len, 0);
}
efree(langs);
}
}
return zend_string_copy(request->language);
}
/* }}} */
static zval* yaf_request_read_property(zval *zobj, zval *name, int type, void **cache_slot, zval *rv) /* {{{ */ {
zend_string *member;
yaf_request_object *request = Z_YAFREQUESTOBJ_P(zobj);
if (UNEXPECTED(Z_TYPE_P(name) != IS_STRING)) {
return &EG(uninitialized_zval);
}
if (UNEXPECTED(type == BP_VAR_W || type == BP_VAR_RW)) {
php_error_docref(NULL, E_WARNING,
"Indirect modification of Yaf_Reqeust internal property '%s' is not allowed", Z_STRVAL_P(name));
return &EG(error_zval);
}
member = Z_STR_P(name);
switch (ZSTR_LEN(member)) {
case 3:
if (yaf_slip_equal(ZSTR_VAL(member), ZEND_STRS("uri"))) {
zend_string *val = yaf_request_get_uri(request);
if (val) {
ZVAL_STR(rv, val);
return rv;
}
return &EG(uninitialized_zval);
}
break;
case 6:
if (yaf_slip_equal(ZSTR_VAL(member), ZEND_STRL("method"))) {
zend_string *val = yaf_request_get_method(request);
if (val) {
ZVAL_STR(rv, val);
return rv;
}
return &EG(uninitialized_zval);
}
if (yaf_slip_equal(ZSTR_VAL(member), ZEND_STRL("module"))) {
zend_string *val = yaf_request_get_module(request);
if (val) {
ZVAL_STR(rv, val);
return rv;
}
return &EG(uninitialized_zval);
}
if (yaf_slip_equal(ZSTR_VAL(member), ZEND_STRL("action"))) {
zend_string *val = yaf_request_get_action(request);
if (val) {
ZVAL_STR(rv, val);
return rv;
}
return &EG(uninitialized_zval);
}
if (yaf_slip_equal(ZSTR_VAL(member), ZEND_STRL("routed"))) {
ZVAL_BOOL(rv, yaf_request_is_routed(request));
return rv;
}
break;
case 8:
if (yaf_slip_equal(ZSTR_VAL(member), ZEND_STRL("base_uri"))) {
zend_string *val = yaf_request_get_base_uri(request);
if (val) {
ZVAL_STR(rv, val);
return rv;
}
return &EG(uninitialized_zval);
}
if (yaf_slip_equal(ZSTR_VAL(member), ZEND_STRL("language"))) {
zend_string *val = yaf_request_get_language(request);
if (val) {
ZVAL_STR(rv, val);
return rv;
}
return &EG(uninitialized_zval);
}
break;
case 10:
if (yaf_slip_equal(ZSTR_VAL(member), ZEND_STRL("controller"))) {
zend_string *val = yaf_request_get_controller(request);
if (val) {
ZVAL_STR(rv, val);
return rv;
}
return &EG(uninitialized_zval);
}
if (yaf_slip_equal(ZSTR_VAL(member), ZEND_STRL("dispatched"))) {
ZVAL_BOOL(rv, yaf_request_is_dispatched(request));
return rv;
}
default:
break;
}
return std_object_handlers.read_property(zobj, name, type, cache_slot, rv);
}
/* }}} */
static inline void yaf_request_set_uri(yaf_request_object *request, zend_string *uri) /* {{{ */ {
if (request->uri) {
zend_string_release(request->uri);
}
request->uri = zend_string_copy(uri);
}
/* }}} */
const char *yaf_request_strip_base_uri(zend_string *uri, zend_string *base_uri, size_t *len) /* {{{ */ {
register const char *p = ZSTR_VAL(uri);
if (strncasecmp(p, ZSTR_VAL(base_uri), ZSTR_LEN(base_uri)) == 0) {
p += ZSTR_LEN(base_uri);
if (*p == '\0' || *p == YAF_ROUTER_URL_DELIMIETER || *(--p) == YAF_ROUTER_URL_DELIMIETER) {
*len = ZSTR_LEN(uri) - (p - ZSTR_VAL(uri));
return p;
}
}
*len = ZSTR_LEN(uri);
return ZSTR_VAL(uri);
}
/* }}} */
int yaf_request_set_base_uri(yaf_request_object *request, zend_string *base_uri, zend_string *request_uri) /* {{{ */ {
if (UNEXPECTED(request->base_uri)) {
zend_string_release(request->base_uri);
}
if (base_uri == NULL) {
zend_string *basename = NULL;
zval *script_filename = yaf_request_query_str(YAF_GLOBAL_VARS_SERVER, ZEND_STRL("SCRIPT_FILENAME"));
do {
if (script_filename && IS_STRING == Z_TYPE_P(script_filename)) {
zend_string *file_name;
char *ext;
size_t ext_len;
zval *script_name, *phpself_name, *orig_name;
yaf_application_object *app;
if (UNEXPECTED((app = yaf_application_instance()) && app->ext)) {
ext = ZSTR_VAL(app->ext);
ext_len = ZSTR_LEN(app->ext);
} else {
ext = YAF_DEFAULT_EXT;
ext_len = sizeof(YAF_DEFAULT_EXT) - 1;
}
script_name = yaf_request_query_str(YAF_GLOBAL_VARS_SERVER, ZEND_STRL("SCRIPT_NAME"));
file_name = php_basename(Z_STRVAL_P(script_filename), Z_STRLEN_P(script_filename), ext, ext_len);
if (script_name && EXPECTED(IS_STRING == Z_TYPE_P(script_name))) {
zend_string *script = php_basename(Z_STRVAL_P(script_name), Z_STRLEN_P(script_name), NULL, 0);
if (memcmp(ZSTR_VAL(file_name), ZSTR_VAL(script), MIN(ZSTR_LEN(file_name), ZSTR_LEN(script))) == 0) {
basename = zend_string_copy(Z_STR_P(script_name));
zend_string_release(file_name);
zend_string_release(script);
break;
}
zend_string_release(script);
}
phpself_name = yaf_request_query_str(YAF_GLOBAL_VARS_SERVER, ZEND_STRL("PHP_SELF"));
if (phpself_name && EXPECTED(IS_STRING == Z_TYPE_P(phpself_name))) {
zend_string *phpself = php_basename(Z_STRVAL_P(phpself_name), Z_STRLEN_P(phpself_name), NULL, 0);
if (memcmp(ZSTR_VAL(file_name), ZSTR_VAL(phpself), MIN(ZSTR_LEN(file_name), ZSTR_LEN(file_name))) == 0) {
basename = zend_string_copy(Z_STR_P(phpself_name));
zend_string_release(file_name);
zend_string_release(phpself);
break;
}
zend_string_release(phpself);
}
orig_name = yaf_request_query_str(YAF_GLOBAL_VARS_SERVER, ZEND_STRL("ORIG_SCRIPT_NAME"));
if (orig_name && IS_STRING == Z_TYPE_P(orig_name)) {
zend_string *orig = php_basename(Z_STRVAL_P(orig_name), Z_STRLEN_P(orig_name), NULL, 0);
if (memcmp(ZSTR_VAL(file_name), ZSTR_VAL(orig), MIN(ZSTR_LEN(file_name), ZSTR_LEN(file_name))) == 0) {
basename = zend_string_copy(Z_STR_P(orig_name));
zend_string_release(file_name);
zend_string_release(orig);
break;
}
zend_string_release(orig);
}
zend_string_release(file_name);
}
} while (0);
if (basename) {
if (memcmp(ZSTR_VAL(request_uri), ZSTR_VAL(basename), MIN(ZSTR_LEN(basename), ZSTR_LEN(request_uri))) == 0) {
if (ZSTR_VAL(basename)[ZSTR_LEN(basename) - 1] == '/') {
zend_string *sanitized_uri = zend_string_init(ZSTR_VAL(basename), ZSTR_LEN(basename) - 1, 0);
zend_string_release(basename);
basename = sanitized_uri;
}
request->base_uri = basename;
return 1;
} else {
zend_string *dir = zend_string_init(ZSTR_VAL(basename), ZSTR_LEN(basename), 0); /* php_dirname might alter the string */
zend_string_release(basename);
ZSTR_LEN(dir) = php_dirname(ZSTR_VAL(dir), ZSTR_LEN(dir));
if (*(ZSTR_VAL(dir) + ZSTR_LEN(dir) - 1) == '/') {
ZSTR_VAL(dir)[ZSTR_LEN(dir) - 1] = '\0';
ZSTR_LEN(dir)--;
}
if (ZSTR_LEN(dir)) {
if (memcmp(ZSTR_VAL(request_uri), ZSTR_VAL(dir), MIN(ZSTR_LEN(dir), ZSTR_LEN(request_uri))) == 0) {
request->base_uri = dir;
return 1;
}
}
zend_string_release(dir);
}
}
request->base_uri = NULL;
} else {
zend_string *sanitized_uri = NULL;
if (UNEXPECTED(ZSTR_VAL(base_uri)[ZSTR_LEN(base_uri) - 1] == '/')) {
sanitized_uri = zend_string_init(ZSTR_VAL(base_uri), ZSTR_LEN(base_uri) - 1, 0);
base_uri = sanitized_uri;
} else {
zend_string_copy(base_uri);
}
request->base_uri = base_uri;
}
return 1;
}
/* }}} */
static YAF_WRITE_HANDLER yaf_request_write_property(zval *zobj, zval *name, zval *value, void **cache_slot) /* {{{ */ {
zend_string *member;
yaf_request_object *request = Z_YAFREQUESTOBJ_P(zobj);
if (UNEXPECTED(Z_TYPE_P(name) != IS_STRING)) {
YAF_WHANDLER_RET(value);
}
member = Z_STR_P(name);
if (zend_string_equals_literal(member, "method")) {
if (UNEXPECTED(Z_TYPE_P(value) != IS_STRING || Z_STRLEN_P(value) == 0)) {
YAF_WHANDLER_RET(value);
}
zend_string_release(request->method);
request->method = zend_string_copy(Z_STR_P(value));
YAF_WHANDLER_RET(value);
}
if (zend_string_equals_literal(member, "module")) {
if (UNEXPECTED(Z_TYPE_P(value) != IS_STRING || Z_STRLEN_P(value) == 0)) {
YAF_WHANDLER_RET(value);
}
yaf_request_set_module(request, Z_STR_P(value));
YAF_WHANDLER_RET(value);
}
if (zend_string_equals_literal(member, "controller")) {
if (UNEXPECTED(Z_TYPE_P(value) != IS_STRING || Z_STRLEN_P(value) == 0)) {
YAF_WHANDLER_RET(value);
}
yaf_request_set_controller(request, Z_STR_P(value));
YAF_WHANDLER_RET(value);
}
if (zend_string_equals_literal(member, "action")) {
if (UNEXPECTED(Z_TYPE_P(value) != IS_STRING || Z_STRLEN_P(value) == 0)) {
YAF_WHANDLER_RET(value);
}
yaf_request_set_action(request, Z_STR_P(value));
YAF_WHANDLER_RET(value);
}
if (zend_string_equals_literal(member, "uri") ||
zend_string_equals_literal(member, "base_uri") ||
zend_string_equals_literal(member, "dispatched") ||
zend_string_equals_literal(member, "language") ||
zend_string_equals_literal(member, "routed") ||
zend_string_equals_literal(member, "params")) {
php_error_docref(NULL, E_WARNING,
"Modification of Yaf_Request internal property '%s' is not allowed", Z_STRVAL_P(name));
YAF_WHANDLER_RET(value);
}
return std_object_handlers.write_property(zobj, name, value, cache_slot);
}
/* }}} */
void yaf_request_instance(yaf_request_t *this_ptr, zend_string *request_uri) /* {{{ */ {
zend_object *req = yaf_request_new(yaf_request_http_ce);
yaf_request_http_init(php_yaf_request_fetch_object(req), NULL, request_uri);
ZVAL_OBJ(this_ptr, req);
}
/* }}} */
void yaf_request_set_mvc(yaf_request_object *request, zend_string *module, zend_string *controller, zend_string *action, zend_array *params) /* {{{ */ {
if (module) {
yaf_request_set_module(request, module);
}
if (controller) {
yaf_request_set_controller(request, controller);
}
if (action) {
yaf_request_set_action(request, action);
}
if (params) {
if (!request->params) {
ALLOC_HASHTABLE(request->params);
zend_hash_init(request->params, zend_hash_num_elements(params), NULL, ZVAL_PTR_DTOR, 0);
YAF_ALLOW_VIOLATION(request->params);
}
zend_hash_copy(request->params, params, (copy_ctor_func_t) zval_add_ref);
}
}
/* }}} */
void yaf_request_clean_params(yaf_request_object *request) /* {{{ */ {
if (request->params) {
zend_hash_clean(request->params);
}
}
/* }}} */
static inline zval* yaf_request_fetch_container(unsigned type) /* {{{ */ {
zval *container;
zend_bool jit_initialization = PG(auto_globals_jit);
switch (type) {
case YAF_GLOBAL_VARS_POST:
container = zend_hash_str_find(&EG(symbol_table), ZEND_STRL("_POST"));
break;
case YAF_GLOBAL_VARS_GET:
container = zend_hash_str_find(&EG(symbol_table), ZEND_STRL("_GET"));
break;
case YAF_GLOBAL_VARS_COOKIE:
container = zend_hash_str_find(&EG(symbol_table), ZEND_STRL("_COOKIE"));
break;
case YAF_GLOBAL_VARS_FILES:
container = zend_hash_str_find(&EG(symbol_table), ZEND_STRL("_FILES"));
break;
case YAF_GLOBAL_VARS_SERVER:
if (jit_initialization) {
zend_is_auto_global_str(ZEND_STRL("_SERVER"));
}
container = zend_hash_str_find(&EG(symbol_table), ZEND_STRL("_SERVER"));
break;
case YAF_GLOBAL_VARS_REQUEST:
if (jit_initialization) {
zend_is_auto_global_str(ZEND_STRL("_REQUEST"));
}
container = zend_hash_str_find(&EG(symbol_table), ZEND_STRL("_REQUEST"));
break;
case YAF_GLOBAL_VARS_ENV:
if (jit_initialization) {
zend_is_auto_global_str(ZEND_STRL("_ENV"));
}
container = zend_hash_str_find(&EG(symbol_table), ZEND_STRL("_ENV"));
break;
default:
return NULL;
}
if (UNEXPECTED(Z_TYPE_P(container) != IS_ARRAY)) {
if (Z_TYPE_P(container) != IS_REFERENCE || Z_TYPE_P(Z_REFVAL_P(container)) != IS_ARRAY) {
return NULL;
}
return Z_REFVAL_P(container);
}
return container;
}
/* }}} */
ZEND_HOT zval *yaf_request_query_str(unsigned type, const char *name, size_t len) /* {{{ */ {
zval *container = yaf_request_fetch_container(type);
if (UNEXPECTED(!container)) {
return NULL;
}
if (UNEXPECTED(name == NULL)) {
return container;
}
return zend_hash_str_find(Z_ARRVAL_P(container), name, len);
}
/* }}} */
ZEND_HOT zval *yaf_request_query(unsigned type, zend_string *name) /* {{{ */ {
zval *container = yaf_request_fetch_container(type);
if (UNEXPECTED(!container)) {
return NULL;
}
if (UNEXPECTED(name == NULL)) {
return container;
}
return zend_hash_find(Z_ARRVAL_P(container), name);
}
/* }}} */
int yaf_request_del_param(yaf_request_object *request, zend_string *key) /* {{{ */ {
if (request->params) {
return zend_hash_del(request->params, key);
}
return 0;
}
/* }}} */
int yaf_request_set_params_single(yaf_request_object *request, zend_string *key, zval *value) /* {{{ */ {
if (!request->params) {
ALLOC_HASHTABLE(request->params);
zend_hash_init(request->params, 8, NULL, ZVAL_PTR_DTOR, 0);
YAF_ALLOW_VIOLATION(request->params);
}
if ((zend_hash_update(request->params, key, value)) != NULL) {
Z_TRY_ADDREF_P(value);
return 1;
}
return 0;
}
/* }}} */
int yaf_request_set_params_multi(yaf_request_object *request, zval *values) /* {{{ */ {
zval *entry;
zend_string *key;
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(values), key, entry) {
if (UNEXPECTED(key == NULL)) {
continue;
}
yaf_request_set_params_single(request, key, entry);
} ZEND_HASH_FOREACH_END();
return 0;
}
/* }}} */
zval *yaf_request_get_param(yaf_request_object *request, zend_string *key) /* {{{ */ {
if (request->params) {
return zend_hash_find(request->params, key);
}
return NULL;
}
/* }}} */
zval *yaf_request_get_param_str(yaf_request_object *request, const char *key, size_t len) /* {{{ */ {
if (request->params) {
return zend_hash_str_find(request->params, key, len);
}
return NULL;
}
/* }}} */
const char *yaf_request_get_request_method(void) /* {{{ */ {
if (SG(request_info).request_method) {
return SG(request_info).request_method;
}
#if 0
else if (yaf_slip_equal(sapi_module.name, "cli", 4)) {
return "CLI";
} else {
return "UNKNOWN";
}
#endif
return "CLI";
}
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::isGet(void)
*/
YAF_REQUEST_IS_METHOD(Get);
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::isPost(void)
*/
YAF_REQUEST_IS_METHOD(Post);
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::isPut(void)
*/
YAF_REQUEST_IS_METHOD(Put);
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::isDelete(void)
*/
YAF_REQUEST_IS_METHOD(Delete);
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::isPatch(void)
*/
YAF_REQUEST_IS_METHOD(Patch);
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::isHead(void)
*/
YAF_REQUEST_IS_METHOD(Head);
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::isOptions(void)
*/
YAF_REQUEST_IS_METHOD(Options);
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::isCli(void)
*/
YAF_REQUEST_IS_METHOD(Cli);
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::isXmlHttpRequest()
*/
PHP_METHOD(yaf_request, isXmlHttpRequest) {
zend_string *name;
zval * header;
name = zend_string_init("HTTP_X_REQUESTED_WITH", sizeof("HTTP_X_REQUESTED_WITH") - 1, 0);
header = yaf_request_query(YAF_GLOBAL_VARS_SERVER, name);
zend_string_release(name);
if (header && Z_TYPE_P(header) == IS_STRING
&& strncasecmp("XMLHttpRequest", Z_STRVAL_P(header), Z_STRLEN_P(header)) == 0) {
RETURN_TRUE;
}
RETURN_FALSE;
}
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::getQuery(mixed $name, mixed $default = NULL)
*/
YAF_REQUEST_METHOD(yaf_request, Query, YAF_GLOBAL_VARS_GET);
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::getPost(mixed $name, mixed $default = NULL)
*/
YAF_REQUEST_METHOD(yaf_request, Post, YAF_GLOBAL_VARS_POST);
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::getRequet(mixed $name, mixed $default = NULL)
*/
YAF_REQUEST_METHOD(yaf_request, Request, YAF_GLOBAL_VARS_REQUEST);
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::getFiles(mixed $name, mixed $default = NULL)
*/
YAF_REQUEST_METHOD(yaf_request, Files, YAF_GLOBAL_VARS_FILES);
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::getCookie(mixed $name, mixed $default = NULL)
*/
YAF_REQUEST_METHOD(yaf_request, Cookie, YAF_GLOBAL_VARS_COOKIE);
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::getRaw()
*/
PHP_METHOD(yaf_request, getRaw) {
php_stream *s;
smart_str raw_data = {0};
if (zend_parse_parameters_none() == FAILURE) {
return;
}
s = SG(request_info).request_body;
if (!s || FAILURE == php_stream_rewind(s)) {
RETURN_FALSE;
}
while (!php_stream_eof(s)) {
char buf[512];
size_t len = php_stream_read(s, buf, sizeof(buf));
if (len && len != (size_t) -1) {
smart_str_appendl(&raw_data, buf, len);
}
}
if (raw_data.s) {
smart_str_0(&raw_data);
RETURN_STR(raw_data.s);
} else {
RETURN_FALSE;
}
}
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::get(mixed $name, mixed $default)
* params -> post -> get -> cookie -> server
*/
PHP_METHOD(yaf_request, get) {
zend_string *name;
zval *def = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|z", &name, &def) == FAILURE) {
return;
} else {
zval *value = yaf_request_get_param(Z_YAFREQUESTOBJ_P(getThis()), name);
if (value) {
RETURN_ZVAL(value, 1, 0);
} else {
zval *params = NULL;
zval *pzval = NULL;
YAF_GLOBAL_VARS_TYPE methods[4] = {
YAF_GLOBAL_VARS_POST,
YAF_GLOBAL_VARS_GET,
YAF_GLOBAL_VARS_COOKIE,
YAF_GLOBAL_VARS_SERVER
};
{
int i = 0;
for (;i < 4; i++) {
params = &PG(http_globals)[methods[i]];
if (params && Z_TYPE_P(params) == IS_ARRAY) {
if ((pzval = zend_hash_find(Z_ARRVAL_P(params), name)) != NULL ){
RETURN_ZVAL(pzval, 1, 0);
}
}
}
}
if (def) {
RETURN_ZVAL(def, 1, 0);
}
}
}
RETURN_NULL();
}
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::getEnv(mixed $name, mixed $default = NULL)
*/
YAF_REQUEST_METHOD(yaf_request, Env, YAF_GLOBAL_VARS_ENV);
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::getServer(mixed $name, mixed $default = NULL)
*/
YAF_REQUEST_METHOD(yaf_request, Server, YAF_GLOBAL_VARS_SERVER);
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::getModuleName(void)
*/
PHP_METHOD(yaf_request, getModuleName) {
yaf_request_object *request = Z_YAFREQUESTOBJ_P(getThis());
zend_string *module = yaf_request_get_module(request);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (UNEXPECTED(module == NULL)) {
RETURN_NULL();
}
RETURN_STR(module);
}
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::getControllerName(void)
*/
PHP_METHOD(yaf_request, getControllerName) {
yaf_request_object *request = Z_YAFREQUESTOBJ_P(getThis());
zend_string *controller = yaf_request_get_controller(request);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (UNEXPECTED(controller == NULL)) {
RETURN_NULL();
}
RETURN_STR(controller);
}
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::getActionName(void)
*/
PHP_METHOD(yaf_request, getActionName) {
yaf_request_object *request = Z_YAFREQUESTOBJ_P(getThis());
zend_string *action = yaf_request_get_action(request);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (UNEXPECTED(action == NULL)) {
RETURN_NULL();
}
RETURN_STR(action);
}
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::setModuleName(string $module, bool $format_name = true)
*/
PHP_METHOD(yaf_request, setModuleName) {
zend_string *module;
zend_bool format_name = 1;
yaf_request_object *request = Z_YAFREQUESTOBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|b", &module, &format_name) == FAILURE) {
return;
}
if (EXPECTED(ZSTR_LEN(module))) {
if (format_name) {
yaf_request_set_module(request, module);
} else {
if (request->module) {
zend_string_release(request->module);
request->module = zend_string_copy(module);
}
}
}
RETURN_ZVAL(getThis(), 1, 0);
}
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::setControllerName(string $controller, bool $format_name = true)
*/
PHP_METHOD(yaf_request, setControllerName) {
zend_string *controller;
zend_bool format_name = 1;
yaf_request_object *request = Z_YAFREQUESTOBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|b", &controller, &format_name) == FAILURE) {
return;
}
if (EXPECTED(ZSTR_LEN(controller))) {
if (format_name) {
yaf_request_set_controller(request, controller);
} else {
if (request->controller) {
zend_string_release(request->controller);
request->controller = zend_string_copy(controller);
}
}
}
RETURN_ZVAL(getThis(), 1, 0);
}
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::setActionName(string $action, bool $format_name = true)
*/
PHP_METHOD(yaf_request, setActionName) {
zend_string *action;
zend_bool format_name = 1;
yaf_request_object *request = Z_YAFREQUESTOBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|b", &action, &format_name) == FAILURE) {
return;
}
if (EXPECTED(ZSTR_LEN(action))) {
if (format_name) {
yaf_request_set_action(request, action);
} else {
if (request->action) {
zend_string_release(request->action);
request->action = zend_string_copy(action);
}
}
}
RETURN_ZVAL(getThis(), 1, 0);
}
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::setParam(mixed $value)
*/
PHP_METHOD(yaf_request, setParam) {
unsigned argc;
argc = ZEND_NUM_ARGS();
if (1 == argc) {
zval *value ;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "a", &value) == FAILURE) {
return;
}
if (yaf_request_set_params_multi(Z_YAFREQUESTOBJ_P(getThis()), value)) {
RETURN_ZVAL(getThis(), 1, 0);
}
} else if (2 == argc) {
zval *value;
zend_string *name;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sz", &name, &value) == FAILURE) {
return;
}
if (yaf_request_set_params_single(Z_YAFREQUESTOBJ_P(getThis()), name, value)) {
RETURN_ZVAL(getThis(), 1, 0);
}
} else {
WRONG_PARAM_COUNT;
}
RETURN_FALSE;
}
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::getParam(string $name, $mixed $default = NULL)
*/
PHP_METHOD(yaf_request, getParam) {
zend_string *name;
zval *def = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|z", &name, &def) == FAILURE) {
return;
} else {
zval *value = yaf_request_get_param(Z_YAFREQUESTOBJ_P(getThis()), name);
if (value) {
RETURN_ZVAL(value, 1, 0);
}
if (def) {
RETURN_ZVAL(def, 1, 0);
}
}
RETURN_NULL();
}
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::getException(void)
*/
PHP_METHOD(yaf_request, getException) {
zval *exception;
yaf_request_object *request = Z_YAFREQUESTOBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if ((exception = yaf_request_get_param_str(request, ZEND_STRL("exception")))) {
RETURN_ZVAL(exception, 1, 0);
}
RETURN_NULL();
}
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::getParams(void)
*/
PHP_METHOD(yaf_request, getParams) {
yaf_request_object *request = Z_YAFREQUESTOBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (request->params) {
GC_ADDREF(request->params);
RETURN_ARR(request->params);
}
#if PHP_VERSION_ID < 70400
array_init(return_value);
#else
RETURN_EMPTY_ARRAY();
#endif
}
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::clearParams(void)
*/
PHP_METHOD(yaf_request, clearParams) {
yaf_request_object *request = Z_YAFREQUESTOBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
yaf_request_clean_params(request);
RETURN_ZVAL(getThis(), 1, 0);
}
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::getLanguage(void)
*/
PHP_METHOD(yaf_request, getLanguage) {
yaf_request_object *request = Z_YAFREQUESTOBJ_P(getThis());
zend_string *language = yaf_request_get_language(request);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (UNEXPECTED(language == NULL)) {
RETURN_NULL();
}
RETURN_STR(language);
}
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::getMethod(void)
*/
PHP_METHOD(yaf_request, getMethod) {
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_STR(yaf_request_get_method(Z_YAFREQUESTOBJ_P(getThis())));
}
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::isDispatched(void)
*/
PHP_METHOD(yaf_request, isDispatched) {
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_BOOL(yaf_request_is_dispatched(Z_YAFREQUESTOBJ_P(getThis())));
}
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::setDispatched(bool $dispatched = true)
*/
PHP_METHOD(yaf_request, setDispatched) {
zend_bool state = 1;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &state) == FAILURE){
return;
}
yaf_request_set_dispatched(Z_YAFREQUESTOBJ_P(getThis()), state);
RETURN_ZVAL(getThis(), 1, 0);
}
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::setBaseUri(string $name)
*/
PHP_METHOD(yaf_request, setBaseUri) {
zend_string *uri;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &uri) == FAILURE) {
return;
}
if (ZSTR_LEN(uri) == 0) {
RETURN_FALSE;
}
if (yaf_request_set_base_uri(Z_YAFREQUESTOBJ_P(getThis()), uri, NULL)) {
RETURN_ZVAL(getThis(), 1, 0);
}
RETURN_FALSE;
}
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::getBaseUri(void)
*/
PHP_METHOD(yaf_request, getBaseUri) {
yaf_request_object *request = Z_YAFREQUESTOBJ_P(getThis());
zend_string *base_uri = yaf_request_get_base_uri(request);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (UNEXPECTED(base_uri == NULL)) {
RETURN_EMPTY_STRING();
}
RETURN_STR(base_uri);
}
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::getRequestUri(void)
*/
PHP_METHOD(yaf_request, getRequestUri) {
yaf_request_object *request = Z_YAFREQUESTOBJ_P(getThis());
zend_string *uri = yaf_request_get_uri(request);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (UNEXPECTED(uri == NULL)) {
RETURN_EMPTY_STRING();
}
RETURN_STR(uri);
}
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::setRequestUri(string $name)
*/
PHP_METHOD(yaf_request, setRequestUri) {
zend_string *uri;
yaf_request_object *req = Z_YAFREQUESTOBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &uri) == FAILURE) {
return;
}
yaf_request_set_uri(req, uri);
RETURN_ZVAL(getThis(), 1, 0);
}
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::isRouted(void)
*/
PHP_METHOD(yaf_request, isRouted) {
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_BOOL(yaf_request_is_routed(Z_YAFREQUESTOBJ_P(getThis())));
}
/* }}} */
/** {{{ proto public Yaf_Request_Abstract::setRouted(bool $routed = true)
*/
PHP_METHOD(yaf_request, setRouted) {
zend_bool state = 1;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &state) == FAILURE){
return;
}
yaf_request_set_routed(Z_YAFREQUESTOBJ_P(getThis()), state);
RETURN_ZVAL(getThis(), 1, 0);
}
/* }}} */
/** {{{ yaf_request_methods
*/
zend_function_entry yaf_request_methods[] = {
PHP_ME(yaf_request, isGet, yaf_request_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, isPost, yaf_request_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, isDelete, yaf_request_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, isPatch, yaf_request_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, isPut, yaf_request_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, isHead, yaf_request_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, isOptions, yaf_request_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, isCli, yaf_request_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, isXmlHttpRequest, yaf_request_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, getQuery, yaf_request_get_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, getRequest, yaf_request_get_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, getPost, yaf_request_get_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, getCookie, yaf_request_get_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, getRaw, yaf_request_get_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, getFiles, yaf_request_get_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, get, yaf_request_get_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, getServer, yaf_request_get_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, getEnv, yaf_request_get_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, setParam, yaf_request_set_param_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, getParam, yaf_request_get_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, getParams, yaf_request_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, clearParams, yaf_request_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, getException, yaf_request_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, getModuleName, yaf_request_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, getControllerName, yaf_request_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, getActionName, yaf_request_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, setModuleName, yaf_request_set_module_name_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, setControllerName, yaf_request_set_controller_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, setActionName, yaf_request_set_action_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, getMethod, yaf_request_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, getLanguage, yaf_request_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, setBaseUri, yaf_request_set_baseuri_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, getBaseUri, yaf_request_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, getRequestUri, yaf_request_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, setRequestUri, yaf_request_set_request_uri_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_request, isDispatched, yaf_request_void_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(yaf_request, setDispatched, yaf_request_set_dispatched_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(yaf_request, isRouted, yaf_request_void_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(yaf_request, setRouted, yaf_request_set_routed_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
{NULL, NULL, NULL}
};
/* }}} */
/** {{{ YAF_STARTUP_FUNCTION
*/
YAF_STARTUP_FUNCTION(request){
zend_class_entry ce;
YAF_INIT_CLASS_ENTRY(ce, "Yaf_Request_Abstract", "Yaf\\Request_Abstract", yaf_request_methods);
yaf_request_ce = zend_register_internal_class_ex(&ce, NULL);
yaf_request_ce->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS;
yaf_request_ce->create_object = yaf_request_new;
yaf_request_ce->serialize = zend_class_serialize_deny;
yaf_request_ce->unserialize = zend_class_unserialize_deny;
memcpy(&yaf_request_obj_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
yaf_request_obj_handlers.offset = XtOffsetOf(yaf_request_object, std);
yaf_request_obj_handlers.free_obj = yaf_request_object_free;
yaf_request_obj_handlers.get_properties = yaf_request_get_properties;;
yaf_request_obj_handlers.read_property = yaf_request_read_property;
yaf_request_obj_handlers.write_property = yaf_request_write_property;
yaf_request_obj_handlers.get_gc = yaf_request_get_gc;
yaf_request_obj_handlers.clone_obj = NULL;
YAF_STARTUP(request_http);
YAF_STARTUP(request_simple);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化