/** * Returns an array of Phalcon\Db\Column objects describing a table * * <code>print_r($connection->describeColumns("posts")); ?></code> */ PHP_METHOD(Phalcon_Db_Adapter_Pdo_Oracle, describeColumns) { HashTable *_5; HashPosition _4; zephir_fcall_cache_entry *_24 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *table_param = NULL, *schema_param = NULL, *columns = NULL, *oldColumn = NULL, *field = NULL, *definition = NULL, *columnSize = NULL, *columnPrecision = NULL, *columnScale = NULL, *columnType = NULL, *columnName = NULL, *_0 = NULL, *_1, *_2 = NULL, *_3, **_6, *_7$$5 = NULL, *_8$$5 = NULL, *_9$$6 = NULL, *_10$$6 = NULL, *_11$$7 = NULL, *_12$$8 = NULL, *_13$$8 = NULL, *_14$$9 = NULL, *_15$$10 = NULL, *_16$$11 = NULL, *_17$$12 = NULL, *_18$$13 = NULL, *_19$$14 = NULL, *_20$$4 = NULL, *_21$$3, *_22$$3, *_23$$3 = NULL; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(table_param) == IS_STRING)) { zephir_get_strval(table, table_param); } else { ZEPHIR_INIT_VAR(table); ZVAL_EMPTY_STRING(table); } if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } ZEPHIR_INIT_VAR(columns); array_init(columns); ZEPHIR_INIT_VAR(oldColumn); ZVAL_NULL(oldColumn); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_2, _1, "describecolumns", NULL, 0, table, schema); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 3); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, _2, _3); zephir_check_call_status(); zephir_is_iterable(_0, &_5, &_4, 0, 0, "phalcon/db/adapter/pdo/oracle.zep", 208); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(field, _6); ZEPHIR_INIT_NVAR(definition); zephir_create_array(definition, 1, 0 TSRMLS_CC); add_assoc_long_ex(definition, SS("bindType"), 2); ZEPHIR_OBS_NVAR(columnSize); zephir_array_fetch_long(&columnSize, field, 2, PH_NOISY, "phalcon/db/adapter/pdo/oracle.zep", 102 TSRMLS_CC); ZEPHIR_OBS_NVAR(columnPrecision); zephir_array_fetch_long(&columnPrecision, field, 3, PH_NOISY, "phalcon/db/adapter/pdo/oracle.zep", 103 TSRMLS_CC); ZEPHIR_OBS_NVAR(columnScale); zephir_array_fetch_long(&columnScale, field, 4, PH_NOISY, "phalcon/db/adapter/pdo/oracle.zep", 104 TSRMLS_CC); ZEPHIR_OBS_NVAR(columnType); zephir_array_fetch_long(&columnType, field, 1, PH_NOISY, "phalcon/db/adapter/pdo/oracle.zep", 105 TSRMLS_CC); while (1) { if (zephir_memnstr_str(columnType, SL("NUMBER"), "phalcon/db/adapter/pdo/oracle.zep", 112)) { ZEPHIR_INIT_NVAR(_7$$5); ZVAL_LONG(_7$$5, 3); zephir_array_update_string(&definition, SL("type"), &_7$$5, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &columnPrecision, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("scale"), &columnScale, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8$$5); ZVAL_LONG(_8$$5, 32); zephir_array_update_string(&definition, SL("bindType"), &_8$$5, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("INTEGER"), "phalcon/db/adapter/pdo/oracle.zep", 121)) { ZEPHIR_INIT_NVAR(_9$$6); ZVAL_LONG(_9$$6, 0); zephir_array_update_string(&definition, SL("type"), &_9$$6, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &columnPrecision, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_10$$6); ZVAL_LONG(_10$$6, 1); zephir_array_update_string(&definition, SL("bindType"), &_10$$6, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("VARCHAR2"), "phalcon/db/adapter/pdo/oracle.zep", 129)) { ZEPHIR_INIT_NVAR(_11$$7); ZVAL_LONG(_11$$7, 2); zephir_array_update_string(&definition, SL("type"), &_11$$7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &columnSize, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("FLOAT"), "phalcon/db/adapter/pdo/oracle.zep", 135)) { ZEPHIR_INIT_NVAR(_12$$8); ZVAL_LONG(_12$$8, 7); zephir_array_update_string(&definition, SL("type"), &_12$$8, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &columnSize, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("scale"), &columnScale, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_13$$8); ZVAL_LONG(_13$$8, 32); zephir_array_update_string(&definition, SL("bindType"), &_13$$8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("TIMESTAMP"), "phalcon/db/adapter/pdo/oracle.zep", 144)) { ZEPHIR_INIT_NVAR(_14$$9); ZVAL_LONG(_14$$9, 17); zephir_array_update_string(&definition, SL("type"), &_14$$9, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("DATE"), "phalcon/db/adapter/pdo/oracle.zep", 149)) { ZEPHIR_INIT_NVAR(_15$$10); ZVAL_LONG(_15$$10, 1); zephir_array_update_string(&definition, SL("type"), &_15$$10, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("RAW"), "phalcon/db/adapter/pdo/oracle.zep", 154)) { ZEPHIR_INIT_NVAR(_16$$11); ZVAL_LONG(_16$$11, 6); zephir_array_update_string(&definition, SL("type"), &_16$$11, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("BLOB"), "phalcon/db/adapter/pdo/oracle.zep", 159)) { ZEPHIR_INIT_NVAR(_17$$12); ZVAL_LONG(_17$$12, 6); zephir_array_update_string(&definition, SL("type"), &_17$$12, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("CLOB"), "phalcon/db/adapter/pdo/oracle.zep", 164)) { ZEPHIR_INIT_NVAR(_18$$13); ZVAL_LONG(_18$$13, 6); zephir_array_update_string(&definition, SL("type"), &_18$$13, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("CHAR"), "phalcon/db/adapter/pdo/oracle.zep", 169)) { ZEPHIR_INIT_NVAR(_19$$14); ZVAL_LONG(_19$$14, 5); zephir_array_update_string(&definition, SL("type"), &_19$$14, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &columnSize, PH_COPY | PH_SEPARATE); break; } ZEPHIR_INIT_NVAR(_20$$4); ZVAL_LONG(_20$$4, 6); zephir_array_update_string(&definition, SL("type"), &_20$$4, PH_COPY | PH_SEPARATE); break; } if (Z_TYPE_P(oldColumn) == IS_NULL) { zephir_array_update_string(&definition, SL("first"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } else { zephir_array_update_string(&definition, SL("after"), &oldColumn, PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_21$$3, field, 6, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/oracle.zep", 188 TSRMLS_CC); if (ZEPHIR_IS_STRING(_21$$3, "P")) { zephir_array_update_string(&definition, SL("primary"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_22$$3, field, 5, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/oracle.zep", 195 TSRMLS_CC); if (ZEPHIR_IS_STRING(_22$$3, "N")) { zephir_array_update_string(&definition, SL("notNull"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&columnName, field, 0, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/oracle.zep", 199 TSRMLS_CC); ZEPHIR_INIT_NVAR(_23$$3); object_init_ex(_23$$3, phalcon_db_column_ce); ZEPHIR_CALL_METHOD(NULL, _23$$3, "__construct", &_24, 137, columnName, definition); zephir_check_call_status(); zephir_array_append(&columns, _23$$3, PH_SEPARATE, "phalcon/db/adapter/pdo/oracle.zep", 204); ZEPHIR_CPY_WRT(oldColumn, columnName); } RETURN_CCTOR(columns); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_Digit, validate) { zend_bool _2; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *value = NULL, *message = NULL, *label = NULL, *replacePairs, *_0 = NULL, *_1 = NULL, *_3 = NULL, *_4 = NULL, *_5; 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(_1); ZVAL_STRING(_1, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, this_ptr, "issetoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); _2 = zephir_is_true(_0); if (_2) { _2 = ZEPHIR_IS_EMPTY(value); } if (_2) { RETURN_MM_BOOL(1); } ZEPHIR_CALL_FUNCTION(&_3, "ctype_digit", NULL, 436, value); zephir_check_call_status(); if (!(zephir_is_true(_3))) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); 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(_1); ZVAL_STRING(_1, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); 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(_1); ZVAL_STRING(_1, "Digit", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_4, "strtr", NULL, 53, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_5); ZVAL_STRING(_5, "Digit", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 432, _4, field, _5); zephir_check_temp_parameter(_5); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _1); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); }
/** * Checks for annotations in the public methods of the controller * * @param string module * @param string namespaceName * @param string controller * @param string action * @param Phalcon\Annotations\Annotation annotation */ PHP_METHOD(Phalcon_Mvc_Router_Annotations, processActionAnnotation) { zephir_fcall_cache_entry *_7 = NULL, *_11 = NULL; HashTable *_5, *_9; HashPosition _4, _8; int ZEPHIR_LAST_CALL_STATUS; zend_bool isRoute, _12; zval *module_param = NULL, *namespaceName_param = NULL, *controller_param = NULL, *action_param = NULL, *annotation, *name = NULL, *actionName, *routePrefix, *paths = NULL, *value = NULL, *uri = NULL, *route = NULL, *methods = NULL, *converts = NULL, *param = NULL, *convert = NULL, *conversorParam = NULL, *routeName = NULL, *beforeMatch = NULL, *_0, *_1, _2, *_3 = NULL, **_6, **_10; zval *module = NULL, *namespaceName = NULL, *controller = NULL, *action = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 5, 0, &module_param, &namespaceName_param, &controller_param, &action_param, &annotation); if (unlikely(Z_TYPE_P(module_param) != IS_STRING && Z_TYPE_P(module_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'module' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(module_param) == IS_STRING)) { zephir_get_strval(module, module_param); } else { ZEPHIR_INIT_VAR(module); ZVAL_EMPTY_STRING(module); } if (unlikely(Z_TYPE_P(namespaceName_param) != IS_STRING && Z_TYPE_P(namespaceName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'namespaceName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(namespaceName_param) == IS_STRING)) { zephir_get_strval(namespaceName, namespaceName_param); } else { ZEPHIR_INIT_VAR(namespaceName); ZVAL_EMPTY_STRING(namespaceName); } if (unlikely(Z_TYPE_P(controller_param) != IS_STRING && Z_TYPE_P(controller_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controller' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(controller_param) == IS_STRING)) { zephir_get_strval(controller, controller_param); } else { ZEPHIR_INIT_VAR(controller); ZVAL_EMPTY_STRING(controller); } if (unlikely(Z_TYPE_P(action_param) != IS_STRING && Z_TYPE_P(action_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'action' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(action_param) == IS_STRING)) { zephir_get_strval(action, action_param); } else { ZEPHIR_INIT_VAR(action); ZVAL_EMPTY_STRING(action); } isRoute = 0; ZEPHIR_INIT_VAR(methods); ZVAL_NULL(methods); ZEPHIR_CALL_METHOD(&name, annotation, "getname", NULL, 0); zephir_check_call_status(); do { if (ZEPHIR_IS_STRING(name, "Route")) { isRoute = 1; break; } if (ZEPHIR_IS_STRING(name, "Get")) { isRoute = 1; ZEPHIR_INIT_NVAR(methods); ZVAL_STRING(methods, "GET", 1); break; } if (ZEPHIR_IS_STRING(name, "Post")) { isRoute = 1; ZEPHIR_INIT_NVAR(methods); ZVAL_STRING(methods, "POST", 1); break; } if (ZEPHIR_IS_STRING(name, "Put")) { isRoute = 1; ZEPHIR_INIT_NVAR(methods); ZVAL_STRING(methods, "PUT", 1); break; } if (ZEPHIR_IS_STRING(name, "Delete")) { isRoute = 1; ZEPHIR_INIT_NVAR(methods); ZVAL_STRING(methods, "DELETE", 1); break; } if (ZEPHIR_IS_STRING(name, "Options")) { isRoute = 1; ZEPHIR_INIT_NVAR(methods); ZVAL_STRING(methods, "OPTIONS", 1); break; } } while(0); if (isRoute == 1) { ZEPHIR_INIT_VAR(_0); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_actionSuffix"), PH_NOISY_CC); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "", 0); zephir_fast_str_replace(&_0, _1, &_2, action TSRMLS_CC); ZEPHIR_INIT_VAR(actionName); zephir_fast_strtolower(actionName, _0); ZEPHIR_OBS_VAR(routePrefix); zephir_read_property_this(&routePrefix, this_ptr, SL("_routePrefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "paths", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&paths, annotation, "getnamedargument", NULL, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); if (Z_TYPE_P(paths) != IS_ARRAY) { ZEPHIR_INIT_NVAR(paths); array_init(paths); } if (!(ZEPHIR_IS_EMPTY(module))) { zephir_array_update_string(&paths, SL("module"), &module, PH_COPY | PH_SEPARATE); } if (!(ZEPHIR_IS_EMPTY(namespaceName))) { zephir_array_update_string(&paths, SL("namespace"), &namespaceName, PH_COPY | PH_SEPARATE); } zephir_array_update_string(&paths, SL("controller"), &controller, PH_COPY | PH_SEPARATE); zephir_array_update_string(&paths, SL("action"), &actionName, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 0); ZEPHIR_CALL_METHOD(&value, annotation, "getargument", NULL, 0, _3); zephir_check_call_status(); if (Z_TYPE_P(value) != IS_NULL) { if (!ZEPHIR_IS_STRING(value, "/")) { ZEPHIR_INIT_VAR(uri); ZEPHIR_CONCAT_VV(uri, routePrefix, value); } else { if (Z_TYPE_P(routePrefix) != IS_NULL) { ZEPHIR_CPY_WRT(uri, routePrefix); } else { ZEPHIR_CPY_WRT(uri, value); } } } else { ZEPHIR_INIT_NVAR(uri); ZEPHIR_CONCAT_VV(uri, routePrefix, actionName); } ZEPHIR_CALL_METHOD(&route, this_ptr, "add", NULL, 0, uri, paths); zephir_check_call_status(); if (Z_TYPE_P(methods) != IS_NULL) { ZEPHIR_CALL_METHOD(NULL, route, "via", NULL, 0, methods); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "methods", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&methods, annotation, "getnamedargument", NULL, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); if (Z_TYPE_P(methods) == IS_ARRAY) { ZEPHIR_CALL_METHOD(NULL, route, "via", NULL, 0, methods); zephir_check_call_status(); } else { if (Z_TYPE_P(methods) == IS_STRING) { ZEPHIR_CALL_METHOD(NULL, route, "via", NULL, 0, methods); zephir_check_call_status(); } } } ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "converts", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&converts, annotation, "getnamedargument", NULL, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); if (Z_TYPE_P(converts) == IS_ARRAY) { zephir_is_iterable(converts, &_5, &_4, 0, 0, "phalcon/mvc/router/annotations.zep", 360); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HMKEY(param, _5, _4); ZEPHIR_GET_HVALUE(convert, _6); ZEPHIR_CALL_METHOD(NULL, route, "convert", &_7, 0, param, convert); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "conversors", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&converts, annotation, "getnamedargument", NULL, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); if (Z_TYPE_P(converts) == IS_ARRAY) { zephir_is_iterable(converts, &_9, &_8, 0, 0, "phalcon/mvc/router/annotations.zep", 370); for ( ; zephir_hash_get_current_data_ex(_9, (void**) &_10, &_8) == SUCCESS ; zephir_hash_move_forward_ex(_9, &_8) ) { ZEPHIR_GET_HMKEY(conversorParam, _9, _8); ZEPHIR_GET_HVALUE(convert, _10); ZEPHIR_CALL_METHOD(NULL, route, "convert", &_11, 0, conversorParam, convert); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "beforeMatch", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&beforeMatch, annotation, "getnamedargument", NULL, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); _12 = Z_TYPE_P(beforeMatch) == IS_ARRAY; if (!(_12)) { _12 = Z_TYPE_P(beforeMatch) == IS_STRING; } if (_12) { ZEPHIR_CALL_METHOD(NULL, route, "beforematch", NULL, 0, beforeMatch); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "name", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&routeName, annotation, "getnamedargument", NULL, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); if (Z_TYPE_P(routeName) == IS_STRING) { ZEPHIR_CALL_METHOD(NULL, route, "setname", NULL, 0, routeName); zephir_check_call_status(); } RETURN_MM_BOOL(1); } ZEPHIR_MM_RESTORE(); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_Confirmation, validate) { zend_long ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *fieldWith = NULL, *value = NULL, *valueWith = NULL, *message = NULL, *label = NULL, *labelWith = NULL, *replacePairs = NULL, *code = NULL, *_0, *_2 = NULL, *_1$$3, *_3$$4 = NULL, *_5$$4 = NULL, *_6$$4, *_4$$5; 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, "with", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&fieldWith, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(fieldWith) == IS_ARRAY) { zephir_array_fetch(&_1$$3, fieldWith, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/confirmation.zep", 78 TSRMLS_CC); ZEPHIR_CPY_WRT(fieldWith, _1$$3); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&valueWith, validation, "getvalue", NULL, 0, fieldWith); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_2, this_ptr, "compare", NULL, 482, value, valueWith); zephir_check_call_status(); if (!(zephir_is_true(_2))) { ZEPHIR_CALL_METHOD(&label, this_ptr, "preparelabel", NULL, 0, validation, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3$$4); ZVAL_STRING(_3$$4, "Confirmation", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, _3$$4); zephir_check_temp_parameter(_3$$4); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&code, this_ptr, "preparecode", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_3$$4); ZVAL_STRING(_3$$4, "labelWith", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&labelWith, this_ptr, "getoption", NULL, 0, _3$$4); zephir_check_temp_parameter(_3$$4); zephir_check_call_status(); if (Z_TYPE_P(labelWith) == IS_ARRAY) { zephir_array_fetch(&_4$$5, labelWith, fieldWith, PH_NOISY | PH_READONLY, "phalcon/validation/validator/confirmation.zep", 91 TSRMLS_CC); ZEPHIR_CPY_WRT(labelWith, _4$$5); } if (ZEPHIR_IS_EMPTY(labelWith)) { ZEPHIR_CALL_METHOD(&labelWith, validation, "getlabel", NULL, 0, fieldWith); 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(":with"), &labelWith, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_3$$4); object_init_ex(_3$$4, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_5$$4, "strtr", NULL, 27, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_6$$4); ZVAL_STRING(_6$$4, "Confirmation", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _3$$4, "__construct", NULL, 479, _5$$4, field, _6$$4, code); zephir_check_temp_parameter(_6$$4); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _3$$4); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); }
/** * Set the service definition * * @param mixed $definition */ PHP_METHOD(Phalcon_DI_Service, setDefinition) { zval *definition; phalcon_fetch_params(0, 1, 0, &definition); phalcon_update_property_zval(getThis(), SL("_definition"), definition); }
/** * Handles routing information received from command-line arguments * * @param array $arguments */ PHP_METHOD(Phalcon_CLI_Router, handle){ zval *arguments = NULL, module_name = {}, namespace_name = {}, task_name = {}, action_name = {}; phalcon_fetch_params(0, 0, 1, &arguments); if (!arguments || Z_TYPE_P(arguments) != IS_ARRAY) { PHALCON_THROW_EXCEPTION_STRW(phalcon_cli_router_exception_ce, "Arguments must be an Array"); return; } PHALCON_SEPARATE_PARAM(arguments); /** * Check for a module */ if (phalcon_array_isset_fetch_str(&module_name, arguments, SL("module"))) { phalcon_array_unset_str(arguments, SL("module"), PH_COPY); phalcon_update_property_this(getThis(), SL("_module"), &module_name); } /** * Check for a namespace */ if (phalcon_array_isset_fetch_str(&namespace_name, arguments, SL("namespace"))) { phalcon_array_unset_str(arguments, SL("namespace"), PH_COPY); phalcon_update_property_this(getThis(), SL("_namespace"), &namespace_name); } /** * Check for a task */ if (phalcon_array_isset_fetch_str(&task_name, arguments, SL("task"))) { phalcon_array_unset_str(arguments, SL("task"), PH_COPY); phalcon_update_property_this(getThis(), SL("_task"), &task_name); } /** * Check for an action */ if (phalcon_array_isset_fetch_str(&action_name, arguments, SL("action"))) { phalcon_array_unset_str(arguments, SL("action"), PH_COPY); phalcon_update_property_this(getThis(), SL("_action"), &action_name); } phalcon_update_property_this(getThis(), SL("_params"), arguments); }
PHP_METHOD(Transbybd_TransApi, translate) { zval *args = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *query_param = NULL, *from_param = NULL, *to_param = NULL, *ret = NULL, *_0, _1, _2, *_3 = NULL, *_4, *_5; zval *query = NULL, *from = NULL, *to = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &query_param, &from_param, &to_param); if (unlikely(Z_TYPE_P(query_param) != IS_STRING && Z_TYPE_P(query_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'query' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(query_param) == IS_STRING)) { zephir_get_strval(query, query_param); } else { ZEPHIR_INIT_VAR(query); ZVAL_EMPTY_STRING(query); } if (unlikely(Z_TYPE_P(from_param) != IS_STRING && Z_TYPE_P(from_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'from' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(from_param) == IS_STRING)) { zephir_get_strval(from, from_param); } else { ZEPHIR_INIT_VAR(from); ZVAL_EMPTY_STRING(from); } if (unlikely(Z_TYPE_P(to_param) != IS_STRING && Z_TYPE_P(to_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'to' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(to_param) == IS_STRING)) { zephir_get_strval(to, to_param); } else { ZEPHIR_INIT_VAR(to); ZVAL_EMPTY_STRING(to); } ZEPHIR_INIT_VAR(args); array_init(args); ZEPHIR_INIT_NVAR(args); zephir_create_array(args, 5, 0 TSRMLS_CC); zephir_array_update_string(&args, SL("q"), &query, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("app_id"), PH_NOISY_CC); zephir_array_update_string(&args, SL("appid"), &_0, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, 10000); ZEPHIR_SINIT_VAR(_2); ZVAL_LONG(&_2, 99999); ZEPHIR_CALL_FUNCTION(&_3, "rand", NULL, 1, &_1, &_2); zephir_check_call_status(); zephir_array_update_string(&args, SL("salt"), &_3, PH_COPY | PH_SEPARATE); zephir_array_update_string(&args, SL("from"), &from, PH_COPY | PH_SEPARATE); zephir_array_update_string(&args, SL("to"), &to, PH_COPY | PH_SEPARATE); zephir_array_fetch_string(&_4, args, SL("salt"), PH_NOISY | PH_READONLY, "transbybd/transApi.zep", 33 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_3, this_ptr, "__buildsign", NULL, 2, query, _4); zephir_check_call_status(); zephir_array_update_string(&args, SL("sign"), &_3, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&ret, this_ptr, "__callmutil", NULL, 3, args); zephir_check_call_status(); ZEPHIR_INIT_VAR(_5); zephir_json_decode(_5, &(_5), ret, zephir_get_intval(ZEPHIR_GLOBAL(global_true)) TSRMLS_CC); ZEPHIR_CPY_WRT(ret, _5); RETURN_CCTOR(ret); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_Regex, validate) { int ZEPHIR_LAST_CALL_STATUS; zend_bool failed, _2; zval *field = NULL; zval *validation, *field_param = NULL, *matches, *message = NULL, *value = NULL, *label = NULL, *replacePairs, *_0 = NULL, *_1 = NULL, *_3 = NULL, *_4 = NULL, *_5, *_6 = NULL, *_7; 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(matches); ZVAL_NULL(matches); ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, this_ptr, "issetoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); _2 = zephir_is_true(_0); if (_2) { _2 = ZEPHIR_IS_EMPTY(value); } if (_2) { RETURN_MM_BOOL(1); } ZEPHIR_INIT_NVAR(_1); ZEPHIR_INIT_VAR(_4); ZVAL_STRING(_4, "pattern", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3, this_ptr, "getoption", NULL, 0, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_preg_match(_1, _3, value, matches, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(_1)) { zephir_array_fetch_long(&_5, matches, 0, PH_NOISY | PH_READONLY, "phalcon/validation/validator/regex.zep", 62 TSRMLS_CC); failed = !ZEPHIR_IS_EQUAL(_5, value); } else { failed = 1; } if (failed == 1) { ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _4); zephir_check_temp_parameter(_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); ZVAL_STRING(_4, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _4); zephir_check_temp_parameter(_4); 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(_4); ZVAL_STRING(_4, "Regex", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_4); object_init_ex(_4, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_6, "strtr", NULL, 73, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_7); ZVAL_STRING(_7, "Regex", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _4, "__construct", NULL, 425, _6, field, _7); zephir_check_temp_parameter(_7); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _4); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); }
/** * Internal sanitize wrapper to filter_var * * @param mixed $value * @param string $filter * @return mixed */ PHP_METHOD(Phalcon_Filter, _sanitize){ zval *value, *filter, *filters, *filter_object; zval *arguments, *filtered = NULL, *type = NULL, *quote, *empty_str; zval *escaped, *allow_fraction, *options, *exception_message; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &value, &filter) == FAILURE) { RETURN_MM_NULL(); } PHALCON_OBS_VAR(filters); phalcon_read_property(&filters, this_ptr, SL("_filters"), PH_NOISY_CC); if (phalcon_array_isset(filters, filter)) { PHALCON_OBS_VAR(filter_object); phalcon_array_fetch(&filter_object, filters, filter, PH_NOISY_CC); /** * If the filter is a closure we call it in the PHP userland */ if (phalcon_is_instance_of(filter_object, SL("Closure") TSRMLS_CC)) { PHALCON_INIT_VAR(arguments); array_init_size(arguments, 1); phalcon_array_append(&arguments, value, PH_SEPARATE TSRMLS_CC); PHALCON_INIT_VAR(filtered); PHALCON_CALL_USER_FUNC_ARRAY(filtered, filter_object, arguments); } else { PHALCON_INIT_NVAR(filtered); PHALCON_CALL_METHOD_PARAMS_1(filtered, filter_object, "filter", value); } RETURN_CCTOR(filtered); } if (PHALCON_IS_STRING(filter, "email")) { /** * The 'email' filter uses the filter extension */ PHALCON_INIT_VAR(type); ZVAL_LONG(type, 517); PHALCON_INIT_VAR(quote); ZVAL_STRING(quote, "'", 1); PHALCON_INIT_VAR(empty_str); ZVAL_STRING(empty_str, "", 1); PHALCON_INIT_VAR(escaped); phalcon_fast_str_replace(escaped, quote, empty_str, value TSRMLS_CC); PHALCON_INIT_NVAR(filtered); PHALCON_CALL_FUNC_PARAMS_2(filtered, "filter_var", escaped, type); goto ph_end_0; } if (PHALCON_IS_STRING(filter, "int")) { /** * 'int' filter sanitizes a numeric input */ PHALCON_INIT_NVAR(type); ZVAL_LONG(type, 519); PHALCON_INIT_NVAR(filtered); PHALCON_CALL_FUNC_PARAMS_2(filtered, "filter_var", value, type); goto ph_end_0; } if (PHALCON_IS_STRING(filter, "string")) { PHALCON_INIT_NVAR(type); ZVAL_LONG(type, 513); PHALCON_INIT_NVAR(filtered); PHALCON_CALL_FUNC_PARAMS_2(filtered, "filter_var", value, type); goto ph_end_0; } if (PHALCON_IS_STRING(filter, "float")) { /** * The 'float' filter uses the filter extension */ PHALCON_INIT_VAR(allow_fraction); ZVAL_LONG(allow_fraction, 4096); PHALCON_INIT_VAR(options); array_init_size(options, 1); phalcon_array_update_string(&options, SL("flags"), &allow_fraction, PH_COPY | PH_SEPARATE TSRMLS_CC); PHALCON_INIT_NVAR(type); ZVAL_LONG(type, 520); PHALCON_INIT_NVAR(filtered); PHALCON_CALL_FUNC_PARAMS_3(filtered, "filter_var", value, type, options); goto ph_end_0; } if (PHALCON_IS_STRING(filter, "alphanum")) { PHALCON_INIT_NVAR(filtered); phalcon_filter_alphanum(filtered, value); goto ph_end_0; } if (PHALCON_IS_STRING(filter, "trim")) { PHALCON_INIT_NVAR(filtered); PHALCON_CALL_FUNC_PARAMS_1(filtered, "trim", value); goto ph_end_0; } if (PHALCON_IS_STRING(filter, "striptags")) { PHALCON_INIT_NVAR(filtered); PHALCON_CALL_FUNC_PARAMS_1(filtered, "strip_tags", value); goto ph_end_0; } if (PHALCON_IS_STRING(filter, "lower")) { if (phalcon_function_exists_ex(SS("mb_strtolower") TSRMLS_CC) == SUCCESS) { /** * 'lower' checks for the mbstring extension to make a correct lowercase * transformation */ PHALCON_INIT_NVAR(filtered); PHALCON_CALL_FUNC_PARAMS_1(filtered, "mb_strtolower", value); } else { PHALCON_INIT_NVAR(filtered); phalcon_fast_strtolower(filtered, value); } goto ph_end_0; } if (PHALCON_IS_STRING(filter, "upper")) { if (phalcon_function_exists_ex(SS("mb_strtoupper") TSRMLS_CC) == SUCCESS) { /** * 'upper' checks for the mbstring extension to make a correct lowercase * transformation */ PHALCON_INIT_NVAR(filtered); PHALCON_CALL_FUNC_PARAMS_1(filtered, "mb_strtoupper", value); } else { PHALCON_INIT_NVAR(filtered); PHALCON_CALL_FUNC_PARAMS_1(filtered, "strtoupper", value); } goto ph_end_0; } PHALCON_INIT_VAR(exception_message); PHALCON_CONCAT_SVS(exception_message, "Sanitize filter ", filter, " is not supported"); PHALCON_THROW_EXCEPTION_ZVAL(phalcon_filter_exception_ce, exception_message); return; ph_end_0: RETURN_CCTOR(filtered); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_File, validate) { zend_bool _2, _3, _4, _6, _7, _16, _17, _19, _27, _28, _62, _69$$20, _78$$25; zephir_fcall_cache_entry *_12 = NULL, *_15 = NULL, *_41 = 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, *_0 = NULL, *_1, *_5, *_8, *_18, *_20, *_21 = NULL, *_34 = NULL, *_52 = NULL, *_61 = NULL, *_63 = NULL, *_9$$4 = NULL, *_11$$4 = NULL, *_13$$4 = NULL, *_14$$4 = NULL, *_10$$5, *_22$$6 = NULL, *_24$$6 = NULL, *_25$$6 = NULL, *_26$$6 = NULL, *_23$$7, *_29$$8 = NULL, *_31$$8 = NULL, *_32$$8 = NULL, *_33$$8 = NULL, *_30$$9, *_35$$10 = NULL, *_36$$10, *_37$$10, *_38$$10, *_39$$10, *_40$$10 = NULL, *_42$$10, *_43$$10, _44$$10, *_45$$10, *_46$$10 = NULL, *_47$$12 = NULL, *_49$$12 = NULL, *_50$$12 = NULL, *_51$$12 = NULL, *_48$$13, *_53$$14, _54$$16, *_55$$16, *_56$$18 = NULL, *_58$$18 = NULL, *_59$$18 = NULL, *_60$$18 = NULL, *_57$$19, *_64$$20, *_65$$20 = NULL, *_66$$20 = NULL, *_75$$20 = NULL, *_67$$21 = NULL, *_68$$21, *_70$$23 = NULL, *_71$$23 = NULL, *_73$$23 = NULL, *_74$$23 = NULL, *_72$$24, *_76$$25 = NULL, *_77$$25, *_79$$26 = NULL, *_80$$26 = NULL, *_82$$26 = NULL, *_83$$26 = NULL, *_81$$27; 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_VAR(_9$$4); ZVAL_STRING(_9$$4, "messageIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _9$$4); zephir_check_temp_parameter(_9$$4); 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_VAR(_10$$5); ZVAL_STRING(_10$$5, "FileIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _10$$5); zephir_check_temp_parameter(_10$$5); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_9$$4); object_init_ex(_9$$4, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_11$$4, "strtr", &_12, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_14$$4); ZVAL_STRING(_14$$4, "code", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_13$$4, this_ptr, "getoption", NULL, 0, _14$$4); zephir_check_temp_parameter(_14$$4); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_14$$4); ZVAL_STRING(_14$$4, "FileIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _9$$4, "__construct", &_15, 440, _11$$4, field, _14$$4, _13$$4); zephir_check_temp_parameter(_14$$4); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _9$$4); zephir_check_call_status(); RETURN_MM_BOOL(0); } _16 = !(zephir_array_isset_string(value, SS("error"))); if (!(_16)) { _16 = !(zephir_array_isset_string(value, SS("tmp_name"))); } _17 = _16; if (!(_17)) { zephir_array_fetch_string(&_18, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 75 TSRMLS_CC); _17 = !ZEPHIR_IS_LONG_IDENTICAL(_18, 0); } _19 = _17; if (!(_19)) { zephir_array_fetch_string(&_20, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 75 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_21, "is_uploaded_file", NULL, 231, _20); zephir_check_call_status(); _19 = !zephir_is_true(_21); } if (_19) { ZEPHIR_INIT_VAR(_22$$6); ZVAL_STRING(_22$$6, "messageEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _22$$6); zephir_check_temp_parameter(_22$$6); 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_VAR(_23$$7); ZVAL_STRING(_23$$7, "FileEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _23$$7); zephir_check_temp_parameter(_23$$7); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_22$$6); object_init_ex(_22$$6, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_24$$6, "strtr", &_12, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_26$$6); ZVAL_STRING(_26$$6, "code", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_25$$6, this_ptr, "getoption", NULL, 0, _26$$6); zephir_check_temp_parameter(_26$$6); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_26$$6); ZVAL_STRING(_26$$6, "FileEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _22$$6, "__construct", &_15, 440, _24$$6, field, _26$$6, _25$$6); zephir_check_temp_parameter(_26$$6); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _22$$6); zephir_check_call_status(); RETURN_MM_BOOL(0); } _27 = !(zephir_array_isset_string(value, SS("name"))); if (!(_27)) { _27 = !(zephir_array_isset_string(value, SS("type"))); } _28 = _27; if (!(_28)) { _28 = !(zephir_array_isset_string(value, SS("size"))); } if (_28) { ZEPHIR_INIT_VAR(_29$$8); ZVAL_STRING(_29$$8, "messageValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _29$$8); zephir_check_temp_parameter(_29$$8); 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_VAR(_30$$9); ZVAL_STRING(_30$$9, "FileValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _30$$9); zephir_check_temp_parameter(_30$$9); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_29$$8); object_init_ex(_29$$8, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_31$$8, "strtr", &_12, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_33$$8); ZVAL_STRING(_33$$8, "code", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_32$$8, this_ptr, "getoption", NULL, 0, _33$$8); zephir_check_temp_parameter(_33$$8); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_33$$8); ZVAL_STRING(_33$$8, "FileValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _29$$8, "__construct", &_15, 440, _31$$8, field, _33$$8, _32$$8); zephir_check_temp_parameter(_33$$8); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _29$$8); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "maxSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_34, this_ptr, "hasoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (zephir_is_true(_34)) { 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(_35$$10); ZVAL_STRING(_35$$10, "maxSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&maxSize, this_ptr, "getoption", NULL, 0, _35$$10); zephir_check_temp_parameter(_35$$10); zephir_check_call_status(); ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); ZEPHIR_INIT_VAR(unit); ZVAL_STRING(unit, "B", 1); ZEPHIR_INIT_NVAR(_35$$10); ZEPHIR_INIT_VAR(_36$$10); ZEPHIR_INIT_VAR(_37$$10); zephir_array_keys(_37$$10, byteUnits TSRMLS_CC); zephir_fast_join_str(_36$$10, SL("|"), _37$$10 TSRMLS_CC); ZEPHIR_INIT_VAR(_38$$10); ZEPHIR_CONCAT_SVS(_38$$10, "/^([0-9]+(?:\\.[0-9]+)?)(", _36$$10, ")?$/Di"); zephir_preg_match(_35$$10, _38$$10, 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", 111 TSRMLS_CC); } zephir_array_fetch_long(&_39$$10, matches, 1, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 114 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_40$$10, "floatval", &_41, 303, _39$$10); zephir_check_call_status(); ZEPHIR_INIT_VAR(_42$$10); zephir_array_fetch(&_43$$10, byteUnits, unit, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 114 TSRMLS_CC); ZEPHIR_SINIT_VAR(_44$$10); ZVAL_LONG(&_44$$10, 2); zephir_pow_function(_42$$10, &_44$$10, _43$$10); ZEPHIR_INIT_VAR(bytes); mul_function(bytes, _40$$10, _42$$10 TSRMLS_CC); zephir_array_fetch_string(&_45$$10, value, SL("size"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 116 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_40$$10, "floatval", &_41, 303, _45$$10); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_46$$10, "floatval", &_41, 303, bytes); zephir_check_call_status(); if (ZEPHIR_GT(_40$$10, _46$$10)) { ZEPHIR_INIT_VAR(_47$$12); ZVAL_STRING(_47$$12, "messageSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _47$$12); zephir_check_temp_parameter(_47$$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(":max"), &maxSize, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_48$$13); ZVAL_STRING(_48$$13, "FileSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _48$$13); zephir_check_temp_parameter(_48$$13); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_47$$12); object_init_ex(_47$$12, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_49$$12, "strtr", &_12, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_51$$12); ZVAL_STRING(_51$$12, "code", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_50$$12, this_ptr, "getoption", NULL, 0, _51$$12); zephir_check_temp_parameter(_51$$12); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_51$$12); ZVAL_STRING(_51$$12, "FileSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _47$$12, "__construct", &_15, 440, _49$$12, field, _51$$12, _50$$12); zephir_check_temp_parameter(_51$$12); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _47$$12); zephir_check_call_status(); RETURN_MM_BOOL(0); } } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_52, this_ptr, "hasoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (zephir_is_true(_52)) { ZEPHIR_INIT_VAR(_53$$14); ZVAL_STRING(_53$$14, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&types, this_ptr, "getoption", NULL, 0, _53$$14); zephir_check_temp_parameter(_53$$14); 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", 134); return; } if ((zephir_function_exists_ex(SS("finfo_open") TSRMLS_CC) == SUCCESS)) { ZEPHIR_SINIT_VAR(_54$$16); ZVAL_LONG(&_54$$16, 16); ZEPHIR_CALL_FUNCTION(&tmp, "finfo_open", NULL, 228, &_54$$16); zephir_check_call_status(); zephir_array_fetch_string(&_55$$16, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 139 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&mime, "finfo_file", NULL, 229, tmp, _55$$16); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(NULL, "finfo_close", NULL, 230, 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", 143 TSRMLS_CC); } if (!(zephir_fast_in_array(mime, types TSRMLS_CC))) { ZEPHIR_INIT_VAR(_56$$18); ZVAL_STRING(_56$$18, "messageType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _56$$18); zephir_check_temp_parameter(_56$$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_INIT_NVAR(_56$$18); zephir_fast_join_str(_56$$18, SL(", "), types TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":types"), &_56$$18, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_57$$19); ZVAL_STRING(_57$$19, "FileType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _57$$19); zephir_check_temp_parameter(_57$$19); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_56$$18); object_init_ex(_56$$18, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_58$$18, "strtr", &_12, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_60$$18); ZVAL_STRING(_60$$18, "code", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_59$$18, this_ptr, "getoption", NULL, 0, _60$$18); zephir_check_temp_parameter(_60$$18); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_60$$18); ZVAL_STRING(_60$$18, "FileType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _56$$18, "__construct", &_15, 440, _58$$18, field, _60$$18, _59$$18); zephir_check_temp_parameter(_60$$18); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _56$$18); zephir_check_call_status(); RETURN_MM_BOOL(0); } } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_61, this_ptr, "hasoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _62 = zephir_is_true(_61); if (!(_62)) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_63, this_ptr, "hasoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _62 = zephir_is_true(_63); } if (_62) { zephir_array_fetch_string(&_64$$20, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 160 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&tmp, "getimagesize", NULL, 239, _64$$20); zephir_check_call_status(); ZEPHIR_OBS_VAR(width); zephir_array_fetch_long(&width, tmp, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 161 TSRMLS_CC); ZEPHIR_OBS_VAR(height); zephir_array_fetch_long(&height, tmp, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 162 TSRMLS_CC); ZEPHIR_INIT_VAR(_66$$20); ZVAL_STRING(_66$$20, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_65$$20, this_ptr, "hasoption", NULL, 0, _66$$20); zephir_check_temp_parameter(_66$$20); zephir_check_call_status(); if (zephir_is_true(_65$$20)) { ZEPHIR_INIT_VAR(_68$$21); ZVAL_STRING(_68$$21, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_67$$21, this_ptr, "getoption", NULL, 0, _68$$21); zephir_check_temp_parameter(_68$$21); zephir_check_call_status(); ZEPHIR_INIT_VAR(minResolution); zephir_fast_explode_str(minResolution, SL("x"), _67$$21, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(minWidth); zephir_array_fetch_long(&minWidth, minResolution, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 166 TSRMLS_CC); ZEPHIR_OBS_VAR(minHeight); zephir_array_fetch_long(&minHeight, minResolution, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 167 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(minWidth); ZVAL_LONG(minWidth, 1); ZEPHIR_INIT_NVAR(minHeight); ZVAL_LONG(minHeight, 1); } _69$$20 = ZEPHIR_LT(width, minWidth); if (!(_69$$20)) { _69$$20 = ZEPHIR_LT(height, minHeight); } if (_69$$20) { ZEPHIR_INIT_VAR(_70$$23); ZVAL_STRING(_70$$23, "messageMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _70$$23); zephir_check_temp_parameter(_70$$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(_70$$23); ZVAL_STRING(_70$$23, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_71$$23, this_ptr, "getoption", NULL, 0, _70$$23); zephir_check_temp_parameter(_70$$23); zephir_check_call_status(); zephir_array_update_string(&replacePairs, SL(":min"), &_71$$23, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_72$$24); ZVAL_STRING(_72$$24, "FileMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _72$$24); zephir_check_temp_parameter(_72$$24); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_70$$23); object_init_ex(_70$$23, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_71$$23, "strtr", &_12, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_74$$23); ZVAL_STRING(_74$$23, "code", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_73$$23, this_ptr, "getoption", NULL, 0, _74$$23); zephir_check_temp_parameter(_74$$23); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_74$$23); ZVAL_STRING(_74$$23, "FileMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _70$$23, "__construct", &_15, 440, _71$$23, field, _74$$23, _73$$23); zephir_check_temp_parameter(_74$$23); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _70$$23); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_66$$20); ZVAL_STRING(_66$$20, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_75$$20, this_ptr, "hasoption", NULL, 0, _66$$20); zephir_check_temp_parameter(_66$$20); zephir_check_call_status(); if (zephir_is_true(_75$$20)) { ZEPHIR_INIT_VAR(_77$$25); ZVAL_STRING(_77$$25, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_76$$25, this_ptr, "getoption", NULL, 0, _77$$25); zephir_check_temp_parameter(_77$$25); zephir_check_call_status(); ZEPHIR_INIT_VAR(maxResolution); zephir_fast_explode_str(maxResolution, SL("x"), _76$$25, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(maxWidth); zephir_array_fetch_long(&maxWidth, maxResolution, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 188 TSRMLS_CC); ZEPHIR_OBS_VAR(maxHeight); zephir_array_fetch_long(&maxHeight, maxResolution, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 189 TSRMLS_CC); _78$$25 = ZEPHIR_GT(width, maxWidth); if (!(_78$$25)) { _78$$25 = ZEPHIR_GT(height, maxHeight); } if (_78$$25) { ZEPHIR_INIT_VAR(_79$$26); ZVAL_STRING(_79$$26, "messageMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _79$$26); zephir_check_temp_parameter(_79$$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(_79$$26); ZVAL_STRING(_79$$26, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_80$$26, this_ptr, "getoption", NULL, 0, _79$$26); zephir_check_temp_parameter(_79$$26); zephir_check_call_status(); zephir_array_update_string(&replacePairs, SL(":max"), &_80$$26, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_81$$27); ZVAL_STRING(_81$$27, "FileMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _81$$27); zephir_check_temp_parameter(_81$$27); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_79$$26); object_init_ex(_79$$26, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_80$$26, "strtr", &_12, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_83$$26); ZVAL_STRING(_83$$26, "code", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_82$$26, this_ptr, "getoption", NULL, 0, _83$$26); zephir_check_temp_parameter(_83$$26); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_83$$26); ZVAL_STRING(_83$$26, "FileMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _79$$26, "__construct", &_15, 440, _80$$26, field, _83$$26, _82$$26); zephir_check_temp_parameter(_83$$26); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _79$$26); zephir_check_call_status(); RETURN_MM_BOOL(0); } } } RETURN_MM_BOOL(1); }
/** * Writes the log to the stream itself * * @param string $message * @param int $type * @param int $time * @see http://www.firephp.org/Wiki/Reference/Protocol */ PHP_METHOD(Phalcon_Logger_Adapter_Firephp, logInternal){ zval *message, *type, *time, *formatter, *applied_format; zval *initialized, *index; sapi_header_line h = { NULL, 0, 0 }; smart_str str = { NULL, 0, 0 }; int size, offset, num_bytes; const int chunk = 4960; /* If headers has already been sent, we can do nothing. Exit early. */ if (SG(headers_sent)) { RETURN_FALSE; } PHALCON_MM_GROW(); phalcon_fetch_params(1, 3, 0, &message, &type, &time); PHALCON_INIT_VAR(formatter); phalcon_call_method(formatter, this_ptr, "getformatter"); PHALCON_OBS_VAR(initialized); phalcon_read_static_property(&initialized, SL("phalcon\\logger\\adapter\\firephp"), SL("_initialized") TSRMLS_CC); if (!zend_is_true(initialized)) { /** * Send the required initialization headers. * Use Zend API here so that the user can see the progress and because * if we delegate this to Phalcon and there will be a fatal errors, * chances are that the headers will never ne sent. */ h.line = "X-Wf-Protocol-1: http://meta.wildfirehq.org/Protocol/JsonStream/0.2"; h.line_len = sizeof("X-Wf-Protocol-1: http://meta.wildfirehq.org/Protocol/JsonStream/0.2")-1; sapi_header_op(SAPI_HEADER_REPLACE, &h TSRMLS_CC); h.line = "X-Wf-1-Plugin-1: http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3"; h.line_len = sizeof("X-Wf-1-Plugin-1: http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3")-1; sapi_header_op(SAPI_HEADER_REPLACE, &h TSRMLS_CC); h.line = "X-Wf-1-Structure-1: http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1"; h.line_len = sizeof("X-Wf-1-Structure-1: http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1")-1; sapi_header_op(SAPI_HEADER_REPLACE, &h TSRMLS_CC); ZVAL_TRUE(initialized); /* This will also update the property because "initialized" was not separated */ } PHALCON_INIT_VAR(applied_format); phalcon_call_method_p3(applied_format, formatter, "format", message, type, time); if (Z_TYPE_P(applied_format) != IS_STRING) { PHALCON_THROW_EXCEPTION_STR(phalcon_logger_exception_ce, "The formatted message is not valid"); return; } PHALCON_OBS_VAR(index); phalcon_read_static_property(&index, SL("phalcon\\logger\\adapter\\firephp"), SL("_index") TSRMLS_CC); size = Z_STRLEN_P(applied_format); offset = 0; /** * We need to send the data in chunks not exceeding 5,000 bytes. * Allocate the smart string once to avoid performance penalties. */ smart_str_alloc4(&str, (size > chunk ? chunk : size), 0, num_bytes); while (size > 0) { smart_str_appends(&str, "X-Wf-1-1-1-"); smart_str_append_long(&str, Z_LVAL_P(index)); smart_str_appends(&str, ": "); num_bytes = size > chunk ? chunk : size; if (offset) { /* This is not the first chunk, prepend the payload with "|" */ smart_str_appendc(&str, '|'); } /* Grab the chunk from the encoded string */ smart_str_appendl(&str, Z_STRVAL_P(applied_format) + offset, num_bytes); size -= num_bytes; offset += num_bytes; if (size) { /* If we have more data to send, append "|/" */ smart_str_appendl(&str, "|\\", 2); } smart_str_0(&str); /* Not strictly necessary but just to be safe */ /* Send the result */ h.line = str.c; h.line_len = str.len; sapi_header_op(SAPI_HEADER_REPLACE, &h TSRMLS_CC); /* Update header index; this will update Phalcon\Logger\Adapter\Firephp as well */ ZVAL_LONG(index, Z_LVAL_P(index)+1); /** * Do not free and then reallocate memory. Just pretend the string * is empty. We will take care of deallocation later. */ str.len = 0; } /* Deallocate the smnart string if it is not empty */ if (str.c) { smart_str_free(&str); } PHALCON_MM_RESTORE(); }
/** * Create/Returns a new transaction or an existing one */ PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, getOrCreateTransaction) { HashTable *_2$$5; HashPosition _1$$5; int ZEPHIR_LAST_CALL_STATUS; zval *autoBegin_param = NULL, *dependencyInjector = NULL, *transaction = NULL, *transactions = NULL, *_0, *_5, *_6, **_3$$5, *_4$$7 = NULL; zend_bool autoBegin; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &autoBegin_param); if (!autoBegin_param) { autoBegin = 1; } else { autoBegin = zephir_get_boolval(autoBegin_param); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _0); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_transaction_exception_ce, "A dependency injector container is required to obtain the services related to the ORM", "phalcon/mvc/model/transaction/manager.zep", 189); return; } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_number"), PH_NOISY_CC); if (zephir_is_true(_0)) { ZEPHIR_OBS_VAR(transactions); zephir_read_property_this(&transactions, this_ptr, SL("_transactions"), PH_NOISY_CC); if (Z_TYPE_P(transactions) == IS_ARRAY) { zephir_is_iterable(transactions, &_2$$5, &_1$$5, 0, 1, "phalcon/mvc/model/transaction/manager.zep", 201); for ( ; zephir_hash_get_current_data_ex(_2$$5, (void**) &_3$$5, &_1$$5) == SUCCESS ; zephir_hash_move_backwards_ex(_2$$5, &_1$$5) ) { ZEPHIR_GET_HVALUE(transaction, _3$$5); if (Z_TYPE_P(transaction) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_4$$7); ZVAL_BOOL(_4$$7, 0); ZEPHIR_CALL_METHOD(NULL, transaction, "setisnewtransaction", NULL, 0, _4$$7); zephir_check_call_status(); RETURN_CCTOR(transaction); } } } } ZEPHIR_INIT_NVAR(transaction); object_init_ex(transaction, phalcon_mvc_model_transaction_ce); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_service"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_6); if (autoBegin) { ZVAL_BOOL(_6, 1); } else { ZVAL_BOOL(_6, 0); } ZEPHIR_CALL_METHOD(NULL, transaction, "__construct", NULL, 377, dependencyInjector, _6, _5); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, transaction, "settransactionmanager", NULL, 378, this_ptr); zephir_check_call_status(); zephir_update_property_array_append(this_ptr, SL("_transactions"), transaction TSRMLS_CC); RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("_number") TSRMLS_CC)); RETURN_CCTOR(transaction); }
/** * Performs a string conversion */ PHP_METHOD(Phalcon_Mvc_View_Engine_Volt, convertEncoding) { int ZEPHIR_LAST_CALL_STATUS; zend_bool _0, _1; zval *text_param = NULL, *from_param = NULL, *to_param = NULL; zval *text = NULL, *from = NULL, *to = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &text_param, &from_param, &to_param); zephir_get_strval(text, text_param); if (unlikely(Z_TYPE_P(from_param) != IS_STRING && Z_TYPE_P(from_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'from' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(from_param) == IS_STRING)) { zephir_get_strval(from, from_param); } else { ZEPHIR_INIT_VAR(from); ZVAL_EMPTY_STRING(from); } if (unlikely(Z_TYPE_P(to_param) != IS_STRING && Z_TYPE_P(to_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'to' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(to_param) == IS_STRING)) { zephir_get_strval(to, to_param); } else { ZEPHIR_INIT_VAR(to); ZVAL_EMPTY_STRING(to); } _0 = ZEPHIR_IS_STRING(from, "latin1"); if (!(_0)) { _0 = ZEPHIR_IS_STRING(to, "utf8"); } if (_0) { ZEPHIR_RETURN_CALL_FUNCTION("utf8_encode", NULL, 370, text); zephir_check_call_status(); RETURN_MM(); } _1 = ZEPHIR_IS_STRING(to, "latin1"); if (!(_1)) { _1 = ZEPHIR_IS_STRING(from, "utf8"); } if (_1) { ZEPHIR_RETURN_CALL_FUNCTION("utf8_decode", NULL, 371, text); zephir_check_call_status(); RETURN_MM(); } if ((zephir_function_exists_ex(SS("mb_convert_encoding") TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_FUNCTION("mb_convert_encoding", NULL, 181, text, from, to); zephir_check_call_status(); RETURN_MM(); } if ((zephir_function_exists_ex(SS("iconv") TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_FUNCTION("iconv", NULL, 372, from, to, text); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_exception_ce, "Any of 'mbstring' or 'iconv' is required to perform the charset conversion", "phalcon/mvc/view/engine/volt.zep", 205); return; }
/** * Renders a view using the template engine */ PHP_METHOD(Phalcon_Mvc_View_Engine_Volt, render) { HashTable *_1; HashPosition _0; int ZEPHIR_LAST_CALL_STATUS; zend_bool mustClean; zval *templatePath_param = NULL, *params, *mustClean_param = NULL, *compiler = NULL, *compiledTemplatePath = NULL, *key = NULL, *value = NULL, **_2, *_3 = NULL, *_4, *_5 = NULL; zval *templatePath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &templatePath_param, ¶ms, &mustClean_param); if (unlikely(Z_TYPE_P(templatePath_param) != IS_STRING && Z_TYPE_P(templatePath_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'templatePath' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(templatePath_param) == IS_STRING)) { zephir_get_strval(templatePath, templatePath_param); } else { ZEPHIR_INIT_VAR(templatePath); ZVAL_EMPTY_STRING(templatePath); } if (!mustClean_param) { mustClean = 0; } else { mustClean = zephir_get_boolval(mustClean_param); } if (mustClean) { ZEPHIR_CALL_FUNCTION(NULL, "ob_clean", NULL, 365); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&compiler, this_ptr, "getcompiler", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, compiler, "compile", NULL, 0, templatePath); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&compiledTemplatePath, compiler, "getcompiledtemplatepath", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(params) == IS_ARRAY) { zephir_is_iterable(params, &_1, &_0, 0, 0, "phalcon/mvc/view/engine/volt.zep", 118); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(key, _1, _0); ZEPHIR_GET_HVALUE(value, _2); ZEPHIR_CPY_WRT(_3, value); if (zephir_set_symbol(key, _3 TSRMLS_CC) == FAILURE){ return; } } } if (zephir_require_zval(compiledTemplatePath TSRMLS_CC) == FAILURE) { RETURN_MM_NULL(); } if (mustClean) { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_view"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&_5, "ob_get_contents", NULL, 120); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, _4, "setcontent", NULL, 0, _5); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); }
/** * Rebuild the list of access from the inherit lists * */ PHP_METHOD(Phalcon_Acl_Adapter_Memory, _rebuildAccessList){ zval *roles, *number_roles, *pow_roles, *two, *middle_roles; zval *middle, *roles_names, *roles_inherits; zval *changed = NULL, *i, *internal_access = NULL, *one = NULL, *role_name = NULL; zval *role_inherit = NULL, *inherit_internal = NULL, *access = NULL; zval *resource_name = NULL, *value = NULL, *name = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL; HashTable *ah0, *ah1, *ah2, *ah3; HashPosition hp0, hp1, hp2, hp3; zval **hd; PHALCON_MM_GROW(); PHALCON_OBS_VAR(roles); phalcon_read_property(&roles, this_ptr, SL("_roles"), PH_NOISY_CC); PHALCON_INIT_VAR(number_roles); phalcon_fast_count(number_roles, roles TSRMLS_CC); PHALCON_INIT_VAR(pow_roles); Z_LVAL_P(pow_roles) = Z_LVAL_P(number_roles) * Z_LVAL_P(number_roles); PHALCON_INIT_VAR(two); ZVAL_LONG(two, 2); PHALCON_INIT_VAR(middle_roles); div_function(middle_roles, pow_roles, two TSRMLS_CC); PHALCON_INIT_VAR(middle); PHALCON_CALL_FUNC_PARAMS_1(middle, "ceil", middle_roles); PHALCON_OBS_VAR(roles_names); phalcon_read_property(&roles_names, this_ptr, SL("_rolesNames"), PH_NOISY_CC); PHALCON_OBS_VAR(roles_inherits); phalcon_read_property(&roles_inherits, this_ptr, SL("_roleInherits"), PH_NOISY_CC); PHALCON_INIT_VAR(changed); ZVAL_BOOL(changed, 1); PHALCON_INIT_VAR(i); ZVAL_LONG(i, 0); while (1) { PHALCON_INIT_NVAR(r0); is_smaller_or_equal_function(r0, i, middle TSRMLS_CC); if (!zend_is_true(r0)) { break; } PHALCON_OBS_NVAR(internal_access); phalcon_read_property(&internal_access, this_ptr, SL("_access"), PH_NOISY_CC); if (!phalcon_is_iterable(roles_names, &ah0, &hp0, 0, 0 TSRMLS_CC)) { return; } while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) { PHALCON_GET_FOREACH_KEY(role_name, ah0, hp0); PHALCON_GET_FOREACH_VALUE(one); if (phalcon_array_isset(roles_inherits, role_name)) { PHALCON_OBS_NVAR(r1); phalcon_array_fetch(&r1, roles_inherits, role_name, PH_NOISY_CC); if (!phalcon_is_iterable(r1, &ah1, &hp1, 0, 0 TSRMLS_CC)) { return; } while (zend_hash_get_current_data_ex(ah1, (void**) &hd, &hp1) == SUCCESS) { PHALCON_GET_FOREACH_VALUE(role_inherit); if (phalcon_array_isset(internal_access, role_inherit)) { PHALCON_OBS_NVAR(inherit_internal); phalcon_array_fetch(&inherit_internal, internal_access, role_inherit, PH_NOISY_CC); if (!phalcon_is_iterable(inherit_internal, &ah2, &hp2, 0, 0 TSRMLS_CC)) { return; } while (zend_hash_get_current_data_ex(ah2, (void**) &hd, &hp2) == SUCCESS) { PHALCON_GET_FOREACH_KEY(resource_name, ah2, hp2); PHALCON_GET_FOREACH_VALUE(access); if (!phalcon_is_iterable(access, &ah3, &hp3, 0, 0 TSRMLS_CC)) { return; } while (zend_hash_get_current_data_ex(ah3, (void**) &hd, &hp3) == SUCCESS) { PHALCON_GET_FOREACH_KEY(name, ah3, hp3); PHALCON_GET_FOREACH_VALUE(value); if (phalcon_array_isset(internal_access, role_name)) { PHALCON_OBS_NVAR(r2); phalcon_array_fetch(&r2, internal_access, role_name, PH_NOISY_CC); if (phalcon_array_isset(r2, resource_name)) { PHALCON_OBS_NVAR(r3); phalcon_array_fetch(&r3, internal_access, role_name, PH_NOISY_CC); PHALCON_OBS_NVAR(r4); phalcon_array_fetch(&r4, r3, resource_name, PH_NOISY_CC); if (phalcon_array_isset(r4, name)) { zend_hash_move_forward_ex(ah3, &hp3); continue; } } } phalcon_array_update_zval_zval_zval_multi_3(&internal_access, role_name, resource_name, name, &value, 0 TSRMLS_CC); PHALCON_INIT_NVAR(changed); ZVAL_BOOL(changed, 1); zend_hash_move_forward_ex(ah3, &hp3); } zend_hash_move_forward_ex(ah2, &hp2); } } zend_hash_move_forward_ex(ah1, &hp1); } } zend_hash_move_forward_ex(ah0, &hp0); } if (zend_is_true(changed)) { phalcon_update_property_zval(this_ptr, SL("_access"), internal_access TSRMLS_CC); } PHALCON_SEPARATE(i); increment_function(i); } PHALCON_MM_RESTORE(); }
/** * Phalcon\Filter constructor */ PHP_METHOD(Phalcon_Filter, __construct){ phalcon_update_property_empty_array(phalcon_filter_ce, this_ptr, SL("_filters") TSRMLS_CC); }
/** * Phalcon\CLI\Router constructor */ PHP_METHOD(Phalcon_CLI_Router, __construct){ phalcon_update_property_empty_array(getThis(), SL("_params")); phalcon_update_property_empty_array(getThis(), SL("_defaultParams")); }
/** * Generates SQL to add the table creation options * * @param array $definition * @return array */ PHP_METHOD(Phalcon_Db_Dialect_Postgresql, _getTableOptions){ zval *definition = NULL, *table_options = NULL, *engine = NULL, *auto_increment = NULL; zval *table_collation = NULL, *collation_parts = NULL; zval *a0 = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL, *r6 = NULL; zval *r7 = NULL, *r8 = NULL, *r9 = NULL, *r10 = NULL, *r11 = NULL, *r12 = NULL, *r13 = NULL; zval *r14 = NULL, *r15 = NULL, *r16 = NULL, *r17 = NULL, *r18 = NULL; zval *c0 = NULL, *c1 = NULL; int eval_int; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &definition) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_INIT_VAR(a0); array_init(a0); PHALCON_CPY_WRT(table_options, a0); PHALCON_ALLOC_ZVAL_MM(r0); phalcon_array_fetch_string(&r0, definition, SL("options"), PHALCON_NOISY TSRMLS_CC); eval_int = phalcon_array_isset_string(r0, SL("ENGINE")+1); if (eval_int) { PHALCON_ALLOC_ZVAL_MM(r1); phalcon_array_fetch_string(&r1, definition, SL("options"), PHALCON_NOISY TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(r2); phalcon_array_fetch_string(&r2, r1, SL("ENGINE"), PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(engine, r2); PHALCON_ALLOC_ZVAL_MM(r3); phalcon_array_fetch_string(&r3, definition, SL("options"), PHALCON_NOISY TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(r4); phalcon_array_fetch_string(&r4, r3, SL("ENGINE"), PHALCON_NOISY TSRMLS_CC); if (zend_is_true(r4)) { PHALCON_ALLOC_ZVAL_MM(r5); PHALCON_CONCAT_SV(r5, "ENGINE=", engine); phalcon_array_append(&table_options, r5, PHALCON_SEPARATE_PLZ TSRMLS_CC); } } PHALCON_ALLOC_ZVAL_MM(r6); phalcon_array_fetch_string(&r6, definition, SL("options"), PHALCON_NOISY TSRMLS_CC); eval_int = phalcon_array_isset_string(r6, SL("AUTO_INCREMENT")+1); if (eval_int) { PHALCON_ALLOC_ZVAL_MM(r7); phalcon_array_fetch_string(&r7, definition, SL("options"), PHALCON_NOISY TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(r8); phalcon_array_fetch_string(&r8, r7, SL("AUTO_INCREMENT"), PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(auto_increment, r8); if (zend_is_true(auto_increment)) { PHALCON_ALLOC_ZVAL_MM(r9); PHALCON_CONCAT_SV(r9, "AUTO_INCREMENT=", auto_increment); phalcon_array_append(&table_options, r9, PHALCON_SEPARATE_PLZ TSRMLS_CC); } } PHALCON_ALLOC_ZVAL_MM(r10); phalcon_array_fetch_string(&r10, definition, SL("options"), PHALCON_NOISY TSRMLS_CC); eval_int = phalcon_array_isset_string(r10, SL("TABLE_COLLATION")+1); if (eval_int) { PHALCON_ALLOC_ZVAL_MM(r11); phalcon_array_fetch_string(&r11, definition, SL("options"), PHALCON_NOISY TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(r12); phalcon_array_fetch_string(&r12, r11, SL("TABLE_COLLATION"), PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(table_collation, r12); if (zend_is_true(table_collation)) { PHALCON_INIT_VAR(c0); ZVAL_STRING(c0, "_", 1); PHALCON_ALLOC_ZVAL_MM(r13); phalcon_fast_explode(r13, c0, table_collation TSRMLS_CC); PHALCON_CPY_WRT(collation_parts, r13); PHALCON_ALLOC_ZVAL_MM(r14); PHALCON_ALLOC_ZVAL_MM(r15); phalcon_array_fetch_long(&r15, collation_parts, 0, PHALCON_NOISY TSRMLS_CC); PHALCON_CONCAT_SV(r14, "DEFAULT CHARSET=", r15); phalcon_array_append(&table_options, r14, PHALCON_SEPARATE_PLZ TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(r16); PHALCON_CONCAT_SV(r16, "COLLATE=", table_collation); phalcon_array_append(&table_options, r16, PHALCON_SEPARATE_PLZ TSRMLS_CC); } } PHALCON_ALLOC_ZVAL_MM(r17); phalcon_fast_count(r17, table_options TSRMLS_CC); if (zend_is_true(r17)) { PHALCON_INIT_VAR(c1); ZVAL_STRING(c1, " ", 1); PHALCON_ALLOC_ZVAL_MM(r18); phalcon_fast_join(r18, c1, table_options TSRMLS_CC); RETURN_DZVAL(r18); } PHALCON_MM_RESTORE(); RETURN_NULL(); }
/** * Returns a slice of the resultset to show in the pagination * * @return stdClass */ PHP_METHOD(Phalcon_Paginator_Adapter_NativeArray, getPaginate){ zval *one, *config, *items, *show, *page_number = NULL, *page; zval *number, *rounded_total, *total_pages, *before_page_number; zval *start, *slice, *next = NULL, *before = NULL; PHALCON_MM_GROW(); /** * TODO: Rewrite the whole method! */ PHALCON_INIT_VAR(one); ZVAL_LONG(one, 1); PHALCON_OBS_VAR(config); phalcon_read_property_this(&config, this_ptr, SL("_config"), PH_NOISY_CC); PHALCON_OBS_VAR(items); phalcon_array_fetch_string(&items, config, SL("data"), PH_NOISY); if (Z_TYPE_P(items) != IS_ARRAY) { PHALCON_THROW_EXCEPTION_STR(phalcon_paginator_exception_ce, "Invalid data for paginator"); return; } PHALCON_OBS_VAR(show); phalcon_read_property_this(&show, this_ptr, SL("_limitRows"), PH_NOISY_CC); PHALCON_OBS_VAR(page_number); phalcon_read_property_this(&page_number, this_ptr, SL("_page"), PH_NOISY_CC); if (!zend_is_true(page_number)) { PHALCON_CPY_WRT(page_number, one); } PHALCON_INIT_VAR(page); object_init(page); PHALCON_INIT_VAR(number); phalcon_fast_count(number, items TSRMLS_CC); PHALCON_INIT_VAR(rounded_total); div_function(rounded_total, number, show TSRMLS_CC); PHALCON_INIT_VAR(total_pages); ZVAL_LONG(total_pages, phalcon_get_intval(rounded_total)); /** * Increase total_pages if wasn't integer */ if (!PHALCON_IS_EQUAL(total_pages, rounded_total)) { phalcon_increment(total_pages); } PHALCON_INIT_VAR(before_page_number); sub_function(before_page_number, page_number, one TSRMLS_CC); PHALCON_INIT_VAR(start); mul_function(start, show, before_page_number TSRMLS_CC); PHALCON_INIT_VAR(slice); phalcon_call_func_p3(slice, "array_slice", items, start, show); phalcon_update_property_zval(page, SL("items"), slice TSRMLS_CC); if (PHALCON_LT(page_number, total_pages)) { PHALCON_INIT_VAR(next); phalcon_add_function(next, page_number, one TSRMLS_CC); } else { PHALCON_CPY_WRT(next, total_pages); } phalcon_update_property_zval(page, SL("next"), next TSRMLS_CC); if (PHALCON_GT(page_number, one)) { PHALCON_INIT_VAR(before); sub_function(before, page_number, one TSRMLS_CC); } else { PHALCON_CPY_WRT(before, one); } phalcon_update_property_zval(page, SL("first"), one TSRMLS_CC); phalcon_update_property_zval(page, SL("before"), before TSRMLS_CC); phalcon_update_property_zval(page, SL("current"), page_number TSRMLS_CC); phalcon_update_property_zval(page, SL("last"), total_pages TSRMLS_CC); phalcon_update_property_zval(page, SL("total_pages"), total_pages TSRMLS_CC); phalcon_update_property_zval(page, SL("total_items"), number TSRMLS_CC); RETURN_CTOR(page); }
/** * Generates SQL to create a table in PostgreSQL * * @param string $tableName * @param string $schemaName * @param array $definition * @return string */ PHP_METHOD(Phalcon_Db_Dialect_Postgresql, createTable){ zval *table_name = NULL, *schema_name = NULL, *definition = NULL; zval *table = NULL, *temporary = NULL, *sql = NULL, *create_lines = NULL, *column = NULL; zval *column_line = NULL, *index = NULL, *index_name = NULL, *column_list = NULL; zval *reference = NULL, *reference_sql = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL, *r6 = NULL; zval *r7 = NULL, *r8 = NULL, *r9 = NULL, *r10 = NULL, *r11 = NULL, *r12 = NULL, *r13 = NULL; zval *r14 = NULL, *r15 = NULL, *r16 = NULL, *r17 = NULL, *r18 = NULL, *r19 = NULL, *r20 = NULL; zval *r21 = NULL, *r22 = NULL, *r23 = NULL, *r24 = NULL, *r25 = NULL, *r26 = NULL, *r27 = NULL; zval *r28 = NULL, *r29 = NULL, *r30 = NULL; zval *a0 = NULL; zval *t0 = NULL, *t1 = NULL; zval *c0 = NULL; HashTable *ah0, *ah1, *ah2; HashPosition hp0, hp1, hp2; zval **hd; int eval_int; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz", &table_name, &schema_name, &definition) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } if (zend_is_true(schema_name)) { PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CONCAT_VSV(r0, schema_name, ".", table_name); PHALCON_CPY_WRT(table, r0); } else { PHALCON_CPY_WRT(table, table_name); } PHALCON_INIT_VAR(temporary); ZVAL_BOOL(temporary, 0); eval_int = phalcon_array_isset_string(definition, SL("options")+1); if (eval_int) { PHALCON_ALLOC_ZVAL_MM(r1); phalcon_array_fetch_string(&r1, definition, SL("options"), PHALCON_NOISY TSRMLS_CC); eval_int = phalcon_array_isset_string(r1, SL("temporary")+1); if (eval_int) { PHALCON_ALLOC_ZVAL_MM(r2); phalcon_array_fetch_string(&r2, definition, SL("options"), PHALCON_NOISY TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(r3); phalcon_array_fetch_string(&r3, r2, SL("temporary"), PHALCON_NOISY TSRMLS_CC); if (zend_is_true(r3)) { PHALCON_INIT_VAR(temporary); ZVAL_BOOL(temporary, 1); } } } if (zend_is_true(temporary)) { PHALCON_ALLOC_ZVAL_MM(r4); PHALCON_CONCAT_SVS(r4, "CREATE TEMPORARY TABLE ", table, " (\n\t"); PHALCON_CPY_WRT(sql, r4); } else { PHALCON_ALLOC_ZVAL_MM(r5); PHALCON_CONCAT_SVS(r5, "CREATE TABLE ", table, " (\n\t"); PHALCON_CPY_WRT(sql, r5); } PHALCON_INIT_VAR(a0); array_init(a0); PHALCON_CPY_WRT(create_lines, a0); PHALCON_ALLOC_ZVAL_MM(r6); phalcon_array_fetch_string(&r6, definition, SL("columns"), PHALCON_NOISY TSRMLS_CC); if (phalcon_valid_foreach(r6 TSRMLS_CC)) { ah0 = Z_ARRVAL_P(r6); zend_hash_internal_pointer_reset_ex(ah0, &hp0); fes_46b6_2: if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){ goto fee_46b6_2; } PHALCON_INIT_VAR(column); ZVAL_ZVAL(column, *hd, 1, 0); PHALCON_INIT_VAR(r7); PHALCON_INIT_VAR(r8); PHALCON_CALL_METHOD(r8, column, "getname", PHALCON_NO_CHECK); PHALCON_INIT_VAR(r9); PHALCON_CALL_SELF_PARAMS_1(r9, this_ptr, "getcolumndefinition", column); PHALCON_CONCAT_SVSV(r7, "`", r8, "` ", r9); PHALCON_CPY_WRT(column_line, r7); PHALCON_INIT_VAR(r10); PHALCON_CALL_METHOD(r10, column, "isnotnull", PHALCON_NO_CHECK); if (zend_is_true(r10)) { PHALCON_INIT_VAR(t0); ZVAL_STRING(t0, " NOT NULL", 1); phalcon_concat_self(&column_line, t0 TSRMLS_CC); } PHALCON_INIT_VAR(r11); PHALCON_CALL_METHOD(r11, column, "isautoincrement", PHALCON_NO_CHECK); if (zend_is_true(r11)) { PHALCON_INIT_VAR(t1); ZVAL_STRING(t1, " AUTO_INCREMENT", 1); phalcon_concat_self(&column_line, t1 TSRMLS_CC); } phalcon_array_append(&create_lines, column_line, PHALCON_SEPARATE_PLZ TSRMLS_CC); zend_hash_move_forward_ex(ah0, &hp0); goto fes_46b6_2; fee_46b6_2: if(0){} } else { return; } eval_int = phalcon_array_isset_string(definition, SL("indexes")+1); if (eval_int) { PHALCON_ALLOC_ZVAL_MM(r12); phalcon_array_fetch_string(&r12, definition, SL("indexes"), PHALCON_NOISY TSRMLS_CC); if (phalcon_valid_foreach(r12 TSRMLS_CC)) { ah1 = Z_ARRVAL_P(r12); zend_hash_internal_pointer_reset_ex(ah1, &hp1); fes_46b6_3: if(zend_hash_get_current_data_ex(ah1, (void**) &hd, &hp1) != SUCCESS){ goto fee_46b6_3; } PHALCON_INIT_VAR(index); ZVAL_ZVAL(index, *hd, 1, 0); PHALCON_INIT_VAR(r13); PHALCON_CALL_METHOD(r13, index, "getname", PHALCON_NO_CHECK); PHALCON_CPY_WRT(index_name, r13); PHALCON_INIT_VAR(r14); PHALCON_INIT_VAR(r15); PHALCON_CALL_METHOD(r15, index, "getcolumns", PHALCON_NO_CHECK); PHALCON_CALL_SELF_PARAMS_1(r14, this_ptr, "getcolumnlist", r15); PHALCON_CPY_WRT(column_list, r14); if (PHALCON_COMPARE_STRING(index_name, "PRIMARY")) { PHALCON_INIT_VAR(r16); PHALCON_CONCAT_SVS(r16, "PRIMARY KEY (", column_list, ")"); phalcon_array_append(&create_lines, r16, PHALCON_SEPARATE_PLZ TSRMLS_CC); } else { PHALCON_INIT_VAR(r17); PHALCON_CONCAT_SVSVS(r17, "KEY `", index_name, "` (", column_list, ")"); phalcon_array_append(&create_lines, r17, PHALCON_SEPARATE_PLZ TSRMLS_CC); } zend_hash_move_forward_ex(ah1, &hp1); goto fes_46b6_3; fee_46b6_3: if(0){} } else { return; } } eval_int = phalcon_array_isset_string(definition, SL("references")+1); if (eval_int) { PHALCON_ALLOC_ZVAL_MM(r18); phalcon_array_fetch_string(&r18, definition, SL("references"), PHALCON_NOISY TSRMLS_CC); if (phalcon_valid_foreach(r18 TSRMLS_CC)) { ah2 = Z_ARRVAL_P(r18); zend_hash_internal_pointer_reset_ex(ah2, &hp2); fes_46b6_4: if(zend_hash_get_current_data_ex(ah2, (void**) &hd, &hp2) != SUCCESS){ goto fee_46b6_4; } PHALCON_INIT_VAR(reference); ZVAL_ZVAL(reference, *hd, 1, 0); PHALCON_INIT_VAR(r19); PHALCON_INIT_VAR(r20); PHALCON_CALL_METHOD(r20, reference, "getname", PHALCON_NO_CHECK); PHALCON_INIT_VAR(r21); PHALCON_INIT_VAR(r22); PHALCON_CALL_METHOD(r22, reference, "getcolumns", PHALCON_NO_CHECK); PHALCON_CALL_SELF_PARAMS_1(r21, this_ptr, "getcolumnlist", r22); PHALCON_CONCAT_SVSV(r19, "CONSTRAINT `", r20, "` FOREIGN KEY (", r21); PHALCON_CPY_WRT(reference_sql, r19); PHALCON_INIT_VAR(r23); PHALCON_INIT_VAR(r24); PHALCON_CALL_METHOD(r24, reference, "getreferencedtable", PHALCON_NO_CHECK); PHALCON_INIT_VAR(r25); PHALCON_INIT_VAR(r26); PHALCON_CALL_METHOD(r26, reference, "getreferencedcolumns", PHALCON_NO_CHECK); PHALCON_CALL_SELF_PARAMS_1(r25, this_ptr, "getcolumnlist", r26); PHALCON_CONCAT_SVSVS(r23, ") REFERENCES `", r24, "`(", r25, ")"); phalcon_concat_self(&reference_sql, r23 TSRMLS_CC); phalcon_array_append(&create_lines, reference_sql, PHALCON_SEPARATE_PLZ TSRMLS_CC); zend_hash_move_forward_ex(ah2, &hp2); goto fes_46b6_4; fee_46b6_4: if(0){} } else { return; } } PHALCON_ALLOC_ZVAL_MM(r27); PHALCON_INIT_VAR(c0); ZVAL_STRING(c0, ",\n\t", 1); PHALCON_ALLOC_ZVAL_MM(r28); phalcon_fast_join(r28, c0, create_lines TSRMLS_CC); PHALCON_CONCAT_VS(r27, r28, "\n)"); phalcon_concat_self(&sql, r27 TSRMLS_CC); eval_int = phalcon_array_isset_string(definition, SL("options")+1); if (eval_int) { PHALCON_ALLOC_ZVAL_MM(r29); PHALCON_ALLOC_ZVAL_MM(r30); PHALCON_CALL_SELF_PARAMS_1(r30, this_ptr, "_gettableoptions", definition); PHALCON_CONCAT_SV(r29, " ", r30); phalcon_concat_self(&sql, r29 TSRMLS_CC); } RETURN_CTOR(sql); }
/** * Executes the validator */ PHP_METHOD(Phalcon_Mvc_Model_Validator_Url, validate) { zval *_6$$5; zend_bool _2; zend_long ZEPHIR_LAST_CALL_STATUS; zval *record, *field = NULL, *value = NULL, *message = NULL, *_0 = NULL, *_1 = NULL, _3, *_4 = NULL, *_5$$5 = NULL, *_7$$5 = 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/url.zep", 70); 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(&_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); } ZEPHIR_SINIT_VAR(_3); ZVAL_LONG(&_3, 273); ZEPHIR_CALL_FUNCTION(&_4, "filter_var", NULL, 204, value, &_3); zephir_check_call_status(); if (!(zephir_is_true(_4))) { ZEPHIR_INIT_VAR(_5$$5); ZVAL_STRING(_5$$5, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _5$$5); zephir_check_temp_parameter(_5$$5); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(message); ZVAL_STRING(message, ":field does not have a valid url format", 1); } ZEPHIR_INIT_VAR(_6$$5); zephir_create_array(_6$$5, 1, 0 TSRMLS_CC); zephir_array_update_string(&_6$$5, SL(":field"), &field, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_FUNCTION(&_7$$5, "strtr", NULL, 27, message, _6$$5); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_5$$5); ZVAL_STRING(_5$$5, "Url", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", NULL, 0, _7$$5, field, _5$$5); zephir_check_temp_parameter(_5$$5); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); }
/** * Do a role inherit from another existing role * * @param string $roleName * @param string $roleToInherit */ PHP_METHOD(Phalcon_Acl_Adapter_Memory, addInherit){ zval *role_name, *role_to_inherit, *roles_names; zval *exception_message = NULL, *role_inherit_name = NULL; zval *roles_inherits, *empty_arr, *_roleInherits; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &role_name, &role_to_inherit) == FAILURE) { RETURN_MM_NULL(); } PHALCON_OBS_VAR(roles_names); phalcon_read_property(&roles_names, this_ptr, SL("_rolesNames"), PH_NOISY_CC); if (!phalcon_array_isset(roles_names, role_name)) { PHALCON_INIT_VAR(exception_message); PHALCON_CONCAT_SVS(exception_message, "Role '", role_name, "' does not exist in the role list"); PHALCON_THROW_EXCEPTION_ZVAL(phalcon_acl_exception_ce, exception_message); return; } if (Z_TYPE_P(role_to_inherit) == IS_OBJECT) { PHALCON_INIT_VAR(role_inherit_name); PHALCON_CALL_METHOD(role_inherit_name, role_to_inherit, "getname"); } else { PHALCON_CPY_WRT(role_inherit_name, role_to_inherit); } /** * Check if the role to inherit is valid */ if (!phalcon_array_isset(roles_names, role_inherit_name)) { PHALCON_INIT_NVAR(exception_message); PHALCON_CONCAT_SVS(exception_message, "Role '", role_inherit_name, "' (to inherit) does not exist in the role list"); PHALCON_THROW_EXCEPTION_ZVAL(phalcon_acl_exception_ce, exception_message); return; } if (PHALCON_IS_EQUAL(role_inherit_name, role_name)) { RETURN_MM_FALSE; } PHALCON_OBS_VAR(roles_inherits); phalcon_read_property(&roles_inherits, this_ptr, SL("_roleInherits"), PH_NOISY_CC); if (!phalcon_array_isset(roles_inherits, role_name)) { PHALCON_INIT_VAR(empty_arr); array_init(empty_arr); phalcon_update_property_array(this_ptr, SL("_roleInherits"), role_name, empty_arr TSRMLS_CC); } PHALCON_OBS_VAR(_roleInherits); phalcon_read_property(&_roleInherits, this_ptr, SL("_roleInherits"), PH_NOISY_CC); phalcon_array_update_append_multi_2(&_roleInherits, role_name, role_inherit_name, 0 TSRMLS_CC); phalcon_update_property_zval(this_ptr, SL("_roleInherits"), _roleInherits TSRMLS_CC); /** * Re-build the access list with its inherited roles */ PHALCON_CALL_METHOD_NORETURN(this_ptr, "_rebuildaccesslist"); RETURN_MM_TRUE; }
/** * Sets/Resets the shared instance related to the service * * @param mixed $sharedInstance */ PHP_METHOD(Phalcon_DI_Service, setSharedInstance){ zval *shared_instance; phalcon_fetch_params(0, 1, 0, &shared_instance); phalcon_update_property_zval(getThis(), SL("_sharedInstance"), shared_instance); }
/** * Adds access to resources * * @param string $resourceName * @param mixed $accessList */ PHP_METHOD(Phalcon_Acl_Adapter_Memory, addResourceAccess){ zval *resource_name, *access_list, *resources_names; zval *exception_message, *access_name = NULL, *internal_access_list = NULL; zval *_accessList = NULL; zval *r0 = NULL, *r1 = NULL; zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL; HashTable *ah0; HashPosition hp0; zval **hd; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &resource_name, &access_list) == FAILURE) { RETURN_MM_NULL(); } PHALCON_OBS_VAR(resources_names); phalcon_read_property(&resources_names, this_ptr, SL("_resourcesNames"), PH_NOISY_CC); if (!phalcon_array_isset(resources_names, resource_name)) { PHALCON_INIT_VAR(exception_message); PHALCON_CONCAT_SVS(exception_message, "Resource '", resource_name, "' does not exist in ACL"); PHALCON_THROW_EXCEPTION_ZVAL(phalcon_acl_exception_ce, exception_message); return; } if (Z_TYPE_P(access_list) == IS_ARRAY) { if (!phalcon_is_iterable(access_list, &ah0, &hp0, 0, 0 TSRMLS_CC)) { return; } while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) { PHALCON_GET_FOREACH_VALUE(access_name); PHALCON_OBS_NVAR(internal_access_list); phalcon_read_property(&internal_access_list, this_ptr, SL("_accessList"), PH_NOISY_CC); PHALCON_OBS_NVAR(r0); phalcon_array_fetch(&r0, internal_access_list, resource_name, PH_NOISY_CC); if (!phalcon_array_isset(r0, access_name)) { PHALCON_OBS_NVAR(_accessList); phalcon_read_property(&_accessList, this_ptr, SL("_accessList"), PH_NOISY_CC); PHALCON_INIT_NVAR(t0); ZVAL_LONG(t0, 1); phalcon_array_update_multi_2(&_accessList, resource_name, access_name, &t0, 0 TSRMLS_CC); phalcon_update_property_zval(this_ptr, SL("_accessList"), _accessList TSRMLS_CC); } zend_hash_move_forward_ex(ah0, &hp0); } } else { if (Z_TYPE_P(access_list) == IS_STRING) { PHALCON_OBS_VAR(t1); phalcon_read_property(&t1, this_ptr, SL("_accessList"), PH_NOISY_CC); PHALCON_OBS_VAR(r1); phalcon_array_fetch(&r1, t1, resource_name, PH_NOISY_CC); if (!phalcon_array_isset(r1, access_list)) { PHALCON_OBS_VAR(t2); phalcon_read_property(&t2, this_ptr, SL("_accessList"), PH_NOISY_CC); PHALCON_INIT_VAR(t3); ZVAL_LONG(t3, 1); phalcon_array_update_multi_2(&t2, resource_name, access_list, &t3, 0 TSRMLS_CC); phalcon_update_property_zval(this_ptr, SL("_accessList"), t2 TSRMLS_CC); } } } RETURN_MM_TRUE; }
/** * Resolves the service * * @param array $parameters * @param Phalcon\DIInterface $dependencyInjector * @return object */ PHP_METHOD(Phalcon_DI_Service, resolve){ zval *parameters = NULL, *dependency_injector = NULL, name = {}, shared = {}, shared_instance = {}, definition = {}, builder = {}; int found = 0, ishared = 0; phalcon_fetch_params(0, 0, 2, ¶meters, &dependency_injector); if (!parameters) { parameters = &PHALCON_GLOBAL(z_null); } if (!dependency_injector) { dependency_injector = &PHALCON_GLOBAL(z_null); } phalcon_return_property(&shared, getThis(), SL("_shared")); phalcon_return_property(&shared_instance, getThis(), SL("_sharedInstance")); ishared = zend_is_true(&shared); /* Check if the service is shared */ if (ishared && Z_TYPE(shared_instance) != IS_NULL) { RETURN_CTORW(&shared_instance); } phalcon_return_property(&definition, getThis(), SL("_definition")); if (Z_TYPE(definition) == IS_STRING) { /* String definitions can be class names without implicit parameters */ if (phalcon_class_exists(&definition, 1) != NULL) { found = 1; if (Z_TYPE_P(parameters) == IS_ARRAY) { RETURN_ON_FAILURE(phalcon_create_instance_params(return_value, &definition, parameters)); } else { RETURN_ON_FAILURE(phalcon_create_instance(return_value, &definition)); } } } else if (likely(Z_TYPE(definition) == IS_OBJECT)) { /* Object definitions can be a Closure or an already resolved instance */ found = 1; if (instanceof_function_ex(Z_OBJCE(definition), zend_ce_closure, 0)) { if (likely(Z_TYPE_P(dependency_injector) == IS_OBJECT)) { PHALCON_CALL_CE_STATICW(&definition, zend_ce_closure, "bind", &definition, dependency_injector); } if (Z_TYPE_P(parameters) == IS_ARRAY) { PHALCON_CALL_USER_FUNC_ARRAYW(return_value, &definition, parameters); } else { PHALCON_CALL_USER_FUNCW(return_value, &definition); } } else { PHALCON_CPY_WRT(return_value, &definition); } } else if (Z_TYPE(definition) == IS_ARRAY) { found = 1; /* Array definitions require a 'className' parameter */ object_init_ex(&builder, phalcon_di_service_builder_ce); PHALCON_CALL_METHODW(return_value, &builder, "build", dependency_injector, &definition, parameters); } if (!EG(exception)) { if (found) { if (ishared) { phalcon_update_property_zval(getThis(), SL("_sharedInstance"), return_value); } /* Update the shared instance if the service is shared */ phalcon_update_property_bool(getThis(), SL("_resolved"), 1); } else { phalcon_return_property(&name, getThis(), SL("_name")); PHALCON_THROW_EXCEPTION_FORMATW(phalcon_di_exception_ce, "Service '%s' cannot be resolved", Z_STRVAL(name)); } } }
/** * Checks if a role has access to a resource * * @param string $roleName * @param string $resourceName * @param string $access * @param string $action */ PHP_METHOD(Phalcon_Acl_Adapter_Memory, _allowOrDeny){ zval *role_name, *resource_name, *access, *action; zval *roles_names, *exception_message = NULL, *resources_names; zval *default_access, *access_list, *access_name = NULL; zval *empty_arr = NULL, *_access = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL, *r6 = NULL; zval *r7 = NULL; zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL, *t4 = NULL, *t5 = NULL, *t6 = NULL; zval *t7 = NULL, *t8 = NULL, *t9 = NULL; HashTable *ah0, *ah1; HashPosition hp0, hp1; zval **hd; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzzz", &role_name, &resource_name, &access, &action) == FAILURE) { RETURN_MM_NULL(); } PHALCON_OBS_VAR(roles_names); phalcon_read_property(&roles_names, this_ptr, SL("_rolesNames"), PH_NOISY_CC); if (!phalcon_array_isset(roles_names, role_name)) { PHALCON_INIT_VAR(exception_message); PHALCON_CONCAT_SVS(exception_message, "Role \"", role_name, "\" does not exist in ACL"); PHALCON_THROW_EXCEPTION_ZVAL(phalcon_acl_exception_ce, exception_message); return; } PHALCON_OBS_VAR(resources_names); phalcon_read_property(&resources_names, this_ptr, SL("_resourcesNames"), PH_NOISY_CC); if (!phalcon_array_isset(resources_names, resource_name)) { PHALCON_INIT_NVAR(exception_message); PHALCON_CONCAT_SVS(exception_message, "Resource \"", resource_name, "\" does not exist in ACL"); PHALCON_THROW_EXCEPTION_ZVAL(phalcon_acl_exception_ce, exception_message); return; } PHALCON_OBS_VAR(default_access); phalcon_read_property(&default_access, this_ptr, SL("_defaultAccess"), PH_NOISY_CC); if (Z_TYPE_P(access) == IS_ARRAY) { PHALCON_OBS_VAR(access_list); phalcon_read_property(&access_list, this_ptr, SL("_accessList"), PH_NOISY_CC); if (!phalcon_is_iterable(access, &ah0, &hp0, 0, 0 TSRMLS_CC)) { return; } while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) { PHALCON_GET_FOREACH_VALUE(access_name); PHALCON_OBS_NVAR(r0); phalcon_array_fetch(&r0, access_list, resource_name, PH_NOISY_CC); if (!phalcon_array_isset(r0, access_name)) { PHALCON_INIT_NVAR(exception_message); PHALCON_CONCAT_SVSVS(exception_message, "Acccess '", access_name, "' does not exist in resource '", resource_name, "' in ACL"); PHALCON_THROW_EXCEPTION_ZVAL(phalcon_acl_exception_ce, exception_message); return; } zend_hash_move_forward_ex(ah0, &hp0); } if (!phalcon_is_iterable(access, &ah1, &hp1, 0, 0 TSRMLS_CC)) { return; } while (zend_hash_get_current_data_ex(ah1, (void**) &hd, &hp1) == SUCCESS) { PHALCON_GET_FOREACH_VALUE(access_name); PHALCON_OBS_NVAR(t0); phalcon_read_property(&t0, this_ptr, SL("_access"), PH_NOISY_CC); PHALCON_OBS_NVAR(r1); phalcon_array_fetch(&r1, t0, role_name, PH_NOISY_CC); if (!phalcon_array_isset(r1, resource_name)) { PHALCON_INIT_NVAR(empty_arr); array_init(empty_arr); PHALCON_OBS_NVAR(_access); phalcon_read_property(&_access, this_ptr, SL("_access"), PH_NOISY_CC); phalcon_array_update_multi_2(&_access, role_name, resource_name, &empty_arr, 0 TSRMLS_CC); phalcon_update_property_zval(this_ptr, SL("_access"), _access TSRMLS_CC); } PHALCON_OBS_NVAR(t1); phalcon_read_property(&t1, this_ptr, SL("_access"), PH_NOISY_CC); phalcon_array_update_zval_zval_zval_multi_3(&t1, role_name, resource_name, access_name, &action, 0 TSRMLS_CC); PHALCON_OBS_NVAR(t2); phalcon_read_property(&t2, this_ptr, SL("_access"), PH_NOISY_CC); PHALCON_OBS_NVAR(r2); phalcon_array_fetch(&r2, t2, role_name, PH_NOISY_CC); PHALCON_OBS_NVAR(r3); phalcon_array_fetch(&r3, r2, resource_name, PH_NOISY_CC); if (!phalcon_array_isset_string(r3, SS("*"))) { PHALCON_OBS_NVAR(t3); phalcon_read_property(&t3, this_ptr, SL("_access"), PH_NOISY_CC); phalcon_array_update_string_zval_zval_multi_3(&t3, role_name, resource_name, SL("*"), &default_access, 0 TSRMLS_CC); } zend_hash_move_forward_ex(ah1, &hp1); } } else { if (!PHALCON_IS_STRING(access, "*")) { PHALCON_OBS_VAR(t4); phalcon_read_property(&t4, this_ptr, SL("_accessList"), PH_NOISY_CC); PHALCON_OBS_VAR(r4); phalcon_array_fetch(&r4, t4, resource_name, PH_NOISY_CC); if (!phalcon_array_isset(r4, access)) { PHALCON_INIT_NVAR(exception_message); PHALCON_CONCAT_SVSVS(exception_message, "Acccess '", access, "' does not exist in resource '", resource_name, "' in ACL"); PHALCON_THROW_EXCEPTION_ZVAL(phalcon_acl_exception_ce, exception_message); return; } } PHALCON_OBS_VAR(t5); phalcon_read_property(&t5, this_ptr, SL("_access"), PH_NOISY_CC); PHALCON_OBS_VAR(r5); phalcon_array_fetch(&r5, t5, role_name, PH_NOISY_CC); if (!phalcon_array_isset(r5, resource_name)) { PHALCON_INIT_NVAR(empty_arr); array_init(empty_arr); PHALCON_OBS_VAR(t6); phalcon_read_property(&t6, this_ptr, SL("_access"), PH_NOISY_CC); phalcon_array_update_multi_2(&t6, role_name, resource_name, &empty_arr, 0 TSRMLS_CC); phalcon_update_property_zval(this_ptr, SL("_access"), t6 TSRMLS_CC); } PHALCON_OBS_VAR(t7); phalcon_read_property(&t7, this_ptr, SL("_access"), PH_NOISY_CC); PHALCON_OBS_VAR(r6); phalcon_array_fetch(&r6, t7, role_name, PH_NOISY_CC); PHALCON_OBS_VAR(r7); phalcon_array_fetch(&r7, r6, resource_name, PH_NOISY_CC); if (!phalcon_array_isset_string(r7, SS("*"))) { PHALCON_OBS_VAR(t8); phalcon_read_property(&t8, this_ptr, SL("_access"), PH_NOISY_CC); phalcon_array_update_string_zval_zval_multi_3(&t8, role_name, resource_name, SL("*"), &default_access, 0 TSRMLS_CC); } PHALCON_OBS_VAR(t9); phalcon_read_property(&t9, this_ptr, SL("_access"), PH_NOISY_CC); phalcon_array_update_zval_zval_zval_multi_3(&t9, role_name, resource_name, access, &action, 0 TSRMLS_CC); } PHALCON_CALL_METHOD_NORETURN(this_ptr, "_rebuildaccesslist"); PHALCON_MM_RESTORE(); }
/** * Produce the routing parameters from the rewrite information */ PHP_METHOD(Phalcon_Mvc_Router_Annotations, handle) { zephir_fcall_cache_entry *_9 = NULL, *_17 = NULL, *_18 = NULL; HashTable *_2, *_7, *_11, *_15; HashPosition _1, _6, _10, _14; int ZEPHIR_LAST_CALL_STATUS; zval *uri_param = NULL, *realUri = NULL, *annotationsService = NULL, *handlers, *controllerSuffix, *scope = NULL, *prefix = NULL, *dependencyInjector = NULL, *handler = NULL, *controllerName = NULL, *lowerControllerName = NULL, *namespaceName = NULL, *moduleName = NULL, *sufixed = NULL, *handlerAnnotations = NULL, *classAnnotations = NULL, *annotations = NULL, *annotation = NULL, *methodAnnotations = NULL, *lowercased = NULL, *method = NULL, *collection = NULL, *_0, **_3, *_4, *_5 = NULL, **_8, **_12, *_13 = NULL, **_16; zval *uri = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &uri_param); if (!uri_param) { ZEPHIR_INIT_VAR(uri); ZVAL_EMPTY_STRING(uri); } else { if (unlikely(Z_TYPE_P(uri_param) != IS_STRING && Z_TYPE_P(uri_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'uri' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(uri_param) == IS_STRING)) { zephir_get_strval(uri, uri_param); } else { ZEPHIR_INIT_VAR(uri); ZVAL_EMPTY_STRING(uri); } } if (!(uri && Z_STRLEN_P(uri))) { ZEPHIR_CALL_METHOD(&realUri, this_ptr, "getrewriteuri", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(realUri, uri); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_processed"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { ZEPHIR_INIT_VAR(annotationsService); ZVAL_NULL(annotationsService); ZEPHIR_OBS_VAR(handlers); zephir_read_property_this(&handlers, this_ptr, SL("_handlers"), PH_NOISY_CC); if (Z_TYPE_P(handlers) == IS_ARRAY) { ZEPHIR_OBS_VAR(controllerSuffix); zephir_read_property_this(&controllerSuffix, this_ptr, SL("_controllerSuffix"), PH_NOISY_CC); zephir_is_iterable(handlers, &_2, &_1, 0, 0, "phalcon/mvc/router/annotations.zep", 208); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(scope, _3); if (Z_TYPE_P(scope) == IS_ARRAY) { ZEPHIR_OBS_NVAR(prefix); zephir_array_fetch_long(&prefix, scope, 0, PH_NOISY, "phalcon/mvc/router/annotations.zep", 117 TSRMLS_CC); if (!(ZEPHIR_IS_EMPTY(prefix))) { if (!(zephir_start_with(realUri, prefix, NULL))) { continue; } } if (Z_TYPE_P(annotationsService) != IS_OBJECT) { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _4); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "A dependency injection container is required to access the 'annotations' service", "phalcon/mvc/router/annotations.zep", 129); return; } ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "annotations", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&annotationsService, dependencyInjector, "getshared", NULL, 0, _5); zephir_check_temp_parameter(_5); zephir_check_call_status(); } ZEPHIR_OBS_NVAR(handler); zephir_array_fetch_long(&handler, scope, 1, PH_NOISY, "phalcon/mvc/router/annotations.zep", 138 TSRMLS_CC); if (zephir_memnstr_str(handler, SL("\\"), "phalcon/mvc/router/annotations.zep", 140)) { ZEPHIR_INIT_NVAR(controllerName); zephir_get_class_ns(controllerName, handler, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(lowerControllerName); zephir_uncamelize(lowerControllerName, controllerName); ZEPHIR_INIT_NVAR(namespaceName); zephir_get_ns_class(namespaceName, handler, 0 TSRMLS_CC); } else { ZEPHIR_CPY_WRT(controllerName, handler); ZEPHIR_INIT_NVAR(lowerControllerName); zephir_uncamelize(lowerControllerName, controllerName); ZEPHIR_INIT_NVAR(namespaceName); ZVAL_NULL(namespaceName); } zephir_update_property_this(this_ptr, SL("_routePrefix"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); ZEPHIR_OBS_NVAR(moduleName); zephir_array_isset_long_fetch(&moduleName, scope, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(sufixed); ZEPHIR_CONCAT_VV(sufixed, handler, controllerSuffix); ZEPHIR_CALL_METHOD(&handlerAnnotations, annotationsService, "get", NULL, 0, sufixed); zephir_check_call_status(); if (Z_TYPE_P(handlerAnnotations) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&classAnnotations, handlerAnnotations, "getclassannotations", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(classAnnotations) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&annotations, classAnnotations, "getannotations", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(annotations) == IS_ARRAY) { zephir_is_iterable(annotations, &_7, &_6, 0, 0, "phalcon/mvc/router/annotations.zep", 187); for ( ; zephir_hash_get_current_data_ex(_7, (void**) &_8, &_6) == SUCCESS ; zephir_hash_move_forward_ex(_7, &_6) ) { ZEPHIR_GET_HVALUE(annotation, _8); ZEPHIR_CALL_METHOD(NULL, this_ptr, "processcontrollerannotation", &_9, 0, controllerName, annotation); zephir_check_call_status(); } } } ZEPHIR_CALL_METHOD(&methodAnnotations, handlerAnnotations, "getmethodsannotations", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(methodAnnotations) == IS_ARRAY) { ZEPHIR_INIT_NVAR(lowercased); zephir_uncamelize(lowercased, handler); zephir_is_iterable(methodAnnotations, &_11, &_10, 0, 0, "phalcon/mvc/router/annotations.zep", 203); for ( ; zephir_hash_get_current_data_ex(_11, (void**) &_12, &_10) == SUCCESS ; zephir_hash_move_forward_ex(_11, &_10) ) { ZEPHIR_GET_HMKEY(method, _11, _10); ZEPHIR_GET_HVALUE(collection, _12); if (Z_TYPE_P(collection) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&_13, collection, "getannotations", NULL, 0); zephir_check_call_status(); zephir_is_iterable(_13, &_15, &_14, 0, 0, "phalcon/mvc/router/annotations.zep", 201); for ( ; zephir_hash_get_current_data_ex(_15, (void**) &_16, &_14) == SUCCESS ; zephir_hash_move_forward_ex(_15, &_14) ) { ZEPHIR_GET_HVALUE(annotation, _16); ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_17, 0, moduleName, namespaceName, lowerControllerName, method, annotation); zephir_check_call_status(); } } } } } } } } zephir_update_property_this(this_ptr, SL("_processed"), (1) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_router_annotations_ce, this_ptr, "handle", &_18, 367, realUri); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); }
/** * Check whether a role is allowed to access an action from a resource * * <code> * //Does andres have access to the customers resource to create? * $acl->isAllowed('andres', 'Products', 'create'); * * //Do guests have access to any resource to edit? * $acl->isAllowed('guests', '*', 'edit'); * </code> * * @param string $role * @param string $resource * @param string $access * @return boolean */ PHP_METHOD(Phalcon_Acl_Adapter_Memory, isAllowed){ zval *role, *resource, *access, *default_access; zval *events_manager, *event_name = NULL, *status, *resources_names; zval *roles_names, *have_access = NULL, *access_roles; zval *resource_access = NULL, *resource_name = NULL; zval *t0 = NULL; HashTable *ah0, *ah1; HashPosition hp0, hp1; zval **hd; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz", &role, &resource, &access) == FAILURE) { RETURN_MM_NULL(); } phalcon_update_property_zval(this_ptr, SL("_activeRole"), role TSRMLS_CC); phalcon_update_property_zval(this_ptr, SL("_activeResource"), resource TSRMLS_CC); phalcon_update_property_zval(this_ptr, SL("_activeAccess"), access TSRMLS_CC); PHALCON_OBS_VAR(default_access); phalcon_read_property(&default_access, this_ptr, SL("_defaultAccess"), PH_NOISY_CC); PHALCON_OBS_VAR(events_manager); phalcon_read_property(&events_manager, this_ptr, SL("_eventsManager"), PH_NOISY_CC); if (Z_TYPE_P(events_manager) == IS_OBJECT) { PHALCON_INIT_VAR(event_name); ZVAL_STRING(event_name, "acl:beforeCheckAccess", 1); PHALCON_INIT_VAR(status); PHALCON_CALL_METHOD_PARAMS_2(status, events_manager, "fire", event_name, this_ptr); if (PHALCON_IS_FALSE(status)) { RETURN_CCTOR(status); } } PHALCON_OBS_VAR(resources_names); phalcon_read_property(&resources_names, this_ptr, SL("_resourcesNames"), PH_NOISY_CC); if (!phalcon_array_isset(resources_names, resource)) { RETURN_CCTOR(default_access); } PHALCON_OBS_VAR(roles_names); phalcon_read_property(&roles_names, this_ptr, SL("_rolesNames"), PH_NOISY_CC); if (!phalcon_array_isset(roles_names, role)) { RETURN_CCTOR(default_access); } PHALCON_INIT_VAR(have_access); PHALCON_OBS_VAR(t0); phalcon_read_property(&t0, this_ptr, SL("_access"), PH_NOISY_CC); PHALCON_OBS_VAR(access_roles); phalcon_array_fetch(&access_roles, t0, role, PH_NOISY_CC); if (!phalcon_is_iterable(access_roles, &ah0, &hp0, 0, 0 TSRMLS_CC)) { return; } while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) { PHALCON_GET_FOREACH_KEY(resource_name, ah0, hp0); PHALCON_GET_FOREACH_VALUE(resource_access); if (PHALCON_IS_EQUAL(resource_name, resource)) { if (phalcon_array_isset(resource_access, access)) { PHALCON_OBS_NVAR(have_access); phalcon_array_fetch(&have_access, resource_access, access, PH_NOISY_CC); break; } PHALCON_OBS_NVAR(have_access); phalcon_array_fetch_string(&have_access, resource_access, SL("*"), PH_NOISY_CC); break; } zend_hash_move_forward_ex(ah0, &hp0); } if (Z_TYPE_P(have_access) == IS_NULL) { if (!phalcon_is_iterable(access_roles, &ah1, &hp1, 0, 0 TSRMLS_CC)) { return; } while (zend_hash_get_current_data_ex(ah1, (void**) &hd, &hp1) == SUCCESS) { PHALCON_GET_FOREACH_KEY(resource_name, ah1, hp1); PHALCON_GET_FOREACH_VALUE(resource_access); if (phalcon_array_isset_string(resource_access, SS("*"))) { if (phalcon_array_isset(resource_access, access)) { PHALCON_OBS_NVAR(have_access); phalcon_array_fetch(&have_access, resource_access, access, PH_NOISY_CC); break; } PHALCON_OBS_NVAR(have_access); phalcon_array_fetch_string(&have_access, resource_access, SL("*"), PH_NOISY_CC); break; } zend_hash_move_forward_ex(ah1, &hp1); } } phalcon_update_property_zval(this_ptr, SL("_accessGranted"), have_access TSRMLS_CC); if (Z_TYPE_P(events_manager) == IS_OBJECT) { PHALCON_INIT_NVAR(event_name); ZVAL_STRING(event_name, "acl:afterCheckAccess", 1); PHALCON_CALL_METHOD_PARAMS_2_NORETURN(events_manager, "fire", event_name, this_ptr); } if (Z_TYPE_P(have_access) == IS_NULL) { PHALCON_MM_RESTORE(); RETURN_LONG(0); } RETURN_CCTOR(have_access); }
PHP_METHOD(Test_Statements, test544IssueWithVariable) { zephir_fcall_cache_entry *_6 = NULL; zval *step_param = NULL, *_0, *_1, *_2, *_3, _4 = zval_used_for_init, *_5 = NULL, *_7, *_8, *_9 = NULL; int step, filledWidth, unfilledWidth, totalSteps, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &step_param); if (unlikely(Z_TYPE_P(step_param) != IS_LONG)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'step' must be a long/integer") TSRMLS_CC); RETURN_MM_NULL(); } step = Z_LVAL_P(step_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("totalSteps"), PH_NOISY_CC); totalSteps = zephir_get_numberval(_0); if (step < totalSteps) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("width"), PH_NOISY_CC); filledWidth = (long) ((zephir_safe_div_long_long(((zephir_get_numberval(_1) - 1)), totalSteps TSRMLS_CC) * step)); _2 = zephir_fetch_nproperty_this(this_ptr, SL("width"), PH_NOISY_CC); unfilledWidth = (((zephir_get_numberval(_2) - 1)) - filledWidth); _3 = zephir_fetch_nproperty_this(this_ptr, SL("filledChar"), PH_NOISY_CC); ZEPHIR_SINIT_VAR(_4); ZVAL_LONG(&_4, filledWidth); ZEPHIR_CALL_FUNCTION(&_5, "str_repeat", &_6, 17, _3, &_4); zephir_check_call_status(); _7 = zephir_fetch_nproperty_this(this_ptr, SL("arrow"), PH_NOISY_CC); _8 = zephir_fetch_nproperty_this(this_ptr, SL("unfilledChar"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, unfilledWidth); ZEPHIR_CALL_FUNCTION(&_9, "str_repeat", &_6, 17, _8, &_4); zephir_check_call_status(); ZEPHIR_CONCAT_VVV(return_value, _5, _7, _9); RETURN_MM(); } else if (step == totalSteps) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("filledChar"), PH_NOISY_CC); _2 = zephir_fetch_nproperty_this(this_ptr, SL("width"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_FUNCTION("str_repeat", &_6, 17, _1, _2); zephir_check_call_status(); RETURN_MM(); } else { _1 = zephir_fetch_nproperty_this(this_ptr, SL("unfilledChar"), PH_NOISY_CC); _2 = zephir_fetch_nproperty_this(this_ptr, SL("width"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_FUNCTION("str_repeat", &_6, 17, _1, _2); zephir_check_call_status(); RETURN_MM(); } }
/** * Executes validator * * @param Phalcon\Mvc\ModelInterface $record * @return boolean */ PHP_METHOD(Phalcon_Mvc_Model_Validator_Inclusionin, validate){ zval *record, *field = NULL, *field_name, *is_set, *domain; zval *value, *is_in_array, *option, *message = NULL, *joined_domain; zval *type; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &record) == FAILURE) { RETURN_MM_NULL(); } PHALCON_INIT_VAR(field); ZVAL_STRING(field, "field", 1); PHALCON_INIT_VAR(field_name); PHALCON_CALL_METHOD_PARAMS_1(field_name, this_ptr, "getoption", field); if (Z_TYPE_P(field_name) != IS_STRING) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Field name must be a string"); return; } /** * The 'domain' option must be a valid array of not allowed values */ PHALCON_INIT_NVAR(field); ZVAL_STRING(field, "domain", 1); PHALCON_INIT_VAR(is_set); PHALCON_CALL_METHOD_PARAMS_1(is_set, this_ptr, "issetoption", field); if (PHALCON_IS_FALSE(is_set)) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "The option 'domain' is required for this validator"); return; } PHALCON_INIT_NVAR(field); ZVAL_STRING(field, "domain", 1); PHALCON_INIT_VAR(domain); PHALCON_CALL_METHOD_PARAMS_1(domain, this_ptr, "getoption", field); if (Z_TYPE_P(domain) != IS_ARRAY) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Option 'domain' must be an array"); return; } PHALCON_INIT_VAR(value); PHALCON_CALL_METHOD_PARAMS_1(value, record, "readattribute", field_name); /** * We check if the value contained in the array using "in_array" from the PHP * userland */ PHALCON_INIT_VAR(is_in_array); PHALCON_CALL_FUNC_PARAMS_2(is_in_array, "in_array", value, domain); if (PHALCON_IS_FALSE(is_in_array)) { /** * Check if the developer has defined a custom message */ PHALCON_INIT_VAR(option); ZVAL_STRING(option, "message", 1); PHALCON_INIT_VAR(message); PHALCON_CALL_METHOD_PARAMS_1(message, this_ptr, "getoption", option); if (!zend_is_true(message)) { PHALCON_INIT_VAR(joined_domain); phalcon_fast_join_str(joined_domain, SL(", "), domain TSRMLS_CC); PHALCON_INIT_NVAR(message); PHALCON_CONCAT_SVSV(message, "Value of field '", field_name, "' must be part of list: ", joined_domain); } PHALCON_INIT_VAR(type); ZVAL_STRING(type, "Inclusion", 1); PHALCON_CALL_METHOD_PARAMS_3_NORETURN(this_ptr, "appendmessage", message, field_name, type); RETURN_MM_FALSE; } RETURN_MM_TRUE; }