示例#1
0
/**
 * Check if HTTP method match any of the passed methods
 *
 * @param string|array $methods
 * @return boolean
 */
PHP_METHOD(Phalcon_Http_Request, isMethod) {

    zval *methods, *http_method, *is_equals = NULL, *method = NULL;
    HashTable *ah0;
    HashPosition hp0;
    zval **hd;

    PHALCON_MM_GROW();

    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &methods) == FAILURE) {
        PHALCON_MM_RESTORE();
        RETURN_NULL();
    }

    PHALCON_INIT_VAR(http_method);
    PHALCON_CALL_METHOD(http_method, this_ptr, "getmethod", PH_NO_CHECK);
    if (Z_TYPE_P(methods) == IS_STRING) {
        PHALCON_INIT_VAR(is_equals);
        is_equal_function(is_equals, methods, http_method TSRMLS_CC);

        RETURN_NCTOR(is_equals);
    } else {

        if (!phalcon_valid_foreach(methods TSRMLS_CC)) {
            return;
        }

        ah0 = Z_ARRVAL_P(methods);
        zend_hash_internal_pointer_reset_ex(ah0, &hp0);

ph_cycle_start_0:

        if (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS) {
            goto ph_cycle_end_0;
        }

        PHALCON_GET_FOREACH_VALUE(method);

        PHALCON_INIT_NVAR(is_equals);
        is_equal_function(is_equals, method, http_method TSRMLS_CC);
        if (PHALCON_IS_TRUE(is_equals)) {
            PHALCON_MM_RESTORE();
            RETURN_TRUE;
        }

        zend_hash_move_forward_ex(ah0, &hp0);
        goto ph_cycle_start_0;

ph_cycle_end_0:
        if(0) {}

    }

    PHALCON_MM_RESTORE();
    RETURN_FALSE;
}
示例#2
0
文件: form.c 项目: BlueShark/cphalcon
/**
 * Returns the number of elements in the form
 *
 * @return int
 */
PHP_METHOD(Phalcon_Forms_Form, count){

	zval *elements, *number;

	PHALCON_MM_GROW();

	PHALCON_OBS_VAR(elements);
	phalcon_read_property(&elements, this_ptr, SL("_elements"), PH_NOISY_CC);
	
	PHALCON_INIT_VAR(number);
	phalcon_fast_count(number, elements TSRMLS_CC);
	RETURN_NCTOR(number);
}
示例#3
0
/**
 * Returns the number of arguments that the annotation has
 *
 * @return int
 */
PHP_METHOD(Phalcon_Annotations_Annotation, numberArguments){

	zval *arguments, *number;

	PHALCON_MM_GROW();

	PHALCON_OBS_VAR(arguments);
	phalcon_read_property(&arguments, this_ptr, SL("_arguments"), PH_NOISY_CC);
	
	PHALCON_INIT_VAR(number);
	phalcon_fast_count(number, arguments TSRMLS_CC);
	RETURN_NCTOR(number);
}
示例#4
0
/**
 * Returns the number of messages in the list
 *
 * @return int
 */
PHP_METHOD(Phalcon_Validation_Message_Group, count){

	zval *messages, *number;

	PHALCON_MM_GROW();

	PHALCON_OBS_VAR(messages);
	phalcon_read_property(&messages, this_ptr, SL("_messages"), PH_NOISY_CC);
	
	PHALCON_INIT_VAR(number);
	phalcon_fast_count(number, messages TSRMLS_CC);
	RETURN_NCTOR(number);
}
示例#5
0
/**
 * Checks whether transaction is managed by a transaction manager
 *
 * @return boolean
 */
PHP_METHOD(Phalcon_Mvc_Model_Transaction, isManaged){

	zval *manager = NULL;
	zval *r0 = NULL;

	PHALCON_MM_GROW();
	PHALCON_INIT_VAR(manager);
	phalcon_read_property(&manager, this_ptr, SL("_manager"), PH_NOISY_CC);
	
	PHALCON_ALLOC_ZVAL_MM(r0);
	boolean_not_function(r0, manager TSRMLS_CC);
	
	RETURN_NCTOR(r0);
}
示例#6
0
/**
 * Checks whether offset exists in the resultset
 *
 * @param int $index
 * @return boolean
 */
PHP_METHOD(Phalcon_Mvc_Model_Resultset, offsetExists){

	zval *index, *count, *exists;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 0, &index);
	
	PHALCON_INIT_VAR(count);
	phalcon_call_method(count, this_ptr, "count");
	
	PHALCON_INIT_VAR(exists);
	is_smaller_function(exists, index, count TSRMLS_CC);
	RETURN_NCTOR(exists);
}
示例#7
0
文件: pool.c 项目: rcpsec/cphalcon
/**
 * Check if a default descriptor has already defined
 *
 * @return boolean
 */
PHP_METHOD(Phalcon_Db_Pool, hasDefaultDescriptor){

	zval *t0 = NULL, *t1 = NULL;
	zval *r0 = NULL;

	PHALCON_MM_GROW();
	PHALCON_OBSERVE_VAR(t0);
	phalcon_read_static_property(&t0, SL("Phalcon_Db_Pool"), SL("_defaultDescriptor") TSRMLS_CC);
	PHALCON_INIT_VAR(t1);
	ZVAL_NULL(t1);
	PHALCON_INIT_VAR(r0);
	is_not_identical_function(r0, t1, t0 TSRMLS_CC);
	
	RETURN_NCTOR(r0);
}
示例#8
0
/**
 * Checks whether HTTP method is PUT. if $_SERVER['REQUEST_METHOD']=='PUT'
 *
 * @return boolean
 */
PHP_METHOD(Phalcon_Http_Request, isPut){

	zval *put, *method, *is_put;

	PHALCON_MM_GROW();

	PHALCON_INIT_VAR(put);
	ZVAL_STRING(put, "PUT", 1);
	
	PHALCON_INIT_VAR(method);
	PHALCON_CALL_METHOD(method, this_ptr, "getmethod");
	
	PHALCON_INIT_VAR(is_put);
	is_equal_function(is_put, method, put TSRMLS_CC);
	RETURN_NCTOR(is_put);
}
示例#9
0
/**
 * Checks whether request has been made using any secure layer
 *
 * @return boolean
 */
PHP_METHOD(Phalcon_Http_Request, isSecureRequest){

	zval *scheme, *https, *is_equal;

	PHALCON_MM_GROW();

	PHALCON_INIT_VAR(scheme);
	PHALCON_CALL_METHOD(scheme, this_ptr, "getscheme");
	
	PHALCON_INIT_VAR(https);
	ZVAL_STRING(https, "https", 1);
	
	PHALCON_INIT_VAR(is_equal);
	is_identical_function(is_equal, https, scheme TSRMLS_CC);
	RETURN_NCTOR(is_equal);
}
示例#10
0
/**
 * Checks whether $_SERVER superglobal has certain index
 *
 * @param string $name
 * @return mixed
 */
PHP_METHOD(Phalcon_Http_Request, hasServer){

	zval *name, *_SERVER;
	zval *r0 = NULL;

	PHALCON_MM_GROW();

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &name) == FAILURE) {
		RETURN_MM_NULL();
	}

	phalcon_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC);
	PHALCON_INIT_VAR(r0);
	ZVAL_BOOL(r0, phalcon_array_isset(_SERVER, name));
	RETURN_NCTOR(r0);
}
示例#11
0
/**
 * Checks whether HTTP method is HEAD. if $_SERVER['REQUEST_METHOD']=='HEAD'
 *
 * @return boolean
 */
PHP_METHOD(Phalcon_Http_Request, isHead){

	zval *head, *method, *is_head;

	PHALCON_MM_GROW();

	PHALCON_INIT_VAR(head);
	ZVAL_STRING(head, "HEAD", 1);
	
	PHALCON_INIT_VAR(method);
	PHALCON_CALL_METHOD(method, this_ptr, "getmethod");
	
	PHALCON_INIT_VAR(is_head);
	is_equal_function(is_head, method, head TSRMLS_CC);
	RETURN_NCTOR(is_head);
}
示例#12
0
/**
 * Checks whether HTTP method is PATCH. if $_SERVER['REQUEST_METHOD']=='PATCH'
 *
 * @return boolean
 */
PHP_METHOD(Phalcon_Http_Request, isPatch){

	zval *patch, *method, *is_patch;

	PHALCON_MM_GROW();

	PHALCON_INIT_VAR(patch);
	ZVAL_STRING(patch, "PATCH", 1);
	
	PHALCON_INIT_VAR(method);
	PHALCON_CALL_METHOD(method, this_ptr, "getmethod");
	
	PHALCON_INIT_VAR(is_patch);
	is_equal_function(is_patch, method, patch TSRMLS_CC);
	RETURN_NCTOR(is_patch);
}
示例#13
0
/**
 *
 * Checks whether HTTP method is GET. if $_SERVER['REQUEST_METHOD']=='GET'
 *
 * @return boolean
 */
PHP_METHOD(Phalcon_Http_Request, isGet){

	zval *get, *method, *is_get;

	PHALCON_MM_GROW();

	PHALCON_INIT_VAR(get);
	ZVAL_STRING(get, "GET", 1);
	
	PHALCON_INIT_VAR(method);
	phalcon_call_method(method, this_ptr, "getmethod");
	
	PHALCON_INIT_VAR(is_get);
	is_equal_function(is_get, method, get TSRMLS_CC);
	RETURN_NCTOR(is_get);
}
示例#14
0
/**
 * Check if the component is currently caching the output content
 *
 * @return boolean
 */
PHP_METHOD(Phalcon_Mvc_View, isCaching){

	zval *zero, *cache_level, *is_caching;

	PHALCON_MM_GROW();

	PHALCON_INIT_VAR(zero);
	ZVAL_LONG(zero, 0);
	
	PHALCON_OBS_VAR(cache_level);
	phalcon_read_property_this(&cache_level, this_ptr, SL("_cacheLevel"), PH_NOISY_CC);
	
	PHALCON_INIT_VAR(is_caching);
	is_smaller_function(is_caching, zero, cache_level TSRMLS_CC);
	RETURN_NCTOR(is_caching);
}
示例#15
0
/**
 * Check whether the DI contains a service by a name
 *
 * @param string $name
 * @return boolean
 */
PHP_METHOD(Phalcon_DI, has){

	zval *name, *services, *is_set_service = NULL;
	zval *r0 = NULL;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 0, &name);
	
	PHALCON_OBS_VAR(services);
	phalcon_read_property_this(&services, this_ptr, SL("_services"), PH_NOISY_CC);
	
	PHALCON_INIT_VAR(r0);
	ZVAL_BOOL(r0, phalcon_array_isset(services, name));
	PHALCON_CPY_WRT(is_set_service, r0);
	RETURN_NCTOR(is_set_service);
}
示例#16
0
/**
 * Checks whether HTTP method is POST. if $_SERVER['REQUEST_METHOD']=='POST'
 *
 * @return boolean
 */
PHP_METHOD(Phalcon_Http_Request, isPost) {

    zval *post, *method, *is_post;

    PHALCON_MM_GROW();

    PHALCON_INIT_VAR(post);
    ZVAL_STRING(post, "POST", 1);

    PHALCON_INIT_VAR(method);
    PHALCON_CALL_METHOD(method, this_ptr, "getmethod", PH_NO_CHECK);

    PHALCON_INIT_VAR(is_post);
    is_equal_function(is_post, method, post TSRMLS_CC);

    RETURN_NCTOR(is_post);
}
示例#17
0
/**
 * Checks if the internal meta-data container is empty
 *
 * @return boolean
 */
PHP_METHOD(Phalcon_Model_MetaData, isEmpty){

	zval *t0 = NULL, *t1 = NULL;
	zval *r0 = NULL, *r1 = NULL;

	PHALCON_MM_GROW();
	PHALCON_ALLOC_ZVAL_MM(t0);
	phalcon_read_property(&t0, this_ptr, SL("_metaData"), PHALCON_NOISY TSRMLS_CC);
	PHALCON_ALLOC_ZVAL_MM(r0);
	phalcon_fast_count(r0, t0 TSRMLS_CC);
	PHALCON_INIT_VAR(t1);
	ZVAL_LONG(t1, 0);
	PHALCON_ALLOC_ZVAL_MM(r1);
	is_equal_function(r1, r0, t1 TSRMLS_CC);
	
	RETURN_NCTOR(r1);
}
示例#18
0
/**
 * Tell if the resultset if fresh or an old cached
 *
 * @return boolean
 */
PHP_METHOD(Phalcon_Mvc_Model_Resultset, isFresh){

	zval *type = NULL, *is_fresh = NULL;
	zval *t0 = NULL;

	PHALCON_MM_GROW();
	PHALCON_INIT_VAR(type);
	phalcon_read_property(&type, this_ptr, SL("_type"), PH_NOISY_CC);
	
	PHALCON_INIT_VAR(t0);
	ZVAL_LONG(t0, 1);
	
	PHALCON_INIT_VAR(is_fresh);
	is_equal_function(is_fresh, type, t0 TSRMLS_CC);
	
	RETURN_NCTOR(is_fresh);
}
示例#19
0
/**
 * Check whether a option has been defined in the validator options
 *
 * @param string $option
 * @return boolean
 */
PHP_METHOD(Phalcon_Mvc_Model_Validator, isSetOption){

	zval *option, *options, *is_set = NULL;
	zval *r0 = NULL;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 0, &option);
	
	PHALCON_OBS_VAR(options);
	phalcon_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC);
	
	PHALCON_INIT_VAR(r0);
	ZVAL_BOOL(r0, phalcon_array_isset(options, option));
	PHALCON_CPY_WRT(is_set, r0);
	RETURN_NCTOR(is_set);
}
示例#20
0
/**
 * Check whether is defined a translation key in the internal array
 *
 * @param 	string $index
 * @return bool
 */
PHP_METHOD(Phalcon_Translate_Adapter_NativeArray, exists){

	zval *index, *translate, *exists = NULL;
	zval *r0 = NULL;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 0, &index);
	
	PHALCON_OBS_VAR(translate);
	phalcon_read_property_this(&translate, this_ptr, SL("_translate"), PH_NOISY_CC);
	
	PHALCON_INIT_VAR(r0);
	ZVAL_BOOL(r0, phalcon_array_isset(translate, index));
	PHALCON_CPY_WRT(exists, r0);
	RETURN_NCTOR(exists);
}
示例#21
0
文件: request.c 项目: meibk/cphalcon
/**
 * Checks whether HTTP method is OPTIONS. if $_SERVER['REQUEST_METHOD']=='OPTIONS'
 *
 * @return boolean
 */
PHP_METHOD(Phalcon_Http_Request, isOptions){

	zval *method = NULL, *is_options = NULL;
	zval *t0 = NULL;

	PHALCON_MM_GROW();
	PHALCON_INIT_VAR(method);
	PHALCON_CALL_METHOD(method, this_ptr, "getmethod", PH_NO_CHECK);
	
	PHALCON_INIT_VAR(t0);
	ZVAL_STRING(t0, "OPTIONS", 1);
	
	PHALCON_INIT_VAR(is_options);
	is_equal_function(is_options, method, t0 TSRMLS_CC);
	
	RETURN_NCTOR(is_options);
}
示例#22
0
文件: request.c 项目: meibk/cphalcon
/**
 * Checks whether request has been made using any secure layer
 *
 * @return boolean
 */
PHP_METHOD(Phalcon_Http_Request, isSecureRequest){

	zval *scheme = NULL, *is_equal = NULL;
	zval *t0 = NULL;

	PHALCON_MM_GROW();
	PHALCON_INIT_VAR(scheme);
	PHALCON_CALL_METHOD(scheme, this_ptr, "getscheme", PH_NO_CHECK);
	
	PHALCON_INIT_VAR(t0);
	ZVAL_STRING(t0, "https", 1);
	
	PHALCON_INIT_VAR(is_equal);
	is_identical_function(is_equal, t0, scheme TSRMLS_CC);
	
	RETURN_NCTOR(is_equal);
}
示例#23
0
/**
 * Check whether resource exist in the resources list
 *
 * @param  string $resourceName
 * @return boolean
 */
PHP_METHOD(Phalcon_Acl_Adapter_Memory, isResource){

	zval *resource_name, *resources_names, *is_resource = NULL;
	zval *r0 = NULL;

	PHALCON_MM_GROW();

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &resource_name) == FAILURE) {
		RETURN_MM_NULL();
	}

	PHALCON_OBS_VAR(resources_names);
	phalcon_read_property(&resources_names, this_ptr, SL("_resourcesNames"), PH_NOISY_CC);
	
	PHALCON_INIT_VAR(r0);
	ZVAL_BOOL(r0, phalcon_array_isset(resources_names, resource_name));
	PHALCON_CPY_WRT(is_resource, r0);
	RETURN_NCTOR(is_resource);
}
示例#24
0
/**
 * Checks whether offset exists in the resultset
 *
 * @param int $index
 * @return boolean
 */
PHP_METHOD(Phalcon_Mvc_Model_Resultset, offsetExists){

	zval *index = NULL, *count = NULL, *exists = NULL;

	PHALCON_MM_GROW();
	
	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &index) == FAILURE) {
		PHALCON_MM_RESTORE();
		RETURN_NULL();
	}

	PHALCON_INIT_VAR(count);
	PHALCON_CALL_METHOD(count, this_ptr, "count", PH_NO_CHECK);
	
	PHALCON_INIT_VAR(exists);
	is_smaller_function(exists, index, count TSRMLS_CC);
	
	RETURN_NCTOR(exists);
}
示例#25
0
/**
 * Checks whether request has been made using ajax. Checks if $_SERVER['HTTP_X_REQUESTED_WITH']=='XMLHttpRequest'
 *
 * @return boolean
 */
PHP_METHOD(Phalcon_Http_Request, isAjax){

	zval *requested_header, *xml_http_request;
	zval *requested_with, *is_ajax;

	PHALCON_MM_GROW();

	PHALCON_INIT_VAR(requested_header);
	ZVAL_STRING(requested_header, "HTTP_X_REQUESTED_WITH", 1);
	
	PHALCON_INIT_VAR(xml_http_request);
	ZVAL_STRING(xml_http_request, "XMLHttpRequest", 1);
	
	PHALCON_INIT_VAR(requested_with);
	PHALCON_CALL_METHOD_PARAMS_1(requested_with, this_ptr, "getheader", requested_header);
	
	PHALCON_INIT_VAR(is_ajax);
	is_equal_function(is_ajax, requested_with, xml_http_request TSRMLS_CC);
	RETURN_NCTOR(is_ajax);
}
示例#26
0
文件: request.c 项目: meibk/cphalcon
/**
 * Checks whether request has been made using ajax
 *
 * @return boolean
 */
PHP_METHOD(Phalcon_Http_Request, isAjax){

	zval *requested_header = NULL, *requested_with = NULL, *is_ajax = NULL;
	zval *t0 = NULL;

	PHALCON_MM_GROW();
	PHALCON_INIT_VAR(requested_header);
	ZVAL_STRING(requested_header, "HTTP_X_REQUESTED_WITH", 1);
	
	PHALCON_INIT_VAR(requested_with);
	PHALCON_CALL_METHOD_PARAMS_1(requested_with, this_ptr, "getheader", requested_header, PH_NO_CHECK);
	
	PHALCON_INIT_VAR(t0);
	ZVAL_STRING(t0, "XMLHttpRequest", 1);
	
	PHALCON_INIT_VAR(is_ajax);
	is_equal_function(is_ajax, requested_with, t0 TSRMLS_CC);
	
	RETURN_NCTOR(is_ajax);
}
示例#27
0
/**
 * Checks if the internal meta-data container is empty
 *
 * @return boolean
 */
PHP_METHOD(Phalcon_Mvc_Model_MetaData, isEmpty){

	zval *meta_data, *number, *is_empty;
	zval *t0 = NULL;

	PHALCON_MM_GROW();

	PHALCON_INIT_VAR(meta_data);
	phalcon_read_property(&meta_data, this_ptr, SL("_metaData"), PH_NOISY_CC);
	
	PHALCON_INIT_VAR(number);
	phalcon_fast_count(number, meta_data TSRMLS_CC);
	
	PHALCON_INIT_VAR(t0);
	ZVAL_LONG(t0, 0);
	
	PHALCON_INIT_VAR(is_empty);
	is_equal_function(is_empty, number, t0 TSRMLS_CC);
	
	RETURN_NCTOR(is_empty);
}
示例#28
0
/**
 * Check whether a model is already initialized
 *
 * @param string $modelName
 * @return bool
 */
PHP_METHOD(Phalcon_Mvc_Collection_Manager, isInitialized){

	zval *model_name, *initialized, *lowercased;
	zval *is_intitialized = NULL;
	zval *r0 = NULL;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 0, &model_name);
	
	PHALCON_OBS_VAR(initialized);
	phalcon_read_property_this(&initialized, this_ptr, SL("_initialized"), PH_NOISY_CC);
	
	PHALCON_INIT_VAR(lowercased);
	phalcon_fast_strtolower(lowercased, model_name);
	
	PHALCON_INIT_VAR(r0);
	ZVAL_BOOL(r0, phalcon_array_isset(initialized, lowercased));
	PHALCON_CPY_WRT(is_intitialized, r0);
	RETURN_NCTOR(is_intitialized);
}
示例#29
0
文件: request.c 项目: meibk/cphalcon
/**
 * Checks whether $_SERVER superglobal has certain index
 *
 * @param string $name
 * @return mixed
 */
PHP_METHOD(Phalcon_Http_Request, hasServer){

	zval *name = NULL;
	zval *g0 = NULL;
	zval *r0 = NULL;
	int eval_int;

	PHALCON_MM_GROW();
	
	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &name) == FAILURE) {
		PHALCON_MM_RESTORE();
		RETURN_NULL();
	}

	phalcon_get_global(&g0, SL("_SERVER")+1 TSRMLS_CC);
	eval_int = phalcon_array_isset(g0, name);
	PHALCON_ALLOC_ZVAL_MM(r0);
	ZVAL_BOOL(r0, eval_int);
	
	RETURN_NCTOR(r0);
}
示例#30
0
文件: request.c 项目: meibk/cphalcon
/**
 * Checks whether request include attached files
 *
 * @return boolean
 */
PHP_METHOD(Phalcon_Http_Request, hasFiles){

	zval *files = NULL, *number_files = NULL, *has_files = NULL;
	zval *g0 = NULL;
	zval *t0 = NULL;

	PHALCON_MM_GROW();
	phalcon_get_global(&g0, SL("_FILES")+1 TSRMLS_CC);
	PHALCON_CPY_WRT(files, g0);
	
	PHALCON_INIT_VAR(number_files);
	phalcon_fast_count(number_files, g0 TSRMLS_CC);
	
	PHALCON_INIT_VAR(t0);
	ZVAL_LONG(t0, 0);
	
	PHALCON_INIT_VAR(has_files);
	is_smaller_function(has_files, t0, number_files TSRMLS_CC);
	
	RETURN_NCTOR(has_files);
}