/** * Cache the actual view render to certain level * * @param boolean|array $options */ PHP_METHOD(Phalcon_Mvc_View, cache){ zval *options = NULL, *view_options = NULL, *cache_options = NULL; zval *value = NULL, *key = NULL, *cache_level; HashTable *ah0; HashPosition hp0; zval **hd; PHALCON_MM_GROW(); phalcon_fetch_params(1, 0, 1, &options); if (!options) { PHALCON_INIT_VAR(options); ZVAL_BOOL(options, 1); } if (Z_TYPE_P(options) == IS_ARRAY) { PHALCON_OBS_VAR(view_options); phalcon_read_property_this(&view_options, this_ptr, SL("_options"), PH_NOISY_CC); if (Z_TYPE_P(view_options) != IS_ARRAY) { PHALCON_INIT_NVAR(view_options); array_init(view_options); } /** * Get the default cache options */ if (phalcon_array_isset_string(view_options, SS("cache"))) { PHALCON_OBS_VAR(cache_options); phalcon_array_fetch_string(&cache_options, view_options, SL("cache"), PH_NOISY_CC); } else { PHALCON_INIT_NVAR(cache_options); array_init(cache_options); } if (!phalcon_is_iterable(options, &ah0, &hp0, 0, 0 TSRMLS_CC)) { return; } while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) { PHALCON_GET_FOREACH_KEY(key, ah0, hp0); PHALCON_GET_FOREACH_VALUE(value); phalcon_array_update_zval(&cache_options, key, &value, PH_COPY | PH_SEPARATE TSRMLS_CC); zend_hash_move_forward_ex(ah0, &hp0); } /** * Check if the user has defined a default cache level or use 5 as default */ if (phalcon_array_isset_string(cache_options, SS("level"))) { PHALCON_OBS_VAR(cache_level); phalcon_array_fetch_string(&cache_level, cache_options, SL("level"), PH_NOISY_CC); phalcon_update_property_this(this_ptr, SL("_cacheLevel"), cache_level TSRMLS_CC); } else { phalcon_update_property_long(this_ptr, SL("_cacheLevel"), 5 TSRMLS_CC); } phalcon_array_update_string(&view_options, SL("cache"), &cache_options, PH_COPY | PH_SEPARATE TSRMLS_CC); phalcon_update_property_this(this_ptr, SL("_options"), view_options TSRMLS_CC); } else { /** * If 'options' isn't an array we enable the cache with the default options */ if (zend_is_true(options)) { phalcon_update_property_long(this_ptr, SL("_cacheLevel"), 5 TSRMLS_CC); } else { phalcon_update_property_long(this_ptr, SL("_cacheLevel"), 0 TSRMLS_CC); } } PHALCON_MM_RESTORE(); }
/** * Phalcon\Db\Column constructor * * @param string $columnName * @param array $definition */ PHP_METHOD(Phalcon_Db_Column, __construct){ zval *column_name, *definition, *type, *not_null; zval *primary, *size, *is_numeric = NULL, *scale, *dunsigned; zval *auto_increment, *first, *after, *bind_type; zval *t0 = NULL, *t1 = NULL; PHALCON_MM_GROW(); phalcon_fetch_params(1, 2, 0, &column_name, &definition); phalcon_update_property_this(this_ptr, SL("_columnName"), column_name TSRMLS_CC); /** * Get the column type, one of the TYPE_* constants */ if (phalcon_array_isset_string(definition, SS("type"))) { PHALCON_OBS_VAR(type); phalcon_array_fetch_string(&type, definition, SL("type"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_type"), type TSRMLS_CC); } else { PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Column type is required"); return; } /** * Check if the field is nullable */ if (phalcon_array_isset_string(definition, SS("notNull"))) { PHALCON_OBS_VAR(not_null); phalcon_array_fetch_string(¬_null, definition, SL("notNull"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_notNull"), not_null TSRMLS_CC); } /** * Check if the field is primary key */ if (phalcon_array_isset_string(definition, SS("primary"))) { PHALCON_OBS_VAR(primary); phalcon_array_fetch_string(&primary, definition, SL("primary"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_primary"), primary TSRMLS_CC); } if (phalcon_array_isset_string(definition, SS("size"))) { PHALCON_OBS_VAR(size); phalcon_array_fetch_string(&size, definition, SL("size"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_size"), size TSRMLS_CC); } /** * Check if the column has a decimal scale */ if (phalcon_array_isset_string(definition, SS("scale"))) { PHALCON_INIT_VAR(t0); ZVAL_LONG(t0, 3); PHALCON_INIT_VAR(is_numeric); is_equal_function(is_numeric, type, t0 TSRMLS_CC); if (PHALCON_IS_NOT_TRUE(is_numeric)) { PHALCON_INIT_VAR(t1); ZVAL_LONG(t1, 7); is_equal_function(is_numeric, type, t1 TSRMLS_CC); } if (PHALCON_IS_TRUE(is_numeric)) { PHALCON_OBS_VAR(scale); phalcon_array_fetch_string(&scale, definition, SL("scale"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_scale"), scale TSRMLS_CC); } else { PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Column type does not support scale parameter"); return; } } /** * Check if the field is unsigned (only MySQL) */ if (phalcon_array_isset_string(definition, SS("unsigned"))) { PHALCON_OBS_VAR(dunsigned); phalcon_array_fetch_string(&dunsigned, definition, SL("unsigned"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_unsigned"), dunsigned TSRMLS_CC); } /** * Check if the field is numeric */ if (phalcon_array_isset_string(definition, SS("isNumeric"))) { PHALCON_OBS_NVAR(is_numeric); phalcon_array_fetch_string(&is_numeric, definition, SL("isNumeric"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_isNumeric"), is_numeric TSRMLS_CC); } /** * Check if the field is auto-increment/serial */ if (phalcon_array_isset_string(definition, SS("autoIncrement"))) { if (PHALCON_IS_LONG(type, 0)) { PHALCON_OBS_VAR(auto_increment); phalcon_array_fetch_string(&auto_increment, definition, SL("autoIncrement"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_autoIncrement"), auto_increment TSRMLS_CC); } else { PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Column type cannot be auto-increment"); return; } } /** * Check if the field is placed at the first position of the table */ if (phalcon_array_isset_string(definition, SS("first"))) { PHALCON_OBS_VAR(first); phalcon_array_fetch_string(&first, definition, SL("first"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_first"), first TSRMLS_CC); } /** * Name of the column which is placed before the current field */ if (phalcon_array_isset_string(definition, SS("after"))) { PHALCON_OBS_VAR(after); phalcon_array_fetch_string(&after, definition, SL("after"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_after"), after TSRMLS_CC); } /** * The bind type to cast the field when passing it to PDO */ if (phalcon_array_isset_string(definition, SS("bindType"))) { PHALCON_OBS_VAR(bind_type); phalcon_array_fetch_string(&bind_type, definition, SL("bindType"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_bindType"), bind_type TSRMLS_CC); } PHALCON_MM_RESTORE(); }
/** * Executes the validator */ PHP_METHOD(Phalcon_Mvc_Model_Validator_StringLength, validate) { zval *_6$$9, *_10$$12; zend_bool _1, _3; zend_long ZEPHIR_LAST_CALL_STATUS; zval *record, *field = NULL, *isSetMin = NULL, *isSetMax = NULL, *value = NULL, *length = NULL, *maximum = NULL, *minimum = NULL, *message = NULL, *_0 = NULL, *_2 = NULL, *_4$$8, *_5$$9 = NULL, *_7$$9 = NULL, *_8$$11, *_9$$12 = NULL, *_11$$12 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &record); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "field", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&field, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(field) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Field name must be a string", "phalcon/mvc/model/validator/stringlength.zep", 75); return; } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "min", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&isSetMin, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "max", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&isSetMax, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _1 = !zephir_is_true(isSetMin); if (_1) { _1 = !zephir_is_true(isSetMax); } if (_1) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A minimum or maximum must be set", "phalcon/mvc/model/validator/stringlength.zep", 85); return; } ZEPHIR_CALL_METHOD(&value, record, "readattribute", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _3 = zephir_is_true(_2); if (_3) { _3 = ZEPHIR_IS_EMPTY(value); } if (_3) { RETURN_MM_BOOL(1); } if ((zephir_function_exists_ex(SS("mb_strlen") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, 391, value); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(length); ZVAL_LONG(length, zephir_fast_strlen_ev(value)); } if (zephir_is_true(isSetMax)) { ZEPHIR_INIT_VAR(_4$$8); ZVAL_STRING(_4$$8, "max", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&maximum, this_ptr, "getoption", NULL, 0, _4$$8); zephir_check_temp_parameter(_4$$8); zephir_check_call_status(); if (ZEPHIR_GT(length, maximum)) { ZEPHIR_INIT_VAR(_5$$9); ZVAL_STRING(_5$$9, "messageMaximum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _5$$9); zephir_check_temp_parameter(_5$$9); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(message); ZVAL_STRING(message, "Value of field ':field' exceeds the maximum :max characters", 1); } ZEPHIR_INIT_VAR(_6$$9); zephir_create_array(_6$$9, 2, 0 TSRMLS_CC); zephir_array_update_string(&_6$$9, SL(":field"), &field, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_6$$9, SL(":max"), &maximum, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_FUNCTION(&_7$$9, "strtr", NULL, 27, message, _6$$9); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_5$$9); ZVAL_STRING(_5$$9, "TooLong", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", NULL, 0, _7$$9, field, _5$$9); zephir_check_temp_parameter(_5$$9); zephir_check_call_status(); RETURN_MM_BOOL(0); } } if (zephir_is_true(isSetMin)) { ZEPHIR_INIT_VAR(_8$$11); ZVAL_STRING(_8$$11, "min", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&minimum, this_ptr, "getoption", NULL, 0, _8$$11); zephir_check_temp_parameter(_8$$11); zephir_check_call_status(); if (ZEPHIR_LT(length, minimum)) { ZEPHIR_INIT_VAR(_9$$12); ZVAL_STRING(_9$$12, "messageMinimum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _9$$12); zephir_check_temp_parameter(_9$$12); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(message); ZVAL_STRING(message, "Value of field ':field' is less than the minimum :min characters", 1); } ZEPHIR_INIT_VAR(_10$$12); zephir_create_array(_10$$12, 2, 0 TSRMLS_CC); zephir_array_update_string(&_10$$12, SL(":field"), &field, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_10$$12, SL(":min"), &minimum, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_FUNCTION(&_11$$12, "strtr", NULL, 27, message, _10$$12); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_9$$12); ZVAL_STRING(_9$$12, "TooShort", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", NULL, 0, _11$$12, field, _9$$12); zephir_check_temp_parameter(_9$$12); zephir_check_call_status(); RETURN_MM_BOOL(0); } } RETURN_MM_BOOL(1); }
/** * Generates a URL * * @param string|array $uri * @return string */ PHP_METHOD(Phalcon_Mvc_Url, get){ zval *uri = NULL, *base_uri, *dependency_injector, *service; zval *router, *route_name, *route, *exception_message; zval *pattern, *replaced_pattern = NULL, *controller_name; zval *wildcard = NULL, *action_name, *matches, *match_position; zval *set_order, *names_pattern, *have_variables = NULL; zval *match = NULL, *match_zero = NULL, *match_one = NULL, *value = NULL, *new_pcre_pattern = NULL; zval *final_uri; zval *r0 = NULL, *r1 = NULL, *r2 = NULL; zval *p0[] = { NULL, NULL, NULL, NULL }; HashTable *ah0; HashPosition hp0; zval **hd; int eval_int; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &uri) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } if (!uri) { PHALCON_INIT_NVAR(uri); } PHALCON_INIT_VAR(base_uri); PHALCON_CALL_METHOD(base_uri, this_ptr, "getbaseuri", PH_NO_CHECK); if (Z_TYPE_P(uri) == IS_ARRAY) { eval_int = phalcon_array_isset_string(uri, SS("for")); if (!eval_int) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_url_exception_ce, "It's necessary to define the route name with the parameter \"for\""); return; } PHALCON_INIT_VAR(dependency_injector); phalcon_read_property(&dependency_injector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (!zend_is_true(dependency_injector)) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_url_exception_ce, "A dependency injector container is required to obtain the \"url\" service"); return; } PHALCON_INIT_VAR(service); ZVAL_STRING(service, "router", 1); PHALCON_INIT_VAR(router); PHALCON_CALL_METHOD_PARAMS_1(router, dependency_injector, "getshared", service, PH_NO_CHECK); PHALCON_INIT_VAR(route_name); phalcon_array_fetch_string(&route_name, uri, SL("for"), PH_NOISY_CC); PHALCON_INIT_VAR(route); PHALCON_CALL_METHOD_PARAMS_1(route, router, "getroutebyname", route_name, PH_NO_CHECK); if (Z_TYPE_P(route) != IS_OBJECT) { PHALCON_INIT_VAR(exception_message); PHALCON_CONCAT_SVS(exception_message, "Cannot obtain a route using the name \"", route_name, "\""); PHALCON_THROW_EXCEPTION_ZVAL(phalcon_mvc_url_exception_ce, exception_message); return; } PHALCON_INIT_VAR(pattern); PHALCON_CALL_METHOD(pattern, route, "getpattern", PH_NO_CHECK); PHALCON_CPY_WRT(replaced_pattern, pattern); eval_int = phalcon_array_isset_string(uri, SS("controller")); if (eval_int) { PHALCON_INIT_VAR(controller_name); phalcon_array_fetch_string(&controller_name, uri, SL("controller"), PH_NOISY_CC); PHALCON_INIT_VAR(wildcard); ZVAL_STRING(wildcard, ":controller", 1); PHALCON_INIT_VAR(r0); phalcon_fast_str_replace(r0, wildcard, controller_name, replaced_pattern TSRMLS_CC); PHALCON_CPY_WRT(replaced_pattern, r0); } eval_int = phalcon_array_isset_string(uri, SS("action")); if (eval_int) { PHALCON_INIT_VAR(action_name); phalcon_array_fetch_string(&action_name, uri, SL("action"), PH_NOISY_CC); PHALCON_INIT_NVAR(wildcard); ZVAL_STRING(wildcard, ":action", 1); PHALCON_INIT_VAR(r1); phalcon_fast_str_replace(r1, wildcard, action_name, replaced_pattern TSRMLS_CC); PHALCON_CPY_WRT(replaced_pattern, r1); } if (phalcon_memnstr_str(replaced_pattern, SL("{") TSRMLS_CC)) { PHALCON_INIT_VAR(matches); PHALCON_INIT_VAR(match_position); ZVAL_LONG(match_position, 1); PHALCON_INIT_VAR(set_order); ZVAL_LONG(set_order, 2); PHALCON_INIT_VAR(names_pattern); ZVAL_STRING(names_pattern, "#{(([a-zA-Z][a-zA-Z0-9\\_\\-]*)*)(:([^}]+}?))*}#", 1); p0[0] = names_pattern; p0[1] = replaced_pattern; Z_SET_ISREF_P(matches); p0[2] = matches; p0[3] = set_order; PHALCON_INIT_VAR(r2); PHALCON_CALL_FUNC_PARAMS(r2, "preg_match_all", 4, p0); Z_UNSET_ISREF_P(p0[2]); PHALCON_CPY_WRT(have_variables, r2); if (zend_is_true(have_variables)) { if (!phalcon_valid_foreach(matches TSRMLS_CC)) { return; } ah0 = Z_ARRVAL_P(matches); zend_hash_internal_pointer_reset_ex(ah0, &hp0); ph_cycle_start_0: if (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS) { goto ph_cycle_end_0; } PHALCON_GET_FOREACH_VALUE(match); PHALCON_INIT_NVAR(match_zero); phalcon_array_fetch_long(&match_zero, match, 0, PH_NOISY_CC); PHALCON_INIT_NVAR(match_one); phalcon_array_fetch_long(&match_one, match, 1, PH_NOISY_CC); eval_int = phalcon_array_isset(uri, match_one); if (eval_int) { PHALCON_INIT_NVAR(value); phalcon_array_fetch(&value, uri, match_one, PH_NOISY_CC); PHALCON_INIT_NVAR(new_pcre_pattern); phalcon_fast_str_replace(new_pcre_pattern, match_zero, value, replaced_pattern TSRMLS_CC); PHALCON_CPY_WRT(replaced_pattern, new_pcre_pattern); } zend_hash_move_forward_ex(ah0, &hp0); goto ph_cycle_start_0; ph_cycle_end_0: if(0){} } } RETURN_CCTOR(replaced_pattern); } else { PHALCON_INIT_VAR(final_uri); PHALCON_CONCAT_VV(final_uri, base_uri, uri); RETURN_CTOR(final_uri); } PHALCON_MM_RESTORE(); }
/** * Renders a view * * @param string $path * @param array $params * @return string */ PHP_METHOD(Phalcon_Mvc_View_Simple, render){ zval *path, *params = NULL, *cache = NULL, *is_started = NULL, *key = NULL, *lifetime = NULL; zval *cache_options, *content = NULL, *view_params; zval *merged_params = NULL, *is_fresh = NULL; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 1, &path, ¶ms); if (!params) { params = PHALCON_GLOBAL(z_null); } /** * Create/Get a cache */ PHALCON_CALL_METHOD(&cache, this_ptr, "getcache"); if (Z_TYPE_P(cache) == IS_OBJECT) { /** * Check if the cache is started, the first time a cache is started we start the * cache */ PHALCON_CALL_METHOD(&is_started, cache, "isstarted"); if (PHALCON_IS_FALSE(is_started)) { PHALCON_INIT_VAR(key); PHALCON_INIT_VAR(lifetime); PHALCON_OBS_VAR(cache_options); phalcon_read_property_this(&cache_options, this_ptr, SL("_cacheOptions"), PH_NOISY TSRMLS_CC); /** * Check if the user has defined a different options to the default */ if (Z_TYPE_P(cache_options) == IS_ARRAY) { if (phalcon_array_isset_string(cache_options, SS("key"))) { PHALCON_OBS_NVAR(key); phalcon_array_fetch_string(&key, cache_options, SL("key"), PH_NOISY); } if (phalcon_array_isset_string(cache_options, SS("lifetime"))) { PHALCON_OBS_NVAR(lifetime); phalcon_array_fetch_string(&lifetime, cache_options, SL("lifetime"), PH_NOISY); } } /** * If a cache key is not set we create one using a md5 */ if (Z_TYPE_P(key) == IS_NULL) { PHALCON_INIT_NVAR(key); phalcon_md5(key, path); } /** * We start the cache using the key set */ PHALCON_CALL_METHOD(&content, cache, "start", key, lifetime); if (Z_TYPE_P(content) != IS_NULL) { phalcon_update_property_this(this_ptr, SL("_content"), content TSRMLS_CC); RETURN_CTOR(content); } } } /** * Create a virtual symbol table */ phalcon_create_symbol_table(TSRMLS_C); phalcon_ob_start(TSRMLS_C); PHALCON_OBS_VAR(view_params); phalcon_read_property_this(&view_params, this_ptr, SL("_viewParams"), PH_NOISY TSRMLS_CC); /** * Merge parameters */ if (Z_TYPE_P(params) == IS_ARRAY) { if (Z_TYPE_P(view_params) == IS_ARRAY) { PHALCON_INIT_VAR(merged_params); phalcon_fast_array_merge(merged_params, &view_params, ¶ms TSRMLS_CC); } else { PHALCON_CPY_WRT(merged_params, params); } } else { PHALCON_CPY_WRT(merged_params, view_params); } /** * internalRender is also reused by partials */ PHALCON_CALL_METHOD(NULL, this_ptr, "_internalrender", path, merged_params); /** * Store the data in output into the cache */ if (Z_TYPE_P(cache) == IS_OBJECT) { PHALCON_CALL_METHOD(&is_started, cache, "isstarted"); if (PHALCON_IS_TRUE(is_started)) { PHALCON_CALL_METHOD(&is_fresh, cache, "isfresh"); if (PHALCON_IS_TRUE(is_fresh)) { PHALCON_CALL_METHOD(NULL, cache, "save"); } else { PHALCON_CALL_METHOD(NULL, cache, "stop"); } } else { PHALCON_CALL_METHOD(NULL, cache, "stop"); } } phalcon_ob_end_clean(TSRMLS_C); PHALCON_OBS_NVAR(content); phalcon_read_property_this(&content, this_ptr, SL("_content"), PH_NOISY TSRMLS_CC); RETURN_CTOR(content); }
/** * Returns an array of Phalcon\Db\Column objects describing a table * * <code> * print_r( * $connection->describeColumns("posts") * ); * </code> */ PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, describeColumns) { HashTable *_5; HashPosition _4; zephir_fcall_cache_entry *_41 = NULL, *_45 = NULL, *_47 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *table_param = NULL, *schema_param = NULL, *columns = NULL, *columnType = NULL, *field = NULL, *definition = NULL, *oldColumn = NULL, *columnName = NULL, *charSize = NULL, *numericSize = NULL, *numericScale = NULL, *_0 = NULL, *_1, *_2 = NULL, *_3, **_6, *_7$$4 = NULL, *_8$$4 = NULL, *_9$$5 = NULL, *_10$$5 = NULL, *_11$$6 = NULL, *_12$$6 = NULL, *_13$$7 = NULL, *_14$$8 = NULL, *_15$$8 = NULL, *_16$$9 = NULL, *_17$$10 = NULL, *_18$$10 = NULL, *_19$$11 = NULL, *_20$$12 = NULL, *_21$$12 = NULL, *_22$$13 = NULL, *_23$$14 = NULL, *_24$$14 = NULL, *_25$$15 = NULL, *_26$$15 = NULL, *_27$$15 = NULL, *_28$$16 = NULL, *_29$$17 = NULL, *_30$$18 = NULL, *_31$$18 = NULL, *_32$$19 = NULL, *_33$$3, *_34$$3, *_35$$3, *_36$$3 = NULL, *_46$$3 = NULL, *_37$$26, *_38$$26 = NULL, *_39$$26 = NULL, *_40$$26 = NULL, *_42$$26, _43$$26 = zval_used_for_init, *_44$$26 = NULL; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); zephir_get_strval(table, table_param); if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } ZEPHIR_INIT_VAR(oldColumn); ZVAL_NULL(oldColumn); ZEPHIR_INIT_VAR(columns); array_init(columns); _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/postgresql.zep", 281); for ( ; zend_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zend_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(columnType); zephir_array_fetch_long(&columnType, field, 1, PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 118 TSRMLS_CC); ZEPHIR_OBS_NVAR(charSize); zephir_array_fetch_long(&charSize, field, 2, PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 119 TSRMLS_CC); ZEPHIR_OBS_NVAR(numericSize); zephir_array_fetch_long(&numericSize, field, 3, PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 120 TSRMLS_CC); ZEPHIR_OBS_NVAR(numericScale); zephir_array_fetch_long(&numericScale, field, 4, PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 121 TSRMLS_CC); if (zephir_memnstr_str(columnType, SL("smallint(1)"), "phalcon/db/adapter/pdo/postgresql.zep", 123)) { ZEPHIR_INIT_NVAR(_7$$4); ZVAL_LONG(_7$$4, 8); zephir_array_update_string(&definition, SL("type"), &_7$$4, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8$$4); ZVAL_LONG(_8$$4, 5); zephir_array_update_string(&definition, SL("bindType"), &_8$$4, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("bigint"), "phalcon/db/adapter/pdo/postgresql.zep", 129)) { ZEPHIR_INIT_NVAR(_9$$5); ZVAL_LONG(_9$$5, 14); zephir_array_update_string(&definition, SL("type"), &_9$$5, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_10$$5); ZVAL_LONG(_10$$5, 1); zephir_array_update_string(&definition, SL("bindType"), &_10$$5, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("int"), "phalcon/db/adapter/pdo/postgresql.zep", 136)) { ZEPHIR_INIT_NVAR(_11$$6); ZVAL_LONG(_11$$6, 0); zephir_array_update_string(&definition, SL("type"), &_11$$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"), &numericSize, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_12$$6); ZVAL_LONG(_12$$6, 1); zephir_array_update_string(&definition, SL("bindType"), &_12$$6, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("varying"), "phalcon/db/adapter/pdo/postgresql.zep", 144)) { ZEPHIR_INIT_NVAR(_13$$7); ZVAL_LONG(_13$$7, 2); zephir_array_update_string(&definition, SL("type"), &_13$$7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &charSize, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("date"), "phalcon/db/adapter/pdo/postgresql.zep", 150)) { ZEPHIR_INIT_NVAR(_14$$8); ZVAL_LONG(_14$$8, 1); zephir_array_update_string(&definition, SL("type"), &_14$$8, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_15$$8); ZVAL_LONG(_15$$8, 0); zephir_array_update_string(&definition, SL("size"), &_15$$8, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("timestamp"), "phalcon/db/adapter/pdo/postgresql.zep", 156)) { ZEPHIR_INIT_NVAR(_16$$9); ZVAL_LONG(_16$$9, 17); zephir_array_update_string(&definition, SL("type"), &_16$$9, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("numeric"), "phalcon/db/adapter/pdo/postgresql.zep", 161)) { ZEPHIR_INIT_NVAR(_17$$10); ZVAL_LONG(_17$$10, 3); zephir_array_update_string(&definition, SL("type"), &_17$$10, 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"), &numericSize, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("scale"), &numericScale, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_18$$10); ZVAL_LONG(_18$$10, 32); zephir_array_update_string(&definition, SL("bindType"), &_18$$10, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("char"), "phalcon/db/adapter/pdo/postgresql.zep", 170)) { ZEPHIR_INIT_NVAR(_19$$11); ZVAL_LONG(_19$$11, 5); zephir_array_update_string(&definition, SL("type"), &_19$$11, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &charSize, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("timestamp"), "phalcon/db/adapter/pdo/postgresql.zep", 176)) { ZEPHIR_INIT_NVAR(_20$$12); ZVAL_LONG(_20$$12, 4); zephir_array_update_string(&definition, SL("type"), &_20$$12, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_21$$12); ZVAL_LONG(_21$$12, 0); zephir_array_update_string(&definition, SL("size"), &_21$$12, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("text"), "phalcon/db/adapter/pdo/postgresql.zep", 182)) { ZEPHIR_INIT_NVAR(_22$$13); ZVAL_LONG(_22$$13, 6); zephir_array_update_string(&definition, SL("type"), &_22$$13, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &charSize, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("float"), "phalcon/db/adapter/pdo/postgresql.zep", 188)) { ZEPHIR_INIT_NVAR(_23$$14); ZVAL_LONG(_23$$14, 7); zephir_array_update_string(&definition, SL("type"), &_23$$14, 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"), &numericSize, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_24$$14); ZVAL_LONG(_24$$14, 32); zephir_array_update_string(&definition, SL("bindType"), &_24$$14, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("bool"), "phalcon/db/adapter/pdo/postgresql.zep", 196)) { ZEPHIR_INIT_NVAR(_25$$15); ZVAL_LONG(_25$$15, 8); zephir_array_update_string(&definition, SL("type"), &_25$$15, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_26$$15); ZVAL_LONG(_26$$15, 0); zephir_array_update_string(&definition, SL("size"), &_26$$15, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_27$$15); ZVAL_LONG(_27$$15, 5); zephir_array_update_string(&definition, SL("bindType"), &_27$$15, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("jsonb"), "phalcon/db/adapter/pdo/postgresql.zep", 203)) { ZEPHIR_INIT_NVAR(_28$$16); ZVAL_LONG(_28$$16, 16); zephir_array_update_string(&definition, SL("type"), &_28$$16, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("json"), "phalcon/db/adapter/pdo/postgresql.zep", 208)) { ZEPHIR_INIT_NVAR(_29$$17); ZVAL_LONG(_29$$17, 15); zephir_array_update_string(&definition, SL("type"), &_29$$17, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("uuid"), "phalcon/db/adapter/pdo/postgresql.zep", 213)) { ZEPHIR_INIT_NVAR(_30$$18); ZVAL_LONG(_30$$18, 5); zephir_array_update_string(&definition, SL("type"), &_30$$18, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_31$$18); ZVAL_LONG(_31$$18, 36); zephir_array_update_string(&definition, SL("size"), &_31$$18, PH_COPY | PH_SEPARATE); } else { ZEPHIR_INIT_NVAR(_32$$19); ZVAL_LONG(_32$$19, 2); zephir_array_update_string(&definition, SL("type"), &_32$$19, PH_COPY | PH_SEPARATE); } if (zephir_memnstr_str(columnType, SL("unsigned"), "phalcon/db/adapter/pdo/postgresql.zep", 229)) { zephir_array_update_string(&definition, SL("unsigned"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } 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(&_33$$3, field, 6, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 245 TSRMLS_CC); if (ZEPHIR_IS_STRING(_33$$3, "PRI")) { zephir_array_update_string(&definition, SL("primary"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_34$$3, field, 5, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 252 TSRMLS_CC); if (ZEPHIR_IS_STRING(_34$$3, "NO")) { zephir_array_update_string(&definition, SL("notNull"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_35$$3, field, 7, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 259 TSRMLS_CC); if (ZEPHIR_IS_STRING(_35$$3, "auto_increment")) { zephir_array_update_string(&definition, SL("autoIncrement"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_NVAR(_36$$3); zephir_array_fetch_long(&_36$$3, field, 9, PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 266 TSRMLS_CC); if (Z_TYPE_P(_36$$3) != IS_NULL) { zephir_array_fetch_long(&_37$$26, field, 9, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 267 TSRMLS_CC); ZEPHIR_INIT_NVAR(_38$$26); ZVAL_STRING(_38$$26, "/^'|'?::[[:alnum:][:space:]]+$/", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_39$$26); ZVAL_STRING(_39$$26, "", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&_40$$26, "preg_replace", &_41, 39, _38$$26, _39$$26, _37$$26); zephir_check_temp_parameter(_38$$26); zephir_check_temp_parameter(_39$$26); zephir_check_call_status(); zephir_array_update_string(&definition, SL("default"), &_40$$26, PH_COPY | PH_SEPARATE); zephir_array_fetch_string(&_42$$26, definition, SL("default"), PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 268 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_43$$26); ZVAL_STRING(&_43$$26, "null", 0); ZEPHIR_CALL_FUNCTION(&_44$$26, "strcasecmp", &_45, 16, _42$$26, &_43$$26); zephir_check_call_status(); if (ZEPHIR_IS_LONG(_44$$26, 0)) { zephir_array_update_string(&definition, SL("default"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); } } zephir_array_fetch_long(&columnName, field, 0, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 276 TSRMLS_CC); ZEPHIR_INIT_NVAR(_46$$3); object_init_ex(_46$$3, phalcon_db_column_ce); ZEPHIR_CALL_METHOD(NULL, _46$$3, "__construct", &_47, 148, columnName, definition); zephir_check_call_status(); zephir_array_append(&columns, _46$$3, PH_SEPARATE, "phalcon/db/adapter/pdo/postgresql.zep", 277); ZEPHIR_CPY_WRT(oldColumn, columnName); } RETURN_CCTOR(columns); }
/** * Returns an array of Phalcon\Db\Column objects describing a table * * <code> * print_r($connection->describeColumns("posts")); * </code> * * @param string table * @param string schema * @return Phalcon\Db\Column[] */ PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, describeColumns) { zephir_fcall_cache_entry *_21 = NULL; zephir_nts_static zephir_fcall_cache_entry *_16 = NULL, *_20 = NULL; HashTable *_5; HashPosition _4; int ZEPHIR_LAST_CALL_STATUS; zval *table_param = NULL, *schema_param = NULL, *columns, *columnType = NULL, *field = NULL, *definition = NULL, *oldColumn = NULL, *columnName, *charSize = NULL, *numericSize = NULL, *numericScale = NULL, *_0 = NULL, *_1, *_2 = NULL, *_3 = NULL, **_6, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_10, *_11, *_12, *_13 = NULL, *_14, *_15 = NULL, *_17, _18 = zval_used_for_init, *_19 = NULL; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); zephir_get_strval(table, table_param); if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } ZEPHIR_INIT_VAR(oldColumn); ZVAL_NULL(oldColumn); ZEPHIR_INIT_VAR(columns); array_init(columns); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_2, _1, "describecolumns", NULL, table, schema); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 3); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, _2, _3); zephir_check_call_status(); zephir_is_iterable(_0, &_5, &_4, 0, 0, "phalcon/db/adapter/pdo/postgresql.zep", 295); 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(columnType); zephir_array_fetch_long(&columnType, field, 1, PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 119 TSRMLS_CC); ZEPHIR_OBS_NVAR(charSize); zephir_array_fetch_long(&charSize, field, 2, PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 120 TSRMLS_CC); ZEPHIR_OBS_NVAR(numericSize); zephir_array_fetch_long(&numericSize, field, 3, PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 121 TSRMLS_CC); ZEPHIR_OBS_NVAR(numericScale); zephir_array_fetch_long(&numericScale, field, 4, PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 122 TSRMLS_CC); while (1) { if (zephir_memnstr_str(columnType, SL("smallint(1)"), "phalcon/db/adapter/pdo/postgresql.zep", 129)) { ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 8); zephir_array_update_string(&definition, SL("type"), &_3, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 5); zephir_array_update_string(&definition, SL("bindType"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("int"), "phalcon/db/adapter/pdo/postgresql.zep", 138)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 0); zephir_array_update_string(&definition, SL("type"), &_7, 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"), &numericSize, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 1); zephir_array_update_string(&definition, SL("bindType"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("varying"), "phalcon/db/adapter/pdo/postgresql.zep", 149)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 2); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &charSize, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("date"), "phalcon/db/adapter/pdo/postgresql.zep", 158)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 1); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 0); zephir_array_update_string(&definition, SL("size"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("numeric"), "phalcon/db/adapter/pdo/postgresql.zep", 167)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 3); zephir_array_update_string(&definition, SL("type"), &_7, 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"), &numericSize, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("scale"), &numericScale, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 32); zephir_array_update_string(&definition, SL("bindType"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("char"), "phalcon/db/adapter/pdo/postgresql.zep", 179)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 5); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &charSize, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("timestamp"), "phalcon/db/adapter/pdo/postgresql.zep", 188)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 4); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 0); zephir_array_update_string(&definition, SL("size"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("text"), "phalcon/db/adapter/pdo/postgresql.zep", 197)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 6); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &charSize, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("float"), "phalcon/db/adapter/pdo/postgresql.zep", 206)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 7); zephir_array_update_string(&definition, SL("type"), &_7, 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"), &numericSize, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 32); zephir_array_update_string(&definition, SL("bindType"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("bool"), "phalcon/db/adapter/pdo/postgresql.zep", 217)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 8); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 0); zephir_array_update_string(&definition, SL("size"), &_8, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_9); ZVAL_LONG(_9, 5); zephir_array_update_string(&definition, SL("bindType"), &_9, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("uuid"), "phalcon/db/adapter/pdo/postgresql.zep", 227)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 5); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 36); zephir_array_update_string(&definition, SL("size"), &_8, PH_COPY | PH_SEPARATE); break; } ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 2); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("unsigned"), "phalcon/db/adapter/pdo/postgresql.zep", 243)) { zephir_array_update_string(&definition, SL("unsigned"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } 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(&_10, field, 6, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 259 TSRMLS_CC); if (ZEPHIR_IS_STRING(_10, "PRI")) { zephir_array_update_string(&definition, SL("primary"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_11, field, 5, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 266 TSRMLS_CC); if (ZEPHIR_IS_STRING(_11, "NO")) { zephir_array_update_string(&definition, SL("notNull"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_12, field, 7, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 273 TSRMLS_CC); if (ZEPHIR_IS_STRING(_12, "auto_increment")) { zephir_array_update_string(&definition, SL("autoIncrement"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_NVAR(_13); zephir_array_fetch_long(&_13, field, 9, PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 280 TSRMLS_CC); if (Z_TYPE_P(_13) != IS_NULL) { zephir_array_fetch_long(&_14, field, 9, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 281 TSRMLS_CC); ZEPHIR_INIT_NVAR(_8); ZVAL_STRING(_8, "/^'|'?::[[:alnum:][:space:]]+$/", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_9); ZVAL_STRING(_9, "", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&_15, "preg_replace", &_16, _8, _9, _14); zephir_check_temp_parameter(_8); zephir_check_temp_parameter(_9); zephir_check_call_status(); zephir_array_update_string(&definition, SL("default"), &_15, PH_COPY | PH_SEPARATE); zephir_array_fetch_string(&_17, definition, SL("default"), PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 282 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_18); ZVAL_STRING(&_18, "null", 0); ZEPHIR_CALL_FUNCTION(&_19, "strcasecmp", &_20, _17, &_18); zephir_check_call_status(); if (ZEPHIR_IS_LONG(_19, 0)) { zephir_array_update_string(&definition, SL("default"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); } } zephir_array_fetch_long(&columnName, field, 0, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 290 TSRMLS_CC); ZEPHIR_INIT_NVAR(_7); object_init_ex(_7, phalcon_db_column_ce); ZEPHIR_CALL_METHOD(NULL, _7, "__construct", &_21, columnName, definition); zephir_check_call_status(); zephir_array_append(&columns, _7, PH_SEPARATE, "phalcon/db/adapter/pdo/postgresql.zep", 291); ZEPHIR_CPY_WRT(oldColumn, columnName); } RETURN_CCTOR(columns); }
/** * Stores cached content into the file backend and stops the frontend * * @param int|string keyName * @param string content * @param long lifetime * @param boolean stopBuffer */ PHP_METHOD(Phalcon_Cache_Backend_Xcache, save) { zephir_fcall_cache_entry *_1 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_bool stopBuffer; zval *keyName = NULL, *content = NULL, *lifetime = NULL, *stopBuffer_param = NULL, *lastKey = NULL, *frontend, *cachedContent = NULL, *preparedContent = NULL, *tmp, *tt1 = NULL, *success = NULL, *isBuffering = NULL, *options, *keys = NULL, *specialKey, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 4, &keyName, &content, &lifetime, &stopBuffer_param); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!content) { content = ZEPHIR_GLOBAL(global_null); } if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } if (!stopBuffer_param) { stopBuffer = 1; } else { stopBuffer = zephir_get_boolval(stopBuffer_param); } if (!(zephir_is_true(keyName))) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_SVV(lastKey, "_PHCX", _0, keyName); } if (!(zephir_is_true(lastKey))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Cache must be started first", "phalcon/cache/backend/xcache.zep", 119); return; } ZEPHIR_OBS_VAR(frontend); zephir_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC); if (!(zephir_is_true(content))) { ZEPHIR_CALL_METHOD(&cachedContent, frontend, "getcontent", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(cachedContent, content); } if (!(zephir_is_numeric(cachedContent))) { ZEPHIR_CALL_METHOD(&preparedContent, frontend, "beforestore", NULL, 0, cachedContent); zephir_check_call_status(); } if (!(zephir_is_true(lifetime))) { ZEPHIR_OBS_VAR(tmp); zephir_read_property_this(&tmp, this_ptr, SL("_lastLifetime"), PH_NOISY_CC); if (!(zephir_is_true(tmp))) { ZEPHIR_CALL_METHOD(&tt1, frontend, "getlifetime", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(tt1, tmp); } } else { ZEPHIR_CPY_WRT(tt1, lifetime); } if (zephir_is_numeric(cachedContent)) { ZEPHIR_CALL_FUNCTION(&success, "xcache_set", &_1, 82, lastKey, cachedContent, tt1); zephir_check_call_status(); } else { ZEPHIR_CALL_FUNCTION(&success, "xcache_set", &_1, 82, lastKey, preparedContent, tt1); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&isBuffering, frontend, "isbuffering", NULL, 0); zephir_check_call_status(); if (stopBuffer == 1) { ZEPHIR_CALL_METHOD(NULL, frontend, "stop", NULL, 0); zephir_check_call_status(); } if (ZEPHIR_IS_TRUE_IDENTICAL(isBuffering)) { zend_print_zval(cachedContent, 0); } zephir_update_property_this(this_ptr, SL("_started"), (0) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); if (zephir_is_true(success)) { ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); ZEPHIR_OBS_VAR(specialKey); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (!(zephir_array_isset_string_fetch(&specialKey, _0, SS("statsKey"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/xcache.zep", 169); return; } ZEPHIR_CALL_FUNCTION(&keys, "xcache_get", NULL, 81, specialKey); zephir_check_call_status(); if (Z_TYPE_P(keys) != IS_ARRAY) { ZEPHIR_INIT_NVAR(keys); array_init(keys); } zephir_array_update_zval(&keys, lastKey, &tt1, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_FUNCTION(NULL, "xcache_set", &_1, 82, specialKey, keys); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); }
/** * This method is automatically called in Phalcon\Db\Adapter\Pdo constructor. * Call it when you need to restore a database connection * *<code> * //Make a connection * $connection = new \Phalcon\Db\Adapter\Pdo\Mysql(array( * 'host' => '192.168.0.11', * 'username' => 'sigma', * 'password' => 'secret', * 'dbname' => 'blog', * )); * * //Reconnect * $connection->connect(); * </code> * * @param array descriptor * @return boolean */ PHP_METHOD(Phalcon_Db_Adapter_Pdo, connect) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *descriptor = NULL, *username = NULL, *password = NULL, *dsnParts, *dsnAttributes = NULL, *persistent, *options = NULL, *key = NULL, *value = NULL, **_2, *_3 = NULL, *_4, *_5, *_6; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &descriptor); if (!descriptor) { ZEPHIR_CPY_WRT(descriptor, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(descriptor); } if (Z_TYPE_P(descriptor) == IS_NULL) { ZEPHIR_OBS_NVAR(descriptor); zephir_read_property_this(&descriptor, this_ptr, SL("_descriptor"), PH_NOISY_CC); } ZEPHIR_OBS_VAR(username); if (zephir_array_isset_string_fetch(&username, descriptor, SS("username"), 0 TSRMLS_CC)) { zephir_array_unset_string(&descriptor, SS("username"), PH_SEPARATE); } else { ZEPHIR_INIT_NVAR(username); ZVAL_NULL(username); } ZEPHIR_OBS_VAR(password); if (zephir_array_isset_string_fetch(&password, descriptor, SS("password"), 0 TSRMLS_CC)) { zephir_array_unset_string(&descriptor, SS("password"), PH_SEPARATE); } else { ZEPHIR_INIT_NVAR(password); ZVAL_NULL(password); } ZEPHIR_OBS_VAR(options); if (zephir_array_isset_string_fetch(&options, descriptor, SS("options"), 0 TSRMLS_CC)) { zephir_array_unset_string(&descriptor, SS("options"), PH_SEPARATE); } else { ZEPHIR_INIT_NVAR(options); array_init(options); } ZEPHIR_OBS_VAR(dsnAttributes); if (!(zephir_array_isset_string_fetch(&dsnAttributes, descriptor, SS("dsn"), 0 TSRMLS_CC))) { ZEPHIR_INIT_VAR(dsnParts); array_init(dsnParts); zephir_is_iterable(descriptor, &_1, &_0, 0, 0, "phalcon/db/adapter/pdo.zep", 130); 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_INIT_LNVAR(_3); ZEPHIR_CONCAT_VSV(_3, key, "=", value); zephir_array_append(&dsnParts, _3, PH_SEPARATE, "phalcon/db/adapter/pdo.zep", 128); } ZEPHIR_INIT_NVAR(dsnAttributes); zephir_fast_join_str(dsnAttributes, SL(";"), dsnParts TSRMLS_CC); } ZEPHIR_INIT_VAR(_4); ZVAL_LONG(_4, 2); zephir_array_update_long(&options, 3, &_4, PH_COPY | PH_SEPARATE, "phalcon/db/adapter/pdo.zep", 133); if (zephir_array_isset_string_fetch(&persistent, descriptor, SS("persistent"), 1 TSRMLS_CC)) { if (zephir_is_true(persistent)) { zephir_array_update_long(&options, 12, &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE, "phalcon/db/adapter/pdo.zep", 140); } } ZEPHIR_INIT_VAR(_5); object_init_ex(_5, php_pdo_get_dbh_ce()); _6 = zephir_fetch_nproperty_this(this_ptr, SL("_type"), PH_NOISY_CC); ZEPHIR_INIT_LNVAR(_3); ZEPHIR_CONCAT_VSV(_3, _6, ":", dsnAttributes); ZEPHIR_CALL_METHOD(NULL, _5, "__construct", NULL, _3, username, password, options); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_pdo"), _5 TSRMLS_CC); ZEPHIR_MM_RESTORE(); }
/** * Returns a MongoDb collection based on the backend parameters * * @return MongoCollection */ PHP_METHOD(Phalcon_Cache_Backend_Mongo, _getCollection){ zval *mongo_collection = NULL, *options, *mongo = NULL, *server; zval *database, *collection, *mongo_database; zend_class_entry *ce0; PHALCON_MM_GROW(); PHALCON_OBS_VAR(mongo_collection); phalcon_read_property_this(&mongo_collection, this_ptr, SL("_collection"), PH_NOISY_CC); if (Z_TYPE_P(mongo_collection) != IS_OBJECT) { PHALCON_OBS_VAR(options); phalcon_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); /** * If mongo is defined a valid Mongo object must be passed */ if (phalcon_array_isset_string(options, SS("mongo"))) { PHALCON_OBS_VAR(mongo); phalcon_array_fetch_string(&mongo, options, SL("mongo"), PH_NOISY); if (Z_TYPE_P(mongo) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "The 'mongo' parameter must be a valid Mongo instance"); return; } } else { /** * Server must be defined otherwise */ PHALCON_OBS_VAR(server); phalcon_array_fetch_string(&server, options, SL("server"), PH_NOISY); if (Z_TYPE_P(server) != IS_STRING) { PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "The backend requires a valid MongoDB connection string"); return; } ce0 = zend_fetch_class(SL("Mongo"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); PHALCON_INIT_NVAR(mongo); object_init_ex(mongo, ce0); if (phalcon_has_constructor(mongo TSRMLS_CC)) { phalcon_call_method_p1_noret(mongo, "__construct", server); } } /** * Check if the database name is a string */ PHALCON_OBS_VAR(database); phalcon_array_fetch_string(&database, options, SL("db"), PH_NOISY); if (Z_TYPE_P(database) != IS_STRING) { PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "The backend requires a valid MongoDB db"); return; } /** * Retrieve the connection name */ PHALCON_OBS_VAR(collection); phalcon_array_fetch_string(&collection, options, SL("collection"), PH_NOISY); if (Z_TYPE_P(collection) != IS_STRING) { PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "The backend requires a valid MongoDB collection"); return; } /** * Make the connection and get the collection */ PHALCON_INIT_VAR(mongo_database); phalcon_call_method_p1(mongo_database, mongo, "selectdb", database); PHALCON_INIT_NVAR(mongo_collection); phalcon_call_method_p1(mongo_collection, mongo_database, "selectcollection", collection); } RETURN_CCTOR(mongo_collection); }
/** * Returns a cached content * * @param int|string $keyName * @param long $lifetime * @return mixed */ PHP_METHOD(Phalcon_Cache_Backend_Mongo, get){ zval *key_name, *lifetime = NULL, *frontend, *prefix, *prefixed_key; zval *collection, *conditions, *document, *timestamp; zval *ttl = NULL, *modified_time, *difference, *not_expired; zval *cached_content; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 1, &key_name, &lifetime); if (!lifetime) { PHALCON_INIT_VAR(lifetime); } else { PHALCON_SEPARATE_PARAM(lifetime); } PHALCON_OBS_VAR(frontend); phalcon_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC); PHALCON_OBS_VAR(prefix); phalcon_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC); PHALCON_INIT_VAR(prefixed_key); PHALCON_CONCAT_VV(prefixed_key, prefix, key_name); phalcon_update_property_this(this_ptr, SL("_lastKey"), prefixed_key TSRMLS_CC); PHALCON_INIT_VAR(collection); phalcon_call_method(collection, this_ptr, "_getcollection"); PHALCON_INIT_VAR(conditions); array_init_size(conditions, 1); phalcon_array_update_string(&conditions, SL("key"), &prefixed_key, PH_COPY | PH_SEPARATE); PHALCON_INIT_VAR(document); phalcon_call_method_p1(document, collection, "findone", conditions); if (Z_TYPE_P(document) == IS_ARRAY) { PHALCON_INIT_VAR(timestamp); ZVAL_LONG(timestamp, (long) time(NULL)); /** * Take the lifetime from the frontend or read it from the set in start() */ if (Z_TYPE_P(lifetime) == IS_NULL) { PHALCON_OBS_NVAR(lifetime); phalcon_read_property_this(&lifetime, this_ptr, SL("_lastLifetime"), PH_NOISY_CC); if (Z_TYPE_P(lifetime) == IS_NULL) { PHALCON_INIT_VAR(ttl); phalcon_call_method(ttl, frontend, "getlifetime"); } else { PHALCON_CPY_WRT(ttl, lifetime); } } else { PHALCON_CPY_WRT(ttl, lifetime); } if (!phalcon_array_isset_string(document, SS("time"))) { PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "The cache is currupted"); return; } PHALCON_OBS_VAR(modified_time); phalcon_array_fetch_string(&modified_time, document, SL("time"), PH_NOISY); PHALCON_INIT_VAR(difference); sub_function(difference, timestamp, ttl TSRMLS_CC); PHALCON_INIT_VAR(not_expired); is_smaller_function(not_expired, difference, modified_time TSRMLS_CC); /** * The expiration is based on the column 'time' */ if (PHALCON_IS_TRUE(not_expired)) { if (!phalcon_array_isset_string(document, SS("data"))) { PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "The cache is currupted"); return; } PHALCON_OBS_VAR(cached_content); phalcon_array_fetch_string(&cached_content, document, SL("data"), PH_NOISY); phalcon_call_method_p1(return_value, frontend, "afterretrieve", cached_content); RETURN_MM(); } } RETURN_MM_NULL(); }
/** * Phalcon\Db\Reference constructor * * @param string $referenceName * @param array $definition */ PHP_METHOD(Phalcon_Db_Reference, __construct){ zval *reference_name, *definition, *referenced_table; zval *columns, *referenced_columns, *schema; zval *referenced_schema, *number_columns; zval *number_referenced_columns; PHALCON_MM_GROW(); phalcon_fetch_params(1, 2, 0, &reference_name, &definition); phalcon_update_property_this(this_ptr, SL("_referenceName"), reference_name TSRMLS_CC); if (phalcon_array_isset_string(definition, SS("referencedTable"))) { PHALCON_OBS_VAR(referenced_table); phalcon_array_fetch_string(&referenced_table, definition, SL("referencedTable"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_referencedTable"), referenced_table TSRMLS_CC); } else { PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Referenced table is required"); return; } if (phalcon_array_isset_string(definition, SS("columns"))) { PHALCON_OBS_VAR(columns); phalcon_array_fetch_string(&columns, definition, SL("columns"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_columns"), columns TSRMLS_CC); } else { PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Foreign key columns are required"); return; } if (phalcon_array_isset_string(definition, SS("referencedColumns"))) { PHALCON_OBS_VAR(referenced_columns); phalcon_array_fetch_string(&referenced_columns, definition, SL("referencedColumns"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_referencedColumns"), referenced_columns TSRMLS_CC); } else { PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Referenced columns of the foreign key are required"); return; } if (phalcon_array_isset_string(definition, SS("schema"))) { PHALCON_OBS_VAR(schema); phalcon_array_fetch_string(&schema, definition, SL("schema"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_schemaName"), schema TSRMLS_CC); } if (phalcon_array_isset_string(definition, SS("referencedSchema"))) { PHALCON_OBS_VAR(referenced_schema); phalcon_array_fetch_string(&referenced_schema, definition, SL("referencedSchema"), PH_NOISY); phalcon_update_property_this(this_ptr, SL("_referencedSchema"), referenced_schema TSRMLS_CC); } PHALCON_INIT_VAR(number_columns); phalcon_fast_count(number_columns, columns TSRMLS_CC); PHALCON_INIT_VAR(number_referenced_columns); phalcon_fast_count(number_referenced_columns, referenced_columns TSRMLS_CC); if (!PHALCON_IS_EQUAL(number_columns, number_referenced_columns)) { PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Number of columns is not equals than the number of columns referenced"); return; } PHALCON_MM_RESTORE(); }
#include <php.h> #include "php_zephir.h" #include "zephir.h" #include "utils.h" #include "expr.h" #include "symtable.h" #include "kernel/main.h" zephir_compiled_expr *zephir_operator_comparison_greater(zephir_context *context, zval *expr TSRMLS_DC) { zval *left_expr, *right_expr; zephir_compiled_expr *compiled_expr_left, *compiled_expr_right, *compiled_expr; _zephir_array_fetch_string(&left_expr, expr, SS("left") TSRMLS_CC); if (Z_TYPE_P(left_expr) != IS_ARRAY) { return NULL; } _zephir_array_fetch_string(&right_expr, expr, SS("right") TSRMLS_CC); if (Z_TYPE_P(right_expr) != IS_ARRAY) { return NULL; } compiled_expr_left = zephir_expr(context, left_expr TSRMLS_CC); compiled_expr_right = zephir_expr(context, right_expr TSRMLS_CC); switch (compiled_expr_left->type) { case ZEPHIR_T_TYPE_LONG:
/** * Checks whether view exists on registered extensions and render it * * @param array $engines * @param string $viewPath * @param boolean $silence * @param boolean $mustClean * @param Phalcon\Cache\BackendInterface $cache */ PHP_METHOD(Phalcon_Mvc_View, _engineRender){ zval *engines, *view_path, *silence, *must_clean; zval *cache, *not_exists = NULL, *view_params, *views_dir; zval *base_path, *views_dir_path, *events_manager; zval *render_level, *cache_level, *enter_cache; zval *is_started, *key = NULL, *lifetime = NULL, *view_options; zval *cache_options, *cached_view, *is_fresh; zval *engine = NULL, *extension = NULL, *view_engine_path = NULL; zval *event_name = NULL, *status = NULL, *exception_message; HashTable *ah0; HashPosition hp0; zval **hd; PHALCON_MM_GROW(); phalcon_fetch_params(1, 5, 0, &engines, &view_path, &silence, &must_clean, &cache); PHALCON_INIT_VAR(not_exists); ZVAL_BOOL(not_exists, 1); PHALCON_OBS_VAR(view_params); phalcon_read_property_this(&view_params, this_ptr, SL("_viewParams"), PH_NOISY_CC); PHALCON_OBS_VAR(views_dir); phalcon_read_property_this(&views_dir, this_ptr, SL("_viewsDir"), PH_NOISY_CC); PHALCON_OBS_VAR(base_path); phalcon_read_property_this(&base_path, this_ptr, SL("_basePath"), PH_NOISY_CC); PHALCON_INIT_VAR(views_dir_path); PHALCON_CONCAT_VVV(views_dir_path, base_path, views_dir, view_path); PHALCON_OBS_VAR(events_manager); phalcon_read_property_this(&events_manager, this_ptr, SL("_eventsManager"), PH_NOISY_CC); if (Z_TYPE_P(cache) == IS_OBJECT) { PHALCON_OBS_VAR(render_level); phalcon_read_property_this(&render_level, this_ptr, SL("_renderLevel"), PH_NOISY_CC); PHALCON_OBS_VAR(cache_level); phalcon_read_property_this(&cache_level, this_ptr, SL("_cacheLevel"), PH_NOISY_CC); /** * Evaluate if we need to enter in 'cache' mode */ PHALCON_INIT_VAR(enter_cache); is_smaller_or_equal_function(enter_cache, cache_level, render_level TSRMLS_CC); if (zend_is_true(enter_cache)) { /** * Check if the cache is started, the first time a cache is started we start the * cache */ PHALCON_INIT_VAR(is_started); PHALCON_CALL_METHOD(is_started, cache, "isstarted"); if (PHALCON_IS_FALSE(is_started)) { PHALCON_INIT_VAR(key); PHALCON_INIT_VAR(lifetime); PHALCON_OBS_VAR(view_options); phalcon_read_property_this(&view_options, this_ptr, SL("_options"), PH_NOISY_CC); /** * Check if the user has defined a different options to the default */ if (Z_TYPE_P(view_options) == IS_ARRAY) { if (phalcon_array_isset_string(view_options, SS("cache"))) { PHALCON_OBS_VAR(cache_options); phalcon_array_fetch_string(&cache_options, view_options, SL("cache"), PH_NOISY_CC); if (Z_TYPE_P(cache_options) == IS_ARRAY) { if (phalcon_array_isset_string(cache_options, SS("key"))) { PHALCON_OBS_NVAR(key); phalcon_array_fetch_string(&key, cache_options, SL("key"), PH_NOISY_CC); } if (phalcon_array_isset_string(cache_options, SS("lifetime"))) { PHALCON_OBS_NVAR(lifetime); phalcon_array_fetch_string(&lifetime, cache_options, SL("lifetime"), PH_NOISY_CC); } } } } /** * If a cache key is not set we create one using a md5 */ if (Z_TYPE_P(key) == IS_NULL) { PHALCON_INIT_NVAR(key); PHALCON_CALL_FUNC_PARAMS_1(key, "md5", view_path); } /** * We start the cache using the key set */ PHALCON_INIT_VAR(cached_view); PHALCON_CALL_METHOD_PARAMS_2(cached_view, cache, "start", key, lifetime); if (Z_TYPE_P(cached_view) != IS_NULL) { phalcon_update_property_this(this_ptr, SL("_content"), cached_view TSRMLS_CC); RETURN_MM_NULL(); } } /** * This method only returns true if the cache has not expired */ PHALCON_INIT_VAR(is_fresh); PHALCON_CALL_METHOD(is_fresh, cache, "isfresh"); if (!zend_is_true(is_fresh)) { RETURN_MM_NULL(); } } } /** * Views are rendered in each engine */ if (!phalcon_is_iterable(engines, &ah0, &hp0, 0, 0 TSRMLS_CC)) { return; } while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) { PHALCON_GET_FOREACH_KEY(extension, ah0, hp0); PHALCON_GET_FOREACH_VALUE(engine); PHALCON_INIT_NVAR(view_engine_path); PHALCON_CONCAT_VV(view_engine_path, views_dir_path, extension); if (phalcon_file_exists(view_engine_path TSRMLS_CC) == SUCCESS) { /** * Call beforeRenderView if there is a events manager available */ if (Z_TYPE_P(events_manager) == IS_OBJECT) { phalcon_update_property_this(this_ptr, SL("_activeRenderPath"), view_engine_path TSRMLS_CC); PHALCON_INIT_NVAR(event_name); ZVAL_STRING(event_name, "view:beforeRenderView", 1); PHALCON_INIT_NVAR(status); PHALCON_CALL_METHOD_PARAMS_3(status, events_manager, "fire", event_name, this_ptr, view_engine_path); if (PHALCON_IS_FALSE(status)) { zend_hash_move_forward_ex(ah0, &hp0); continue; } } PHALCON_CALL_METHOD_PARAMS_3_NORETURN(engine, "render", view_engine_path, view_params, must_clean); /** * Call afterRenderView if there is a events manager available */ PHALCON_INIT_NVAR(not_exists); ZVAL_BOOL(not_exists, 0); if (Z_TYPE_P(events_manager) == IS_OBJECT) { PHALCON_INIT_NVAR(event_name); ZVAL_STRING(event_name, "view:afterRenderView", 1); PHALCON_CALL_METHOD_PARAMS_2_NORETURN(events_manager, "fire", event_name, this_ptr); } break; } zend_hash_move_forward_ex(ah0, &hp0); } if (PHALCON_IS_TRUE(not_exists)) { /** * Notify about not found views */ if (Z_TYPE_P(events_manager) == IS_OBJECT) { phalcon_update_property_this(this_ptr, SL("_activeRenderPath"), view_engine_path TSRMLS_CC); PHALCON_INIT_NVAR(event_name); ZVAL_STRING(event_name, "view:notFoundView", 1); PHALCON_CALL_METHOD_PARAMS_2_NORETURN(events_manager, "fire", event_name, this_ptr); } if (!zend_is_true(silence)) { PHALCON_INIT_VAR(exception_message); PHALCON_CONCAT_SVS(exception_message, "View '", views_dir_path, "' was not found in the views directory"); PHALCON_THROW_EXCEPTION_ZVAL(phalcon_mvc_view_exception_ce, exception_message); return; } } PHALCON_MM_RESTORE(); }
/** * Lists table indexes * * <code> * print_r($connection->describeIndexes('robots_parts')); * </code> * * @param string table * @param string schema * @return \Phalcon\Db\IndexInterface[] */ PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, describeIndexes) { HashTable *_5, *_28, *_15$$3; HashPosition _4, _27, _14$$3; zephir_fcall_cache_entry *_20 = NULL, *_33 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *table, *schema = NULL, *indexes = NULL, *index = NULL, *keyName = NULL, *indexObjects = NULL, *name = NULL, *columns = NULL, *describeIndex = NULL, *indexSql = NULL, *_0 = NULL, *_1, *_2 = NULL, *_3, **_6, **_29, *_7$$4 = NULL, *_8$$3, *_10$$3 = NULL, *_11$$3, *_12$$3 = NULL, *_13$$3 = NULL, **_16$$3, *_18$$3, *_19$$3 = NULL, *_21$$3, *_9$$6, *_17$$7, *_22$$8 = NULL, *_23$$8 = NULL, _24$$8 = zval_used_for_init, *_25$$9 = NULL, *_26$$10 = NULL, *_30$$12 = NULL, *_31$$12, *_32$$12; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table, &schema); if (!schema) { schema = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(indexes); array_init(indexes); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_2, _1, "describeindexes", NULL, 0, table, schema); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 2); 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/sqlite.zep", 341); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(index, _6); ZEPHIR_OBS_NVAR(keyName); zephir_array_fetch_string(&keyName, index, SL("name"), PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 311 TSRMLS_CC); if (!(zephir_array_isset(indexes, keyName))) { ZEPHIR_INIT_NVAR(_7$$4); array_init(_7$$4); zephir_array_update_zval(&indexes, keyName, &_7$$4, PH_COPY | PH_SEPARATE); } zephir_array_fetch(&_8$$3, indexes, keyName, PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 317 TSRMLS_CC); if (!(zephir_array_isset_string(_8$$3, SS("columns")))) { ZEPHIR_INIT_NVAR(columns); array_init(columns); } else { zephir_array_fetch(&_9$$6, indexes, keyName, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 320 TSRMLS_CC); ZEPHIR_OBS_NVAR(columns); zephir_array_fetch_string(&columns, _9$$6, SL("columns"), PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 320 TSRMLS_CC); } _11$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_12$$3, _11$$3, "describeindex", NULL, 0, keyName); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_13$$3); ZVAL_LONG(_13$$3, 2); ZEPHIR_CALL_METHOD(&_10$$3, this_ptr, "fetchall", NULL, 0, _12$$3, _13$$3); zephir_check_call_status(); zephir_is_iterable(_10$$3, &_15$$3, &_14$$3, 0, 0, "phalcon/db/adapter/pdo/sqlite.zep", 327); for ( ; zephir_hash_get_current_data_ex(_15$$3, (void**) &_16$$3, &_14$$3) == SUCCESS ; zephir_hash_move_forward_ex(_15$$3, &_14$$3) ) { ZEPHIR_GET_HVALUE(describeIndex, _16$$3); zephir_array_fetch_string(&_17$$7, describeIndex, SL("name"), PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 324 TSRMLS_CC); zephir_array_append(&columns, _17$$7, PH_SEPARATE, "phalcon/db/adapter/pdo/sqlite.zep", 324); } zephir_array_update_multi(&indexes, &columns TSRMLS_CC, SL("zs"), 3, keyName, SL("columns")); _18$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_19$$3, _18$$3, "listindexessql", NULL, 0, table, schema, keyName); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&indexSql, this_ptr, "fetchcolumn", &_20, 0, _19$$3); zephir_check_call_status(); zephir_array_fetch_string(&_21$$3, index, SL("unique"), PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 330 TSRMLS_CC); if (zephir_is_true(_21$$3)) { ZEPHIR_INIT_NVAR(_22$$8); ZEPHIR_INIT_NVAR(_23$$8); ZEPHIR_SINIT_NVAR(_24$$8); ZVAL_STRING(&_24$$8, "# UNIQUE #i", 0); zephir_preg_match(_23$$8, &_24$$8, indexSql, _22$$8, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(_23$$8)) { ZEPHIR_INIT_NVAR(_25$$9); ZVAL_STRING(_25$$9, "UNIQUE", 1); zephir_array_update_multi(&indexes, &_25$$9 TSRMLS_CC, SL("zs"), 3, keyName, SL("type")); } else { ZEPHIR_INIT_NVAR(_26$$10); ZVAL_STRING(_26$$10, "PRIMARY", 1); zephir_array_update_multi(&indexes, &_26$$10 TSRMLS_CC, SL("zs"), 3, keyName, SL("type")); } } else { zephir_array_update_multi(&indexes, &ZEPHIR_GLOBAL(global_null) TSRMLS_CC, SL("zs"), 3, keyName, SL("type")); } } ZEPHIR_INIT_VAR(indexObjects); array_init(indexObjects); zephir_is_iterable(indexes, &_28, &_27, 0, 0, "phalcon/db/adapter/pdo/sqlite.zep", 346); for ( ; zephir_hash_get_current_data_ex(_28, (void**) &_29, &_27) == SUCCESS ; zephir_hash_move_forward_ex(_28, &_27) ) { ZEPHIR_GET_HMKEY(name, _28, _27); ZEPHIR_GET_HVALUE(index, _29); ZEPHIR_INIT_NVAR(_30$$12); object_init_ex(_30$$12, phalcon_db_index_ce); zephir_array_fetch_string(&_31$$12, index, SL("columns"), PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 343 TSRMLS_CC); zephir_array_fetch_string(&_32$$12, index, SL("type"), PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 343 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, _30$$12, "__construct", &_33, 15, name, _31$$12, _32$$12); zephir_check_call_status(); zephir_array_update_zval(&indexObjects, name, &_30$$12, PH_COPY | PH_SEPARATE); } RETURN_CCTOR(indexObjects); }
/** * Executes the validation * * @param Phalcon\Validation $validator * @param string $attribute * @return boolean */ PHP_METHOD(Phalcon_Validation_Validator_Confirmation, validate){ zval *validator, *attribute, *with_attribute; zval *value = NULL, *with_value = NULL, *message_str, *message, *code; zval *label, *with_label, *pairs, *prepared = NULL; zend_class_entry *ce = Z_OBJCE_P(getThis()); PHALCON_MM_GROW(); phalcon_fetch_params(1, 2, 0, &validator, &attribute); PHALCON_VERIFY_CLASS_EX(validator, phalcon_validation_ce, phalcon_validation_exception_ce, 1); PHALCON_OBS_VAR(with_attribute); RETURN_MM_ON_FAILURE(phalcon_validation_validator_getoption_helper(ce, &with_attribute, getThis(), "with" TSRMLS_CC)); PHALCON_CALL_METHOD(&value, validator, "getvalue", attribute); PHALCON_CALL_METHOD(&with_value, validator, "getvalue", with_attribute); if (!PHALCON_IS_EQUAL(value, with_value)) { PHALCON_OBS_VAR(label); RETURN_MM_ON_FAILURE(phalcon_validation_validator_getoption_helper(ce, &label, getThis(), phalcon_interned_label TSRMLS_CC)); if (!zend_is_true(label)) { PHALCON_CALL_METHOD(&label, validator, "getlabel", attribute); if (!zend_is_true(label)) { PHALCON_CPY_WRT(label, attribute); } } PHALCON_OBS_VAR(with_label); RETURN_MM_ON_FAILURE(phalcon_validation_validator_getoption_helper(ce, &with_label, getThis(), phalcon_interned_label TSRMLS_CC)); if (!zend_is_true(with_label)) { PHALCON_CALL_METHOD(&with_label, validator, "getlabel", with_attribute); if (!zend_is_true(with_label)) { PHALCON_CPY_WRT(with_label, with_attribute); } } PHALCON_ALLOC_GHOST_ZVAL(pairs); array_init_size(pairs, 2); Z_ADDREF_P(label); add_assoc_zval_ex(pairs, SS(":field"), label); Z_ADDREF_P(with_label); add_assoc_zval_ex(pairs, SS(":with"), with_label); PHALCON_OBS_VAR(message_str); RETURN_MM_ON_FAILURE(phalcon_validation_validator_getoption_helper(ce, &message_str, getThis(), phalcon_interned_message TSRMLS_CC)); if (!zend_is_true(message_str)) { PHALCON_OBSERVE_OR_NULLIFY_VAR(message_str); RETURN_MM_ON_FAILURE(phalcon_validation_getdefaultmessage_helper(Z_OBJCE_P(validator), &message_str, validator, "Confirmation" TSRMLS_CC)); } PHALCON_OBS_VAR(code); RETURN_MM_ON_FAILURE(phalcon_validation_validator_getoption_helper(ce, &code, getThis(), phalcon_interned_code TSRMLS_CC)); if (Z_TYPE_P(code) == IS_NULL) { ZVAL_LONG(code, 0); } PHALCON_CALL_FUNCTION(&prepared, "strtr", message_str, pairs); message = phalcon_validation_message_construct_helper(prepared, attribute, "Confirmation", code TSRMLS_CC); Z_DELREF_P(message); PHALCON_CALL_METHOD(NULL, validator, "appendmessage", message); RETURN_MM_FALSE; } RETURN_MM_TRUE; }
/** * Returns an array of Phalcon\Db\Column objects describing a table * * <code> * print_r($connection->describeColumns("posts")); * </code> */ PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, describeColumns) { zend_bool _11$$4, _36$$3; HashTable *_5; HashPosition _4; zephir_fcall_cache_entry *_35 = NULL, *_42 = NULL, *_44 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *table_param = NULL, *schema_param = NULL, *columns = NULL, *columnType = NULL, *field = NULL, *definition = NULL, *oldColumn = NULL, *sizePattern = NULL, *matches = NULL, *matchOne = NULL, *matchTwo = NULL, *columnName = NULL, *_0 = NULL, *_1, *_2 = NULL, *_3, **_6, *_7$$5 = NULL, *_8$$5 = NULL, *_9$$6 = NULL, *_10$$6 = NULL, *_26$$4 = NULL, *_12$$7 = NULL, *_13$$7 = NULL, *_14$$7, *_15$$9 = NULL, *_16$$10 = NULL, *_17$$11 = NULL, *_18$$12 = NULL, *_19$$12 = NULL, *_20$$13 = NULL, *_21$$14 = NULL, *_22$$15 = NULL, *_23$$16 = NULL, *_24$$16 = NULL, *_25$$17 = NULL, *_27$$18 = NULL, *_28$$20 = NULL, *_29$$21 = NULL, *_30$$3, *_31$$3, *_32$$3, _33$$3 = zval_used_for_init, *_34$$3 = NULL, *_37$$3, *_43$$3 = NULL, *_38$$27, *_39$$27 = NULL, *_40$$27 = NULL, *_41$$27 = NULL; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); zephir_get_strval(table, table_param); if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } ZEPHIR_INIT_VAR(oldColumn); ZVAL_NULL(oldColumn); ZEPHIR_INIT_VAR(sizePattern); ZVAL_STRING(sizePattern, "#\\(([0-9]+)(?:,\\s*([0-9]+))*\\)#", 1); ZEPHIR_INIT_VAR(columns); array_init(columns); _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/sqlite.zep", 291); 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(columnType); zephir_array_fetch_long(&columnType, field, 2, PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 108 TSRMLS_CC); while (1) { if (zephir_memnstr_str(columnType, SL("tinyint(1)"), "phalcon/db/adapter/pdo/sqlite.zep", 115)) { ZEPHIR_INIT_NVAR(_7$$5); ZVAL_LONG(_7$$5, 8); zephir_array_update_string(&definition, SL("type"), &_7$$5, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8$$5); ZVAL_LONG(_8$$5, 5); zephir_array_update_string(&definition, SL("bindType"), &_8$$5, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(columnType); ZVAL_STRING(columnType, "boolean", 1); break; } if (zephir_memnstr_str(columnType, SL("bigint"), "phalcon/db/adapter/pdo/sqlite.zep", 125)) { ZEPHIR_INIT_NVAR(_9$$6); ZVAL_LONG(_9$$6, 14); 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_INIT_NVAR(_10$$6); ZVAL_LONG(_10$$6, 1); zephir_array_update_string(&definition, SL("bindType"), &_10$$6, PH_COPY | PH_SEPARATE); break; } _11$$4 = zephir_memnstr_str(columnType, SL("int"), "phalcon/db/adapter/pdo/sqlite.zep", 135); if (!(_11$$4)) { _11$$4 = zephir_memnstr_str(columnType, SL("INT"), "phalcon/db/adapter/pdo/sqlite.zep", 135); } if (_11$$4) { ZEPHIR_INIT_NVAR(_12$$7); ZVAL_LONG(_12$$7, 0); zephir_array_update_string(&definition, SL("type"), &_12$$7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_13$$7); ZVAL_LONG(_13$$7, 1); zephir_array_update_string(&definition, SL("bindType"), &_13$$7, PH_COPY | PH_SEPARATE); zephir_array_fetch_long(&_14$$7, field, 5, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 141 TSRMLS_CC); if (zephir_is_true(_14$$7)) { zephir_array_update_string(&definition, SL("autoIncrement"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } break; } if (zephir_memnstr_str(columnType, SL("varchar"), "phalcon/db/adapter/pdo/sqlite.zep", 150)) { ZEPHIR_INIT_NVAR(_15$$9); ZVAL_LONG(_15$$9, 2); zephir_array_update_string(&definition, SL("type"), &_15$$9, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("date"), "phalcon/db/adapter/pdo/sqlite.zep", 158)) { ZEPHIR_INIT_NVAR(_16$$10); ZVAL_LONG(_16$$10, 1); zephir_array_update_string(&definition, SL("type"), &_16$$10, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("timestamp"), "phalcon/db/adapter/pdo/sqlite.zep", 166)) { ZEPHIR_INIT_NVAR(_17$$11); ZVAL_LONG(_17$$11, 17); zephir_array_update_string(&definition, SL("type"), &_17$$11, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("decimal"), "phalcon/db/adapter/pdo/sqlite.zep", 174)) { ZEPHIR_INIT_NVAR(_18$$12); ZVAL_LONG(_18$$12, 3); zephir_array_update_string(&definition, SL("type"), &_18$$12, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_19$$12); ZVAL_LONG(_19$$12, 32); zephir_array_update_string(&definition, SL("bindType"), &_19$$12, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("char"), "phalcon/db/adapter/pdo/sqlite.zep", 184)) { ZEPHIR_INIT_NVAR(_20$$13); ZVAL_LONG(_20$$13, 5); zephir_array_update_string(&definition, SL("type"), &_20$$13, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("datetime"), "phalcon/db/adapter/pdo/sqlite.zep", 192)) { ZEPHIR_INIT_NVAR(_21$$14); ZVAL_LONG(_21$$14, 4); zephir_array_update_string(&definition, SL("type"), &_21$$14, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("text"), "phalcon/db/adapter/pdo/sqlite.zep", 200)) { ZEPHIR_INIT_NVAR(_22$$15); ZVAL_LONG(_22$$15, 6); zephir_array_update_string(&definition, SL("type"), &_22$$15, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("float"), "phalcon/db/adapter/pdo/sqlite.zep", 208)) { ZEPHIR_INIT_NVAR(_23$$16); ZVAL_LONG(_23$$16, 7); zephir_array_update_string(&definition, SL("type"), &_23$$16, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_24$$16); ZVAL_LONG(_24$$16, 3); zephir_array_update_string(&definition, SL("bindType"), &_24$$16, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("enum"), "phalcon/db/adapter/pdo/sqlite.zep", 218)) { ZEPHIR_INIT_NVAR(_25$$17); ZVAL_LONG(_25$$17, 5); zephir_array_update_string(&definition, SL("type"), &_25$$17, PH_COPY | PH_SEPARATE); break; } ZEPHIR_INIT_NVAR(_26$$4); ZVAL_LONG(_26$$4, 2); zephir_array_update_string(&definition, SL("type"), &_26$$4, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("("), "phalcon/db/adapter/pdo/sqlite.zep", 233)) { ZEPHIR_INIT_NVAR(matches); ZVAL_NULL(matches); ZEPHIR_INIT_NVAR(_27$$18); zephir_preg_match(_27$$18, sizePattern, columnType, matches, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(_27$$18)) { ZEPHIR_OBS_NVAR(matchOne); if (zephir_array_isset_long_fetch(&matchOne, matches, 1, 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_28$$20); ZVAL_LONG(_28$$20, zephir_get_intval(matchOne)); zephir_array_update_string(&definition, SL("size"), &_28$$20, PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_NVAR(matchTwo); if (zephir_array_isset_long_fetch(&matchTwo, matches, 2, 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_29$$21); ZVAL_LONG(_29$$21, zephir_get_intval(matchTwo)); zephir_array_update_string(&definition, SL("scale"), &_29$$21, PH_COPY | PH_SEPARATE); } } } if (zephir_memnstr_str(columnType, SL("unsigned"), "phalcon/db/adapter/pdo/sqlite.zep", 248)) { zephir_array_update_string(&definition, SL("unsigned"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } 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(&_30$$3, field, 5, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 264 TSRMLS_CC); if (zephir_is_true(_30$$3)) { zephir_array_update_string(&definition, SL("primary"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_31$$3, field, 3, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 271 TSRMLS_CC); if (zephir_is_true(_31$$3)) { zephir_array_update_string(&definition, SL("notNull"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_32$$3, field, 4, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 279 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_33$$3); ZVAL_STRING(&_33$$3, "null", 0); ZEPHIR_CALL_FUNCTION(&_34$$3, "strcasecmp", &_35, 19, _32$$3, &_33$$3); zephir_check_call_status(); _36$$3 = !ZEPHIR_IS_LONG(_34$$3, 0); if (_36$$3) { zephir_array_fetch_long(&_37$$3, field, 4, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 279 TSRMLS_CC); _36$$3 = !ZEPHIR_IS_STRING(_37$$3, ""); } if (_36$$3) { zephir_array_fetch_long(&_38$$27, field, 4, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 280 TSRMLS_CC); ZEPHIR_INIT_NVAR(_39$$27); ZVAL_STRING(_39$$27, "/^'|'$/", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_40$$27); ZVAL_STRING(_40$$27, "", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&_41$$27, "preg_replace", &_42, 29, _39$$27, _40$$27, _38$$27); zephir_check_temp_parameter(_39$$27); zephir_check_temp_parameter(_40$$27); zephir_check_call_status(); zephir_array_update_string(&definition, SL("default"), &_41$$27, PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&columnName, field, 1, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 286 TSRMLS_CC); ZEPHIR_INIT_NVAR(_43$$3); object_init_ex(_43$$3, phalcon_db_column_ce); ZEPHIR_CALL_METHOD(NULL, _43$$3, "__construct", &_44, 137, columnName, definition); zephir_check_call_status(); zephir_array_append(&columns, _43$$3, PH_SEPARATE, "phalcon/db/adapter/pdo/sqlite.zep", 287); ZEPHIR_CPY_WRT(oldColumn, columnName); } RETURN_CCTOR(columns); }
/* . it - column of the Hessenberg that is complete, PIPEFGMRES is actually computing two columns ahead of this */ static PetscErrorCode KSPPIPEFGMRESUpdateHessenberg(KSP ksp,PetscInt it,PetscBool *hapend,PetscReal *res) { PetscScalar *hh,*cc,*ss,*rs; PetscInt j; PetscReal hapbnd; KSP_PIPEFGMRES *pipefgmres = (KSP_PIPEFGMRES*)(ksp->data); PetscErrorCode ierr; PetscFunctionBegin; hh = HH(0,it); /* pointer to beginning of column to update */ cc = CC(0); /* beginning of cosine rotations */ ss = SS(0); /* beginning of sine rotations */ rs = RS(0); /* right hand side of least squares system */ /* The Hessenberg matrix is now correct through column it, save that form for possible spectral analysis */ for (j=0; j<=it+1; j++) *HES(j,it) = hh[j]; /* check for the happy breakdown */ hapbnd = PetscMin(PetscAbsScalar(hh[it+1] / rs[it]),pipefgmres->haptol); if (PetscAbsScalar(hh[it+1]) < hapbnd) { ierr = PetscInfo4(ksp,"Detected happy breakdown, current hapbnd = %14.12e H(%D,%D) = %14.12e\n",(double)hapbnd,it+1,it,(double)PetscAbsScalar(*HH(it+1,it)));CHKERRQ(ierr); *hapend = PETSC_TRUE; } /* Apply all the previously computed plane rotations to the new column of the Hessenberg matrix */ /* Note: this uses the rotation [conj(c) s ; -s c], c= cos(theta), s= sin(theta), and some refs have [c s ; -conj(s) c] (don't be confused!) */ for (j=0; j<it; j++) { PetscScalar hhj = hh[j]; hh[j] = PetscConj(cc[j])*hhj + ss[j]*hh[j+1]; hh[j+1] = -ss[j] *hhj + cc[j]*hh[j+1]; } /* compute the new plane rotation, and apply it to: 1) the right-hand-side of the Hessenberg system (RS) note: it affects RS(it) and RS(it+1) 2) the new column of the Hessenberg matrix note: it affects HH(it,it) which is currently pointed to by hh and HH(it+1, it) (*(hh+1)) thus obtaining the updated value of the residual... */ /* compute new plane rotation */ if (!*hapend) { PetscReal delta = PetscSqrtReal(PetscSqr(PetscAbsScalar(hh[it])) + PetscSqr(PetscAbsScalar(hh[it+1]))); if (delta == 0.0) { ksp->reason = KSP_DIVERGED_NULL; PetscFunctionReturn(0); } cc[it] = hh[it] / delta; /* new cosine value */ ss[it] = hh[it+1] / delta; /* new sine value */ hh[it] = PetscConj(cc[it])*hh[it] + ss[it]*hh[it+1]; rs[it+1] = -ss[it]*rs[it]; rs[it] = PetscConj(cc[it])*rs[it]; *res = PetscAbsScalar(rs[it+1]); } else { /* happy breakdown: HH(it+1, it) = 0, therefore we don't need to apply another rotation matrix (so RH doesn't change). The new residual is always the new sine term times the residual from last time (RS(it)), but now the new sine rotation would be zero...so the residual should be zero...so we will multiply "zero" by the last residual. This might not be exactly what we want to do here -could just return "zero". */ *res = 0.0; } PetscFunctionReturn(0); }
/** * Creates a table */ PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, createTable) { HashTable *_2$$6; HashPosition _1$$6; zephir_fcall_cache_entry *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *definition = NULL; zval *tableName_param = NULL, *schemaName_param = NULL, *definition_param = NULL, *sql = NULL, *queries = NULL, *query = NULL, *exception = NULL, *columns = NULL, *_0, **_3$$6, *_4$$7 = NULL, *_6$$5, *_7$$10, *_8$$10; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &definition_param); if (UNEXPECTED(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (EXPECTED(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (UNEXPECTED(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (EXPECTED(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } definition = definition_param; ZEPHIR_OBS_VAR(columns); if (!(zephir_array_isset_string_fetch(&columns, definition, SS("columns"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The table must contain at least one column", "phalcon/db/adapter/pdo/postgresql.zep", 292); return; } if (!(zephir_fast_count_int(columns TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The table must contain at least one column", "phalcon/db/adapter/pdo/postgresql.zep", 296); return; } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&sql, _0, "createtable", NULL, 0, tableName, schemaName, definition); zephir_check_call_status(); ZEPHIR_INIT_VAR(queries); zephir_fast_explode_str(queries, SL(";"), sql, LONG_MAX TSRMLS_CC); if (zephir_fast_count_int(queries TSRMLS_CC) > 1) { /* try_start_1: */ ZEPHIR_CALL_METHOD(NULL, this_ptr, "begin", NULL, 0); zephir_check_call_status_or_jump(try_end_1); zephir_is_iterable(queries, &_2$$6, &_1$$6, 0, 0, "phalcon/db/adapter/pdo/postgresql.zep", 312); for ( ; zend_hash_get_current_data_ex(_2$$6, (void**) &_3$$6, &_1$$6) == SUCCESS ; zend_hash_move_forward_ex(_2$$6, &_1$$6) ) { ZEPHIR_GET_HVALUE(query, _3$$6); if (ZEPHIR_IS_EMPTY(query)) { continue; } ZEPHIR_INIT_LNVAR(_4$$7); ZEPHIR_CONCAT_VS(_4$$7, query, ";"); ZEPHIR_CALL_METHOD(NULL, this_ptr, "query", &_5, 0, _4$$7); zephir_check_call_status_or_jump(try_end_1); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "commit", NULL, 0); zephir_check_call_status_or_jump(try_end_1); RETURN_MM(); try_end_1: if (EG(exception)) { ZEPHIR_INIT_VAR(_6$$5); ZEPHIR_CPY_WRT(_6$$5, EG(exception)); if (zephir_instance_of_ev(_6$$5, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) { zend_clear_exception(TSRMLS_C); ZEPHIR_CPY_WRT(exception, _6$$5); ZEPHIR_CALL_METHOD(NULL, this_ptr, "rollback", NULL, 0); zephir_check_call_status(); zephir_throw_exception_debug(exception, "phalcon/db/adapter/pdo/postgresql.zep", 316 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } } else { zephir_array_fetch_long(&_7$$10, queries, 0, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 319 TSRMLS_CC); ZEPHIR_INIT_VAR(_8$$10); ZEPHIR_CONCAT_VS(_8$$10, _7$$10, ";"); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, _8$$10); zephir_check_call_status(); RETURN_MM(); } RETURN_MM_BOOL(1); }
/** * Adds an INNER join to the query * *<code> * $criteria->join("Robots"); * $criteria->join("Robots", "r.id = RobotsParts.robots_id"); * $criteria->join("Robots", "r.id = RobotsParts.robots_id", "r"); * $criteria->join("Robots", "r.id = RobotsParts.robots_id", "r", "LEFT"); *</code> */ PHP_METHOD(Phalcon_Mvc_Model_Criteria, join) { zval *_1$$4; zval *model_param = NULL, *conditions = NULL, *alias = NULL, *type = NULL, *join = NULL, *mergedJoins = NULL, *currentJoins = NULL, *_0, *_2; zval *model = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 3, &model_param, &conditions, &alias, &type); if (unlikely(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(model_param) == IS_STRING)) { zephir_get_strval(model, model_param); } else { ZEPHIR_INIT_VAR(model); ZVAL_EMPTY_STRING(model); } if (!conditions) { conditions = ZEPHIR_GLOBAL(global_null); } if (!alias) { alias = ZEPHIR_GLOBAL(global_null); } if (!type) { type = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(join); zephir_create_array(join, 4, 0 TSRMLS_CC); zephir_array_fast_append(join, model); zephir_array_fast_append(join, conditions); zephir_array_fast_append(join, alias); zephir_array_fast_append(join, type); ZEPHIR_OBS_VAR(currentJoins); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_params"), PH_NOISY_CC); if (zephir_array_isset_string_fetch(¤tJoins, _0, SS("joins"), 0 TSRMLS_CC)) { if (Z_TYPE_P(currentJoins) == IS_ARRAY) { ZEPHIR_INIT_VAR(_1$$4); zephir_create_array(_1$$4, 1, 0 TSRMLS_CC); zephir_array_fast_append(_1$$4, join); ZEPHIR_INIT_VAR(mergedJoins); zephir_fast_array_merge(mergedJoins, &(currentJoins), &(_1$$4) TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(mergedJoins); zephir_create_array(mergedJoins, 1, 0 TSRMLS_CC); zephir_array_fast_append(mergedJoins, join); } } else { ZEPHIR_INIT_NVAR(mergedJoins); zephir_create_array(mergedJoins, 1, 0 TSRMLS_CC); zephir_array_fast_append(mergedJoins, join); } ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "joins", 1); zephir_update_property_array(this_ptr, SL("_params"), _2, mergedJoins TSRMLS_CC); RETURN_THIS(); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_File, validate) { zend_bool _2, _3, _4, _6, _7, _16, _17, _18, _20, _21, _23, _30, _31, _62, _69$$21, _77$$26; zephir_fcall_cache_entry *_12 = NULL, *_14 = NULL, *_43 = 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, *_15 = NULL, *_19, *_22, *_24, *_25 = NULL, *_36 = NULL, *_53 = NULL, *_61 = NULL, *_63 = NULL, *_9$$4 = NULL, *_11$$4 = NULL, *_13$$4, *_10$$5, *_26$$7 = NULL, *_28$$7 = NULL, *_29$$7, *_27$$8, *_32$$9 = NULL, *_34$$9 = NULL, *_35$$9, *_33$$10, *_37$$11 = NULL, *_38$$11, *_39$$11, *_40$$11, *_41$$11, *_42$$11 = NULL, *_44$$11, *_45$$11, _46$$11, *_47$$11, *_48$$11 = NULL, *_49$$13 = NULL, *_51$$13 = NULL, *_52$$13, *_50$$14, *_54$$15, _55$$17, *_56$$17, *_57$$19 = NULL, *_59$$19 = NULL, *_60$$19, *_58$$20, *_64$$21, *_65$$21 = NULL, *_66$$21 = NULL, *_74$$21 = NULL, *_67$$22 = NULL, *_68$$22, *_70$$24 = NULL, *_71$$24 = NULL, *_73$$24, *_72$$25, *_75$$26 = NULL, *_76$$26, *_78$$27 = NULL, *_79$$27 = NULL, *_81$$27, *_80$$28; 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, 55, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_13$$4); ZVAL_STRING(_13$$4, "FileIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _9$$4, "__construct", &_14, 434, _11$$4, field, _13$$4); zephir_check_temp_parameter(_13$$4); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _9$$4); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_15, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _16 = zephir_is_true(_15); if (_16) { _17 = ZEPHIR_IS_EMPTY(value); if (!(_17)) { _18 = zephir_array_isset_string(value, SS("error")); if (_18) { zephir_array_fetch_string(&_19, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 75 TSRMLS_CC); _18 = ZEPHIR_IS_LONG_IDENTICAL(_19, 4); } _17 = _18; } _16 = _17; } if (_16) { RETURN_MM_BOOL(1); } _20 = !(zephir_array_isset_string(value, SS("error"))); if (!(_20)) { _20 = !(zephir_array_isset_string(value, SS("tmp_name"))); } _21 = _20; if (!(_21)) { zephir_array_fetch_string(&_22, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 79 TSRMLS_CC); _21 = !ZEPHIR_IS_LONG_IDENTICAL(_22, 0); } _23 = _21; if (!(_23)) { zephir_array_fetch_string(&_24, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 79 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_25, "is_uploaded_file", NULL, 229, _24); zephir_check_call_status(); _23 = !zephir_is_true(_25); } if (_23) { ZEPHIR_INIT_VAR(_26$$7); ZVAL_STRING(_26$$7, "messageEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _26$$7); zephir_check_temp_parameter(_26$$7); 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(_27$$8); ZVAL_STRING(_27$$8, "FileEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _27$$8); zephir_check_temp_parameter(_27$$8); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_26$$7); object_init_ex(_26$$7, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_28$$7, "strtr", &_12, 55, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_29$$7); ZVAL_STRING(_29$$7, "FileEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _26$$7, "__construct", &_14, 434, _28$$7, field, _29$$7); zephir_check_temp_parameter(_29$$7); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _26$$7); zephir_check_call_status(); RETURN_MM_BOOL(0); } _30 = !(zephir_array_isset_string(value, SS("name"))); if (!(_30)) { _30 = !(zephir_array_isset_string(value, SS("type"))); } _31 = _30; if (!(_31)) { _31 = !(zephir_array_isset_string(value, SS("size"))); } if (_31) { ZEPHIR_INIT_VAR(_32$$9); ZVAL_STRING(_32$$9, "messageValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _32$$9); zephir_check_temp_parameter(_32$$9); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_33$$10); ZVAL_STRING(_33$$10, "FileValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _33$$10); zephir_check_temp_parameter(_33$$10); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_32$$9); object_init_ex(_32$$9, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_34$$9, "strtr", &_12, 55, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_35$$9); ZVAL_STRING(_35$$9, "FileValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _32$$9, "__construct", &_14, 434, _34$$9, field, _35$$9); zephir_check_temp_parameter(_35$$9); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _32$$9); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "maxSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_36, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (zephir_is_true(_36)) { ZEPHIR_INIT_VAR(byteUnits); zephir_create_array(byteUnits, 9, 0 TSRMLS_CC); add_assoc_long_ex(byteUnits, SS("B"), 0); add_assoc_long_ex(byteUnits, SS("K"), 10); add_assoc_long_ex(byteUnits, SS("M"), 20); add_assoc_long_ex(byteUnits, SS("G"), 30); add_assoc_long_ex(byteUnits, SS("T"), 40); add_assoc_long_ex(byteUnits, SS("KB"), 10); add_assoc_long_ex(byteUnits, SS("MB"), 20); add_assoc_long_ex(byteUnits, SS("GB"), 30); add_assoc_long_ex(byteUnits, SS("TB"), 40); ZEPHIR_INIT_VAR(_37$$11); ZVAL_STRING(_37$$11, "maxSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&maxSize, this_ptr, "getoption", NULL, 0, _37$$11); zephir_check_temp_parameter(_37$$11); zephir_check_call_status(); ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); ZEPHIR_INIT_VAR(unit); ZVAL_STRING(unit, "B", 1); ZEPHIR_INIT_NVAR(_37$$11); ZEPHIR_INIT_VAR(_38$$11); ZEPHIR_INIT_VAR(_39$$11); zephir_array_keys(_39$$11, byteUnits TSRMLS_CC); zephir_fast_join_str(_38$$11, SL("|"), _39$$11 TSRMLS_CC); ZEPHIR_INIT_VAR(_40$$11); ZEPHIR_CONCAT_SVS(_40$$11, "/^([0-9]+(?:\\.[0-9]+)?)(", _38$$11, ")?$/Di"); zephir_preg_match(_37$$11, _40$$11, maxSize, matches, 0, 0 , 0 TSRMLS_CC); if (zephir_array_isset_long(matches, 2)) { ZEPHIR_OBS_NVAR(unit); zephir_array_fetch_long(&unit, matches, 2, PH_NOISY, "phalcon/validation/validator/file.zep", 115 TSRMLS_CC); } zephir_array_fetch_long(&_41$$11, matches, 1, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 118 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_42$$11, "floatval", &_43, 301, _41$$11); zephir_check_call_status(); ZEPHIR_INIT_VAR(_44$$11); zephir_array_fetch(&_45$$11, byteUnits, unit, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 118 TSRMLS_CC); ZEPHIR_SINIT_VAR(_46$$11); ZVAL_LONG(&_46$$11, 2); zephir_pow_function(_44$$11, &_46$$11, _45$$11); ZEPHIR_INIT_VAR(bytes); mul_function(bytes, _42$$11, _44$$11 TSRMLS_CC); zephir_array_fetch_string(&_47$$11, value, SL("size"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 120 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_42$$11, "floatval", &_43, 301, _47$$11); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_48$$11, "floatval", &_43, 301, bytes); zephir_check_call_status(); if (ZEPHIR_GT(_42$$11, _48$$11)) { ZEPHIR_INIT_VAR(_49$$13); ZVAL_STRING(_49$$13, "messageSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _49$$13); zephir_check_temp_parameter(_49$$13); 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(_50$$14); ZVAL_STRING(_50$$14, "FileSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _50$$14); zephir_check_temp_parameter(_50$$14); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_49$$13); object_init_ex(_49$$13, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_51$$13, "strtr", &_12, 55, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_52$$13); ZVAL_STRING(_52$$13, "FileSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _49$$13, "__construct", &_14, 434, _51$$13, field, _52$$13); zephir_check_temp_parameter(_52$$13); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _49$$13); zephir_check_call_status(); RETURN_MM_BOOL(0); } } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_53, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (zephir_is_true(_53)) { ZEPHIR_INIT_VAR(_54$$15); ZVAL_STRING(_54$$15, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&types, this_ptr, "getoption", NULL, 0, _54$$15); zephir_check_temp_parameter(_54$$15); zephir_check_call_status(); if (Z_TYPE_P(types) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Option 'allowedTypes' must be an array", "phalcon/validation/validator/file.zep", 138); return; } if ((zephir_function_exists_ex(SS("finfo_open") TSRMLS_CC) == SUCCESS)) { ZEPHIR_SINIT_VAR(_55$$17); ZVAL_LONG(&_55$$17, 16); ZEPHIR_CALL_FUNCTION(&tmp, "finfo_open", NULL, 226, &_55$$17); zephir_check_call_status(); zephir_array_fetch_string(&_56$$17, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 143 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&mime, "finfo_file", NULL, 227, tmp, _56$$17); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(NULL, "finfo_close", NULL, 228, tmp); zephir_check_call_status(); } else { ZEPHIR_OBS_NVAR(mime); zephir_array_fetch_string(&mime, value, SL("type"), PH_NOISY, "phalcon/validation/validator/file.zep", 147 TSRMLS_CC); } if (!(zephir_fast_in_array(mime, types TSRMLS_CC))) { ZEPHIR_INIT_VAR(_57$$19); ZVAL_STRING(_57$$19, "messageType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _57$$19); zephir_check_temp_parameter(_57$$19); 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(_57$$19); zephir_fast_join_str(_57$$19, SL(", "), types TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":types"), &_57$$19, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_58$$20); ZVAL_STRING(_58$$20, "FileType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _58$$20); zephir_check_temp_parameter(_58$$20); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_57$$19); object_init_ex(_57$$19, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_59$$19, "strtr", &_12, 55, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_60$$19); ZVAL_STRING(_60$$19, "FileType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _57$$19, "__construct", &_14, 434, _59$$19, field, _60$$19); zephir_check_temp_parameter(_60$$19); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _57$$19); 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, "issetoption", 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, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _62 = zephir_is_true(_63); } if (_62) { zephir_array_fetch_string(&_64$$21, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 164 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&tmp, "getimagesize", NULL, 237, _64$$21); zephir_check_call_status(); ZEPHIR_OBS_VAR(width); zephir_array_fetch_long(&width, tmp, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 165 TSRMLS_CC); ZEPHIR_OBS_VAR(height); zephir_array_fetch_long(&height, tmp, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 166 TSRMLS_CC); ZEPHIR_INIT_VAR(_66$$21); ZVAL_STRING(_66$$21, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_65$$21, this_ptr, "issetoption", NULL, 0, _66$$21); zephir_check_temp_parameter(_66$$21); zephir_check_call_status(); if (zephir_is_true(_65$$21)) { ZEPHIR_INIT_VAR(_68$$22); ZVAL_STRING(_68$$22, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_67$$22, this_ptr, "getoption", NULL, 0, _68$$22); zephir_check_temp_parameter(_68$$22); zephir_check_call_status(); ZEPHIR_INIT_VAR(minResolution); zephir_fast_explode_str(minResolution, SL("x"), _67$$22, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(minWidth); zephir_array_fetch_long(&minWidth, minResolution, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 170 TSRMLS_CC); ZEPHIR_OBS_VAR(minHeight); zephir_array_fetch_long(&minHeight, minResolution, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 171 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(minWidth); ZVAL_LONG(minWidth, 1); ZEPHIR_INIT_NVAR(minHeight); ZVAL_LONG(minHeight, 1); } _69$$21 = ZEPHIR_LT(width, minWidth); if (!(_69$$21)) { _69$$21 = ZEPHIR_LT(height, minHeight); } if (_69$$21) { ZEPHIR_INIT_VAR(_70$$24); ZVAL_STRING(_70$$24, "messageMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _70$$24); zephir_check_temp_parameter(_70$$24); 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$$24); ZVAL_STRING(_70$$24, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_71$$24, this_ptr, "getoption", NULL, 0, _70$$24); zephir_check_temp_parameter(_70$$24); zephir_check_call_status(); zephir_array_update_string(&replacePairs, SL(":min"), &_71$$24, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_72$$25); ZVAL_STRING(_72$$25, "FileMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _72$$25); zephir_check_temp_parameter(_72$$25); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_70$$24); object_init_ex(_70$$24, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_71$$24, "strtr", &_12, 55, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_73$$24); ZVAL_STRING(_73$$24, "FileMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _70$$24, "__construct", &_14, 434, _71$$24, field, _73$$24); zephir_check_temp_parameter(_73$$24); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _70$$24); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_66$$21); ZVAL_STRING(_66$$21, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_74$$21, this_ptr, "issetoption", NULL, 0, _66$$21); zephir_check_temp_parameter(_66$$21); zephir_check_call_status(); if (zephir_is_true(_74$$21)) { ZEPHIR_INIT_VAR(_76$$26); ZVAL_STRING(_76$$26, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_75$$26, this_ptr, "getoption", NULL, 0, _76$$26); zephir_check_temp_parameter(_76$$26); zephir_check_call_status(); ZEPHIR_INIT_VAR(maxResolution); zephir_fast_explode_str(maxResolution, SL("x"), _75$$26, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(maxWidth); zephir_array_fetch_long(&maxWidth, maxResolution, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 192 TSRMLS_CC); ZEPHIR_OBS_VAR(maxHeight); zephir_array_fetch_long(&maxHeight, maxResolution, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 193 TSRMLS_CC); _77$$26 = ZEPHIR_GT(width, maxWidth); if (!(_77$$26)) { _77$$26 = ZEPHIR_GT(height, maxHeight); } if (_77$$26) { ZEPHIR_INIT_VAR(_78$$27); ZVAL_STRING(_78$$27, "messageMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _78$$27); zephir_check_temp_parameter(_78$$27); 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(_78$$27); ZVAL_STRING(_78$$27, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_79$$27, this_ptr, "getoption", NULL, 0, _78$$27); zephir_check_temp_parameter(_78$$27); zephir_check_call_status(); zephir_array_update_string(&replacePairs, SL(":max"), &_79$$27, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_80$$28); ZVAL_STRING(_80$$28, "FileMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _80$$28); zephir_check_temp_parameter(_80$$28); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_78$$27); object_init_ex(_78$$27, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_79$$27, "strtr", &_12, 55, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_81$$27); ZVAL_STRING(_81$$27, "FileMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _78$$27, "__construct", &_14, 434, _79$$27, field, _81$$27); zephir_check_temp_parameter(_81$$27); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _78$$27); zephir_check_call_status(); RETURN_MM_BOOL(0); } } } RETURN_MM_BOOL(1); }
/** * Sets the conditions parameter in the criteria */ PHP_METHOD(Phalcon_Mvc_Model_Criteria, where) { zval *conditions_param = NULL, *bindParams = NULL, *bindTypes = NULL, *currentBindParams = NULL, *currentBindTypes = NULL, *_0, *_1$$3, *_2$$4, *_3$$4, *_4$$5, *_5$$6, *_6$$7, *_7$$7, *_8$$8; zval *conditions = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams, &bindTypes); if (unlikely(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(conditions_param) == IS_STRING)) { zephir_get_strval(conditions, conditions_param); } else { ZEPHIR_INIT_VAR(conditions); ZVAL_EMPTY_STRING(conditions); } if (!bindParams) { bindParams = ZEPHIR_GLOBAL(global_null); } if (!bindTypes) { bindTypes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "conditions", 1); zephir_update_property_array(this_ptr, SL("_params"), _0, conditions TSRMLS_CC); if (Z_TYPE_P(bindParams) == IS_ARRAY) { ZEPHIR_OBS_VAR(currentBindParams); _1$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_params"), PH_NOISY_CC); if (zephir_array_isset_string_fetch(¤tBindParams, _1$$3, SS("bind"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(_2$$4); zephir_fast_array_merge(_2$$4, &(currentBindParams), &(bindParams) TSRMLS_CC); ZEPHIR_INIT_VAR(_3$$4); ZVAL_STRING(_3$$4, "bind", 1); zephir_update_property_array(this_ptr, SL("_params"), _3$$4, _2$$4 TSRMLS_CC); } else { ZEPHIR_INIT_VAR(_4$$5); ZVAL_STRING(_4$$5, "bind", 1); zephir_update_property_array(this_ptr, SL("_params"), _4$$5, bindParams TSRMLS_CC); } } if (Z_TYPE_P(bindTypes) == IS_ARRAY) { ZEPHIR_OBS_VAR(currentBindTypes); _5$$6 = zephir_fetch_nproperty_this(this_ptr, SL("_params"), PH_NOISY_CC); if (zephir_array_isset_string_fetch(¤tBindTypes, _5$$6, SS("bindTypes"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(_6$$7); zephir_fast_array_merge(_6$$7, &(currentBindTypes), &(bindTypes) TSRMLS_CC); ZEPHIR_INIT_VAR(_7$$7); ZVAL_STRING(_7$$7, "bindTypes", 1); zephir_update_property_array(this_ptr, SL("_params"), _7$$7, _6$$7 TSRMLS_CC); } else { ZEPHIR_INIT_VAR(_8$$8); ZVAL_STRING(_8$$8, "bindTypes", 1); zephir_update_property_array(this_ptr, SL("_params"), _8$$8, bindTypes TSRMLS_CC); } } RETURN_THIS(); }
/* * unvis - decode characters previously encoded by vis */ int unvis(char *cp, int c, int *astate, int flag) { unsigned char uc = (unsigned char)c; unsigned char st, ia, is, lc; /* * Bottom 8 bits of astate hold the state machine state. * Top 8 bits hold the current character in the http 1866 nv string decoding */ #define GS(a) ((a) & 0xff) #define SS(a, b) (((uint32_t)(a) << 24) | (b)) #define GI(a) ((uint32_t)(a) >> 24) _DIAGASSERT(cp != NULL); _DIAGASSERT(astate != NULL); st = GS(*astate); if (flag & UNVIS_END) { switch (st) { case S_OCTAL2: case S_OCTAL3: case S_HEX2: *astate = SS(0, S_GROUND); return UNVIS_VALID; case S_GROUND: return UNVIS_NOCHAR; default: return UNVIS_SYNBAD; } } switch (st) { case S_GROUND: *cp = 0; if ((flag & VIS_NOESCAPE) == 0 && c == '\\') { *astate = SS(0, S_START); return UNVIS_NOCHAR; } if ((flag & VIS_HTTP1808) && c == '%') { *astate = SS(0, S_HEX1); return UNVIS_NOCHAR; } if ((flag & VIS_HTTP1866) && c == '&') { *astate = SS(0, S_AMP); return UNVIS_NOCHAR; } if ((flag & VIS_MIMESTYLE) && c == '=') { *astate = SS(0, S_MIME1); return UNVIS_NOCHAR; } *cp = c; return UNVIS_VALID; case S_START: switch(c) { case '\\': *cp = c; *astate = SS(0, S_GROUND); return UNVIS_VALID; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': *cp = (c - '0'); *astate = SS(0, S_OCTAL2); return UNVIS_NOCHAR; case 'M': *cp = (char)0200; *astate = SS(0, S_META); return UNVIS_NOCHAR; case '^': *astate = SS(0, S_CTRL); return UNVIS_NOCHAR; case 'n': *cp = '\n'; *astate = SS(0, S_GROUND); return UNVIS_VALID; case 'r': *cp = '\r'; *astate = SS(0, S_GROUND); return UNVIS_VALID; case 'b': *cp = '\b'; *astate = SS(0, S_GROUND); return UNVIS_VALID; case 'a': *cp = '\007'; *astate = SS(0, S_GROUND); return UNVIS_VALID; case 'v': *cp = '\v'; *astate = SS(0, S_GROUND); return UNVIS_VALID; case 't': *cp = '\t'; *astate = SS(0, S_GROUND); return UNVIS_VALID; case 'f': *cp = '\f'; *astate = SS(0, S_GROUND); return UNVIS_VALID; case 's': *cp = ' '; *astate = SS(0, S_GROUND); return UNVIS_VALID; case 'E': *cp = '\033'; *astate = SS(0, S_GROUND); return UNVIS_VALID; case '\n': /* * hidden newline */ *astate = SS(0, S_GROUND); return UNVIS_NOCHAR; case '$': /* * hidden marker */ *astate = SS(0, S_GROUND); return UNVIS_NOCHAR; } goto bad; case S_META: if (c == '-') *astate = SS(0, S_META1); else if (c == '^') *astate = SS(0, S_CTRL); else goto bad; return UNVIS_NOCHAR; case S_META1: *astate = SS(0, S_GROUND); *cp |= c; return UNVIS_VALID; case S_CTRL: if (c == '?') *cp |= 0177; else *cp |= c & 037; *astate = SS(0, S_GROUND); return UNVIS_VALID; case S_OCTAL2: /* second possible octal digit */ if (isoctal(uc)) { /* * yes - and maybe a third */ *cp = (*cp << 3) + (c - '0'); *astate = SS(0, S_OCTAL3); return UNVIS_NOCHAR; } /* * no - done with current sequence, push back passed char */ *astate = SS(0, S_GROUND); return UNVIS_VALIDPUSH; case S_OCTAL3: /* third possible octal digit */ *astate = SS(0, S_GROUND); if (isoctal(uc)) { *cp = (*cp << 3) + (c - '0'); return UNVIS_VALID; } /* * we were done, push back passed char */ return UNVIS_VALIDPUSH; case S_HEX1: if (isxdigit(uc)) { *cp = xtod(uc); *astate = SS(0, S_HEX2); return UNVIS_NOCHAR; } /* * no - done with current sequence, push back passed char */ *astate = SS(0, S_GROUND); return UNVIS_VALIDPUSH; case S_HEX2: *astate = S_GROUND; if (isxdigit(uc)) { *cp = xtod(uc) | (*cp << 4); return UNVIS_VALID; } return UNVIS_VALIDPUSH; case S_MIME1: if (uc == '\n' || uc == '\r') { *astate = SS(0, S_EATCRNL); return UNVIS_NOCHAR; } if (isxdigit(uc) && (isdigit(uc) || isupper(uc))) { *cp = XTOD(uc); *astate = SS(0, S_MIME2); return UNVIS_NOCHAR; } goto bad; case S_MIME2: if (isxdigit(uc) && (isdigit(uc) || isupper(uc))) { *astate = SS(0, S_GROUND); *cp = XTOD(uc) | (*cp << 4); return UNVIS_VALID; } goto bad; case S_EATCRNL: switch (uc) { case '\r': case '\n': return UNVIS_NOCHAR; case '=': *astate = SS(0, S_MIME1); return UNVIS_NOCHAR; default: *cp = uc; *astate = SS(0, S_GROUND); return UNVIS_VALID; } case S_AMP: *cp = 0; if (uc == '#') { *astate = SS(0, S_NUMBER); return UNVIS_NOCHAR; } *astate = SS(0, S_STRING); /*FALLTHROUGH*/ case S_STRING: ia = *cp; /* index in the array */ is = GI(*astate); /* index in the string */ lc = is == 0 ? 0 : nv[ia].name[is - 1]; /* last character */ if (uc == ';') uc = '\0'; for (; ia < __arraycount(nv); ia++) { if (is != 0 && nv[ia].name[is - 1] != lc) goto bad; if (nv[ia].name[is] == uc) break; } if (ia == __arraycount(nv)) goto bad; if (uc != 0) { *cp = ia; *astate = SS(is + 1, S_STRING); return UNVIS_NOCHAR; } *cp = nv[ia].value; *astate = SS(0, S_GROUND); return UNVIS_VALID; case S_NUMBER: if (uc == ';') return UNVIS_VALID; if (!isdigit(uc)) goto bad; *cp += (*cp * 10) + uc - '0'; return UNVIS_NOCHAR; default: bad: /* * decoder in unknown state - (probably uninitialized) */ *astate = SS(0, S_GROUND); return UNVIS_SYNBAD; } }
/** * Gets most possibly client IPv4 Address. This methods search in $_SERVER['REMOTE_ADDR'] and optionally in $_SERVER['HTTP_X_FORWARDED_FOR'] * * @param boolean $trustForwardedHeader * @return string */ PHP_METHOD(Phalcon_Http_Request, getClientAddress) { zval *trust_forwarded_header = NULL, *server = NULL, *address = NULL; zval *comma, *addresses, *first; zval *g0 = NULL; int eval_int; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &trust_forwarded_header) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } if (!trust_forwarded_header) { PHALCON_INIT_NVAR(trust_forwarded_header); ZVAL_BOOL(trust_forwarded_header, 0); } phalcon_get_global(&g0, SL("_SERVER")+1 TSRMLS_CC); PHALCON_CPY_WRT(server, g0); /** * Proxies uses this IP */ if (PHALCON_IS_TRUE(trust_forwarded_header)) { eval_int = phalcon_array_isset_string(server, SS("HTTP_X_FORWARDED_FOR")); if (eval_int) { PHALCON_INIT_VAR(address); phalcon_array_fetch_string(&address, server, SL("HTTP_X_FORWARDED_FOR"), PH_NOISY_CC); RETURN_CCTOR(address); } } eval_int = phalcon_array_isset_string(server, SS("REMOTE_ADDR")); if (eval_int) { PHALCON_INIT_NVAR(address); phalcon_array_fetch_string(&address, server, SL("REMOTE_ADDR"), PH_NOISY_CC); if (phalcon_memnstr_str(address, SL(",") TSRMLS_CC)) { /** * The client address has multiples parts, only return the first part */ PHALCON_INIT_VAR(comma); ZVAL_STRING(comma, ",", 1); PHALCON_INIT_VAR(addresses); phalcon_fast_explode(addresses, comma, address TSRMLS_CC); PHALCON_INIT_VAR(first); phalcon_array_fetch_long(&first, addresses, 0, PH_NOISY_CC); RETURN_CCTOR(first); } RETURN_CCTOR(address); } PHALCON_MM_RESTORE(); RETURN_FALSE; }
/** * Generates an unique auth code. * * Implementing classes may want to override this function to implement * other auth code generation schemes. * * @return string An unique auth code. * * @ingroup oauth2_section_4 */ PHP_METHOD(OAuth2_ResponseType_AuthorizationCode, generateAuthorizationCode) { zephir_nts_static zephir_fcall_cache_entry *_6 = NULL, *_8 = NULL, *_10 = NULL, *_13 = NULL, *_16 = NULL; int tokenLen, ZEPHIR_LAST_CALL_STATUS; zval *randomData = NULL, _0, _1 = zval_used_for_init, _2 = zval_used_for_init, *_3, _4, *_5 = NULL, *_7 = NULL, *_9 = NULL, *_11 = NULL, *_12 = NULL, *_14 = NULL, *_15 = NULL; ZEPHIR_MM_GROW(); tokenLen = 40; ZEPHIR_SINIT_VAR(_0); ZVAL_STRING(&_0, "/dev/urandom", 0); if ((zephir_function_exists_ex(SS("mcrypt_create_iv") TSRMLS_CC) == SUCCESS)) { ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, 100); ZEPHIR_SINIT_VAR(_2); ZVAL_LONG(&_2, 1); ZEPHIR_CALL_FUNCTION(&randomData, "mcrypt_create_iv", NULL, &_1, &_2); zephir_check_call_status(); } else if ((zephir_function_exists_ex(SS("openssl_random_pseudo_bytes") TSRMLS_CC) == SUCCESS)) { ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 100); ZEPHIR_CALL_FUNCTION(&randomData, "openssl_random_pseudo_bytes", NULL, _3); zephir_check_call_status(); } else if ((zephir_file_exists(&_0 TSRMLS_CC) == SUCCESS)) { ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "/dev/urandom", 0); ZEPHIR_SINIT_NVAR(_2); ZVAL_LONG(&_2, 0); ZEPHIR_SINIT_VAR(_4); ZVAL_LONG(&_4, 100); ZEPHIR_CALL_FUNCTION(&_5, "file_get_contents", &_6, &_1, ZEPHIR_GLOBAL(global_false), ZEPHIR_GLOBAL(global_null), &_2, &_4); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_7, "mt_rand", &_8); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_9, "uniqid", &_10, _7, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); ZEPHIR_INIT_NVAR(randomData); ZEPHIR_CONCAT_VV(randomData, _5, _9); } else { ZEPHIR_CALL_FUNCTION(&_5, "mt_rand", &_8); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_7, "mt_rand", &_8); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_9, "mt_rand", &_8); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_11, "mt_rand", &_8); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_12, "microtime", &_13, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_14, "mt_rand", &_8); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_15, "uniqid", &_10, _14, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); ZEPHIR_INIT_NVAR(randomData); ZEPHIR_CONCAT_VVVVVV(randomData, _5, _7, _9, _11, _12, _15); } ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "sha512", 0); ZEPHIR_CALL_FUNCTION(&_5, "hash", NULL, &_1, randomData); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, 0); ZEPHIR_SINIT_NVAR(_2); ZVAL_LONG(&_2, tokenLen); ZEPHIR_RETURN_CALL_FUNCTION("substr", &_16, _5, &_1, &_2); zephir_check_call_status(); RETURN_MM(); }
/** * Returns a cached content * * @param int|string $keyName * @param long $lifetime * @return mixed */ PHP_METHOD(Phalcon_Cache_Backend_File, get){ zval *key_name, *lifetime = NULL; zval *options, *prefix, *prefixed_key, *cache_dir; zval *cache_file, *tmp = NULL; zval *modified_time; zval *cached_content, *exception_message; long int now, ttl, mtime, diff; int expired; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 1, &key_name, &lifetime); options = phalcon_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY TSRMLS_CC); prefix = phalcon_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY TSRMLS_CC); PHALCON_INIT_VAR(prefixed_key); PHALCON_CONCAT_VV(prefixed_key, prefix, key_name); phalcon_update_property_this(this_ptr, SL("_lastKey"), prefixed_key TSRMLS_CC); if (unlikely(!phalcon_array_isset_string_fetch(&cache_dir, options, SS("cacheDir")))) { PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options"); return; } PHALCON_INIT_VAR(cache_file); PHALCON_CONCAT_VV(cache_file, cache_dir, prefixed_key); if (phalcon_file_exists(cache_file TSRMLS_CC) == SUCCESS) { zval *frontend = phalcon_fetch_nproperty_this(this_ptr, SL("_frontend"), PH_NOISY TSRMLS_CC); /** * Check if the file has expired */ now = (long int)time(NULL); /** * Take the lifetime from the frontend or read it from the set in start() */ if (!lifetime || Z_TYPE_P(lifetime) == IS_NULL) { zval *last_lifetime = phalcon_fetch_nproperty_this(this_ptr, SL("_lastLifetime"), PH_NOISY TSRMLS_CC); if (Z_TYPE_P(last_lifetime) == IS_NULL) { PHALCON_CALL_METHOD(&tmp, frontend, "getlifetime"); ttl = phalcon_get_intval(tmp); } else { ttl = phalcon_get_intval(last_lifetime); } } else { ttl = phalcon_get_intval(lifetime); } PHALCON_INIT_VAR(modified_time); phalcon_filemtime(modified_time, cache_file TSRMLS_CC); if (unlikely(Z_TYPE_P(modified_time) != IS_LONG)) { convert_to_long(modified_time); } mtime = Z_LVAL_P(modified_time); diff = now - ttl; expired = diff > mtime; /** * The content is only retrieved if the content has not expired */ if (!expired) { /** * Use file-get-contents to control that the openbase_dir can't be skipped */ PHALCON_INIT_VAR(cached_content); phalcon_file_get_contents(cached_content, cache_file TSRMLS_CC); if (PHALCON_IS_FALSE(cached_content)) { PHALCON_INIT_VAR(exception_message); PHALCON_CONCAT_SVS(exception_message, "Cache file ", cache_file, " could not be opened"); PHALCON_THROW_EXCEPTION_ZVAL(phalcon_cache_exception_ce, exception_message); return; } if (phalcon_is_numeric(cached_content)) { RETURN_CCTOR(cached_content); } else { /** * Use the frontend to process the content of the cache */ PHALCON_RETURN_CALL_METHOD(frontend, "afterretrieve", cached_content); } RETURN_MM(); } } RETURN_MM_NULL(); }
/** * Restores the internal state of a Phalcon\Db\Column object * * @param array $data * @return \Phalcon\Db\Column */ PHP_METHOD(Phalcon_Db_Column, __set_state){ zval *data, *definition, *column_name, *column_type; zval *not_null, *primary, *size, *dunsigned, *after; zval *is_numeric, *first, *bind_type; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 0, &data); if (Z_TYPE_P(data) != IS_ARRAY) { PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Column state must be an array"); return; } PHALCON_INIT_VAR(definition); array_init(definition); if (!phalcon_array_isset_string(data, SS("_columnName"))) { PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Column name is required"); return; } PHALCON_OBS_VAR(column_name); phalcon_array_fetch_string(&column_name, data, SL("_columnName"), PH_NOISY); if (phalcon_array_isset_string(data, SS("_type"))) { PHALCON_OBS_VAR(column_type); phalcon_array_fetch_string(&column_type, data, SL("_type"), PH_NOISY); phalcon_array_update_string(&definition, SL("type"), &column_type, PH_COPY | PH_SEPARATE); } if (phalcon_array_isset_string(data, SS("_notNull"))) { PHALCON_OBS_VAR(not_null); phalcon_array_fetch_string(¬_null, data, SL("_notNull"), PH_NOISY); phalcon_array_update_string(&definition, SL("notNull"), ¬_null, PH_COPY | PH_SEPARATE); } if (phalcon_array_isset_string(data, SS("_primary"))) { PHALCON_OBS_VAR(primary); phalcon_array_fetch_string(&primary, data, SL("_primary"), PH_NOISY); phalcon_array_update_string(&definition, SL("primary"), &primary, PH_COPY | PH_SEPARATE); } if (phalcon_array_isset_string(data, SS("_size"))) { PHALCON_OBS_VAR(size); phalcon_array_fetch_string(&size, data, SL("_size"), PH_NOISY); phalcon_array_update_string(&definition, SL("size"), &size, PH_COPY | PH_SEPARATE); } if (phalcon_array_isset_string(data, SS("_unsigned"))) { PHALCON_OBS_VAR(dunsigned); phalcon_array_fetch_string(&dunsigned, data, SL("_unsigned"), PH_NOISY); phalcon_array_update_string(&definition, SL("unsigned"), &dunsigned, PH_COPY | PH_SEPARATE); } if (phalcon_array_isset_string(data, SS("_after"))) { PHALCON_OBS_VAR(after); phalcon_array_fetch_string(&after, data, SL("_after"), PH_NOISY); phalcon_array_update_string(&definition, SL("after"), &after, PH_COPY | PH_SEPARATE); } if (phalcon_array_isset_string(data, SS("_isNumeric"))) { PHALCON_OBS_VAR(is_numeric); phalcon_array_fetch_string(&is_numeric, data, SL("_isNumeric"), PH_NOISY); phalcon_array_update_string(&definition, SL("isNumeric"), &is_numeric, PH_COPY | PH_SEPARATE); } if (phalcon_array_isset_string(data, SS("_first"))) { PHALCON_OBS_VAR(first); phalcon_array_fetch_string(&first, data, SL("_first"), PH_NOISY); phalcon_array_update_string(&definition, SL("first"), &first, PH_COPY | PH_SEPARATE); } if (phalcon_array_isset_string(data, SS("_bindType"))) { PHALCON_OBS_VAR(bind_type); phalcon_array_fetch_string(&bind_type, data, SL("_bindType"), PH_NOISY); phalcon_array_update_string(&definition, SL("bindType"), &bind_type, PH_COPY | PH_SEPARATE); } object_init_ex(return_value, phalcon_db_column_ce); phalcon_call_method_p2_noret(return_value, "__construct", column_name, definition); RETURN_MM(); }
/** * Stores cached content into the file backend and stops the frontend * * @param int|string $keyName * @param string $content * @param long $lifetime * @param boolean $stopBuffer */ PHP_METHOD(Phalcon_Cache_Backend_File, save){ zval *key_name = NULL, *content = NULL, *lifetime = NULL, *stop_buffer = NULL; zval *cache_file, *cached_content = NULL, *prepared_content = NULL, *status, *is_buffering = NULL; zval *last_key, *frontend, *options, *cache_dir; PHALCON_MM_GROW(); phalcon_fetch_params(1, 0, 4, &key_name, &content, &lifetime, &stop_buffer); if (!key_name || Z_TYPE_P(key_name) == IS_NULL) { last_key = phalcon_fetch_nproperty_this(this_ptr, SL("_lastKey"), PH_NOISY TSRMLS_CC); } else { zval *prefix = phalcon_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY TSRMLS_CC); PHALCON_INIT_VAR(last_key); PHALCON_CONCAT_VV(last_key, prefix, key_name); } if (!zend_is_true(last_key)) { PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "The cache must be started first"); return; } frontend = phalcon_fetch_nproperty_this(this_ptr, SL("_frontend"), PH_NOISY TSRMLS_CC); options = phalcon_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY TSRMLS_CC); if (unlikely(!phalcon_array_isset_string_fetch(&cache_dir, options, SS("cacheDir")))) { PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options"); return; } PHALCON_INIT_VAR(cache_file); PHALCON_CONCAT_VV(cache_file, cache_dir, last_key); if (!content || !zend_is_true(content)) { PHALCON_CALL_METHOD(&cached_content, frontend, "getcontent"); } else { cached_content = content; } PHALCON_CALL_METHOD(&prepared_content, frontend, "beforestore", cached_content); /** * We use file_put_contents to respect open-base-dir directive */ PHALCON_INIT_VAR(status); if (!phalcon_is_numeric(cached_content)) { phalcon_file_put_contents(status, cache_file, prepared_content TSRMLS_CC); } else { phalcon_file_put_contents(status, cache_file, cached_content TSRMLS_CC); } if (PHALCON_IS_FALSE(status)) { PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "Cache directory is not writable"); return; } PHALCON_CALL_METHOD(&is_buffering, frontend, "isbuffering"); if (!stop_buffer || PHALCON_IS_TRUE(stop_buffer)) { PHALCON_CALL_METHOD(NULL, frontend, "stop"); } if (PHALCON_IS_TRUE(is_buffering)) { zend_print_zval(cached_content, 0); } phalcon_update_property_bool(this_ptr, SL("_started"), 0 TSRMLS_CC); PHALCON_MM_RESTORE(); }
/** * Gets a variable from the $_POST superglobal applying filters if needed * If no parameters are given the $_POST superglobal is returned * *<code> * //Returns value from $_POST["user_email"] without sanitizing * $userEmail = $request->getPost("user_email"); * * //Returns value from $_POST["user_email"] with sanitizing * $userEmail = $request->getPost("user_email", "email"); *</code> * * @param string $name * @param string|array $filters * @param mixed $defaultValue * @return mixed */ PHP_METHOD(Phalcon_Http_Request, getPost){ zval *name = NULL, *filters = NULL, *default_value = NULL, *post = NULL, *_POST; zval *value, *filter = NULL, *dependency_injector, *service; PHALCON_MM_GROW(); phalcon_fetch_params(1, 0, 3, &name, &filters, &default_value); if (!name) { PHALCON_INIT_VAR(name); } if (!filters) { PHALCON_INIT_VAR(filters); } if (!default_value) { PHALCON_INIT_VAR(default_value); } phalcon_get_global(&_POST, SS("_POST") TSRMLS_CC); PHALCON_CPY_WRT(post, _POST); if (Z_TYPE_P(name) != IS_NULL) { if (phalcon_array_isset(post, name)) { PHALCON_OBS_VAR(value); phalcon_array_fetch(&value, post, name, PH_NOISY); if (Z_TYPE_P(filters) != IS_NULL) { PHALCON_OBS_VAR(filter); phalcon_read_property_this(&filter, this_ptr, SL("_filter"), PH_NOISY_CC); if (Z_TYPE_P(filter) != IS_OBJECT) { PHALCON_OBS_VAR(dependency_injector); phalcon_read_property_this(&dependency_injector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependency_injector) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STR(phalcon_http_request_exception_ce, "A dependency injection object is required to access the 'filter' service"); return; } PHALCON_INIT_VAR(service); ZVAL_STRING(service, "filter", 1); PHALCON_INIT_NVAR(filter); phalcon_call_method_p1(filter, dependency_injector, "getshared", service); phalcon_update_property_this(this_ptr, SL("_filter"), filter TSRMLS_CC); } phalcon_call_method_p2(return_value, filter, "sanitize", value, filters); RETURN_MM(); } else { RETURN_CCTOR(value); } } RETURN_CCTOR(default_value); } RETURN_CCTOR(post); }
PHP_METHOD(PhalconPlus_Base_ModuleDef, __construct) { zephir_fcall_cache_entry *_4 = NULL, *_19 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zend_bool isPrimary; zval *moduleDir = NULL, *_2$$3; zval *boot, *moduleDir_param = NULL, *isPrimary_param = NULL, *_0 = NULL, *_3 = NULL, *_5, *_6 = NULL, *_7, *appConfig = NULL, *_8, *_9, *_10, *_11, *_12, *_13, *_14, *_15, *_16 = NULL, *_17, *_18 = NULL, *_20, *_21, *_22 = NULL, *_1$$3, *_23$$4, *_24$$4, *_25$$4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &boot, &moduleDir_param, &isPrimary_param); if (UNEXPECTED(Z_TYPE_P(moduleDir_param) != IS_STRING && Z_TYPE_P(moduleDir_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'moduleDir' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (EXPECTED(Z_TYPE_P(moduleDir_param) == IS_STRING)) { zephir_get_strval(moduleDir, moduleDir_param); } else { ZEPHIR_INIT_VAR(moduleDir); ZVAL_EMPTY_STRING(moduleDir); } if (!isPrimary_param) { isPrimary = 0; } else { isPrimary = zephir_get_boolval(isPrimary_param); } ZEPHIR_CALL_FUNCTION(&_0, "is_dir", NULL, 39, moduleDir); zephir_check_call_status(); if (!(zephir_is_true(_0))) { ZEPHIR_INIT_VAR(_1$$3); object_init_ex(_1$$3, zend_exception_get_default(TSRMLS_C)); ZEPHIR_INIT_VAR(_2$$3); ZEPHIR_CONCAT_SV(_2$$3, "Module directory not exists or not a dir, file positon: ", moduleDir); ZEPHIR_CALL_METHOD(NULL, _1$$3, "__construct", NULL, 7, _2$$3); zephir_check_call_status(); zephir_throw_exception_debug(_1$$3, "phalconplus/Base/ModuleDef.zep", 42 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } zephir_update_property_this(getThis(), SL("dir"), moduleDir TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&_3, phalconplus_enum_sys_ce, "getmoduleconfigpath", &_4, 40, moduleDir); zephir_check_call_status(); zephir_update_property_this(getThis(), SL("configPath"), _3 TSRMLS_CC); ZEPHIR_INIT_VAR(_5); object_init_ex(_5, zephir_get_internal_ce(SS("phalcon\\config") TSRMLS_CC)); _7 = zephir_fetch_nproperty_this(this_ptr, SL("configPath"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_6, boot, "load", NULL, 41, _7); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, _5, "__construct", NULL, 0, _6); zephir_check_call_status(); zephir_update_property_this(getThis(), SL("config"), _5 TSRMLS_CC); _8 = zephir_fetch_nproperty_this(this_ptr, SL("config"), PH_NOISY_CC); ZEPHIR_OBS_VAR(appConfig); zephir_read_property(&appConfig, _8, SL("application"), PH_NOISY_CC); ZEPHIR_OBS_VAR(_9); zephir_read_property(&_9, appConfig, SL("name"), PH_NOISY_CC); zephir_update_property_this(getThis(), SL("name"), _9 TSRMLS_CC); ZEPHIR_INIT_VAR(_10); object_init_ex(_10, phalconplus_enum_runmode_ce); ZEPHIR_INIT_VAR(_11); ZEPHIR_INIT_VAR(_12); ZEPHIR_OBS_VAR(_13); zephir_read_property(&_13, appConfig, SL("mode"), PH_NOISY_CC); zephir_fast_strtolower(_12, _13); zephir_ucfirst(_11, _12); ZEPHIR_CALL_METHOD(NULL, _10, "__construct", NULL, 42, _11); zephir_check_call_status(); zephir_update_property_this(getThis(), SL("runMode"), _10 TSRMLS_CC); ZEPHIR_OBS_VAR(_14); zephir_read_property(&_14, appConfig, SL("ns"), PH_NOISY_CC); _15 = zephir_fetch_nproperty_this(this_ptr, SL("runMode"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_16, _15, "getmapclassname", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_17); ZEPHIR_CONCAT_VV(_17, _14, _16); zephir_update_property_this(getThis(), SL("className"), _17 TSRMLS_CC); _20 = zephir_fetch_nproperty_this(this_ptr, SL("runMode"), PH_NOISY_CC); ZEPHIR_CALL_CE_STATIC(&_18, phalconplus_enum_sys_ce, "getmoduleclasspath", &_19, 43, moduleDir, _20); zephir_check_call_status(); zephir_update_property_this(getThis(), SL("classPath"), _18 TSRMLS_CC); _21 = zephir_fetch_nproperty_this(this_ptr, SL("classPath"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&_22, "is_file", NULL, 44, _21); zephir_check_call_status(); if (!(zephir_is_true(_22))) { ZEPHIR_INIT_VAR(_23$$4); object_init_ex(_23$$4, zend_exception_get_default(TSRMLS_C)); _24$$4 = zephir_fetch_nproperty_this(this_ptr, SL("classPath"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_25$$4); ZEPHIR_CONCAT_SV(_25$$4, "Module class file not exists: ", _24$$4); ZEPHIR_CALL_METHOD(NULL, _23$$4, "__construct", NULL, 7, _25$$4); zephir_check_call_status(); zephir_throw_exception_debug(_23$$4, "phalconplus/Base/ModuleDef.zep", 61 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (isPrimary) { zephir_update_property_this(getThis(), SL("isPrimary"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(getThis(), SL("isPrimary"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_MM_RESTORE(); }