/** * 判断字母是否在某个区域内。用于判断某个字符只能介于[a-h](包含)之间的类似情况。 * @param string alpha 原值。 * @param string start_alpha 起始值。 * @param string end_alpha 截止值。 * @return boolean */ PHP_METHOD(Winer_Validator, alpha_between) { int ZEPHIR_LAST_CALL_STATUS; zval *alpha_param = NULL, *start_alpha_param = NULL, *end_alpha_param = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL; zval *alpha = NULL, *start_alpha = NULL, *end_alpha = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &alpha_param, &start_alpha_param, &end_alpha_param); zephir_get_strval(alpha, alpha_param); zephir_get_strval(start_alpha, start_alpha_param); zephir_get_strval(end_alpha, end_alpha_param); ZEPHIR_CALL_SELF(&_0, "is_alpha", NULL, alpha); zephir_check_call_status(); if (ZEPHIR_IS_FALSE(_0)) { RETURN_MM_BOOL(0); } ZEPHIR_CALL_SELF(&_1, "is_alpha", NULL, start_alpha); zephir_check_call_status(); if (ZEPHIR_IS_FALSE(_1)) { RETURN_MM_BOOL(0); } ZEPHIR_CALL_SELF(&_2, "is_alpha", NULL, end_alpha); zephir_check_call_status(); if (ZEPHIR_IS_FALSE(_2)) { RETURN_MM_BOOL(0); } if (ZEPHIR_GE(start_alpha, end_alpha)) { RETURN_MM_BOOL(0); } if (ZEPHIR_LT(alpha, start_alpha)) { RETURN_MM_BOOL(0); } if (ZEPHIR_GT(alpha, end_alpha)) { RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); }
/** * Executes the validator */ PHP_METHOD(Phalcon_Mvc_Model_Validator_StringLength, validate) { zval *_6$$9, *_11$$12; zend_bool _1, _3; zephir_fcall_cache_entry *_8 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *record, *field = NULL, *isSetMin = NULL, *isSetMax = NULL, *value = NULL, *length = NULL, *maximum = NULL, *minimum = NULL, *message = NULL, *_0 = NULL, *_2 = NULL, *_4$$8, *_5$$9 = NULL, *_7$$9 = NULL, *_9$$11, *_10$$12 = NULL, *_12$$12 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &record); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "field", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&field, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(field) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Field name must be a string", "phalcon/mvc/model/validator/stringlength.zep", 67); return; } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "min", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&isSetMin, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "max", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&isSetMax, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _1 = !zephir_is_true(isSetMin); if (_1) { _1 = !zephir_is_true(isSetMax); } if (_1) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A minimum or maximum must be set", "phalcon/mvc/model/validator/stringlength.zep", 77); return; } ZEPHIR_CALL_METHOD(&value, record, "readattribute", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _3 = zephir_is_true(_2); if (_3) { _3 = ZEPHIR_IS_EMPTY(value); } if (_3) { RETURN_MM_BOOL(1); } if ((zephir_function_exists_ex(SS("mb_strlen") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, 357, value); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(length); ZVAL_LONG(length, zephir_fast_strlen_ev(value)); } if (zephir_is_true(isSetMax)) { ZEPHIR_INIT_VAR(_4$$8); ZVAL_STRING(_4$$8, "max", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&maximum, this_ptr, "getoption", NULL, 0, _4$$8); zephir_check_temp_parameter(_4$$8); zephir_check_call_status(); if (ZEPHIR_GT(length, maximum)) { ZEPHIR_INIT_VAR(_5$$9); ZVAL_STRING(_5$$9, "messageMaximum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _5$$9); zephir_check_temp_parameter(_5$$9); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(message); ZVAL_STRING(message, "Value of field ':field' exceeds the maximum :max characters", 1); } ZEPHIR_INIT_VAR(_6$$9); zephir_create_array(_6$$9, 2, 0 TSRMLS_CC); zephir_array_update_string(&_6$$9, SL(":field"), &field, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_6$$9, SL(":max"), &maximum, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_FUNCTION(&_7$$9, "strtr", &_8, 55, message, _6$$9); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_5$$9); ZVAL_STRING(_5$$9, "TooLong", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", NULL, 0, _7$$9, field, _5$$9); zephir_check_temp_parameter(_5$$9); zephir_check_call_status(); RETURN_MM_BOOL(0); } } if (zephir_is_true(isSetMin)) { ZEPHIR_INIT_VAR(_9$$11); ZVAL_STRING(_9$$11, "min", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&minimum, this_ptr, "getoption", NULL, 0, _9$$11); zephir_check_temp_parameter(_9$$11); zephir_check_call_status(); if (ZEPHIR_LT(length, minimum)) { ZEPHIR_INIT_VAR(_10$$12); ZVAL_STRING(_10$$12, "messageMinimum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _10$$12); zephir_check_temp_parameter(_10$$12); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(message); ZVAL_STRING(message, "Value of field ':field' is less than the minimum :min characters", 1); } ZEPHIR_INIT_VAR(_11$$12); zephir_create_array(_11$$12, 2, 0 TSRMLS_CC); zephir_array_update_string(&_11$$12, SL(":field"), &field, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_11$$12, SL(":min"), &minimum, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_FUNCTION(&_12$$12, "strtr", &_8, 55, message, _11$$12); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_10$$12); ZVAL_STRING(_10$$12, "TooShort", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", NULL, 0, _12$$12, field, _10$$12); zephir_check_temp_parameter(_10$$12); zephir_check_call_status(); RETURN_MM_BOOL(0); } } RETURN_MM_BOOL(1); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_StringLength, validate) { zend_bool _1, _3; zephir_fcall_cache_entry *_8 = NULL, *_10 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *isSetMin = NULL, *isSetMax = NULL, *value = NULL, *length = NULL, *message = NULL, *minimum = NULL, *maximum = NULL, *label = NULL, *replacePairs = NULL, *_0 = NULL, *_2 = NULL, *_4$$8, *_5$$9 = NULL, *_7$$9 = NULL, *_9$$9, *_6$$10, *_11$$11, *_12$$12 = NULL, *_14$$12 = NULL, *_15$$12, *_13$$13; ZEPHIR_MM_GROW(); 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_INIT_VAR(_0); ZVAL_STRING(_0, "min", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&isSetMin, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "max", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&isSetMax, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _1 = !zephir_is_true(isSetMin); if (_1) { _1 = !zephir_is_true(isSetMax); } if (_1) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "A minimum or maximum must be set", "phalcon/validation/validator/stringlength.zep", 62); return; } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _3 = zephir_is_true(_2); if (_3) { _3 = ZEPHIR_IS_EMPTY(value); } if (_3) { RETURN_MM_BOOL(1); } ZEPHIR_INIT_NVAR(_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(); } if ((zephir_function_exists_ex(SS("mb_strlen") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, 359, value); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(length); ZVAL_LONG(length, zephir_fast_strlen_ev(value)); } if (zephir_is_true(isSetMax)) { ZEPHIR_INIT_VAR(_4$$8); ZVAL_STRING(_4$$8, "max", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&maximum, this_ptr, "getoption", NULL, 0, _4$$8); zephir_check_temp_parameter(_4$$8); zephir_check_call_status(); if (ZEPHIR_GT(length, maximum)) { ZEPHIR_INIT_VAR(_5$$9); ZVAL_STRING(_5$$9, "messageMaximum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _5$$9); zephir_check_temp_parameter(_5$$9); 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_array_update_string(&replacePairs, SL(":max"), &maximum, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_6$$10); ZVAL_STRING(_6$$10, "TooLong", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _6$$10); zephir_check_temp_parameter(_6$$10); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_5$$9); object_init_ex(_5$$9, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_7$$9, "strtr", &_8, 55, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_9$$9); ZVAL_STRING(_9$$9, "TooLong", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _5$$9, "__construct", &_10, 438, _7$$9, field, _9$$9); zephir_check_temp_parameter(_9$$9); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _5$$9); zephir_check_call_status(); RETURN_MM_BOOL(0); } } if (zephir_is_true(isSetMin)) { ZEPHIR_INIT_VAR(_11$$11); ZVAL_STRING(_11$$11, "min", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&minimum, this_ptr, "getoption", NULL, 0, _11$$11); zephir_check_temp_parameter(_11$$11); zephir_check_call_status(); if (ZEPHIR_LT(length, minimum)) { ZEPHIR_INIT_VAR(_12$$12); ZVAL_STRING(_12$$12, "messageMinimum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _12$$12); zephir_check_temp_parameter(_12$$12); 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"), &minimum, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_13$$13); ZVAL_STRING(_13$$13, "TooShort", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _13$$13); zephir_check_temp_parameter(_13$$13); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_12$$12); object_init_ex(_12$$12, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_14$$12, "strtr", &_8, 55, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_15$$12); ZVAL_STRING(_15$$12, "TooShort", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _12$$12, "__construct", &_10, 438, _14$$12, field, _15$$12); zephir_check_temp_parameter(_15$$12); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _12$$12); zephir_check_call_status(); RETURN_MM_BOOL(0); } } RETURN_MM_BOOL(1); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_Between, validate) { zend_bool _3; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *value = NULL, *minimum = NULL, *maximum = NULL, *message = NULL, *label = NULL, *replacePairs = NULL, *code = NULL, *_0 = NULL, *_1$$3, *_2$$4, *_4$$5 = NULL, *_9$$5 = NULL, *_10$$5, *_5$$6, *_6$$8, *_7$$9, *_8$$10; ZEPHIR_MM_GROW(); 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, "minimum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&minimum, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "maximum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&maximum, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(minimum) == IS_ARRAY) { zephir_array_fetch(&_1$$3, minimum, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/between.zep", 72 TSRMLS_CC); ZEPHIR_CPY_WRT(minimum, _1$$3); } if (Z_TYPE_P(maximum) == IS_ARRAY) { zephir_array_fetch(&_2$$4, maximum, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/between.zep", 76 TSRMLS_CC); ZEPHIR_CPY_WRT(maximum, _2$$4); } _3 = ZEPHIR_LT(value, minimum); if (!(_3)) { _3 = ZEPHIR_GT(value, maximum); } if (_3) { ZEPHIR_INIT_VAR(_4$$5); ZVAL_STRING(_4$$5, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _4$$5); zephir_check_temp_parameter(_4$$5); zephir_check_call_status(); if (Z_TYPE_P(label) == IS_ARRAY) { zephir_array_fetch(&_5$$6, label, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/between.zep", 83 TSRMLS_CC); ZEPHIR_CPY_WRT(label, _5$$6); } if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_4$$5); ZVAL_STRING(_4$$5, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _4$$5); zephir_check_temp_parameter(_4$$5); zephir_check_call_status(); if (Z_TYPE_P(message) == IS_ARRAY) { zephir_array_fetch(&_6$$8, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/between.zep", 91 TSRMLS_CC); ZEPHIR_CPY_WRT(message, _6$$8); } ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 3, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":min"), &minimum, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":max"), &maximum, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_7$$9); ZVAL_STRING(_7$$9, "Between", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _7$$9); zephir_check_temp_parameter(_7$$9); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_4$$5); ZVAL_STRING(_4$$5, "code", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&code, this_ptr, "getoption", NULL, 0, _4$$5); zephir_check_temp_parameter(_4$$5); zephir_check_call_status(); if (Z_TYPE_P(code) == IS_ARRAY) { zephir_array_fetch(&_8$$10, code, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/between.zep", 100 TSRMLS_CC); ZEPHIR_CPY_WRT(code, _8$$10); } ZEPHIR_INIT_NVAR(_4$$5); object_init_ex(_4$$5, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_9$$5, "strtr", NULL, 26, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_10$$5); ZVAL_STRING(_10$$5, "Between", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _4$$5, "__construct", NULL, 462, _9$$5, field, _10$$5, code); zephir_check_temp_parameter(_10$$5); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _4$$5); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); }
/** * 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); }
/** * Decrypts an encrypted text * *<code> * echo $crypt->decrypt($encrypted, "decrypt password"); *</code> */ PHP_METHOD(Phalcon_Crypt, decrypt) { zephir_nts_static zephir_fcall_cache_entry *_4 = NULL; zend_bool _3; int ZEPHIR_LAST_CALL_STATUS; zval *text_param = NULL, *key = NULL, *decryptKey = NULL, *ivSize = NULL, *cipher, *mode, *keySize, *length, *blockSize = NULL, *paddingType, *decrypted = NULL, *_0, _1, *_2; zval *text = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &text_param, &key); if (unlikely(Z_TYPE_P(text_param) != IS_STRING && Z_TYPE_P(text_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'text' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(text_param) == IS_STRING)) { zephir_get_strval(text, text_param); } else { ZEPHIR_INIT_VAR(text); ZVAL_EMPTY_STRING(text); } if (!key) { key = ZEPHIR_GLOBAL(global_null); } if (!((zephir_function_exists_ex(SS("mcrypt_get_iv_size") TSRMLS_CC) == SUCCESS))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_crypt_exception_ce, "mcrypt extension is required", "phalcon/crypt.zep", 360); return; } if (Z_TYPE_P(key) == IS_NULL) { ZEPHIR_OBS_VAR(decryptKey); zephir_read_property_this(&decryptKey, this_ptr, SL("_key"), PH_NOISY_CC); } else { ZEPHIR_CPY_WRT(decryptKey, key); } if (ZEPHIR_IS_EMPTY(decryptKey)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_crypt_exception_ce, "Decryption key cannot be empty", "phalcon/crypt.zep", 370); return; } ZEPHIR_OBS_VAR(cipher); zephir_read_property_this(&cipher, this_ptr, SL("_cipher"), PH_NOISY_CC); ZEPHIR_OBS_VAR(mode); zephir_read_property_this(&mode, this_ptr, SL("_mode"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&ivSize, "mcrypt_get_iv_size", NULL, cipher, mode); zephir_check_call_status(); ZEPHIR_INIT_VAR(keySize); ZVAL_LONG(keySize, zephir_fast_strlen_ev(decryptKey)); if (ZEPHIR_GT(keySize, ivSize)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_crypt_exception_ce, "Size of key is too large for this algorithm", "phalcon/crypt.zep", 379); return; } ZEPHIR_INIT_VAR(length); ZVAL_LONG(length, zephir_fast_strlen_ev(text)); if (ZEPHIR_GT(keySize, length)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_crypt_exception_ce, "Size of IV is larger than text to decrypt", "phalcon/crypt.zep", 384); return; } ZEPHIR_INIT_VAR(_0); zephir_substr(_0, text, zephir_get_intval(ivSize), 0, ZEPHIR_SUBSTR_NO_LENGTH); ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, 0); ZEPHIR_INIT_VAR(_2); zephir_substr(_2, text, 0 , zephir_get_intval(ivSize), 0); ZEPHIR_CALL_FUNCTION(&decrypted, "mcrypt_decrypt", NULL, cipher, decryptKey, _0, mode, _2); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&blockSize, "mcrypt_get_block_size", NULL, cipher, mode); zephir_check_call_status(); ZEPHIR_OBS_VAR(paddingType); zephir_read_property_this(&paddingType, this_ptr, SL("_padding"), PH_NOISY_CC); _3 = ZEPHIR_IS_STRING(mode, "cbc"); if (!(_3)) { _3 = ZEPHIR_IS_STRING(mode, "ecb"); } if (_3) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_cryptunpadtext", &_4, decrypted, mode, blockSize, paddingType); zephir_check_call_status(); RETURN_MM(); } RETURN_CCTOR(decrypted); }
/** * Shows a backtrace item */ PHP_METHOD(Phalcon_Debug, showTraceItem) { zend_bool _40$$24; HashTable *_18$$14; HashPosition _17$$14; zval *_1, *_26$$16 = NULL; zephir_fcall_cache_entry *_21 = NULL, *_47 = NULL; zval *trace = NULL; zval *n_param = NULL, *trace_param = NULL, *className = NULL, *prepareInternalClass = NULL, *preparedFunctionName = NULL, *html = NULL, *classReflection = NULL, *prepareUriClass = NULL, *functionName = NULL, *functionReflection = NULL, *traceArgs = NULL, *arguments = NULL, *argument = NULL, *filez = NULL, *line = NULL, *showFiles = NULL, *lines = NULL, *numberLines = NULL, *showFileFragment = NULL, *beforeLine = NULL, *afterLine = NULL, *lastLine = NULL, *linePosition = NULL, *currentLine = NULL, *classNameWithLink = NULL, *functionNameWithLink = NULL, _0, *_16, *_2$$3, *_3$$3, _4$$3, *_11$$3, *_12$$3, _5$$4, _6$$4, *_7$$5 = NULL, *_8$$6, _9$$6, _10$$6, *_13$$10 = NULL, _14$$11, _15$$11, **_19$$14, *_23$$14, *_24$$14, *_20$$15 = NULL, *_22$$15 = NULL, *_25$$16, *_27$$16, _28$$18, _29$$18, *_30$$18, _31$$23, *_32$$23, *_33$$26 = NULL, *_34$$26 = NULL, *_35$$26 = NULL, _36$$26 = zval_used_for_init, *_37$$27 = NULL, _38$$27 = zval_used_for_init, _39$$27 = zval_used_for_init, *_41$$29 = NULL, _42$$29 = zval_used_for_init, _43$$29 = zval_used_for_init, _44$$29 = zval_used_for_init, _45$$29 = zval_used_for_init, *_46$$29 = NULL; int n, ZEPHIR_LAST_CALL_STATUS, firstLine = 0, i = 0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &n_param, &trace_param); n = zephir_get_intval(n_param); trace = trace_param; ZEPHIR_SINIT_VAR(_0); ZVAL_LONG(&_0, n); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVS(_1, "<tr><td align=\"right\" valign=\"top\" class=\"error-number\">#", &_0, "</td><td>"); ZEPHIR_CPY_WRT(html, _1); ZEPHIR_OBS_VAR(className); if (zephir_array_isset_string_fetch(&className, trace, SS("class"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(_2$$3); ZEPHIR_INIT_VAR(_3$$3); ZEPHIR_SINIT_VAR(_4$$3); ZVAL_STRING(&_4$$3, "/^Phalcon/", 0); zephir_preg_match(_3$$3, &_4$$3, className, _2$$3, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(_3$$3)) { ZEPHIR_SINIT_VAR(_5$$4); ZVAL_STRING(&_5$$4, "\\", 0); ZEPHIR_SINIT_VAR(_6$$4); ZVAL_STRING(&_6$$4, "/", 0); ZEPHIR_INIT_VAR(prepareUriClass); zephir_fast_str_replace(&prepareUriClass, &_5$$4, &_6$$4, className TSRMLS_CC); ZEPHIR_INIT_VAR(classNameWithLink); ZEPHIR_CONCAT_SVSVS(classNameWithLink, "<a target=\"_new\" href=\"//api.phalconphp.com/class/", prepareUriClass, ".html\">", className, "</a>"); } else { ZEPHIR_INIT_VAR(classReflection); object_init_ex(classReflection, zephir_get_internal_ce(SS("reflectionclass") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, classReflection, "__construct", NULL, 91, className); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_7$$5, classReflection, "isinternal", NULL, 163); zephir_check_call_status(); if (zephir_is_true(_7$$5)) { ZEPHIR_INIT_VAR(_8$$6); zephir_fast_strtolower(_8$$6, className); ZEPHIR_SINIT_VAR(_9$$6); ZVAL_STRING(&_9$$6, "_", 0); ZEPHIR_SINIT_VAR(_10$$6); ZVAL_STRING(&_10$$6, "-", 0); ZEPHIR_INIT_VAR(prepareInternalClass); zephir_fast_str_replace(&prepareInternalClass, &_9$$6, &_10$$6, _8$$6 TSRMLS_CC); ZEPHIR_INIT_NVAR(classNameWithLink); ZEPHIR_CONCAT_SVSVS(classNameWithLink, "<a target=\"_new\" href=\"http://php.net/manual/en/class.", prepareInternalClass, ".php\">", className, "</a>"); } else { ZEPHIR_CPY_WRT(classNameWithLink, className); } } ZEPHIR_INIT_VAR(_11$$3); ZEPHIR_CONCAT_SVS(_11$$3, "<span class=\"error-class\">", classNameWithLink, "</span>"); zephir_concat_self(&html, _11$$3 TSRMLS_CC); zephir_array_fetch_string(&_12$$3, trace, SL("type"), PH_NOISY | PH_READONLY, "phalcon/debug.zep", 386 TSRMLS_CC); zephir_concat_self(&html, _12$$3 TSRMLS_CC); } ZEPHIR_OBS_VAR(functionName); zephir_array_fetch_string(&functionName, trace, SL("function"), PH_NOISY, "phalcon/debug.zep", 392 TSRMLS_CC); if (zephir_array_isset_string(trace, SS("class"))) { ZEPHIR_CPY_WRT(functionNameWithLink, functionName); } else { if ((zephir_function_exists(functionName TSRMLS_CC) == SUCCESS)) { ZEPHIR_INIT_VAR(functionReflection); object_init_ex(functionReflection, zephir_get_internal_ce(SS("reflectionfunction") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, functionReflection, "__construct", NULL, 82, functionName); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_13$$10, functionReflection, "isinternal", NULL, 164); zephir_check_call_status(); if (zephir_is_true(_13$$10)) { ZEPHIR_SINIT_VAR(_14$$11); ZVAL_STRING(&_14$$11, "_", 0); ZEPHIR_SINIT_VAR(_15$$11); ZVAL_STRING(&_15$$11, "-", 0); ZEPHIR_INIT_VAR(preparedFunctionName); zephir_fast_str_replace(&preparedFunctionName, &_14$$11, &_15$$11, functionName TSRMLS_CC); ZEPHIR_INIT_NVAR(functionNameWithLink); ZEPHIR_CONCAT_SVSVS(functionNameWithLink, "<a target=\"_new\" href=\"http://php.net/manual/en/function.", preparedFunctionName, ".php\">", functionName, "</a>"); } else { ZEPHIR_CPY_WRT(functionNameWithLink, functionName); } } else { ZEPHIR_CPY_WRT(functionNameWithLink, functionName); } } ZEPHIR_INIT_VAR(_16); ZEPHIR_CONCAT_SVS(_16, "<span class=\"error-function\">", functionNameWithLink, "</span>"); zephir_concat_self(&html, _16 TSRMLS_CC); ZEPHIR_OBS_VAR(traceArgs); if (zephir_array_isset_string_fetch(&traceArgs, trace, SS("args"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(arguments); array_init(arguments); zephir_is_iterable(traceArgs, &_18$$14, &_17$$14, 0, 0, "phalcon/debug.zep", 441); for ( ; zend_hash_get_current_data_ex(_18$$14, (void**) &_19$$14, &_17$$14) == SUCCESS ; zend_hash_move_forward_ex(_18$$14, &_17$$14) ) { ZEPHIR_GET_HVALUE(argument, _19$$14); ZEPHIR_CALL_METHOD(&_20$$15, this_ptr, "_getvardump", &_21, 0, argument); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_22$$15); ZEPHIR_CONCAT_SVS(_22$$15, "<span class=\"error-parameter\">", _20$$15, "</span>"); zephir_array_append(&arguments, _22$$15, PH_SEPARATE, "phalcon/debug.zep", 435); } ZEPHIR_INIT_VAR(_23$$14); zephir_fast_join_str(_23$$14, SL(", "), arguments TSRMLS_CC); ZEPHIR_INIT_VAR(_24$$14); ZEPHIR_CONCAT_SVS(_24$$14, "(", _23$$14, ")"); zephir_concat_self(&html, _24$$14 TSRMLS_CC); } ZEPHIR_OBS_VAR(filez); if (zephir_array_isset_string_fetch(&filez, trace, SS("file"), 0 TSRMLS_CC)) { ZEPHIR_OBS_VAR(_25$$16); zephir_array_fetch_string(&_25$$16, trace, SL("line"), PH_NOISY, "phalcon/debug.zep", 449 TSRMLS_CC); zephir_get_strval(_26$$16, _25$$16); ZEPHIR_CPY_WRT(line, _26$$16); ZEPHIR_INIT_VAR(_27$$16); ZEPHIR_CONCAT_SVSVS(_27$$16, "<br/><div class=\"error-file\">", filez, " (", line, ")</div>"); zephir_concat_self(&html, _27$$16 TSRMLS_CC); ZEPHIR_OBS_VAR(showFiles); zephir_read_property_this(&showFiles, this_ptr, SL("_showFiles"), PH_NOISY_CC); if (zephir_is_true(showFiles)) { ZEPHIR_CALL_FUNCTION(&lines, "file", NULL, 165, filez); zephir_check_call_status(); ZEPHIR_INIT_VAR(numberLines); ZVAL_LONG(numberLines, zephir_fast_count_int(lines TSRMLS_CC)); ZEPHIR_OBS_VAR(showFileFragment); zephir_read_property_this(&showFileFragment, this_ptr, SL("_showFileFragment"), PH_NOISY_CC); if (zephir_is_true(showFileFragment)) { ZEPHIR_INIT_VAR(beforeLine); ZVAL_LONG(beforeLine, (zephir_get_numberval(line) - 7)); if (ZEPHIR_LT_LONG(beforeLine, 1)) { firstLine = 1; } else { firstLine = zephir_get_numberval(beforeLine); } ZEPHIR_INIT_VAR(afterLine); ZVAL_LONG(afterLine, (zephir_get_numberval(line) + 5)); if (ZEPHIR_GT(afterLine, numberLines)) { ZEPHIR_CPY_WRT(lastLine, numberLines); } else { ZEPHIR_CPY_WRT(lastLine, afterLine); } ZEPHIR_SINIT_VAR(_28$$18); ZVAL_LONG(&_28$$18, firstLine); ZEPHIR_SINIT_VAR(_29$$18); ZVAL_LONG(&_29$$18, firstLine); ZEPHIR_INIT_VAR(_30$$18); ZEPHIR_CONCAT_SVSVSVS(_30$$18, "<pre class=\"prettyprint highlight:", &_28$$18, ":", line, " linenums:", &_29$$18, "\">"); zephir_concat_self(&html, _30$$18 TSRMLS_CC); } else { firstLine = 1; ZEPHIR_CPY_WRT(lastLine, numberLines); ZEPHIR_SINIT_VAR(_31$$23); ZVAL_LONG(&_31$$23, firstLine); ZEPHIR_INIT_VAR(_32$$23); ZEPHIR_CONCAT_SVSVS(_32$$23, "<pre class=\"prettyprint highlight:", &_31$$23, ":", line, " linenums error-scroll\">"); zephir_concat_self(&html, _32$$23 TSRMLS_CC); } i = firstLine; while (1) { if (!(ZEPHIR_GE_LONG(lastLine, i))) { break; } ZEPHIR_INIT_NVAR(linePosition); ZVAL_LONG(linePosition, (i - 1)); ZEPHIR_OBS_NVAR(currentLine); zephir_array_fetch(¤tLine, lines, linePosition, PH_NOISY, "phalcon/debug.zep", 522 TSRMLS_CC); if (zephir_is_true(showFileFragment)) { if (i == firstLine) { ZEPHIR_INIT_NVAR(_33$$26); ZEPHIR_INIT_NVAR(_34$$26); ZEPHIR_INIT_NVAR(_35$$26); zephir_fast_trim(_35$$26, currentLine, NULL , ZEPHIR_TRIM_RIGHT TSRMLS_CC); ZEPHIR_SINIT_NVAR(_36$$26); ZVAL_STRING(&_36$$26, "#\\*\\/#", 0); zephir_preg_match(_34$$26, &_36$$26, _35$$26, _33$$26, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(_34$$26)) { ZEPHIR_INIT_NVAR(_37$$27); ZEPHIR_SINIT_NVAR(_38$$27); ZVAL_STRING(&_38$$27, "* /", 0); ZEPHIR_SINIT_NVAR(_39$$27); ZVAL_STRING(&_39$$27, " ", 0); zephir_fast_str_replace(&_37$$27, &_38$$27, &_39$$27, currentLine TSRMLS_CC); ZEPHIR_CPY_WRT(currentLine, _37$$27); } } } _40$$24 = ZEPHIR_IS_STRING(currentLine, "\n"); if (!(_40$$24)) { _40$$24 = ZEPHIR_IS_STRING(currentLine, "\r\n"); } if (_40$$24) { zephir_concat_self_str(&html, SL(" \n") TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(_41$$29); ZEPHIR_SINIT_NVAR(_42$$29); ZVAL_STRING(&_42$$29, "\t", 0); ZEPHIR_SINIT_NVAR(_43$$29); ZVAL_STRING(&_43$$29, " ", 0); zephir_fast_str_replace(&_41$$29, &_42$$29, &_43$$29, currentLine TSRMLS_CC); ZEPHIR_SINIT_NVAR(_44$$29); ZVAL_LONG(&_44$$29, 2); ZEPHIR_SINIT_NVAR(_45$$29); ZVAL_STRING(&_45$$29, "UTF-8", 0); ZEPHIR_CALL_FUNCTION(&_46$$29, "htmlentities", &_47, 158, _41$$29, &_44$$29, &_45$$29); zephir_check_call_status(); zephir_concat_self(&html, _46$$29 TSRMLS_CC); } i++; } zephir_concat_self_str(&html, SL("</pre>") TSRMLS_CC); } } zephir_concat_self_str(&html, SL("</td></tr>") TSRMLS_CC); RETURN_CCTOR(html); }
/** * Validates the data from the decoded JWT. * * @return boolean TRUE if the JWT request is valid and can be decoded. Otherwise, FALSE is returned. * * @see OAuth2\GrantType\GrantTypeInterface::getTokenData() */ PHP_METHOD(OAuth2_GrantType_JwtBearer, validateRequest) { zend_bool _14, _21; zephir_fcall_cache_entry *_9 = NULL, *_12 = NULL; zval *_6; int ZEPHIR_LAST_CALL_STATUS; zval *request, *response, *undecodedJWT = NULL, *jwt = NULL, *notBefore, *jti = NULL, *key = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4, *_5 = NULL, *_7, *_8 = NULL, *_10, *_11 = NULL, *_13 = NULL, *_15, *_16, *_17, *_18, *_19, *_20, *_22, *_23, *_24, *_25, *_26, *_27, *_28; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &request, &response); if (!(zephir_instance_of_ev(request, oauth2_requestinterface_ce TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Parameter 'request' must be an instance of 'OAuth2\\RequestInterface'", "", 0); return; } if (!(zephir_instance_of_ev(response, oauth2_responseinterface_ce TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Parameter 'response' must be an instance of 'OAuth2\\ResponseInterface'", "", 0); return; } ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "assertion", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, request, "request", NULL, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (!(zephir_is_true(_0))) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "invalid_request", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "Missing parameters: \"assertion\" required", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "assertion", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&undecodedJWT, request, "request", NULL, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); _4 = zephir_fetch_nproperty_this(this_ptr, SL("jwtUtil"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "assertion", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_5, request, "request", NULL, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_1); ZVAL_NULL(_1); ZEPHIR_INIT_NVAR(_2); ZVAL_BOOL(_2, 0); ZEPHIR_CALL_METHOD(&jwt, _4, "decode", NULL, _5, _1, _2); zephir_check_call_status(); if (!(zephir_is_true(jwt))) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "invalid_request", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "JWT is malformed", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_1); ZEPHIR_INIT_VAR(_6); array_init_size(_6, 12); zephir_array_update_string(&_6, SL("scope"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_array_update_string(&_6, SL("iss"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_array_update_string(&_6, SL("sub"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_array_update_string(&_6, SL("aud"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_array_update_string(&_6, SL("exp"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_array_update_string(&_6, SL("nbf"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_array_update_string(&_6, SL("iat"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_array_update_string(&_6, SL("jti"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_array_update_string(&_6, SL("typ"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_fast_array_merge(_1, &(_6), &(jwt) TSRMLS_CC); ZEPHIR_CPY_WRT(jwt, _1); if (!(zephir_array_isset_string(jwt, SS("iss")))) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "invalid_grant", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "Invalid issuer (iss) provided", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } if (!(zephir_array_isset_string(jwt, SS("sub")))) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "invalid_grant", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "Invalid subject (sub) provided", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } if (!(zephir_array_isset_string(jwt, SS("exp")))) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "invalid_grant", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "Expiration (exp) time must be present", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } zephir_array_fetch_string(&_7, jwt, SL("exp"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 115 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_8, "ctype_digit", &_9, _7); zephir_check_call_status(); if (zephir_is_true(_8)) { zephir_array_fetch_string(&_10, jwt, SL("exp"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 116 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_11, "time", &_12); zephir_check_call_status(); if (ZEPHIR_LE(_10, _11)) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "invalid_grant", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "JWT has expired", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } } else { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "invalid_grant", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "Expiration (exp) time must be a unix time stamp", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_OBS_VAR(notBefore); zephir_array_fetch_string(¬Before, jwt, SL("nbf"), PH_NOISY, "oauth2/granttype/jwtbearer.zep", 126 TSRMLS_CC); if (zephir_is_true(notBefore)) { ZEPHIR_CALL_FUNCTION(&_11, "ctype_digit", &_9, notBefore); zephir_check_call_status(); if (zephir_is_true(_11)) { ZEPHIR_CALL_FUNCTION(&_13, "time", &_12); zephir_check_call_status(); if (ZEPHIR_GT(notBefore, _13)) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "invalid_grant", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "JWT cannot be used before the Not Before (nbf) time", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } } else { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "invalid_grant", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "Not Before (nbf) time must be a unix time stamp", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } } _14 = !zephir_array_isset_string(jwt, SS("aud")); if (!(_14)) { zephir_array_fetch_string(&_10, jwt, SL("aud"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 140 TSRMLS_CC); _15 = zephir_fetch_nproperty_this(this_ptr, SL("audience"), PH_NOISY_CC); _14 = !ZEPHIR_IS_EQUAL(_10, _15); } if (_14) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "invalid_grant", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "Invalid audience (aud)", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } if (zephir_array_isset_string(jwt, SS("jti"))) { _16 = zephir_fetch_nproperty_this(this_ptr, SL("storage"), PH_NOISY_CC); zephir_array_fetch_string(&_10, jwt, SL("iss"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 148 TSRMLS_CC); zephir_array_fetch_string(&_17, jwt, SL("sub"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 148 TSRMLS_CC); zephir_array_fetch_string(&_18, jwt, SL("aud"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 148 TSRMLS_CC); zephir_array_fetch_string(&_19, jwt, SL("exp"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 148 TSRMLS_CC); zephir_array_fetch_string(&_20, jwt, SL("jti"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 148 TSRMLS_CC); ZEPHIR_CALL_METHOD(&jti, _16, "getjti", NULL, _10, _17, _18, _19, _20); zephir_check_call_status(); _21 = zephir_is_true(jti); if (_21) { zephir_array_fetch_string(&_22, jti, SL("expires"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 151 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_11, "time", &_12); zephir_check_call_status(); _21 = ZEPHIR_GT(_22, _11); } if (_21) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "invalid_grant", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "JSON Token Identifier (jti) has already been used", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } else { _23 = zephir_fetch_nproperty_this(this_ptr, SL("storage"), PH_NOISY_CC); zephir_array_fetch_string(&_24, jwt, SL("iss"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 155 TSRMLS_CC); zephir_array_fetch_string(&_25, jwt, SL("sub"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 155 TSRMLS_CC); zephir_array_fetch_string(&_26, jwt, SL("aud"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 155 TSRMLS_CC); zephir_array_fetch_string(&_27, jwt, SL("exp"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 155 TSRMLS_CC); zephir_array_fetch_string(&_28, jwt, SL("jti"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 155 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, _23, "setjti", NULL, _24, _25, _26, _27, _28); zephir_check_call_status(); } } _16 = zephir_fetch_nproperty_this(this_ptr, SL("storage"), PH_NOISY_CC); zephir_array_fetch_string(&_10, jwt, SL("iss"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 161 TSRMLS_CC); zephir_array_fetch_string(&_17, jwt, SL("sub"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 161 TSRMLS_CC); ZEPHIR_CALL_METHOD(&key, _16, "getclientkey", NULL, _10, _17); zephir_check_call_status(); if (!(zephir_is_true(key))) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "invalid_grant", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "Invalid issuer (iss) or subject (sub) provided", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } _16 = zephir_fetch_nproperty_this(this_ptr, SL("jwtUtil"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_1); ZVAL_BOOL(_1, 1); ZEPHIR_CALL_METHOD(&_11, _16, "decode", NULL, undecodedJWT, key, _1); zephir_check_call_status(); if (!(zephir_is_true(_11))) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "invalid_grant", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "JWT failed signature verification", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } zephir_update_property_this(this_ptr, SL("jwt"), jwt TSRMLS_CC); 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 _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); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_Between, validate) { zend_bool _2, _3; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *value = NULL, *minimum = NULL, *maximum = NULL, *message = NULL, *label = NULL, *replacePairs = NULL, *_0 = NULL, *_1 = NULL, *_4$$4 = NULL, *_6$$4 = NULL, *_7$$4, *_5$$6; ZEPHIR_MM_GROW(); 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, "minimum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&minimum, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "maximum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&maximum, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _2 = zephir_is_true(_1); if (_2) { _2 = ZEPHIR_IS_EMPTY(value); } if (_2) { RETURN_MM_BOOL(1); } _3 = ZEPHIR_LT(value, minimum); if (!(_3)) { _3 = ZEPHIR_GT(value, maximum); } if (_3) { ZEPHIR_INIT_VAR(_4$$4); ZVAL_STRING(_4$$4, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _4$$4); zephir_check_temp_parameter(_4$$4); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_4$$4); ZVAL_STRING(_4$$4, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _4$$4); zephir_check_temp_parameter(_4$$4); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 3, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":min"), &minimum, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":max"), &maximum, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_5$$6); ZVAL_STRING(_5$$6, "Between", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _5$$6); zephir_check_temp_parameter(_5$$6); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_4$$4); object_init_ex(_4$$4, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_6$$4, "strtr", NULL, 55, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_7$$4); ZVAL_STRING(_7$$4, "Between", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _4$$4, "__construct", NULL, 434, _6$$4, field, _7$$4); zephir_check_temp_parameter(_7$$4); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _4$$4); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_Between, validate) { zend_bool _3; zend_long ZEPHIR_LAST_CALL_STATUS; zval *validation, validation_sub, *field, field_sub, value, minimum, maximum, message, label, replacePairs, code, _0, _1$$3, _2$$4, _4$$5, _5$$5, _6$$5; zval *this_ptr = getThis(); ZVAL_UNDEF(&validation_sub); ZVAL_UNDEF(&field_sub); ZVAL_UNDEF(&value); ZVAL_UNDEF(&minimum); ZVAL_UNDEF(&maximum); ZVAL_UNDEF(&message); ZVAL_UNDEF(&label); ZVAL_UNDEF(&replacePairs); ZVAL_UNDEF(&code); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_2$$4); ZVAL_UNDEF(&_4$$5); ZVAL_UNDEF(&_5$$5); ZVAL_UNDEF(&_6$$5); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field); ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "minimum"); ZEPHIR_CALL_METHOD(&minimum, this_ptr, "getoption", NULL, 0, &_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_0); ZVAL_STRING(&_0, "maximum"); ZEPHIR_CALL_METHOD(&maximum, this_ptr, "getoption", NULL, 0, &_0); zephir_check_call_status(); if (Z_TYPE_P(&minimum) == IS_ARRAY) { zephir_array_fetch(&_1$$3, &minimum, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/between.zep", 79 TSRMLS_CC); ZEPHIR_CPY_WRT(&minimum, &_1$$3); } if (Z_TYPE_P(&maximum) == IS_ARRAY) { zephir_array_fetch(&_2$$4, &maximum, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/between.zep", 83 TSRMLS_CC); ZEPHIR_CPY_WRT(&maximum, &_2$$4); } _3 = ZEPHIR_LT(&value, &minimum); if (!(_3)) { _3 = ZEPHIR_GT(&value, &maximum); } if (_3) { ZEPHIR_CALL_METHOD(&label, this_ptr, "preparelabel", NULL, 0, validation, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(&_4$$5); ZVAL_STRING(&_4$$5, "Between"); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, &_4$$5); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&code, this_ptr, "preparecode", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(&replacePairs); zephir_create_array(&replacePairs, 3, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":min"), &minimum, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":max"), &maximum, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_4$$5); object_init_ex(&_4$$5, phalcon_messages_message_ce); ZEPHIR_CALL_FUNCTION(&_5$$5, "strtr", NULL, 48, &message, &replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(&_6$$5); ZVAL_STRING(&_6$$5, "Between"); ZEPHIR_CALL_METHOD(NULL, &_4$$5, "__construct", NULL, 300, &_5$$5, field, &_6$$5, &code); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_4$$5); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); }
/** * Shows a backtrace item */ PHP_METHOD(Phalcon_Debug, showTraceItem) { zephir_fcall_cache_entry *_16 = NULL; HashTable *_14; HashPosition _13; zephir_nts_static zephir_fcall_cache_entry *_4 = NULL, *_6 = NULL, *_8 = NULL, *_11 = NULL, *_12 = NULL, *_19 = NULL, *_24 = NULL; zval *_1, *_18 = NULL; zval *trace = NULL; zval *n_param = NULL, *trace_param = NULL, *space, *twoSpaces, *underscore, *minus, *className, *namespaceSeparator, *prepareInternalClass, *preparedFunctionName, *html = NULL, *classReflection, *prepareUriClass, *functionName, *functionReflection, *traceArgs, *arguments, *argument = NULL, *filez, *line = NULL, *showFiles, *lines = NULL, *numberLines, *showFileFragment, *beforeLine, *afterLine, *lastLine = NULL, *commentPattern, *utf8, *entCompat, *tab, *comment, linePosition = zval_used_for_init, *currentLine = NULL, _0, *_2 = NULL, *_3 = NULL, *_5 = NULL, *_7 = NULL, *_9 = NULL, *_10, **_15, *_17, _20 = zval_used_for_init, _21, *_22, *_23 = NULL; int n, firstLine, i, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &n_param, &trace_param); n = zephir_get_intval(n_param); trace = trace_param; ZEPHIR_INIT_VAR(space); ZVAL_STRING(space, " ", 1); ZEPHIR_INIT_VAR(twoSpaces); ZVAL_STRING(twoSpaces, " ", 1); ZEPHIR_INIT_VAR(underscore); ZVAL_STRING(underscore, "_", 1); ZEPHIR_INIT_VAR(minus); ZVAL_STRING(minus, "-", 1); ZEPHIR_SINIT_VAR(_0); ZVAL_LONG(&_0, n); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVS(_1, "<tr><td align=\"right\" valign=\"top\" class=\"error-number\">#", &_0, "</td><td>"); ZEPHIR_CPY_WRT(html, _1); if (zephir_array_isset_string(trace, SS("class"))) { ZEPHIR_OBS_VAR(className); zephir_array_fetch_string(&className, trace, SL("class"), PH_NOISY, "phalcon/debug.zep", 355 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "/^Phalcon/", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&_3, "preg_match", &_4, _2, className); zephir_check_temp_parameter(_2); zephir_check_call_status(); if (zephir_is_true(_3)) { ZEPHIR_INIT_VAR(namespaceSeparator); ZVAL_STRING(namespaceSeparator, "\\", 1); ZEPHIR_INIT_VAR(prepareUriClass); zephir_fast_str_replace(&prepareUriClass, namespaceSeparator, underscore, className TSRMLS_CC); ZEPHIR_INIT_VAR(_5); ZEPHIR_CONCAT_SVSVS(_5, "<span class=\"error-class\"><a target=\"_new\" href=\"http://docs.phalconphp.com/en/latest/api/", prepareUriClass, ".html\">", className, "</a></span>"); zephir_concat_self(&html, _5 TSRMLS_CC); } else { ZEPHIR_INIT_VAR(classReflection); object_init_ex(classReflection, zephir_get_internal_ce(SS("reflectionclass") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, classReflection, "__construct", &_6, className); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_7, classReflection, "isinternal", &_8); zephir_check_call_status(); if (zephir_is_true(_7)) { ZEPHIR_INIT_VAR(prepareInternalClass); ZEPHIR_INIT_NVAR(_2); zephir_fast_strtolower(_2, className); zephir_fast_str_replace(&prepareInternalClass, underscore, minus, _2 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_5); ZEPHIR_CONCAT_SVSVS(_5, "<span class=\"error-class\"><a target=\"_new\" href=\"http://php.net/manual/en/class.", prepareInternalClass, ".php\">", className, "</a></span>"); zephir_concat_self(&html, _5 TSRMLS_CC); } else { ZEPHIR_INIT_VAR(_9); ZEPHIR_CONCAT_SVS(_9, "<span class=\"error-class\">", className, "</span>"); zephir_concat_self(&html, _9 TSRMLS_CC); } } zephir_array_fetch_string(&_10, trace, SL("type"), PH_NOISY | PH_READONLY, "phalcon/debug.zep", 396 TSRMLS_CC); zephir_concat_self(&html, _10 TSRMLS_CC); } ZEPHIR_OBS_VAR(functionName); zephir_array_fetch_string(&functionName, trace, SL("function"), PH_NOISY, "phalcon/debug.zep", 402 TSRMLS_CC); if (zephir_array_isset_string(trace, SS("class"))) { ZEPHIR_INIT_LNVAR(_5); ZEPHIR_CONCAT_SVS(_5, "<span class=\"error-function\">", functionName, "</span>"); zephir_concat_self(&html, _5 TSRMLS_CC); } else { if ((zephir_function_exists(functionName TSRMLS_CC) == SUCCESS)) { ZEPHIR_INIT_VAR(functionReflection); object_init_ex(functionReflection, zephir_get_internal_ce(SS("reflectionfunction") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, functionReflection, "__construct", &_11, functionName); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_3, functionReflection, "isinternal", &_12); zephir_check_call_status(); if (zephir_is_true(_3)) { ZEPHIR_INIT_VAR(preparedFunctionName); zephir_fast_str_replace(&preparedFunctionName, underscore, minus, functionName TSRMLS_CC); ZEPHIR_INIT_LNVAR(_9); ZEPHIR_CONCAT_SVSVS(_9, "<span class=\"error-function\"><a target=\"_new\" href=\"http://php.net/manual/en/function.", preparedFunctionName, ".php\">", functionName, "</a></span>"); zephir_concat_self(&html, _9 TSRMLS_CC); } else { ZEPHIR_INIT_LNVAR(_9); ZEPHIR_CONCAT_SVS(_9, "<span class=\"error-function\">", functionName, "</span>"); zephir_concat_self(&html, _9 TSRMLS_CC); } } else { ZEPHIR_INIT_LNVAR(_5); ZEPHIR_CONCAT_SVS(_5, "<span class=\"error-function\">", functionName, "</span>"); zephir_concat_self(&html, _5 TSRMLS_CC); } } if (zephir_array_isset_string(trace, SS("args"))) { ZEPHIR_OBS_VAR(traceArgs); zephir_array_fetch_string(&traceArgs, trace, SL("args"), PH_NOISY, "phalcon/debug.zep", 436 TSRMLS_CC); if (zephir_fast_count_int(traceArgs TSRMLS_CC)) { ZEPHIR_INIT_VAR(arguments); array_init(arguments); zephir_is_iterable(traceArgs, &_14, &_13, 0, 0, "phalcon/debug.zep", 451); for ( ; zephir_hash_get_current_data_ex(_14, (void**) &_15, &_13) == SUCCESS ; zephir_hash_move_forward_ex(_14, &_13) ) { ZEPHIR_GET_HVALUE(argument, _15); ZEPHIR_CALL_METHOD(&_3, this_ptr, "_getvardump", &_16, argument); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_5); ZEPHIR_CONCAT_SVS(_5, "<span class=\"error-parameter\">", _3, "</span>"); zephir_array_append(&arguments, _5, PH_SEPARATE, "phalcon/debug.zep", 445); } ZEPHIR_INIT_NVAR(_2); zephir_fast_join_str(_2, SL(", "), arguments TSRMLS_CC); ZEPHIR_INIT_LNVAR(_9); ZEPHIR_CONCAT_SVS(_9, "(", _2, ")"); zephir_concat_self(&html, _9 TSRMLS_CC); } else { zephir_concat_self_str(&html, SL("()") TSRMLS_CC); } } ZEPHIR_OBS_VAR(filez); if (zephir_array_isset_string_fetch(&filez, trace, SS("file"), 0 TSRMLS_CC)) { ZEPHIR_OBS_VAR(_17); zephir_array_fetch_string(&_17, trace, SL("line"), PH_NOISY, "phalcon/debug.zep", 462 TSRMLS_CC); zephir_get_strval(_18, _17); ZEPHIR_CPY_WRT(line, _18); ZEPHIR_INIT_LNVAR(_5); ZEPHIR_CONCAT_SVSVS(_5, "<br/><div class=\"error-file\">", filez, " (", line, ")</div>"); zephir_concat_self(&html, _5 TSRMLS_CC); ZEPHIR_OBS_VAR(showFiles); zephir_read_property_this(&showFiles, this_ptr, SL("_showFiles"), PH_NOISY_CC); if (zephir_is_true(showFiles)) { ZEPHIR_CALL_FUNCTION(&lines, "file", &_19, filez); zephir_check_call_status(); ZEPHIR_INIT_VAR(numberLines); ZVAL_LONG(numberLines, zephir_fast_count_int(lines TSRMLS_CC)); ZEPHIR_OBS_VAR(showFileFragment); zephir_read_property_this(&showFileFragment, this_ptr, SL("_showFileFragment"), PH_NOISY_CC); if (zephir_is_true(showFileFragment)) { ZEPHIR_INIT_VAR(beforeLine); ZVAL_LONG(beforeLine, (zephir_get_numberval(line) - 7)); if (ZEPHIR_LT_LONG(beforeLine, 1)) { firstLine = 1; } else { firstLine = zephir_get_numberval(beforeLine); } ZEPHIR_INIT_VAR(afterLine); ZVAL_LONG(afterLine, (zephir_get_numberval(line) + 5)); if (ZEPHIR_GT(afterLine, numberLines)) { ZEPHIR_CPY_WRT(lastLine, numberLines); } else { ZEPHIR_CPY_WRT(lastLine, afterLine); } ZEPHIR_SINIT_VAR(_20); ZVAL_LONG(&_20, firstLine); ZEPHIR_SINIT_VAR(_21); ZVAL_LONG(&_21, firstLine); ZEPHIR_INIT_VAR(_22); ZEPHIR_CONCAT_SVSVSVS(_22, "<pre class=\"prettyprint highlight:", &_20, ":", line, " linenums:", &_21, "\">"); zephir_concat_self(&html, _22 TSRMLS_CC); } else { firstLine = 1; ZEPHIR_CPY_WRT(lastLine, numberLines); ZEPHIR_SINIT_NVAR(_20); ZVAL_LONG(&_20, firstLine); ZEPHIR_INIT_LNVAR(_9); ZEPHIR_CONCAT_SVSVS(_9, "<pre class=\"prettyprint highlight:", &_20, ":", line, " linenums error-scroll\">"); zephir_concat_self(&html, _9 TSRMLS_CC); } ZEPHIR_INIT_VAR(commentPattern); ZVAL_STRING(commentPattern, "#\\*\\/#", 1); ZEPHIR_INIT_VAR(utf8); ZVAL_STRING(utf8, "UTF-8", 1); ZEPHIR_INIT_VAR(entCompat); ZVAL_LONG(entCompat, 2); ZEPHIR_INIT_VAR(tab); ZVAL_STRING(tab, "\t", 1); ZEPHIR_INIT_VAR(comment); ZVAL_STRING(comment, "* /", 1); i = firstLine; while (1) { if (!(ZEPHIR_GE_LONG(lastLine, i))) { break; } ZEPHIR_SINIT_NVAR(linePosition); ZVAL_LONG(&linePosition, (i - 1)); ZEPHIR_OBS_NVAR(currentLine); zephir_array_fetch(¤tLine, lines, &linePosition, PH_NOISY, "phalcon/debug.zep", 550 TSRMLS_CC); if (zephir_is_true(showFileFragment)) { if (i == firstLine) { ZEPHIR_INIT_NVAR(_2); zephir_fast_trim(_2, currentLine, NULL , ZEPHIR_TRIM_RIGHT TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_3, "preg_match", &_4, commentPattern, _2); zephir_check_call_status(); if (zephir_is_true(_3)) { ZEPHIR_INIT_NVAR(_23); zephir_fast_str_replace(&_23, comment, space, currentLine TSRMLS_CC); ZEPHIR_CPY_WRT(currentLine, _23); } } } if (ZEPHIR_IS_STRING(currentLine, "\n")) { zephir_concat_self_str(&html, SL(" \n") TSRMLS_CC); } else { if (ZEPHIR_IS_STRING(currentLine, "\r\n")) { zephir_concat_self_str(&html, SL(" \n") TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(_23); zephir_fast_str_replace(&_23, tab, twoSpaces, currentLine TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_7, "htmlentities", &_24, _23, entCompat, utf8); zephir_check_call_status(); zephir_concat_self(&html, _7 TSRMLS_CC); } } i++; } zephir_concat_self_str(&html, SL("</pre>") TSRMLS_CC); } } zephir_concat_self_str(&html, SL("</td></tr>") TSRMLS_CC); RETURN_CCTOR(html); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_StringLength, validate) { zend_bool _1; zend_long ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *isSetMin = NULL, *isSetMax = NULL, *value = NULL, *length = NULL, *message = NULL, *minimum = NULL, *maximum = NULL, *label = NULL, *replacePairs = NULL, *code = NULL, *_0 = NULL, *_2$$6, *_3$$7, *_4$$8 = NULL, *_5$$8 = NULL, *_6$$8 = NULL, *_7$$9, *_8$$10, *_9$$11 = NULL, *_10$$11 = NULL, *_11$$11 = NULL; ZEPHIR_MM_GROW(); 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_INIT_VAR(_0); ZVAL_STRING(_0, "min", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&isSetMin, this_ptr, "hasoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "max", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&isSetMax, this_ptr, "hasoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _1 = !zephir_is_true(isSetMin); if (_1) { _1 = !zephir_is_true(isSetMax); } if (_1) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "A minimum or maximum must be set", "phalcon/validation/validator/stringlength.zep", 95); return; } 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(); if ((zephir_function_exists_ex(SS("mb_strlen") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, 238, value); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(length); ZVAL_LONG(length, zephir_fast_strlen_ev(value)); } if (zephir_is_true(isSetMax)) { ZEPHIR_INIT_VAR(_2$$6); ZVAL_STRING(_2$$6, "max", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&maximum, this_ptr, "getoption", NULL, 0, _2$$6); zephir_check_temp_parameter(_2$$6); zephir_check_call_status(); if (Z_TYPE_P(maximum) == IS_ARRAY) { zephir_array_fetch(&_3$$7, maximum, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/stringlength.zep", 116 TSRMLS_CC); ZEPHIR_CPY_WRT(maximum, _3$$7); } if (ZEPHIR_GT(length, maximum)) { ZEPHIR_INIT_VAR(_4$$8); ZVAL_STRING(_4$$8, "TooLong", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_5$$8); ZVAL_STRING(_5$$8, "messageMaximum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, _4$$8, _5$$8); zephir_check_temp_parameter(_4$$8); zephir_check_temp_parameter(_5$$8); 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_array_update_string(&replacePairs, SL(":max"), &maximum, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_4$$8); object_init_ex(_4$$8, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_6$$8, "strtr", NULL, 27, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_5$$8); ZVAL_STRING(_5$$8, "TooLong", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _4$$8, "__construct", NULL, 478, _6$$8, field, _5$$8, code); zephir_check_temp_parameter(_5$$8); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _4$$8); zephir_check_call_status(); RETURN_MM_BOOL(0); } } if (zephir_is_true(isSetMin)) { ZEPHIR_INIT_VAR(_7$$9); ZVAL_STRING(_7$$9, "min", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&minimum, this_ptr, "getoption", NULL, 0, _7$$9); zephir_check_temp_parameter(_7$$9); zephir_check_call_status(); if (Z_TYPE_P(minimum) == IS_ARRAY) { zephir_array_fetch(&_8$$10, minimum, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/stringlength.zep", 142 TSRMLS_CC); ZEPHIR_CPY_WRT(minimum, _8$$10); } if (ZEPHIR_LT(length, minimum)) { ZEPHIR_INIT_VAR(_9$$11); ZVAL_STRING(_9$$11, "TooShort", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_10$$11); ZVAL_STRING(_10$$11, "messageMinimum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, _9$$11, _10$$11); zephir_check_temp_parameter(_9$$11); zephir_check_temp_parameter(_10$$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_array_update_string(&replacePairs, SL(":min"), &minimum, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_9$$11); object_init_ex(_9$$11, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_11$$11, "strtr", NULL, 27, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_10$$11); ZVAL_STRING(_10$$11, "TooShort", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _9$$11, "__construct", NULL, 478, _11$$11, field, _10$$11, code); zephir_check_temp_parameter(_10$$11); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _9$$11); 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); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_StringLength, validate) { zend_bool _1; zephir_fcall_cache_entry *_10 = NULL, *_12 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *isSetMin = NULL, *isSetMax = NULL, *value = NULL, *length = NULL, *message = NULL, *minimum = NULL, *maximum = NULL, *label = NULL, *replacePairs = NULL, *code = NULL, *_0 = NULL, *_2$$4, *_3$$6, *_4$$9, *_5$$10, *_6$$11 = NULL, *_9$$11 = NULL, *_11$$11, *_7$$12, *_8$$13, *_13$$14, *_14$$15, *_15$$16 = NULL, *_18$$16 = NULL, *_19$$16, *_16$$17, *_17$$18; ZEPHIR_MM_GROW(); 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_INIT_VAR(_0); ZVAL_STRING(_0, "min", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&isSetMin, this_ptr, "hasoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "max", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&isSetMax, this_ptr, "hasoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _1 = !zephir_is_true(isSetMin); if (_1) { _1 = !zephir_is_true(isSetMax); } if (_1) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "A minimum or maximum must be set", "phalcon/validation/validator/stringlength.zep", 92); return; } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_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(&_2$$4, label, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/stringlength.zep", 98 TSRMLS_CC); ZEPHIR_CPY_WRT(label, _2$$4); } 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(&_3$$6, code, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/stringlength.zep", 106 TSRMLS_CC); ZEPHIR_CPY_WRT(code, _3$$6); } if ((zephir_function_exists_ex(SS("mb_strlen") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, 382, value); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(length); ZVAL_LONG(length, zephir_fast_strlen_ev(value)); } if (zephir_is_true(isSetMax)) { ZEPHIR_INIT_VAR(_4$$9); ZVAL_STRING(_4$$9, "max", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&maximum, this_ptr, "getoption", NULL, 0, _4$$9); zephir_check_temp_parameter(_4$$9); zephir_check_call_status(); if (Z_TYPE_P(maximum) == IS_ARRAY) { zephir_array_fetch(&_5$$10, maximum, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/stringlength.zep", 123 TSRMLS_CC); ZEPHIR_CPY_WRT(maximum, _5$$10); } if (ZEPHIR_GT(length, maximum)) { ZEPHIR_INIT_VAR(_6$$11); ZVAL_STRING(_6$$11, "messageMaximum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _6$$11); zephir_check_temp_parameter(_6$$11); 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_array_update_string(&replacePairs, SL(":max"), &maximum, PH_COPY | PH_SEPARATE); if (Z_TYPE_P(message) == IS_ARRAY) { zephir_array_fetch(&_7$$12, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/stringlength.zep", 132 TSRMLS_CC); ZEPHIR_CPY_WRT(message, _7$$12); } if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_8$$13); ZVAL_STRING(_8$$13, "TooLong", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _8$$13); zephir_check_temp_parameter(_8$$13); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_6$$11); object_init_ex(_6$$11, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_9$$11, "strtr", &_10, 26, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_11$$11); ZVAL_STRING(_11$$11, "TooLong", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _6$$11, "__construct", &_12, 466, _9$$11, field, _11$$11, code); zephir_check_temp_parameter(_11$$11); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _6$$11); zephir_check_call_status(); RETURN_MM_BOOL(0); } } if (zephir_is_true(isSetMin)) { ZEPHIR_INIT_VAR(_13$$14); ZVAL_STRING(_13$$14, "min", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&minimum, this_ptr, "getoption", NULL, 0, _13$$14); zephir_check_temp_parameter(_13$$14); zephir_check_call_status(); if (Z_TYPE_P(minimum) == IS_ARRAY) { zephir_array_fetch(&_14$$15, minimum, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/stringlength.zep", 159 TSRMLS_CC); ZEPHIR_CPY_WRT(minimum, _14$$15); } if (ZEPHIR_LT(length, minimum)) { ZEPHIR_INIT_VAR(_15$$16); ZVAL_STRING(_15$$16, "messageMinimum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _15$$16); zephir_check_temp_parameter(_15$$16); 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"), &minimum, PH_COPY | PH_SEPARATE); if (Z_TYPE_P(message) == IS_ARRAY) { zephir_array_fetch(&_16$$17, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/stringlength.zep", 168 TSRMLS_CC); ZEPHIR_CPY_WRT(message, _16$$17); } if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_17$$18); ZVAL_STRING(_17$$18, "TooShort", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _17$$18); zephir_check_temp_parameter(_17$$18); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_15$$16); object_init_ex(_15$$16, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_18$$16, "strtr", &_10, 26, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_19$$16); ZVAL_STRING(_19$$16, "TooShort", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _15$$16, "__construct", &_12, 466, _18$$16, field, _19$$16, code); zephir_check_temp_parameter(_19$$16); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _15$$16); zephir_check_call_status(); RETURN_MM_BOOL(0); } } RETURN_MM_BOOL(1); }