/** * Returns a cached content * * @param string keyName * @param long lifetime * @return mixed */ PHP_METHOD(Phalcon_Cache_Backend_Memory, get) { int ZEPHIR_LAST_CALL_STATUS; zval *keyName, *lifetime = NULL, *lastKey = NULL, *cachedContent, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &keyName, &lifetime); if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(keyName) == IS_NULL) { 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_VV(lastKey, _0, keyName); zephir_update_property_this(this_ptr, SL("_lastKey"), lastKey TSRMLS_CC); } ZEPHIR_OBS_VAR(cachedContent); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&cachedContent, _0, lastKey, 0 TSRMLS_CC))) { RETURN_MM_NULL(); } if (Z_TYPE_P(cachedContent) == IS_NULL) { RETURN_MM_NULL(); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_frontend"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "afterretrieve", NULL, cachedContent); zephir_check_call_status(); RETURN_MM(); }
/** * Generates SQL to query indexes detail on a table */ PHP_METHOD(Phalcon_Db_Dialect_Sqlite, describeIndex) { zval *index_param = NULL; zval *index = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &index_param); if (unlikely(Z_TYPE_P(index_param) != IS_STRING && Z_TYPE_P(index_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'index' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(index_param) == IS_STRING)) { zephir_get_strval(index, index_param); } else { ZEPHIR_INIT_VAR(index); ZVAL_EMPTY_STRING(index); } ZEPHIR_CONCAT_SVS(return_value, "PRAGMA index_info('", index, "')"); RETURN_MM(); }
/** * Unserializes a value from a serialized string. * * @param string serializedData * * @return mixed */ PHP_METHOD(Xpl_Serializer_Json, unserialize) { zval *serializedData_param = NULL; zval *serializedData = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &serializedData_param); if (unlikely(Z_TYPE_P(serializedData_param) != IS_STRING && Z_TYPE_P(serializedData_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'serializedData' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(serializedData_param) == IS_STRING)) { zephir_get_strval(serializedData, serializedData_param); } else { ZEPHIR_INIT_VAR(serializedData); ZVAL_EMPTY_STRING(serializedData); } zephir_json_decode(return_value, &(return_value), serializedData, 0 TSRMLS_CC); RETURN_MM(); }
/** * Adds a number to a string or increment that number if it already is defined * *<code> * echo Phalcon\Text::increment("a"); // "a_1" * echo Phalcon\Text::increment("a_1"); // "a_2" *</code> * * @param string $str * @param string $separator * @return string */ PHP_METHOD(Phalcon_Text, increment){ zval *str, *separator = NULL, *parts, *number = NULL, *first_part; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 1, &str, &separator); if (!separator) { PHALCON_INIT_VAR(separator); } else { PHALCON_SEPARATE_PARAM(separator); } if (Z_TYPE_P(separator) == IS_NULL) { PHALCON_INIT_NVAR(separator); ZVAL_STRING(separator, "_", 1); } PHALCON_INIT_VAR(parts); phalcon_fast_explode(parts, separator, str); if (phalcon_array_isset_long(parts, 1)) { PHALCON_OBS_VAR(number); phalcon_array_fetch_long(&number, parts, 1, PH_NOISY); SEPARATE_ZVAL(&number); phalcon_increment(number); } else { number = PHALCON_GLOBAL(z_one); } PHALCON_OBS_VAR(first_part); phalcon_array_fetch_long(&first_part, parts, 0, PH_NOISY); PHALCON_CONCAT_VVV(return_value, first_part, separator, number); RETURN_MM(); }
PHP_METHOD(Test_Strings, uncamelize) { zval *str_param = NULL, *delimiter = NULL, delimiter_sub, __$null; zval str; zval *this_ptr = getThis(); ZVAL_UNDEF(&str); ZVAL_UNDEF(&delimiter_sub); ZVAL_NULL(&__$null); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &str_param, &delimiter); zephir_get_strval(&str, str_param); if (!delimiter) { delimiter = &delimiter_sub; delimiter = &__$null; } zephir_uncamelize(return_value, &str, delimiter ); RETURN_MM(); }
/** * Filters the content using JSMIN */ PHP_METHOD(Phalcon_Assets_Filters_Jsmin, filter) { zval *content_param = NULL; zval *content = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &content_param); if (unlikely(Z_TYPE_P(content_param) != IS_STRING && Z_TYPE_P(content_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'content' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(content_param) == IS_STRING)) { zephir_get_strval(content, content_param); } else { ZEPHIR_INIT_VAR(content); ZVAL_EMPTY_STRING(content); } phalcon_jsmin(return_value, content TSRMLS_CC); RETURN_MM(); }
/** * Returns an HTML string of information about a single variable. * * <code> * echo (new \Phalcon\Debug\Dump())->variable($foo, "foo"); * </code> */ PHP_METHOD(Phalcon_Debug_Dump, variable) { zval *_0; int ZEPHIR_LAST_CALL_STATUS; zval *name = NULL; zval *variable, *name_param = NULL, *_1 = NULL, *_2, _3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &variable, &name_param); if (!name_param) { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } else { zephir_get_strval(name, name_param); } ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 2, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "pre", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, this_ptr, "getstyle", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); zephir_array_update_string(&_0, SL(":style"), &_1, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&_1, this_ptr, "output", NULL, 0, variable, name); zephir_check_call_status(); zephir_array_update_string(&_0, SL(":output"), &_1, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_VAR(_3); ZVAL_STRING(&_3, "<pre style=':style'>:output</pre>", 0); ZEPHIR_RETURN_CALL_FUNCTION("strtr", NULL, 26, &_3, _0); zephir_check_call_status(); RETURN_MM(); }
/** * Adds a route to the router that only match if the HTTP method is PUT */ PHP_METHOD(Phalcon_Mvc_Router, addPut) { int ZEPHIR_LAST_CALL_STATUS; zval *pattern_param = NULL, *paths = NULL, *position = NULL, *_0; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } if (!position) { ZEPHIR_INIT_VAR(position); ZVAL_LONG(position, 1); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "PUT", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, pattern, paths, _0, position); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); }
/** * Generates SQL to create a view * * @param string viewName * @param array definition * @param string schemaName * @return string */ PHP_METHOD(Phalcon_Db_Dialect_Postgresql, createView) { zval *viewName, *definition, *schemaName, *viewSql, *view = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &viewName, &definition, &schemaName); ZEPHIR_OBS_VAR(viewSql); if (!(zephir_array_isset_string_fetch(&viewSql, definition, SS("sql"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The index 'sql' is required in the definition array", "phalcon/db/dialect/postgresql.zep", 315); return; } if (zephir_is_true(schemaName)) { ZEPHIR_INIT_VAR(view); ZEPHIR_CONCAT_VSV(view, viewName, ".", schemaName); } else { ZEPHIR_CPY_WRT(view, viewName); } ZEPHIR_CONCAT_SVSV(return_value, "CREATE VIEW ", view, " AS ", viewSql); RETURN_MM(); }
PHP_METHOD(Cake_Core_Configure, read) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_1 = NULL; zval *_var = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &_var); if (!_var) { _var = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(_var) == IS_NULL) { _0 = zephir_fetch_static_property_ce(cake_core_configure_ce, SL("_values") TSRMLS_CC); RETURN_CTOR(_0); } _0 = zephir_fetch_static_property_ce(cake_core_configure_ce, SL("_values") TSRMLS_CC); ZEPHIR_RETURN_CALL_CE_STATIC(cake_utility_hash_ce, "get", &_1, 5, _0, _var); zephir_check_call_status(); RETURN_MM(); }
/** * Get last row in the resultset */ PHP_METHOD(Phalcon_Mvc_Model_Resultset, getLast) { zephir_nts_static zephir_fcall_cache_entry *_1 = NULL, *_3 = NULL, *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *_0 = NULL, _2, *_4 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "count", &_1); zephir_check_call_status(); ZEPHIR_SINIT_VAR(_2); ZVAL_LONG(&_2, (zephir_get_numberval(_0) - 1)); ZEPHIR_CALL_METHOD(NULL, this_ptr, "seek", &_3, &_2); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_4, this_ptr, "valid", NULL); zephir_check_call_status(); if (!ZEPHIR_IS_FALSE_IDENTICAL(_4)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "current", &_5); zephir_check_call_status(); RETURN_MM(); } RETURN_MM_BOOL(0); }
/** * * @param string $session_id optional, session id * * @return boolean */ PHP_METHOD(Phalcon_Session_Adapter_Memcache, destroy){ zval *sid = NULL; zval *memcache; PHALCON_MM_GROW(); phalcon_fetch_params(1, 0, 1, &sid); if (!sid) { PHALCON_INIT_VAR(sid); PHALCON_CALL_SELF(&sid, "getid"); } memcache = phalcon_fetch_nproperty_this(this_ptr, SL("_memcache"), PH_NOISY TSRMLS_CC); if (Z_TYPE_P(memcache) == IS_OBJECT) { PHALCON_RETURN_CALL_METHOD(memcache, "delete", sid); RETURN_MM(); } else { RETURN_MM_FALSE; } }
/** * Generates a URL for a static resource * *<code> * // Generate a URL for a static resource * echo $url->getStatic("img/logo.png"); * * // Generate a URL for a static predefined route * echo $url->getStatic( * [ * "for" => "logo-cdn", * ] * ); *</code> */ PHP_METHOD(Phalcon_Mvc_Url, getStatic) { zend_long ZEPHIR_LAST_CALL_STATUS; zval *uri = NULL, *_0 = NULL, *_1, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &uri); if (!uri) { uri = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "getstaticbaseuri", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_NULL(_1); ZEPHIR_INIT_VAR(_2); ZVAL_NULL(_2); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "get", NULL, 0, uri, _1, _2, _0); zephir_check_call_status(); RETURN_MM(); }
PHP_METHOD(PocketMine_Math_Vector2, round) { int ZEPHIR_LAST_CALL_STATUS; zephir_nts_static zephir_fcall_cache_entry *_2 = NULL; zval *_0, *_1 = NULL, *_3, *_4 = NULL, *_5, *_6; ZEPHIR_MM_GROW(); object_init_ex(return_value, pocketmine_math_vector2_ce); _0 = zephir_fetch_nproperty_this(this_ptr, SL("x"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&_1, "round", &_2, _0); zephir_check_call_status(); _3 = zephir_fetch_nproperty_this(this_ptr, SL("y"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&_4, "round", &_2, _3); zephir_check_call_status(); ZEPHIR_INIT_VAR(_5); ZVAL_LONG(_5, zephir_get_intval(_1)); ZEPHIR_INIT_VAR(_6); ZVAL_LONG(_6, zephir_get_intval(_4)); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, _5, _6); zephir_check_call_status(); RETURN_MM(); }
/** * Reads column-map information for certain model using a MODEL_* constant * *<code> * print_r($metaData->readColumnMapIndex(new Robots(), MetaData::MODELS_REVERSE_COLUMN_MAP)); *</code> * * @param Phalcon\Mvc\ModelInterface $model * @param int $index */ PHP_METHOD(Phalcon_Mvc_Model_MetaData, readColumnMapIndex){ zval **model, **index, *key_name, *column_map = NULL, *null_value; zval *column_map_model, *attributes; phalcon_fetch_params_ex(2, 0, &model, &index); PHALCON_VERIFY_CLASS_EX(*model, phalcon_mvc_modelinterface_ce, phalcon_mvc_model_exception_ce, 0); PHALCON_ENSURE_IS_LONG(index); PHALCON_MM_GROW(); if (!PHALCON_GLOBAL(orm).column_renaming) { RETURN_MM(); } PHALCON_INIT_VAR(key_name); phalcon_get_class(key_name, *model, 1 TSRMLS_CC); PHALCON_OBS_VAR(column_map); phalcon_read_property_this(&column_map, this_ptr, SL("_columnMap"), PH_NOISY TSRMLS_CC); if (!phalcon_array_isset(column_map, key_name)) { null_value = PHALCON_GLOBAL(z_null); PHALCON_CALL_METHOD(NULL, this_ptr, "_initialize", *model, null_value, null_value, null_value); PHALCON_OBS_NVAR(column_map); phalcon_read_property_this(&column_map, this_ptr, SL("_columnMap"), PH_NOISY TSRMLS_CC); } PHALCON_OBS_VAR(column_map_model); phalcon_array_fetch(&column_map_model, column_map, key_name, PH_NOISY); PHALCON_OBS_VAR(attributes); phalcon_array_fetch(&attributes, column_map_model, *index, PH_NOISY); RETURN_CTOR(attributes); }
/** * The peek commands let the client inspect a job in the system. */ PHP_METHOD(Phalcon_Queue_Beanstalk, jobPeek) { zval *_1; zval *id_param = NULL, *response = NULL, _0, *_2, *_3, *_4 = NULL, *_5, *_6 = NULL; int id, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &id_param); id = zephir_get_intval(id_param); ZEPHIR_SINIT_VAR(_0); ZVAL_LONG(&_0, id); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SV(_1, "peek ", &_0); ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, _1); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&response, this_ptr, "readstatus", NULL, 409); zephir_check_call_status(); zephir_array_fetch_long(&_2, response, 0, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 462 TSRMLS_CC); if (!ZEPHIR_IS_STRING(_2, "FOUND")) { RETURN_MM_BOOL(0); } object_init_ex(return_value, phalcon_queue_beanstalk_job_ce); zephir_array_fetch_long(&_3, response, 1, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 466 TSRMLS_CC); zephir_array_fetch_long(&_5, response, 2, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 466 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_4, this_ptr, "read", NULL, 0, _5); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_6, "unserialize", NULL, 66, _4); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 410, this_ptr, _3, _6); zephir_check_call_status(); RETURN_MM(); }
/** * Returns the annotations found in the class docblock * * @return Phalcon\Annotations\Collection */ PHP_METHOD(Phalcon_Annotations_Reflection, getClassAnnotations){ zval *annotations, *reflection_data, *reflection_class; PHALCON_MM_GROW(); annotations = phalcon_read_property(getThis(), SL("_classAnnotations"), PH_NOISY); if (Z_TYPE_P(annotations) != IS_OBJECT) { reflection_data = phalcon_read_property(getThis(), SL("_reflectionData"), PH_NOISY); if (phalcon_array_isset_str_fetch(&reflection_class, reflection_data, SL("class"))) { object_init_ex(return_value, phalcon_annotations_collection_ce); PHALCON_CALL_METHOD(NULL, return_value, "__construct", reflection_class); phalcon_update_property_this(getThis(), SL("_classAnnotations"), return_value); RETURN_MM(); } phalcon_update_property_this(getThis(), SL("_classAnnotations"), &PHALCON_GLOBAL(z_false)); RETURN_MM_FALSE; } RETURN_CTOR(annotations); }
PHP_METHOD(Litesploit_Libs_Network_Telnet, loader) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_3 = NULL; zval *litesploit = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, _4, _5, _6, _7, _8, _9; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &litesploit); ZEPHIR_SEPARATE_PARAM(litesploit); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "/telnet.server\\((.*)\\)/", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "$telnetserver = $1;", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&_2, "preg_replace", &_3, 8, _0, _1, litesploit); zephir_check_temp_parameter(_0); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_CPY_WRT(litesploit, _2); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "/telnet.port\\((.*)\\)/", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "$telnetport = $1;", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&_2, "preg_replace", &_3, 8, _0, _1, litesploit); zephir_check_temp_parameter(_0); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_CPY_WRT(litesploit, _2); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "/telnet.username\\((.*)\\)/", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "$telnetusername = $1;", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&_2, "preg_replace", &_3, 8, _0, _1, litesploit); zephir_check_temp_parameter(_0); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_CPY_WRT(litesploit, _2); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "/telnet.password\\((.*)\\)/", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "$telnetpassword = $1;", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&_2, "preg_replace", &_3, 8, _0, _1, litesploit); zephir_check_temp_parameter(_0); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_CPY_WRT(litesploit, _2); ZEPHIR_INIT_NVAR(_0); ZEPHIR_SINIT_VAR(_4); ZVAL_STRING(&_4, "telnet.connect()", 0); ZEPHIR_SINIT_VAR(_5); ZVAL_STRING(&_5, "$telnet = new \\Telnet\\Client($telnetserver, $telnetport); $telnet->connect();", 0); zephir_fast_str_replace(&_0, &_4, &_5, litesploit TSRMLS_CC); ZEPHIR_CPY_WRT(litesploit, _0); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "/telnet.execute\\((.*)\\)/", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "$telnet->execute($1)", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&_2, "preg_replace", &_3, 8, _0, _1, litesploit); zephir_check_temp_parameter(_0); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_CPY_WRT(litesploit, _2); ZEPHIR_INIT_NVAR(_0); ZEPHIR_SINIT_VAR(_6); ZVAL_STRING(&_6, "telnet.username", 0); ZEPHIR_SINIT_VAR(_7); ZVAL_STRING(&_7, "$telnetusername", 0); zephir_fast_str_replace(&_0, &_6, &_7, litesploit TSRMLS_CC); ZEPHIR_CPY_WRT(litesploit, _0); ZEPHIR_INIT_NVAR(_0); ZEPHIR_SINIT_VAR(_8); ZVAL_STRING(&_8, "telnet.password", 0); ZEPHIR_SINIT_VAR(_9); ZVAL_STRING(&_9, "$telnetpassword", 0); zephir_fast_str_replace(&_0, &_8, &_9, litesploit TSRMLS_CC); ZEPHIR_CPY_WRT(litesploit, _0); RETVAL_ZVAL(litesploit, 1, 0); RETURN_MM(); }
/** * Internal validations, if it returns true, then skip the current validator */ PHP_METHOD(Phalcon_Validation, preChecking) { HashTable *_1$$3, *_7$$9; HashPosition _0$$3, _6$$9; zephir_fcall_cache_entry *_3 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *field, *validator, *singleField = NULL, *allowEmpty = NULL, *emptyValue = NULL, *value = NULL, *result = NULL, **_2$$3, *_4$$6, *_5$$6, **_8$$9; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &field, &validator); if (Z_TYPE_P(field) == IS_ARRAY) { zephir_is_iterable(field, &_1$$3, &_0$$3, 0, 0, "phalcon/validation.zep", 590); for ( ; zend_hash_get_current_data_ex(_1$$3, (void**) &_2$$3, &_0$$3) == SUCCESS ; zend_hash_move_forward_ex(_1$$3, &_0$$3) ) { ZEPHIR_GET_HVALUE(singleField, _2$$3); ZEPHIR_CALL_METHOD(&result, this_ptr, "prechecking", &_3, 469, singleField, validator); zephir_check_call_status(); if (zephir_is_true(result)) { RETURN_CCTOR(result); } } } else { ZEPHIR_INIT_VAR(_4$$6); ZVAL_STRING(_4$$6, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_5$$6); ZVAL_BOOL(_5$$6, 0); ZEPHIR_CALL_METHOD(&allowEmpty, validator, "getoption", NULL, 0, _4$$6, _5$$6); zephir_check_temp_parameter(_4$$6); zephir_check_call_status(); if (zephir_is_true(allowEmpty)) { if ((zephir_method_exists_ex(validator, SS("isallowempty") TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_METHOD(validator, "isallowempty", NULL, 0, this_ptr, field); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_CALL_METHOD(&value, this_ptr, "getvalue", NULL, 0, field); zephir_check_call_status(); if (Z_TYPE_P(allowEmpty) == IS_ARRAY) { zephir_is_iterable(allowEmpty, &_7$$9, &_6$$9, 0, 0, "phalcon/validation.zep", 604); for ( ; zend_hash_get_current_data_ex(_7$$9, (void**) &_8$$9, &_6$$9) == SUCCESS ; zend_hash_move_forward_ex(_7$$9, &_6$$9) ) { ZEPHIR_GET_HVALUE(emptyValue, _8$$9); if (ZEPHIR_IS_IDENTICAL(emptyValue, value)) { RETURN_MM_BOOL(1); } } RETURN_MM_BOOL(0); } RETURN_MM_BOOL(ZEPHIR_IS_EMPTY(value)); } } RETURN_MM_BOOL(0); }
/** * Returns the cookie's value * * @param string|array $filters * @param string $defaultValue * @return mixed */ PHP_METHOD(Phalcon_Http_Cookie, getValue){ zval *filters = NULL, *default_value = NULL, *restored, *dependency_injector = NULL; zval *readed, *name, *_COOKIE, *value = NULL, *encryption; zval *service = NULL, *crypt = NULL, *decrypted_value = NULL, *filter = NULL; PHALCON_MM_GROW(); phalcon_fetch_params(0, 0, 2, &filters, &default_value); if (!filters) { filters = &PHALCON_GLOBAL(z_null); } if (!default_value) { default_value = &PHALCON_GLOBAL(z_null); } restored = phalcon_read_property(getThis(), SL("_restored"), PH_NOISY); if (!zend_is_true(restored)) { PHALCON_CALL_METHOD(NULL, getThis(), "restore"); } PHALCON_INIT_VAR(dependency_injector); readed = phalcon_read_property(getThis(), SL("_readed"), PH_NOISY); if (PHALCON_IS_FALSE(readed)) { name = phalcon_read_property(getThis(), SL("_name"), PH_NOISY); _COOKIE = phalcon_get_global(SL("_COOKIE")); if (phalcon_array_isset_fetch(&value, _COOKIE, name)) { encryption = phalcon_read_property(getThis(), SL("_useEncryption"), PH_NOISY); if (zend_is_true(encryption)) { dependency_injector = phalcon_read_property(getThis(), SL("_dependencyInjector"), PH_NOISY); if (Z_TYPE_P(dependency_injector) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STR(phalcon_http_cookie_exception_ce, "A dependency injection object is required to access the 'filter' service"); return; } PHALCON_INIT_VAR(service); ZVAL_STRING(service, "crypt"); PHALCON_CALL_METHOD(&crypt, dependency_injector, "getshared", service); PHALCON_VERIFY_INTERFACE(crypt, phalcon_cryptinterface_ce); /** * Decrypt the value also decoding it with base64 */ PHALCON_CALL_METHOD(&decrypted_value, crypt, "decryptbase64", value); } else { PHALCON_CPY_WRT(decrypted_value, value); } /** * Update the decrypted value */ phalcon_update_property_this(getThis(), SL("_value"), decrypted_value); if (Z_TYPE_P(filters) != IS_NULL) { filter = phalcon_read_property(getThis(), SL("_filter"), PH_NOISY); if (Z_TYPE_P(filter) != IS_OBJECT) { if (Z_TYPE_P(dependency_injector) == IS_NULL) { dependency_injector = phalcon_read_property(getThis(), SL("_dependencyInjector"), PH_NOISY); PHALCON_VERIFY_INTERFACE_EX(dependency_injector, phalcon_diinterface_ce, phalcon_http_cookie_exception_ce, 1); } PHALCON_INIT_NVAR(service); ZVAL_STR(service, IS(filter)); PHALCON_CALL_METHOD(&filter, dependency_injector, "getshared", service); PHALCON_VERIFY_INTERFACE(filter, phalcon_filterinterface_ce); phalcon_update_property_this(getThis(), SL("_filter"), filter); } PHALCON_RETURN_CALL_METHOD(filter, "sanitize", decrypted_value, filters); RETURN_MM(); } /** * Return the value without filtering */ RETURN_CTOR(decrypted_value); } RETURN_CTOR(default_value); } value = phalcon_read_property(getThis(), SL("_value"), PH_NOISY); RETURN_CTOR(value); }
/** * Applies a format to a message before sending it to the log * * @param string $message * @param int $type * @param int $timestamp * @param array $context * * @return string */ PHP_METHOD(Phalcon_Logger_Formatter_Firephp, format) { zval *_18; HashTable *_7; HashPosition _6; zend_bool param, _11, _14; int type, timestamp, ZEPHIR_LAST_CALL_STATUS; zval *message_param = NULL, *type_param = NULL, *timestamp_param = NULL, *context = NULL, *meta, *body = NULL, *backtrace = NULL, *encoded, *len, *lastTrace = NULL, *_0 = NULL, *_1 = NULL, *_2, *backtraceItem = NULL, *key = NULL, _3, _4, *_5, **_8, *_9, *_10, *_12, *_13, *_15, *_16, *_17; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 1, &message_param, &type_param, ×tamp_param, &context); zephir_get_strval(message, message_param); type = zephir_get_intval(type_param); timestamp = zephir_get_intval(timestamp_param); if (!context) { context = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(context) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&_0, this_ptr, "interpolate", NULL, 0, message, context); zephir_check_call_status(); zephir_get_strval(message, _0); } ZEPHIR_INIT_VAR(meta); zephir_create_array(meta, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, type); ZEPHIR_CALL_METHOD(&_0, this_ptr, "gettypestring", NULL, 0, _1); zephir_check_call_status(); zephir_array_update_string(&meta, SL("Type"), &_0, PH_COPY | PH_SEPARATE); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_showBacktrace"), PH_NOISY_CC); if (zephir_is_true(_2)) { param = 0; ZEPHIR_INIT_NVAR(_1); ZEPHIR_GET_CONSTANT(_1, "PHP_VERSION"); ZEPHIR_SINIT_VAR(_3); ZVAL_STRING(&_3, "5.3.6", 0); ZEPHIR_SINIT_VAR(_4); ZVAL_STRING(&_4, "<", 0); ZEPHIR_CALL_FUNCTION(&_0, "version_compare", NULL, 248, _1, &_3, &_4); zephir_check_call_status(); if (!(zephir_is_true(_0))) { param = (2) ? 1 : 0; } ZEPHIR_CALL_FUNCTION(&backtrace, "debug_backtrace", NULL, 150, (param ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false))); zephir_check_call_status(); Z_SET_ISREF_P(backtrace); ZEPHIR_CALL_FUNCTION(&lastTrace, "end", NULL, 170, backtrace); Z_UNSET_ISREF_P(backtrace); zephir_check_call_status(); if (zephir_array_isset_string(lastTrace, SS("file"))) { zephir_array_fetch_string(&_5, lastTrace, SL("file"), PH_NOISY | PH_READONLY, "phalcon/logger/formatter/firephp.zep", 133 TSRMLS_CC); zephir_array_update_string(&meta, SL("File"), &_5, PH_COPY | PH_SEPARATE); } if (zephir_array_isset_string(lastTrace, SS("line"))) { zephir_array_fetch_string(&_5, lastTrace, SL("line"), PH_NOISY | PH_READONLY, "phalcon/logger/formatter/firephp.zep", 137 TSRMLS_CC); zephir_array_update_string(&meta, SL("Line"), &_5, PH_COPY | PH_SEPARATE); } zephir_is_iterable(backtrace, &_7, &_6, 1, 0, "phalcon/logger/formatter/firephp.zep", 146); for ( ; zephir_hash_get_current_data_ex(_7, (void**) &_8, &_6) == SUCCESS ; zephir_hash_move_forward_ex(_7, &_6) ) { ZEPHIR_GET_HMKEY(key, _7, _6); ZEPHIR_GET_HVALUE(backtraceItem, _8); zephir_array_unset_string(&backtraceItem, SS("object"), PH_SEPARATE); zephir_array_unset_string(&backtraceItem, SS("args"), PH_SEPARATE); zephir_array_update_zval(&backtrace, key, &backtraceItem, PH_COPY | PH_SEPARATE); } } _9 = zephir_fetch_nproperty_this(this_ptr, SL("_enableLabels"), PH_NOISY_CC); if (zephir_is_true(_9)) { zephir_array_update_string(&meta, SL("Label"), &message, PH_COPY | PH_SEPARATE); } _10 = zephir_fetch_nproperty_this(this_ptr, SL("_enableLabels"), PH_NOISY_CC); _11 = !zephir_is_true(_10); if (_11) { _12 = zephir_fetch_nproperty_this(this_ptr, SL("_showBacktrace"), PH_NOISY_CC); _11 = !zephir_is_true(_12); } _13 = zephir_fetch_nproperty_this(this_ptr, SL("_enableLabels"), PH_NOISY_CC); _14 = zephir_is_true(_13); if (_14) { _15 = zephir_fetch_nproperty_this(this_ptr, SL("_showBacktrace"), PH_NOISY_CC); _14 = !zephir_is_true(_15); } if (_11) { ZEPHIR_CPY_WRT(body, message); } else if (_14) { ZEPHIR_INIT_NVAR(body); ZVAL_STRING(body, "", 1); } else { ZEPHIR_INIT_NVAR(body); array_init(body); _16 = zephir_fetch_nproperty_this(this_ptr, SL("_showBacktrace"), PH_NOISY_CC); if (zephir_is_true(_16)) { zephir_array_update_string(&body, SL("backtrace"), &backtrace, PH_COPY | PH_SEPARATE); } _17 = zephir_fetch_nproperty_this(this_ptr, SL("_enableLabels"), PH_NOISY_CC); if (!(zephir_is_true(_17))) { zephir_array_update_string(&body, SL("message"), &message, PH_COPY | PH_SEPARATE); } } ZEPHIR_INIT_VAR(_18); zephir_create_array(_18, 2, 0 TSRMLS_CC); zephir_array_fast_append(_18, meta); zephir_array_fast_append(_18, body); ZEPHIR_INIT_VAR(encoded); zephir_json_encode(encoded, &(encoded), _18, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(len); ZVAL_LONG(len, zephir_fast_strlen_ev(encoded)); ZEPHIR_CONCAT_VSVS(return_value, len, "|", encoded, "|"); RETURN_MM(); }
/** * Magic method to get or set services using setters/getters * * @param string $method * @param array $arguments * @return mixed */ PHP_METHOD(Phalcon_DI, __call){ zval *method, *arguments = NULL, *services, *service_name = NULL; zval *possible_service = NULL, *handler, *exception_message; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 1, &method, &arguments); if (!arguments) { PHALCON_INIT_VAR(arguments); } /** * If the magic method starts with 'get' we try to get a service with that name */ if (phalcon_start_with_str(method, SL("get"))) { PHALCON_OBS_VAR(services); phalcon_read_property_this(&services, this_ptr, SL("_services"), PH_NOISY_CC); PHALCON_INIT_VAR(service_name); phalcon_substr(service_name, method, 3, 0); PHALCON_INIT_VAR(possible_service); phalcon_lcfirst(possible_service, service_name); if (phalcon_array_isset(services, possible_service)) { if (phalcon_fast_count_ev(arguments TSRMLS_CC)) { phalcon_call_method_p2(return_value, this_ptr, "get", possible_service, arguments); RETURN_MM(); } phalcon_call_method_p1(return_value, this_ptr, "get", possible_service); RETURN_MM(); } } /** * If the magic method starts with 'set' we try to set a service using that name */ if (phalcon_start_with_str(method, SL("set"))) { if (phalcon_array_isset_long(arguments, 0)) { PHALCON_INIT_NVAR(service_name); phalcon_substr(service_name, method, 3, 0); PHALCON_INIT_NVAR(possible_service); phalcon_lcfirst(possible_service, service_name); PHALCON_OBS_VAR(handler); phalcon_array_fetch_long(&handler, arguments, 0, PH_NOISY); phalcon_call_method_p2_noret(this_ptr, "set", possible_service, handler); RETURN_MM_NULL(); } } /** * The method doesn't start with set/get throw an exception */ PHALCON_INIT_VAR(exception_message); PHALCON_CONCAT_SVS(exception_message, "Call to undefined method or service '", method, "'"); PHALCON_THROW_EXCEPTION_ZVAL(phalcon_di_exception_ce, exception_message); return; }
/** * Get an object from the container * * @param string offset * @throws \Pdm\Di\Exception\ServiceNotFound * @return mixed */ PHP_METHOD(Pdm_Di_Container, get) { zend_class_entry *_3, *_4; int ZEPHIR_LAST_CALL_STATUS; zval *offset_param = NULL, *service, *className, *instance, *_0, *_1; zval *offset = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &offset_param); if (unlikely(Z_TYPE_P(offset_param) != IS_STRING && Z_TYPE_P(offset_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'offset' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (unlikely(Z_TYPE_P(offset_param) == IS_STRING)) { offset = offset_param; } else { ZEPHIR_INIT_VAR(offset); ZVAL_EMPTY_STRING(offset); } ZEPHIR_OBS_VAR(service); _0 = zephir_fetch_nproperty_this(this_ptr, SL("container"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&service, _0, offset, 0 TSRMLS_CC))) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, pdm_di_exception_servicenotfound_ce); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_VS(_2, offset, " is not defined."); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "pdm/di/container.zep", 142 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (Z_TYPE_P(service) == IS_STRING) { _3 = zend_fetch_class(Z_STRVAL_P(service), Z_STRLEN_P(service), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(return_value, _3); if (zephir_has_constructor(return_value TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL); zephir_check_call_status(); } RETURN_MM(); } if (Z_TYPE_P(service) == IS_ARRAY) { ZEPHIR_OBS_VAR(className); if (zephir_array_isset_string_fetch(&className, service, SS("className"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(instance); _4 = zend_fetch_class(Z_STRVAL_P(className), Z_STRLEN_P(className), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(instance, _4); if (zephir_has_constructor(instance TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, instance, "__construct", NULL, service); zephir_check_call_status(); } if (Z_TYPE_P(instance) == IS_OBJECT) { if (zephir_instance_of_ev(instance, pdm_di_injectionawareinterface_ce TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, instance, "setdi", NULL, this_ptr); zephir_check_call_status(); } } RETURN_CCTOR(instance); } } if (Z_TYPE_P(service) == IS_OBJECT) { if (zephir_instance_of_ev(service, zend_ce_closure TSRMLS_CC)) { ZEPHIR_RETURN_CALL_ZVAL_FUNCTION(service, NULL); zephir_check_call_status(); RETURN_MM(); } } RETURN_CCTOR(service); }
/** * Replaces placeholders from pattern returning a valid PCRE regular expression * * @param string pattern * @return string */ PHP_METHOD(Test_Router_Route, compilePattern) { zval *pattern = NULL, pattern_sub, idPattern, _0$$4, _1$$4, _2$$5, _3$$5, _4$$6, _5$$6, _6$$7, _7$$7, _8$$8, _9$$8, _10$$8, _11$$9, _12$$9, _13$$9; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&pattern_sub); ZVAL_UNDEF(&idPattern); ZVAL_UNDEF(&_0$$4); ZVAL_UNDEF(&_1$$4); ZVAL_UNDEF(&_2$$5); ZVAL_UNDEF(&_3$$5); ZVAL_UNDEF(&_4$$6); ZVAL_UNDEF(&_5$$6); ZVAL_UNDEF(&_6$$7); ZVAL_UNDEF(&_7$$7); ZVAL_UNDEF(&_8$$8); ZVAL_UNDEF(&_9$$8); ZVAL_UNDEF(&_10$$8); ZVAL_UNDEF(&_11$$9); ZVAL_UNDEF(&_12$$9); ZVAL_UNDEF(&_13$$9); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &pattern); ZEPHIR_SEPARATE_PARAM(pattern); if (zephir_memnstr_str(pattern, SL(":"), "test/router/route.zep", 56)) { ZEPHIR_INIT_VAR(&idPattern); ZVAL_STRING(&idPattern, "/([a-zA-Z0-9\\_\\-]+)"); if (zephir_memnstr_str(pattern, SL("/:module"), "test/router/route.zep", 62)) { ZEPHIR_INIT_VAR(&_0$$4); ZEPHIR_INIT_VAR(&_1$$4); ZVAL_STRING(&_1$$4, "/:module"); zephir_fast_str_replace(&_0$$4, &_1$$4, &idPattern, pattern TSRMLS_CC); ZEPHIR_CPY_WRT(pattern, &_0$$4); } if (zephir_memnstr_str(pattern, SL("/:controller"), "test/router/route.zep", 67)) { ZEPHIR_INIT_VAR(&_2$$5); ZEPHIR_INIT_VAR(&_3$$5); ZVAL_STRING(&_3$$5, "/:controller"); zephir_fast_str_replace(&_2$$5, &_3$$5, &idPattern, pattern TSRMLS_CC); ZEPHIR_CPY_WRT(pattern, &_2$$5); } if (zephir_memnstr_str(pattern, SL("/:namespace"), "test/router/route.zep", 72)) { ZEPHIR_INIT_VAR(&_4$$6); ZEPHIR_INIT_VAR(&_5$$6); ZVAL_STRING(&_5$$6, "/:namespace"); zephir_fast_str_replace(&_4$$6, &_5$$6, &idPattern, pattern TSRMLS_CC); ZEPHIR_CPY_WRT(pattern, &_4$$6); } if (zephir_memnstr_str(pattern, SL("/:action"), "test/router/route.zep", 77)) { ZEPHIR_INIT_VAR(&_6$$7); ZEPHIR_INIT_VAR(&_7$$7); ZVAL_STRING(&_7$$7, "/:action"); zephir_fast_str_replace(&_6$$7, &_7$$7, &idPattern, pattern TSRMLS_CC); ZEPHIR_CPY_WRT(pattern, &_6$$7); } if (zephir_memnstr_str(pattern, SL("/:params"), "test/router/route.zep", 82)) { ZEPHIR_INIT_VAR(&_8$$8); ZEPHIR_INIT_VAR(&_9$$8); ZVAL_STRING(&_9$$8, "/:params"); ZEPHIR_INIT_VAR(&_10$$8); ZVAL_STRING(&_10$$8, "(/.*)*"); zephir_fast_str_replace(&_8$$8, &_9$$8, &_10$$8, pattern TSRMLS_CC); ZEPHIR_CPY_WRT(pattern, &_8$$8); } if (zephir_memnstr_str(pattern, SL("/:int"), "test/router/route.zep", 87)) { ZEPHIR_INIT_VAR(&_11$$9); ZEPHIR_INIT_VAR(&_12$$9); ZVAL_STRING(&_12$$9, "/:int"); ZEPHIR_INIT_VAR(&_13$$9); ZVAL_STRING(&_13$$9, "/([0-9]+)"); zephir_fast_str_replace(&_11$$9, &_12$$9, &_13$$9, pattern TSRMLS_CC); ZEPHIR_CPY_WRT(pattern, &_11$$9); } } if (zephir_memnstr_str(pattern, SL("("), "test/router/route.zep", 93)) { ZEPHIR_CONCAT_SVS(return_value, "#^", pattern, "$#"); RETURN_MM(); } if (zephir_memnstr_str(pattern, SL("["), "test/router/route.zep", 98)) { ZEPHIR_CONCAT_SVS(return_value, "#^", pattern, "$#"); RETURN_MM(); } RETVAL_ZVAL(pattern, 1, 0); RETURN_MM(); }
/** * Extracts parameters from a string * * @param string pattern */ PHP_METHOD(Test_Router_Route, extractNamedParams) { long _0, _5$$11, _26$$19; zend_bool notValid, _6$$12, _7$$12, _8$$12, _9$$12, _10$$12, _11$$12, _12$$12, _13$$12, _14$$12, _15$$12, _16$$12, _17$$12, _25$$18; int tmp = 0, cursor = 0, cursorVar = 0, marker = 0, bracketCount, parenthesesCount, foundPattern, intermediate, numberMatches; char ch = 0; zval *pattern_param = NULL, matches, _1$$11, _2$$11, _3$$11, _18$$16, _19$$16, _20$$16, _22$$16, _23$$16, _27$$19, _28$$28; zval pattern, route, item, variable, regexp, _4$$11, _21$$16, _24$$16, _29$$29; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&pattern); ZVAL_UNDEF(&route); ZVAL_UNDEF(&item); ZVAL_UNDEF(&variable); ZVAL_UNDEF(®exp); ZVAL_UNDEF(&_4$$11); ZVAL_UNDEF(&_21$$16); ZVAL_UNDEF(&_24$$16); ZVAL_UNDEF(&_29$$29); ZVAL_UNDEF(&matches); ZVAL_UNDEF(&_1$$11); ZVAL_UNDEF(&_2$$11); ZVAL_UNDEF(&_3$$11); ZVAL_UNDEF(&_18$$16); ZVAL_UNDEF(&_19$$16); ZVAL_UNDEF(&_20$$16); ZVAL_UNDEF(&_22$$16); ZVAL_UNDEF(&_23$$16); ZVAL_UNDEF(&_27$$19); ZVAL_UNDEF(&_28$$28); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &pattern_param); zephir_get_strval(&pattern, pattern_param); notValid = 0; bracketCount = 0; parenthesesCount = 0; foundPattern = 0; intermediate = 0; numberMatches = 0; if (zephir_fast_strlen_ev(&pattern) <= 0) { RETURN_MM_BOOL(0); } ZEPHIR_INIT_VAR(&matches); array_init(&matches); ZEPHIR_INIT_VAR(&route); ZVAL_STRING(&route, ""); for (_0 = 0; _0 < Z_STRLEN_P(&pattern); _0++) { cursor = _0; ch = ZEPHIR_STRING_OFFSET(&pattern, _0); if (parenthesesCount == 0) { if (ch == '{') { if (bracketCount == 0) { marker = (cursor + 1); intermediate = 0; notValid = 0; } bracketCount++; } else { if (ch == '}') { bracketCount--; if (intermediate > 0) { if (bracketCount == 0) { numberMatches++; ZEPHIR_INIT_NVAR(&variable); ZVAL_STRING(&variable, ""); ZEPHIR_INIT_NVAR(®exp); ZVAL_STRING(®exp, ""); ZVAL_LONG(&_1$$11, marker); ZVAL_LONG(&_2$$11, (cursor - marker)); ZEPHIR_INIT_NVAR(&_3$$11); zephir_substr(&_3$$11, &pattern, zephir_get_intval(&_1$$11), zephir_get_intval(&_2$$11), 0); zephir_get_strval(&_4$$11, &_3$$11); ZEPHIR_CPY_WRT(&item, &_4$$11); for (_5$$11 = 0; _5$$11 < Z_STRLEN_P(&item); _5$$11++) { cursorVar = _5$$11; ch = ZEPHIR_STRING_OFFSET(&item, _5$$11); if (ch == '\0') { break; } _6$$12 = cursorVar == 0; if (_6$$12) { _7$$12 = ch >= 'a'; if (_7$$12) { _7$$12 = ch <= 'z'; } _8$$12 = _7$$12; if (!(_8$$12)) { _9$$12 = ch >= 'A'; if (_9$$12) { _9$$12 = ch <= 'Z'; } _8$$12 = _9$$12; } _6$$12 = !(_8$$12); } if (_6$$12) { notValid = 1; break; } _10$$12 = ch >= 'a'; if (_10$$12) { _10$$12 = ch <= 'z'; } _11$$12 = _10$$12; if (!(_11$$12)) { _12$$12 = ch >= 'A'; if (_12$$12) { _12$$12 = ch <= 'Z'; } _11$$12 = _12$$12; } _13$$12 = _11$$12; if (!(_13$$12)) { _14$$12 = ch >= '0'; if (_14$$12) { _14$$12 = ch <= '9'; } _13$$12 = _14$$12; } _15$$12 = _13$$12; if (!(_15$$12)) { _15$$12 = ch == '-'; } _16$$12 = _15$$12; if (!(_16$$12)) { _16$$12 = ch == '_'; } _17$$12 = _16$$12; if (!(_17$$12)) { _17$$12 = ch == ':'; } if (_17$$12) { if (ch == ':') { ZVAL_LONG(&_18$$16, 0); ZVAL_LONG(&_19$$16, cursorVar); ZEPHIR_INIT_NVAR(&_20$$16); zephir_substr(&_20$$16, &item, 0 , zephir_get_intval(&_19$$16), 0); zephir_get_strval(&_21$$16, &_20$$16); ZEPHIR_CPY_WRT(&variable, &_21$$16); ZVAL_LONG(&_22$$16, (cursorVar + 1)); ZEPHIR_INIT_NVAR(&_23$$16); zephir_substr(&_23$$16, &item, zephir_get_intval(&_22$$16), 0, ZEPHIR_SUBSTR_NO_LENGTH); zephir_get_strval(&_24$$16, &_23$$16); ZEPHIR_CPY_WRT(®exp, &_24$$16); break; } } else { notValid = 1; break; } } if (!(notValid)) { tmp = numberMatches; _25$$18 = zephir_is_true(&variable); if (_25$$18) { _25$$18 = zephir_is_true(®exp); } if (_25$$18) { foundPattern = 0; for (_26$$19 = 0; _26$$19 < Z_STRLEN_P(®exp); _26$$19++) { ch = ZEPHIR_STRING_OFFSET(®exp, _26$$19); if (ch == '\0') { break; } if (!(foundPattern)) { if (ch == '(') { foundPattern = 1; } } else { if (ch == ')') { foundPattern = 2; break; } } } if (foundPattern != 2) { zephir_concat_self_str(&route, "(", sizeof("(")-1 TSRMLS_CC); zephir_concat_self(&route, ®exp TSRMLS_CC); zephir_concat_self_str(&route, ")", sizeof(")")-1 TSRMLS_CC); } else { zephir_concat_self(&route, ®exp TSRMLS_CC); } ZEPHIR_INIT_NVAR(&_27$$19); ZVAL_LONG(&_27$$19, tmp); zephir_array_update_zval(&matches, &variable, &_27$$19, PH_COPY | PH_SEPARATE); } else { zephir_concat_self_str(&route, "([^/]*)", sizeof("([^/]*)")-1 TSRMLS_CC); ZEPHIR_INIT_NVAR(&_28$$28); ZVAL_LONG(&_28$$28, tmp); zephir_array_update_zval(&matches, &item, &_28$$28, PH_COPY | PH_SEPARATE); } } else { ZEPHIR_INIT_LNVAR(_29$$29); ZEPHIR_CONCAT_SVS(&_29$$29, "{", &item, "}"); zephir_concat_self(&route, &_29$$29 TSRMLS_CC); } continue; } } } } } if (bracketCount == 0) { if (ch == '(') { parenthesesCount++; } else { if (ch == ')') { parenthesesCount--; if (parenthesesCount == 0) { numberMatches++; } } } } if (bracketCount > 0) { intermediate++; } else { zephir_concat_self_char(&route, ch TSRMLS_CC); } } zephir_create_array(return_value, 2, 0 TSRMLS_CC); zephir_array_fast_append(return_value, &route); zephir_array_fast_append(return_value, &matches); RETURN_MM(); }
/** * Produces an string representation of a variable * * @param mixed $variable * @return string */ PHP_METHOD(Phalcon_Debug, _getVarDump){ zval *variable, *class_name, *dumped_object; zval *array_dump = NULL, *dump = NULL; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 0, &variable); if (PHALCON_IS_SCALAR(variable)) { /** * Boolean variables are represented as 'true'/'false' */ if (Z_TYPE_P(variable) == IS_BOOL) { if (zend_is_true(variable)) { RETURN_MM_STRING("true", 1); } else { RETURN_MM_STRING("false", 1); } } /** * String variables are escaped to avoid XSS injections */ if (Z_TYPE_P(variable) == IS_STRING) { phalcon_call_method_p1(return_value, this_ptr, "_escapestring", variable); RETURN_MM(); } /** * Other scalar variables are just converted to strings */ RETURN_CCTOR(variable); } /** * If the variable is an object print its class name */ if (Z_TYPE_P(variable) == IS_OBJECT) { PHALCON_INIT_VAR(class_name); phalcon_get_class(class_name, variable, 0 TSRMLS_CC); /** * Try to check for a 'dump' method, this surely produces a better printable * representation */ if (phalcon_method_exists_ex(variable, SS("dump") TSRMLS_CC) == SUCCESS) { PHALCON_INIT_VAR(dumped_object); phalcon_call_method(dumped_object, variable, "dump"); /** * dump() must return an array, generate a recursive representation using * getArrayDump */ PHALCON_INIT_VAR(array_dump); phalcon_call_method_p1(array_dump, this_ptr, "_getarraydump", dumped_object); PHALCON_INIT_VAR(dump); PHALCON_CONCAT_SVSVS(dump, "Object(", class_name, ": ", array_dump, ")"); } else { /** * If dump() is not available just print the class name */ PHALCON_INIT_NVAR(dump); PHALCON_CONCAT_SVS(dump, "Object(", class_name, ")</span>"); } RETURN_CTOR(dump); } /** * Recursively process the array and enclose it in Array() */ if (Z_TYPE_P(variable) == IS_ARRAY) { PHALCON_INIT_NVAR(array_dump); phalcon_call_method_p1(array_dump, this_ptr, "_getarraydump", variable); PHALCON_CONCAT_SVS(return_value, "Array(", array_dump, ")"); RETURN_MM(); } /** * Null variables are represented as 'null' * Other types are represented by its type */ RETURN_MM_STRING(zend_zval_type_name(variable), 1); }
/** * Gets the a value to validate in the array/object data source * * @param string field * @return mixed */ PHP_METHOD(Phalcon_Validation, getValue) { zend_bool _1; zephir_fcall_cache_entry *_2 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *field_param = NULL, *entity = NULL, *method = NULL, *value = NULL, *data = NULL, *values = NULL, *filters = NULL, *fieldFilters = NULL, *dependencyInjector = NULL, *filterService = NULL, *_0$$3, *_3$$20; zval *field = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &field_param); zephir_get_strval(field, field_param); ZEPHIR_OBS_VAR(entity); zephir_read_property_this(&entity, this_ptr, SL("_entity"), PH_NOISY_CC); if (Z_TYPE_P(entity) == IS_OBJECT) { ZEPHIR_INIT_VAR(_0$$3); zephir_camelize(_0$$3, field, NULL ); ZEPHIR_INIT_VAR(method); ZEPHIR_CONCAT_SV(method, "get", _0$$3); if ((zephir_method_exists(entity, method TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD_ZVAL(&value, entity, method, NULL, 0); zephir_check_call_status(); } else { if ((zephir_method_exists_ex(entity, SS("readattribute") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&value, entity, "readattribute", NULL, 0, field); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(value); if (zephir_isset_property_zval(entity, field TSRMLS_CC)) { zephir_read_property_zval(&value, entity, field, PH_NOISY_CC); } else { ZVAL_NULL(value); } } } RETURN_CCTOR(value); } ZEPHIR_OBS_VAR(data); zephir_read_property_this(&data, this_ptr, SL("_data"), PH_NOISY_CC); _1 = Z_TYPE_P(data) != IS_ARRAY; if (_1) { _1 = Z_TYPE_P(data) != IS_OBJECT; } if (_1) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "There is no data to validate", "phalcon/validation.zep", 504); return; } ZEPHIR_OBS_VAR(values); zephir_read_property_this(&values, this_ptr, SL("_values"), PH_NOISY_CC); ZEPHIR_OBS_NVAR(value); if (zephir_array_isset_fetch(&value, values, field, 0 TSRMLS_CC)) { RETURN_CCTOR(value); } ZEPHIR_INIT_NVAR(value); ZVAL_NULL(value); if (Z_TYPE_P(data) == IS_ARRAY) { if (zephir_array_isset(data, field)) { ZEPHIR_OBS_NVAR(value); zephir_array_fetch(&value, data, field, PH_NOISY, "phalcon/validation.zep", 516 TSRMLS_CC); } } else { if (Z_TYPE_P(data) == IS_OBJECT) { if (zephir_isset_property_zval(data, field TSRMLS_CC)) { ZEPHIR_OBS_NVAR(value); zephir_read_property_zval(&value, data, field, PH_NOISY_CC); } } } if (Z_TYPE_P(value) == IS_NULL) { RETURN_MM_NULL(); } ZEPHIR_OBS_VAR(filters); zephir_read_property_this(&filters, this_ptr, SL("_filters"), PH_NOISY_CC); if (Z_TYPE_P(filters) == IS_ARRAY) { ZEPHIR_OBS_VAR(fieldFilters); if (zephir_array_isset_fetch(&fieldFilters, filters, field, 0 TSRMLS_CC)) { if (zephir_is_true(fieldFilters)) { ZEPHIR_CALL_METHOD(&dependencyInjector, this_ptr, "getdi", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_CALL_CE_STATIC(&dependencyInjector, phalcon_di_ce, "getdefault", &_2, 1); zephir_check_call_status(); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "A dependency injector is required to obtain the 'filter' service", "phalcon/validation.zep", 541); return; } } ZEPHIR_INIT_VAR(_3$$20); ZVAL_STRING(_3$$20, "filter", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&filterService, dependencyInjector, "getshared", NULL, 0, _3$$20); zephir_check_temp_parameter(_3$$20); zephir_check_call_status(); if (Z_TYPE_P(filterService) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Returned 'filter' service is invalid", "phalcon/validation.zep", 547); return; } ZEPHIR_RETURN_CALL_METHOD(filterService, "sanitize", NULL, 0, value, fieldFilters); zephir_check_call_status(); RETURN_MM(); } } } zephir_update_property_array(this_ptr, SL("_values"), field, value TSRMLS_CC); RETURN_CCTOR(value); }
/** * Gets a value from the internal related entity or from the default value */ PHP_METHOD(Phalcon_Forms_Form, getValue) { zend_long ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *entity = NULL, *method = NULL, *value = NULL, *data = NULL, *internal = NULL, *forbidden = NULL, *_1, *_0$$4; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } ZEPHIR_OBS_VAR(entity); zephir_read_property_this(&entity, this_ptr, SL("_entity"), PH_NOISY_CC); ZEPHIR_OBS_VAR(data); zephir_read_property_this(&data, this_ptr, SL("_data"), PH_NOISY_CC); if ((zephir_method_exists_ex(this_ptr, SS("getcustomvalue") TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getcustomvalue", NULL, 0, name, entity, data); zephir_check_call_status(); RETURN_MM(); } if (Z_TYPE_P(entity) == IS_OBJECT) { ZEPHIR_INIT_VAR(_0$$4); zephir_camelize(_0$$4, name, NULL ); ZEPHIR_INIT_VAR(method); ZEPHIR_CONCAT_SV(method, "get", _0$$4); if ((zephir_method_exists(entity, method TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_METHOD_ZVAL(entity, method, NULL, 0); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_OBS_VAR(value); if (zephir_fetch_property_zval(&value, entity, name, PH_SILENT_CC)) { RETURN_CCTOR(value); } } if (Z_TYPE_P(data) == IS_ARRAY) { ZEPHIR_OBS_NVAR(value); if (zephir_array_isset_fetch(&value, data, name, 0 TSRMLS_CC)) { RETURN_CCTOR(value); } } ZEPHIR_INIT_VAR(forbidden); zephir_create_array(forbidden, 12, 0 TSRMLS_CC); zephir_array_update_string(&forbidden, SL("validation"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&forbidden, SL("action"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&forbidden, SL("useroption"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&forbidden, SL("useroptions"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&forbidden, SL("entity"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&forbidden, SL("elements"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&forbidden, SL("messages"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&forbidden, SL("messagesfor"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&forbidden, SL("label"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&forbidden, SL("value"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&forbidden, SL("di"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&forbidden, SL("eventsmanager"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_VAR(internal); zephir_fast_strtolower(internal, name); if (zephir_array_isset(forbidden, internal)) { RETURN_MM_NULL(); } ZEPHIR_INIT_VAR(_1); zephir_camelize(_1, name, NULL ); ZEPHIR_INIT_NVAR(method); ZEPHIR_CONCAT_SV(method, "get", _1); if ((zephir_method_exists(this_ptr, method TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_METHOD_ZVAL(this_ptr, method, NULL, 0); zephir_check_call_status(); RETURN_MM(); } RETURN_MM_NULL(); }
/** * Check whether internal resource has rows to fetch * * @return boolean */ PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, valid){ zval *type = NULL, *row = NULL, *underscore; zval *empty_str, *active_row = NULL; zval *dirty_state, *column = NULL, *alias = NULL, *source = NULL, *attributes = NULL; zval *column_map = NULL, *row_model = NULL, *attribute = NULL, *column_alias = NULL; zval *column_value = NULL; zval *value = NULL, *sql_alias = NULL, *n_alias = NULL; HashTable *ah0, *ah1; HashPosition hp0, hp1; zval **hd; int i_type, is_partial; PHALCON_MM_GROW(); type = phalcon_fetch_nproperty_this(this_ptr, SL("_type"), PH_NOISY TSRMLS_CC); i_type = (Z_TYPE_P(type) == IS_LONG) ? Z_LVAL_P(type) : phalcon_get_intval(type); is_partial = (i_type == PHALCON_MVC_MODEL_RESULTSET_TYPE_PARTIAL); type = NULL; PHALCON_INIT_VAR(row); if (is_partial) { /** * The result is bigger than 32 rows so it's retrieved one by one */ zval *result = phalcon_fetch_nproperty_this(this_ptr, SL("_result"), PH_NOISY TSRMLS_CC); if (PHALCON_IS_NOT_FALSE(result)) { PHALCON_CALL_METHOD(&row, result, "fetch", result); } else { ZVAL_FALSE(row); } } else { /** * The full rows are dumped in this_ptr->rows */ zval *rows = phalcon_fetch_nproperty_this(this_ptr, SL("_rows"), PH_NOISY TSRMLS_CC); if (Z_TYPE_P(rows) == IS_ARRAY) { phalcon_array_get_current(row, rows); if (Z_TYPE_P(row) == IS_OBJECT) { zend_hash_move_forward(Z_ARRVAL_P(rows)); } } else { ZVAL_FALSE(row); } } /** * Valid records are arrays */ if (Z_TYPE_P(row) == IS_ARRAY || Z_TYPE_P(row) == IS_OBJECT) { /** * The result type=1 so we need to build every row */ if (is_partial) { /** * Get current hydration mode */ zval *hydrate_mode = phalcon_fetch_nproperty_this(this_ptr, SL("_hydrateMode"), PH_NOISY TSRMLS_CC); zval *columns_types = phalcon_fetch_nproperty_this(this_ptr, SL("_columnTypes"), PH_NOISY TSRMLS_CC); int i_hydrate_mode = phalcon_get_intval(hydrate_mode); PHALCON_INIT_VAR(underscore); ZVAL_STRING(underscore, "_", 1); PHALCON_INIT_VAR(empty_str); ZVAL_EMPTY_STRING(empty_str); /** * Each row in a complex result is a Phalcon\Mvc\Model\Row instance */ PHALCON_INIT_VAR(active_row); switch (i_hydrate_mode) { case 0: object_init_ex(active_row, phalcon_mvc_model_row_ce); break; case 1: array_init(active_row); break; case 2: default: object_init(active_row); break; } /** * Create every record according to the column types */ /** * Set records as dirty state PERSISTENT by default */ PHALCON_INIT_VAR(dirty_state); ZVAL_LONG(dirty_state, 0); phalcon_is_iterable(columns_types, &ah0, &hp0, 0, 0); while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) { PHALCON_GET_HKEY(alias, ah0, hp0); PHALCON_GET_HVALUE(column); PHALCON_OBS_NVAR(type); phalcon_array_fetch_string(&type, column, SL("type"), PH_NOISY); if (PHALCON_IS_STRING(type, "object")) { /** * Object columns are assigned column by column */ PHALCON_OBS_NVAR(source); phalcon_array_fetch_string(&source, column, SL("column"), PH_NOISY); PHALCON_OBS_NVAR(attributes); phalcon_array_fetch_string(&attributes, column, SL("attributes"), PH_NOISY); PHALCON_OBS_NVAR(column_map); phalcon_array_fetch_string(&column_map, column, SL("columnMap"), PH_NOISY); /** * Assign the values from the _source_attribute notation to its real column name */ PHALCON_INIT_NVAR(row_model); array_init(row_model); phalcon_is_iterable(attributes, &ah1, &hp1, 0, 0); while (zend_hash_get_current_data_ex(ah1, (void**) &hd, &hp1) == SUCCESS) { PHALCON_GET_HVALUE(attribute); /** * Columns are supposed to be in the form _table_field */ PHALCON_INIT_NVAR(column_alias); PHALCON_CONCAT_VVVV(column_alias, underscore, source, underscore, attribute); PHALCON_OBS_NVAR(column_value); phalcon_array_fetch(&column_value, row, column_alias, PH_NOISY); phalcon_array_update_zval(&row_model, attribute, column_value, PH_COPY | PH_SEPARATE); zend_hash_move_forward_ex(ah1, &hp1); } /** * Generate the column value according to the hydration type */ switch (phalcon_get_intval(hydrate_mode)) { case 0: { zval *keep_snapshots, *instance; /** * Check if the resultset must keep snapshots */ if (!phalcon_array_isset_string_fetch(&keep_snapshots, column, SS("keepSnapshots"))) { keep_snapshots = PHALCON_GLOBAL(z_false); } /** * Get the base instance */ if (!phalcon_array_isset_string_fetch(&instance, column, SS("instance"))) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Undefined index: instance"); instance = PHALCON_GLOBAL(z_null); } /** * Assign the values to the attributes using a column map */ PHALCON_CALL_CE_STATIC(&value, phalcon_mvc_model_ce, "cloneresultmap", instance, row_model, column_map, dirty_state, keep_snapshots); break; } default: /** * Other kinds of hydrations */ PHALCON_CALL_CE_STATIC(&value, phalcon_mvc_model_ce, "cloneresultmaphydrate", row_model, column_map, hydrate_mode); break; } /** * The complete object is assigned to an attribute with the name of the alias or * the model name */ PHALCON_OBS_NVAR(attribute); if (phalcon_array_isset_string(column, SS("balias"))) { phalcon_array_fetch_string(&attribute, column, SL("balias"), PH_NOISY); } } else { /** * Scalar columns are simply assigned to the result object */ if (phalcon_array_isset_string(column, SS("sqlAlias"))) { PHALCON_OBS_NVAR(sql_alias); phalcon_array_fetch_string(&sql_alias, column, SL("sqlAlias"), PH_NOISY); PHALCON_OBS_NVAR(value); phalcon_array_fetch(&value, row, sql_alias, PH_NOISY); } else { PHALCON_OBS_NVAR(value); if (phalcon_array_isset(row, alias)) { phalcon_array_fetch(&value, row, alias, PH_NOISY); } } /** * If a 'balias' is defined is not an unnamed scalar */ if (phalcon_array_isset_string(column, SS("balias"))) { PHALCON_CPY_WRT(attribute, alias); } else { PHALCON_INIT_NVAR(n_alias); phalcon_fast_str_replace(n_alias, underscore, empty_str, alias); PHALCON_CPY_WRT(attribute, n_alias); } assert(attribute != NULL); } /** * Assign the instance according to the hydration type */ if (unlikely(!attribute)) { zend_throw_exception_ex(phalcon_mvc_model_exception_ce, 0 TSRMLS_CC, "Unexpected inconsistency: attribute is NULL"); RETURN_MM(); } switch (phalcon_get_intval(hydrate_mode)) { case 1: phalcon_array_update_zval(&active_row, attribute, value, PH_COPY | PH_SEPARATE); break; default: phalcon_update_property_zval_zval(active_row, attribute, value TSRMLS_CC); break; } zend_hash_move_forward_ex(ah0, &hp0); } /** * Store the generated row in this_ptr->activeRow to be retrieved by 'current' */ phalcon_update_property_this(this_ptr, SL("_activeRow"), active_row TSRMLS_CC); } else { /** * The row is already built so we just assign it to the activeRow */ phalcon_update_property_this(this_ptr, SL("_activeRow"), row TSRMLS_CC); } RETURN_MM_TRUE; } /** * There are no results to retrieve so we update this_ptr->activeRow as false */ phalcon_update_property_bool(this_ptr, SL("_activeRow"), 0 TSRMLS_CC); RETURN_MM_FALSE; }
/** * Listens for notifications from the models manager */ PHP_METHOD(Phalcon_Mvc_Collection_Behavior_SoftDelete, notify) { HashTable *_5$$7; HashPosition _4$$7; zephir_fcall_cache_entry *_7 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *type_param = NULL, *model, *options = NULL, *value = NULL, *field = NULL, *updateModel = NULL, *message = NULL, *_0$$3, *_1$$3 = NULL, *_2$$6 = NULL, *_3$$7 = NULL, **_6$$7; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &type_param, &model); if (unlikely(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(type_param) == IS_STRING)) { zephir_get_strval(type, type_param); } else { ZEPHIR_INIT_VAR(type); ZVAL_EMPTY_STRING(type); } if (ZEPHIR_IS_STRING(type, "beforeDelete")) { ZEPHIR_CALL_METHOD(&options, this_ptr, "getoptions", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_VAR(value); if (!(zephir_array_isset_string_fetch(&value, options, SS("value"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "The option 'value' is required", "phalcon/mvc/collection/behavior/softdelete.zep", 51); return; } ZEPHIR_OBS_VAR(field); if (!(zephir_array_isset_string_fetch(&field, options, SS("field"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "The option 'field' is required", "phalcon/mvc/collection/behavior/softdelete.zep", 58); return; } ZEPHIR_INIT_VAR(_0$$3); ZVAL_BOOL(_0$$3, 1); ZEPHIR_CALL_METHOD(NULL, model, "skipoperation", NULL, 0, _0$$3); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_1$$3, model, "readattribute", NULL, 0, field); zephir_check_call_status(); if (!ZEPHIR_IS_EQUAL(_1$$3, value)) { ZEPHIR_INIT_VAR(updateModel); if (zephir_clone(updateModel, model TSRMLS_CC) == FAILURE) { RETURN_MM(); } ZEPHIR_CALL_METHOD(NULL, updateModel, "writeattribute", NULL, 0, field, value); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_2$$6, updateModel, "save", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_2$$6))) { ZEPHIR_CALL_METHOD(&_3$$7, updateModel, "getmessages", NULL, 0); zephir_check_call_status(); zephir_is_iterable(_3$$7, &_5$$7, &_4$$7, 0, 0, "phalcon/mvc/collection/behavior/softdelete.zep", 90); for ( ; zephir_hash_get_current_data_ex(_5$$7, (void**) &_6$$7, &_4$$7) == SUCCESS ; zephir_hash_move_forward_ex(_5$$7, &_4$$7) ) { ZEPHIR_GET_HVALUE(message, _6$$7); ZEPHIR_CALL_METHOD(NULL, model, "appendmessage", &_7, 0, message); zephir_check_call_status(); } RETURN_MM_BOOL(0); } ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", NULL, 0, field, value); zephir_check_call_status(); } } ZEPHIR_MM_RESTORE(); }