/** * Checks a plain text password and its hash version to check if the password matches */ PHP_METHOD(Phalcon_Security, checkHash) { unsigned char _5; long _4; zephir_nts_static zephir_fcall_cache_entry *_2 = NULL; zend_bool _0; char ch; int maxPassLength, i, sum, cryptedLength, passwordLength, ZEPHIR_LAST_CALL_STATUS; zval *password_param = NULL, *passwordHash_param = NULL, *maxPassLength_param = NULL, *_1 = NULL; zval *password = NULL, *passwordHash = NULL, *cryptedHash = NULL, *_3 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &password_param, &passwordHash_param, &maxPassLength_param); zephir_get_strval(password, password_param); zephir_get_strval(passwordHash, passwordHash_param); if (!maxPassLength_param) { maxPassLength = 0; } else { maxPassLength = zephir_get_intval(maxPassLength_param); } if (maxPassLength) { _0 = maxPassLength > 0; if (_0) { _0 = zephir_fast_strlen_ev(password) > maxPassLength; } if (_0) { RETURN_MM_BOOL(0); } } ZEPHIR_CALL_FUNCTION(&_1, "crypt", &_2, password, passwordHash); zephir_check_call_status(); zephir_get_strval(_3, _1); ZEPHIR_CPY_WRT(cryptedHash, _3); cryptedLength = zephir_fast_strlen_ev(cryptedHash); passwordLength = zephir_fast_strlen_ev(passwordHash); zephir_concat_self(&cryptedHash, passwordHash TSRMLS_CC); sum = (cryptedLength - passwordLength); for (_4 = 0; _4 < Z_STRLEN_P(passwordHash); _4++) { i = _4; ch = ZEPHIR_STRING_OFFSET(passwordHash, _4); _5 = ZEPHIR_STRING_OFFSET(cryptedHash, i); sum = (sum | ((_5 ^ ch))); } RETURN_MM_BOOL(0 == sum); }
/** * Checks a plain text password and its hash version to check if the password matches */ PHP_METHOD(Phalcon_Security, checkHash) { unsigned char _4$$5; zend_bool _0$$3; long _3; char ch = 0; int maxPassLength, ZEPHIR_LAST_CALL_STATUS, i = 0, sum = 0, cryptedLength = 0, passwordLength = 0; zval *password_param = NULL, *passwordHash_param = NULL, *maxPassLength_param = NULL, *_1 = NULL; zval *password = NULL, *passwordHash = NULL, *cryptedHash = NULL, *_2 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &password_param, &passwordHash_param, &maxPassLength_param); zephir_get_strval(password, password_param); zephir_get_strval(passwordHash, passwordHash_param); if (!maxPassLength_param) { maxPassLength = 0; } else { maxPassLength = zephir_get_intval(maxPassLength_param); } if (maxPassLength) { _0$$3 = maxPassLength > 0; if (_0$$3) { _0$$3 = zephir_fast_strlen_ev(password) > maxPassLength; } if (_0$$3) { RETURN_MM_BOOL(0); } } ZEPHIR_CALL_FUNCTION(&_1, "crypt", NULL, 396, password, passwordHash); zephir_check_call_status(); zephir_get_strval(_2, _1); ZEPHIR_CPY_WRT(cryptedHash, _2); cryptedLength = zephir_fast_strlen_ev(cryptedHash); passwordLength = zephir_fast_strlen_ev(passwordHash); zephir_concat_self(&cryptedHash, passwordHash TSRMLS_CC); sum = (cryptedLength - passwordLength); for (_3 = 0; _3 < Z_STRLEN_P(passwordHash); _3++) { i = _3; ch = ZEPHIR_STRING_OFFSET(passwordHash, _3); _4$$5 = ZEPHIR_STRING_OFFSET(cryptedHash, i); sum = (sum | ((_4$$5 ^ ch))); } RETURN_MM_BOOL(0 == sum); }
PHP_METHOD(Test_BuiltIn_CharMethods, getHexForString) { int ZEPHIR_LAST_CALL_STATUS; zephir_nts_static zephir_fcall_cache_entry *_5 = NULL; long _0; char ch; zval *str_param = NULL, *o, *_1 = NULL, _2 = zval_used_for_init, _3 = zval_used_for_init, *_4 = NULL; zval *str = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &str_param); zephir_get_strval(str, str_param); ZEPHIR_INIT_VAR(o); ZVAL_STRING(o, "", 1); for (_0 = 0; _0 < Z_STRLEN_P(str); _0++) { ch = ZEPHIR_STRING_OFFSET(str, _0); ZEPHIR_SINIT_NVAR(_2); ZVAL_STRING(&_2, "%X", 0); ZEPHIR_SINIT_NVAR(_3); ZVAL_LONG(&_3, ch); ZEPHIR_CALL_FUNCTION(&_4, "sprintf", &_5, &_2, &_3); zephir_check_call_status(); zephir_concat_self(&o, _4 TSRMLS_CC); } RETURN_CCTOR(o); }
PHP_METHOD(Yb_Std, normalCase) { long _0; zend_bool found, _1$$3, _2$$3, _3$$3, _4$$3; char c = 0; zval *from_param = NULL, *sep_param = NULL; zval *from = NULL, *sep = NULL, *to; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &from_param, &sep_param); zephir_get_strval(from, from_param); if (!sep_param) { ZEPHIR_INIT_VAR(sep); ZVAL_STRING(sep, "-", 1); } else { zephir_get_strval(sep, sep_param); } ZEPHIR_INIT_VAR(to); ZVAL_EMPTY_STRING(to); found = 0; for (_0 = 0; _0 < Z_STRLEN_P(from); _0++) { c = ZEPHIR_STRING_OFFSET(from, _0); _1$$3 = c >= '0'; if (_1$$3) { _1$$3 = c <= '9'; } _2$$3 = _1$$3; if (!(_2$$3)) { _3$$3 = c >= 'a'; if (_3$$3) { _3$$3 = c <= 'z'; } _2$$3 = _3$$3; } if (_2$$3) { zephir_concat_self_char(&to, c TSRMLS_CC); found = 1; continue; } _4$$3 = c >= 'A'; if (_4$$3) { _4$$3 = c <= 'Z'; } if (_4$$3) { if (found) { zephir_concat_self(&to, sep TSRMLS_CC); } c += 32; zephir_concat_self_char(&to, c TSRMLS_CC); found = 1; continue; } } RETURN_CTOR(to); }
PHP_METHOD(Yb_Std, sizeToBytes) { unsigned char _6$$3; int ZEPHIR_LAST_CALL_STATUS; zval *size_param = NULL, *match = NULL, *_0, *_1 = NULL, *_2, _3, *_4$$3, *_7$$4, *_8$$5, *_9$$6, *_10$$7; zval *size = NULL, *unit = NULL, *_5$$3 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &size_param); zephir_get_strval(size, size_param); ZEPHIR_INIT_VAR(match); ZVAL_NULL(match); ZEPHIR_INIT_VAR(_0); ZEPHIR_INIT_VAR(_2); zephir_fast_strtoupper(_2, size); ZEPHIR_SINIT_VAR(_3); ZVAL_STRING(&_3, "/^([\\d\\.]+)([KMGT])B?$/", 0); zephir_preg_match(_0, &_3, _2, match, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(_0)) { ZEPHIR_OBS_VAR(_4$$3); zephir_array_fetch_long(&_4$$3, match, 2, PH_NOISY, "yb/std.zep", 17 TSRMLS_CC); zephir_get_strval(_5$$3, _4$$3); ZEPHIR_CPY_WRT(unit, _5$$3); _6$$3 = ZEPHIR_STRING_OFFSET(unit, 0); do { if (_6$$3 == 'T') { ZEPHIR_OBS_VAR(_7$$4); zephir_array_fetch_long(&_7$$4, match, 1, PH_NOISY, "yb/std.zep", 20 TSRMLS_CC); RETURN_MM_DOUBLE((1099511627776.0 * zephir_get_doubleval(_7$$4))); } if (_6$$3 == 'G') { ZEPHIR_OBS_VAR(_8$$5); zephir_array_fetch_long(&_8$$5, match, 1, PH_NOISY, "yb/std.zep", 22 TSRMLS_CC); RETURN_MM_DOUBLE((1073741824.0 * zephir_get_doubleval(_8$$5))); } if (_6$$3 == 'M') { ZEPHIR_OBS_VAR(_9$$6); zephir_array_fetch_long(&_9$$6, match, 1, PH_NOISY, "yb/std.zep", 24 TSRMLS_CC); RETURN_MM_DOUBLE((1048576.0 * zephir_get_doubleval(_9$$6))); } if (_6$$3 == 'K') { ZEPHIR_OBS_VAR(_10$$7); zephir_array_fetch_long(&_10$$7, match, 1, PH_NOISY, "yb/std.zep", 26 TSRMLS_CC); RETURN_MM_DOUBLE((1024.0 * zephir_get_doubleval(_10$$7))); } } while(0); } ZEPHIR_RETURN_CALL_FUNCTION("floatval", NULL, 75, size); zephir_check_call_status(); RETURN_MM(); }
PHP_METHOD(Test_Flow, testFor39) { zval _2; long _1; char _0; int i = 0; ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "hello", 0); for (_1 = 0; _1 < Z_STRLEN_P(&_2); _1++) { _0 = ZEPHIR_STRING_OFFSET(&_2, _1); i++; } RETURN_LONG(i); }
PHP_METHOD(Test_Strings, strToHex) { unsigned char _1$$3; zend_long ZEPHIR_LAST_CALL_STATUS, i; zephir_fcall_cache_entry *_4 = NULL, *_6 = NULL; zval *value_param = NULL, _0, _2$$3, _3$$3, _5$$3; zval value, ret; zval *this_ptr = getThis(); ZVAL_UNDEF(&value); ZVAL_UNDEF(&ret); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &value_param); zephir_get_strval(&value, value_param); i = 0; ZEPHIR_INIT_VAR(&ret); ZVAL_STRING(&ret, ""); while (1) { if (!(i < zephir_fast_strlen_ev(&value))) { break; } _1$$3 = ZEPHIR_STRING_OFFSET(&value, i); ZEPHIR_INIT_NVAR(&_2$$3); ZVAL_STRINGL(&_2$$3, &_1$$3, 1); ZEPHIR_CALL_FUNCTION(&_3$$3, "ord", &_4, 78, &_2$$3); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_5$$3, "dechex", &_6, 10, &_3$$3); zephir_check_call_status(); zephir_concat_self(&ret, &_5$$3 TSRMLS_CC); i++; } RETURN_CTOR(&ret); }
PHP_METHOD(Test_Flow, testFor30) { int v, _0; zval *b; zval *a, *_1 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(a); array_init(a); ZEPHIR_INIT_VAR(b); ZVAL_STRING(b, "hello", 1); for (_0 = 0; _0 < Z_STRLEN_P(b); _0++) { v = ZEPHIR_STRING_OFFSET(b, _0); ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, v); zephir_array_append(&a, _1, PH_SEPARATE); } RETURN_CCTOR(a); }
PHP_METHOD(Test_Flow, testFor31) { int k, v, _0; zval *b; zval *a, *_1 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(a); array_init(a); ZEPHIR_INIT_VAR(b); ZVAL_STRING(b, "hello", 1); for (_0 = 0; _0 < Z_STRLEN_P(b); _0++) { k = _0; v = ZEPHIR_STRING_OFFSET(b, _0); ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, v); zephir_array_update_long(&a, k, &_1, PH_COPY | PH_SEPARATE, "test/flow.zep", 691); } RETURN_CCTOR(a); }
/** * Extracts parameters from a string * * @param string pattern * @return array|boolean */ PHP_METHOD(Phalcon_Cli_Router_Route, extractNamedParams) { long _0, _5$$11, _26$$19; zend_bool notValid = 0, _6$$12, _7$$12, _8$$12, _9$$12, _10$$12, _11$$12, _12$$12, _13$$12, _14$$12, _15$$12, _16$$12, _17$$12, _25$$18; int tmp = 0, cursor = 0, cursorVar = 0, marker = 0, bracketCount, parenthesesCount, foundPattern, intermediate, numberMatches; char ch = 0; zval *pattern_param = NULL, *matches = NULL, _1$$11 = zval_used_for_init, _2$$11 = zval_used_for_init, *_3$$11 = NULL, _18$$16 = zval_used_for_init, _19$$16 = zval_used_for_init, *_20$$16 = NULL, _22$$16 = zval_used_for_init, *_23$$16 = NULL, *_27$$19 = NULL, *_28$$28, *_29$$28 = NULL, *_30$$28 = NULL; zval *pattern = NULL, *route = NULL, *item = NULL, *variable = NULL, *regexp = NULL, *_4$$11 = NULL, *_21$$16 = NULL, *_24$$16 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &pattern_param); if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } bracketCount = 0; parenthesesCount = 0; foundPattern = 0; intermediate = 0; numberMatches = 0; if (zephir_fast_strlen_ev(pattern) <= 0) { RETURN_MM_BOOL(0); } ZEPHIR_INIT_VAR(matches); array_init(matches); ZEPHIR_INIT_VAR(route); ZVAL_EMPTY_STRING(route); for (_0 = 0; _0 < Z_STRLEN_P(pattern); _0++) { cursor = _0; ch = ZEPHIR_STRING_OFFSET(pattern, _0); if (parenthesesCount == 0) { if (ch == '{') { if (bracketCount == 0) { marker = (cursor + 1); intermediate = 0; notValid = 0; } bracketCount++; } else { if (ch == '}') { bracketCount--; if (intermediate > 0) { if (bracketCount == 0) { numberMatches++; ZEPHIR_INIT_NVAR(variable); ZVAL_EMPTY_STRING(variable); ZEPHIR_INIT_NVAR(regexp); ZVAL_EMPTY_STRING(regexp); ZEPHIR_SINIT_NVAR(_1$$11); ZVAL_LONG(&_1$$11, marker); ZEPHIR_SINIT_NVAR(_2$$11); ZVAL_LONG(&_2$$11, (cursor - marker)); ZEPHIR_INIT_NVAR(_3$$11); zephir_substr(_3$$11, pattern, zephir_get_intval(&_1$$11), zephir_get_intval(&_2$$11), 0); zephir_get_strval(_4$$11, _3$$11); ZEPHIR_CPY_WRT(item, _4$$11); for (_5$$11 = 0; _5$$11 < Z_STRLEN_P(item); _5$$11++) { cursorVar = _5$$11; ch = ZEPHIR_STRING_OFFSET(item, _5$$11); if (ch == '\0') { break; } _6$$12 = cursorVar == 0; if (_6$$12) { _7$$12 = ch >= 'a'; if (_7$$12) { _7$$12 = ch <= 'z'; } _8$$12 = _7$$12; if (!(_8$$12)) { _9$$12 = ch >= 'A'; if (_9$$12) { _9$$12 = ch <= 'Z'; } _8$$12 = _9$$12; } _6$$12 = !(_8$$12); } if (_6$$12) { notValid = 1; break; } _10$$12 = ch >= 'a'; if (_10$$12) { _10$$12 = ch <= 'z'; } _11$$12 = _10$$12; if (!(_11$$12)) { _12$$12 = ch >= 'A'; if (_12$$12) { _12$$12 = ch <= 'Z'; } _11$$12 = _12$$12; } _13$$12 = _11$$12; if (!(_13$$12)) { _14$$12 = ch >= '0'; if (_14$$12) { _14$$12 = ch <= '9'; } _13$$12 = _14$$12; } _15$$12 = _13$$12; if (!(_15$$12)) { _15$$12 = ch == '-'; } _16$$12 = _15$$12; if (!(_16$$12)) { _16$$12 = ch == '_'; } _17$$12 = _16$$12; if (!(_17$$12)) { _17$$12 = ch == ':'; } if (_17$$12) { if (ch == ':') { ZEPHIR_SINIT_NVAR(_18$$16); ZVAL_LONG(&_18$$16, 0); ZEPHIR_SINIT_NVAR(_19$$16); ZVAL_LONG(&_19$$16, cursorVar); ZEPHIR_INIT_NVAR(_20$$16); zephir_substr(_20$$16, item, 0 , zephir_get_intval(&_19$$16), 0); zephir_get_strval(_21$$16, _20$$16); ZEPHIR_CPY_WRT(variable, _21$$16); ZEPHIR_SINIT_NVAR(_22$$16); ZVAL_LONG(&_22$$16, (cursorVar + 1)); ZEPHIR_INIT_NVAR(_23$$16); zephir_substr(_23$$16, item, zephir_get_intval(&_22$$16), 0, ZEPHIR_SUBSTR_NO_LENGTH); zephir_get_strval(_24$$16, _23$$16); ZEPHIR_CPY_WRT(regexp, _24$$16); break; } } else { notValid = 1; break; } } if (!(notValid)) { tmp = numberMatches; _25$$18 = zephir_is_true(variable); if (_25$$18) { _25$$18 = zephir_is_true(regexp); } if (_25$$18) { foundPattern = 0; for (_26$$19 = 0; _26$$19 < Z_STRLEN_P(regexp); _26$$19++) { ch = ZEPHIR_STRING_OFFSET(regexp, _26$$19); if (ch == '\0') { break; } if (!(foundPattern)) { if (ch == '(') { foundPattern = 1; } } else { if (ch == ')') { foundPattern = 2; break; } } } if (foundPattern != 2) { zephir_concat_self_str(&route, "(", sizeof("(")-1 TSRMLS_CC); zephir_concat_self(&route, regexp TSRMLS_CC); zephir_concat_self_str(&route, ")", sizeof(")")-1 TSRMLS_CC); } else { zephir_concat_self(&route, regexp TSRMLS_CC); } ZEPHIR_INIT_NVAR(_27$$19); ZVAL_LONG(_27$$19, tmp); zephir_array_update_zval(&matches, variable, &_27$$19, PH_COPY | PH_SEPARATE); } else { _28$$28 = zephir_fetch_nproperty_this(this_ptr, SL("_delimiter"), PH_NOISY_CC); ZEPHIR_INIT_LNVAR(_29$$28); ZEPHIR_CONCAT_SVS(_29$$28, "([^", _28$$28, "]*)"); zephir_concat_self(&route, _29$$28 TSRMLS_CC); ZEPHIR_INIT_NVAR(_30$$28); ZVAL_LONG(_30$$28, tmp); zephir_array_update_zval(&matches, item, &_30$$28, PH_COPY | PH_SEPARATE); } } else { zephir_concat_self_str(&route, "{", sizeof("{")-1 TSRMLS_CC); zephir_concat_self(&route, item TSRMLS_CC); zephir_concat_self_str(&route, "}", sizeof("}")-1 TSRMLS_CC); } continue; } } } } } if (bracketCount == 0) { if (ch == '(') { parenthesesCount++; } else { if (ch == ')') { parenthesesCount--; if (parenthesesCount == 0) { numberMatches++; } } } } if (bracketCount > 0) { intermediate++; } else { zephir_concat_self_char(&route, ch TSRMLS_CC); } } zephir_create_array(return_value, 2, 0 TSRMLS_CC); zephir_array_fast_append(return_value, route); zephir_array_fast_append(return_value, matches); RETURN_MM(); }
PHP_METHOD(Yb_Std, camelCase) { long _0; zend_bool found, upper, _1$$3, _2$$3, _3$$3; char c = 0; zval *from_param = NULL; zval *from = NULL, *to; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &from_param); zephir_get_strval(from, from_param); ZEPHIR_INIT_VAR(to); ZVAL_EMPTY_STRING(to); found = 0; upper = 0; for (_0 = 0; _0 < Z_STRLEN_P(from); _0++) { c = ZEPHIR_STRING_OFFSET(from, _0); _1$$3 = c >= '0'; if (_1$$3) { _1$$3 = c <= '9'; } if (_1$$3) { if (found) { zephir_concat_self_char(&to, c TSRMLS_CC); } continue; } _2$$3 = c >= 'a'; if (_2$$3) { _2$$3 = c <= 'z'; } if (_2$$3) { if (upper) { upper = 0; c -= 32; } zephir_concat_self_char(&to, c TSRMLS_CC); found = 1; continue; } _3$$3 = c >= 'A'; if (_3$$3) { _3$$3 = c <= 'Z'; } if (_3$$3) { if (upper) { upper = 0; } else { c += 32; } zephir_concat_self_char(&to, c TSRMLS_CC); found = 1; continue; } if (found) { upper = 1; } } RETURN_CTOR(to); }
/** * Extracts parameters from a string * * @param string pattern */ PHP_METHOD(Test_Router_Route, extractNamedParams) { zephir_nts_static zephir_fcall_cache_entry *_4 = NULL; long _0, _6, _23; zend_bool notValid = 0, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18; int tmp, cursor, cursorVar, marker, bracketCount = 0, parenthesesCount = 0, foundPattern = 0, intermediate = 0, numberMatches = 0, ZEPHIR_LAST_CALL_STATUS; char ch; zval *pattern_param = NULL, *matches, _1 = zval_used_for_init, _2 = zval_used_for_init, *_3 = NULL, *_19 = NULL, *_21 = NULL, *_24 = NULL; zval *pattern = NULL, *route, *item = NULL, *variable = NULL, *regexp = NULL, *_5 = NULL, *_20 = NULL, *_22 = NULL, *_25 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &pattern_param); zephir_get_strval(pattern, pattern_param); if (zephir_fast_strlen_ev(pattern) <= 0) { RETURN_MM_BOOL(0); } ZEPHIR_INIT_VAR(matches); array_init(matches); ZEPHIR_INIT_VAR(route); ZVAL_EMPTY_STRING(route); for (_0 = 0; _0 < Z_STRLEN_P(pattern); _0++) { cursor = _0; ch = ZEPHIR_STRING_OFFSET(pattern, _0); if (parenthesesCount == 0) { if (ch == '{') { if (bracketCount == 0) { marker = (cursor + 1); intermediate = 0; notValid = 0; } bracketCount++; } else { if (ch == '}') { bracketCount--; if (intermediate > 0) { if (bracketCount == 0) { numberMatches++; ZEPHIR_INIT_NVAR(variable); ZVAL_EMPTY_STRING(variable); ZEPHIR_INIT_NVAR(regexp); ZVAL_EMPTY_STRING(regexp); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, marker); ZEPHIR_SINIT_NVAR(_2); ZVAL_LONG(&_2, (cursor - marker)); ZEPHIR_CALL_FUNCTION(&_3, "substr", &_4, pattern, &_1, &_2); zephir_check_call_status(); zephir_get_strval(_5, _3); ZEPHIR_CPY_WRT(item, _5); for (_6 = 0; _6 < Z_STRLEN_P(item); _6++) { cursorVar = _6; ch = ZEPHIR_STRING_OFFSET(item, _6); if (ch == '\0') { break; } _7 = cursorVar == 0; if (_7) { _8 = ch >= 'a'; if (_8) { _8 = ch <= 'z'; } _9 = _8; if (!(_9)) { _10 = ch >= 'A'; if (_10) { _10 = ch <= 'Z'; } _9 = _10; } _7 = !_9; } if (_7) { notValid = 1; break; } _11 = ch >= 'a'; if (_11) { _11 = ch <= 'z'; } _12 = _11; if (!(_12)) { _13 = ch >= 'A'; if (_13) { _13 = ch <= 'Z'; } _12 = _13; } _14 = _12; if (!(_14)) { _15 = ch >= '0'; if (_15) { _15 = ch <= '9'; } _14 = _15; } _16 = _14; if (!(_16)) { _16 = ch == '-'; } _17 = _16; if (!(_17)) { _17 = ch == '_'; } _18 = _17; if (!(_18)) { _18 = ch == ':'; } if (_18) { if (ch == ':') { ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, 0); ZEPHIR_SINIT_NVAR(_2); ZVAL_LONG(&_2, cursorVar); ZEPHIR_CALL_FUNCTION(&_19, "substr", &_4, item, &_1, &_2); zephir_check_call_status(); zephir_get_strval(_20, _19); ZEPHIR_CPY_WRT(variable, _20); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, (cursorVar + 1)); ZEPHIR_CALL_FUNCTION(&_21, "substr", &_4, item, &_1); zephir_check_call_status(); zephir_get_strval(_22, _21); ZEPHIR_CPY_WRT(regexp, _22); break; } } else { notValid = 1; break; } } if (!(notValid)) { tmp = numberMatches; _7 = zephir_is_true(variable); if (_7) { _7 = zephir_is_true(regexp); } if (_7) { foundPattern = 0; for (_23 = 0; _23 < Z_STRLEN_P(regexp); _23++) { ch = ZEPHIR_STRING_OFFSET(regexp, _23); if (ch == '\0') { break; } if (!(foundPattern)) { if (ch == '(') { foundPattern = 1; } } else { if (ch == ')') { foundPattern = 2; break; } } } if (foundPattern != 2) { zephir_concat_self_str(&route, "(", sizeof("(")-1 TSRMLS_CC); zephir_concat_self(&route, regexp TSRMLS_CC); zephir_concat_self_str(&route, ")", sizeof(")")-1 TSRMLS_CC); } else { zephir_concat_self(&route, regexp TSRMLS_CC); } ZEPHIR_INIT_NVAR(_24); ZVAL_LONG(_24, tmp); zephir_array_update_zval(&matches, variable, &_24, PH_COPY | PH_SEPARATE); } else { zephir_concat_self_str(&route, "([^/]*)", sizeof("([^/]*)")-1 TSRMLS_CC); ZEPHIR_INIT_NVAR(_24); ZVAL_LONG(_24, tmp); zephir_array_update_zval(&matches, item, &_24, PH_COPY | PH_SEPARATE); } } else { ZEPHIR_INIT_LNVAR(_25); ZEPHIR_CONCAT_SVS(_25, "{", item, "}"); zephir_concat_self(&route, _25 TSRMLS_CC); } continue; } } } } } if (bracketCount == 0) { if (ch == '(') { parenthesesCount++; } else { if (ch == ')') { parenthesesCount--; if (parenthesesCount == 0) { numberMatches++; } } } } if (bracketCount > 0) { intermediate++; } else { zephir_concat_self_char(&route, ch TSRMLS_CC); } } array_init_size(return_value, 3); zephir_array_fast_append(return_value, route); zephir_array_fast_append(return_value, matches); RETURN_MM(); }
/** * Generates a URL * *<code> * // Generate a URL appending the URI to the base URI * echo $url->get("products/edit/1"); * * // Generate a URL for a predefined route * echo $url->get( * [ * "for" => "blog-post", * "title" => "some-cool-stuff", * "year" => "2015", * ] * ); * * // Generate a URL with GET arguments (/show/products?id=1&name=Carrots) * echo $url->get( * "show/products", * [ * "id" => 1, * "name" => "Carrots", * ] * ); * * // Generate an absolute URL by setting the third parameter as false. * echo $url->get( * "https://phalconphp.com/", * null, * false * ); *</code> */ PHP_METHOD(Phalcon_Mvc_Url, get) { unsigned char _17$$14, _19$$14, _24$$16; zend_bool _0$$3, _1$$3, _15$$14, _16$$14, _18$$14, _22$$16, _23$$16, _25$$19; zval *strUri = NULL, *_14$$14 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *uri = NULL, *args = NULL, *local = NULL, *baseUri = NULL, *router = NULL, *dependencyInjector = NULL, *routeName = NULL, *route = NULL, *queryString = NULL, *_2$$4, *_3$$4, _4$$4, *_5$$9, *_9$$9 = NULL, *_12$$9, *_13$$9 = NULL, *_6$$11, *_7$$11 = NULL, *_8$$11, *_10$$13, *_11$$13, _20$$15, *_21$$15, _26$$20, *_27$$20, *_28$$21, *_29$$22; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 4, &uri, &args, &local, &baseUri); if (!uri) { ZEPHIR_CPY_WRT(uri, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(uri); } if (!args) { args = ZEPHIR_GLOBAL(global_null); } if (!local) { ZEPHIR_CPY_WRT(local, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(local); } if (!baseUri) { ZEPHIR_CPY_WRT(baseUri, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(baseUri); } if (Z_TYPE_P(local) == IS_NULL) { _0$$3 = Z_TYPE_P(uri) == IS_STRING; if (_0$$3) { _1$$3 = zephir_memnstr_str(uri, SL("//"), "phalcon/mvc/url.zep", 208); if (!(_1$$3)) { _1$$3 = zephir_memnstr_str(uri, SL(":"), "phalcon/mvc/url.zep", 208); } _0$$3 = _1$$3; } if (_0$$3) { ZEPHIR_INIT_VAR(_2$$4); ZEPHIR_INIT_VAR(_3$$4); ZEPHIR_SINIT_VAR(_4$$4); ZVAL_STRING(&_4$$4, "#^((//)|([a-z0-9]+://)|([a-z0-9]+:))#i", 0); zephir_preg_match(_3$$4, &_4$$4, uri, _2$$4, 0, 0 , 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(local); if (zephir_is_true(_3$$4)) { ZVAL_BOOL(local, 0); } else { ZVAL_BOOL(local, 1); } } else { ZEPHIR_INIT_NVAR(local); ZVAL_BOOL(local, 1); } } if (Z_TYPE_P(baseUri) != IS_STRING) { ZEPHIR_CALL_METHOD(&baseUri, this_ptr, "getbaseuri", NULL, 0); zephir_check_call_status(); } if (Z_TYPE_P(uri) == IS_ARRAY) { ZEPHIR_OBS_VAR(routeName); if (!(zephir_array_isset_string_fetch(&routeName, uri, SS("for"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_url_exception_ce, "It's necessary to define the route name with the parameter 'for'", "phalcon/mvc/url.zep", 226); return; } _5$$9 = zephir_fetch_nproperty_this(this_ptr, SL("_router"), PH_NOISY_CC); ZEPHIR_CPY_WRT(router, _5$$9); if (Z_TYPE_P(router) != IS_OBJECT) { _6$$11 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _6$$11); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_url_exception_ce, "A dependency injector container is required to obtain the 'router' service", "phalcon/mvc/url.zep", 238); return; } ZEPHIR_INIT_VAR(_8$$11); ZVAL_STRING(_8$$11, "router", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_7$$11, dependencyInjector, "getshared", NULL, 0, _8$$11); zephir_check_temp_parameter(_8$$11); zephir_check_call_status(); ZEPHIR_CPY_WRT(router, _7$$11); zephir_update_property_this(getThis(), SL("_router"), router TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_9$$9, router, "getroutebyname", NULL, 0, routeName); zephir_check_call_status(); ZEPHIR_CPY_WRT(route, _9$$9); if (Z_TYPE_P(route) != IS_OBJECT) { ZEPHIR_INIT_VAR(_10$$13); object_init_ex(_10$$13, phalcon_mvc_url_exception_ce); ZEPHIR_INIT_VAR(_11$$13); ZEPHIR_CONCAT_SVS(_11$$13, "Cannot obtain a route using the name '", routeName, "'"); ZEPHIR_CALL_METHOD(NULL, _10$$13, "__construct", NULL, 9, _11$$13); zephir_check_call_status(); zephir_throw_exception_debug(_10$$13, "phalcon/mvc/url.zep", 250 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(_12$$9); ZEPHIR_CALL_METHOD(&_9$$9, route, "getpattern", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_13$$9, route, "getreversedpaths", NULL, 0); zephir_check_call_status(); phalcon_replace_paths(_12$$9, _9$$9, _13$$9, uri TSRMLS_CC); ZEPHIR_CPY_WRT(uri, _12$$9); } if (zephir_is_true(local)) { zephir_get_strval(_14$$14, uri); ZEPHIR_CPY_WRT(strUri, _14$$14); _15$$14 = ZEPHIR_IS_STRING(baseUri, "/"); if (_15$$14) { _15$$14 = zephir_fast_strlen_ev(strUri) > 2; } _16$$14 = _15$$14; if (_16$$14) { _17$$14 = ZEPHIR_STRING_OFFSET(strUri, 0); _16$$14 = _17$$14 == '/'; } _18$$14 = _16$$14; if (_18$$14) { _19$$14 = ZEPHIR_STRING_OFFSET(strUri, 1); _18$$14 = _19$$14 != '/'; } if (_18$$14) { ZEPHIR_SINIT_VAR(_20$$15); ZVAL_LONG(&_20$$15, 1); ZEPHIR_INIT_VAR(_21$$15); zephir_substr(_21$$15, strUri, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); ZEPHIR_INIT_NVAR(uri); ZEPHIR_CONCAT_VV(uri, baseUri, _21$$15); } else { _22$$16 = ZEPHIR_IS_STRING(baseUri, "/"); if (_22$$16) { _22$$16 = zephir_fast_strlen_ev(strUri) == 1; } _23$$16 = _22$$16; if (_23$$16) { _24$$16 = ZEPHIR_STRING_OFFSET(strUri, 0); _23$$16 = _24$$16 == '/'; } if (_23$$16) { ZEPHIR_CPY_WRT(uri, baseUri); } else { ZEPHIR_INIT_NVAR(uri); ZEPHIR_CONCAT_VV(uri, baseUri, strUri); } } } if (zephir_is_true(args)) { ZEPHIR_CALL_FUNCTION(&queryString, "http_build_query", NULL, 394, args); zephir_check_call_status(); _25$$19 = Z_TYPE_P(queryString) == IS_STRING; if (_25$$19) { _25$$19 = ((zephir_fast_strlen_ev(queryString)) ? 1 : 0); } if (_25$$19) { ZEPHIR_SINIT_VAR(_26$$20); ZVAL_STRING(&_26$$20, "?", 0); ZEPHIR_INIT_VAR(_27$$20); zephir_fast_strpos(_27$$20, uri, &_26$$20, 0 ); if (!ZEPHIR_IS_FALSE_IDENTICAL(_27$$20)) { ZEPHIR_INIT_VAR(_28$$21); ZEPHIR_CONCAT_SV(_28$$21, "&", queryString); zephir_concat_self(&uri, _28$$21 TSRMLS_CC); } else { ZEPHIR_INIT_VAR(_29$$22); ZEPHIR_CONCAT_SV(_29$$22, "?", queryString); zephir_concat_self(&uri, _29$$22 TSRMLS_CC); } } } RETVAL_ZVAL(uri, 1, 0); RETURN_MM(); }
/** * Generates a URL * *<code> * //Generate a URL appending the URI to the base URI * echo $url->get('products/edit/1'); * * //Generate a URL for a predefined route * echo $url->get(array('for' => 'blog-post', 'title' => 'some-cool-stuff', 'year' => '2015')); *</code> */ PHP_METHOD(Phalcon_Mvc_Url, get) { unsigned char _10, _12; int ZEPHIR_LAST_CALL_STATUS; zend_bool _0, _1, _11; zval *strUri = NULL, *_9 = NULL; zval *uri = NULL, *args = NULL, *local = NULL, *baseUri = NULL, *router = NULL, *dependencyInjector = NULL, *routeName, *route = NULL, *queryString = NULL, *_2, *_3 = NULL, _4 = zval_used_for_init, *_5, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_13; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 4, &uri, &args, &local, &baseUri); if (!uri) { ZEPHIR_CPY_WRT(uri, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(uri); } if (!args) { args = ZEPHIR_GLOBAL(global_null); } if (!local) { ZEPHIR_CPY_WRT(local, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(local); } if (!baseUri) { ZEPHIR_CPY_WRT(baseUri, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(baseUri); } if (Z_TYPE_P(local) == IS_NULL) { _0 = Z_TYPE_P(uri) == IS_STRING; if (_0) { _1 = zephir_memnstr_str(uri, SL("//"), "phalcon/mvc/url.zep", 181); if (!(_1)) { _1 = zephir_memnstr_str(uri, SL(":"), "phalcon/mvc/url.zep", 181); } _0 = _1; } if (_0) { ZEPHIR_INIT_VAR(_2); ZEPHIR_INIT_VAR(_3); ZEPHIR_SINIT_VAR(_4); ZVAL_STRING(&_4, "#^(//)|([a-z0-9]+://)|([a-z0-9]+:)#i", 0); zephir_preg_match(_3, &_4, uri, _2, 0, 0 , 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(local); if (zephir_is_true(_3)) { ZVAL_BOOL(local, 0); } else { ZVAL_BOOL(local, 1); } } else { ZEPHIR_INIT_NVAR(local); ZVAL_BOOL(local, 1); } } if (Z_TYPE_P(baseUri) != IS_STRING) { ZEPHIR_CALL_METHOD(&baseUri, this_ptr, "getbaseuri", NULL, 0); zephir_check_call_status(); } if (Z_TYPE_P(uri) == IS_ARRAY) { ZEPHIR_OBS_VAR(routeName); if (!(zephir_array_isset_string_fetch(&routeName, uri, SS("for"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_url_exception_ce, "It's necessary to define the route name with the parameter 'for'", "phalcon/mvc/url.zep", 199); return; } _5 = zephir_fetch_nproperty_this(this_ptr, SL("_router"), PH_NOISY_CC); ZEPHIR_CPY_WRT(router, _5); if (Z_TYPE_P(router) != IS_OBJECT) { _5 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _5); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_url_exception_ce, "A dependency injector container is required to obtain the 'router' service", "phalcon/mvc/url.zep", 211); return; } ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "router", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_6, dependencyInjector, "getshared", NULL, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); ZEPHIR_CPY_WRT(router, _6); zephir_update_property_this(this_ptr, SL("_router"), router TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_6, router, "getroutebyname", NULL, 0, routeName); zephir_check_call_status(); ZEPHIR_CPY_WRT(route, _6); if (Z_TYPE_P(route) != IS_OBJECT) { ZEPHIR_INIT_NVAR(_3); object_init_ex(_3, phalcon_mvc_url_exception_ce); ZEPHIR_INIT_VAR(_7); ZEPHIR_CONCAT_SVS(_7, "Cannot obtain a route using the name '", routeName, "'"); ZEPHIR_CALL_METHOD(NULL, _3, "__construct", NULL, 9, _7); zephir_check_call_status(); zephir_throw_exception_debug(_3, "phalcon/mvc/url.zep", 223 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_NVAR(_3); ZEPHIR_CALL_METHOD(&_6, route, "getpattern", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_8, route, "getreversedpaths", NULL, 0); zephir_check_call_status(); phalcon_replace_paths(_3, _6, _8, uri TSRMLS_CC); ZEPHIR_CPY_WRT(uri, _3); } if (zephir_is_true(local)) { zephir_get_strval(_9, uri); ZEPHIR_CPY_WRT(strUri, _9); _0 = ZEPHIR_IS_STRING(baseUri, "/"); if (_0) { _0 = zephir_fast_strlen_ev(strUri) > 2; } _1 = _0; if (_1) { _10 = ZEPHIR_STRING_OFFSET(strUri, 0); _1 = _10 == '/'; } _11 = _1; if (_11) { _12 = ZEPHIR_STRING_OFFSET(strUri, 1); _11 = _12 != '/'; } ZEPHIR_INIT_NVAR(uri); if (_11) { ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, 1); ZEPHIR_INIT_NVAR(_3); zephir_substr(_3, strUri, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); ZEPHIR_CONCAT_VV(uri, baseUri, _3); } else { ZEPHIR_CONCAT_VV(uri, baseUri, strUri); } } if (zephir_is_true(args)) { ZEPHIR_CALL_FUNCTION(&queryString, "http_build_query", NULL, 369, args); zephir_check_call_status(); _0 = Z_TYPE_P(queryString) == IS_STRING; if (_0) { _0 = (zephir_fast_strlen_ev(queryString)) ? 1 : 0; } if (_0) { ZEPHIR_SINIT_NVAR(_4); ZVAL_STRING(&_4, "?", 0); ZEPHIR_INIT_NVAR(_3); zephir_fast_strpos(_3, uri, &_4, 0 ); if (!ZEPHIR_IS_FALSE_IDENTICAL(_3)) { ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SV(_7, "&", queryString); zephir_concat_self(&uri, _7 TSRMLS_CC); } else { ZEPHIR_INIT_VAR(_13); ZEPHIR_CONCAT_SV(_13, "?", queryString); zephir_concat_self(&uri, _13 TSRMLS_CC); } } } RETVAL_ZVAL(uri, 1, 0); RETURN_MM(); }
/** * Removes padding @a padding_type from @a text * If the function detects that the text was not padded, it will return it unmodified * * @param return_value Result, possibly unpadded * @param text Message to be unpadded * @param mode Encryption mode; unpadding is applied only in CBC or ECB mode * @param block_size Cipher block size * @param padding_type Padding scheme */ PHP_METHOD(Phalcon_Crypt, _cryptUnpadText) { unsigned char _14, _16; zephir_nts_static zephir_fcall_cache_entry *_6 = NULL, *_9 = NULL, *_11 = NULL; zend_bool _0, _1, _2, _13, _15; long length; int blockSize, paddingType, i, paddingSize = 0, ord, ZEPHIR_LAST_CALL_STATUS; zval *text_param = NULL, *mode_param = NULL, *blockSize_param = NULL, *paddingType_param = NULL, *padding = NULL, *last = NULL, _3 = zval_used_for_init, _4 = zval_used_for_init, *_5 = NULL, _7 = zval_used_for_init, *_8 = NULL, *_10 = NULL, *_12 = NULL; zval *text = NULL, *mode = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &text_param, &mode_param, &blockSize_param, &paddingType_param); 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 (unlikely(Z_TYPE_P(mode_param) != IS_STRING && Z_TYPE_P(mode_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'mode' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(mode_param) == IS_STRING)) { zephir_get_strval(mode, mode_param); } else { ZEPHIR_INIT_VAR(mode); ZVAL_EMPTY_STRING(mode); } if (unlikely(Z_TYPE_P(blockSize_param) != IS_LONG)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'blockSize' must be a long/integer") TSRMLS_CC); RETURN_MM_NULL(); } blockSize = Z_LVAL_P(blockSize_param); if (unlikely(Z_TYPE_P(paddingType_param) != IS_LONG)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'paddingType' must be a long/integer") TSRMLS_CC); RETURN_MM_NULL(); } paddingType = Z_LVAL_P(paddingType_param); length = zephir_fast_strlen_ev(text); _0 = length > 0; if (_0) { _0 = (zephir_safe_mod_long_long(length, blockSize TSRMLS_CC) == 0); } _1 = _0; if (_1) { _2 = ZEPHIR_IS_STRING(mode, "cbc"); if (!(_2)) { _2 = ZEPHIR_IS_STRING(mode, "ecb"); } _1 = _2; } if (_1) { do { if (paddingType == 1) { ZEPHIR_SINIT_VAR(_3); ZVAL_LONG(&_3, (length - 1)); ZEPHIR_SINIT_VAR(_4); ZVAL_LONG(&_4, 1); ZEPHIR_INIT_VAR(last); zephir_substr(last, text, zephir_get_intval(&_3), 1 , 0); ZEPHIR_CALL_FUNCTION(&_5, "ord", &_6, last); zephir_check_call_status(); ord = zephir_get_intval(_5); if (ord <= blockSize) { paddingSize = ord; ZEPHIR_SINIT_VAR(_7); ZVAL_LONG(&_7, 0); ZEPHIR_CALL_FUNCTION(&_8, "chr", &_9, &_7); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_7); ZVAL_LONG(&_7, (paddingSize - 1)); ZEPHIR_CALL_FUNCTION(&_10, "str_repeat", &_11, _8, &_7); zephir_check_call_status(); ZEPHIR_INIT_VAR(padding); ZEPHIR_CONCAT_VV(padding, _10, last); ZEPHIR_SINIT_NVAR(_7); ZVAL_LONG(&_7, (length - paddingSize)); ZEPHIR_INIT_VAR(_12); zephir_substr(_12, text, zephir_get_intval(&_7), 0, ZEPHIR_SUBSTR_NO_LENGTH); if (!ZEPHIR_IS_EQUAL(_12, padding)) { paddingSize = 0; } } break; } if (paddingType == 2) { ZEPHIR_SINIT_NVAR(_3); ZVAL_LONG(&_3, (length - 1)); ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, 1); ZEPHIR_INIT_NVAR(last); zephir_substr(last, text, zephir_get_intval(&_3), 1 , 0); ZEPHIR_CALL_FUNCTION(&_5, "ord", &_6, last); zephir_check_call_status(); ord = zephir_get_intval(_5); if (ord <= blockSize) { paddingSize = ord; ZEPHIR_SINIT_NVAR(_7); ZVAL_LONG(&_7, paddingSize); ZEPHIR_CALL_FUNCTION(&_8, "chr", &_9, &_7); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_7); ZVAL_LONG(&_7, paddingSize); ZEPHIR_CALL_FUNCTION(&padding, "str_repeat", &_11, _8, &_7); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_7); ZVAL_LONG(&_7, (length - paddingSize)); ZEPHIR_INIT_NVAR(_12); zephir_substr(_12, text, zephir_get_intval(&_7), 0, ZEPHIR_SUBSTR_NO_LENGTH); if (!ZEPHIR_IS_EQUAL(_12, padding)) { paddingSize = 0; } } break; } if (paddingType == 3) { ZEPHIR_SINIT_NVAR(_3); ZVAL_LONG(&_3, (length - 1)); ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, 1); ZEPHIR_INIT_NVAR(last); zephir_substr(last, text, zephir_get_intval(&_3), 1 , 0); ZEPHIR_CALL_FUNCTION(&_5, "ord", &_6, last); zephir_check_call_status(); paddingSize = zephir_get_intval(_5); break; } if (paddingType == 4) { i = (length - 1); while (1) { _13 = i > 0; if (_13) { _14 = ZEPHIR_STRING_OFFSET(text, i); _13 = _14 == 0x00; } _15 = _13; if (_15) { _15 = paddingSize < blockSize; } if (!(_15)) { break; } paddingSize++; i--; } _16 = ZEPHIR_STRING_OFFSET(text, i); if (_16 == 0x80) { paddingSize++; } else { paddingSize = 0; } break; } if (paddingType == 5) { i = (length - 1); while (1) { _13 = i >= 0; if (_13) { _14 = ZEPHIR_STRING_OFFSET(text, i); _13 = _14 == 0x00; } _15 = _13; if (_15) { _15 = paddingSize <= blockSize; } if (!(_15)) { break; } paddingSize++; i--; } break; } if (paddingType == 6) { i = (length - 1); while (1) { _13 = i >= 0; if (_13) { _14 = ZEPHIR_STRING_OFFSET(text, i); _13 = _14 == 0x20; } _15 = _13; if (_15) { _15 = paddingSize <= blockSize; } if (!(_15)) { break; } paddingSize++; i--; } break; } break; } while(0); _13 = (paddingSize) ? 1 : 0; if (_13) { _13 = paddingSize <= blockSize; } if (_13) { if (paddingSize < length) { ZEPHIR_SINIT_NVAR(_3); ZVAL_LONG(&_3, 0); ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, (length - paddingSize)); zephir_substr(return_value, text, 0 , zephir_get_intval(&_4), 0); RETURN_MM(); } else { RETURN_MM_STRING("", 1); } } else { paddingSize = 0; } } if (!(paddingSize)) { RETURN_CTOR(text); } ZEPHIR_MM_RESTORE(); }
/** * Extracts parameters from a string */ PHP_METHOD(Phalcon_Mvc_Router_Route, extractNamedParams) { long _0, _5, _25; zend_bool notValid, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17; int tmp, cursor, cursorVar, marker, bracketCount = 0, parenthesesCount = 0, foundPattern = 0, intermediate = 0, numberMatches = 0; char ch; zval *pattern_param = NULL, *matches, _1 = zval_used_for_init, _2 = zval_used_for_init, *_3 = NULL, _18 = zval_used_for_init, _19 = zval_used_for_init, *_20 = NULL, _22 = zval_used_for_init, *_23 = NULL; zval *pattern = NULL, *route, *item = NULL, *variable = NULL, *regexp = NULL, *_4 = NULL, *_21 = NULL, *_24 = NULL, *_26 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &pattern_param); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (zephir_fast_strlen_ev(pattern) <= 0) { RETURN_MM_BOOL(0); } ZEPHIR_INIT_VAR(matches); array_init(matches); ZEPHIR_INIT_VAR(route); ZVAL_EMPTY_STRING(route); for (_0 = 0; _0 < Z_STRLEN_P(pattern); _0++) { cursor = _0; ch = ZEPHIR_STRING_OFFSET(pattern, _0); if (parenthesesCount == 0) { if (ch == '{') { if (bracketCount == 0) { marker = (cursor + 1); intermediate = 0; notValid = 0; } bracketCount++; } else { if (ch == '}') { bracketCount--; if (intermediate > 0) { if (bracketCount == 0) { numberMatches++; ZEPHIR_INIT_NVAR(variable); ZVAL_EMPTY_STRING(variable); ZEPHIR_INIT_NVAR(regexp); ZVAL_EMPTY_STRING(regexp); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, marker); ZEPHIR_SINIT_NVAR(_2); ZVAL_LONG(&_2, (cursor - marker)); ZEPHIR_INIT_NVAR(_3); zephir_substr(_3, pattern, zephir_get_intval(&_1), zephir_get_intval(&_2), 0); zephir_get_strval(_4, _3); ZEPHIR_CPY_WRT(item, _4); for (_5 = 0; _5 < Z_STRLEN_P(item); _5++) { cursorVar = _5; ch = ZEPHIR_STRING_OFFSET(item, _5); if (ch == '\0') { break; } _6 = cursorVar == 0; if (_6) { _7 = ch >= 'a'; if (_7) { _7 = ch <= 'z'; } _8 = _7; if (!(_8)) { _9 = ch >= 'A'; if (_9) { _9 = ch <= 'Z'; } _8 = _9; } _6 = !(_8); } if (_6) { notValid = 1; break; } _10 = ch >= 'a'; if (_10) { _10 = ch <= 'z'; } _11 = _10; if (!(_11)) { _12 = ch >= 'A'; if (_12) { _12 = ch <= 'Z'; } _11 = _12; } _13 = _11; if (!(_13)) { _14 = ch >= '0'; if (_14) { _14 = ch <= '9'; } _13 = _14; } _15 = _13; if (!(_15)) { _15 = ch == '-'; } _16 = _15; if (!(_16)) { _16 = ch == '_'; } _17 = _16; if (!(_17)) { _17 = ch == ':'; } if (_17) { if (ch == ':') { ZEPHIR_SINIT_NVAR(_18); ZVAL_LONG(&_18, 0); ZEPHIR_SINIT_NVAR(_19); ZVAL_LONG(&_19, cursorVar); ZEPHIR_INIT_NVAR(_20); zephir_substr(_20, item, 0 , zephir_get_intval(&_19), 0); zephir_get_strval(_21, _20); ZEPHIR_CPY_WRT(variable, _21); ZEPHIR_SINIT_NVAR(_22); ZVAL_LONG(&_22, (cursorVar + 1)); ZEPHIR_INIT_NVAR(_23); zephir_substr(_23, item, zephir_get_intval(&_22), 0, ZEPHIR_SUBSTR_NO_LENGTH); zephir_get_strval(_24, _23); ZEPHIR_CPY_WRT(regexp, _24); break; } } else { notValid = 1; break; } } if (!(notValid)) { tmp = numberMatches; _6 = zephir_is_true(variable); if (_6) { _6 = zephir_is_true(regexp); } if (_6) { foundPattern = 0; for (_25 = 0; _25 < Z_STRLEN_P(regexp); _25++) { ch = ZEPHIR_STRING_OFFSET(regexp, _25); if (ch == '\0') { break; } if (!(foundPattern)) { if (ch == '(') { foundPattern = 1; } } else { if (ch == ')') { foundPattern = 2; break; } } } if (foundPattern != 2) { ZEPHIR_INIT_LNVAR(_26); ZEPHIR_CONCAT_SVS(_26, "(", regexp, ")"); zephir_concat_self(&route, _26 TSRMLS_CC); } else { zephir_concat_self(&route, regexp TSRMLS_CC); } ZEPHIR_INIT_NVAR(_20); ZVAL_LONG(_20, tmp); zephir_array_update_zval(&matches, variable, &_20, PH_COPY | PH_SEPARATE); } else { zephir_concat_self_str(&route, "([^/]*)", sizeof("([^/]*)")-1 TSRMLS_CC); ZEPHIR_INIT_NVAR(_23); ZVAL_LONG(_23, tmp); zephir_array_update_zval(&matches, item, &_23, PH_COPY | PH_SEPARATE); } } else { ZEPHIR_INIT_LNVAR(_26); ZEPHIR_CONCAT_SVS(_26, "{", item, "}"); zephir_concat_self(&route, _26 TSRMLS_CC); } continue; } } } } } if (bracketCount == 0) { if (ch == '(') { parenthesesCount++; } else { if (ch == ')') { parenthesesCount--; if (parenthesesCount == 0) { numberMatches++; } } } } if (bracketCount > 0) { intermediate++; } else { zephir_concat_self_char(&route, ch TSRMLS_CC); } } zephir_create_array(return_value, 2, 0 TSRMLS_CC); zephir_array_fast_append(return_value, route); zephir_array_fast_append(return_value, matches); RETURN_MM(); }
/** * Removes padding @a padding_type from @a text * If the function detects that the text was not padded, it will return it unmodified * * @param string text Message to be unpadded * @param string mode Encryption mode; unpadding is applied only in CBC or ECB mode * @param int blockSize Cipher block size * @param int paddingType Padding scheme */ PHP_METHOD(Phalcon_Crypt, _cryptUnpadText) { unsigned char _23$$11, _25$$11, _27$$15, _30$$17; zend_bool _0, _1, _2, _22$$11, _24$$11, _26$$15, _28$$15, _29$$17, _31$$17, _32$$3; long length = 0; zephir_fcall_cache_entry *_6 = NULL, *_9 = NULL, *_11 = NULL; int blockSize, paddingType, ZEPHIR_LAST_CALL_STATUS, i = 0, paddingSize, ord = 0; zval *text_param = NULL, *mode_param = NULL, *blockSize_param = NULL, *paddingType_param = NULL, *padding = NULL, *last = NULL, _3$$4, _4$$4, *_5$$4 = NULL, _7$$5 = zval_used_for_init, *_8$$5 = NULL, *_10$$5 = NULL, *_12$$5, _13$$7, _14$$7, *_15$$7 = NULL, _16$$8 = zval_used_for_init, *_17$$8 = NULL, *_18$$8, _19$$10, _20$$10, *_21$$10 = NULL, _33$$21, _34$$21; zval *text = NULL, *mode = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &text_param, &mode_param, &blockSize_param, &paddingType_param); zephir_get_strval(text, text_param); if (unlikely(Z_TYPE_P(mode_param) != IS_STRING && Z_TYPE_P(mode_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'mode' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(mode_param) == IS_STRING)) { zephir_get_strval(mode, mode_param); } else { ZEPHIR_INIT_VAR(mode); ZVAL_EMPTY_STRING(mode); } if (unlikely(Z_TYPE_P(blockSize_param) != IS_LONG)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'blockSize' must be a int") TSRMLS_CC); RETURN_MM_NULL(); } blockSize = Z_LVAL_P(blockSize_param); if (unlikely(Z_TYPE_P(paddingType_param) != IS_LONG)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'paddingType' must be a int") TSRMLS_CC); RETURN_MM_NULL(); } paddingType = Z_LVAL_P(paddingType_param); paddingSize = 0; length = zephir_fast_strlen_ev(text); _0 = length > 0; if (_0) { _0 = (zephir_safe_mod_long_long(length, blockSize TSRMLS_CC) == 0); } _1 = _0; if (_1) { _2 = ZEPHIR_IS_STRING(mode, "cbc"); if (!(_2)) { _2 = ZEPHIR_IS_STRING(mode, "ecb"); } _1 = _2; } if (_1) { do { if (paddingType == 1) { ZEPHIR_SINIT_VAR(_3$$4); ZVAL_LONG(&_3$$4, (length - 1)); ZEPHIR_SINIT_VAR(_4$$4); ZVAL_LONG(&_4$$4, 1); ZEPHIR_INIT_VAR(last); zephir_substr(last, text, zephir_get_intval(&_3$$4), 1 , 0); ZEPHIR_CALL_FUNCTION(&_5$$4, "ord", &_6, 134, last); zephir_check_call_status(); ord = zephir_get_intval(_5$$4); if (ord <= blockSize) { paddingSize = ord; ZEPHIR_SINIT_VAR(_7$$5); ZVAL_LONG(&_7$$5, 0); ZEPHIR_CALL_FUNCTION(&_8$$5, "chr", &_9, 132, &_7$$5); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_7$$5); ZVAL_LONG(&_7$$5, (paddingSize - 1)); ZEPHIR_CALL_FUNCTION(&_10$$5, "str_repeat", &_11, 133, _8$$5, &_7$$5); zephir_check_call_status(); ZEPHIR_INIT_VAR(padding); ZEPHIR_CONCAT_VV(padding, _10$$5, last); ZEPHIR_SINIT_NVAR(_7$$5); ZVAL_LONG(&_7$$5, (length - paddingSize)); ZEPHIR_INIT_VAR(_12$$5); zephir_substr(_12$$5, text, zephir_get_intval(&_7$$5), 0, ZEPHIR_SUBSTR_NO_LENGTH); if (!ZEPHIR_IS_EQUAL(_12$$5, padding)) { paddingSize = 0; } } break; } if (paddingType == 2) { ZEPHIR_SINIT_VAR(_13$$7); ZVAL_LONG(&_13$$7, (length - 1)); ZEPHIR_SINIT_VAR(_14$$7); ZVAL_LONG(&_14$$7, 1); ZEPHIR_INIT_NVAR(last); zephir_substr(last, text, zephir_get_intval(&_13$$7), 1 , 0); ZEPHIR_CALL_FUNCTION(&_15$$7, "ord", &_6, 134, last); zephir_check_call_status(); ord = zephir_get_intval(_15$$7); if (ord <= blockSize) { paddingSize = ord; ZEPHIR_SINIT_VAR(_16$$8); ZVAL_LONG(&_16$$8, paddingSize); ZEPHIR_CALL_FUNCTION(&_17$$8, "chr", &_9, 132, &_16$$8); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_16$$8); ZVAL_LONG(&_16$$8, paddingSize); ZEPHIR_CALL_FUNCTION(&padding, "str_repeat", &_11, 133, _17$$8, &_16$$8); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_16$$8); ZVAL_LONG(&_16$$8, (length - paddingSize)); ZEPHIR_INIT_VAR(_18$$8); zephir_substr(_18$$8, text, zephir_get_intval(&_16$$8), 0, ZEPHIR_SUBSTR_NO_LENGTH); if (!ZEPHIR_IS_EQUAL(_18$$8, padding)) { paddingSize = 0; } } break; } if (paddingType == 3) { ZEPHIR_SINIT_VAR(_19$$10); ZVAL_LONG(&_19$$10, (length - 1)); ZEPHIR_SINIT_VAR(_20$$10); ZVAL_LONG(&_20$$10, 1); ZEPHIR_INIT_NVAR(last); zephir_substr(last, text, zephir_get_intval(&_19$$10), 1 , 0); ZEPHIR_CALL_FUNCTION(&_21$$10, "ord", &_6, 134, last); zephir_check_call_status(); paddingSize = zephir_get_intval(_21$$10); break; } if (paddingType == 4) { i = (length - 1); while (1) { _22$$11 = i > 0; if (_22$$11) { _23$$11 = ZEPHIR_STRING_OFFSET(text, i); _22$$11 = _23$$11 == 0x00; } _24$$11 = _22$$11; if (_24$$11) { _24$$11 = paddingSize < blockSize; } if (!(_24$$11)) { break; } paddingSize++; i--; } _25$$11 = ZEPHIR_STRING_OFFSET(text, i); if (_25$$11 == 0x80) { paddingSize++; } else { paddingSize = 0; } break; } if (paddingType == 5) { i = (length - 1); while (1) { _26$$15 = i >= 0; if (_26$$15) { _27$$15 = ZEPHIR_STRING_OFFSET(text, i); _26$$15 = _27$$15 == 0x00; } _28$$15 = _26$$15; if (_28$$15) { _28$$15 = paddingSize <= blockSize; } if (!(_28$$15)) { break; } paddingSize++; i--; } break; } if (paddingType == 6) { i = (length - 1); while (1) { _29$$17 = i >= 0; if (_29$$17) { _30$$17 = ZEPHIR_STRING_OFFSET(text, i); _29$$17 = _30$$17 == 0x20; } _31$$17 = _29$$17; if (_31$$17) { _31$$17 = paddingSize <= blockSize; } if (!(_31$$17)) { break; } paddingSize++; i--; } break; } break; } while(0); _32$$3 = (paddingSize) ? 1 : 0; if (_32$$3) { _32$$3 = paddingSize <= blockSize; } if (_32$$3) { if (paddingSize < length) { ZEPHIR_SINIT_VAR(_33$$21); ZVAL_LONG(&_33$$21, 0); ZEPHIR_SINIT_VAR(_34$$21); ZVAL_LONG(&_34$$21, (length - paddingSize)); zephir_substr(return_value, text, 0 , zephir_get_intval(&_34$$21), 0); RETURN_MM(); } RETURN_MM_STRING("", 1); } else { paddingSize = 0; } } if (!(paddingSize)) { RETURN_CTOR(text); } ZEPHIR_MM_RESTORE(); }
/** * Generates a URL * *<code> * // Generate a URL appending the URI to the base URI * echo $url->get("products/edit/1"); * * // Generate a URL for a predefined route * echo $url->get( * [ * "for" => "blog-post", * "title" => "some-cool-stuff", * "year" => "2015", * ] * ); * * // Generate a URL with GET arguments (/show/products?id=1&name=Carrots) * echo $url->get( * "show/products", * [ * "id" => 1, * "name" => "Carrots", * ] * ); * * // Generate an absolute URL by setting the third parameter as false. * echo $url->get( * "https://phalconphp.com/", * null, * false * ); *</code> */ PHP_METHOD(Phalcon_Mvc_Url, get) { unsigned char _20$$14, _22$$14, _27$$16; zval strUri, _15$$14; zend_long ZEPHIR_LAST_CALL_STATUS; zend_bool local, _0$$3, _1$$3, _18$$14, _19$$14, _21$$14, _25$$16, _26$$16, _28$$19; zval *uri = NULL, uri_sub, *args = NULL, args_sub, *local_param = NULL, *baseUri = NULL, baseUri_sub, __$null, router, dependencyInjector, routeName, route, queryString, _2$$4, _3$$4, _4$$4, _5$$4, _6$$9, _10$$9, _13$$9, _14$$9, _7$$11, _8$$11, _9$$11, _11$$13, _12$$13, _16$$14, _17$$14, _23$$15, _24$$15, _29$$20, _30$$20, _31$$21, _32$$22; zval *this_ptr = getThis(); ZVAL_UNDEF(&uri_sub); ZVAL_UNDEF(&args_sub); ZVAL_UNDEF(&baseUri_sub); ZVAL_NULL(&__$null); ZVAL_UNDEF(&router); ZVAL_UNDEF(&dependencyInjector); ZVAL_UNDEF(&routeName); ZVAL_UNDEF(&route); ZVAL_UNDEF(&queryString); ZVAL_UNDEF(&_2$$4); ZVAL_UNDEF(&_3$$4); ZVAL_UNDEF(&_4$$4); ZVAL_UNDEF(&_5$$4); ZVAL_UNDEF(&_6$$9); ZVAL_UNDEF(&_10$$9); ZVAL_UNDEF(&_13$$9); ZVAL_UNDEF(&_14$$9); ZVAL_UNDEF(&_7$$11); ZVAL_UNDEF(&_8$$11); ZVAL_UNDEF(&_9$$11); ZVAL_UNDEF(&_11$$13); ZVAL_UNDEF(&_12$$13); ZVAL_UNDEF(&_16$$14); ZVAL_UNDEF(&_17$$14); ZVAL_UNDEF(&_23$$15); ZVAL_UNDEF(&_24$$15); ZVAL_UNDEF(&_29$$20); ZVAL_UNDEF(&_30$$20); ZVAL_UNDEF(&_31$$21); ZVAL_UNDEF(&_32$$22); ZVAL_UNDEF(&strUri); ZVAL_UNDEF(&_15$$14); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 4, &uri, &args, &local_param, &baseUri); if (!uri) { uri = &uri_sub; ZEPHIR_CPY_WRT(uri, &__$null); } else { ZEPHIR_SEPARATE_PARAM(uri); } if (!args) { args = &args_sub; args = &__$null; } if (!local_param) { local = 0; } else { local = zephir_get_boolval(local_param); } if (!baseUri) { baseUri = &baseUri_sub; ZEPHIR_CPY_WRT(baseUri, &__$null); } else { ZEPHIR_SEPARATE_PARAM(baseUri); } if (local == 0) { _0$$3 = Z_TYPE_P(uri) == IS_STRING; if (_0$$3) { _1$$3 = zephir_memnstr_str(uri, SL("//"), "phalcon/mvc/url.zep", 103); if (!(_1$$3)) { _1$$3 = zephir_memnstr_str(uri, SL(":"), "phalcon/mvc/url.zep", 103); } _0$$3 = _1$$3; } if (_0$$3) { ZEPHIR_INIT_VAR(&_2$$4); ZEPHIR_INIT_VAR(&_3$$4); ZVAL_STRING(&_3$$4, "#^((//)|([a-z0-9]+://)|([a-z0-9]+:))#i"); ZEPHIR_INIT_VAR(&_4$$4); ZEPHIR_INIT_VAR(&_5$$4); ZVAL_STRING(&_5$$4, "#^((//)|([a-z0-9]+://)|([a-z0-9]+:))#i"); zephir_preg_match(&_4$$4, &_5$$4, uri, &_2$$4, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(&_4$$4)) { local = 0; } else { local = 1; } } else { local = 1; } } if (Z_TYPE_P(baseUri) != IS_STRING) { ZEPHIR_CALL_METHOD(baseUri, this_ptr, "getbaseuri", NULL, 0); zephir_check_call_status(); } if (Z_TYPE_P(uri) == IS_ARRAY) { ZEPHIR_OBS_VAR(&routeName); if (!(zephir_array_isset_string_fetch(&routeName, uri, SL("for"), 0))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_url_exception_ce, "It's necessary to define the route name with the parameter 'for'", "phalcon/mvc/url.zep", 121); return; } zephir_read_property(&_6$$9, this_ptr, SL("router"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CPY_WRT(&router, &_6$$9); if (Z_TYPE_P(&router) != IS_OBJECT) { zephir_read_property(&_7$$11, this_ptr, SL("container"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CPY_WRT(&dependencyInjector, &_7$$11); if (Z_TYPE_P(&dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_url_exception_ce, "A dependency injector container is required to obtain the 'router' service", "phalcon/mvc/url.zep", 133); return; } ZEPHIR_INIT_VAR(&_9$$11); ZVAL_STRING(&_9$$11, "router"); ZEPHIR_CALL_METHOD(&_8$$11, &dependencyInjector, "getshared", NULL, 0, &_9$$11); zephir_check_call_status(); ZEPHIR_CPY_WRT(&router, &_8$$11); zephir_update_property_zval(this_ptr, SL("router"), &router); } ZEPHIR_CALL_METHOD(&_10$$9, &router, "getroutebyname", NULL, 0, &routeName); zephir_check_call_status(); ZEPHIR_CPY_WRT(&route, &_10$$9); if (Z_TYPE_P(&route) != IS_OBJECT) { ZEPHIR_INIT_VAR(&_11$$13); object_init_ex(&_11$$13, phalcon_mvc_url_exception_ce); ZEPHIR_INIT_VAR(&_12$$13); ZEPHIR_CONCAT_SVS(&_12$$13, "Cannot obtain a route using the name '", &routeName, "'"); ZEPHIR_CALL_METHOD(NULL, &_11$$13, "__construct", NULL, 4, &_12$$13); zephir_check_call_status(); zephir_throw_exception_debug(&_11$$13, "phalcon/mvc/url.zep", 145 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&_13$$9); ZEPHIR_CALL_METHOD(&_10$$9, &route, "getpattern", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_14$$9, &route, "getreversedpaths", NULL, 0); zephir_check_call_status(); phalcon_replace_paths(&_13$$9, &_10$$9, &_14$$9, uri TSRMLS_CC); ZEPHIR_CPY_WRT(uri, &_13$$9); } if (local) { zephir_get_strval(&_15$$14, uri); ZEPHIR_CPY_WRT(&strUri, &_15$$14); ZVAL_LONG(&_16$$14, -1); ZEPHIR_INIT_VAR(&_17$$14); zephir_substr(&_17$$14, baseUri, -1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); _18$$14 = ZEPHIR_IS_STRING(&_17$$14, "/"); if (_18$$14) { _18$$14 = zephir_fast_strlen_ev(&strUri) > 2; } _19$$14 = _18$$14; if (_19$$14) { _20$$14 = ZEPHIR_STRING_OFFSET(&strUri, 0); _19$$14 = _20$$14 == '/'; } _21$$14 = _19$$14; if (_21$$14) { _22$$14 = ZEPHIR_STRING_OFFSET(&strUri, 1); _21$$14 = _22$$14 != '/'; } if (_21$$14) { ZVAL_LONG(&_23$$15, 1); ZEPHIR_INIT_VAR(&_24$$15); zephir_substr(&_24$$15, &strUri, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); ZEPHIR_INIT_NVAR(uri); ZEPHIR_CONCAT_VV(uri, baseUri, &_24$$15); } else { _25$$16 = ZEPHIR_IS_STRING(baseUri, "/"); if (_25$$16) { _25$$16 = zephir_fast_strlen_ev(&strUri) == 1; } _26$$16 = _25$$16; if (_26$$16) { _27$$16 = ZEPHIR_STRING_OFFSET(&strUri, 0); _26$$16 = _27$$16 == '/'; } if (_26$$16) { ZEPHIR_CPY_WRT(uri, baseUri); } else { ZEPHIR_INIT_NVAR(uri); ZEPHIR_CONCAT_VV(uri, baseUri, &strUri); } } } if (zephir_is_true(args)) { ZEPHIR_CALL_FUNCTION(&queryString, "http_build_query", NULL, 372, args); zephir_check_call_status(); _28$$19 = Z_TYPE_P(&queryString) == IS_STRING; if (_28$$19) { _28$$19 = ((zephir_fast_strlen_ev(&queryString)) ? 1 : 0); } if (_28$$19) { ZEPHIR_INIT_VAR(&_29$$20); ZVAL_STRING(&_29$$20, "?"); ZEPHIR_INIT_VAR(&_30$$20); zephir_fast_strpos(&_30$$20, uri, &_29$$20, 0 ); if (!ZEPHIR_IS_FALSE_IDENTICAL(&_30$$20)) { ZEPHIR_INIT_VAR(&_31$$21); ZEPHIR_CONCAT_SV(&_31$$21, "&", &queryString); zephir_concat_self(uri, &_31$$21 TSRMLS_CC); } else { ZEPHIR_INIT_VAR(&_32$$22); ZEPHIR_CONCAT_SV(&_32$$22, "?", &queryString); zephir_concat_self(uri, &_32$$22 TSRMLS_CC); } } } RETVAL_ZVAL(uri, 1, 0); RETURN_MM(); }
/** * Extracts parameters from a string * * @param string pattern */ PHP_METHOD(Test_Router_Route, extractNamedParams) { long _0, _5$$11, _26$$19; zend_bool notValid, _6$$12, _7$$12, _8$$12, _9$$12, _10$$12, _11$$12, _12$$12, _13$$12, _14$$12, _15$$12, _16$$12, _17$$12, _25$$18; int tmp = 0, cursor = 0, cursorVar = 0, marker = 0, bracketCount, parenthesesCount, foundPattern, intermediate, numberMatches; char ch = 0; zval *pattern_param = NULL, matches, _1$$11, _2$$11, _3$$11, _18$$16, _19$$16, _20$$16, _22$$16, _23$$16, _27$$19, _28$$28; zval pattern, route, item, variable, regexp, _4$$11, _21$$16, _24$$16, _29$$29; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&pattern); ZVAL_UNDEF(&route); ZVAL_UNDEF(&item); ZVAL_UNDEF(&variable); ZVAL_UNDEF(®exp); ZVAL_UNDEF(&_4$$11); ZVAL_UNDEF(&_21$$16); ZVAL_UNDEF(&_24$$16); ZVAL_UNDEF(&_29$$29); ZVAL_UNDEF(&matches); ZVAL_UNDEF(&_1$$11); ZVAL_UNDEF(&_2$$11); ZVAL_UNDEF(&_3$$11); ZVAL_UNDEF(&_18$$16); ZVAL_UNDEF(&_19$$16); ZVAL_UNDEF(&_20$$16); ZVAL_UNDEF(&_22$$16); ZVAL_UNDEF(&_23$$16); ZVAL_UNDEF(&_27$$19); ZVAL_UNDEF(&_28$$28); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &pattern_param); zephir_get_strval(&pattern, pattern_param); notValid = 0; bracketCount = 0; parenthesesCount = 0; foundPattern = 0; intermediate = 0; numberMatches = 0; if (zephir_fast_strlen_ev(&pattern) <= 0) { RETURN_MM_BOOL(0); } ZEPHIR_INIT_VAR(&matches); array_init(&matches); ZEPHIR_INIT_VAR(&route); ZVAL_STRING(&route, ""); for (_0 = 0; _0 < Z_STRLEN_P(&pattern); _0++) { cursor = _0; ch = ZEPHIR_STRING_OFFSET(&pattern, _0); if (parenthesesCount == 0) { if (ch == '{') { if (bracketCount == 0) { marker = (cursor + 1); intermediate = 0; notValid = 0; } bracketCount++; } else { if (ch == '}') { bracketCount--; if (intermediate > 0) { if (bracketCount == 0) { numberMatches++; ZEPHIR_INIT_NVAR(&variable); ZVAL_STRING(&variable, ""); ZEPHIR_INIT_NVAR(®exp); ZVAL_STRING(®exp, ""); ZVAL_LONG(&_1$$11, marker); ZVAL_LONG(&_2$$11, (cursor - marker)); ZEPHIR_INIT_NVAR(&_3$$11); zephir_substr(&_3$$11, &pattern, zephir_get_intval(&_1$$11), zephir_get_intval(&_2$$11), 0); zephir_get_strval(&_4$$11, &_3$$11); ZEPHIR_CPY_WRT(&item, &_4$$11); for (_5$$11 = 0; _5$$11 < Z_STRLEN_P(&item); _5$$11++) { cursorVar = _5$$11; ch = ZEPHIR_STRING_OFFSET(&item, _5$$11); if (ch == '\0') { break; } _6$$12 = cursorVar == 0; if (_6$$12) { _7$$12 = ch >= 'a'; if (_7$$12) { _7$$12 = ch <= 'z'; } _8$$12 = _7$$12; if (!(_8$$12)) { _9$$12 = ch >= 'A'; if (_9$$12) { _9$$12 = ch <= 'Z'; } _8$$12 = _9$$12; } _6$$12 = !(_8$$12); } if (_6$$12) { notValid = 1; break; } _10$$12 = ch >= 'a'; if (_10$$12) { _10$$12 = ch <= 'z'; } _11$$12 = _10$$12; if (!(_11$$12)) { _12$$12 = ch >= 'A'; if (_12$$12) { _12$$12 = ch <= 'Z'; } _11$$12 = _12$$12; } _13$$12 = _11$$12; if (!(_13$$12)) { _14$$12 = ch >= '0'; if (_14$$12) { _14$$12 = ch <= '9'; } _13$$12 = _14$$12; } _15$$12 = _13$$12; if (!(_15$$12)) { _15$$12 = ch == '-'; } _16$$12 = _15$$12; if (!(_16$$12)) { _16$$12 = ch == '_'; } _17$$12 = _16$$12; if (!(_17$$12)) { _17$$12 = ch == ':'; } if (_17$$12) { if (ch == ':') { ZVAL_LONG(&_18$$16, 0); ZVAL_LONG(&_19$$16, cursorVar); ZEPHIR_INIT_NVAR(&_20$$16); zephir_substr(&_20$$16, &item, 0 , zephir_get_intval(&_19$$16), 0); zephir_get_strval(&_21$$16, &_20$$16); ZEPHIR_CPY_WRT(&variable, &_21$$16); ZVAL_LONG(&_22$$16, (cursorVar + 1)); ZEPHIR_INIT_NVAR(&_23$$16); zephir_substr(&_23$$16, &item, zephir_get_intval(&_22$$16), 0, ZEPHIR_SUBSTR_NO_LENGTH); zephir_get_strval(&_24$$16, &_23$$16); ZEPHIR_CPY_WRT(®exp, &_24$$16); break; } } else { notValid = 1; break; } } if (!(notValid)) { tmp = numberMatches; _25$$18 = zephir_is_true(&variable); if (_25$$18) { _25$$18 = zephir_is_true(®exp); } if (_25$$18) { foundPattern = 0; for (_26$$19 = 0; _26$$19 < Z_STRLEN_P(®exp); _26$$19++) { ch = ZEPHIR_STRING_OFFSET(®exp, _26$$19); if (ch == '\0') { break; } if (!(foundPattern)) { if (ch == '(') { foundPattern = 1; } } else { if (ch == ')') { foundPattern = 2; break; } } } if (foundPattern != 2) { zephir_concat_self_str(&route, "(", sizeof("(")-1 TSRMLS_CC); zephir_concat_self(&route, ®exp TSRMLS_CC); zephir_concat_self_str(&route, ")", sizeof(")")-1 TSRMLS_CC); } else { zephir_concat_self(&route, ®exp TSRMLS_CC); } ZEPHIR_INIT_NVAR(&_27$$19); ZVAL_LONG(&_27$$19, tmp); zephir_array_update_zval(&matches, &variable, &_27$$19, PH_COPY | PH_SEPARATE); } else { zephir_concat_self_str(&route, "([^/]*)", sizeof("([^/]*)")-1 TSRMLS_CC); ZEPHIR_INIT_NVAR(&_28$$28); ZVAL_LONG(&_28$$28, tmp); zephir_array_update_zval(&matches, &item, &_28$$28, PH_COPY | PH_SEPARATE); } } else { ZEPHIR_INIT_LNVAR(_29$$29); ZEPHIR_CONCAT_SVS(&_29$$29, "{", &item, "}"); zephir_concat_self(&route, &_29$$29 TSRMLS_CC); } continue; } } } } } if (bracketCount == 0) { if (ch == '(') { parenthesesCount++; } else { if (ch == ')') { parenthesesCount--; if (parenthesesCount == 0) { numberMatches++; } } } } if (bracketCount > 0) { intermediate++; } else { zephir_concat_self_char(&route, ch TSRMLS_CC); } } zephir_create_array(return_value, 2, 0 TSRMLS_CC); zephir_array_fast_append(return_value, &route); zephir_array_fast_append(return_value, &matches); RETURN_MM(); }
PHP_METHOD(Yb_Upload_StorageAbstract, generateUri) { unsigned char _12, _13, _14, _15; zephir_fcall_cache_entry *_9 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *source_param = NULL, *prefix_param = NULL, *extension_param = NULL, *_0, *_2 = NULL, *_8 = NULL, *_1$$3, *_3$$4, *_4$$4, _5$$4, *_6$$5; zval *source = NULL, *prefix = NULL, *extension = NULL, *uri, *uuid = NULL, *_10, *_11 = NULL, *_7$$5, *_16$$6; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &source_param, &prefix_param, &extension_param); zephir_get_strval(source, source_param); zephir_get_strval(prefix, prefix_param); zephir_get_strval(extension, extension_param); ZEPHIR_INIT_VAR(uri); ZVAL_STRING(uri, "/", 1); _0 = zephir_fetch_nproperty_this(this_ptr, SL("uriGenerator"), PH_NOISY_CC); if (zephir_is_true(_0)) { _1$$3 = zephir_fetch_nproperty_this(this_ptr, SL("uriGenerator"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_1$$3, "generateuri", NULL, 0, source, prefix, extension); zephir_check_call_status(); RETURN_MM(); } if (zephir_fast_strlen_ev(prefix) > 0) { ZEPHIR_INIT_VAR(_3$$4); ZEPHIR_INIT_VAR(_4$$4); ZEPHIR_SINIT_VAR(_5$$4); ZVAL_STRING(&_5$$4, "#^(\\w+/)*\\w*$#", 0); zephir_preg_match(_4$$4, &_5$$4, prefix, _3$$4, 0, 0 , 0 TSRMLS_CC); if (unlikely(!zephir_is_true(_4$$4))) { ZEPHIR_INIT_VAR(_6$$5); object_init_ex(_6$$5, yb_upload_exception_ce); ZEPHIR_INIT_VAR(_7$$5); ZEPHIR_CONCAT_SV(_7$$5, "Invalid prefix: ", prefix); ZEPHIR_CALL_METHOD(NULL, _6$$5, "__construct", NULL, 2, _7$$5); zephir_check_call_status(); zephir_throw_exception_debug(_6$$5, "yb/upload/storageabstract.zep", 37 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } zephir_concat_self(&uri, prefix TSRMLS_CC); } ZEPHIR_INIT_VAR(_10); ZEPHIR_CONCAT_VV(_10, source, extension); ZEPHIR_CALL_CE_STATIC(&_8, yb_std_ce, "uuid", &_9, 28, _10); zephir_check_call_status(); zephir_get_strval(_11, _8); ZEPHIR_CPY_WRT(uuid, _11); _12 = ZEPHIR_STRING_OFFSET(uuid, 0); zephir_concat_self_char(&uri, _12 TSRMLS_CC); _13 = ZEPHIR_STRING_OFFSET(uuid, 1); zephir_concat_self_char(&uri, _13 TSRMLS_CC); zephir_concat_self_str(&uri, "/", sizeof("/")-1 TSRMLS_CC); _14 = ZEPHIR_STRING_OFFSET(uuid, 2); zephir_concat_self_char(&uri, _14 TSRMLS_CC); _15 = ZEPHIR_STRING_OFFSET(uuid, 3); zephir_concat_self_char(&uri, _15 TSRMLS_CC); zephir_concat_self_str(&uri, "/", sizeof("/")-1 TSRMLS_CC); zephir_concat_self(&uri, uuid TSRMLS_CC); if (!(!extension) && Z_STRLEN_P(extension)) { ZEPHIR_INIT_VAR(_16$$6); ZEPHIR_CONCAT_SV(_16$$6, ".", extension); zephir_concat_self(&uri, _16$$6 TSRMLS_CC); } RETURN_CTOR(uri); }