/** * Get rewrite info. This info is read from $_GET['_url']. This returns '/' if the rewrite information cannot be read * * @return string */ PHP_METHOD(Test_Router, getRewriteUri) { zval *url = NULL, *urlParts, *realUri, *_0, *_GET, *_SERVER; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_uriSource"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { ZEPHIR_OBS_VAR(url); zephir_get_global(&_GET, SS("_GET") TSRMLS_CC); if (zephir_array_isset_string_fetch(&url, _GET, SS("_url"), 0 TSRMLS_CC)) { if (!(zephir_is_true(url))) { RETURN_CCTOR(url); } } } else { ZEPHIR_OBS_NVAR(url); zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); if (zephir_array_isset_string_fetch(&url, _SERVER, SS("REQUEST_URI"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(urlParts); zephir_fast_explode_str(urlParts, SL("?"), url, LONG_MAX TSRMLS_CC); zephir_array_fetch_long(&realUri, urlParts, 0, PH_NOISY | PH_READONLY TSRMLS_CC); if (!(zephir_is_true(realUri))) { RETURN_CTOR(realUri); } } } RETURN_MM_STRING("/", 1); }
/** * Check if everything in required scope is contained in available scope. * * @param string required_scope A space-separated string of scopes. * * @return boolean TRUE if everything in required scope is contained in available scope, * and FALSE if it isn't. * * @see http://tools.ietf.org/html/rfc6749#section-7 * * @ingroup oauth2_section_7 */ PHP_METHOD(OAuth2_Scope, checkScope) { int ZEPHIR_LAST_CALL_STATUS; zephir_nts_static zephir_fcall_cache_entry *_3 = NULL; zval *required_scope_param = NULL, *available_scope_param = NULL, *scope1, *scope2, *_0, *_1, *_2 = NULL; zval *required_scope = NULL, *available_scope = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &required_scope_param, &available_scope_param); if (unlikely(Z_TYPE_P(required_scope_param) != IS_STRING && Z_TYPE_P(required_scope_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'required_scope' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(required_scope_param) == IS_STRING)) { zephir_get_strval(required_scope, required_scope_param); } else { ZEPHIR_INIT_VAR(required_scope); ZVAL_EMPTY_STRING(required_scope); } if (unlikely(Z_TYPE_P(available_scope_param) != IS_STRING && Z_TYPE_P(available_scope_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'available_scope' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(available_scope_param) == IS_STRING)) { zephir_get_strval(available_scope, available_scope_param); } else { ZEPHIR_INIT_VAR(available_scope); ZVAL_EMPTY_STRING(available_scope); } ZEPHIR_INIT_VAR(scope1); ZEPHIR_INIT_VAR(_0); zephir_fast_trim(_0, required_scope, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); zephir_fast_explode_str(scope1, SL(" "), _0, LONG_MAX TSRMLS_CC); ZEPHIR_INIT_VAR(scope2); ZEPHIR_INIT_VAR(_1); zephir_fast_trim(_1, available_scope, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); zephir_fast_explode_str(scope2, SL(" "), _1, LONG_MAX TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_2, "array_diff", &_3, scope1, scope2); zephir_check_call_status(); RETURN_MM_BOOL(zephir_fast_count_int(_2 TSRMLS_CC) == 0); }
PHP_METHOD(Test_Strings, testExplodeStr) { zval *str; zephir_fetch_params(0, 1, 0, &str); zephir_fast_explode_str(return_value, SL(","), str, LONG_MAX TSRMLS_CC); return; }
/** * Reads the latest status from the Beanstalkd server */ PHP_METHOD(Phalcon_Queue_Beanstalk, readStatus) { int ZEPHIR_LAST_CALL_STATUS; zval *_0 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "read", NULL); zephir_check_call_status(); zephir_fast_explode_str(return_value, SL(" "), _0, LONG_MAX TSRMLS_CC); RETURN_MM(); }
PHP_METHOD(Test_Strings, testExplodeStr) { zval *str, str_sub; zval *this_ptr = getThis(); ZVAL_UNDEF(&str_sub); zephir_fetch_params(0, 1, 0, &str); zephir_fast_explode_str(return_value, SL(","), str, LONG_MAX TSRMLS_CC); return; }
PHP_METHOD(Test_Strings, testExplodeLimit) { int limit; zval *str, *limit_param = NULL, _0; zephir_fetch_params(0, 2, 0, &str, &limit_param); limit = zephir_get_intval(limit_param); ZEPHIR_SINIT_VAR(_0); ZVAL_LONG(&_0, limit); zephir_fast_explode_str(return_value, SL(","), str, zephir_get_intval(&_0) TSRMLS_CC); return; }
/** * Returns the major framework's version * @deprecated Will be removed in 4.0.0 */ PHP_METHOD(Phalcon_Debug, getMajorVersion) { zval *parts = NULL, *_0 = NULL, *_2; int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_1 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_CE_STATIC(&_0, phalcon_version_ce, "get", &_1, 160); zephir_check_call_status(); ZEPHIR_INIT_VAR(parts); zephir_fast_explode_str(parts, SL(" "), _0, LONG_MAX TSRMLS_CC); zephir_array_fetch_long(&_2, parts, 0, PH_NOISY | PH_READONLY, "phalcon/debug.zep", 279 TSRMLS_CC); RETURN_CTOR(_2); }
/** * Reads the latest status from the Beanstalkd server */ PHP_METHOD(Phalcon_Queue_Beanstalk, readStatus) { zval *status = NULL; int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&status, this_ptr, "read", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { array_init(return_value); RETURN_MM(); } zephir_fast_explode_str(return_value, SL(" "), status, LONG_MAX TSRMLS_CC); RETURN_MM(); }
PHP_METHOD(Test_Strings, testExplodeLimit) { zend_long limit; zval *str, str_sub, *limit_param = NULL, _0; zval *this_ptr = getThis(); ZVAL_UNDEF(&str_sub); ZVAL_UNDEF(&_0); zephir_fetch_params(0, 2, 0, &str, &limit_param); limit = zephir_get_intval(limit_param); ZVAL_LONG(&_0, limit); zephir_fast_explode_str(return_value, SL(","), str, zephir_get_intval(&_0) TSRMLS_CC); return; }
PHP_METHOD(phalcon_0__closure, __invoke) { int ZEPHIR_LAST_CALL_STATUS; zval *matches, *words, *_0, *_1, *_2 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &matches); zephir_array_fetch_long(&_0, matches, 1, PH_NOISY | PH_READONLY, "phalcon/text.zep", 272 TSRMLS_CC); ZEPHIR_INIT_VAR(words); zephir_fast_explode_str(words, SL("|"), _0, LONG_MAX TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_2, "array_rand", NULL, 442, words); zephir_check_call_status(); zephir_array_fetch(&_1, words, _2, PH_NOISY | PH_READONLY, "phalcon/text.zep", 273 TSRMLS_CC); RETURN_CTOR(_1); }
PHP_METHOD(Cake_Core_Functions, pluginSplit) { zend_bool dotAppend; zval *name_param = NULL, *dotAppend_param = NULL, *plugin_param = NULL, _0, *_1, *parts, *_2; zval *name = NULL, *plugin = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &name_param, &dotAppend_param, &plugin_param); zephir_get_strval(name, name_param); if (!dotAppend_param) { dotAppend = 0; } else { dotAppend = zephir_get_boolval(dotAppend_param); } if (!plugin_param) { ZEPHIR_INIT_VAR(plugin); ZVAL_EMPTY_STRING(plugin); } else { zephir_get_strval(plugin, plugin_param); } ZEPHIR_SINIT_VAR(_0); ZVAL_STRING(&_0, ".", 0); ZEPHIR_INIT_VAR(_1); zephir_fast_strpos(_1, name, &_0, 0 ); if (!ZEPHIR_IS_FALSE_IDENTICAL(_1)) { ZEPHIR_INIT_VAR(parts); zephir_fast_explode_str(parts, SL("."), name, 2 TSRMLS_CC); if (dotAppend) { ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, ".", 1); zephir_array_update_long(&parts, 0, &_2, PH_COPY | PH_SEPARATE, "cake/Core/Functions.zep", 12); } RETURN_CCTOR(parts); } zephir_create_array(return_value, 2, 0 TSRMLS_CC); zephir_array_fast_append(return_value, plugin); zephir_array_fast_append(return_value, name); RETURN_MM(); }
/** * Check if the provided scope exists in storage. * * @param string! scope A space-separated string of scopes. * * @return boolean TRUE if it exists, FALSE otherwise. */ PHP_METHOD(OAuth2_Scope, scopeExists) { zephir_nts_static zephir_fcall_cache_entry *_1 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *scope_param = NULL, *scopes, *reservedScope = NULL, *nonReservedScopes = NULL, *_0, *_2, *_3; zval *scope = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &scope_param); if (unlikely(Z_TYPE_P(scope_param) != IS_STRING && Z_TYPE_P(scope_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'scope' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(scope_param) == IS_STRING)) { zephir_get_strval(scope, scope_param); } else { ZEPHIR_INIT_VAR(scope); ZVAL_EMPTY_STRING(scope); } ZEPHIR_INIT_VAR(scopes); ZEPHIR_INIT_VAR(_0); zephir_fast_trim(_0, scope, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); zephir_fast_explode_str(scopes, SL(" "), _0, LONG_MAX TSRMLS_CC); ZEPHIR_CALL_METHOD(&reservedScope, this_ptr, "getreservedscopes", NULL); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&nonReservedScopes, "array_diff", &_1, scopes, reservedScope); zephir_check_call_status(); if (zephir_fast_count_int(nonReservedScopes TSRMLS_CC) == 0) { RETURN_MM_BOOL(1); } ZEPHIR_INIT_VAR(_2); zephir_fast_join_str(_2, SL(" "), nonReservedScopes TSRMLS_CC); ZEPHIR_CPY_WRT(nonReservedScopes, _2); _3 = zephir_fetch_nproperty_this(this_ptr, SL("storage"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_3, "scopeexists", NULL, nonReservedScopes); zephir_check_call_status(); RETURN_MM(); }
PHP_METHOD(Test_Strings, testExplodeStr) { zval *str, str_sub; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&str_sub); zephir_fetch_params(0, 1, 0, &str); zephir_fast_explode_str(return_value, SL(","), str, LONG_MAX TSRMLS_CC); return; }
PHP_METHOD(Yb_Std, valueOf) { zend_bool _3$$3; HashTable *_1; HashPosition _0; zval *key = NULL; zval *arr_param = NULL, *key_param = NULL, *defaultValue = NULL, *parts = NULL, *part = NULL, *returnValue = NULL, *tmpValue = NULL, **_2; zval *arr = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &arr_param, &key_param, &defaultValue); zephir_get_arrval(arr, arr_param); zephir_get_strval(key, key_param); if (!defaultValue) { defaultValue = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(parts); zephir_fast_explode_str(parts, SL("."), key, LONG_MAX TSRMLS_CC); ZEPHIR_CPY_WRT(returnValue, arr); zephir_is_iterable(parts, &_1, &_0, 0, 0, "yb/std.zep", 236); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(part, _2); _3$$3 = Z_TYPE_P(returnValue) != IS_ARRAY; if (!(_3$$3)) { _3$$3 = !(zephir_array_isset_fetch(&tmpValue, returnValue, part, 1 TSRMLS_CC)); } if (_3$$3) { RETVAL_ZVAL(defaultValue, 1, 0); RETURN_MM(); } ZEPHIR_CPY_WRT(returnValue, tmpValue); } RETURN_CCTOR(returnValue); }
PHP_METHOD(Test_Strings, testExplodeLimit) { int limit; zval *str, str_sub, *limit_param = NULL, _0; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&str_sub); ZVAL_UNDEF(&_0); zephir_fetch_params(0, 2, 0, &str, &limit_param); limit = zephir_get_intval(limit_param); ZVAL_LONG(&_0, limit); zephir_fast_explode_str(return_value, SL(","), str, zephir_get_intval(&_0) TSRMLS_CC); return; }
/** * Modifies a table column based on a definition */ PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, modifyColumn) { HashTable *_2$$4; HashPosition _1$$4; zephir_fcall_cache_entry *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *column, *currentColumn = NULL, *sql = NULL, *queries = NULL, *query = NULL, *exception = NULL, *_0, **_3$$4, *_4$$5 = NULL, *_6$$3, *_7$$8 = NULL, *_8$$8, *_9$$8; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 1, &tableName_param, &schemaName_param, &column, ¤tColumn); if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } if (!currentColumn) { currentColumn = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&sql, _0, "modifycolumn", NULL, 0, tableName, schemaName, column, currentColumn); zephir_check_call_status(); ZEPHIR_INIT_VAR(queries); zephir_fast_explode_str(queries, SL(";"), sql, LONG_MAX TSRMLS_CC); if (zephir_fast_count_int(queries TSRMLS_CC) > 1) { /* try_start_1: */ ZEPHIR_CALL_METHOD(NULL, this_ptr, "begin", NULL, 0); zephir_check_call_status_or_jump(try_end_1); zephir_is_iterable(queries, &_2$$4, &_1$$4, 0, 0, "phalcon/db/adapter/pdo/postgresql.zep", 344); for ( ; zend_hash_get_current_data_ex(_2$$4, (void**) &_3$$4, &_1$$4) == SUCCESS ; zend_hash_move_forward_ex(_2$$4, &_1$$4) ) { ZEPHIR_GET_HVALUE(query, _3$$4); if (ZEPHIR_IS_EMPTY(query)) { continue; } ZEPHIR_INIT_LNVAR(_4$$5); ZEPHIR_CONCAT_VS(_4$$5, query, ";"); ZEPHIR_CALL_METHOD(NULL, this_ptr, "query", &_5, 0, _4$$5); zephir_check_call_status_or_jump(try_end_1); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "commit", NULL, 0); zephir_check_call_status_or_jump(try_end_1); RETURN_MM(); try_end_1: if (EG(exception)) { ZEPHIR_INIT_VAR(_6$$3); ZEPHIR_CPY_WRT(_6$$3, EG(exception)); if (zephir_instance_of_ev(_6$$3, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) { zend_clear_exception(TSRMLS_C); ZEPHIR_CPY_WRT(exception, _6$$3); ZEPHIR_CALL_METHOD(NULL, this_ptr, "rollback", NULL, 0); zephir_check_call_status(); zephir_throw_exception_debug(exception, "phalcon/db/adapter/pdo/postgresql.zep", 349 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } } else { ZEPHIR_INIT_VAR(_7$$8); if (!(ZEPHIR_IS_EMPTY(sql))) { zephir_array_fetch_long(&_8$$8, queries, 0, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 353 TSRMLS_CC); ZEPHIR_INIT_VAR(_9$$8); ZEPHIR_CONCAT_VS(_9$$8, _8$$8, ";"); ZEPHIR_CALL_METHOD(&_7$$8, this_ptr, "execute", NULL, 0, _9$$8); zephir_check_call_status(); } else { ZVAL_BOOL(_7$$8, 1); } RETURN_CCTOR(_7$$8); } RETURN_MM_BOOL(1); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_File, validate) { zephir_fcall_cache_entry *_10 = NULL, *_12 = NULL, *_29 = NULL; zend_bool _2, _3, _4, _6, _7, _13, _14, _15, _17, _18, _20, _24, _25, _37, _38, _40; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *value = NULL, *message = NULL, *label = NULL, *replacePairs = NULL, *types = NULL, *byteUnits, *unit = NULL, *maxSize = NULL, *matches, *bytes, *mime = NULL, *tmp = NULL, *width, *height, *minResolution, *maxResolution, *minWidth = NULL, *maxWidth, *minHeight = NULL, *maxHeight, *_0 = NULL, *_SERVER, *_1, *_POST, *_FILES, *_5, *_8, *_9 = NULL, *_11 = NULL, *_16, *_19, *_21, *_22 = NULL, *_23 = NULL, *_26 = NULL, *_27, *_28, *_30 = NULL, *_31, _32 = zval_used_for_init, *_33, *_34 = NULL, *_35 = NULL, *_36, *_39 = NULL, *_41 = NULL; ZEPHIR_MM_GROW(); zephir_get_global(&_FILES, SS("_FILES") TSRMLS_CC); zephir_get_global(&_POST, SS("_POST") TSRMLS_CC); zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } zephir_array_fetch_string(&_1, _SERVER, SL("REQUEST_METHOD"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 62 TSRMLS_CC); _2 = ZEPHIR_IS_STRING(_1, "POST"); if (_2) { _2 = ZEPHIR_IS_EMPTY(_POST); } _3 = _2; if (_3) { _3 = ZEPHIR_IS_EMPTY(_FILES); } _4 = _3; if (_4) { zephir_array_fetch_string(&_5, _SERVER, SL("CONTENT_LENGTH"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 62 TSRMLS_CC); _4 = ZEPHIR_GT_LONG(_5, 0); } _6 = _4; if (!(_6)) { _7 = zephir_array_isset_string(value, SS("error")); if (_7) { zephir_array_fetch_string(&_8, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 62 TSRMLS_CC); _7 = ZEPHIR_IS_LONG_IDENTICAL(_8, 1); } _6 = _7; } if (_6) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "messageIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "FileIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_9, "strtr", &_10, 53, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_11); ZVAL_STRING(_11, "FileIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", &_12, 436, _9, field, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _0); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_9, this_ptr, "issetoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); _13 = zephir_is_true(_9); if (_13) { _14 = ZEPHIR_IS_EMPTY(value); if (!(_14)) { _15 = zephir_array_isset_string(value, SS("error")); if (_15) { zephir_array_fetch_string(&_16, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 75 TSRMLS_CC); _15 = ZEPHIR_IS_LONG_IDENTICAL(_16, 4); } _14 = _15; } _13 = _14; } if (_13) { RETURN_MM_BOOL(1); } _17 = !(zephir_array_isset_string(value, SS("error"))); if (!(_17)) { _17 = !(zephir_array_isset_string(value, SS("tmp_name"))); } _18 = _17; if (!(_18)) { zephir_array_fetch_string(&_19, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 79 TSRMLS_CC); _18 = !ZEPHIR_IS_LONG_IDENTICAL(_19, 0); } _20 = _18; if (!(_20)) { zephir_array_fetch_string(&_21, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 79 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_9, "is_uploaded_file", NULL, 232, _21); zephir_check_call_status(); _20 = !zephir_is_true(_9); } if (_20) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "messageEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "FileEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_11); object_init_ex(_11, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_22, "strtr", &_10, 53, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_23); ZVAL_STRING(_23, "FileEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _11, "__construct", &_12, 436, _22, field, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _11); zephir_check_call_status(); RETURN_MM_BOOL(0); } _24 = !(zephir_array_isset_string(value, SS("name"))); if (!(_24)) { _24 = !(zephir_array_isset_string(value, SS("type"))); } _25 = _24; if (!(_25)) { _25 = !(zephir_array_isset_string(value, SS("size"))); } if (_25) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "messageValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "FileValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_11); object_init_ex(_11, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_9, "strtr", &_10, 53, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_23); ZVAL_STRING(_23, "FileValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _11, "__construct", &_12, 436, _9, field, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _11); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "maxSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_9, this_ptr, "issetoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); if (zephir_is_true(_9)) { ZEPHIR_INIT_VAR(byteUnits); zephir_create_array(byteUnits, 9, 0 TSRMLS_CC); add_assoc_long_ex(byteUnits, SS("B"), 0); add_assoc_long_ex(byteUnits, SS("K"), 10); add_assoc_long_ex(byteUnits, SS("M"), 20); add_assoc_long_ex(byteUnits, SS("G"), 30); add_assoc_long_ex(byteUnits, SS("T"), 40); add_assoc_long_ex(byteUnits, SS("KB"), 10); add_assoc_long_ex(byteUnits, SS("MB"), 20); add_assoc_long_ex(byteUnits, SS("GB"), 30); add_assoc_long_ex(byteUnits, SS("TB"), 40); ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "maxSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&maxSize, this_ptr, "getoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); ZEPHIR_INIT_VAR(unit); ZVAL_STRING(unit, "B", 1); ZEPHIR_INIT_NVAR(_11); ZEPHIR_INIT_NVAR(_23); ZEPHIR_INIT_VAR(_26); zephir_array_keys(_26, byteUnits TSRMLS_CC); zephir_fast_join_str(_23, SL("|"), _26 TSRMLS_CC); ZEPHIR_INIT_VAR(_27); ZEPHIR_CONCAT_SVS(_27, "/^([0-9]+(?:\\.[0-9]+)?)(", _23, ")?$/Di"); zephir_preg_match(_11, _27, maxSize, matches, 0, 0 , 0 TSRMLS_CC); if (zephir_array_isset_long(matches, 2)) { ZEPHIR_OBS_NVAR(unit); zephir_array_fetch_long(&unit, matches, 2, PH_NOISY, "phalcon/validation/validator/file.zep", 115 TSRMLS_CC); } zephir_array_fetch_long(&_28, matches, 1, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 118 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_22, "floatval", &_29, 311, _28); zephir_check_call_status(); ZEPHIR_INIT_VAR(_30); zephir_array_fetch(&_31, byteUnits, unit, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 118 TSRMLS_CC); ZEPHIR_SINIT_VAR(_32); ZVAL_LONG(&_32, 2); zephir_pow_function(_30, &_32, _31); ZEPHIR_INIT_VAR(bytes); mul_function(bytes, _22, _30 TSRMLS_CC); zephir_array_fetch_string(&_33, value, SL("size"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 120 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_22, "floatval", &_29, 311, _33); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_34, "floatval", &_29, 311, bytes); zephir_check_call_status(); if (ZEPHIR_GT(_22, _34)) { ZEPHIR_INIT_NVAR(_30); ZVAL_STRING(_30, "messageSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _30); zephir_check_temp_parameter(_30); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":max"), &maxSize, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_30); ZVAL_STRING(_30, "FileSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _30); zephir_check_temp_parameter(_30); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_30); object_init_ex(_30, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_35, "strtr", &_10, 53, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_36); ZVAL_STRING(_36, "FileSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _30, "__construct", &_12, 436, _35, field, _36); zephir_check_temp_parameter(_36); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _30); zephir_check_call_status(); RETURN_MM_BOOL(0); } } ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_9, this_ptr, "issetoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); if (zephir_is_true(_9)) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&types, this_ptr, "getoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); if (Z_TYPE_P(types) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Option 'allowedTypes' must be an array", "phalcon/validation/validator/file.zep", 138); return; } if ((zephir_function_exists_ex(SS("finfo_open") TSRMLS_CC) == SUCCESS)) { ZEPHIR_SINIT_NVAR(_32); ZVAL_LONG(&_32, 16); ZEPHIR_CALL_FUNCTION(&tmp, "finfo_open", NULL, 229, &_32); zephir_check_call_status(); zephir_array_fetch_string(&_28, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 143 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&mime, "finfo_file", NULL, 230, tmp, _28); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(NULL, "finfo_close", NULL, 231, tmp); zephir_check_call_status(); } else { ZEPHIR_OBS_NVAR(mime); zephir_array_fetch_string(&mime, value, SL("type"), PH_NOISY, "phalcon/validation/validator/file.zep", 147 TSRMLS_CC); } if (!(zephir_fast_in_array(mime, types TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "messageType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_11); zephir_fast_join_str(_11, SL(", "), types TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":types"), &_11, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "FileType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_11); object_init_ex(_11, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_22, "strtr", &_10, 53, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_23); ZVAL_STRING(_23, "FileType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _11, "__construct", &_12, 436, _22, field, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _11); zephir_check_call_status(); RETURN_MM_BOOL(0); } } ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_9, this_ptr, "issetoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); _37 = zephir_is_true(_9); if (!(_37)) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_22, this_ptr, "issetoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); _37 = zephir_is_true(_22); } if (_37) { zephir_array_fetch_string(&_28, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 164 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&tmp, "getimagesize", NULL, 249, _28); zephir_check_call_status(); ZEPHIR_OBS_VAR(width); zephir_array_fetch_long(&width, tmp, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 165 TSRMLS_CC); ZEPHIR_OBS_VAR(height); zephir_array_fetch_long(&height, tmp, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 166 TSRMLS_CC); ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_34, this_ptr, "issetoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); if (zephir_is_true(_34)) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_35, this_ptr, "getoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); ZEPHIR_INIT_VAR(minResolution); zephir_fast_explode_str(minResolution, SL("x"), _35, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(minWidth); zephir_array_fetch_long(&minWidth, minResolution, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 170 TSRMLS_CC); ZEPHIR_OBS_VAR(minHeight); zephir_array_fetch_long(&minHeight, minResolution, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 171 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(minWidth); ZVAL_LONG(minWidth, 1); ZEPHIR_INIT_NVAR(minHeight); ZVAL_LONG(minHeight, 1); } _38 = ZEPHIR_LT(width, minWidth); if (!(_38)) { _38 = ZEPHIR_LT(height, minHeight); } if (_38) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "messageMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_35, this_ptr, "getoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); zephir_array_update_string(&replacePairs, SL(":min"), &_35, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "FileMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_11); object_init_ex(_11, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_35, "strtr", &_10, 53, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_23); ZVAL_STRING(_23, "FileMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _11, "__construct", &_12, 436, _35, field, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _11); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_23); ZVAL_STRING(_23, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_35, this_ptr, "issetoption", NULL, 0, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); if (zephir_is_true(_35)) { ZEPHIR_INIT_NVAR(_23); ZVAL_STRING(_23, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_39, this_ptr, "getoption", NULL, 0, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); ZEPHIR_INIT_VAR(maxResolution); zephir_fast_explode_str(maxResolution, SL("x"), _39, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(maxWidth); zephir_array_fetch_long(&maxWidth, maxResolution, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 192 TSRMLS_CC); ZEPHIR_OBS_VAR(maxHeight); zephir_array_fetch_long(&maxHeight, maxResolution, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 193 TSRMLS_CC); _40 = ZEPHIR_GT(width, maxWidth); if (!(_40)) { _40 = ZEPHIR_GT(height, maxHeight); } if (_40) { ZEPHIR_INIT_NVAR(_23); ZVAL_STRING(_23, "messageMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_23); ZVAL_STRING(_23, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_41, this_ptr, "getoption", NULL, 0, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); zephir_array_update_string(&replacePairs, SL(":max"), &_41, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_23); ZVAL_STRING(_23, "FileMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_23); object_init_ex(_23, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_41, "strtr", &_10, 53, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_26); ZVAL_STRING(_26, "FileMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _23, "__construct", &_12, 436, _41, field, _26); zephir_check_temp_parameter(_26); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _23); zephir_check_call_status(); RETURN_MM_BOOL(0); } } } RETURN_MM_BOOL(1); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_File, validate) { zend_bool _4, _5, _6, _8, _9, _18, _19, _21, _29, _30, _65, _72$$29, _81$$36; zephir_fcall_cache_entry *_15 = NULL, *_17 = NULL, *_44 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *_SERVER, *_POST, *_FILES, *value = NULL, *message = NULL, *label = NULL, *replacePairs = NULL, *types = NULL, *byteUnits = NULL, *unit = NULL, *maxSize = NULL, *matches = NULL, *bytes = NULL, *mime = NULL, *tmp = NULL, *width = NULL, *height = NULL, *minResolution = NULL, *maxResolution = NULL, *minWidth = NULL, *maxWidth = NULL, *minHeight = NULL, *maxHeight = NULL, *fieldTypes = NULL, *code = NULL, *minResolutionArray = NULL, *maxResolutionArray = NULL, *_0 = NULL, *_3, *_7, *_10, *_20, *_22, *_23 = NULL, *_36 = NULL, *_55 = NULL, *_64 = NULL, *_66 = NULL, *_1$$3, *_2$$5, *_11$$6 = NULL, *_14$$6 = NULL, *_16$$6, *_12$$7, *_13$$8, *_24$$9 = NULL, *_27$$9 = NULL, *_28$$9, *_25$$10, *_26$$11, *_31$$12 = NULL, *_34$$12 = NULL, *_35$$12, *_32$$13, *_33$$14, *_37$$15 = NULL, *_39$$15, *_40$$15, *_41$$15, *_42$$15, *_43$$15 = NULL, *_45$$15, *_46$$15, _47$$15, *_48$$15, *_49$$15 = NULL, *_38$$16, *_50$$18 = NULL, *_53$$18 = NULL, *_54$$18, *_51$$19, *_52$$20, *_56$$21, _57$$24, *_58$$24, *_59$$26 = NULL, *_62$$26 = NULL, *_63$$26, *_60$$27, *_61$$28, *_67$$29, *_68$$29 = NULL, *_69$$29 = NULL, *_78$$29 = NULL, *_70$$30, *_71$$31, *_73$$33 = NULL, *_76$$33 = NULL, *_77$$33, *_74$$34, *_75$$35, *_79$$36, *_80$$37, *_82$$38 = NULL, *_85$$38 = NULL, *_86$$38, *_83$$39, *_84$$40; ZEPHIR_MM_GROW(); zephir_get_global(&_FILES, SS("_FILES") TSRMLS_CC); zephir_get_global(&_POST, SS("_POST") TSRMLS_CC); zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(label) == IS_ARRAY) { zephir_array_fetch(&_1$$3, label, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 108 TSRMLS_CC); ZEPHIR_CPY_WRT(label, _1$$3); } if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "code", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&code, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(code) == IS_ARRAY) { zephir_array_fetch(&_2$$5, code, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 117 TSRMLS_CC); ZEPHIR_CPY_WRT(code, _2$$5); } zephir_array_fetch_string(&_3, _SERVER, SL("REQUEST_METHOD"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 121 TSRMLS_CC); _4 = ZEPHIR_IS_STRING(_3, "POST"); if (_4) { _4 = ZEPHIR_IS_EMPTY(_POST); } _5 = _4; if (_5) { _5 = ZEPHIR_IS_EMPTY(_FILES); } _6 = _5; if (_6) { zephir_array_fetch_string(&_7, _SERVER, SL("CONTENT_LENGTH"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 121 TSRMLS_CC); _6 = ZEPHIR_GT_LONG(_7, 0); } _8 = _6; if (!(_8)) { _9 = zephir_array_isset_string(value, SS("error")); if (_9) { zephir_array_fetch_string(&_10, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 121 TSRMLS_CC); _9 = ZEPHIR_IS_LONG_IDENTICAL(_10, 1); } _8 = _9; } if (_8) { ZEPHIR_INIT_VAR(_11$$6); ZVAL_STRING(_11$$6, "messageIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _11$$6); zephir_check_temp_parameter(_11$$6); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (Z_TYPE_P(message) == IS_ARRAY) { zephir_array_fetch(&_12$$7, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 127 TSRMLS_CC); ZEPHIR_CPY_WRT(message, _12$$7); } if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_13$$8); ZVAL_STRING(_13$$8, "FileIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _13$$8); zephir_check_temp_parameter(_13$$8); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_11$$6); object_init_ex(_11$$6, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_14$$6, "strtr", &_15, 26, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_16$$6); ZVAL_STRING(_16$$6, "FileIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _11$$6, "__construct", &_17, 466, _14$$6, field, _16$$6, code); zephir_check_temp_parameter(_16$$6); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _11$$6); zephir_check_call_status(); RETURN_MM_BOOL(0); } _18 = !(zephir_array_isset_string(value, SS("error"))); if (!(_18)) { _18 = !(zephir_array_isset_string(value, SS("tmp_name"))); } _19 = _18; if (!(_19)) { zephir_array_fetch_string(&_20, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 138 TSRMLS_CC); _19 = !ZEPHIR_IS_LONG_IDENTICAL(_20, 0); } _21 = _19; if (!(_21)) { zephir_array_fetch_string(&_22, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 138 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_23, "is_uploaded_file", NULL, 246, _22); zephir_check_call_status(); _21 = !zephir_is_true(_23); } if (_21) { ZEPHIR_INIT_VAR(_24$$9); ZVAL_STRING(_24$$9, "messageEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _24$$9); zephir_check_temp_parameter(_24$$9); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (Z_TYPE_P(message) == IS_ARRAY) { zephir_array_fetch(&_25$$10, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 144 TSRMLS_CC); ZEPHIR_CPY_WRT(message, _25$$10); } if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_26$$11); ZVAL_STRING(_26$$11, "FileEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _26$$11); zephir_check_temp_parameter(_26$$11); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_24$$9); object_init_ex(_24$$9, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_27$$9, "strtr", &_15, 26, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_28$$9); ZVAL_STRING(_28$$9, "FileEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _24$$9, "__construct", &_17, 466, _27$$9, field, _28$$9, code); zephir_check_temp_parameter(_28$$9); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _24$$9); zephir_check_call_status(); RETURN_MM_BOOL(0); } _29 = !(zephir_array_isset_string(value, SS("name"))); if (!(_29)) { _29 = !(zephir_array_isset_string(value, SS("type"))); } _30 = _29; if (!(_30)) { _30 = !(zephir_array_isset_string(value, SS("size"))); } if (_30) { ZEPHIR_INIT_VAR(_31$$12); ZVAL_STRING(_31$$12, "messageValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _31$$12); zephir_check_temp_parameter(_31$$12); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (Z_TYPE_P(message) == IS_ARRAY) { zephir_array_fetch(&_32$$13, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 161 TSRMLS_CC); ZEPHIR_CPY_WRT(message, _32$$13); } if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_33$$14); ZVAL_STRING(_33$$14, "FileValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _33$$14); zephir_check_temp_parameter(_33$$14); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_31$$12); object_init_ex(_31$$12, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_34$$12, "strtr", &_15, 26, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_35$$12); ZVAL_STRING(_35$$12, "FileValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _31$$12, "__construct", &_17, 466, _34$$12, field, _35$$12, code); zephir_check_temp_parameter(_35$$12); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _31$$12); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "maxSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_36, this_ptr, "hasoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (zephir_is_true(_36)) { ZEPHIR_INIT_VAR(byteUnits); zephir_create_array(byteUnits, 9, 0 TSRMLS_CC); add_assoc_long_ex(byteUnits, SS("B"), 0); add_assoc_long_ex(byteUnits, SS("K"), 10); add_assoc_long_ex(byteUnits, SS("M"), 20); add_assoc_long_ex(byteUnits, SS("G"), 30); add_assoc_long_ex(byteUnits, SS("T"), 40); add_assoc_long_ex(byteUnits, SS("KB"), 10); add_assoc_long_ex(byteUnits, SS("MB"), 20); add_assoc_long_ex(byteUnits, SS("GB"), 30); add_assoc_long_ex(byteUnits, SS("TB"), 40); ZEPHIR_INIT_VAR(_37$$15); ZVAL_STRING(_37$$15, "maxSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&maxSize, this_ptr, "getoption", NULL, 0, _37$$15); zephir_check_temp_parameter(_37$$15); zephir_check_call_status(); ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); ZEPHIR_INIT_VAR(unit); ZVAL_STRING(unit, "B", 1); if (Z_TYPE_P(maxSize) == IS_ARRAY) { zephir_array_fetch(&_38$$16, maxSize, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 180 TSRMLS_CC); ZEPHIR_CPY_WRT(maxSize, _38$$16); } ZEPHIR_INIT_NVAR(_37$$15); ZEPHIR_INIT_VAR(_39$$15); ZEPHIR_INIT_VAR(_40$$15); zephir_array_keys(_40$$15, byteUnits TSRMLS_CC); zephir_fast_join_str(_39$$15, SL("|"), _40$$15 TSRMLS_CC); ZEPHIR_INIT_VAR(_41$$15); ZEPHIR_CONCAT_SVS(_41$$15, "/^([0-9]+(?:\\.[0-9]+)?)(", _39$$15, ")?$/Di"); zephir_preg_match(_37$$15, _41$$15, maxSize, matches, 0, 0 , 0 TSRMLS_CC); if (zephir_array_isset_long(matches, 2)) { ZEPHIR_OBS_NVAR(unit); zephir_array_fetch_long(&unit, matches, 2, PH_NOISY, "phalcon/validation/validator/file.zep", 186 TSRMLS_CC); } zephir_array_fetch_long(&_42$$15, matches, 1, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 189 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_43$$15, "floatval", &_44, 322, _42$$15); zephir_check_call_status(); ZEPHIR_INIT_VAR(_45$$15); zephir_array_fetch(&_46$$15, byteUnits, unit, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 189 TSRMLS_CC); ZEPHIR_SINIT_VAR(_47$$15); ZVAL_LONG(&_47$$15, 2); zephir_pow_function(_45$$15, &_47$$15, _46$$15); ZEPHIR_INIT_VAR(bytes); mul_function(bytes, _43$$15, _45$$15 TSRMLS_CC); zephir_array_fetch_string(&_48$$15, value, SL("size"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 191 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_43$$15, "floatval", &_44, 322, _48$$15); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_49$$15, "floatval", &_44, 322, bytes); zephir_check_call_status(); if (ZEPHIR_GT(_43$$15, _49$$15)) { ZEPHIR_INIT_VAR(_50$$18); ZVAL_STRING(_50$$18, "messageSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _50$$18); zephir_check_temp_parameter(_50$$18); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":max"), &maxSize, PH_COPY | PH_SEPARATE); if (Z_TYPE_P(message) == IS_ARRAY) { zephir_array_fetch(&_51$$19, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 196 TSRMLS_CC); ZEPHIR_CPY_WRT(message, _51$$19); } if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_52$$20); ZVAL_STRING(_52$$20, "FileSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _52$$20); zephir_check_temp_parameter(_52$$20); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_50$$18); object_init_ex(_50$$18, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_53$$18, "strtr", &_15, 26, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_54$$18); ZVAL_STRING(_54$$18, "FileSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _50$$18, "__construct", &_17, 466, _53$$18, field, _54$$18, code); zephir_check_temp_parameter(_54$$18); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _50$$18); zephir_check_call_status(); RETURN_MM_BOOL(0); } } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_55, this_ptr, "hasoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (zephir_is_true(_55)) { ZEPHIR_INIT_VAR(_56$$21); ZVAL_STRING(_56$$21, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&types, this_ptr, "getoption", NULL, 0, _56$$21); zephir_check_temp_parameter(_56$$21); zephir_check_call_status(); ZEPHIR_OBS_VAR(fieldTypes); if (zephir_array_isset_fetch(&fieldTypes, types, field, 0 TSRMLS_CC)) { ZEPHIR_CPY_WRT(types, fieldTypes); } if (Z_TYPE_P(types) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Option 'allowedTypes' must be an array", "phalcon/validation/validator/file.zep", 217); return; } if ((zephir_function_exists_ex(SS("finfo_open") TSRMLS_CC) == SUCCESS)) { ZEPHIR_SINIT_VAR(_57$$24); ZVAL_LONG(&_57$$24, 16); ZEPHIR_CALL_FUNCTION(&tmp, "finfo_open", NULL, 243, &_57$$24); zephir_check_call_status(); zephir_array_fetch_string(&_58$$24, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 222 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&mime, "finfo_file", NULL, 244, tmp, _58$$24); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(NULL, "finfo_close", NULL, 245, tmp); zephir_check_call_status(); } else { ZEPHIR_OBS_NVAR(mime); zephir_array_fetch_string(&mime, value, SL("type"), PH_NOISY, "phalcon/validation/validator/file.zep", 226 TSRMLS_CC); } if (!(zephir_fast_in_array(mime, types TSRMLS_CC))) { ZEPHIR_INIT_VAR(_59$$26); ZVAL_STRING(_59$$26, "messageType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _59$$26); zephir_check_temp_parameter(_59$$26); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_59$$26); zephir_fast_join_str(_59$$26, SL(", "), types TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":types"), &_59$$26, PH_COPY | PH_SEPARATE); if (Z_TYPE_P(message) == IS_ARRAY) { zephir_array_fetch(&_60$$27, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 234 TSRMLS_CC); ZEPHIR_CPY_WRT(message, _60$$27); } if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_61$$28); ZVAL_STRING(_61$$28, "FileType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _61$$28); zephir_check_temp_parameter(_61$$28); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_59$$26); object_init_ex(_59$$26, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_62$$26, "strtr", &_15, 26, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_63$$26); ZVAL_STRING(_63$$26, "FileType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _59$$26, "__construct", &_17, 466, _62$$26, field, _63$$26, code); zephir_check_temp_parameter(_63$$26); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _59$$26); zephir_check_call_status(); RETURN_MM_BOOL(0); } } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_64, this_ptr, "hasoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _65 = zephir_is_true(_64); if (!(_65)) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_66, this_ptr, "hasoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _65 = zephir_is_true(_66); } if (_65) { zephir_array_fetch_string(&_67$$29, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 247 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&tmp, "getimagesize", NULL, 254, _67$$29); zephir_check_call_status(); ZEPHIR_OBS_VAR(width); zephir_array_fetch_long(&width, tmp, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 248 TSRMLS_CC); ZEPHIR_OBS_VAR(height); zephir_array_fetch_long(&height, tmp, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 249 TSRMLS_CC); ZEPHIR_INIT_VAR(_69$$29); ZVAL_STRING(_69$$29, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_68$$29, this_ptr, "hasoption", NULL, 0, _69$$29); zephir_check_temp_parameter(_69$$29); zephir_check_call_status(); if (zephir_is_true(_68$$29)) { ZEPHIR_INIT_VAR(_70$$30); ZVAL_STRING(_70$$30, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&minResolution, this_ptr, "getoption", NULL, 0, _70$$30); zephir_check_temp_parameter(_70$$30); zephir_check_call_status(); if (Z_TYPE_P(minResolution) == IS_ARRAY) { zephir_array_fetch(&_71$$31, minResolution, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 254 TSRMLS_CC); ZEPHIR_CPY_WRT(minResolution, _71$$31); } ZEPHIR_INIT_VAR(minResolutionArray); zephir_fast_explode_str(minResolutionArray, SL("x"), minResolution, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(minWidth); zephir_array_fetch_long(&minWidth, minResolutionArray, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 257 TSRMLS_CC); ZEPHIR_OBS_VAR(minHeight); zephir_array_fetch_long(&minHeight, minResolutionArray, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 258 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(minWidth); ZVAL_LONG(minWidth, 1); ZEPHIR_INIT_NVAR(minHeight); ZVAL_LONG(minHeight, 1); } _72$$29 = ZEPHIR_LT(width, minWidth); if (!(_72$$29)) { _72$$29 = ZEPHIR_LT(height, minHeight); } if (_72$$29) { ZEPHIR_INIT_VAR(_73$$33); ZVAL_STRING(_73$$33, "messageMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _73$$33); zephir_check_temp_parameter(_73$$33); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":min"), &minResolution, PH_COPY | PH_SEPARATE); if (Z_TYPE_P(message) == IS_ARRAY) { zephir_array_fetch(&_74$$34, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 269 TSRMLS_CC); ZEPHIR_CPY_WRT(message, _74$$34); } if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_75$$35); ZVAL_STRING(_75$$35, "FileMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _75$$35); zephir_check_temp_parameter(_75$$35); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_73$$33); object_init_ex(_73$$33, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_76$$33, "strtr", &_15, 26, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_77$$33); ZVAL_STRING(_77$$33, "FileMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _73$$33, "__construct", &_17, 466, _76$$33, field, _77$$33, code); zephir_check_temp_parameter(_77$$33); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _73$$33); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_69$$29); ZVAL_STRING(_69$$29, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_78$$29, this_ptr, "hasoption", NULL, 0, _69$$29); zephir_check_temp_parameter(_69$$29); zephir_check_call_status(); if (zephir_is_true(_78$$29)) { ZEPHIR_INIT_VAR(_79$$36); ZVAL_STRING(_79$$36, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&maxResolution, this_ptr, "getoption", NULL, 0, _79$$36); zephir_check_temp_parameter(_79$$36); zephir_check_call_status(); if (Z_TYPE_P(maxResolution) == IS_ARRAY) { zephir_array_fetch(&_80$$37, maxResolution, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 284 TSRMLS_CC); ZEPHIR_CPY_WRT(maxResolution, _80$$37); } ZEPHIR_INIT_VAR(maxResolutionArray); zephir_fast_explode_str(maxResolutionArray, SL("x"), maxResolution, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(maxWidth); zephir_array_fetch_long(&maxWidth, maxResolutionArray, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 287 TSRMLS_CC); ZEPHIR_OBS_VAR(maxHeight); zephir_array_fetch_long(&maxHeight, maxResolutionArray, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 288 TSRMLS_CC); _81$$36 = ZEPHIR_GT(width, maxWidth); if (!(_81$$36)) { _81$$36 = ZEPHIR_GT(height, maxHeight); } if (_81$$36) { ZEPHIR_INIT_VAR(_82$$38); ZVAL_STRING(_82$$38, "messageMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _82$$38); zephir_check_temp_parameter(_82$$38); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":max"), &maxResolution, PH_COPY | PH_SEPARATE); if (Z_TYPE_P(message) == IS_ARRAY) { zephir_array_fetch(&_83$$39, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 295 TSRMLS_CC); ZEPHIR_CPY_WRT(message, _83$$39); } if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_84$$40); ZVAL_STRING(_84$$40, "FileMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _84$$40); zephir_check_temp_parameter(_84$$40); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_82$$38); object_init_ex(_82$$38, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_85$$38, "strtr", &_15, 26, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_86$$38); ZVAL_STRING(_86$$38, "FileMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _82$$38, "__construct", &_17, 466, _85$$38, field, _86$$38, code); zephir_check_temp_parameter(_86$$38); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _82$$38); zephir_check_call_status(); RETURN_MM_BOOL(0); } } } RETURN_MM_BOOL(1); }
/** * Reconfigure the route adding a new pattern and a set of paths * * @param string pattern * @param array paths */ PHP_METHOD(Test_Router_Route, reConfigure) { int ZEPHIR_LAST_CALL_STATUS, _0$$5; zval *pattern, pattern_sub, *paths = NULL, paths_sub, __$null, moduleName, controllerName, actionName, parts, routePaths, realClassName, namespaceName, pcrePattern, compiledPattern, extracted, _1$$10, _2$$19, _3$$19; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&pattern_sub); ZVAL_UNDEF(&paths_sub); ZVAL_NULL(&__$null); ZVAL_UNDEF(&moduleName); ZVAL_UNDEF(&controllerName); ZVAL_UNDEF(&actionName); ZVAL_UNDEF(&parts); ZVAL_UNDEF(&routePaths); ZVAL_UNDEF(&realClassName); ZVAL_UNDEF(&namespaceName); ZVAL_UNDEF(&pcrePattern); ZVAL_UNDEF(&compiledPattern); ZVAL_UNDEF(&extracted); ZVAL_UNDEF(&_1$$10); ZVAL_UNDEF(&_2$$19); ZVAL_UNDEF(&_3$$19); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &pattern, &paths); if (!paths) { paths = &paths_sub; paths = &__$null; } if (Z_TYPE_P(pattern) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "The pattern must be string", "test/router/route.zep", 270); return; } if (Z_TYPE_P(paths) != IS_NULL) { if (Z_TYPE_P(paths) == IS_STRING) { ZEPHIR_INIT_VAR(&moduleName); ZVAL_NULL(&moduleName); ZEPHIR_INIT_VAR(&controllerName); ZVAL_NULL(&controllerName); ZEPHIR_INIT_VAR(&actionName); ZVAL_NULL(&actionName); ZEPHIR_INIT_VAR(&parts); zephir_fast_explode_str(&parts, SL("::"), paths, LONG_MAX TSRMLS_CC); do { _0$$5 = zephir_fast_count_int(&parts TSRMLS_CC); if (_0$$5 == 3) { ZEPHIR_OBS_NVAR(&moduleName); zephir_array_fetch_long(&moduleName, &parts, 0, PH_NOISY, "test/router/route.zep", 286 TSRMLS_CC); ZEPHIR_OBS_NVAR(&controllerName); zephir_array_fetch_long(&controllerName, &parts, 1, PH_NOISY, "test/router/route.zep", 287 TSRMLS_CC); ZEPHIR_OBS_NVAR(&actionName); zephir_array_fetch_long(&actionName, &parts, 2, PH_NOISY, "test/router/route.zep", 288 TSRMLS_CC); break; } if (_0$$5 == 2) { ZEPHIR_OBS_NVAR(&controllerName); zephir_array_fetch_long(&controllerName, &parts, 0, PH_NOISY, "test/router/route.zep", 291 TSRMLS_CC); ZEPHIR_OBS_NVAR(&actionName); zephir_array_fetch_long(&actionName, &parts, 1, PH_NOISY, "test/router/route.zep", 292 TSRMLS_CC); break; } if (_0$$5 == 1) { ZEPHIR_OBS_NVAR(&controllerName); zephir_array_fetch_long(&controllerName, &parts, 0, PH_NOISY, "test/router/route.zep", 295 TSRMLS_CC); break; } } while(0); ZEPHIR_INIT_VAR(&routePaths); array_init(&routePaths); if (Z_TYPE_P(&moduleName) != IS_NULL) { zephir_array_update_string(&routePaths, SL("module"), &moduleName, PH_COPY | PH_SEPARATE); } if (Z_TYPE_P(&controllerName) != IS_NULL) { if (zephir_memnstr_str(&controllerName, SL("\\"), "test/router/route.zep", 310)) { ZEPHIR_INIT_VAR(&realClassName); zephir_get_class_ns(&realClassName, &controllerName, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(&namespaceName); zephir_get_ns_class(&namespaceName, &controllerName, 0 TSRMLS_CC); if (zephir_is_true(&namespaceName)) { zephir_array_update_string(&routePaths, SL("namespace"), &namespaceName, PH_COPY | PH_SEPARATE); } } else { ZEPHIR_CPY_WRT(&realClassName, &controllerName); } ZEPHIR_INIT_VAR(&_1$$10); zephir_uncamelize(&_1$$10, &realClassName); zephir_array_update_string(&routePaths, SL("controller"), &_1$$10, PH_COPY | PH_SEPARATE); } if (Z_TYPE_P(&actionName) != IS_NULL) { zephir_array_update_string(&routePaths, SL("action"), &actionName, PH_COPY | PH_SEPARATE); } } else { ZEPHIR_CPY_WRT(&routePaths, paths); } } else { ZEPHIR_INIT_NVAR(&routePaths); array_init(&routePaths); } if (Z_TYPE_P(&routePaths) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "The route contains invalid paths", "test/router/route.zep", 342); return; } if (!(zephir_start_with_str(pattern, SL("#")))) { if (zephir_memnstr_str(pattern, SL("{"), "test/router/route.zep", 348)) { ZEPHIR_CALL_METHOD(&extracted, this_ptr, "extractnamedparams", NULL, 0, pattern); zephir_check_call_status(); ZEPHIR_OBS_VAR(&pcrePattern); zephir_array_fetch_long(&pcrePattern, &extracted, 0, PH_NOISY, "test/router/route.zep", 351 TSRMLS_CC); ZEPHIR_INIT_VAR(&_2$$19); zephir_array_fetch_long(&_3$$19, &extracted, 1, PH_NOISY | PH_READONLY, "test/router/route.zep", 352 TSRMLS_CC); zephir_fast_array_merge(&_2$$19, &routePaths, &_3$$19 TSRMLS_CC); ZEPHIR_CPY_WRT(&routePaths, &_2$$19); } else { ZEPHIR_CPY_WRT(&pcrePattern, pattern); } ZEPHIR_CALL_METHOD(&compiledPattern, this_ptr, "compilepattern", NULL, 0, &pcrePattern); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(&compiledPattern, pattern); } zephir_update_property_zval(this_ptr, SL("_pattern"), pattern); zephir_update_property_zval(this_ptr, SL("_compiledPattern"), &compiledPattern); zephir_update_property_zval(this_ptr, SL("_paths"), &routePaths); ZEPHIR_MM_RESTORE(); }
/** * Handles routing information received from the rewrite engine * *<code> * //Read the info from the rewrite engine * $router->handle(); * * //Manually passing an URL * $router->handle('/posts/edit/1'); *</code> * * @param string uri */ PHP_METHOD(Test_Router, handle) { zephir_nts_static zephir_fcall_cache_entry *_12 = NULL; HashTable *_2, *_9; HashPosition _1, _8; int ZEPHIR_LAST_CALL_STATUS; zval *uri = NULL, *realUri = NULL, *request = NULL, *currentHostName = NULL, *routeFound = NULL, *parts = NULL, *params, *matches, *notFoundPaths, *vnamespace, *module, *controller, *action, *paramsStr, *strParams = NULL, *paramsMerge = NULL, *route = NULL, *methods = NULL, *dependencyInjector = NULL, *hostname = NULL, *regexHostName = NULL, *matched = NULL, *pattern = NULL, *handledUri = NULL, *beforeMatch = NULL, *paths = NULL, *converters = NULL, *part = NULL, *position = NULL, *matchPosition = NULL, *_0, **_3, *_4, *_5 = NULL, *_6 = NULL, *_7 = NULL, **_10, _11, *_13, *_14, *_15, *_16; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &uri); if (!uri) { uri = ZEPHIR_GLOBAL(global_null); } if (!(zephir_is_true(uri))) { ZEPHIR_CALL_METHOD(&realUri, this_ptr, "getrewriteuri", NULL); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(realUri, uri); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_removeExtraSlashes"), PH_NOISY_CC); if (zephir_is_true(_0)) { ZEPHIR_CALL_METHOD(&handledUri, this_ptr, "doremoveextraslashes", NULL, realUri); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(handledUri, realUri); } ZEPHIR_INIT_VAR(request); ZVAL_NULL(request); ZEPHIR_INIT_VAR(currentHostName); ZVAL_NULL(currentHostName); ZEPHIR_INIT_VAR(routeFound); ZVAL_BOOL(routeFound, 0); ZEPHIR_INIT_VAR(parts); array_init(parts); ZEPHIR_INIT_VAR(params); array_init(params); ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); zephir_update_property_this(this_ptr, SL("_wasMatched"), (0) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_matchedRoute"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_routes"), PH_NOISY_CC); zephir_is_iterable(_0, &_2, &_1, 0, 1); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_backwards_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(route, _3); ZEPHIR_CALL_METHOD(&methods, route, "gethttpmethods", NULL); zephir_check_call_status(); if (Z_TYPE_P(methods) != IS_NULL) { if (Z_TYPE_P(request) == IS_NULL) { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _4); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_STR(test_router_exception_ce, "A dependency injection container is required to access the 'request' service"); return; } ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "request", 0); ZEPHIR_CALL_METHOD(&request, dependencyInjector, "getshared", NULL, _5); zephir_check_temp_parameter(_5); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&_6, request, "ismethod", NULL, methods); zephir_check_call_status(); if (ZEPHIR_IS_FALSE(_6)) { continue; } } ZEPHIR_CALL_METHOD(&hostname, route, "gethostname", NULL); zephir_check_call_status(); if (Z_TYPE_P(hostname) != IS_NULL) { if (Z_TYPE_P(request) == IS_NULL) { ZEPHIR_OBS_NVAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_STR(test_router_exception_ce, "A dependency injection container is required to access the 'request' service"); return; } ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "request", 0); ZEPHIR_CALL_METHOD(&request, dependencyInjector, "getshared", NULL, _5); zephir_check_temp_parameter(_5); zephir_check_call_status(); } if (Z_TYPE_P(currentHostName) != IS_OBJECT) { ZEPHIR_CALL_METHOD(¤tHostName, request, "gethttphost", NULL); zephir_check_call_status(); } if (Z_TYPE_P(currentHostName) != IS_NULL) { continue; } ZEPHIR_INIT_NVAR(matched); if (zephir_memnstr_str(hostname, SL("("), "test/router.zep", 381)) { if (zephir_memnstr_str(hostname, SL("#"), "test/router.zep", 382)) { ZEPHIR_INIT_NVAR(regexHostName); ZEPHIR_CONCAT_SVS(regexHostName, "#^", hostname, "$#"); } else { ZEPHIR_CPY_WRT(regexHostName, hostname); } ZEPHIR_INIT_NVAR(_7); zephir_preg_match(matched, &(matched), regexHostName, currentHostName, _7, 0, 0 , 0 TSRMLS_CC); } else { ZVAL_BOOL(matched, ZEPHIR_IS_EQUAL(currentHostName, hostname)); } if (!(zephir_is_true(matched))) { continue; } } ZEPHIR_CALL_METHOD(&pattern, route, "getcompiledpattern", NULL); zephir_check_call_status(); ZEPHIR_INIT_NVAR(routeFound); if (zephir_memnstr_str(pattern, SL("^"), "test/router.zep", 400)) { zephir_preg_match(routeFound, &(routeFound), pattern, handledUri, matches, 0, 0 , 0 TSRMLS_CC); } else { ZVAL_BOOL(routeFound, ZEPHIR_IS_EQUAL(pattern, handledUri)); } if (zephir_is_true(routeFound)) { ZEPHIR_CALL_METHOD(&beforeMatch, route, "getbeforematch", NULL); zephir_check_call_status(); if (Z_TYPE_P(beforeMatch) != IS_NULL) { if (zephir_is_callable(beforeMatch TSRMLS_CC)) { ZEPHIR_THROW_EXCEPTION_STR(test_router_exception_ce, "Before-Match callback is not callable in matched route"); return; } } } if (zephir_is_true(routeFound)) { ZEPHIR_CALL_METHOD(&paths, route, "getpaths", NULL); zephir_check_call_status(); ZEPHIR_CPY_WRT(parts, paths); if (Z_TYPE_P(matches) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&converters, route, "getconverters", NULL); zephir_check_call_status(); zephir_is_iterable(paths, &_9, &_8, 0, 0); for ( ; zephir_hash_get_current_data_ex(_9, (void**) &_10, &_8) == SUCCESS ; zephir_hash_move_forward_ex(_9, &_8) ) { ZEPHIR_GET_HMKEY(part, _9, _8); ZEPHIR_GET_HVALUE(position, _10); ZEPHIR_OBS_NVAR(matchPosition); if (zephir_array_isset_fetch(&matchPosition, matches, position, 0 TSRMLS_CC)) { if (Z_TYPE_P(converters) == IS_ARRAY) { if (zephir_array_isset(converters, part)) { continue; } } zephir_array_update_zval(&parts, part, &matchPosition, PH_COPY | PH_SEPARATE); } else { if (Z_TYPE_P(converters) == IS_ARRAY) { if (zephir_array_isset(converters, part)) { } } } } zephir_update_property_this(this_ptr, SL("_matches"), matches TSRMLS_CC); } zephir_update_property_this(this_ptr, SL("_matchedRoute"), route TSRMLS_CC); break; } } if (zephir_is_true(routeFound)) { zephir_update_property_this(this_ptr, SL("_wasMatched"), (1) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_wasMatched"), (0) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } if (!(zephir_is_true(routeFound))) { ZEPHIR_OBS_VAR(notFoundPaths); zephir_read_property_this(¬FoundPaths, this_ptr, SL("_notFoundPaths"), PH_NOISY_CC); if (Z_TYPE_P(notFoundPaths) != IS_NULL) { ZEPHIR_CPY_WRT(parts, notFoundPaths); ZEPHIR_INIT_BNVAR(routeFound); ZVAL_BOOL(routeFound, 1); } } if (zephir_is_true(routeFound)) { ZEPHIR_OBS_VAR(vnamespace); if (zephir_array_isset_string_fetch(&vnamespace, parts, SS("namespace"), 0 TSRMLS_CC)) { if (!(zephir_is_numeric(vnamespace))) { zephir_update_property_this(this_ptr, SL("_namespace"), vnamespace TSRMLS_CC); } zephir_array_unset_string(&parts, SS("namespace"), PH_SEPARATE); } else { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultNamespace"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_namespace"), _4 TSRMLS_CC); } ZEPHIR_OBS_VAR(module); if (zephir_array_isset_string_fetch(&module, parts, SS("module"), 0 TSRMLS_CC)) { if (!(zephir_is_numeric(module))) { zephir_update_property_this(this_ptr, SL("_module"), module TSRMLS_CC); } zephir_array_unset_string(&parts, SS("module"), PH_SEPARATE); } else { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultModule"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_module"), _4 TSRMLS_CC); } ZEPHIR_OBS_VAR(controller); if (zephir_array_isset_string_fetch(&controller, parts, SS("controller"), 0 TSRMLS_CC)) { if (!(zephir_is_numeric(controller))) { zephir_update_property_this(this_ptr, SL("_controller"), controller TSRMLS_CC); } zephir_array_unset_string(&parts, SS("controller"), PH_SEPARATE); } else { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultController"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_controller"), _4 TSRMLS_CC); } ZEPHIR_OBS_VAR(action); if (zephir_array_isset_string_fetch(&action, parts, SS("action"), 0 TSRMLS_CC)) { if (!(zephir_is_numeric(action))) { zephir_update_property_this(this_ptr, SL("_action"), action TSRMLS_CC); } zephir_array_unset_string(&parts, SS("action"), PH_SEPARATE); } else { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultAction"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_action"), _4 TSRMLS_CC); } ZEPHIR_OBS_VAR(paramsStr); if (zephir_array_isset_string_fetch(¶msStr, parts, SS("params"), 0 TSRMLS_CC)) { ZEPHIR_SINIT_VAR(_11); ZVAL_LONG(&_11, 1); ZEPHIR_CALL_FUNCTION(&strParams, "substr", &_12, paramsStr, &_11); zephir_check_call_status(); if (zephir_is_true(strParams)) { ZEPHIR_INIT_BNVAR(params); zephir_fast_explode_str(params, SL("/"), strParams, LONG_MAX TSRMLS_CC); } zephir_array_unset_string(&parts, SS("params"), PH_SEPARATE); } if (zephir_fast_count_int(params TSRMLS_CC)) { ZEPHIR_INIT_VAR(paramsMerge); zephir_fast_array_merge(paramsMerge, &(params), &(parts) TSRMLS_CC); } else { ZEPHIR_CPY_WRT(paramsMerge, parts); } zephir_update_property_this(this_ptr, SL("_params"), paramsMerge TSRMLS_CC); } else { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultNamespace"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_namespace"), _4 TSRMLS_CC); _13 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultModule"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_module"), _13 TSRMLS_CC); _14 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultController"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_controller"), _14 TSRMLS_CC); _15 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultAction"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_action"), _15 TSRMLS_CC); _16 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultParams"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_params"), _16 TSRMLS_CC); } ZEPHIR_MM_RESTORE(); }
/** * Reconfigure the route adding a new pattern and a set of paths * * @param string pattern * @param array paths */ PHP_METHOD(Test_Router_Route, reConfigure) { int _0, ZEPHIR_LAST_CALL_STATUS; zval *pattern, *paths = NULL, *moduleName = NULL, *controllerName = NULL, *actionName = NULL, *parts, *routePaths = NULL, *realClassName = NULL, *namespaceName, *pcrePattern = NULL, *compiledPattern = NULL, *extracted = NULL, *_1 = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &pattern, &paths); if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(pattern) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "The pattern must be string", "test/router/route.zep", 270); return; } if (Z_TYPE_P(paths) != IS_NULL) { if (Z_TYPE_P(paths) == IS_STRING) { ZEPHIR_INIT_VAR(moduleName); ZVAL_NULL(moduleName); ZEPHIR_INIT_VAR(controllerName); ZVAL_NULL(controllerName); ZEPHIR_INIT_VAR(actionName); ZVAL_NULL(actionName); ZEPHIR_INIT_VAR(parts); zephir_fast_explode_str(parts, SL("::"), paths, LONG_MAX TSRMLS_CC); do { _0 = zephir_fast_count_int(parts TSRMLS_CC); if (_0 == 3) { ZEPHIR_OBS_NVAR(moduleName); zephir_array_fetch_long(&moduleName, parts, 0, PH_NOISY, "test/router/route.zep", 286 TSRMLS_CC); ZEPHIR_OBS_NVAR(controllerName); zephir_array_fetch_long(&controllerName, parts, 1, PH_NOISY, "test/router/route.zep", 287 TSRMLS_CC); ZEPHIR_OBS_NVAR(actionName); zephir_array_fetch_long(&actionName, parts, 2, PH_NOISY, "test/router/route.zep", 288 TSRMLS_CC); break; } if (_0 == 2) { ZEPHIR_OBS_NVAR(controllerName); zephir_array_fetch_long(&controllerName, parts, 0, PH_NOISY, "test/router/route.zep", 291 TSRMLS_CC); ZEPHIR_OBS_NVAR(actionName); zephir_array_fetch_long(&actionName, parts, 1, PH_NOISY, "test/router/route.zep", 292 TSRMLS_CC); break; } if (_0 == 1) { ZEPHIR_OBS_NVAR(controllerName); zephir_array_fetch_long(&controllerName, parts, 0, PH_NOISY, "test/router/route.zep", 295 TSRMLS_CC); break; } } while(0); ZEPHIR_INIT_VAR(routePaths); array_init(routePaths); if (Z_TYPE_P(moduleName) != IS_NULL) { zephir_array_update_string(&routePaths, SL("module"), &moduleName, PH_COPY | PH_SEPARATE); } if (Z_TYPE_P(controllerName) != IS_NULL) { if (zephir_memnstr_str(controllerName, SL("\\"), "test/router/route.zep", 310)) { ZEPHIR_INIT_VAR(realClassName); zephir_get_class_ns(realClassName, controllerName, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(namespaceName); zephir_get_ns_class(namespaceName, controllerName, 0 TSRMLS_CC); if (zephir_is_true(namespaceName)) { zephir_array_update_string(&routePaths, SL("namespace"), &namespaceName, PH_COPY | PH_SEPARATE); } } else { ZEPHIR_CPY_WRT(realClassName, controllerName); } ZEPHIR_INIT_VAR(_1); zephir_uncamelize(_1, realClassName); zephir_array_update_string(&routePaths, SL("controller"), &_1, PH_COPY | PH_SEPARATE); } if (Z_TYPE_P(actionName) != IS_NULL) { zephir_array_update_string(&routePaths, SL("action"), &actionName, PH_COPY | PH_SEPARATE); } } else { ZEPHIR_CPY_WRT(routePaths, paths); } } else { ZEPHIR_INIT_NVAR(routePaths); array_init(routePaths); } if (Z_TYPE_P(routePaths) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "The route contains invalid paths", "test/router/route.zep", 342); return; } if (!(zephir_start_with_str(pattern, SL("#")))) { if (zephir_memnstr_str(pattern, SL("{"), "test/router/route.zep", 348)) { ZEPHIR_CALL_METHOD(&extracted, this_ptr, "extractnamedparams", NULL, pattern); zephir_check_call_status(); ZEPHIR_OBS_VAR(pcrePattern); zephir_array_fetch_long(&pcrePattern, extracted, 0, PH_NOISY, "test/router/route.zep", 351 TSRMLS_CC); ZEPHIR_INIT_NVAR(_1); zephir_array_fetch_long(&_2, extracted, 1, PH_NOISY | PH_READONLY, "test/router/route.zep", 352 TSRMLS_CC); zephir_fast_array_merge(_1, &(routePaths), &(_2) TSRMLS_CC); ZEPHIR_CPY_WRT(routePaths, _1); } else { ZEPHIR_CPY_WRT(pcrePattern, pattern); } ZEPHIR_CALL_METHOD(&compiledPattern, this_ptr, "compilepattern", NULL, pcrePattern); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(compiledPattern, pattern); } zephir_update_property_this(this_ptr, SL("_pattern"), pattern TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_compiledPattern"), compiledPattern TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_paths"), routePaths TSRMLS_CC); ZEPHIR_MM_RESTORE(); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_File, validate) { zend_bool _1, _2, _3, _5, _6, _13, _14, _16, _22, _23, _53, _60$$16, _67$$21; zephir_fcall_cache_entry *_11 = NULL, *_12 = NULL, *_36 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *_SERVER, *_POST, *_FILES, *value = NULL, *message = NULL, *label = NULL, *replacePairs = NULL, *types = NULL, *byteUnits = NULL, *unit = NULL, *maxSize = NULL, *matches = NULL, *bytes = NULL, *mime = NULL, *tmp = NULL, *width = NULL, *height = NULL, *minResolution = NULL, *maxResolution = NULL, *minWidth = NULL, *maxWidth = NULL, *minHeight = NULL, *maxHeight = NULL, *fieldTypes = NULL, *code = NULL, *minResolutionArray = NULL, *maxResolutionArray = NULL, *_0, *_4, *_7, *_15, *_17, *_18 = NULL, *_27 = NULL, *_28 = NULL, *_45 = NULL, *_52 = NULL, *_54 = NULL, *_8$$3 = NULL, *_9$$3 = NULL, *_10$$3 = NULL, *_19$$4 = NULL, *_20$$4 = NULL, *_21$$4 = NULL, *_24$$5 = NULL, *_25$$5 = NULL, *_26$$5 = NULL, *_29$$6 = NULL, *_31$$6, *_32$$6, *_33$$6, *_34$$6, *_35$$6 = NULL, *_37$$6, *_38$$6, _39$$6, *_40$$6, *_41$$6 = NULL, *_30$$7, *_42$$9 = NULL, *_43$$9 = NULL, *_44$$9 = NULL, *_46$$10, _47$$13, *_48$$13, *_49$$15 = NULL, *_50$$15 = NULL, *_51$$15 = NULL, *_55$$16, *_56$$16 = NULL, *_57$$16 = NULL, *_64$$16 = NULL, *_58$$17, *_59$$18, *_61$$20 = NULL, *_62$$20 = NULL, *_63$$20 = NULL, *_65$$21, *_66$$22, *_68$$23 = NULL, *_69$$23 = NULL, *_70$$23 = NULL; ZEPHIR_MM_GROW(); zephir_get_global(&_FILES, SS("_FILES") TSRMLS_CC); zephir_get_global(&_POST, SS("_POST") TSRMLS_CC); zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (UNEXPECTED(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (EXPECTED(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&label, this_ptr, "preparelabel", NULL, 0, validation, field); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&code, this_ptr, "preparecode", NULL, 0, field); zephir_check_call_status(); zephir_array_fetch_string(&_0, _SERVER, SL("REQUEST_METHOD"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 109 TSRMLS_CC); _1 = ZEPHIR_IS_STRING(_0, "POST"); if (_1) { _1 = ZEPHIR_IS_EMPTY(_POST); } _2 = _1; if (_2) { _2 = ZEPHIR_IS_EMPTY(_FILES); } _3 = _2; if (_3) { zephir_array_fetch_string(&_4, _SERVER, SL("CONTENT_LENGTH"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 109 TSRMLS_CC); _3 = ZEPHIR_GT_LONG(_4, 0); } _5 = _3; if (!(_5)) { _6 = zephir_array_isset_string(value, SS("error")); if (_6) { zephir_array_fetch_string(&_7, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 109 TSRMLS_CC); _6 = ZEPHIR_IS_LONG_IDENTICAL(_7, 1); } _5 = _6; } if (_5) { ZEPHIR_INIT_VAR(_8$$3); ZVAL_STRING(_8$$3, "FileIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_9$$3); ZVAL_STRING(_9$$3, "messageIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, _8$$3, _9$$3); zephir_check_temp_parameter(_8$$3); zephir_check_temp_parameter(_9$$3); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_8$$3); object_init_ex(_8$$3, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_10$$3, "strtr", &_11, 27, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_9$$3); ZVAL_STRING(_9$$3, "FileIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _8$$3, "__construct", &_12, 475, _10$$3, field, _9$$3, code); zephir_check_temp_parameter(_9$$3); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _8$$3); zephir_check_call_status(); RETURN_MM_BOOL(0); } _13 = !(zephir_array_isset_string(value, SS("error"))); if (!(_13)) { _13 = !(zephir_array_isset_string(value, SS("tmp_name"))); } _14 = _13; if (!(_14)) { zephir_array_fetch_string(&_15, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 124 TSRMLS_CC); _14 = !ZEPHIR_IS_LONG_IDENTICAL(_15, 0); } _16 = _14; if (!(_16)) { zephir_array_fetch_string(&_17, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 124 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_18, "is_uploaded_file", NULL, 253, _17); zephir_check_call_status(); _16 = !zephir_is_true(_18); } if (_16) { ZEPHIR_INIT_VAR(_19$$4); ZVAL_STRING(_19$$4, "FileEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_20$$4); ZVAL_STRING(_20$$4, "messageEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, _19$$4, _20$$4); zephir_check_temp_parameter(_19$$4); zephir_check_temp_parameter(_20$$4); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_19$$4); object_init_ex(_19$$4, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_21$$4, "strtr", &_11, 27, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_20$$4); ZVAL_STRING(_20$$4, "FileEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _19$$4, "__construct", &_12, 475, _21$$4, field, _20$$4, code); zephir_check_temp_parameter(_20$$4); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _19$$4); zephir_check_call_status(); RETURN_MM_BOOL(0); } _22 = !(zephir_array_isset_string(value, SS("name"))); if (!(_22)) { _22 = !(zephir_array_isset_string(value, SS("type"))); } _23 = _22; if (!(_23)) { _23 = !(zephir_array_isset_string(value, SS("size"))); } if (_23) { ZEPHIR_INIT_VAR(_24$$5); ZVAL_STRING(_24$$5, "FileValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_25$$5); ZVAL_STRING(_25$$5, "messageValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, _24$$5, _25$$5); zephir_check_temp_parameter(_24$$5); zephir_check_temp_parameter(_25$$5); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_24$$5); object_init_ex(_24$$5, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_26$$5, "strtr", &_11, 27, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_25$$5); ZVAL_STRING(_25$$5, "FileValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _24$$5, "__construct", &_12, 475, _26$$5, field, _25$$5, code); zephir_check_temp_parameter(_25$$5); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _24$$5); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_VAR(_28); ZVAL_STRING(_28, "maxSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_27, this_ptr, "hasoption", NULL, 0, _28); zephir_check_temp_parameter(_28); zephir_check_call_status(); if (zephir_is_true(_27)) { ZEPHIR_INIT_VAR(byteUnits); zephir_create_array(byteUnits, 9, 0 TSRMLS_CC); add_assoc_long_ex(byteUnits, SS("B"), 0); add_assoc_long_ex(byteUnits, SS("K"), 10); add_assoc_long_ex(byteUnits, SS("M"), 20); add_assoc_long_ex(byteUnits, SS("G"), 30); add_assoc_long_ex(byteUnits, SS("T"), 40); add_assoc_long_ex(byteUnits, SS("KB"), 10); add_assoc_long_ex(byteUnits, SS("MB"), 20); add_assoc_long_ex(byteUnits, SS("GB"), 30); add_assoc_long_ex(byteUnits, SS("TB"), 40); ZEPHIR_INIT_VAR(_29$$6); ZVAL_STRING(_29$$6, "maxSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&maxSize, this_ptr, "getoption", NULL, 0, _29$$6); zephir_check_temp_parameter(_29$$6); zephir_check_call_status(); ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); ZEPHIR_INIT_VAR(unit); ZVAL_STRING(unit, "B", 1); if (Z_TYPE_P(maxSize) == IS_ARRAY) { zephir_array_fetch(&_30$$7, maxSize, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 162 TSRMLS_CC); ZEPHIR_CPY_WRT(maxSize, _30$$7); } ZEPHIR_INIT_NVAR(_29$$6); ZEPHIR_INIT_VAR(_31$$6); ZEPHIR_INIT_VAR(_32$$6); zephir_array_keys(_32$$6, byteUnits TSRMLS_CC); zephir_fast_join_str(_31$$6, SL("|"), _32$$6 TSRMLS_CC); ZEPHIR_INIT_VAR(_33$$6); ZEPHIR_CONCAT_SVS(_33$$6, "/^([0-9]+(?:\\.[0-9]+)?)(", _31$$6, ")?$/Di"); zephir_preg_match(_29$$6, _33$$6, maxSize, matches, 0, 0 , 0 TSRMLS_CC); if (zephir_array_isset_long(matches, 2)) { ZEPHIR_OBS_NVAR(unit); zephir_array_fetch_long(&unit, matches, 2, PH_NOISY, "phalcon/validation/validator/file.zep", 168 TSRMLS_CC); } zephir_array_fetch_long(&_34$$6, matches, 1, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 171 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_35$$6, "floatval", &_36, 328, _34$$6); zephir_check_call_status(); ZEPHIR_INIT_VAR(_37$$6); zephir_array_fetch(&_38$$6, byteUnits, unit, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 171 TSRMLS_CC); ZEPHIR_SINIT_VAR(_39$$6); ZVAL_LONG(&_39$$6, 2); zephir_pow_function(_37$$6, &_39$$6, _38$$6); ZEPHIR_INIT_VAR(bytes); mul_function(bytes, _35$$6, _37$$6 TSRMLS_CC); zephir_array_fetch_string(&_40$$6, value, SL("size"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 173 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_35$$6, "floatval", &_36, 328, _40$$6); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_41$$6, "floatval", &_36, 328, bytes); zephir_check_call_status(); if (ZEPHIR_GT(_35$$6, _41$$6)) { ZEPHIR_INIT_VAR(_42$$9); ZVAL_STRING(_42$$9, "FileSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_43$$9); ZVAL_STRING(_43$$9, "messageSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, _42$$9, _43$$9); zephir_check_temp_parameter(_42$$9); zephir_check_temp_parameter(_43$$9); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_42$$9); object_init_ex(_42$$9, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_44$$9, "strtr", &_11, 27, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_43$$9); ZVAL_STRING(_43$$9, "FileSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _42$$9, "__construct", &_12, 475, _44$$9, field, _43$$9, code); zephir_check_temp_parameter(_43$$9); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _42$$9); zephir_check_call_status(); RETURN_MM_BOOL(0); } } ZEPHIR_INIT_NVAR(_28); ZVAL_STRING(_28, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_45, this_ptr, "hasoption", NULL, 0, _28); zephir_check_temp_parameter(_28); zephir_check_call_status(); if (zephir_is_true(_45)) { ZEPHIR_INIT_VAR(_46$$10); ZVAL_STRING(_46$$10, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&types, this_ptr, "getoption", NULL, 0, _46$$10); zephir_check_temp_parameter(_46$$10); zephir_check_call_status(); ZEPHIR_OBS_VAR(fieldTypes); if (zephir_array_isset_fetch(&fieldTypes, types, field, 0 TSRMLS_CC)) { ZEPHIR_CPY_WRT(types, fieldTypes); } if (Z_TYPE_P(types) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Option 'allowedTypes' must be an array", "phalcon/validation/validator/file.zep", 198); return; } if ((zephir_function_exists_ex(SS("finfo_open") TSRMLS_CC) == SUCCESS)) { ZEPHIR_SINIT_VAR(_47$$13); ZVAL_LONG(&_47$$13, 16); ZEPHIR_CALL_FUNCTION(&tmp, "finfo_open", NULL, 250, &_47$$13); zephir_check_call_status(); zephir_array_fetch_string(&_48$$13, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 203 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&mime, "finfo_file", NULL, 251, tmp, _48$$13); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(NULL, "finfo_close", NULL, 252, tmp); zephir_check_call_status(); } else { ZEPHIR_OBS_NVAR(mime); zephir_array_fetch_string(&mime, value, SL("type"), PH_NOISY, "phalcon/validation/validator/file.zep", 207 TSRMLS_CC); } if (!(zephir_fast_in_array(mime, types TSRMLS_CC))) { ZEPHIR_INIT_VAR(_49$$15); ZVAL_STRING(_49$$15, "FileType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_50$$15); ZVAL_STRING(_50$$15, "messageType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, _49$$15, _50$$15); zephir_check_temp_parameter(_49$$15); zephir_check_temp_parameter(_50$$15); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_49$$15); zephir_fast_join_str(_49$$15, SL(", "), types TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":types"), &_49$$15, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_49$$15); object_init_ex(_49$$15, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_51$$15, "strtr", &_11, 27, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_50$$15); ZVAL_STRING(_50$$15, "FileType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _49$$15, "__construct", &_12, 475, _51$$15, field, _50$$15, code); zephir_check_temp_parameter(_50$$15); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _49$$15); zephir_check_call_status(); RETURN_MM_BOOL(0); } } ZEPHIR_INIT_NVAR(_28); ZVAL_STRING(_28, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_52, this_ptr, "hasoption", NULL, 0, _28); zephir_check_temp_parameter(_28); zephir_check_call_status(); _53 = zephir_is_true(_52); if (!(_53)) { ZEPHIR_INIT_NVAR(_28); ZVAL_STRING(_28, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_54, this_ptr, "hasoption", NULL, 0, _28); zephir_check_temp_parameter(_28); zephir_check_call_status(); _53 = zephir_is_true(_54); } if (_53) { zephir_array_fetch_string(&_55$$16, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 228 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&tmp, "getimagesize", NULL, 261, _55$$16); zephir_check_call_status(); ZEPHIR_OBS_VAR(width); zephir_array_fetch_long(&width, tmp, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 229 TSRMLS_CC); ZEPHIR_OBS_VAR(height); zephir_array_fetch_long(&height, tmp, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 230 TSRMLS_CC); ZEPHIR_INIT_VAR(_57$$16); ZVAL_STRING(_57$$16, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_56$$16, this_ptr, "hasoption", NULL, 0, _57$$16); zephir_check_temp_parameter(_57$$16); zephir_check_call_status(); if (zephir_is_true(_56$$16)) { ZEPHIR_INIT_VAR(_58$$17); ZVAL_STRING(_58$$17, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&minResolution, this_ptr, "getoption", NULL, 0, _58$$17); zephir_check_temp_parameter(_58$$17); zephir_check_call_status(); if (Z_TYPE_P(minResolution) == IS_ARRAY) { zephir_array_fetch(&_59$$18, minResolution, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 235 TSRMLS_CC); ZEPHIR_CPY_WRT(minResolution, _59$$18); } ZEPHIR_INIT_VAR(minResolutionArray); zephir_fast_explode_str(minResolutionArray, SL("x"), minResolution, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(minWidth); zephir_array_fetch_long(&minWidth, minResolutionArray, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 238 TSRMLS_CC); ZEPHIR_OBS_VAR(minHeight); zephir_array_fetch_long(&minHeight, minResolutionArray, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 239 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(minWidth); ZVAL_LONG(minWidth, 1); ZEPHIR_INIT_NVAR(minHeight); ZVAL_LONG(minHeight, 1); } _60$$16 = ZEPHIR_LT(width, minWidth); if (!(_60$$16)) { _60$$16 = ZEPHIR_LT(height, minHeight); } if (_60$$16) { ZEPHIR_INIT_VAR(_61$$20); ZVAL_STRING(_61$$20, "FileMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_62$$20); ZVAL_STRING(_62$$20, "messageMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, _61$$20, _62$$20); zephir_check_temp_parameter(_61$$20); zephir_check_temp_parameter(_62$$20); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":min"), &minResolution, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_61$$20); object_init_ex(_61$$20, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_63$$20, "strtr", &_11, 27, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_62$$20); ZVAL_STRING(_62$$20, "FileMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _61$$20, "__construct", &_12, 475, _63$$20, field, _62$$20, code); zephir_check_temp_parameter(_62$$20); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _61$$20); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_57$$16); ZVAL_STRING(_57$$16, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_64$$16, this_ptr, "hasoption", NULL, 0, _57$$16); zephir_check_temp_parameter(_57$$16); zephir_check_call_status(); if (zephir_is_true(_64$$16)) { ZEPHIR_INIT_VAR(_65$$21); ZVAL_STRING(_65$$21, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&maxResolution, this_ptr, "getoption", NULL, 0, _65$$21); zephir_check_temp_parameter(_65$$21); zephir_check_call_status(); if (Z_TYPE_P(maxResolution) == IS_ARRAY) { zephir_array_fetch(&_66$$22, maxResolution, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 265 TSRMLS_CC); ZEPHIR_CPY_WRT(maxResolution, _66$$22); } ZEPHIR_INIT_VAR(maxResolutionArray); zephir_fast_explode_str(maxResolutionArray, SL("x"), maxResolution, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(maxWidth); zephir_array_fetch_long(&maxWidth, maxResolutionArray, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 268 TSRMLS_CC); ZEPHIR_OBS_VAR(maxHeight); zephir_array_fetch_long(&maxHeight, maxResolutionArray, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 269 TSRMLS_CC); _67$$21 = ZEPHIR_GT(width, maxWidth); if (!(_67$$21)) { _67$$21 = ZEPHIR_GT(height, maxHeight); } if (_67$$21) { ZEPHIR_INIT_VAR(_68$$23); ZVAL_STRING(_68$$23, "FileMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_69$$23); ZVAL_STRING(_69$$23, "messageMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, _68$$23, _69$$23); zephir_check_temp_parameter(_68$$23); zephir_check_temp_parameter(_69$$23); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":max"), &maxResolution, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_68$$23); object_init_ex(_68$$23, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_70$$23, "strtr", &_11, 27, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_69$$23); ZVAL_STRING(_69$$23, "FileMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _68$$23, "__construct", &_12, 475, _70$$23, field, _69$$23, code); zephir_check_temp_parameter(_69$$23); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _68$$23); zephir_check_call_status(); RETURN_MM_BOOL(0); } } } RETURN_MM_BOOL(1); }
/** * Handles routing information received from the rewrite engine * *<code> * //Read the info from the rewrite engine * $router->handle(); * * //Manually passing an URL * $router->handle('/posts/edit/1'); *</code> */ PHP_METHOD(Phalcon_Mvc_Router, handle) { zval *_21$$28 = NULL, *_28$$37 = NULL, *_30$$40 = NULL; HashTable *_6, *_25$$33; HashPosition _5, _24$$33; zend_bool _1; zephir_fcall_cache_entry *_18 = NULL, *_20 = NULL, *_23 = NULL, *_31 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *uri_param = NULL, *realUri = NULL, *request = NULL, *currentHostName = NULL, *routeFound = NULL, *parts = NULL, *params = NULL, *matches = NULL, *notFoundPaths = NULL, *vnamespace = NULL, *module = NULL, *controller = NULL, *action = NULL, *paramsStr = NULL, *strParams = NULL, *route = NULL, *methods = NULL, *dependencyInjector = NULL, *hostname = NULL, *regexHostName = NULL, *matched = NULL, *pattern = NULL, *handledUri = NULL, *beforeMatch = NULL, *paths = NULL, *converters = NULL, *part = NULL, *position = NULL, *matchPosition = NULL, *converter = NULL, *eventsManager = NULL, *_0, *_4, **_7, *_32, *_33, *_34, *_35, *_36, _2$$5, *_3$$7, *_8$$10, *_9$$10 = NULL, *_10$$10 = NULL, *_11$$9 = NULL, *_12$$9 = NULL, *_13$$14, *_14$$14 = NULL, *_15$$14 = NULL, *_16$$18 = NULL, *_17$$23 = NULL, *_19$$27 = NULL, *_22$$31 = NULL, **_26$$33, *_27$$37 = NULL, *_29$$40 = NULL, _37$$55, *_38$$57, *_39$$59; zval *uri = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &uri_param); if (!uri_param) { ZEPHIR_INIT_VAR(uri); ZVAL_EMPTY_STRING(uri); } else { zephir_get_strval(uri, uri_param); } if (!(!(!uri) && Z_STRLEN_P(uri))) { ZEPHIR_CALL_METHOD(&realUri, this_ptr, "getrewriteuri", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(realUri, uri); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_removeExtraSlashes"), PH_NOISY_CC); _1 = zephir_is_true(_0); if (_1) { _1 = !ZEPHIR_IS_STRING(realUri, "/"); } if (_1) { ZEPHIR_SINIT_VAR(_2$$5); ZVAL_STRING(&_2$$5, "/", 0); ZEPHIR_INIT_VAR(handledUri); zephir_fast_trim(handledUri, realUri, &_2$$5, ZEPHIR_TRIM_RIGHT TSRMLS_CC); } else { ZEPHIR_CPY_WRT(handledUri, realUri); } ZEPHIR_INIT_VAR(request); ZVAL_NULL(request); ZEPHIR_INIT_VAR(currentHostName); ZVAL_NULL(currentHostName); ZEPHIR_INIT_VAR(routeFound); ZVAL_BOOL(routeFound, 0); ZEPHIR_INIT_VAR(parts); array_init(parts); ZEPHIR_INIT_VAR(params); array_init(params); ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); if (0) { zephir_update_property_this(this_ptr, SL("_wasMatched"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_wasMatched"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } zephir_update_property_this(this_ptr, SL("_matchedRoute"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); ZEPHIR_OBS_VAR(eventsManager); zephir_read_property_this(&eventsManager, this_ptr, SL("_eventsManager"), PH_NOISY_CC); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_3$$7); ZVAL_STRING(_3$$7, "router:beforeCheckRoutes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _3$$7, this_ptr); zephir_check_temp_parameter(_3$$7); zephir_check_call_status(); } _4 = zephir_fetch_nproperty_this(this_ptr, SL("_routes"), PH_NOISY_CC); zephir_is_iterable(_4, &_6, &_5, 0, 1, "phalcon/mvc/router.zep", 558); for ( ; zephir_hash_get_current_data_ex(_6, (void**) &_7, &_5) == SUCCESS ; zephir_hash_move_backwards_ex(_6, &_5) ) { ZEPHIR_GET_HVALUE(route, _7); ZEPHIR_INIT_NVAR(params); array_init(params); ZEPHIR_INIT_NVAR(matches); ZVAL_NULL(matches); ZEPHIR_CALL_METHOD(&methods, route, "gethttpmethods", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(methods) != IS_NULL) { if (Z_TYPE_P(request) == IS_NULL) { _8$$10 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _8$$10); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "A dependency injection container is required to access the 'request' service", "phalcon/mvc/router.zep", 384); return; } ZEPHIR_INIT_NVAR(_10$$10); ZVAL_STRING(_10$$10, "request", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_9$$10, dependencyInjector, "getshared", NULL, 0, _10$$10); zephir_check_temp_parameter(_10$$10); zephir_check_call_status(); ZEPHIR_CPY_WRT(request, _9$$10); } ZEPHIR_INIT_NVAR(_12$$9); ZVAL_BOOL(_12$$9, 1); ZEPHIR_CALL_METHOD(&_11$$9, request, "ismethod", NULL, 0, methods, _12$$9); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_11$$9)) { continue; } } ZEPHIR_CALL_METHOD(&hostname, route, "gethostname", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(hostname) != IS_NULL) { if (Z_TYPE_P(request) == IS_NULL) { _13$$14 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _13$$14); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "A dependency injection container is required to access the 'request' service", "phalcon/mvc/router.zep", 411); return; } ZEPHIR_INIT_NVAR(_15$$14); ZVAL_STRING(_15$$14, "request", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_14$$14, dependencyInjector, "getshared", NULL, 0, _15$$14); zephir_check_temp_parameter(_15$$14); zephir_check_call_status(); ZEPHIR_CPY_WRT(request, _14$$14); } if (Z_TYPE_P(currentHostName) != IS_OBJECT) { ZEPHIR_CALL_METHOD(¤tHostName, request, "gethttphost", NULL, 0); zephir_check_call_status(); } if (Z_TYPE_P(currentHostName) == IS_NULL) { continue; } if (zephir_memnstr_str(hostname, SL("("), "phalcon/mvc/router.zep", 434)) { if (!(zephir_memnstr_str(hostname, SL("#"), "phalcon/mvc/router.zep", 435))) { ZEPHIR_INIT_NVAR(regexHostName); ZEPHIR_CONCAT_SVS(regexHostName, "#^", hostname, "$#"); } else { ZEPHIR_CPY_WRT(regexHostName, hostname); } ZEPHIR_INIT_NVAR(_16$$18); ZEPHIR_INIT_NVAR(matched); zephir_preg_match(matched, regexHostName, currentHostName, _16$$18, 0, 0 , 0 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(matched); ZVAL_BOOL(matched, ZEPHIR_IS_EQUAL(currentHostName, hostname)); } if (!(zephir_is_true(matched))) { continue; } } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_17$$23); ZVAL_STRING(_17$$23, "router:beforeCheckRoute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_18, 0, _17$$23, this_ptr, route); zephir_check_temp_parameter(_17$$23); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&pattern, route, "getcompiledpattern", NULL, 0); zephir_check_call_status(); if (zephir_memnstr_str(pattern, SL("^"), "phalcon/mvc/router.zep", 459)) { ZEPHIR_INIT_NVAR(routeFound); zephir_preg_match(routeFound, pattern, handledUri, matches, 0, 0 , 0 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(routeFound); ZVAL_BOOL(routeFound, ZEPHIR_IS_EQUAL(pattern, handledUri)); } if (zephir_is_true(routeFound)) { if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_19$$27); ZVAL_STRING(_19$$27, "router:matchedRoute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_20, 0, _19$$27, this_ptr, route); zephir_check_temp_parameter(_19$$27); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&beforeMatch, route, "getbeforematch", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(beforeMatch) != IS_NULL) { if (!(zephir_is_callable(beforeMatch TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "Before-Match callback is not callable in matched route", "phalcon/mvc/router.zep", 481); return; } ZEPHIR_INIT_NVAR(_21$$28); zephir_create_array(_21$$28, 3, 0 TSRMLS_CC); zephir_array_fast_append(_21$$28, handledUri); zephir_array_fast_append(_21$$28, route); zephir_array_fast_append(_21$$28, this_ptr); ZEPHIR_INIT_NVAR(routeFound); ZEPHIR_CALL_USER_FUNC_ARRAY(routeFound, beforeMatch, _21$$28); zephir_check_call_status(); } } else { if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_22$$31); ZVAL_STRING(_22$$31, "router:notMatchedRoute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&routeFound, eventsManager, "fire", &_23, 0, _22$$31, this_ptr, route); zephir_check_temp_parameter(_22$$31); zephir_check_call_status(); } } if (zephir_is_true(routeFound)) { ZEPHIR_CALL_METHOD(&paths, route, "getpaths", NULL, 0); zephir_check_call_status(); ZEPHIR_CPY_WRT(parts, paths); if (Z_TYPE_P(matches) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&converters, route, "getconverters", NULL, 0); zephir_check_call_status(); zephir_is_iterable(paths, &_25$$33, &_24$$33, 0, 0, "phalcon/mvc/router.zep", 547); for ( ; zephir_hash_get_current_data_ex(_25$$33, (void**) &_26$$33, &_24$$33) == SUCCESS ; zephir_hash_move_forward_ex(_25$$33, &_24$$33) ) { ZEPHIR_GET_HMKEY(part, _25$$33, _24$$33); ZEPHIR_GET_HVALUE(position, _26$$33); ZEPHIR_OBS_NVAR(matchPosition); if (zephir_array_isset_fetch(&matchPosition, matches, position, 0 TSRMLS_CC)) { if (Z_TYPE_P(converters) == IS_ARRAY) { ZEPHIR_OBS_NVAR(converter); if (zephir_array_isset_fetch(&converter, converters, part, 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_27$$37); ZEPHIR_INIT_NVAR(_28$$37); zephir_create_array(_28$$37, 1, 0 TSRMLS_CC); zephir_array_fast_append(_28$$37, matchPosition); ZEPHIR_CALL_USER_FUNC_ARRAY(_27$$37, converter, _28$$37); zephir_check_call_status(); zephir_array_update_zval(&parts, part, &_27$$37, PH_COPY | PH_SEPARATE); continue; } } zephir_array_update_zval(&parts, part, &matchPosition, PH_COPY | PH_SEPARATE); } else { if (Z_TYPE_P(converters) == IS_ARRAY) { ZEPHIR_OBS_NVAR(converter); if (zephir_array_isset_fetch(&converter, converters, part, 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_29$$40); ZEPHIR_INIT_NVAR(_30$$40); zephir_create_array(_30$$40, 1, 0 TSRMLS_CC); zephir_array_fast_append(_30$$40, position); ZEPHIR_CALL_USER_FUNC_ARRAY(_29$$40, converter, _30$$40); zephir_check_call_status(); zephir_array_update_zval(&parts, part, &_29$$40, PH_COPY | PH_SEPARATE); } } } } zephir_update_property_this(this_ptr, SL("_matches"), matches TSRMLS_CC); } zephir_update_property_this(this_ptr, SL("_matchedRoute"), route TSRMLS_CC); break; } } if (zephir_is_true(routeFound)) { if (1) { zephir_update_property_this(this_ptr, SL("_wasMatched"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_wasMatched"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } else { if (0) { zephir_update_property_this(this_ptr, SL("_wasMatched"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_wasMatched"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } if (!(zephir_is_true(routeFound))) { ZEPHIR_OBS_VAR(notFoundPaths); zephir_read_property_this(¬FoundPaths, this_ptr, SL("_notFoundPaths"), PH_NOISY_CC); if (Z_TYPE_P(notFoundPaths) != IS_NULL) { ZEPHIR_CALL_CE_STATIC(&parts, phalcon_mvc_router_route_ce, "getroutepaths", &_31, 79, notFoundPaths); zephir_check_call_status(); ZEPHIR_INIT_NVAR(routeFound); ZVAL_BOOL(routeFound, 1); } } _32 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultNamespace"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_namespace"), _32 TSRMLS_CC); _33 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultModule"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_module"), _33 TSRMLS_CC); _34 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultController"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_controller"), _34 TSRMLS_CC); _35 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultAction"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_action"), _35 TSRMLS_CC); _36 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultParams"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_params"), _36 TSRMLS_CC); if (zephir_is_true(routeFound)) { ZEPHIR_OBS_VAR(vnamespace); if (zephir_array_isset_string_fetch(&vnamespace, parts, SS("namespace"), 0 TSRMLS_CC)) { if (!(zephir_is_numeric(vnamespace))) { zephir_update_property_this(this_ptr, SL("_namespace"), vnamespace TSRMLS_CC); } zephir_array_unset_string(&parts, SS("namespace"), PH_SEPARATE); } ZEPHIR_OBS_VAR(module); if (zephir_array_isset_string_fetch(&module, parts, SS("module"), 0 TSRMLS_CC)) { if (!(zephir_is_numeric(module))) { zephir_update_property_this(this_ptr, SL("_module"), module TSRMLS_CC); } zephir_array_unset_string(&parts, SS("module"), PH_SEPARATE); } ZEPHIR_OBS_VAR(controller); if (zephir_array_isset_string_fetch(&controller, parts, SS("controller"), 0 TSRMLS_CC)) { if (!(zephir_is_numeric(controller))) { zephir_update_property_this(this_ptr, SL("_controller"), controller TSRMLS_CC); } zephir_array_unset_string(&parts, SS("controller"), PH_SEPARATE); } ZEPHIR_OBS_VAR(action); if (zephir_array_isset_string_fetch(&action, parts, SS("action"), 0 TSRMLS_CC)) { if (!(zephir_is_numeric(action))) { zephir_update_property_this(this_ptr, SL("_action"), action TSRMLS_CC); } zephir_array_unset_string(&parts, SS("action"), PH_SEPARATE); } ZEPHIR_OBS_VAR(paramsStr); if (zephir_array_isset_string_fetch(¶msStr, parts, SS("params"), 0 TSRMLS_CC)) { if (Z_TYPE_P(paramsStr) == IS_STRING) { ZEPHIR_SINIT_VAR(_37$$55); ZVAL_STRING(&_37$$55, "/", 0); ZEPHIR_INIT_VAR(strParams); zephir_fast_trim(strParams, paramsStr, &_37$$55, ZEPHIR_TRIM_BOTH TSRMLS_CC); if (!ZEPHIR_IS_STRING_IDENTICAL(strParams, "")) { ZEPHIR_INIT_NVAR(params); zephir_fast_explode_str(params, SL("/"), strParams, LONG_MAX TSRMLS_CC); } } zephir_array_unset_string(&parts, SS("params"), PH_SEPARATE); } if (zephir_fast_count_int(params TSRMLS_CC)) { ZEPHIR_INIT_VAR(_38$$57); zephir_fast_array_merge(_38$$57, &(params), &(parts) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_params"), _38$$57 TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_params"), parts TSRMLS_CC); } } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_39$$59); ZVAL_STRING(_39$$59, "router:afterCheckRoutes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _39$$59, this_ptr); zephir_check_temp_parameter(_39$$59); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_File, validate) { zend_bool _1, _2, _3, _5, _6, _11, _12, _14, _20, _21, _50, _57$$16, _64$$21; zend_long ZEPHIR_LAST_CALL_STATUS; zval *validation, validation_sub, *field, field_sub, *_SERVER, *_POST, *_FILES, value, message, label, replacePairs, types, byteUnits, unit, maxSize, matches, bytes, mime, tmp, width, height, minResolution, maxResolution, minWidth, maxWidth, minHeight, maxHeight, fieldTypes, code, minResolutionArray, maxResolutionArray, _0, _4, _7, _13, _15, _16, _25, _26, _42, _49, _51, _8$$3, _9$$3, _10$$3, _17$$4, _18$$4, _19$$4, _22$$5, _23$$5, _24$$5, _27$$6, _29$$6, _30$$6, _31$$6, _32$$6, _33$$6, _34$$6, _35$$6, _36$$6, _37$$6, _38$$6, _28$$7, _39$$9, _40$$9, _41$$9, _43$$10, _44$$13, _45$$13, _46$$15, _47$$15, _48$$15, _52$$16, _53$$16, _54$$16, _61$$16, _55$$17, _56$$18, _58$$20, _59$$20, _60$$20, _62$$21, _63$$22, _65$$23, _66$$23, _67$$23; zval *this_ptr = getThis(); ZVAL_UNDEF(&validation_sub); ZVAL_UNDEF(&field_sub); ZVAL_UNDEF(&value); ZVAL_UNDEF(&message); ZVAL_UNDEF(&label); ZVAL_UNDEF(&replacePairs); ZVAL_UNDEF(&types); ZVAL_UNDEF(&byteUnits); ZVAL_UNDEF(&unit); ZVAL_UNDEF(&maxSize); ZVAL_UNDEF(&matches); ZVAL_UNDEF(&bytes); ZVAL_UNDEF(&mime); ZVAL_UNDEF(&tmp); ZVAL_UNDEF(&width); ZVAL_UNDEF(&height); ZVAL_UNDEF(&minResolution); ZVAL_UNDEF(&maxResolution); ZVAL_UNDEF(&minWidth); ZVAL_UNDEF(&maxWidth); ZVAL_UNDEF(&minHeight); ZVAL_UNDEF(&maxHeight); ZVAL_UNDEF(&fieldTypes); ZVAL_UNDEF(&code); ZVAL_UNDEF(&minResolutionArray); ZVAL_UNDEF(&maxResolutionArray); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_7); ZVAL_UNDEF(&_13); ZVAL_UNDEF(&_15); ZVAL_UNDEF(&_16); ZVAL_UNDEF(&_25); ZVAL_UNDEF(&_26); ZVAL_UNDEF(&_42); ZVAL_UNDEF(&_49); ZVAL_UNDEF(&_51); ZVAL_UNDEF(&_8$$3); ZVAL_UNDEF(&_9$$3); ZVAL_UNDEF(&_10$$3); ZVAL_UNDEF(&_17$$4); ZVAL_UNDEF(&_18$$4); ZVAL_UNDEF(&_19$$4); ZVAL_UNDEF(&_22$$5); ZVAL_UNDEF(&_23$$5); ZVAL_UNDEF(&_24$$5); ZVAL_UNDEF(&_27$$6); ZVAL_UNDEF(&_29$$6); ZVAL_UNDEF(&_30$$6); ZVAL_UNDEF(&_31$$6); ZVAL_UNDEF(&_32$$6); ZVAL_UNDEF(&_33$$6); ZVAL_UNDEF(&_34$$6); ZVAL_UNDEF(&_35$$6); ZVAL_UNDEF(&_36$$6); ZVAL_UNDEF(&_37$$6); ZVAL_UNDEF(&_38$$6); ZVAL_UNDEF(&_28$$7); ZVAL_UNDEF(&_39$$9); ZVAL_UNDEF(&_40$$9); ZVAL_UNDEF(&_41$$9); ZVAL_UNDEF(&_43$$10); ZVAL_UNDEF(&_44$$13); ZVAL_UNDEF(&_45$$13); ZVAL_UNDEF(&_46$$15); ZVAL_UNDEF(&_47$$15); ZVAL_UNDEF(&_48$$15); ZVAL_UNDEF(&_52$$16); ZVAL_UNDEF(&_53$$16); ZVAL_UNDEF(&_54$$16); ZVAL_UNDEF(&_61$$16); ZVAL_UNDEF(&_55$$17); ZVAL_UNDEF(&_56$$18); ZVAL_UNDEF(&_58$$20); ZVAL_UNDEF(&_59$$20); ZVAL_UNDEF(&_60$$20); ZVAL_UNDEF(&_62$$21); ZVAL_UNDEF(&_63$$22); ZVAL_UNDEF(&_65$$23); ZVAL_UNDEF(&_66$$23); ZVAL_UNDEF(&_67$$23); ZEPHIR_MM_GROW(); zephir_get_global(&_FILES, SL("_FILES")); zephir_get_global(&_POST, SL("_POST")); zephir_get_global(&_SERVER, SL("_SERVER")); zephir_fetch_params(1, 2, 0, &validation, &field); ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&label, this_ptr, "preparelabel", NULL, 0, validation, field); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&code, this_ptr, "preparecode", NULL, 0, field); zephir_check_call_status(); zephir_array_fetch_string(&_0, _SERVER, SL("REQUEST_METHOD"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 103 TSRMLS_CC); _1 = ZEPHIR_IS_STRING(&_0, "POST"); if (_1) { _1 = ZEPHIR_IS_EMPTY(_POST); } _2 = _1; if (_2) { _2 = ZEPHIR_IS_EMPTY(_FILES); } _3 = _2; if (_3) { zephir_array_fetch_string(&_4, _SERVER, SL("CONTENT_LENGTH"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 103 TSRMLS_CC); _3 = ZEPHIR_GT_LONG(&_4, 0); } _5 = _3; if (!(_5)) { _6 = zephir_array_isset_string(&value, SL("error")); if (_6) { zephir_array_fetch_string(&_7, &value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 103 TSRMLS_CC); _6 = ZEPHIR_IS_LONG_IDENTICAL(&_7, 1); } _5 = _6; } if (_5) { ZEPHIR_INIT_VAR(&_8$$3); ZVAL_STRING(&_8$$3, "FileIniSize"); ZEPHIR_INIT_VAR(&_9$$3); ZVAL_STRING(&_9$$3, "messageIniSize"); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, &_8$$3, &_9$$3); zephir_check_call_status(); ZEPHIR_INIT_VAR(&replacePairs); zephir_create_array(&replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_8$$3); object_init_ex(&_8$$3, phalcon_messages_message_ce); ZEPHIR_CALL_FUNCTION(&_10$$3, "strtr", NULL, 50, &message, &replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_9$$3); ZVAL_STRING(&_9$$3, "FileIniSize"); ZEPHIR_CALL_METHOD(NULL, &_8$$3, "__construct", NULL, 295, &_10$$3, field, &_9$$3, &code); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_8$$3); zephir_check_call_status(); RETURN_MM_BOOL(0); } _11 = !(zephir_array_isset_string(&value, SL("error"))); if (!(_11)) { _11 = !(zephir_array_isset_string(&value, SL("tmp_name"))); } _12 = _11; if (!(_12)) { zephir_array_fetch_string(&_13, &value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 119 TSRMLS_CC); _12 = !ZEPHIR_IS_LONG_IDENTICAL(&_13, 0); } _14 = _12; if (!(_14)) { zephir_array_fetch_string(&_15, &value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 119 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_16, "is_uploaded_file", NULL, 228, &_15); zephir_check_call_status(); _14 = !zephir_is_true(&_16); } if (_14) { ZEPHIR_INIT_VAR(&_17$$4); ZVAL_STRING(&_17$$4, "FileEmpty"); ZEPHIR_INIT_VAR(&_18$$4); ZVAL_STRING(&_18$$4, "messageEmpty"); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, &_17$$4, &_18$$4); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&replacePairs); zephir_create_array(&replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_17$$4); object_init_ex(&_17$$4, phalcon_messages_message_ce); ZEPHIR_CALL_FUNCTION(&_19$$4, "strtr", NULL, 50, &message, &replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_18$$4); ZVAL_STRING(&_18$$4, "FileEmpty"); ZEPHIR_CALL_METHOD(NULL, &_17$$4, "__construct", NULL, 295, &_19$$4, field, &_18$$4, &code); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_17$$4); zephir_check_call_status(); RETURN_MM_BOOL(0); } _20 = !(zephir_array_isset_string(&value, SL("name"))); if (!(_20)) { _20 = !(zephir_array_isset_string(&value, SL("type"))); } _21 = _20; if (!(_21)) { _21 = !(zephir_array_isset_string(&value, SL("size"))); } if (_21) { ZEPHIR_INIT_VAR(&_22$$5); ZVAL_STRING(&_22$$5, "FileValid"); ZEPHIR_INIT_VAR(&_23$$5); ZVAL_STRING(&_23$$5, "messageValid"); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, &_22$$5, &_23$$5); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&replacePairs); zephir_create_array(&replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_22$$5); object_init_ex(&_22$$5, phalcon_messages_message_ce); ZEPHIR_CALL_FUNCTION(&_24$$5, "strtr", NULL, 50, &message, &replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_23$$5); ZVAL_STRING(&_23$$5, "FileValid"); ZEPHIR_CALL_METHOD(NULL, &_22$$5, "__construct", NULL, 295, &_24$$5, field, &_23$$5, &code); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_22$$5); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_VAR(&_26); ZVAL_STRING(&_26, "maxSize"); ZEPHIR_CALL_METHOD(&_25, this_ptr, "hasoption", NULL, 0, &_26); zephir_check_call_status(); if (zephir_is_true(&_25)) { ZEPHIR_INIT_VAR(&byteUnits); zephir_create_array(&byteUnits, 9, 0 TSRMLS_CC); add_assoc_long_ex(&byteUnits, SL("B"), 0); add_assoc_long_ex(&byteUnits, SL("K"), 10); add_assoc_long_ex(&byteUnits, SL("M"), 20); add_assoc_long_ex(&byteUnits, SL("G"), 30); add_assoc_long_ex(&byteUnits, SL("T"), 40); add_assoc_long_ex(&byteUnits, SL("KB"), 10); add_assoc_long_ex(&byteUnits, SL("MB"), 20); add_assoc_long_ex(&byteUnits, SL("GB"), 30); add_assoc_long_ex(&byteUnits, SL("TB"), 40); ZEPHIR_INIT_VAR(&_27$$6); ZVAL_STRING(&_27$$6, "maxSize"); ZEPHIR_CALL_METHOD(&maxSize, this_ptr, "getoption", NULL, 0, &_27$$6); zephir_check_call_status(); ZEPHIR_INIT_VAR(&matches); ZVAL_NULL(&matches); ZEPHIR_INIT_VAR(&unit); ZVAL_STRING(&unit, "B"); if (Z_TYPE_P(&maxSize) == IS_ARRAY) { zephir_array_fetch(&_28$$7, &maxSize, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 159 TSRMLS_CC); ZEPHIR_CPY_WRT(&maxSize, &_28$$7); } ZEPHIR_INIT_NVAR(&_27$$6); ZEPHIR_INIT_VAR(&_29$$6); zephir_array_keys(&_29$$6, &byteUnits TSRMLS_CC); zephir_fast_join_str(&_27$$6, SL("|"), &_29$$6 TSRMLS_CC); ZEPHIR_INIT_VAR(&_30$$6); ZEPHIR_CONCAT_SVS(&_30$$6, "/^([0-9]+(?:\\.[0-9]+)?)(", &_27$$6, ")?$/Di"); ZEPHIR_INIT_VAR(&_31$$6); zephir_preg_match(&_31$$6, &_30$$6, &maxSize, &matches, 0, 0 , 0 TSRMLS_CC); if (zephir_array_isset_long(&matches, 2)) { ZEPHIR_OBS_NVAR(&unit); zephir_array_fetch_long(&unit, &matches, 2, PH_NOISY, "phalcon/validation/validator/file.zep", 165 TSRMLS_CC); } zephir_array_fetch_long(&_32$$6, &matches, 1, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 168 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_33$$6, "floatval", NULL, 319, &_32$$6); zephir_check_call_status(); ZEPHIR_INIT_VAR(&_34$$6); zephir_array_fetch(&_35$$6, &byteUnits, &unit, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 168 TSRMLS_CC); ZVAL_LONG(&_36$$6, 2); zephir_pow_function(&_34$$6, &_36$$6, &_35$$6); ZEPHIR_INIT_VAR(&bytes); mul_function(&bytes, &_33$$6, &_34$$6 TSRMLS_CC); zephir_array_fetch_string(&_37$$6, &value, SL("size"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 170 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_33$$6, "floatval", NULL, 319, &_37$$6); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_38$$6, "floatval", NULL, 319, &bytes); zephir_check_call_status(); if (ZEPHIR_GT(&_33$$6, &_38$$6)) { ZEPHIR_INIT_VAR(&_39$$9); ZVAL_STRING(&_39$$9, "FileSize"); ZEPHIR_INIT_VAR(&_40$$9); ZVAL_STRING(&_40$$9, "messageSize"); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, &_39$$9, &_40$$9); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&replacePairs); zephir_create_array(&replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":max"), &maxSize, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_39$$9); object_init_ex(&_39$$9, phalcon_messages_message_ce); ZEPHIR_CALL_FUNCTION(&_41$$9, "strtr", NULL, 50, &message, &replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_40$$9); ZVAL_STRING(&_40$$9, "FileSize"); ZEPHIR_CALL_METHOD(NULL, &_39$$9, "__construct", NULL, 295, &_41$$9, field, &_40$$9, &code); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_39$$9); zephir_check_call_status(); RETURN_MM_BOOL(0); } } ZEPHIR_INIT_NVAR(&_26); ZVAL_STRING(&_26, "allowedTypes"); ZEPHIR_CALL_METHOD(&_42, this_ptr, "hasoption", NULL, 0, &_26); zephir_check_call_status(); if (zephir_is_true(&_42)) { ZEPHIR_INIT_VAR(&_43$$10); ZVAL_STRING(&_43$$10, "allowedTypes"); ZEPHIR_CALL_METHOD(&types, this_ptr, "getoption", NULL, 0, &_43$$10); zephir_check_call_status(); ZEPHIR_OBS_VAR(&fieldTypes); if (zephir_array_isset_fetch(&fieldTypes, &types, field, 0 TSRMLS_CC)) { ZEPHIR_CPY_WRT(&types, &fieldTypes); } if (Z_TYPE_P(&types) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Option 'allowedTypes' must be an array", "phalcon/validation/validator/file.zep", 196); return; } if ((zephir_function_exists_ex(SL("finfo_open") TSRMLS_CC) == SUCCESS)) { ZVAL_LONG(&_44$$13, 16); ZEPHIR_CALL_FUNCTION(&tmp, "finfo_open", NULL, 225, &_44$$13); zephir_check_call_status(); zephir_array_fetch_string(&_45$$13, &value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 201 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&mime, "finfo_file", NULL, 226, &tmp, &_45$$13); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(NULL, "finfo_close", NULL, 227, &tmp); zephir_check_call_status(); } else { ZEPHIR_OBS_NVAR(&mime); zephir_array_fetch_string(&mime, &value, SL("type"), PH_NOISY, "phalcon/validation/validator/file.zep", 205 TSRMLS_CC); } if (!(zephir_fast_in_array(&mime, &types TSRMLS_CC))) { ZEPHIR_INIT_VAR(&_46$$15); ZVAL_STRING(&_46$$15, "FileType"); ZEPHIR_INIT_VAR(&_47$$15); ZVAL_STRING(&_47$$15, "messageType"); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, &_46$$15, &_47$$15); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&replacePairs); zephir_create_array(&replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_46$$15); zephir_fast_join_str(&_46$$15, SL(", "), &types TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":types"), &_46$$15, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_46$$15); object_init_ex(&_46$$15, phalcon_messages_message_ce); ZEPHIR_CALL_FUNCTION(&_48$$15, "strtr", NULL, 50, &message, &replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_47$$15); ZVAL_STRING(&_47$$15, "FileType"); ZEPHIR_CALL_METHOD(NULL, &_46$$15, "__construct", NULL, 295, &_48$$15, field, &_47$$15, &code); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_46$$15); zephir_check_call_status(); RETURN_MM_BOOL(0); } } ZEPHIR_INIT_NVAR(&_26); ZVAL_STRING(&_26, "minResolution"); ZEPHIR_CALL_METHOD(&_49, this_ptr, "hasoption", NULL, 0, &_26); zephir_check_call_status(); _50 = zephir_is_true(&_49); if (!(_50)) { ZEPHIR_INIT_NVAR(&_26); ZVAL_STRING(&_26, "maxResolution"); ZEPHIR_CALL_METHOD(&_51, this_ptr, "hasoption", NULL, 0, &_26); zephir_check_call_status(); _50 = zephir_is_true(&_51); } if (_50) { zephir_array_fetch_string(&_52$$16, &value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 226 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&tmp, "getimagesize", NULL, 237, &_52$$16); zephir_check_call_status(); ZEPHIR_OBS_VAR(&width); zephir_array_fetch_long(&width, &tmp, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 227 TSRMLS_CC); ZEPHIR_OBS_VAR(&height); zephir_array_fetch_long(&height, &tmp, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 228 TSRMLS_CC); ZEPHIR_INIT_VAR(&_54$$16); ZVAL_STRING(&_54$$16, "minResolution"); ZEPHIR_CALL_METHOD(&_53$$16, this_ptr, "hasoption", NULL, 0, &_54$$16); zephir_check_call_status(); if (zephir_is_true(&_53$$16)) { ZEPHIR_INIT_VAR(&_55$$17); ZVAL_STRING(&_55$$17, "minResolution"); ZEPHIR_CALL_METHOD(&minResolution, this_ptr, "getoption", NULL, 0, &_55$$17); zephir_check_call_status(); if (Z_TYPE_P(&minResolution) == IS_ARRAY) { zephir_array_fetch(&_56$$18, &minResolution, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 233 TSRMLS_CC); ZEPHIR_CPY_WRT(&minResolution, &_56$$18); } ZEPHIR_INIT_VAR(&minResolutionArray); zephir_fast_explode_str(&minResolutionArray, SL("x"), &minResolution, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(&minWidth); zephir_array_fetch_long(&minWidth, &minResolutionArray, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 236 TSRMLS_CC); ZEPHIR_OBS_VAR(&minHeight); zephir_array_fetch_long(&minHeight, &minResolutionArray, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 237 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(&minWidth); ZVAL_LONG(&minWidth, 1); ZEPHIR_INIT_NVAR(&minHeight); ZVAL_LONG(&minHeight, 1); } _57$$16 = ZEPHIR_LT(&width, &minWidth); if (!(_57$$16)) { _57$$16 = ZEPHIR_LT(&height, &minHeight); } if (_57$$16) { ZEPHIR_INIT_VAR(&_58$$20); ZVAL_STRING(&_58$$20, "FileMinResolution"); ZEPHIR_INIT_VAR(&_59$$20); ZVAL_STRING(&_59$$20, "messageMinResolution"); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, &_58$$20, &_59$$20); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&replacePairs); zephir_create_array(&replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":min"), &minResolution, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_58$$20); object_init_ex(&_58$$20, phalcon_messages_message_ce); ZEPHIR_CALL_FUNCTION(&_60$$20, "strtr", NULL, 50, &message, &replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_59$$20); ZVAL_STRING(&_59$$20, "FileMinResolution"); ZEPHIR_CALL_METHOD(NULL, &_58$$20, "__construct", NULL, 295, &_60$$20, field, &_59$$20, &code); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_58$$20); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(&_54$$16); ZVAL_STRING(&_54$$16, "maxResolution"); ZEPHIR_CALL_METHOD(&_61$$16, this_ptr, "hasoption", NULL, 0, &_54$$16); zephir_check_call_status(); if (zephir_is_true(&_61$$16)) { ZEPHIR_INIT_VAR(&_62$$21); ZVAL_STRING(&_62$$21, "maxResolution"); ZEPHIR_CALL_METHOD(&maxResolution, this_ptr, "getoption", NULL, 0, &_62$$21); zephir_check_call_status(); if (Z_TYPE_P(&maxResolution) == IS_ARRAY) { zephir_array_fetch(&_63$$22, &maxResolution, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 263 TSRMLS_CC); ZEPHIR_CPY_WRT(&maxResolution, &_63$$22); } ZEPHIR_INIT_VAR(&maxResolutionArray); zephir_fast_explode_str(&maxResolutionArray, SL("x"), &maxResolution, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(&maxWidth); zephir_array_fetch_long(&maxWidth, &maxResolutionArray, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 266 TSRMLS_CC); ZEPHIR_OBS_VAR(&maxHeight); zephir_array_fetch_long(&maxHeight, &maxResolutionArray, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 267 TSRMLS_CC); _64$$21 = ZEPHIR_GT(&width, &maxWidth); if (!(_64$$21)) { _64$$21 = ZEPHIR_GT(&height, &maxHeight); } if (_64$$21) { ZEPHIR_INIT_VAR(&_65$$23); ZVAL_STRING(&_65$$23, "FileMaxResolution"); ZEPHIR_INIT_VAR(&_66$$23); ZVAL_STRING(&_66$$23, "messageMaxResolution"); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, &_65$$23, &_66$$23); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&replacePairs); zephir_create_array(&replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":max"), &maxResolution, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_65$$23); object_init_ex(&_65$$23, phalcon_messages_message_ce); ZEPHIR_CALL_FUNCTION(&_67$$23, "strtr", NULL, 50, &message, &replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_66$$23); ZVAL_STRING(&_66$$23, "FileMaxResolution"); ZEPHIR_CALL_METHOD(NULL, &_65$$23, "__construct", NULL, 295, &_67$$23, field, &_66$$23, &code); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_65$$23); zephir_check_call_status(); RETURN_MM_BOOL(0); } } } RETURN_MM_BOOL(1); }
/** * Reconfigure the route adding a new pattern and a set of paths * * @param string pattern * @param array paths */ PHP_METHOD(Phalcon_Cli_Router_Route, reConfigure) { int ZEPHIR_LAST_CALL_STATUS, _0$$4; zval *pattern_param = NULL, *paths = NULL, *moduleName = NULL, *taskName = NULL, *actionName = NULL, *parts = NULL, *routePaths = NULL, *realClassName = NULL, *namespaceName = NULL, *pcrePattern = NULL, *compiledPattern = NULL, *extracted = NULL, *_1$$9, *_2$$18, *_3$$18, *_4$$21, *_5$$21, _6$$21; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &pattern_param, &paths); if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(paths) != IS_NULL) { if (Z_TYPE_P(paths) == IS_STRING) { ZEPHIR_INIT_VAR(moduleName); ZVAL_NULL(moduleName); ZEPHIR_INIT_VAR(taskName); ZVAL_NULL(taskName); ZEPHIR_INIT_VAR(actionName); ZVAL_NULL(actionName); ZEPHIR_INIT_VAR(parts); zephir_fast_explode_str(parts, SL("::"), paths, LONG_MAX TSRMLS_CC); do { _0$$4 = zephir_fast_count_int(parts TSRMLS_CC); if (_0$$4 == 3) { ZEPHIR_OBS_NVAR(moduleName); zephir_array_fetch_long(&moduleName, parts, 0, PH_NOISY, "phalcon/cli/router/route.zep", 318 TSRMLS_CC); ZEPHIR_OBS_NVAR(taskName); zephir_array_fetch_long(&taskName, parts, 1, PH_NOISY, "phalcon/cli/router/route.zep", 319 TSRMLS_CC); ZEPHIR_OBS_NVAR(actionName); zephir_array_fetch_long(&actionName, parts, 2, PH_NOISY, "phalcon/cli/router/route.zep", 320 TSRMLS_CC); break; } if (_0$$4 == 2) { ZEPHIR_OBS_NVAR(taskName); zephir_array_fetch_long(&taskName, parts, 0, PH_NOISY, "phalcon/cli/router/route.zep", 324 TSRMLS_CC); ZEPHIR_OBS_NVAR(actionName); zephir_array_fetch_long(&actionName, parts, 1, PH_NOISY, "phalcon/cli/router/route.zep", 325 TSRMLS_CC); break; } if (_0$$4 == 1) { ZEPHIR_OBS_NVAR(taskName); zephir_array_fetch_long(&taskName, parts, 0, PH_NOISY, "phalcon/cli/router/route.zep", 329 TSRMLS_CC); break; } } while(0); ZEPHIR_INIT_VAR(routePaths); array_init(routePaths); if (Z_TYPE_P(moduleName) != IS_NULL) { zephir_array_update_string(&routePaths, SL("module"), &moduleName, PH_COPY | PH_SEPARATE); } if (Z_TYPE_P(taskName) != IS_NULL) { if (zephir_memnstr_str(taskName, SL("\\"), "phalcon/cli/router/route.zep", 344)) { ZEPHIR_INIT_VAR(realClassName); zephir_get_class_ns(realClassName, taskName, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(namespaceName); zephir_get_ns_class(namespaceName, taskName, 0 TSRMLS_CC); if (zephir_is_true(namespaceName)) { zephir_array_update_string(&routePaths, SL("namespace"), &namespaceName, PH_COPY | PH_SEPARATE); } } else { ZEPHIR_CPY_WRT(realClassName, taskName); } ZEPHIR_INIT_VAR(_1$$9); zephir_uncamelize(_1$$9, realClassName, NULL ); zephir_array_update_string(&routePaths, SL("task"), &_1$$9, PH_COPY | PH_SEPARATE); } if (Z_TYPE_P(actionName) != IS_NULL) { zephir_array_update_string(&routePaths, SL("action"), &actionName, PH_COPY | PH_SEPARATE); } } else { ZEPHIR_CPY_WRT(routePaths, paths); } } else { ZEPHIR_INIT_NVAR(routePaths); array_init(routePaths); } if (Z_TYPE_P(routePaths) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_router_exception_ce, "The route contains invalid paths", "phalcon/cli/router/route.zep", 376); return; } if (!(zephir_start_with_str(pattern, SL("#")))) { if (zephir_memnstr_str(pattern, SL("{"), "phalcon/cli/router/route.zep", 384)) { ZEPHIR_CALL_METHOD(&extracted, this_ptr, "extractnamedparams", NULL, 0, pattern); zephir_check_call_status(); ZEPHIR_OBS_VAR(pcrePattern); zephir_array_fetch_long(&pcrePattern, extracted, 0, PH_NOISY, "phalcon/cli/router/route.zep", 389 TSRMLS_CC); ZEPHIR_INIT_VAR(_2$$18); zephir_array_fetch_long(&_3$$18, extracted, 1, PH_NOISY | PH_READONLY, "phalcon/cli/router/route.zep", 390 TSRMLS_CC); zephir_fast_array_merge(_2$$18, &(routePaths), &(_3$$18) TSRMLS_CC); ZEPHIR_CPY_WRT(routePaths, _2$$18); } else { ZEPHIR_CPY_WRT(pcrePattern, pattern); } ZEPHIR_CALL_METHOD(&compiledPattern, this_ptr, "compilepattern", NULL, 0, pcrePattern); zephir_check_call_status(); } else { if (zephir_memnstr_str(pattern, SL(":delimiter"), "phalcon/cli/router/route.zep", 401)) { ZEPHIR_INIT_VAR(_4$$21); _5$$21 = zephir_fetch_nproperty_this(this_ptr, SL("_delimiter"), PH_NOISY_CC); ZEPHIR_SINIT_VAR(_6$$21); ZVAL_STRING(&_6$$21, ":delimiter", 0); zephir_fast_str_replace(&_4$$21, &_6$$21, _5$$21, pattern TSRMLS_CC); zephir_get_strval(pattern, _4$$21); } ZEPHIR_CPY_WRT(compiledPattern, pattern); } zephir_update_property_this(this_ptr, SL("_pattern"), pattern TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_compiledPattern"), compiledPattern TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_paths"), routePaths TSRMLS_CC); ZEPHIR_MM_RESTORE(); }
/** * Returns routePaths */ PHP_METHOD(Phalcon_Mvc_Router_Route, getRoutePaths) { int _0; zval *paths = NULL, *moduleName = NULL, *controllerName = NULL, *actionName = NULL, *parts, *routePaths = NULL, *realClassName = NULL, *namespaceName, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &paths); if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(paths) != IS_NULL) { if (Z_TYPE_P(paths) == IS_STRING) { ZEPHIR_INIT_VAR(moduleName); ZVAL_NULL(moduleName); ZEPHIR_INIT_VAR(controllerName); ZVAL_NULL(controllerName); ZEPHIR_INIT_VAR(actionName); ZVAL_NULL(actionName); ZEPHIR_INIT_VAR(parts); zephir_fast_explode_str(parts, SL("::"), paths, LONG_MAX TSRMLS_CC); do { _0 = zephir_fast_count_int(parts TSRMLS_CC); if (_0 == 3) { ZEPHIR_OBS_NVAR(moduleName); zephir_array_fetch_long(&moduleName, parts, 0, PH_NOISY, "phalcon/mvc/router/route.zep", 353 TSRMLS_CC); ZEPHIR_OBS_NVAR(controllerName); zephir_array_fetch_long(&controllerName, parts, 1, PH_NOISY, "phalcon/mvc/router/route.zep", 354 TSRMLS_CC); ZEPHIR_OBS_NVAR(actionName); zephir_array_fetch_long(&actionName, parts, 2, PH_NOISY, "phalcon/mvc/router/route.zep", 355 TSRMLS_CC); break; } if (_0 == 2) { ZEPHIR_OBS_NVAR(controllerName); zephir_array_fetch_long(&controllerName, parts, 0, PH_NOISY, "phalcon/mvc/router/route.zep", 359 TSRMLS_CC); ZEPHIR_OBS_NVAR(actionName); zephir_array_fetch_long(&actionName, parts, 1, PH_NOISY, "phalcon/mvc/router/route.zep", 360 TSRMLS_CC); break; } if (_0 == 1) { ZEPHIR_OBS_NVAR(controllerName); zephir_array_fetch_long(&controllerName, parts, 0, PH_NOISY, "phalcon/mvc/router/route.zep", 364 TSRMLS_CC); break; } } while(0); ZEPHIR_INIT_VAR(routePaths); array_init(routePaths); if (Z_TYPE_P(moduleName) != IS_NULL) { zephir_array_update_string(&routePaths, SL("module"), &moduleName, PH_COPY | PH_SEPARATE); } if (Z_TYPE_P(controllerName) != IS_NULL) { if (zephir_memnstr_str(controllerName, SL("\\"), "phalcon/mvc/router/route.zep", 379)) { ZEPHIR_INIT_VAR(realClassName); zephir_get_class_ns(realClassName, controllerName, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(namespaceName); zephir_get_ns_class(namespaceName, controllerName, 0 TSRMLS_CC); if (zephir_is_true(namespaceName)) { zephir_array_update_string(&routePaths, SL("namespace"), &namespaceName, PH_COPY | PH_SEPARATE); } } else { ZEPHIR_CPY_WRT(realClassName, controllerName); } ZEPHIR_INIT_VAR(_1); zephir_uncamelize(_1, realClassName); zephir_array_update_string(&routePaths, SL("controller"), &_1, PH_COPY | PH_SEPARATE); } if (Z_TYPE_P(actionName) != IS_NULL) { zephir_array_update_string(&routePaths, SL("action"), &actionName, PH_COPY | PH_SEPARATE); } } else { ZEPHIR_CPY_WRT(routePaths, paths); } } else { ZEPHIR_INIT_NVAR(routePaths); array_init(routePaths); } if (Z_TYPE_P(routePaths) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "The route contains invalid paths", "phalcon/mvc/router/route.zep", 411); return; } RETURN_CCTOR(routePaths); }
/** * Handles routing information received from the rewrite engine * *<code> * //Read the info from the rewrite engine * $router->handle(); * * //Manually passing an URL * $router->handle('/posts/edit/1'); *</code> * * @param string uri */ PHP_METHOD(Test_Router, handle) { zend_function *_8 = NULL, *_9 = NULL, *_11 = NULL, *_12 = NULL, *_14 = NULL; HashTable *_3, *_16; HashPosition _2, _15; zval *uri = NULL, *realUri = NULL, *request = NULL, *currentHostName = NULL, *routeFound = NULL, *parts = NULL, *params, *matches, *notFoundPaths, *vnamespace, *module, *controller, *action, *paramsStr, *strParams, *paramsMerge = NULL, *route = NULL, *methods = NULL, *dependencyInjector = NULL, *hostname = NULL, *regexHostName = NULL, *matched = NULL, *pattern = NULL, *handledUri = NULL, *beforeMatch = NULL, *paths = NULL, *converters = NULL, *part = NULL, *position = NULL, *matchPosition = NULL, *_0, *_1, **_4, *_5, *_6 = NULL, *_7 = NULL, *_10 = NULL, *_13 = NULL, **_17, *_18, *_19, *_20, *_21, *_22; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &uri); if (!uri) { uri = ZEPHIR_GLOBAL(global_null); } if (!(zephir_is_true(uri))) { ZEPHIR_INIT_VAR(realUri); zephir_call_method(realUri, this_ptr, "getrewriteuri"); } else { ZEPHIR_CPY_WRT(realUri, uri); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_removeExtraSlashes"), PH_NOISY_CC); if (zephir_is_true(_0)) { ZEPHIR_INIT_VAR(handledUri); zephir_call_method_p1(handledUri, this_ptr, "doremoveextraslashes", realUri); } else { ZEPHIR_CPY_WRT(handledUri, realUri); } ZEPHIR_INIT_VAR(request); ZVAL_NULL(request); ZEPHIR_INIT_VAR(currentHostName); ZVAL_NULL(currentHostName); ZEPHIR_INIT_VAR(routeFound); ZVAL_BOOL(routeFound, 0); ZEPHIR_INIT_VAR(parts); array_init(parts); ZEPHIR_INIT_VAR(params); array_init(params); ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); zephir_update_property_this(this_ptr, SL("_wasMatched"), (0) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_matchedRoute"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_routes"), PH_NOISY_CC); zephir_is_iterable(_1, &_3, &_2, 0, 1); for ( ; zend_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zend_hash_move_backwards_ex(_3, &_2) ) { ZEPHIR_GET_HVALUE(route, _4); ZEPHIR_INIT_NVAR(methods); zephir_call_method(methods, route, "gethttpmethods"); if ((Z_TYPE_P(methods) != IS_NULL)) { if ((Z_TYPE_P(request) == IS_NULL)) { _5 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _5); if ((Z_TYPE_P(dependencyInjector) != IS_OBJECT)) { ZEPHIR_INIT_LNVAR(_6); object_init_ex(_6, test_router_exception_ce); ZEPHIR_INIT_NVAR(_7); ZVAL_STRING(_7, "A dependency injection container is required to access the 'request' service", 1); zephir_call_method_p1_cache_noret(_6, "__construct", &_8, _7); zephir_throw_exception(_6 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_NVAR(_7); ZVAL_STRING(_7, "request", 1); ZEPHIR_INIT_NVAR(request); zephir_call_method_p1_cache(request, dependencyInjector, "getshared", &_9, _7); } ZEPHIR_INIT_NVAR(_7); zephir_call_method_p1(_7, request, "ismethod", methods); if (ZEPHIR_IS_FALSE(_7)) { continue; } } ZEPHIR_INIT_NVAR(hostname); zephir_call_method(hostname, route, "gethostname"); if ((Z_TYPE_P(hostname) != IS_NULL)) { if ((Z_TYPE_P(request) == IS_NULL)) { ZEPHIR_OBS_NVAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if ((Z_TYPE_P(dependencyInjector) != IS_OBJECT)) { ZEPHIR_INIT_LNVAR(_6); object_init_ex(_6, test_router_exception_ce); ZEPHIR_INIT_NVAR(_10); ZVAL_STRING(_10, "A dependency injection container is required to access the 'request' service", 1); zephir_call_method_p1_cache_noret(_6, "__construct", &_11, _10); zephir_throw_exception(_6 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_NVAR(_7); ZVAL_STRING(_7, "request", 1); ZEPHIR_INIT_NVAR(request); zephir_call_method_p1_cache(request, dependencyInjector, "getshared", &_12, _7); } if ((Z_TYPE_P(currentHostName) != IS_OBJECT)) { ZEPHIR_INIT_NVAR(currentHostName); zephir_call_method(currentHostName, request, "gethttphost"); } if ((Z_TYPE_P(currentHostName) != IS_NULL)) { continue; } ZEPHIR_INIT_NVAR(matched); if (zephir_memnstr_str(hostname, SL("("), "test/router.zep", 381)) { if (zephir_memnstr_str(hostname, SL("#"), "test/router.zep", 382)) { ZEPHIR_INIT_NVAR(regexHostName); ZEPHIR_CONCAT_SVS(regexHostName, "#^", hostname, "$#"); } else { ZEPHIR_CPY_WRT(regexHostName, hostname); } ZEPHIR_INIT_NVAR(_13); zephir_preg_match(matched, &(matched), regexHostName, currentHostName, _13, 0, 0 , 0 TSRMLS_CC); } else { ZVAL_BOOL(matched, ZEPHIR_IS_EQUAL(currentHostName, hostname)); } if (!(zephir_is_true(matched))) { continue; } } ZEPHIR_INIT_NVAR(pattern); zephir_call_method(pattern, route, "getcompiledpattern"); ZEPHIR_INIT_NVAR(routeFound); if (zephir_memnstr_str(pattern, SL("^"), "test/router.zep", 400)) { zephir_preg_match(routeFound, &(routeFound), pattern, handledUri, matches, 0, 0 , 0 TSRMLS_CC); } else { ZVAL_BOOL(routeFound, ZEPHIR_IS_EQUAL(pattern, handledUri)); } if (zephir_is_true(routeFound)) { ZEPHIR_INIT_NVAR(beforeMatch); zephir_call_method(beforeMatch, route, "getbeforematch"); if ((Z_TYPE_P(beforeMatch) != IS_NULL)) { if (zephir_is_callable(beforeMatch TSRMLS_CC)) { ZEPHIR_INIT_LNVAR(_6); object_init_ex(_6, test_router_exception_ce); ZEPHIR_INIT_NVAR(_7); ZVAL_STRING(_7, "Before-Match callback is not callable in matched route", 1); zephir_call_method_p1_cache_noret(_6, "__construct", &_14, _7); zephir_throw_exception(_6 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } } if (zephir_is_true(routeFound)) { ZEPHIR_INIT_NVAR(paths); zephir_call_method(paths, route, "getpaths"); ZEPHIR_CPY_WRT(parts, paths); if ((Z_TYPE_P(matches) == IS_ARRAY)) { ZEPHIR_INIT_NVAR(converters); zephir_call_method(converters, route, "getconverters"); zephir_is_iterable(paths, &_16, &_15, 0, 0); for ( ; zend_hash_get_current_data_ex(_16, (void**) &_17, &_15) == SUCCESS ; zephir_hash_move_forward_ex(_16, &_15) ) { ZEPHIR_GET_HMKEY(part, _16, _15); ZEPHIR_GET_HVALUE(position, _17); ZEPHIR_OBS_NVAR(matchPosition); if (zephir_array_isset_fetch(&matchPosition, matches, position, 0 TSRMLS_CC)) { if ((Z_TYPE_P(converters) == IS_ARRAY)) { if (zephir_array_isset(converters, part)) { continue; } } zephir_array_update_zval(&parts, part, &matchPosition, PH_COPY | PH_SEPARATE); } else { if ((Z_TYPE_P(converters) == IS_ARRAY)) { if (zephir_array_isset(converters, part)) { } } } } zephir_update_property_this(this_ptr, SL("_matches"), matches TSRMLS_CC); } zephir_update_property_this(this_ptr, SL("_matchedRoute"), route TSRMLS_CC); break; } } if (zephir_is_true(routeFound)) { zephir_update_property_this(this_ptr, SL("_wasMatched"), (1) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_wasMatched"), (0) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } if (!(zephir_is_true(routeFound))) { ZEPHIR_OBS_VAR(notFoundPaths); zephir_read_property_this(¬FoundPaths, this_ptr, SL("_notFoundPaths"), PH_NOISY_CC); if ((Z_TYPE_P(notFoundPaths) != IS_NULL)) { ZEPHIR_CPY_WRT(parts, notFoundPaths); ZEPHIR_INIT_BNVAR(routeFound); ZVAL_BOOL(routeFound, 1); } } if (zephir_is_true(routeFound)) { ZEPHIR_OBS_VAR(vnamespace); if (zephir_array_isset_string_fetch(&vnamespace, parts, SS("namespace"), 0 TSRMLS_CC)) { if (!(zephir_is_numeric(vnamespace))) { zephir_update_property_this(this_ptr, SL("_namespace"), vnamespace TSRMLS_CC); } zephir_array_fetch_string(&_18, parts, SL("namespace"), PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_unset(&parts, _18, PH_SEPARATE); } else { _5 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultNamespace"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_namespace"), _5 TSRMLS_CC); } ZEPHIR_OBS_VAR(module); if (zephir_array_isset_string_fetch(&module, parts, SS("module"), 0 TSRMLS_CC)) { if (!(zephir_is_numeric(module))) { zephir_update_property_this(this_ptr, SL("_module"), module TSRMLS_CC); } zephir_array_fetch_string(&_18, parts, SL("module"), PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_unset(&parts, _18, PH_SEPARATE); } else { _5 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultModule"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_module"), _5 TSRMLS_CC); } ZEPHIR_OBS_VAR(controller); if (zephir_array_isset_string_fetch(&controller, parts, SS("controller"), 0 TSRMLS_CC)) { if (!(zephir_is_numeric(controller))) { zephir_update_property_this(this_ptr, SL("_controller"), controller TSRMLS_CC); } zephir_array_fetch_string(&_18, parts, SL("controller"), PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_unset(&parts, _18, PH_SEPARATE); } else { _5 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultController"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_controller"), _5 TSRMLS_CC); } ZEPHIR_OBS_VAR(action); if (zephir_array_isset_string_fetch(&action, parts, SS("action"), 0 TSRMLS_CC)) { if (!(zephir_is_numeric(action))) { zephir_update_property_this(this_ptr, SL("_action"), action TSRMLS_CC); } zephir_array_fetch_string(&_18, parts, SL("action"), PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_unset(&parts, _18, PH_SEPARATE); } else { _5 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultAction"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_action"), _5 TSRMLS_CC); } ZEPHIR_OBS_VAR(paramsStr); if (zephir_array_isset_string_fetch(¶msStr, parts, SS("params"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(strParams); zephir_substr(strParams, paramsStr, 1 , 0 ); if (zephir_is_true(strParams)) { ZEPHIR_INIT_BNVAR(params); zephir_fast_explode_str(params, SL("/"), strParams, LONG_MAX TSRMLS_CC); } zephir_array_fetch_string(&_18, parts, SL("params"), PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_unset(&parts, _18, PH_SEPARATE); } if (zephir_fast_count_int(params TSRMLS_CC)) { ZEPHIR_INIT_VAR(paramsMerge); zephir_fast_array_merge(paramsMerge, &(params), &(parts) TSRMLS_CC); } else { ZEPHIR_CPY_WRT(paramsMerge, parts); } zephir_update_property_this(this_ptr, SL("_params"), paramsMerge TSRMLS_CC); } else { _5 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultNamespace"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_namespace"), _5 TSRMLS_CC); _19 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultModule"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_module"), _19 TSRMLS_CC); _20 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultController"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_controller"), _20 TSRMLS_CC); _21 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultAction"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_action"), _21 TSRMLS_CC); _22 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultParams"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_params"), _22 TSRMLS_CC); } ZEPHIR_MM_RESTORE(); }
/** * Magic loader to load instantiated class. * * @param string $file Class namespace. * @return void */ PHP_METHOD(Panada_Gear, loader) { zephir_nts_static zephir_fcall_cache_entry *_16 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *file = NULL, *folder = NULL, *prefix, *_0, *_1, *_2, *_3, *_4 = NULL, *_5 = NULL, *_6, *_7, *_8, *_9, *_10, *_11, *_12, _13, _14, *_15 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &file); ZEPHIR_SEPARATE_PARAM(file); ZEPHIR_INIT_VAR(prefix); zephir_fast_explode_str(prefix, SL("\\"), file, LONG_MAX TSRMLS_CC); zephir_array_fetch_long(&_0, prefix, 0, PH_NOISY | PH_READONLY TSRMLS_CC); do { if (ZEPHIR_IS_STRING(_0, "Models")) { ZEPHIR_INIT_VAR(folder); ZEPHIR_GET_CONSTANT(folder, "APP"); break; } if (ZEPHIR_IS_STRING(_0, "Libraries")) { ZEPHIR_INIT_NVAR(folder); ZEPHIR_GET_CONSTANT(folder, "APP"); break; } if (ZEPHIR_IS_STRING(_0, "Controllers")) { ZEPHIR_INIT_NVAR(folder); ZEPHIR_GET_CONSTANT(folder, "APP"); break; } if (ZEPHIR_IS_STRING(_0, "Resources")) { ZEPHIR_INIT_NVAR(folder); ZEPHIR_GET_CONSTANT(folder, "GEAR"); break; } if (ZEPHIR_IS_STRING(_0, "Drivers")) { ZEPHIR_INIT_NVAR(folder); ZEPHIR_GET_CONSTANT(folder, "GEAR"); break; } if (ZEPHIR_IS_STRING(_0, "Modules")) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("config"), PH_NOISY_CC); zephir_array_fetch_string(&_2, _1, SL("main"), PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_string(&_3, _2, SL("module"), PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_OBS_NVAR(folder); zephir_array_fetch_string(&folder, _3, SL("path"), PH_NOISY TSRMLS_CC); break; } _1 = zephir_fetch_nproperty_this(this_ptr, SL("config"), PH_NOISY_CC); zephir_array_fetch_string(&_2, _1, SL("main"), PH_NOISY | PH_READONLY TSRMLS_CC); if (!(zephir_array_isset_string(_2, SS("namespace")))) { ZEPHIR_INIT_VAR(_4); object_init_ex(_4, panada_resources_runexception_ce); ZEPHIR_INIT_VAR(_5); ZEPHIR_CONCAT_SVS(_5, "Resource ", file, " not available!"); ZEPHIR_CALL_METHOD(NULL, _4, "__construct", NULL, _5); zephir_check_call_status(); zephir_throw_exception(_4 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } _6 = zephir_fetch_nproperty_this(this_ptr, SL("config"), PH_NOISY_CC); zephir_array_fetch_string(&_3, _6, SL("main"), PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_string(&_7, _3, SL("namespace"), PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_long(&_8, prefix, 0, PH_NOISY | PH_READONLY TSRMLS_CC); if (!(zephir_array_isset(_7, _8))) { ZEPHIR_INIT_LNVAR(_4); object_init_ex(_4, panada_resources_runexception_ce); ZEPHIR_INIT_LNVAR(_5); ZEPHIR_CONCAT_SVS(_5, "Resource ", file, " not available!"); ZEPHIR_CALL_METHOD(NULL, _4, "__construct", NULL, _5); zephir_check_call_status(); zephir_throw_exception(_4 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } _9 = zephir_fetch_nproperty_this(this_ptr, SL("config"), PH_NOISY_CC); zephir_array_fetch_string(&_10, _9, SL("main"), PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_fetch_string(&_11, _10, SL("namespace"), PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_OBS_NVAR(folder); ZEPHIR_OBS_VAR(_12); zephir_array_fetch_long(&_12, prefix, 0, PH_NOISY TSRMLS_CC); zephir_array_fetch(&folder, _11, _12, PH_NOISY TSRMLS_CC); break; } while(0); ZEPHIR_SINIT_VAR(_13); ZVAL_STRING(&_13, "\\", 0); ZEPHIR_SINIT_VAR(_14); ZVAL_STRING(&_14, "/", 0); ZEPHIR_CALL_FUNCTION(&_15, "str_ireplace", &_16, &_13, &_14, file); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_VVS(_4, folder, _15, ".php"); ZEPHIR_CPY_WRT(file, _4); if (!((zephir_file_exists(file TSRMLS_CC) == SUCCESS))) { ZEPHIR_INIT_LNVAR(_4); object_init_ex(_4, panada_resources_runexception_ce); ZEPHIR_INIT_LNVAR(_5); ZEPHIR_CONCAT_SVS(_5, "Resource ", file, " not available!"); ZEPHIR_CALL_METHOD(NULL, _4, "__construct", NULL, _5); zephir_check_call_status(); zephir_throw_exception(_4 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (zephir_require_zval(file TSRMLS_CC) == FAILURE) { RETURN_MM_NULL(); } ZEPHIR_MM_RESTORE(); }
/** * Get the server variable REMOTE_ADDR, or the first ip of HTTP_X_FORWARDED_FOR (when using proxy) * * @return string $remote_addr ip of client */ PHP_METHOD(Phady_Util_Tools, getRemoteAddr) { zend_bool _0, _2, _3, _9, _15, _21; zval *ips, *remoteAddr = NULL, *_SERVER, *_1, *_4, *_5, *_6, *_7, _8, *_10, *_11, *_12, *_13, _14, *_16, *_17, *_18, *_19, _20, *_22, *_23, *_24, *_25, _26, *_27, _28, *_29, *_30; ZEPHIR_MM_GROW(); zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); _0 = zephir_array_isset_string(_SERVER, SS("HTTP_X_FORWARDED_FOR")); if (_0) { zephir_array_fetch_string(&_1, _SERVER, SL("HTTP_X_FORWARDED_FOR"), PH_NOISY | PH_READONLY, "phady/util/tools.zep", 86 TSRMLS_CC); _0 = zephir_is_true(_1); } _2 = _0; if (_2) { _3 = !(zephir_array_isset_string(_SERVER, SS("REMOTE_ADDR"))); if (!(_3)) { ZEPHIR_INIT_VAR(_4); ZEPHIR_INIT_VAR(_5); ZEPHIR_INIT_VAR(_6); zephir_array_fetch_string(&_7, _SERVER, SL("REMOTE_ADDR"), PH_NOISY | PH_READONLY, "phady/util/tools.zep", 87 TSRMLS_CC); zephir_fast_trim(_6, _7, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); ZEPHIR_SINIT_VAR(_8); ZVAL_STRING(&_8, "/^127\\..*/i", 0); zephir_preg_match(_5, &_8, _6, _4, 0, 0 , 0 TSRMLS_CC); _3 = zephir_is_true(_5); } _9 = _3; if (!(_9)) { ZEPHIR_INIT_VAR(_10); ZEPHIR_INIT_VAR(_11); ZEPHIR_INIT_VAR(_12); zephir_array_fetch_string(&_13, _SERVER, SL("REMOTE_ADDR"), PH_NOISY | PH_READONLY, "phady/util/tools.zep", 87 TSRMLS_CC); zephir_fast_trim(_12, _13, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); ZEPHIR_SINIT_VAR(_14); ZVAL_STRING(&_14, "/^172\\.16.*/i", 0); zephir_preg_match(_11, &_14, _12, _10, 0, 0 , 0 TSRMLS_CC); _9 = zephir_is_true(_11); } _15 = _9; if (!(_15)) { ZEPHIR_INIT_VAR(_16); ZEPHIR_INIT_VAR(_17); ZEPHIR_INIT_VAR(_18); zephir_array_fetch_string(&_19, _SERVER, SL("REMOTE_ADDR"), PH_NOISY | PH_READONLY, "phady/util/tools.zep", 88 TSRMLS_CC); zephir_fast_trim(_18, _19, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); ZEPHIR_SINIT_VAR(_20); ZVAL_STRING(&_20, "/^192\\.168\\.*/i", 0); zephir_preg_match(_17, &_20, _18, _16, 0, 0 , 0 TSRMLS_CC); _15 = zephir_is_true(_17); } _21 = _15; if (!(_21)) { ZEPHIR_INIT_VAR(_22); ZEPHIR_INIT_VAR(_23); ZEPHIR_INIT_VAR(_24); zephir_array_fetch_string(&_25, _SERVER, SL("REMOTE_ADDR"), PH_NOISY | PH_READONLY, "phady/util/tools.zep", 88 TSRMLS_CC); zephir_fast_trim(_24, _25, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); ZEPHIR_SINIT_VAR(_26); ZVAL_STRING(&_26, "/^10\\..*/i", 0); zephir_preg_match(_23, &_26, _24, _22, 0, 0 , 0 TSRMLS_CC); _21 = zephir_is_true(_23); } _2 = _21; } if (_2) { zephir_array_fetch_string(&_27, _SERVER, SL("HTTP_X_FORWARDED_FOR"), PH_NOISY | PH_READONLY, "phady/util/tools.zep", 90 TSRMLS_CC); ZEPHIR_SINIT_VAR(_28); ZVAL_STRING(&_28, ",", 0); ZEPHIR_INIT_VAR(_29); zephir_fast_strpos(_29, _27, &_28, 0 ); if (zephir_is_true(_29)) { zephir_array_fetch_string(&_30, _SERVER, SL("HTTP_X_FORWARDED_FOR"), PH_NOISY | PH_READONLY, "phady/util/tools.zep", 92 TSRMLS_CC); ZEPHIR_INIT_VAR(ips); zephir_fast_explode_str(ips, SL(","), _30, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(remoteAddr); zephir_array_fetch_long(&remoteAddr, ips, 0, PH_NOISY, "phady/util/tools.zep", 93 TSRMLS_CC); } else { ZEPHIR_OBS_NVAR(remoteAddr); zephir_array_fetch_string(&remoteAddr, _SERVER, SL("HTTP_X_FORWARDED_FOR"), PH_NOISY, "phady/util/tools.zep", 96 TSRMLS_CC); } } else { ZEPHIR_OBS_NVAR(remoteAddr); zephir_array_fetch_string(&remoteAddr, _SERVER, SL("REMOTE_ADDR"), PH_NOISY, "phady/util/tools.zep", 99 TSRMLS_CC); } RETURN_CCTOR(remoteAddr); }
/** * Fires an event in the events manager causing the active listeners to be notified about it * *<code> * $eventsManager->fire('db', $connection); *</code> * * @param string eventType * @param object source * @param mixed data * @param boolean cancelable * @return mixed */ PHP_METHOD(Phalcon_Events_Manager, fire) { zephir_fcall_cache_entry *_5 = NULL, *_6 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_bool cancelable, _3$$6, _7$$8; zval *eventType_param = NULL, *source, *data = NULL, *cancelable_param = NULL, *events = NULL, *eventParts = NULL, *type = NULL, *eventName = NULL, *event = NULL, *status = NULL, *fireEvents = NULL, *_2, *_0$$4, *_4$$7, *_8$$10; zval *eventType = NULL, *_1$$4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 2, &eventType_param, &source, &data, &cancelable_param); if (unlikely(Z_TYPE_P(eventType_param) != IS_STRING && Z_TYPE_P(eventType_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventType' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(eventType_param) == IS_STRING)) { zephir_get_strval(eventType, eventType_param); } else { ZEPHIR_INIT_VAR(eventType); ZVAL_EMPTY_STRING(eventType); } if (!data) { data = ZEPHIR_GLOBAL(global_null); } if (!cancelable_param) { cancelable = 1; } else { cancelable = zephir_get_boolval(cancelable_param); } ZEPHIR_OBS_VAR(events); zephir_read_property_this(&events, this_ptr, SL("_events"), PH_NOISY_CC); if (Z_TYPE_P(events) != IS_ARRAY) { RETURN_MM_NULL(); } if (!(zephir_memnstr_str(eventType, SL(":"), "phalcon/events/manager.zep", 381))) { ZEPHIR_INIT_VAR(_0$$4); object_init_ex(_0$$4, phalcon_events_exception_ce); ZEPHIR_INIT_VAR(_1$$4); ZEPHIR_CONCAT_SV(_1$$4, "Invalid event type ", eventType); ZEPHIR_CALL_METHOD(NULL, _0$$4, "__construct", NULL, 9, _1$$4); zephir_check_call_status(); zephir_throw_exception_debug(_0$$4, "phalcon/events/manager.zep", 382 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(eventParts); zephir_fast_explode_str(eventParts, SL(":"), eventType, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(type); zephir_array_fetch_long(&type, eventParts, 0, PH_NOISY, "phalcon/events/manager.zep", 386 TSRMLS_CC); ZEPHIR_OBS_VAR(eventName); zephir_array_fetch_long(&eventName, eventParts, 1, PH_NOISY, "phalcon/events/manager.zep", 387 TSRMLS_CC); ZEPHIR_INIT_VAR(status); ZVAL_NULL(status); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_collect"), PH_NOISY_CC); if (zephir_is_true(_2)) { zephir_update_property_this(this_ptr, SL("_responses"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); } ZEPHIR_INIT_VAR(event); ZVAL_NULL(event); ZEPHIR_OBS_VAR(fireEvents); if (zephir_array_isset_fetch(&fireEvents, events, type, 0 TSRMLS_CC)) { _3$$6 = Z_TYPE_P(fireEvents) == IS_OBJECT; if (!(_3$$6)) { _3$$6 = Z_TYPE_P(fireEvents) == IS_ARRAY; } if (_3$$6) { ZEPHIR_INIT_NVAR(event); object_init_ex(event, phalcon_events_event_ce); ZEPHIR_INIT_VAR(_4$$7); if (cancelable) { ZVAL_BOOL(_4$$7, 1); } else { ZVAL_BOOL(_4$$7, 0); } ZEPHIR_CALL_METHOD(NULL, event, "__construct", &_5, 194, eventName, source, data, _4$$7); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&status, this_ptr, "firequeue", &_6, 195, fireEvents, event); zephir_check_call_status(); } } ZEPHIR_OBS_NVAR(fireEvents); if (zephir_array_isset_fetch(&fireEvents, events, eventType, 0 TSRMLS_CC)) { _7$$8 = Z_TYPE_P(fireEvents) == IS_OBJECT; if (!(_7$$8)) { _7$$8 = Z_TYPE_P(fireEvents) == IS_ARRAY; } if (_7$$8) { if (Z_TYPE_P(event) == IS_NULL) { ZEPHIR_INIT_NVAR(event); object_init_ex(event, phalcon_events_event_ce); ZEPHIR_INIT_VAR(_8$$10); if (cancelable) { ZVAL_BOOL(_8$$10, 1); } else { ZVAL_BOOL(_8$$10, 0); } ZEPHIR_CALL_METHOD(NULL, event, "__construct", &_5, 194, eventName, source, data, _8$$10); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&status, this_ptr, "firequeue", &_6, 195, fireEvents, event); zephir_check_call_status(); } } RETURN_CCTOR(status); }