/** * Handle the whole command-line tasks */ PHP_METHOD(Phalcon_Cli_Console, handle) { zend_bool _5; int ZEPHIR_LAST_CALL_STATUS; zval *arguments_param = NULL, *dependencyInjector = NULL, *router = NULL, *eventsManager = NULL, *moduleName = NULL, *modules = NULL, *module = NULL, *path = NULL, *className = NULL, *moduleObject = NULL, *dispatcher = NULL, *task = NULL, *_0, *_3 = NULL, *_4 = NULL, *_15 = NULL, *_16 = NULL, *_17, *_1$$4 = NULL, *_2$$4, *_6$$6, *_7$$10 = NULL, *_8$$10, *_9$$12, *_10$$12, *_11$$15, *_12$$15, *_13$$17 = NULL, *_14$$17, *_18$$19 = NULL, *_19$$19, *_20$$21; zval *arguments = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &arguments_param); if (!arguments_param) { ZEPHIR_INIT_VAR(arguments); array_init(arguments); } else { zephir_get_arrval(arguments, arguments_param); } ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_console_exception_ce, "A dependency injection object is required to access internal services", "phalcon/cli/console.zep", 69); return; } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _0); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_2$$4); ZVAL_STRING(_2$$4, "console:boot", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1$$4, eventsManager, "fire", NULL, 0, _2$$4, this_ptr); zephir_check_temp_parameter(_2$$4); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_1$$4)) { RETURN_MM_BOOL(0); } } ZEPHIR_INIT_VAR(_4); ZVAL_STRING(_4, "router", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3, dependencyInjector, "getshared", NULL, 0, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); ZEPHIR_CPY_WRT(router, _3); _5 = !(zephir_fast_count_int(arguments TSRMLS_CC)); if (_5) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_arguments"), PH_NOISY_CC); _5 = zephir_is_true(_0); } if (_5) { _6$$6 = zephir_fetch_nproperty_this(this_ptr, SL("_arguments"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, router, "handle", NULL, 0, _6$$6); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(NULL, router, "handle", NULL, 0, arguments); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&moduleName, router, "getmodulename", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(moduleName))) { ZEPHIR_OBS_NVAR(moduleName); zephir_read_property_this(&moduleName, this_ptr, SL("_defaultModule"), PH_NOISY_CC); } if (zephir_is_true(moduleName)) { if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_8$$10); ZVAL_STRING(_8$$10, "console:beforeStartModule", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_7$$10, eventsManager, "fire", NULL, 0, _8$$10, this_ptr, moduleName); zephir_check_temp_parameter(_8$$10); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_7$$10)) { RETURN_MM_BOOL(0); } } ZEPHIR_OBS_VAR(modules); zephir_read_property_this(&modules, this_ptr, SL("_modules"), PH_NOISY_CC); if (!(zephir_array_isset(modules, moduleName))) { ZEPHIR_INIT_VAR(_9$$12); object_init_ex(_9$$12, phalcon_cli_console_exception_ce); ZEPHIR_INIT_VAR(_10$$12); ZEPHIR_CONCAT_SVS(_10$$12, "Module '", moduleName, "' isn't registered in the console container"); ZEPHIR_CALL_METHOD(NULL, _9$$12, "__construct", NULL, 9, _10$$12); zephir_check_call_status(); zephir_throw_exception_debug(_9$$12, "phalcon/cli/console.zep", 109 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_OBS_VAR(module); zephir_array_fetch(&module, modules, moduleName, PH_NOISY, "phalcon/cli/console.zep", 112 TSRMLS_CC); if (Z_TYPE_P(module) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_console_exception_ce, "Invalid module definition path", "phalcon/cli/console.zep", 114); return; } ZEPHIR_OBS_VAR(path); if (zephir_array_isset_string_fetch(&path, module, SS("path"), 0 TSRMLS_CC)) { if (!((zephir_file_exists(path TSRMLS_CC) == SUCCESS))) { ZEPHIR_INIT_VAR(_11$$15); object_init_ex(_11$$15, phalcon_cli_console_exception_ce); ZEPHIR_INIT_VAR(_12$$15); ZEPHIR_CONCAT_SVS(_12$$15, "Module definition path '", path, "' doesn't exist"); ZEPHIR_CALL_METHOD(NULL, _11$$15, "__construct", NULL, 9, _12$$15); zephir_check_call_status(); zephir_throw_exception_debug(_11$$15, "phalcon/cli/console.zep", 119 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (zephir_require_zval(path TSRMLS_CC) == FAILURE) { RETURN_MM_NULL(); } } ZEPHIR_OBS_VAR(className); if (!(zephir_array_isset_string_fetch(&className, module, SS("className"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(className); ZVAL_STRING(className, "Module", 1); } ZEPHIR_CALL_METHOD(&moduleObject, dependencyInjector, "get", NULL, 0, className); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, moduleObject, "registerautoloaders", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, moduleObject, "registerservices", NULL, 0, dependencyInjector); zephir_check_call_status(); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_14$$17); ZVAL_STRING(_14$$17, "console:afterStartModule", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_13$$17, eventsManager, "fire", NULL, 0, _14$$17, this_ptr, moduleObject); zephir_check_temp_parameter(_14$$17); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_13$$17)) { RETURN_MM_BOOL(0); } } } ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "dispatcher", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3, dependencyInjector, "getshared", NULL, 0, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); ZEPHIR_CPY_WRT(dispatcher, _3); ZEPHIR_CALL_METHOD(&_3, router, "gettaskname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, dispatcher, "settaskname", NULL, 0, _3); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_15, router, "getactionname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, dispatcher, "setactionname", NULL, 0, _15); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_16, router, "getparams", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, dispatcher, "setparams", NULL, 0, _16); zephir_check_call_status(); _17 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, dispatcher, "setoptions", NULL, 0, _17); zephir_check_call_status(); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_19$$19); ZVAL_STRING(_19$$19, "console:beforeHandleTask", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_18$$19, eventsManager, "fire", NULL, 0, _19$$19, this_ptr, dispatcher); zephir_check_temp_parameter(_19$$19); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_18$$19)) { RETURN_MM_BOOL(0); } } ZEPHIR_CALL_METHOD(&task, dispatcher, "dispatch", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_20$$21); ZVAL_STRING(_20$$21, "console:afterHandleTask", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _20$$21, this_ptr, task); zephir_check_temp_parameter(_20$$21); zephir_check_call_status(); } RETURN_CCTOR(task); }
/** * Connect: Establish connection to a database * @param string hostname Hostname[:port] overriding datasource specs [optional] * @param string username Username overriding datasource specs [optional] * @param string passname Password overriding datasource specs [optional] * @param string database Database name overriding datasource specsString [optional] * @return boolean */ PHP_METHOD(ADOdb_Connection, connect) { zend_function *_6 = NULL; HashTable *_4; HashPosition _3; zval *hostname_param = NULL, *username_param = NULL, *password_param = NULL, *database_param = NULL, *options = NULL, *_0, *_1, *_2, *option = NULL, *value = NULL, **_5; zval *hostname = NULL, *username = NULL, *password = NULL, *database = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 5, &hostname_param, &username_param, &password_param, &database_param, &options); if (!hostname_param) { ZEPHIR_INIT_VAR(hostname); ZVAL_EMPTY_STRING(hostname); } else { zephir_get_strval(hostname, hostname_param); } if (!username_param) { ZEPHIR_INIT_VAR(username); ZVAL_EMPTY_STRING(username); } else { zephir_get_strval(username, username_param); } if (!password_param) { ZEPHIR_INIT_VAR(password); ZVAL_EMPTY_STRING(password); } else { zephir_get_strval(password, password_param); } if (!database_param) { ZEPHIR_INIT_VAR(database); ZVAL_EMPTY_STRING(database); } else { zephir_get_strval(database, database_param); } if (!options) { ZEPHIR_INIT_VAR(options); array_init(options); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("connection"), PH_NOISY_CC); if (zephir_is_true(_0)) { RETURN_MM_BOOL(0); } if (hostname && Z_STRLEN_P(hostname)) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("dso"), PH_NOISY_CC); zephir_call_method_p1_noret(_1, "sethostname", hostname); } if (username && Z_STRLEN_P(username)) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("dso"), PH_NOISY_CC); zephir_call_method_p1_noret(_1, "setusername", username); } if (password && Z_STRLEN_P(password)) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("dso"), PH_NOISY_CC); zephir_call_method_p1_noret(_1, "setpassword", password); } if (database && Z_STRLEN_P(database)) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("dso"), PH_NOISY_CC); zephir_call_method_p1_noret(_1, "setdatabase", database); } ZEPHIR_INIT_VAR(_2); _1 = zephir_fetch_nproperty_this(this_ptr, SL("dso"), PH_NOISY_CC); zephir_call_static_p1(_2, "ADOdb\\Driver\\DriverManager", "create", _1); zephir_update_property_this(this_ptr, SL("connection"), _2 TSRMLS_CC); zephir_is_iterable(options, &_4, &_3, 0, 0); for ( ; zend_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zephir_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HMKEY(option, _4, _3); ZEPHIR_GET_HVALUE(value, _5); zephir_call_method_p2_cache_noret(this_ptr, "setattribute", &_6, option, value); } RETURN_MM_BOOL(1); }
/** * We have to cast values manually because parse_ini_file() has a poor implementation. * * @param mixed ini The array casted by `parse_ini_file` */ PHP_METHOD(Phalcon_Config_Adapter_Ini, _cast) { zend_bool _5$$5, _6$$5, _8$$5, _9$$5; HashTable *_1$$3; HashPosition _0$$3; zephir_fcall_cache_entry *_4 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *ini, *key = NULL, *val = NULL, **_2$$3, *_3$$4 = NULL, *_7$$5, *_10$$5, *_11$$9, *_12$$9, _13$$9; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &ini); ZEPHIR_SEPARATE_PARAM(ini); if (Z_TYPE_P(ini) == IS_ARRAY) { zephir_is_iterable(ini, &_1$$3, &_0$$3, 1, 0, "phalcon/config/adapter/ini.zep", 148); for ( ; zephir_hash_get_current_data_ex(_1$$3, (void**) &_2$$3, &_0$$3) == SUCCESS ; zephir_hash_move_forward_ex(_1$$3, &_0$$3) ) { ZEPHIR_GET_HMKEY(key, _1$$3, _0$$3); ZEPHIR_GET_HVALUE(val, _2$$3); ZEPHIR_CALL_METHOD(&_3$$4, this_ptr, "_cast", &_4, 137, val); zephir_check_call_status(); zephir_array_update_zval(&ini, key, &_3$$4, PH_COPY | PH_SEPARATE); } zend_hash_destroy(_1$$3); FREE_HASHTABLE(_1$$3); } if (Z_TYPE_P(ini) == IS_STRING) { _5$$5 = ZEPHIR_IS_STRING_IDENTICAL(ini, "true"); if (!(_5$$5)) { _5$$5 = ZEPHIR_IS_STRING_IDENTICAL(ini, "yes"); } _6$$5 = _5$$5; if (!(_6$$5)) { ZEPHIR_INIT_VAR(_7$$5); zephir_fast_strtolower(_7$$5, ini); _6$$5 = ZEPHIR_IS_STRING_IDENTICAL(_7$$5, "on"); } if (_6$$5) { RETURN_MM_BOOL(1); } _8$$5 = ZEPHIR_IS_STRING_IDENTICAL(ini, "false"); if (!(_8$$5)) { _8$$5 = ZEPHIR_IS_STRING_IDENTICAL(ini, "no"); } _9$$5 = _8$$5; if (!(_9$$5)) { ZEPHIR_INIT_VAR(_10$$5); zephir_fast_strtolower(_10$$5, ini); _9$$5 = ZEPHIR_IS_STRING_IDENTICAL(_10$$5, "off"); } if (_9$$5) { RETURN_MM_BOOL(0); } if (ZEPHIR_IS_STRING_IDENTICAL(ini, "null")) { RETURN_MM_NULL(); } if (zephir_is_numeric(ini)) { ZEPHIR_INIT_VAR(_11$$9); ZEPHIR_INIT_VAR(_12$$9); ZEPHIR_SINIT_VAR(_13$$9); ZVAL_STRING(&_13$$9, "/[.]+/", 0); zephir_preg_match(_12$$9, &_13$$9, ini, _11$$9, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(_12$$9)) { RETURN_MM_DOUBLE(zephir_get_doubleval(ini)); } else { RETURN_MM_LONG(zephir_get_intval(ini)); } } } RETVAL_ZVAL(ini, 1, 0); RETURN_MM(); }
/** * getOctet allow to gets the value of a configuration option in octet * * @return int the value of a configuration option in octet */ PHP_METHOD(Phady_Util_Tools, getOctets) { int size, ZEPHIR_LAST_CALL_STATUS; zval *option, *_0, *_1, _2, *_3, *_4, _5, *_6, *_7, _8, *_9 = NULL, *_10 = NULL, *_11 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &option); ZEPHIR_INIT_VAR(_0); ZEPHIR_INIT_VAR(_1); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "/[0-9]+k/i", 0); zephir_preg_match(_1, &_2, option, _0, 0, 0 , 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_3); ZEPHIR_INIT_VAR(_4); ZEPHIR_SINIT_VAR(_5); ZVAL_STRING(&_5, "/[0-9]+m/i", 0); zephir_preg_match(_4, &_5, option, _3, 0, 0 , 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_6); ZEPHIR_INIT_VAR(_7); ZEPHIR_SINIT_VAR(_8); ZVAL_STRING(&_8, "/[0-9]+g/i", 0); zephir_preg_match(_7, &_8, option, _6, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(_1)) { ZEPHIR_INIT_VAR(_9); ZVAL_STRING(_9, "/m/i", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_10); ZVAL_STRING(_10, "", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&_11, "preg_replace", NULL, 142, _9, _10, option); zephir_check_temp_parameter(_9); zephir_check_temp_parameter(_10); zephir_check_call_status(); size = (zephir_get_intval(_11) * 1024); } else if (zephir_is_true(_4)) { ZEPHIR_INIT_NVAR(_9); ZVAL_STRING(_9, "/m/i", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_10); ZVAL_STRING(_10, "", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&_11, "preg_replace", NULL, 142, _9, _10, option); zephir_check_temp_parameter(_9); zephir_check_temp_parameter(_10); zephir_check_call_status(); size = (1048576 * zephir_get_intval(_11)); } else if (zephir_is_true(_7)) { ZEPHIR_INIT_NVAR(_9); ZVAL_STRING(_9, "/g/i", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_10); ZVAL_STRING(_10, "", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&_11, "preg_replace", NULL, 142, _9, _10, option); zephir_check_temp_parameter(_9); zephir_check_temp_parameter(_10); zephir_check_call_status(); size = ((1048576 * 1024) * zephir_get_intval(_11)); } else { size = zephir_get_numberval(option); } RETURN_MM_LONG(size); }
/** * Returns an array of Phalcon\Db\Column objects describing a table * * <code> * print_r($connection->describeColumns("posts")); * </code> */ PHP_METHOD(Phalcon_Db_Adapter_Pdo_Mysql, describeColumns) { zephir_fcall_cache_entry *_15 = 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, *sizePattern, *matches = NULL, *matchOne = NULL, *matchTwo = NULL, *columnName, *_0 = NULL, *_1, *_2 = NULL, *_3 = NULL, **_6, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_10, *_11, *_12, *_13 = NULL, *_14; 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/mysql.zep", 329); 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/mysql.zep", 111 TSRMLS_CC); while (1) { if (zephir_memnstr_str(columnType, SL("bigint"), "phalcon/db/adapter/pdo/mysql.zep", 118)) { ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 14); zephir_array_update_string(&definition, SL("type"), &_3, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 1); zephir_array_update_string(&definition, SL("bindType"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("int"), "phalcon/db/adapter/pdo/mysql.zep", 128)) { 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_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("varchar"), "phalcon/db/adapter/pdo/mysql.zep", 138)) { 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("datetime"), "phalcon/db/adapter/pdo/mysql.zep", 146)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 4); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("enum"), "phalcon/db/adapter/pdo/mysql.zep", 154)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 5); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("char"), "phalcon/db/adapter/pdo/mysql.zep", 162)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 5); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("date"), "phalcon/db/adapter/pdo/mysql.zep", 170)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 1); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("text"), "phalcon/db/adapter/pdo/mysql.zep", 178)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 6); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("decimal"), "phalcon/db/adapter/pdo/mysql.zep", 186)) { 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_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("double"), "phalcon/db/adapter/pdo/mysql.zep", 196)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 9); 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_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("float"), "phalcon/db/adapter/pdo/mysql.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_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("bit"), "phalcon/db/adapter/pdo/mysql.zep", 216)) { 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, 5); zephir_array_update_string(&definition, SL("bindType"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("tinyblob"), "phalcon/db/adapter/pdo/mysql.zep", 225)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 10); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 5); zephir_array_update_string(&definition, SL("bindType"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("mediumblob"), "phalcon/db/adapter/pdo/mysql.zep", 234)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 12); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("longblob"), "phalcon/db/adapter/pdo/mysql.zep", 242)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 13); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("blob"), "phalcon/db/adapter/pdo/mysql.zep", 250)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 11); zephir_array_update_string(&definition, SL("type"), &_7, 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("("), "phalcon/db/adapter/pdo/mysql.zep", 265)) { ZEPHIR_INIT_NVAR(matches); ZVAL_NULL(matches); ZEPHIR_INIT_NVAR(_8); zephir_preg_match(_8, sizePattern, columnType, matches, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(_8)) { ZEPHIR_OBS_NVAR(matchOne); if (zephir_array_isset_long_fetch(&matchOne, matches, 1, 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_9); ZVAL_LONG(_9, zephir_get_intval(matchOne)); zephir_array_update_string(&definition, SL("size"), &_9, PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_NVAR(matchTwo); if (zephir_array_isset_long_fetch(&matchTwo, matches, 2, 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_9); ZVAL_LONG(_9, zephir_get_intval(matchTwo)); zephir_array_update_string(&definition, SL("scale"), &_9, PH_COPY | PH_SEPARATE); } } } if (zephir_memnstr_str(columnType, SL("unsigned"), "phalcon/db/adapter/pdo/mysql.zep", 280)) { 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, 3, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 296 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, 2, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 303 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, 5, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 310 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, 4, PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 317 TSRMLS_CC); if (Z_TYPE_P(_13) != IS_NULL) { zephir_array_fetch_long(&_14, field, 4, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 318 TSRMLS_CC); zephir_array_update_string(&definition, SL("default"), &_14, PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&columnName, field, 0, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 324 TSRMLS_CC); ZEPHIR_INIT_NVAR(_7); object_init_ex(_7, phalcon_db_column_ce); ZEPHIR_CALL_METHOD(NULL, _7, "__construct", &_15, 140, columnName, definition); zephir_check_call_status(); zephir_array_append(&columns, _7, PH_SEPARATE, "phalcon/db/adapter/pdo/mysql.zep", 325); ZEPHIR_CPY_WRT(oldColumn, columnName); } RETURN_CCTOR(columns); }
/** * Sets the HTTP response code * *<code> * $response->setStatusCode(404, "Not Found"); *</code> */ PHP_METHOD(Phalcon_Http_Response, setStatusCode) { zval *_10; zephir_fcall_cache_entry *_7 = NULL, *_8 = NULL; zend_bool _4; HashTable *_2; HashPosition _1; zval *message = NULL, *_13, *_15; zval *code_param = NULL, *message_param = NULL, *headers = NULL, *currentHeadersRaw = NULL, *key = NULL, *defaultMessage, *_0 = NULL, **_3, _5 = zval_used_for_init, *_6 = NULL, *_9, *_11, *_12, _14; int code, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &code_param, &message_param); code = zephir_get_intval(code_param); if (!message_param) { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } else { zephir_get_strval(message, message_param); } ZEPHIR_CALL_METHOD(&headers, this_ptr, "getheaders", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(¤tHeadersRaw, headers, "toarray", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(currentHeadersRaw) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_is_iterable(currentHeadersRaw, &_2, &_1, 0, 0, "phalcon/http/response.zep", 130); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(key, _2, _1); ZEPHIR_GET_HVALUE(_0, _3); _4 = Z_TYPE_P(key) == IS_STRING; if (_4) { ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "HTTP/", 0); ZEPHIR_CALL_FUNCTION(&_6, "strstr", &_7, 235, key, &_5); zephir_check_call_status(); _4 = zephir_is_true(_6); } if (_4) { ZEPHIR_CALL_METHOD(NULL, headers, "remove", &_8, 0, key); zephir_check_call_status(); } } } if (ZEPHIR_IS_STRING_IDENTICAL(message, "")) { ZEPHIR_OBS_VAR(_9); zephir_read_property_this(&_9, this_ptr, SL("_statusCodes"), PH_NOISY_CC); if (Z_TYPE_P(_9) != IS_ARRAY) { ZEPHIR_INIT_VAR(_10); zephir_create_array(_10, 59, 0 TSRMLS_CC); add_index_stringl(_10, 100, SL("Continue"), 1); add_index_stringl(_10, 101, SL("Switching Protocols"), 1); add_index_stringl(_10, 102, SL("Processing"), 1); add_index_stringl(_10, 200, SL("OK"), 1); add_index_stringl(_10, 201, SL("Created"), 1); add_index_stringl(_10, 202, SL("Accepted"), 1); add_index_stringl(_10, 203, SL("Non-Authoritative Information"), 1); add_index_stringl(_10, 204, SL("No Content"), 1); add_index_stringl(_10, 205, SL("Reset Content"), 1); add_index_stringl(_10, 206, SL("Partial Content"), 1); add_index_stringl(_10, 207, SL("Multi-status"), 1); add_index_stringl(_10, 208, SL("Already Reported"), 1); add_index_stringl(_10, 300, SL("Multiple Choices"), 1); add_index_stringl(_10, 301, SL("Moved Permanently"), 1); add_index_stringl(_10, 302, SL("Found"), 1); add_index_stringl(_10, 303, SL("See Other"), 1); add_index_stringl(_10, 304, SL("Not Modified"), 1); add_index_stringl(_10, 305, SL("Use Proxy"), 1); add_index_stringl(_10, 306, SL("Switch Proxy"), 1); add_index_stringl(_10, 307, SL("Temporary Redirect"), 1); add_index_stringl(_10, 400, SL("Bad Request"), 1); add_index_stringl(_10, 401, SL("Unauthorized"), 1); add_index_stringl(_10, 402, SL("Payment Required"), 1); add_index_stringl(_10, 403, SL("Forbidden"), 1); add_index_stringl(_10, 404, SL("Not Found"), 1); add_index_stringl(_10, 405, SL("Method Not Allowed"), 1); add_index_stringl(_10, 406, SL("Not Acceptable"), 1); add_index_stringl(_10, 407, SL("Proxy Authentication Required"), 1); add_index_stringl(_10, 408, SL("Request Time-out"), 1); add_index_stringl(_10, 409, SL("Conflict"), 1); add_index_stringl(_10, 410, SL("Gone"), 1); add_index_stringl(_10, 411, SL("Length Required"), 1); add_index_stringl(_10, 412, SL("Precondition Failed"), 1); add_index_stringl(_10, 413, SL("Request Entity Too Large"), 1); add_index_stringl(_10, 414, SL("Request-URI Too Large"), 1); add_index_stringl(_10, 415, SL("Unsupported Media Type"), 1); add_index_stringl(_10, 416, SL("Requested range not satisfiable"), 1); add_index_stringl(_10, 417, SL("Expectation Failed"), 1); add_index_stringl(_10, 418, SL("I'm a teapot"), 1); add_index_stringl(_10, 422, SL("Unprocessable Entity"), 1); add_index_stringl(_10, 423, SL("Locked"), 1); add_index_stringl(_10, 424, SL("Failed Dependency"), 1); add_index_stringl(_10, 425, SL("Unordered Collection"), 1); add_index_stringl(_10, 426, SL("Upgrade Required"), 1); add_index_stringl(_10, 428, SL("Precondition Required"), 1); add_index_stringl(_10, 429, SL("Too Many Requests"), 1); add_index_stringl(_10, 431, SL("Request Header Fields Too Large"), 1); add_index_stringl(_10, 500, SL("Internal Server Error"), 1); add_index_stringl(_10, 501, SL("Not Implemented"), 1); add_index_stringl(_10, 502, SL("Bad Gateway"), 1); add_index_stringl(_10, 503, SL("Service Unavailable"), 1); add_index_stringl(_10, 504, SL("Gateway Time-out"), 1); add_index_stringl(_10, 505, SL("HTTP Version not supported"), 1); add_index_stringl(_10, 506, SL("Variant Also Negotiates"), 1); add_index_stringl(_10, 507, SL("Insufficient Storage"), 1); add_index_stringl(_10, 508, SL("Loop Detected"), 1); add_index_stringl(_10, 511, SL("Network Authentication Required"), 1); zephir_update_property_this(this_ptr, SL("_statusCodes"), _10 TSRMLS_CC); } _11 = zephir_fetch_nproperty_this(this_ptr, SL("_statusCodes"), PH_NOISY_CC); if (!(zephir_array_isset_long(_11, code))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_response_exception_ce, "Non-standard statuscode given without a message", "phalcon/http/response.zep", 204); return; } _12 = zephir_fetch_nproperty_this(this_ptr, SL("_statusCodes"), PH_NOISY_CC); ZEPHIR_OBS_VAR(defaultMessage); zephir_array_fetch_long(&defaultMessage, _12, code, PH_NOISY, "phalcon/http/response.zep", 207 TSRMLS_CC); zephir_get_strval(message, defaultMessage); } ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, code); ZEPHIR_INIT_VAR(_13); ZEPHIR_CONCAT_SVSV(_13, "HTTP/1.1 ", &_5, " ", message); ZEPHIR_CALL_METHOD(NULL, headers, "setraw", NULL, 0, _13); zephir_check_call_status(); ZEPHIR_SINIT_VAR(_14); ZVAL_LONG(&_14, code); ZEPHIR_INIT_VAR(_15); ZEPHIR_CONCAT_VSV(_15, &_14, " ", message); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "Status", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, headers, "set", NULL, 0, _0, _15); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_THIS(); }
/** * Generates a URL * *<code> * // Generate a URL appending the URI to the base URI * echo $url->get("products/edit/1"); * * // Generate a URL for a predefined route * echo $url->get( * [ * "for" => "blog-post", * "title" => "some-cool-stuff", * "year" => "2015", * ] * ); * * // Generate a URL with GET arguments (/show/products?id=1&name=Carrots) * echo $url->get( * "show/products", * [ * "id" => 1, * "name" => "Carrots", * ] * ); * * // Generate an absolute URL by setting the third parameter as false. * echo $url->get( * "https://phalconphp.com/", * null, * false * ); *</code> */ PHP_METHOD(Phalcon_Mvc_Url, get) { unsigned char _20$$14, _22$$14, _27$$16; zval strUri, _15$$14; zend_long ZEPHIR_LAST_CALL_STATUS; zend_bool local, _0$$3, _1$$3, _18$$14, _19$$14, _21$$14, _25$$16, _26$$16, _28$$19; zval *uri = NULL, uri_sub, *args = NULL, args_sub, *local_param = NULL, *baseUri = NULL, baseUri_sub, __$null, router, dependencyInjector, routeName, route, queryString, _2$$4, _3$$4, _4$$4, _5$$4, _6$$9, _10$$9, _13$$9, _14$$9, _7$$11, _8$$11, _9$$11, _11$$13, _12$$13, _16$$14, _17$$14, _23$$15, _24$$15, _29$$20, _30$$20, _31$$21, _32$$22; zval *this_ptr = getThis(); ZVAL_UNDEF(&uri_sub); ZVAL_UNDEF(&args_sub); ZVAL_UNDEF(&baseUri_sub); ZVAL_NULL(&__$null); ZVAL_UNDEF(&router); ZVAL_UNDEF(&dependencyInjector); ZVAL_UNDEF(&routeName); ZVAL_UNDEF(&route); ZVAL_UNDEF(&queryString); ZVAL_UNDEF(&_2$$4); ZVAL_UNDEF(&_3$$4); ZVAL_UNDEF(&_4$$4); ZVAL_UNDEF(&_5$$4); ZVAL_UNDEF(&_6$$9); ZVAL_UNDEF(&_10$$9); ZVAL_UNDEF(&_13$$9); ZVAL_UNDEF(&_14$$9); ZVAL_UNDEF(&_7$$11); ZVAL_UNDEF(&_8$$11); ZVAL_UNDEF(&_9$$11); ZVAL_UNDEF(&_11$$13); ZVAL_UNDEF(&_12$$13); ZVAL_UNDEF(&_16$$14); ZVAL_UNDEF(&_17$$14); ZVAL_UNDEF(&_23$$15); ZVAL_UNDEF(&_24$$15); ZVAL_UNDEF(&_29$$20); ZVAL_UNDEF(&_30$$20); ZVAL_UNDEF(&_31$$21); ZVAL_UNDEF(&_32$$22); ZVAL_UNDEF(&strUri); ZVAL_UNDEF(&_15$$14); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 4, &uri, &args, &local_param, &baseUri); if (!uri) { uri = &uri_sub; ZEPHIR_CPY_WRT(uri, &__$null); } else { ZEPHIR_SEPARATE_PARAM(uri); } if (!args) { args = &args_sub; args = &__$null; } if (!local_param) { local = 0; } else { local = zephir_get_boolval(local_param); } if (!baseUri) { baseUri = &baseUri_sub; ZEPHIR_CPY_WRT(baseUri, &__$null); } else { ZEPHIR_SEPARATE_PARAM(baseUri); } if (local == 0) { _0$$3 = Z_TYPE_P(uri) == IS_STRING; if (_0$$3) { _1$$3 = zephir_memnstr_str(uri, SL("//"), "phalcon/mvc/url.zep", 103); if (!(_1$$3)) { _1$$3 = zephir_memnstr_str(uri, SL(":"), "phalcon/mvc/url.zep", 103); } _0$$3 = _1$$3; } if (_0$$3) { ZEPHIR_INIT_VAR(&_2$$4); ZEPHIR_INIT_VAR(&_3$$4); ZVAL_STRING(&_3$$4, "#^((//)|([a-z0-9]+://)|([a-z0-9]+:))#i"); ZEPHIR_INIT_VAR(&_4$$4); ZEPHIR_INIT_VAR(&_5$$4); ZVAL_STRING(&_5$$4, "#^((//)|([a-z0-9]+://)|([a-z0-9]+:))#i"); zephir_preg_match(&_4$$4, &_5$$4, uri, &_2$$4, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(&_4$$4)) { local = 0; } else { local = 1; } } else { local = 1; } } if (Z_TYPE_P(baseUri) != IS_STRING) { ZEPHIR_CALL_METHOD(baseUri, this_ptr, "getbaseuri", NULL, 0); zephir_check_call_status(); } if (Z_TYPE_P(uri) == IS_ARRAY) { ZEPHIR_OBS_VAR(&routeName); if (!(zephir_array_isset_string_fetch(&routeName, uri, SL("for"), 0))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_url_exception_ce, "It's necessary to define the route name with the parameter 'for'", "phalcon/mvc/url.zep", 121); return; } zephir_read_property(&_6$$9, this_ptr, SL("router"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CPY_WRT(&router, &_6$$9); if (Z_TYPE_P(&router) != IS_OBJECT) { zephir_read_property(&_7$$11, this_ptr, SL("container"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CPY_WRT(&dependencyInjector, &_7$$11); if (Z_TYPE_P(&dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_url_exception_ce, "A dependency injector container is required to obtain the 'router' service", "phalcon/mvc/url.zep", 133); return; } ZEPHIR_INIT_VAR(&_9$$11); ZVAL_STRING(&_9$$11, "router"); ZEPHIR_CALL_METHOD(&_8$$11, &dependencyInjector, "getshared", NULL, 0, &_9$$11); zephir_check_call_status(); ZEPHIR_CPY_WRT(&router, &_8$$11); zephir_update_property_zval(this_ptr, SL("router"), &router); } ZEPHIR_CALL_METHOD(&_10$$9, &router, "getroutebyname", NULL, 0, &routeName); zephir_check_call_status(); ZEPHIR_CPY_WRT(&route, &_10$$9); if (Z_TYPE_P(&route) != IS_OBJECT) { ZEPHIR_INIT_VAR(&_11$$13); object_init_ex(&_11$$13, phalcon_mvc_url_exception_ce); ZEPHIR_INIT_VAR(&_12$$13); ZEPHIR_CONCAT_SVS(&_12$$13, "Cannot obtain a route using the name '", &routeName, "'"); ZEPHIR_CALL_METHOD(NULL, &_11$$13, "__construct", NULL, 4, &_12$$13); zephir_check_call_status(); zephir_throw_exception_debug(&_11$$13, "phalcon/mvc/url.zep", 145 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&_13$$9); ZEPHIR_CALL_METHOD(&_10$$9, &route, "getpattern", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_14$$9, &route, "getreversedpaths", NULL, 0); zephir_check_call_status(); phalcon_replace_paths(&_13$$9, &_10$$9, &_14$$9, uri TSRMLS_CC); ZEPHIR_CPY_WRT(uri, &_13$$9); } if (local) { zephir_get_strval(&_15$$14, uri); ZEPHIR_CPY_WRT(&strUri, &_15$$14); ZVAL_LONG(&_16$$14, -1); ZEPHIR_INIT_VAR(&_17$$14); zephir_substr(&_17$$14, baseUri, -1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); _18$$14 = ZEPHIR_IS_STRING(&_17$$14, "/"); if (_18$$14) { _18$$14 = zephir_fast_strlen_ev(&strUri) > 2; } _19$$14 = _18$$14; if (_19$$14) { _20$$14 = ZEPHIR_STRING_OFFSET(&strUri, 0); _19$$14 = _20$$14 == '/'; } _21$$14 = _19$$14; if (_21$$14) { _22$$14 = ZEPHIR_STRING_OFFSET(&strUri, 1); _21$$14 = _22$$14 != '/'; } if (_21$$14) { ZVAL_LONG(&_23$$15, 1); ZEPHIR_INIT_VAR(&_24$$15); zephir_substr(&_24$$15, &strUri, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); ZEPHIR_INIT_NVAR(uri); ZEPHIR_CONCAT_VV(uri, baseUri, &_24$$15); } else { _25$$16 = ZEPHIR_IS_STRING(baseUri, "/"); if (_25$$16) { _25$$16 = zephir_fast_strlen_ev(&strUri) == 1; } _26$$16 = _25$$16; if (_26$$16) { _27$$16 = ZEPHIR_STRING_OFFSET(&strUri, 0); _26$$16 = _27$$16 == '/'; } if (_26$$16) { ZEPHIR_CPY_WRT(uri, baseUri); } else { ZEPHIR_INIT_NVAR(uri); ZEPHIR_CONCAT_VV(uri, baseUri, &strUri); } } } if (zephir_is_true(args)) { ZEPHIR_CALL_FUNCTION(&queryString, "http_build_query", NULL, 372, args); zephir_check_call_status(); _28$$19 = Z_TYPE_P(&queryString) == IS_STRING; if (_28$$19) { _28$$19 = ((zephir_fast_strlen_ev(&queryString)) ? 1 : 0); } if (_28$$19) { ZEPHIR_INIT_VAR(&_29$$20); ZVAL_STRING(&_29$$20, "?"); ZEPHIR_INIT_VAR(&_30$$20); zephir_fast_strpos(&_30$$20, uri, &_29$$20, 0 ); if (!ZEPHIR_IS_FALSE_IDENTICAL(&_30$$20)) { ZEPHIR_INIT_VAR(&_31$$21); ZEPHIR_CONCAT_SV(&_31$$21, "&", &queryString); zephir_concat_self(uri, &_31$$21 TSRMLS_CC); } else { ZEPHIR_INIT_VAR(&_32$$22); ZEPHIR_CONCAT_SV(&_32$$22, "?", &queryString); zephir_concat_self(uri, &_32$$22 TSRMLS_CC); } } } RETVAL_ZVAL(uri, 1, 0); RETURN_MM(); }
/** * Detach the listener from the events manager * * @param string eventType * @param object handler */ PHP_METHOD(Phalcon_Events_Manager, detach) { zephir_fcall_cache_entry *_3 = NULL, *_4 = NULL, *_8 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *eventType_param = NULL, *handler, *priorityQueue = NULL, *newPriorityQueue = NULL, *key = NULL, *data = NULL, *_0, *_1$$5 = NULL, *_2$$5 = NULL, *_5$$6, *_6$$7, *_7$$7; zval *eventType = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &eventType_param, &handler); if (unlikely(Z_TYPE_P(eventType_param) != IS_STRING && Z_TYPE_P(eventType_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventType' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(eventType_param) == IS_STRING)) { zephir_get_strval(eventType, eventType_param); } else { ZEPHIR_INIT_VAR(eventType); ZVAL_EMPTY_STRING(eventType); } if (Z_TYPE_P(handler) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_events_exception_ce, "Event handler must be an Object", "phalcon/events/manager.zep", 99); return; } ZEPHIR_OBS_VAR(priorityQueue); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_events"), PH_NOISY_CC); if (zephir_array_isset_fetch(&priorityQueue, _0, eventType, 0 TSRMLS_CC)) { if (Z_TYPE_P(priorityQueue) == IS_OBJECT) { ZEPHIR_INIT_VAR(newPriorityQueue); object_init_ex(newPriorityQueue, spl_ce_SplPriorityQueue); if (zephir_has_constructor(newPriorityQueue TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, newPriorityQueue, "__construct", NULL, 0); zephir_check_call_status(); } ZEPHIR_INIT_VAR(_1$$5); ZVAL_LONG(_1$$5, 1); ZEPHIR_CALL_METHOD(NULL, newPriorityQueue, "setextractflags", NULL, 190, _1$$5); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_1$$5); ZVAL_LONG(_1$$5, 3); ZEPHIR_CALL_METHOD(NULL, priorityQueue, "setextractflags", NULL, 0, _1$$5); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, priorityQueue, "top", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_2$$5, priorityQueue, "valid", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_2$$5))) { break; } ZEPHIR_CALL_METHOD(&data, priorityQueue, "current", &_3, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, priorityQueue, "next", &_4, 0); zephir_check_call_status(); zephir_array_fetch_string(&_5$$6, data, SL("data"), PH_NOISY | PH_READONLY, "phalcon/events/manager.zep", 116 TSRMLS_CC); if (!ZEPHIR_IS_IDENTICAL(_5$$6, handler)) { zephir_array_fetch_string(&_6$$7, data, SL("data"), PH_NOISY | PH_READONLY, "phalcon/events/manager.zep", 117 TSRMLS_CC); zephir_array_fetch_string(&_7$$7, data, SL("priority"), PH_NOISY | PH_READONLY, "phalcon/events/manager.zep", 117 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, newPriorityQueue, "insert", &_8, 191, _6$$7, _7$$7); zephir_check_call_status(); } } zephir_update_property_array(this_ptr, SL("_events"), eventType, newPriorityQueue TSRMLS_CC); } else { ZEPHIR_CALL_FUNCTION(&key, "array_search", NULL, 192, handler, priorityQueue, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); if (!ZEPHIR_IS_FALSE_IDENTICAL(key)) { zephir_array_unset(&priorityQueue, key, PH_SEPARATE); } zephir_update_property_array(this_ptr, SL("_events"), eventType, priorityQueue TSRMLS_CC); } } ZEPHIR_MM_RESTORE(); }
/** * Internal handler to call a queue of events * * @param \SplPriorityQueue|array queue * @param \Phalcon\Events\Event event * @return mixed */ PHP_METHOD(Phalcon_Events_Manager, fireQueue) { HashTable *_12$$21; HashPosition _11$$21; zend_bool collect = 0, cancelable = 0; zephir_fcall_cache_entry *_7 = NULL, *_8 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *queue, *event, *status = NULL, *arguments = NULL, *eventName = NULL, *data = NULL, *iterator = NULL, *source = NULL, *handler = NULL, *_4 = NULL, *_5, *_0$$5, *_1$$5, _2$$5, *_3$$5 = NULL, *_6$$8 = NULL, *_9$$14 = NULL, *_10$$19 = NULL, **_13$$21, *_14$$27 = NULL, *_15$$32 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &queue, &event); if (Z_TYPE_P(queue) != IS_ARRAY) { if (Z_TYPE_P(queue) == IS_OBJECT) { if (!(zephir_instance_of_ev(queue, spl_ce_SplPriorityQueue TSRMLS_CC))) { ZEPHIR_INIT_VAR(_0$$5); object_init_ex(_0$$5, phalcon_events_exception_ce); ZEPHIR_INIT_VAR(_1$$5); zephir_get_class(_1$$5, queue, 0 TSRMLS_CC); ZEPHIR_SINIT_VAR(_2$$5); ZVAL_STRING(&_2$$5, "Unexpected value type: expected object of type SplPriorityQueue, %s given", 0); ZEPHIR_CALL_FUNCTION(&_3$$5, "sprintf", NULL, 193, &_2$$5, _1$$5); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, _0$$5, "__construct", NULL, 9, _3$$5); zephir_check_call_status(); zephir_throw_exception_debug(_0$$5, "phalcon/events/manager.zep", 205 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_events_exception_ce, "The queue is not valid", "phalcon/events/manager.zep", 208); return; } } ZEPHIR_INIT_VAR(status); ZVAL_NULL(status); ZEPHIR_INIT_VAR(arguments); ZVAL_NULL(arguments); ZEPHIR_CALL_METHOD(&eventName, event, "gettype", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(eventName) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_events_exception_ce, "The event type not valid", "phalcon/events/manager.zep", 217); return; } ZEPHIR_CALL_METHOD(&source, event, "getsource", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&data, event, "getdata", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_4, event, "iscancelable", NULL, 0); zephir_check_call_status(); cancelable = zephir_get_boolval(_4); ZEPHIR_OBS_VAR(_5); zephir_read_property_this(&_5, this_ptr, SL("_collect"), PH_NOISY_CC); collect = zephir_get_boolval(_5); if (Z_TYPE_P(queue) == IS_OBJECT) { ZEPHIR_INIT_VAR(iterator); if (zephir_clone(iterator, queue TSRMLS_CC) == FAILURE) { RETURN_MM(); } ZEPHIR_CALL_METHOD(NULL, iterator, "top", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_6$$8, iterator, "valid", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_6$$8))) { break; } ZEPHIR_CALL_METHOD(&handler, iterator, "current", &_7, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, iterator, "next", &_8, 0); zephir_check_call_status(); if (Z_TYPE_P(handler) == IS_OBJECT) { if (zephir_instance_of_ev(handler, zend_ce_closure TSRMLS_CC)) { if (Z_TYPE_P(arguments) == IS_NULL) { ZEPHIR_INIT_NVAR(arguments); zephir_create_array(arguments, 3, 0 TSRMLS_CC); zephir_array_fast_append(arguments, event); zephir_array_fast_append(arguments, source); zephir_array_fast_append(arguments, data); } ZEPHIR_INIT_NVAR(status); ZEPHIR_CALL_USER_FUNC_ARRAY(status, handler, arguments); zephir_check_call_status(); if (collect) { zephir_update_property_array_append(this_ptr, SL("_responses"), status TSRMLS_CC); } if (cancelable) { ZEPHIR_CALL_METHOD(&_9$$14, event, "isstopped", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_9$$14)) { break; } } } else { if ((zephir_method_exists(handler, eventName TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD_ZVAL(&status, handler, eventName, NULL, 0, event, source, data); zephir_check_call_status(); if (collect) { zephir_update_property_array_append(this_ptr, SL("_responses"), status TSRMLS_CC); } if (cancelable) { ZEPHIR_CALL_METHOD(&_10$$19, event, "isstopped", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_10$$19)) { break; } } } } } } } else { zephir_is_iterable(queue, &_12$$21, &_11$$21, 0, 0, "phalcon/events/manager.zep", 353); for ( ; zephir_hash_get_current_data_ex(_12$$21, (void**) &_13$$21, &_11$$21) == SUCCESS ; zephir_hash_move_forward_ex(_12$$21, &_11$$21) ) { ZEPHIR_GET_HVALUE(handler, _13$$21); if (Z_TYPE_P(handler) == IS_OBJECT) { if (zephir_instance_of_ev(handler, zend_ce_closure TSRMLS_CC)) { if (Z_TYPE_P(arguments) == IS_NULL) { ZEPHIR_INIT_NVAR(arguments); zephir_create_array(arguments, 3, 0 TSRMLS_CC); zephir_array_fast_append(arguments, event); zephir_array_fast_append(arguments, source); zephir_array_fast_append(arguments, data); } ZEPHIR_INIT_NVAR(status); ZEPHIR_CALL_USER_FUNC_ARRAY(status, handler, arguments); zephir_check_call_status(); if (collect) { zephir_update_property_array_append(this_ptr, SL("_responses"), status TSRMLS_CC); } if (cancelable) { ZEPHIR_CALL_METHOD(&_14$$27, event, "isstopped", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_14$$27)) { break; } } } else { if ((zephir_method_exists(handler, eventName TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD_ZVAL(&status, handler, eventName, NULL, 0, event, source, data); zephir_check_call_status(); if (collect) { zephir_update_property_array_append(this_ptr, SL("_responses"), status TSRMLS_CC); } if (cancelable) { ZEPHIR_CALL_METHOD(&_15$$32, event, "isstopped", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_15$$32)) { break; } } } } } } } RETURN_CCTOR(status); }
/** * @return array */ PHP_METHOD(Lynx_Annotation_RegexDocParser, parseAnnotations) { zval *_14 = NULL; HashTable *_3, *_8; HashPosition _2, _7; int ZEPHIR_LAST_CALL_STATUS; zephir_nts_static zephir_fcall_cache_entry *_1 = NULL, *_11 = NULL; zval *docComment, *hasAnnotations = NULL, *matches, *anno = NULL, *annoName = NULL, *val = NULL, *hasParams = NULL, *params, *param = NULL, *rex, *_0 = NULL, *annotations, **_4, *_5, *regex1, *_6, **_9, *_10 = NULL, *_12, *_13 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &docComment); ZEPHIR_INIT_VAR(matches); array_init(matches); ZEPHIR_INIT_VAR(params); array_init(params); ZEPHIR_INIT_VAR(rex); ZVAL_STRING(rex, "/@(\\w+)(?:\\s*(?:\\(\\s*)?(.*?)(?:\\s*\\))?)??\\s*(?:\n|\\*\\/)/", 1); ZEPHIR_INIT_VAR(annotations); array_init(annotations); ZEPHIR_INIT_VAR(regex1); ZVAL_STRING(regex1, "/(\\w+)\\s*=\\s*(\\[[^\\]]*\\]|\"[^\"]*\"|[^,)]*)\\s*(?:,|$)/", 1); ZEPHIR_INIT_VAR(val); ZVAL_BOOL(val, 1); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 2); Z_SET_ISREF_P(matches); ZEPHIR_CALL_FUNCTION(&hasAnnotations, "preg_match_all", &_1, rex, docComment, matches, _0); Z_UNSET_ISREF_P(matches); zephir_check_call_status(); if (!zephir_is_true(hasAnnotations)) { array_init(return_value); RETURN_MM(); } zephir_is_iterable(matches, &_3, &_2, 0, 0, "lynx/Annotation/RegexDocParser.zep", 67); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HVALUE(anno, _4); ZEPHIR_INIT_NVAR(annoName); zephir_array_fetch_long(&_5, anno, 1, PH_NOISY | PH_READONLY, "lynx/Annotation/RegexDocParser.zep", 33 TSRMLS_CC); zephir_fast_strtolower(annoName, _5); ZEPHIR_INIT_NVAR(val); ZVAL_BOOL(val, 1); if (zephir_array_isset_long(anno, 2)) { zephir_array_fetch_long(&_6, anno, 2, PH_NOISY | PH_READONLY, "lynx/Annotation/RegexDocParser.zep", 38 TSRMLS_CC); ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 2); Z_SET_ISREF_P(params); ZEPHIR_CALL_FUNCTION(&hasParams, "preg_match_all", &_1, regex1, _6, params, _0); Z_UNSET_ISREF_P(params); zephir_check_call_status(); if (zephir_is_true(hasParams)) { ZEPHIR_INIT_NVAR(val); array_init(val); zephir_is_iterable(params, &_8, &_7, 0, 0, "lynx/Annotation/RegexDocParser.zep", 46); for ( ; zephir_hash_get_current_data_ex(_8, (void**) &_9, &_7) == SUCCESS ; zephir_hash_move_forward_ex(_8, &_7) ) { ZEPHIR_GET_HVALUE(param, _9); zephir_array_fetch_long(&_12, param, 2, PH_NOISY | PH_READONLY, "lynx/Annotation/RegexDocParser.zep", 43 TSRMLS_CC); ZEPHIR_CALL_SELF(&_10, "parsevalue", &_11, _12); zephir_check_call_status(); ZEPHIR_OBS_NVAR(_13); zephir_array_fetch_long(&_13, param, 1, PH_NOISY, "lynx/Annotation/RegexDocParser.zep", 43 TSRMLS_CC); zephir_array_update_zval(&val, _13, &_10, PH_COPY | PH_SEPARATE); } } else { ZEPHIR_INIT_NVAR(val); zephir_array_fetch_long(&_12, anno, 2, PH_NOISY | PH_READONLY, "lynx/Annotation/RegexDocParser.zep", 47 TSRMLS_CC); zephir_fast_trim(val, _12, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); if (ZEPHIR_IS_STRING(val, "")) { ZEPHIR_INIT_NVAR(val); ZVAL_BOOL(val, 1); } else { ZEPHIR_CALL_SELF(&_10, "parsevalue", &_11, val); zephir_check_call_status(); ZEPHIR_CPY_WRT(val, _10); } } } if (zephir_array_isset(annotations, annoName)) { zephir_array_fetch(&_6, annotations, annoName, PH_NOISY | PH_READONLY, "lynx/Annotation/RegexDocParser.zep", 58 TSRMLS_CC); if (!(Z_TYPE_P(_6) == IS_ARRAY)) { ZEPHIR_INIT_NVAR(_14); array_init_size(_14, 2); ZEPHIR_OBS_NVAR(_13); zephir_array_fetch(&_13, annotations, annoName, PH_NOISY, "lynx/Annotation/RegexDocParser.zep", 59 TSRMLS_CC); zephir_array_fast_append(_14, _13); zephir_array_update_zval(&annotations, annoName, &_14, PH_COPY | PH_SEPARATE); } zephir_array_update_multi(&annotations, &val TSRMLS_CC, SL("za"), 2, annoName); } else { zephir_array_update_zval(&annotations, annoName, &val, PH_COPY | PH_SEPARATE); } } RETURN_CCTOR(annotations); }
/** * 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_Memcache, save) { int ZEPHIR_LAST_CALL_STATUS; zend_bool stopBuffer; zval *keyName = NULL, *content = NULL, *lifetime = NULL, *stopBuffer_param = NULL, *lastKey = NULL, *frontend, *memcache = NULL, *cachedContent = NULL, *preparedContent = NULL, *tmp, *ttl = NULL, *success = NULL, *options, *specialKey, *keys = NULL, *isBuffering = NULL, *_0, *_1 = NULL; 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_VV(lastKey, _0, keyName); } if (!(zephir_is_true(lastKey))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Cache must be started first", "phalcon/cache/backend/memcache.zep", 172); return; } ZEPHIR_OBS_VAR(frontend); zephir_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC); ZEPHIR_OBS_VAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); if (Z_TYPE_P(memcache) != IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); } if (Z_TYPE_P(content) == IS_NULL) { ZEPHIR_CALL_METHOD(&cachedContent, frontend, "getcontent", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(cachedContent, content); } ZEPHIR_CALL_METHOD(&preparedContent, frontend, "beforestore", NULL, 0, cachedContent); zephir_check_call_status(); if (Z_TYPE_P(lifetime) == IS_NULL) { ZEPHIR_OBS_VAR(tmp); zephir_read_property_this(&tmp, this_ptr, SL("_lastLifetime"), PH_NOISY_CC); if (!(zephir_is_true(tmp))) { ZEPHIR_CALL_METHOD(&ttl, frontend, "getlifetime", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(ttl, tmp); } } else { ZEPHIR_CPY_WRT(ttl, lifetime); } if (zephir_is_numeric(cachedContent)) { ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, 0); ZEPHIR_CALL_METHOD(&success, memcache, "set", NULL, 0, lastKey, cachedContent, _1, ttl); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 0); ZEPHIR_CALL_METHOD(&success, memcache, "set", NULL, 0, lastKey, preparedContent, _1, ttl); zephir_check_call_status(); } if (!(zephir_is_true(success))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Failed storing data in memcached", "phalcon/cache/backend/memcache.zep", 219); return; } ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); ZEPHIR_OBS_VAR(specialKey); if (!(zephir_array_isset_string_fetch(&specialKey, options, SS("statsKey"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/memcache.zep", 225); return; } if (Z_TYPE_P(specialKey) != IS_NULL) { ZEPHIR_CALL_METHOD(&keys, memcache, "get", NULL, 0, specialKey); zephir_check_call_status(); if (Z_TYPE_P(keys) != IS_ARRAY) { ZEPHIR_INIT_NVAR(keys); array_init(keys); } if (!(zephir_array_isset(keys, lastKey))) { zephir_array_update_zval(&keys, lastKey, &ttl, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(NULL, memcache, "set", NULL, 0, specialKey, keys); 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); ZEPHIR_MM_RESTORE(); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_InclusionIn, validate) { zend_long ZEPHIR_LAST_CALL_STATUS; zval *validation, validation_sub, *field, field_sub, value, domain, message, label, replacePairs, strict, fieldDomain, code, _0, _1, _4, _2$$6, _3$$7, _5$$9, _6$$9, _7$$9; zval *this_ptr = getThis(); ZVAL_UNDEF(&validation_sub); ZVAL_UNDEF(&field_sub); ZVAL_UNDEF(&value); ZVAL_UNDEF(&domain); ZVAL_UNDEF(&message); ZVAL_UNDEF(&label); ZVAL_UNDEF(&replacePairs); ZVAL_UNDEF(&strict); ZVAL_UNDEF(&fieldDomain); ZVAL_UNDEF(&code); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_2$$6); ZVAL_UNDEF(&_3$$7); ZVAL_UNDEF(&_5$$9); ZVAL_UNDEF(&_6$$9); ZVAL_UNDEF(&_7$$9); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field); ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "domain"); ZEPHIR_CALL_METHOD(&domain, this_ptr, "getoption", NULL, 0, &_0); zephir_check_call_status(); ZEPHIR_OBS_VAR(&fieldDomain); if (zephir_array_isset_fetch(&fieldDomain, &domain, field, 0 TSRMLS_CC)) { if (Z_TYPE_P(&fieldDomain) == IS_ARRAY) { ZEPHIR_CPY_WRT(&domain, &fieldDomain); } } if (Z_TYPE_P(&domain) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Option 'domain' must be an array", "phalcon/validation/validator/inclusionin.zep", 81); return; } ZEPHIR_INIT_VAR(&strict); ZVAL_BOOL(&strict, 0); ZEPHIR_INIT_NVAR(&_0); ZVAL_STRING(&_0, "strict"); ZEPHIR_CALL_METHOD(&_1, this_ptr, "hasoption", NULL, 0, &_0); zephir_check_call_status(); if (zephir_is_true(&_1)) { ZEPHIR_INIT_VAR(&_2$$6); ZVAL_STRING(&_2$$6, "strict"); ZEPHIR_CALL_METHOD(&strict, this_ptr, "getoption", NULL, 0, &_2$$6); zephir_check_call_status(); if (Z_TYPE_P(&strict) == IS_ARRAY) { zephir_array_fetch(&_3$$7, &strict, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/inclusionin.zep", 89 TSRMLS_CC); ZEPHIR_CPY_WRT(&strict, &_3$$7); } if (((Z_TYPE_P(&strict) == IS_TRUE || Z_TYPE_P(&strict) == IS_FALSE) != 1)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Option 'strict' must be a bool", "phalcon/validation/validator/inclusionin.zep", 93); return; } } ZEPHIR_CALL_FUNCTION(&_4, "in_array", NULL, 455, &value, &domain, &strict); zephir_check_call_status(); if (!(zephir_is_true(&_4))) { ZEPHIR_CALL_METHOD(&label, this_ptr, "preparelabel", NULL, 0, validation, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(&_5$$9); ZVAL_STRING(&_5$$9, "InclusionIn"); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, &_5$$9); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&code, this_ptr, "preparecode", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(&replacePairs); zephir_create_array(&replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_5$$9); zephir_fast_join_str(&_5$$9, SL(", "), &domain TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":domain"), &_5$$9, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_5$$9); object_init_ex(&_5$$9, phalcon_messages_message_ce); ZEPHIR_CALL_FUNCTION(&_6$$9, "strtr", NULL, 48, &message, &replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(&_7$$9); ZVAL_STRING(&_7$$9, "InclusionIn"); ZEPHIR_CALL_METHOD(NULL, &_5$$9, "__construct", NULL, 300, &_6$$9, field, &_7$$9, &code); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_5$$9); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); }
/** * Phalcon\Config\Adapter\Yaml constructor * * @throws \Phalcon\Config\Exception */ PHP_METHOD(Phalcon_Config_Adapter_Yaml, __construct) { zephir_fcall_cache_entry *_5 = NULL; zephir_nts_static zephir_fcall_cache_entry *_2 = NULL, *_7 = NULL, *_8 = NULL; int ndocs = 0, ZEPHIR_LAST_CALL_STATUS; zval *callbacks = NULL; zval *filePath_param = NULL, *callbacks_param = NULL, *yamlConfig = NULL, _0, *_1 = NULL, *_3 = NULL, *_4 = NULL, *_6; zval *filePath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &filePath_param, &callbacks_param); if (unlikely(Z_TYPE_P(filePath_param) != IS_STRING && Z_TYPE_P(filePath_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'filePath' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(filePath_param) == IS_STRING)) { zephir_get_strval(filePath, filePath_param); } else { ZEPHIR_INIT_VAR(filePath); ZVAL_EMPTY_STRING(filePath); } if (!callbacks_param) { ZEPHIR_INIT_VAR(callbacks); array_init(callbacks); } else { callbacks = callbacks_param; } ZEPHIR_SINIT_VAR(_0); ZVAL_STRING(&_0, "yaml", 0); ZEPHIR_CALL_FUNCTION(&_1, "extension_loaded", &_2, &_0); zephir_check_call_status(); if (!(zephir_is_true(_1))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_config_exception_ce, "Yaml extension not loaded", "phalcon/config/adapter/yaml.zep", 62); return; } if (!ZEPHIR_IS_STRING_IDENTICAL(callbacks, "")) { ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 0); ZEPHIR_INIT_VAR(_4); ZVAL_LONG(_4, ndocs); Z_SET_ISREF_P(_4); ZEPHIR_CALL_FUNCTION(&yamlConfig, "yaml_parse_file", &_5, filePath, _3, _4, callbacks); Z_UNSET_ISREF_P(_4); zephir_check_call_status(); } else { ZEPHIR_CALL_FUNCTION(&yamlConfig, "yaml_parse_file", &_5, filePath); zephir_check_call_status(); } if (ZEPHIR_IS_FALSE_IDENTICAL(yamlConfig)) { ZEPHIR_INIT_NVAR(_3); object_init_ex(_3, phalcon_config_exception_ce); ZEPHIR_INIT_NVAR(_4); zephir_basename(_4, filePath TSRMLS_CC); ZEPHIR_INIT_VAR(_6); ZEPHIR_CONCAT_SVS(_6, "Configuration file ", _4, " can't be loaded"); ZEPHIR_CALL_METHOD(NULL, _3, "__construct", &_7, _6); zephir_check_call_status(); zephir_throw_exception_debug(_3, "phalcon/config/adapter/yaml.zep", 72 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_CALL_PARENT(NULL, phalcon_config_adapter_yaml_ce, this_ptr, "__construct", &_8, yamlConfig); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_File, validate) { zend_bool _1, _2, _3, _5, _6, _11, _12, _14, _20, _21, _50, _57$$16, _64$$21; zend_long ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *_SERVER, *_POST, *_FILES, *value = NULL, *message = NULL, *label = NULL, *replacePairs = NULL, *types = NULL, *byteUnits = NULL, *unit = NULL, *maxSize = NULL, *matches = NULL, *bytes = NULL, *mime = NULL, *tmp = NULL, *width = NULL, *height = NULL, *minResolution = NULL, *maxResolution = NULL, *minWidth = NULL, *maxWidth = NULL, *minHeight = NULL, *maxHeight = NULL, *fieldTypes = NULL, *code = NULL, *minResolutionArray = NULL, *maxResolutionArray = NULL, *_0, *_4, *_7, *_13, *_15, *_16 = NULL, *_25 = NULL, *_26 = NULL, *_42 = NULL, *_49 = NULL, *_51 = NULL, *_8$$3 = NULL, *_9$$3 = NULL, *_10$$3 = NULL, *_17$$4 = NULL, *_18$$4 = NULL, *_19$$4 = NULL, *_22$$5 = NULL, *_23$$5 = NULL, *_24$$5 = NULL, *_27$$6 = NULL, *_29$$6, *_30$$6, *_31$$6, *_32$$6, *_33$$6 = NULL, *_34$$6, *_35$$6, _36$$6, *_37$$6, *_38$$6 = NULL, *_28$$7, *_39$$9 = NULL, *_40$$9 = NULL, *_41$$9 = NULL, *_43$$10, _44$$13, *_45$$13, *_46$$15 = NULL, *_47$$15 = NULL, *_48$$15 = NULL, *_52$$16, *_53$$16 = NULL, *_54$$16 = NULL, *_61$$16 = NULL, *_55$$17, *_56$$18, *_58$$20 = NULL, *_59$$20 = NULL, *_60$$20 = NULL, *_62$$21, *_63$$22, *_65$$23 = NULL, *_66$$23 = NULL, *_67$$23 = NULL; ZEPHIR_MM_GROW(); zephir_get_global(&_FILES, SS("_FILES") TSRMLS_CC); zephir_get_global(&_POST, SS("_POST") TSRMLS_CC); zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (UNEXPECTED(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (EXPECTED(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&label, this_ptr, "preparelabel", NULL, 0, validation, field); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&code, this_ptr, "preparecode", NULL, 0, field); zephir_check_call_status(); zephir_array_fetch_string(&_0, _SERVER, SL("REQUEST_METHOD"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 112 TSRMLS_CC); _1 = ZEPHIR_IS_STRING(_0, "POST"); if (_1) { _1 = ZEPHIR_IS_EMPTY(_POST); } _2 = _1; if (_2) { _2 = ZEPHIR_IS_EMPTY(_FILES); } _3 = _2; if (_3) { zephir_array_fetch_string(&_4, _SERVER, SL("CONTENT_LENGTH"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 112 TSRMLS_CC); _3 = ZEPHIR_GT_LONG(_4, 0); } _5 = _3; if (!(_5)) { _6 = zephir_array_isset_string(value, SS("error")); if (_6) { zephir_array_fetch_string(&_7, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 112 TSRMLS_CC); _6 = ZEPHIR_IS_LONG_IDENTICAL(_7, 1); } _5 = _6; } if (_5) { ZEPHIR_INIT_VAR(_8$$3); ZVAL_STRING(_8$$3, "FileIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_9$$3); ZVAL_STRING(_9$$3, "messageIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, _8$$3, _9$$3); zephir_check_temp_parameter(_8$$3); zephir_check_temp_parameter(_9$$3); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8$$3); object_init_ex(_8$$3, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_10$$3, "strtr", NULL, 27, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_9$$3); ZVAL_STRING(_9$$3, "FileIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _8$$3, "__construct", NULL, 470, _10$$3, field, _9$$3, code); zephir_check_temp_parameter(_9$$3); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _8$$3); zephir_check_call_status(); RETURN_MM_BOOL(0); } _11 = !(zephir_array_isset_string(value, SS("error"))); if (!(_11)) { _11 = !(zephir_array_isset_string(value, SS("tmp_name"))); } _12 = _11; if (!(_12)) { zephir_array_fetch_string(&_13, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 128 TSRMLS_CC); _12 = !ZEPHIR_IS_LONG_IDENTICAL(_13, 0); } _14 = _12; if (!(_14)) { zephir_array_fetch_string(&_15, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 128 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_16, "is_uploaded_file", NULL, 247, _15); zephir_check_call_status(); _14 = !zephir_is_true(_16); } if (_14) { ZEPHIR_INIT_VAR(_17$$4); ZVAL_STRING(_17$$4, "FileEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_18$$4); ZVAL_STRING(_18$$4, "messageEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, _17$$4, _18$$4); zephir_check_temp_parameter(_17$$4); zephir_check_temp_parameter(_18$$4); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_17$$4); object_init_ex(_17$$4, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_19$$4, "strtr", NULL, 27, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_18$$4); ZVAL_STRING(_18$$4, "FileEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _17$$4, "__construct", NULL, 470, _19$$4, field, _18$$4, code); zephir_check_temp_parameter(_18$$4); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _17$$4); zephir_check_call_status(); RETURN_MM_BOOL(0); } _20 = !(zephir_array_isset_string(value, SS("name"))); if (!(_20)) { _20 = !(zephir_array_isset_string(value, SS("type"))); } _21 = _20; if (!(_21)) { _21 = !(zephir_array_isset_string(value, SS("size"))); } if (_21) { ZEPHIR_INIT_VAR(_22$$5); ZVAL_STRING(_22$$5, "FileValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_23$$5); ZVAL_STRING(_23$$5, "messageValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, _22$$5, _23$$5); zephir_check_temp_parameter(_22$$5); zephir_check_temp_parameter(_23$$5); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_22$$5); object_init_ex(_22$$5, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_24$$5, "strtr", NULL, 27, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_23$$5); ZVAL_STRING(_23$$5, "FileValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _22$$5, "__construct", NULL, 470, _24$$5, field, _23$$5, code); zephir_check_temp_parameter(_23$$5); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _22$$5); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_VAR(_26); ZVAL_STRING(_26, "maxSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_25, this_ptr, "hasoption", NULL, 0, _26); zephir_check_temp_parameter(_26); zephir_check_call_status(); if (zephir_is_true(_25)) { ZEPHIR_INIT_VAR(byteUnits); zephir_create_array(byteUnits, 9, 0 TSRMLS_CC); add_assoc_long_ex(byteUnits, 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(_27$$6); ZVAL_STRING(_27$$6, "maxSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&maxSize, this_ptr, "getoption", NULL, 0, _27$$6); zephir_check_temp_parameter(_27$$6); zephir_check_call_status(); ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); ZEPHIR_INIT_VAR(unit); ZVAL_STRING(unit, "B", 1); if (Z_TYPE_P(maxSize) == IS_ARRAY) { zephir_array_fetch(&_28$$7, maxSize, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 168 TSRMLS_CC); ZEPHIR_CPY_WRT(maxSize, _28$$7); } ZEPHIR_INIT_NVAR(_27$$6); ZEPHIR_INIT_VAR(_29$$6); ZEPHIR_INIT_VAR(_30$$6); zephir_array_keys(_30$$6, byteUnits TSRMLS_CC); zephir_fast_join_str(_29$$6, SL("|"), _30$$6 TSRMLS_CC); ZEPHIR_INIT_VAR(_31$$6); ZEPHIR_CONCAT_SVS(_31$$6, "/^([0-9]+(?:\\.[0-9]+)?)(", _29$$6, ")?$/Di"); zephir_preg_match(_27$$6, _31$$6, maxSize, matches, 0, 0 , 0 TSRMLS_CC); if (zephir_array_isset_long(matches, 2)) { ZEPHIR_OBS_NVAR(unit); zephir_array_fetch_long(&unit, matches, 2, PH_NOISY, "phalcon/validation/validator/file.zep", 174 TSRMLS_CC); } zephir_array_fetch_long(&_32$$6, matches, 1, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 177 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_33$$6, "floatval", NULL, 323, _32$$6); zephir_check_call_status(); ZEPHIR_INIT_VAR(_34$$6); zephir_array_fetch(&_35$$6, byteUnits, unit, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 177 TSRMLS_CC); ZEPHIR_SINIT_VAR(_36$$6); ZVAL_LONG(&_36$$6, 2); zephir_pow_function(_34$$6, &_36$$6, _35$$6); ZEPHIR_INIT_VAR(bytes); mul_function(bytes, _33$$6, _34$$6 TSRMLS_CC); zephir_array_fetch_string(&_37$$6, value, SL("size"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 179 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_33$$6, "floatval", NULL, 323, _37$$6); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_38$$6, "floatval", NULL, 323, bytes); zephir_check_call_status(); if (ZEPHIR_GT(_33$$6, _38$$6)) { ZEPHIR_INIT_VAR(_39$$9); ZVAL_STRING(_39$$9, "FileSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_40$$9); ZVAL_STRING(_40$$9, "messageSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, _39$$9, _40$$9); zephir_check_temp_parameter(_39$$9); zephir_check_temp_parameter(_40$$9); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":max"), &maxSize, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_39$$9); object_init_ex(_39$$9, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_41$$9, "strtr", NULL, 27, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_40$$9); ZVAL_STRING(_40$$9, "FileSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _39$$9, "__construct", NULL, 470, _41$$9, field, _40$$9, code); zephir_check_temp_parameter(_40$$9); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _39$$9); zephir_check_call_status(); RETURN_MM_BOOL(0); } } ZEPHIR_INIT_NVAR(_26); ZVAL_STRING(_26, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_42, this_ptr, "hasoption", NULL, 0, _26); zephir_check_temp_parameter(_26); zephir_check_call_status(); if (zephir_is_true(_42)) { ZEPHIR_INIT_VAR(_43$$10); ZVAL_STRING(_43$$10, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&types, this_ptr, "getoption", NULL, 0, _43$$10); zephir_check_temp_parameter(_43$$10); zephir_check_call_status(); ZEPHIR_OBS_VAR(fieldTypes); if (zephir_array_isset_fetch(&fieldTypes, types, field, 0 TSRMLS_CC)) { ZEPHIR_CPY_WRT(types, fieldTypes); } if (Z_TYPE_P(types) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Option 'allowedTypes' must be an array", "phalcon/validation/validator/file.zep", 205); return; } if ((zephir_function_exists_ex(SS("finfo_open") TSRMLS_CC) == SUCCESS)) { ZEPHIR_SINIT_VAR(_44$$13); ZVAL_LONG(&_44$$13, 16); ZEPHIR_CALL_FUNCTION(&tmp, "finfo_open", NULL, 244, &_44$$13); zephir_check_call_status(); zephir_array_fetch_string(&_45$$13, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 210 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&mime, "finfo_file", NULL, 245, tmp, _45$$13); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(NULL, "finfo_close", NULL, 246, 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", 214 TSRMLS_CC); } if (!(zephir_fast_in_array(mime, types TSRMLS_CC))) { ZEPHIR_INIT_VAR(_46$$15); ZVAL_STRING(_46$$15, "FileType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_47$$15); ZVAL_STRING(_47$$15, "messageType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, _46$$15, _47$$15); zephir_check_temp_parameter(_46$$15); zephir_check_temp_parameter(_47$$15); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_46$$15); zephir_fast_join_str(_46$$15, SL(", "), types TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":types"), &_46$$15, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_46$$15); object_init_ex(_46$$15, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_48$$15, "strtr", NULL, 27, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_47$$15); ZVAL_STRING(_47$$15, "FileType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _46$$15, "__construct", NULL, 470, _48$$15, field, _47$$15, code); zephir_check_temp_parameter(_47$$15); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _46$$15); zephir_check_call_status(); RETURN_MM_BOOL(0); } } ZEPHIR_INIT_NVAR(_26); ZVAL_STRING(_26, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_49, this_ptr, "hasoption", NULL, 0, _26); zephir_check_temp_parameter(_26); zephir_check_call_status(); _50 = zephir_is_true(_49); if (!(_50)) { ZEPHIR_INIT_NVAR(_26); ZVAL_STRING(_26, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_51, this_ptr, "hasoption", NULL, 0, _26); zephir_check_temp_parameter(_26); zephir_check_call_status(); _50 = zephir_is_true(_51); } if (_50) { zephir_array_fetch_string(&_52$$16, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 235 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&tmp, "getimagesize", NULL, 255, _52$$16); zephir_check_call_status(); ZEPHIR_OBS_VAR(width); zephir_array_fetch_long(&width, tmp, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 236 TSRMLS_CC); ZEPHIR_OBS_VAR(height); zephir_array_fetch_long(&height, tmp, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 237 TSRMLS_CC); ZEPHIR_INIT_VAR(_54$$16); ZVAL_STRING(_54$$16, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_53$$16, this_ptr, "hasoption", NULL, 0, _54$$16); zephir_check_temp_parameter(_54$$16); zephir_check_call_status(); if (zephir_is_true(_53$$16)) { ZEPHIR_INIT_VAR(_55$$17); ZVAL_STRING(_55$$17, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&minResolution, this_ptr, "getoption", NULL, 0, _55$$17); zephir_check_temp_parameter(_55$$17); zephir_check_call_status(); if (Z_TYPE_P(minResolution) == IS_ARRAY) { zephir_array_fetch(&_56$$18, minResolution, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 242 TSRMLS_CC); ZEPHIR_CPY_WRT(minResolution, _56$$18); } ZEPHIR_INIT_VAR(minResolutionArray); zephir_fast_explode_str(minResolutionArray, SL("x"), minResolution, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(minWidth); zephir_array_fetch_long(&minWidth, minResolutionArray, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 245 TSRMLS_CC); ZEPHIR_OBS_VAR(minHeight); zephir_array_fetch_long(&minHeight, minResolutionArray, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 246 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(minWidth); ZVAL_LONG(minWidth, 1); ZEPHIR_INIT_NVAR(minHeight); ZVAL_LONG(minHeight, 1); } _57$$16 = ZEPHIR_LT(width, minWidth); if (!(_57$$16)) { _57$$16 = ZEPHIR_LT(height, minHeight); } if (_57$$16) { ZEPHIR_INIT_VAR(_58$$20); ZVAL_STRING(_58$$20, "FileMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_59$$20); ZVAL_STRING(_59$$20, "messageMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, _58$$20, _59$$20); zephir_check_temp_parameter(_58$$20); zephir_check_temp_parameter(_59$$20); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":min"), &minResolution, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_58$$20); object_init_ex(_58$$20, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_60$$20, "strtr", NULL, 27, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_59$$20); ZVAL_STRING(_59$$20, "FileMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _58$$20, "__construct", NULL, 470, _60$$20, field, _59$$20, code); zephir_check_temp_parameter(_59$$20); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _58$$20); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_54$$16); ZVAL_STRING(_54$$16, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_61$$16, this_ptr, "hasoption", NULL, 0, _54$$16); zephir_check_temp_parameter(_54$$16); zephir_check_call_status(); if (zephir_is_true(_61$$16)) { ZEPHIR_INIT_VAR(_62$$21); ZVAL_STRING(_62$$21, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&maxResolution, this_ptr, "getoption", NULL, 0, _62$$21); zephir_check_temp_parameter(_62$$21); zephir_check_call_status(); if (Z_TYPE_P(maxResolution) == IS_ARRAY) { zephir_array_fetch(&_63$$22, maxResolution, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 272 TSRMLS_CC); ZEPHIR_CPY_WRT(maxResolution, _63$$22); } ZEPHIR_INIT_VAR(maxResolutionArray); zephir_fast_explode_str(maxResolutionArray, SL("x"), maxResolution, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(maxWidth); zephir_array_fetch_long(&maxWidth, maxResolutionArray, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 275 TSRMLS_CC); ZEPHIR_OBS_VAR(maxHeight); zephir_array_fetch_long(&maxHeight, maxResolutionArray, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 276 TSRMLS_CC); _64$$21 = ZEPHIR_GT(width, maxWidth); if (!(_64$$21)) { _64$$21 = ZEPHIR_GT(height, maxHeight); } if (_64$$21) { ZEPHIR_INIT_VAR(_65$$23); ZVAL_STRING(_65$$23, "FileMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_66$$23); ZVAL_STRING(_66$$23, "messageMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, _65$$23, _66$$23); zephir_check_temp_parameter(_65$$23); zephir_check_temp_parameter(_66$$23); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":max"), &maxResolution, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_65$$23); object_init_ex(_65$$23, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_67$$23, "strtr", NULL, 27, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_66$$23); ZVAL_STRING(_66$$23, "FileMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _65$$23, "__construct", NULL, 470, _67$$23, field, _66$$23, code); zephir_check_temp_parameter(_66$$23); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _65$$23); zephir_check_call_status(); RETURN_MM_BOOL(0); } } } RETURN_MM_BOOL(1); }
PHP_METHOD(Test_Quantum, harmos) { zend_bool _13, _16, _32, _35; zval *_10 = NULL, *_11 = NULL, *_12 = NULL; zephir_fcall_cache_entry *_4 = NULL, *_6 = NULL, *_8 = NULL, *_36 = NULL; int i, j, n, ZEPHIR_LAST_CALL_STATUS, _14, _15, _17, _18, _33, _34; zval *x_param = NULL, *psr, *psi, *p2, *v, *paramater, *fp = NULL, *tmp, *_0 = NULL, _1 = zval_used_for_init, _2 = zval_used_for_init, *_3 = NULL, *_5 = NULL, *_7 = NULL, *_9 = NULL, *_19, *_20, *_21, *_22, *_23, *_24, *_25, *_26, _27 = zval_used_for_init, *_28, *_29, *_30, *_31; double x, dt, dx, k0, item_psr, item_psi; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &x_param); x = zephir_get_doubleval(x_param); dx = 0.02; k0 = (3.0 * 3.14159265358979323846); dt = zephir_safe_div_double_long((dx * dx), 4.0 TSRMLS_CC); ZEPHIR_INIT_VAR(paramater); zephir_create_array(paramater, 4, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_0); ZVAL_DOUBLE(_0, dx); zephir_array_fast_append(paramater, _0); ZEPHIR_INIT_NVAR(_0); ZVAL_DOUBLE(_0, k0); zephir_array_fast_append(paramater, _0); ZEPHIR_INIT_NVAR(_0); ZVAL_DOUBLE(_0, dt); zephir_array_fast_append(paramater, _0); ZEPHIR_INIT_NVAR(_0); ZVAL_DOUBLE(_0, x); zephir_array_fast_append(paramater, _0); i = 0; ZEPHIR_INIT_VAR(psr); array_init(psr); ZEPHIR_INIT_VAR(psi); array_init(psi); ZEPHIR_INIT_VAR(p2); array_init(p2); ZEPHIR_INIT_VAR(v); array_init(v); ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "harmos.txt", 0); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "w", 0); ZEPHIR_CALL_FUNCTION(&fp, "fopen", NULL, 30, &_1, &_2); zephir_check_call_status(); if (!(zephir_is_true(fp))) { RETURN_MM_LONG(1); } while (1) { if (!(i <= 751)) { break; } ZEPHIR_SINIT_NVAR(_1); ZVAL_DOUBLE(&_1, (k0 * x)); ZEPHIR_CALL_FUNCTION(&_3, "sin", &_4, 10, &_1); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_1); ZVAL_DOUBLE(&_1, ((x * x) * 2.0)); ZEPHIR_CALL_FUNCTION(&_5, "exp", &_6, 1, &_1); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_7); div_function(_7, _3, _5 TSRMLS_CC); item_psi = zephir_get_numberval(_7); ZEPHIR_SINIT_NVAR(_1); ZVAL_DOUBLE(&_1, (k0 * x)); ZEPHIR_CALL_FUNCTION(&_3, "cos", &_8, 11, &_1); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_1); ZVAL_DOUBLE(&_1, ((x * x) * 2.0)); ZEPHIR_CALL_FUNCTION(&_5, "exp", &_6, 1, &_1); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_9); div_function(_9, _3, _5 TSRMLS_CC); item_psr = zephir_get_numberval(_9); ZEPHIR_INIT_NVAR(_10); zephir_create_array(_10, 1, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_0); ZVAL_DOUBLE(_0, item_psr); zephir_array_fast_append(_10, _0); zephir_array_update_long(&psr, i, &_10, PH_COPY | PH_SEPARATE, "test/quantum.zep", 39); ZEPHIR_INIT_NVAR(_11); zephir_create_array(_11, 1, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_0); ZVAL_DOUBLE(_0, item_psi); zephir_array_fast_append(_11, _0); zephir_array_update_long(&psi, i, &_11, PH_COPY | PH_SEPARATE, "test/quantum.zep", 40); ZEPHIR_INIT_NVAR(_12); zephir_create_array(_12, 1, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_0); ZVAL_DOUBLE(_0, (double) ((double) (5.0 * x) * x)); zephir_array_fast_append(_12, _0); zephir_array_update_long(&v, i, &_12, PH_COPY | PH_SEPARATE, "test/quantum.zep", 41); x = (x + dx); i++; } i = 1; j = 1; ZEPHIR_INIT_VAR(tmp); zephir_create_array(tmp, 1, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_0); ZVAL_DOUBLE(_0, 2.0); zephir_array_fast_append(tmp, _0); _15 = 20000; _14 = 0; _13 = 0; if (_14 <= _15) { while (1) { if (_13) { _14++; if (!(_14 <= _15)) { break; } } else { _13 = 1; } n = _14; _18 = (751 - 1); _17 = 1; _16 = 0; if (_17 <= _18) { while (1) { if (_16) { _17++; if (!(_17 <= _18)) { break; } } else { _16 = 1; } i = _17; zephir_array_fetch_long(&_19, psr, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 50 TSRMLS_CC); zephir_array_fetch_long(&_20, _19, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 50 TSRMLS_CC); zephir_array_fetch_long(&_21, paramater, 2, PH_NOISY | PH_READONLY, "test/quantum.zep", 50 TSRMLS_CC); zephir_array_fetch_long(&_22, psi, (i + 1), PH_NOISY | PH_READONLY, "test/quantum.zep", 50 TSRMLS_CC); zephir_array_fetch_long(&_23, _22, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 50 TSRMLS_CC); zephir_array_fetch_long(&_24, psi, (i - 1), PH_NOISY | PH_READONLY, "test/quantum.zep", 50 TSRMLS_CC); zephir_array_fetch_long(&_25, _24, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); zephir_add_function_ex(&_1, _23, _25 TSRMLS_CC); zephir_array_fetch_long(&_23, tmp, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC); zephir_array_fetch_long(&_25, psi, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC); zephir_array_fetch_long(&_26, _25, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); mul_function(&_2, _23, _26 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_7); sub_function(_7, &_1, &_2 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); mul_function(&_1, _21, _7 TSRMLS_CC); zephir_array_fetch_long(&_21, paramater, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC); zephir_array_fetch_long(&_23, paramater, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_7); mul_function(_7, _21, _23 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); div_function(&_2, &_1, _7 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); sub_function(&_1, _20, &_2 TSRMLS_CC); zephir_array_fetch_long(&_20, paramater, 2, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC); zephir_array_fetch_long(&_21, v, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC); zephir_array_fetch_long(&_23, _21, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); mul_function(&_2, _20, _23 TSRMLS_CC); zephir_array_fetch_long(&_20, psi, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC); zephir_array_fetch_long(&_23, _20, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_27); mul_function(&_27, &_2, _23 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_7); zephir_add_function_ex(_7, &_1, &_27 TSRMLS_CC); zephir_array_update_multi(&psr, &_7 TSRMLS_CC, SL("ll"), 2, i, 1); zephir_array_fetch_long(&_23, psr, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 53 TSRMLS_CC); zephir_array_fetch_long(&_26, _23, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 53 TSRMLS_CC); zephir_array_fetch_long(&_28, psr, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 53 TSRMLS_CC); zephir_array_fetch_long(&_29, _28, 1, PH_NOISY | PH_READONLY, "test/quantum.zep", 53 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); mul_function(&_1, _26, _29 TSRMLS_CC); zephir_array_fetch_long(&_26, psi, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 53 TSRMLS_CC); zephir_array_fetch_long(&_29, _26, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 53 TSRMLS_CC); zephir_array_fetch_long(&_30, psi, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 53 TSRMLS_CC); zephir_array_fetch_long(&_31, _30, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 53 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); mul_function(&_2, _29, _31 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_7); zephir_add_function_ex(_7, &_1, &_2 TSRMLS_CC); zephir_array_update_long(&p2, i, &_7, PH_COPY | PH_SEPARATE, "test/quantum.zep", 53); } } _34 = (751 - 1); _33 = 1; _32 = 0; if (_33 <= _34) { while (1) { if (_32) { _33++; if (!(_33 <= _34)) { break; } } else { _32 = 1; } j = _33; ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 0); zephir_array_update_multi(&psr, &_0 TSRMLS_CC, SL("ll"), 2, 0, 1); ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 0); zephir_array_update_multi(&psr, &_0 TSRMLS_CC, SL("ll"), 2, 751, 1); zephir_array_fetch_long(&_19, psi, j, PH_NOISY | PH_READONLY, "test/quantum.zep", 58 TSRMLS_CC); zephir_array_fetch_long(&_20, _19, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 58 TSRMLS_CC); zephir_array_fetch_long(&_21, paramater, 2, PH_NOISY | PH_READONLY, "test/quantum.zep", 58 TSRMLS_CC); zephir_array_fetch_long(&_22, psr, (j + 1), PH_NOISY | PH_READONLY, "test/quantum.zep", 58 TSRMLS_CC); zephir_array_fetch_long(&_23, _22, 1, PH_NOISY | PH_READONLY, "test/quantum.zep", 58 TSRMLS_CC); zephir_array_fetch_long(&_24, psr, (j - 1), PH_NOISY | PH_READONLY, "test/quantum.zep", 58 TSRMLS_CC); zephir_array_fetch_long(&_25, _24, 1, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); zephir_add_function_ex(&_1, _23, _25 TSRMLS_CC); zephir_array_fetch_long(&_23, tmp, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC); zephir_array_fetch_long(&_25, psr, j, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC); zephir_array_fetch_long(&_26, _25, 1, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); mul_function(&_2, _23, _26 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_9); sub_function(_9, &_1, &_2 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); mul_function(&_1, _21, _9 TSRMLS_CC); zephir_array_fetch_long(&_21, paramater, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC); zephir_array_fetch_long(&_23, paramater, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_9); mul_function(_9, _21, _23 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); div_function(&_2, &_1, _9 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); zephir_add_function_ex(&_1, _20, &_2 TSRMLS_CC); zephir_array_fetch_long(&_20, paramater, 2, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC); zephir_array_fetch_long(&_21, v, j, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC); zephir_array_fetch_long(&_23, _21, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); mul_function(&_2, _20, _23 TSRMLS_CC); zephir_array_fetch_long(&_20, psr, j, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC); zephir_array_fetch_long(&_23, _20, 1, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_27); mul_function(&_27, &_2, _23 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_9); sub_function(_9, &_1, &_27 TSRMLS_CC); zephir_array_update_multi(&psi, &_9 TSRMLS_CC, SL("ll"), 2, j, 1); } } _35 = n == 0; if (!(_35)) { _35 = zephir_safe_mod_long_long(n, 2000 TSRMLS_CC) == 0; } if (_35) { i = 1; while (1) { if (!(i < (751 - 1))) { break; } zephir_array_fetch_long(&_19, p2, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 67 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "%16.8lf %16.8lf %16.8lf \n", 0); ZEPHIR_SINIT_NVAR(_2); ZVAL_DOUBLE(&_2, ((double) i * dx)); ZEPHIR_SINIT_NVAR(_27); ZVAL_DOUBLE(&_27, ((double) n * dt)); ZEPHIR_CALL_FUNCTION(NULL, "fprintf", &_36, 57, fp, &_1, &_2, &_27, _19); zephir_check_call_status(); i = (i + 10); } ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "\n", 0); ZEPHIR_CALL_FUNCTION(NULL, "fprintf", &_36, 57, fp, &_1); zephir_check_call_status(); } j = 1; while (1) { if (!(j < (751 - 1))) { break; } zephir_array_fetch_long(&_19, psi, j, PH_NOISY | PH_READONLY, "test/quantum.zep", 76 TSRMLS_CC); zephir_array_fetch_long(&_20, _19, 1, PH_NOISY | PH_READONLY, "test/quantum.zep", 76 TSRMLS_CC); zephir_array_update_multi(&psi, &_20 TSRMLS_CC, SL("ll"), 2, j, 0); zephir_array_fetch_long(&_20, psr, j, PH_NOISY | PH_READONLY, "test/quantum.zep", 77 TSRMLS_CC); zephir_array_fetch_long(&_21, _20, 1, PH_NOISY | PH_READONLY, "test/quantum.zep", 77 TSRMLS_CC); zephir_array_update_multi(&psr, &_21 TSRMLS_CC, SL("ll"), 2, j, 0); j++; } } } RETURN_MM_BOOL(1); }
/** * Fires an event in the events manager causing the active listeners to be notified about it * *<code> * $eventsManager->fire('db', $connection); *</code> * * @param string eventType * @param object source * @param mixed data * @param boolean cancelable * @return mixed */ PHP_METHOD(Phalcon_Events_Manager, fire) { zephir_fcall_cache_entry *_5 = NULL, *_6 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_bool cancelable, _3$$6, _7$$8; zval *eventType_param = NULL, *source, *data = NULL, *cancelable_param = NULL, *events = NULL, *eventParts = NULL, *type = NULL, *eventName = NULL, *event = NULL, *status = NULL, *fireEvents = NULL, *_2, *_0$$4, *_4$$7, *_8$$10; zval *eventType = NULL, *_1$$4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 2, &eventType_param, &source, &data, &cancelable_param); if (unlikely(Z_TYPE_P(eventType_param) != IS_STRING && Z_TYPE_P(eventType_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventType' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(eventType_param) == IS_STRING)) { zephir_get_strval(eventType, eventType_param); } else { ZEPHIR_INIT_VAR(eventType); ZVAL_EMPTY_STRING(eventType); } if (!data) { data = ZEPHIR_GLOBAL(global_null); } if (!cancelable_param) { cancelable = 1; } else { cancelable = zephir_get_boolval(cancelable_param); } ZEPHIR_OBS_VAR(events); zephir_read_property_this(&events, this_ptr, SL("_events"), PH_NOISY_CC); if (Z_TYPE_P(events) != IS_ARRAY) { RETURN_MM_NULL(); } if (!(zephir_memnstr_str(eventType, SL(":"), "phalcon/events/manager.zep", 381))) { ZEPHIR_INIT_VAR(_0$$4); object_init_ex(_0$$4, phalcon_events_exception_ce); ZEPHIR_INIT_VAR(_1$$4); ZEPHIR_CONCAT_SV(_1$$4, "Invalid event type ", eventType); ZEPHIR_CALL_METHOD(NULL, _0$$4, "__construct", NULL, 9, _1$$4); zephir_check_call_status(); zephir_throw_exception_debug(_0$$4, "phalcon/events/manager.zep", 382 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(eventParts); zephir_fast_explode_str(eventParts, SL(":"), eventType, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(type); zephir_array_fetch_long(&type, eventParts, 0, PH_NOISY, "phalcon/events/manager.zep", 386 TSRMLS_CC); ZEPHIR_OBS_VAR(eventName); zephir_array_fetch_long(&eventName, eventParts, 1, PH_NOISY, "phalcon/events/manager.zep", 387 TSRMLS_CC); ZEPHIR_INIT_VAR(status); ZVAL_NULL(status); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_collect"), PH_NOISY_CC); if (zephir_is_true(_2)) { zephir_update_property_this(this_ptr, SL("_responses"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); } ZEPHIR_INIT_VAR(event); ZVAL_NULL(event); ZEPHIR_OBS_VAR(fireEvents); if (zephir_array_isset_fetch(&fireEvents, events, type, 0 TSRMLS_CC)) { _3$$6 = Z_TYPE_P(fireEvents) == IS_OBJECT; if (!(_3$$6)) { _3$$6 = Z_TYPE_P(fireEvents) == IS_ARRAY; } if (_3$$6) { ZEPHIR_INIT_NVAR(event); object_init_ex(event, phalcon_events_event_ce); ZEPHIR_INIT_VAR(_4$$7); if (cancelable) { ZVAL_BOOL(_4$$7, 1); } else { ZVAL_BOOL(_4$$7, 0); } ZEPHIR_CALL_METHOD(NULL, event, "__construct", &_5, 194, eventName, source, data, _4$$7); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&status, this_ptr, "firequeue", &_6, 195, fireEvents, event); zephir_check_call_status(); } } ZEPHIR_OBS_NVAR(fireEvents); if (zephir_array_isset_fetch(&fireEvents, events, eventType, 0 TSRMLS_CC)) { _7$$8 = Z_TYPE_P(fireEvents) == IS_OBJECT; if (!(_7$$8)) { _7$$8 = Z_TYPE_P(fireEvents) == IS_ARRAY; } if (_7$$8) { if (Z_TYPE_P(event) == IS_NULL) { ZEPHIR_INIT_NVAR(event); object_init_ex(event, phalcon_events_event_ce); ZEPHIR_INIT_VAR(_8$$10); if (cancelable) { ZVAL_BOOL(_8$$10, 1); } else { ZVAL_BOOL(_8$$10, 0); } ZEPHIR_CALL_METHOD(NULL, event, "__construct", &_5, 194, eventName, source, data, _8$$10); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&status, this_ptr, "firequeue", &_6, 195, fireEvents, event); zephir_check_call_status(); } } RETURN_CCTOR(status); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_CreditCard, validate) { int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *message = NULL, *label = NULL, *replacePairs = NULL, *value = NULL, *valid = NULL, *_0$$3 = NULL, *_2$$3 = NULL, *_3$$3, *_1$$5; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&valid, this_ptr, "verifybyluhnalgorithm", NULL, 438, value); zephir_check_call_status(); if (!(zephir_is_true(valid))) { ZEPHIR_INIT_VAR(_0$$3); ZVAL_STRING(_0$$3, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _0$$3); zephir_check_temp_parameter(_0$$3); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_0$$3); ZVAL_STRING(_0$$3, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _0$$3); zephir_check_temp_parameter(_0$$3); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_1$$5); ZVAL_STRING(_1$$5, "CreditCard", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _1$$5); zephir_check_temp_parameter(_1$$5); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_0$$3); object_init_ex(_0$$3, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_2$$3, "strtr", NULL, 55, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3$$3); ZVAL_STRING(_3$$3, "CreditCard", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _0$$3, "__construct", NULL, 434, _2$$3, field, _3$$3); zephir_check_temp_parameter(_3$$3); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _0$$3); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); }
/** * Attach a listener to the events manager * * @param string eventType * @param object|callable handler * @param int priority */ PHP_METHOD(Phalcon_Events_Manager, attach) { int priority, ZEPHIR_LAST_CALL_STATUS; zval *eventType_param = NULL, *handler, *priority_param = NULL, *priorityQueue = NULL, *_0, *_1$$4, *_2$$5, *_3$$7; zval *eventType = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &eventType_param, &handler, &priority_param); if (unlikely(Z_TYPE_P(eventType_param) != IS_STRING && Z_TYPE_P(eventType_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventType' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(eventType_param) == IS_STRING)) { zephir_get_strval(eventType, eventType_param); } else { ZEPHIR_INIT_VAR(eventType); ZVAL_EMPTY_STRING(eventType); } if (!priority_param) { priority = 100; } else { if (unlikely(Z_TYPE_P(priority_param) != IS_LONG)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'priority' must be a int") TSRMLS_CC); RETURN_MM_NULL(); } priority = Z_LVAL_P(priority_param); } if (Z_TYPE_P(handler) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_events_exception_ce, "Event handler must be an Object", "phalcon/events/manager.zep", 56); return; } ZEPHIR_OBS_VAR(priorityQueue); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_events"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&priorityQueue, _0, eventType, 0 TSRMLS_CC))) { _1$$4 = zephir_fetch_nproperty_this(this_ptr, SL("_enablePriorities"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(priorityQueue); if (zephir_is_true(_1$$4)) { object_init_ex(priorityQueue, spl_ce_SplPriorityQueue); if (zephir_has_constructor(priorityQueue TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, priorityQueue, "__construct", NULL, 0); zephir_check_call_status(); } ZEPHIR_INIT_VAR(_2$$5); ZVAL_LONG(_2$$5, 1); ZEPHIR_CALL_METHOD(NULL, priorityQueue, "setextractflags", NULL, 190, _2$$5); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_events"), eventType, priorityQueue TSRMLS_CC); } else { array_init(priorityQueue); } } if (Z_TYPE_P(priorityQueue) == IS_OBJECT) { ZEPHIR_INIT_VAR(_3$$7); ZVAL_LONG(_3$$7, priority); ZEPHIR_CALL_METHOD(NULL, priorityQueue, "insert", NULL, 191, handler, _3$$7); zephir_check_call_status(); } else { zephir_array_append(&priorityQueue, handler, PH_SEPARATE, "phalcon/events/manager.zep", 82); zephir_update_property_array(this_ptr, SL("_events"), eventType, priorityQueue TSRMLS_CC); } ZEPHIR_MM_RESTORE(); }
/** * Redirect by HTTP to another action or URL * *<code> * //Using a string redirect (internal/external) * $response->redirect("posts/index"); * $response->redirect("http://en.wikipedia.org", true); * $response->redirect("http://www.example.com/new-location", true, 301); * * //Making a redirection based on a named route * $response->redirect(array( * "for" => "index-lang", * "lang" => "jp", * "controller" => "index" * )); *</code> * * @param string|array location * @param boolean externalRedirect * @param int statusCode * @return \Phalcon\Http\Response */ PHP_METHOD(Phalcon_Http_Response, redirect) { int statusCode, ZEPHIR_LAST_CALL_STATUS; zend_bool externalRedirect, _0; zval *location = NULL, *externalRedirect_param = NULL, *statusCode_param = NULL, *header = NULL, *url = NULL, *dependencyInjector = NULL, *matched, *message = NULL, *view = NULL, _1 = zval_used_for_init, *_2 = NULL, *_3, *_4 = NULL, *_5; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 3, &location, &externalRedirect_param, &statusCode_param); if (!location) { ZEPHIR_CPY_WRT(location, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(location); } if (!externalRedirect_param) { externalRedirect = 0; } else { externalRedirect = zephir_get_boolval(externalRedirect_param); } if (!statusCode_param) { statusCode = 302; } else { statusCode = zephir_get_intval(statusCode_param); } if (!(zephir_is_true(location))) { ZEPHIR_INIT_NVAR(location); ZVAL_STRING(location, "", 1); } if (externalRedirect) { ZEPHIR_CPY_WRT(header, location); } else { _0 = Z_TYPE_P(location) == IS_STRING; if (_0) { ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "://", 0); ZEPHIR_CALL_FUNCTION(&_2, "strstr", NULL, 235, location, &_1); zephir_check_call_status(); _0 = zephir_is_true(_2); } if (_0) { ZEPHIR_INIT_VAR(_3); ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "/^[^:\\/?#]++:/", 0); ZEPHIR_INIT_VAR(matched); zephir_preg_match(matched, &_1, location, _3, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(matched)) { ZEPHIR_CPY_WRT(header, location); } else { ZEPHIR_INIT_NVAR(header); ZVAL_NULL(header); } } else { ZEPHIR_INIT_NVAR(header); ZVAL_NULL(header); } } ZEPHIR_CALL_METHOD(&dependencyInjector, this_ptr, "getdi", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(header))) { ZEPHIR_INIT_VAR(_4); ZVAL_STRING(_4, "url", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, dependencyInjector, "getshared", NULL, 0, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); ZEPHIR_CPY_WRT(url, _2); ZEPHIR_CALL_METHOD(&header, url, "get", NULL, 0, location); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "view", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, dependencyInjector, "has", NULL, 0, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); if (zephir_is_true(_2)) { ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "view", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&view, dependencyInjector, "getshared", NULL, 0, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); if (zephir_instance_of_ev(view, phalcon_mvc_viewinterface_ce TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, view, "disable", NULL, 0); zephir_check_call_status(); } } _0 = statusCode < 300; if (!(_0)) { _0 = statusCode > 308; } if (_0) { statusCode = 302; _5 = zephir_fetch_nproperty_this(this_ptr, SL("_statusCodes"), PH_NOISY_CC); ZEPHIR_OBS_VAR(message); zephir_array_fetch_long(&message, _5, 302, PH_NOISY, "phalcon/http/response.zep", 481 TSRMLS_CC); } else { ZEPHIR_OBS_NVAR(message); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_statusCodes"), PH_NOISY_CC); zephir_array_isset_long_fetch(&message, _5, statusCode, 0 TSRMLS_CC); } ZEPHIR_INIT_NVAR(_4); ZVAL_LONG(_4, statusCode); ZEPHIR_CALL_METHOD(NULL, this_ptr, "setstatuscode", NULL, 0, _4, message); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Location", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "setheader", NULL, 0, _4, header); zephir_check_temp_parameter(_4); zephir_check_call_status(); RETURN_THIS(); }
/** * Writes the log to the stream itself */ PHP_METHOD(Phalcon_Logger_Adapter_Firephp, logInternal) { HashTable *_8; HashPosition _7; zephir_fcall_cache_entry *_2 = NULL; zval *context = NULL; int type, time, ZEPHIR_LAST_CALL_STATUS; zval *message_param = NULL, *type_param = NULL, *time_param = NULL, *context_param = NULL, *chunk = NULL, *format = NULL, *chString = NULL, *content = NULL, *key = NULL, *index = NULL, *_0, *_3 = NULL, *_4, *_5, _6, **_9, _1$$3 = zval_used_for_init; zval *message = NULL, *_10$$4 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &message_param, &type_param, &time_param, &context_param); zephir_get_strval(message, message_param); type = zephir_get_intval(type_param); time = zephir_get_intval(time_param); zephir_get_arrval(context, context_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_initialized"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { ZEPHIR_SINIT_VAR(_1$$3); ZVAL_STRING(&_1$$3, "X-Wf-Protocol-1: http://meta.wildfirehq.org/Protocol/JsonStream/0.2", 0); ZEPHIR_CALL_FUNCTION(NULL, "header", &_2, 248, &_1$$3); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_1$$3); ZVAL_STRING(&_1$$3, "X-Wf-1-Plugin-1: http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3", 0); ZEPHIR_CALL_FUNCTION(NULL, "header", &_2, 248, &_1$$3); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_1$$3); ZVAL_STRING(&_1$$3, "X-Wf-Structure-1: http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1", 0); ZEPHIR_CALL_FUNCTION(NULL, "header", &_2, 248, &_1$$3); zephir_check_call_status(); if (1) { zephir_update_property_this(this_ptr, SL("_initialized"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_initialized"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } ZEPHIR_CALL_METHOD(&_3, this_ptr, "getformatter", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_4); ZVAL_LONG(_4, type); ZEPHIR_INIT_VAR(_5); ZVAL_LONG(_5, time); ZEPHIR_CALL_METHOD(&format, _3, "format", NULL, 0, message, _4, _5, context); zephir_check_call_status(); ZEPHIR_SINIT_VAR(_6); ZVAL_LONG(&_6, 4500); ZEPHIR_CALL_FUNCTION(&chunk, "str_split", NULL, 74, format, &_6); zephir_check_call_status(); ZEPHIR_OBS_VAR(index); zephir_read_property_this(&index, this_ptr, SL("_index"), PH_NOISY_CC); zephir_is_iterable(chunk, &_8, &_7, 0, 0, "phalcon/logger/adapter/firephp.zep", 92); for ( ; zephir_hash_get_current_data_ex(_8, (void**) &_9, &_7) == SUCCESS ; zephir_hash_move_forward_ex(_8, &_7) ) { ZEPHIR_GET_HMKEY(key, _8, _7); ZEPHIR_GET_HVALUE(chString, _9); zephir_get_strval(_10$$4, index); ZEPHIR_INIT_NVAR(content); ZEPHIR_CONCAT_SVSV(content, "X-Wf-1-1-1-", _10$$4, ": ", chString); if (zephir_array_isset_long(chunk, (zephir_get_numberval(key) + 1))) { zephir_concat_self_str(&content, SL("|\\") TSRMLS_CC); } ZEPHIR_CALL_FUNCTION(NULL, "header", &_2, 248, content); zephir_check_call_status(); ZEPHIR_SEPARATE(index); zephir_increment(index); } zephir_update_property_this(this_ptr, SL("_index"), index TSRMLS_CC); ZEPHIR_MM_RESTORE(); }
/** * Get the server variable REMOTE_ADDR, or the first ip of HTTP_X_FORWARDED_FOR (when using proxy) * * @return string $remote_addr ip of client */ PHP_METHOD(Phady_Util_Tools, getRemoteAddr) { zend_bool _0, _2, _3, _9, _15, _21; zval *ips, *remoteAddr = NULL, *_SERVER, *_1, *_4, *_5, *_6, *_7, _8, *_10, *_11, *_12, *_13, _14, *_16, *_17, *_18, *_19, _20, *_22, *_23, *_24, *_25, _26, *_27, _28, *_29, *_30; ZEPHIR_MM_GROW(); zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); _0 = zephir_array_isset_string(_SERVER, SS("HTTP_X_FORWARDED_FOR")); if (_0) { zephir_array_fetch_string(&_1, _SERVER, SL("HTTP_X_FORWARDED_FOR"), PH_NOISY | PH_READONLY, "phady/util/tools.zep", 86 TSRMLS_CC); _0 = zephir_is_true(_1); } _2 = _0; if (_2) { _3 = !(zephir_array_isset_string(_SERVER, SS("REMOTE_ADDR"))); if (!(_3)) { ZEPHIR_INIT_VAR(_4); ZEPHIR_INIT_VAR(_5); ZEPHIR_INIT_VAR(_6); zephir_array_fetch_string(&_7, _SERVER, SL("REMOTE_ADDR"), PH_NOISY | PH_READONLY, "phady/util/tools.zep", 87 TSRMLS_CC); zephir_fast_trim(_6, _7, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); ZEPHIR_SINIT_VAR(_8); ZVAL_STRING(&_8, "/^127\\..*/i", 0); zephir_preg_match(_5, &_8, _6, _4, 0, 0 , 0 TSRMLS_CC); _3 = zephir_is_true(_5); } _9 = _3; if (!(_9)) { ZEPHIR_INIT_VAR(_10); ZEPHIR_INIT_VAR(_11); ZEPHIR_INIT_VAR(_12); zephir_array_fetch_string(&_13, _SERVER, SL("REMOTE_ADDR"), PH_NOISY | PH_READONLY, "phady/util/tools.zep", 87 TSRMLS_CC); zephir_fast_trim(_12, _13, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); ZEPHIR_SINIT_VAR(_14); ZVAL_STRING(&_14, "/^172\\.16.*/i", 0); zephir_preg_match(_11, &_14, _12, _10, 0, 0 , 0 TSRMLS_CC); _9 = zephir_is_true(_11); } _15 = _9; if (!(_15)) { ZEPHIR_INIT_VAR(_16); ZEPHIR_INIT_VAR(_17); ZEPHIR_INIT_VAR(_18); zephir_array_fetch_string(&_19, _SERVER, SL("REMOTE_ADDR"), PH_NOISY | PH_READONLY, "phady/util/tools.zep", 88 TSRMLS_CC); zephir_fast_trim(_18, _19, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); ZEPHIR_SINIT_VAR(_20); ZVAL_STRING(&_20, "/^192\\.168\\.*/i", 0); zephir_preg_match(_17, &_20, _18, _16, 0, 0 , 0 TSRMLS_CC); _15 = zephir_is_true(_17); } _21 = _15; if (!(_21)) { ZEPHIR_INIT_VAR(_22); ZEPHIR_INIT_VAR(_23); ZEPHIR_INIT_VAR(_24); zephir_array_fetch_string(&_25, _SERVER, SL("REMOTE_ADDR"), PH_NOISY | PH_READONLY, "phady/util/tools.zep", 88 TSRMLS_CC); zephir_fast_trim(_24, _25, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); ZEPHIR_SINIT_VAR(_26); ZVAL_STRING(&_26, "/^10\\..*/i", 0); zephir_preg_match(_23, &_26, _24, _22, 0, 0 , 0 TSRMLS_CC); _21 = zephir_is_true(_23); } _2 = _21; } if (_2) { zephir_array_fetch_string(&_27, _SERVER, SL("HTTP_X_FORWARDED_FOR"), PH_NOISY | PH_READONLY, "phady/util/tools.zep", 90 TSRMLS_CC); ZEPHIR_SINIT_VAR(_28); ZVAL_STRING(&_28, ",", 0); ZEPHIR_INIT_VAR(_29); zephir_fast_strpos(_29, _27, &_28, 0 ); if (zephir_is_true(_29)) { zephir_array_fetch_string(&_30, _SERVER, SL("HTTP_X_FORWARDED_FOR"), PH_NOISY | PH_READONLY, "phady/util/tools.zep", 92 TSRMLS_CC); ZEPHIR_INIT_VAR(ips); zephir_fast_explode_str(ips, SL(","), _30, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(remoteAddr); zephir_array_fetch_long(&remoteAddr, ips, 0, PH_NOISY, "phady/util/tools.zep", 93 TSRMLS_CC); } else { ZEPHIR_OBS_NVAR(remoteAddr); zephir_array_fetch_string(&remoteAddr, _SERVER, SL("HTTP_X_FORWARDED_FOR"), PH_NOISY, "phady/util/tools.zep", 96 TSRMLS_CC); } } else { ZEPHIR_OBS_NVAR(remoteAddr); zephir_array_fetch_string(&remoteAddr, _SERVER, SL("REMOTE_ADDR"), PH_NOISY, "phady/util/tools.zep", 99 TSRMLS_CC); } RETURN_CCTOR(remoteAddr); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_File, validate) { zephir_fcall_cache_entry *_10 = NULL, *_12 = NULL, *_29 = NULL; zend_bool _2, _3, _4, _6, _7, _13, _14, _15, _17, _18, _20, _24, _25, _37, _38, _40; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *value = NULL, *message = NULL, *label = NULL, *replacePairs = NULL, *types = NULL, *byteUnits, *unit = NULL, *maxSize = NULL, *matches, *bytes, *mime = NULL, *tmp = NULL, *width, *height, *minResolution, *maxResolution, *minWidth = NULL, *maxWidth, *minHeight = NULL, *maxHeight, *_0 = NULL, *_SERVER, *_1, *_POST, *_FILES, *_5, *_8, *_9 = NULL, *_11 = NULL, *_16, *_19, *_21, *_22 = NULL, *_23 = NULL, *_26 = NULL, *_27, *_28, *_30 = NULL, *_31, _32 = zval_used_for_init, *_33, *_34 = NULL, *_35 = NULL, *_36, *_39 = NULL, *_41 = NULL; ZEPHIR_MM_GROW(); zephir_get_global(&_FILES, SS("_FILES") TSRMLS_CC); zephir_get_global(&_POST, SS("_POST") TSRMLS_CC); zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } zephir_array_fetch_string(&_1, _SERVER, SL("REQUEST_METHOD"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 62 TSRMLS_CC); _2 = ZEPHIR_IS_STRING(_1, "POST"); if (_2) { _2 = ZEPHIR_IS_EMPTY(_POST); } _3 = _2; if (_3) { _3 = ZEPHIR_IS_EMPTY(_FILES); } _4 = _3; if (_4) { zephir_array_fetch_string(&_5, _SERVER, SL("CONTENT_LENGTH"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 62 TSRMLS_CC); _4 = ZEPHIR_GT_LONG(_5, 0); } _6 = _4; if (!(_6)) { _7 = zephir_array_isset_string(value, SS("error")); if (_7) { zephir_array_fetch_string(&_8, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 62 TSRMLS_CC); _7 = ZEPHIR_IS_LONG_IDENTICAL(_8, 1); } _6 = _7; } if (_6) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "messageIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "FileIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_9, "strtr", &_10, 53, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_11); ZVAL_STRING(_11, "FileIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", &_12, 436, _9, field, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _0); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_9, this_ptr, "issetoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); _13 = zephir_is_true(_9); if (_13) { _14 = ZEPHIR_IS_EMPTY(value); if (!(_14)) { _15 = zephir_array_isset_string(value, SS("error")); if (_15) { zephir_array_fetch_string(&_16, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 75 TSRMLS_CC); _15 = ZEPHIR_IS_LONG_IDENTICAL(_16, 4); } _14 = _15; } _13 = _14; } if (_13) { RETURN_MM_BOOL(1); } _17 = !(zephir_array_isset_string(value, SS("error"))); if (!(_17)) { _17 = !(zephir_array_isset_string(value, SS("tmp_name"))); } _18 = _17; if (!(_18)) { zephir_array_fetch_string(&_19, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 79 TSRMLS_CC); _18 = !ZEPHIR_IS_LONG_IDENTICAL(_19, 0); } _20 = _18; if (!(_20)) { zephir_array_fetch_string(&_21, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 79 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_9, "is_uploaded_file", NULL, 232, _21); zephir_check_call_status(); _20 = !zephir_is_true(_9); } if (_20) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "messageEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "FileEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_11); object_init_ex(_11, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_22, "strtr", &_10, 53, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_23); ZVAL_STRING(_23, "FileEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _11, "__construct", &_12, 436, _22, field, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _11); zephir_check_call_status(); RETURN_MM_BOOL(0); } _24 = !(zephir_array_isset_string(value, SS("name"))); if (!(_24)) { _24 = !(zephir_array_isset_string(value, SS("type"))); } _25 = _24; if (!(_25)) { _25 = !(zephir_array_isset_string(value, SS("size"))); } if (_25) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "messageValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "FileValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_11); object_init_ex(_11, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_9, "strtr", &_10, 53, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_23); ZVAL_STRING(_23, "FileValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _11, "__construct", &_12, 436, _9, field, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _11); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "maxSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_9, this_ptr, "issetoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); if (zephir_is_true(_9)) { ZEPHIR_INIT_VAR(byteUnits); zephir_create_array(byteUnits, 9, 0 TSRMLS_CC); add_assoc_long_ex(byteUnits, SS("B"), 0); add_assoc_long_ex(byteUnits, SS("K"), 10); add_assoc_long_ex(byteUnits, SS("M"), 20); add_assoc_long_ex(byteUnits, SS("G"), 30); add_assoc_long_ex(byteUnits, SS("T"), 40); add_assoc_long_ex(byteUnits, SS("KB"), 10); add_assoc_long_ex(byteUnits, SS("MB"), 20); add_assoc_long_ex(byteUnits, SS("GB"), 30); add_assoc_long_ex(byteUnits, SS("TB"), 40); ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "maxSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&maxSize, this_ptr, "getoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); ZEPHIR_INIT_VAR(unit); ZVAL_STRING(unit, "B", 1); ZEPHIR_INIT_NVAR(_11); ZEPHIR_INIT_NVAR(_23); ZEPHIR_INIT_VAR(_26); zephir_array_keys(_26, byteUnits TSRMLS_CC); zephir_fast_join_str(_23, SL("|"), _26 TSRMLS_CC); ZEPHIR_INIT_VAR(_27); ZEPHIR_CONCAT_SVS(_27, "/^([0-9]+(?:\\.[0-9]+)?)(", _23, ")?$/Di"); zephir_preg_match(_11, _27, maxSize, matches, 0, 0 , 0 TSRMLS_CC); if (zephir_array_isset_long(matches, 2)) { ZEPHIR_OBS_NVAR(unit); zephir_array_fetch_long(&unit, matches, 2, PH_NOISY, "phalcon/validation/validator/file.zep", 115 TSRMLS_CC); } zephir_array_fetch_long(&_28, matches, 1, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 118 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_22, "floatval", &_29, 311, _28); zephir_check_call_status(); ZEPHIR_INIT_VAR(_30); zephir_array_fetch(&_31, byteUnits, unit, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 118 TSRMLS_CC); ZEPHIR_SINIT_VAR(_32); ZVAL_LONG(&_32, 2); zephir_pow_function(_30, &_32, _31); ZEPHIR_INIT_VAR(bytes); mul_function(bytes, _22, _30 TSRMLS_CC); zephir_array_fetch_string(&_33, value, SL("size"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 120 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_22, "floatval", &_29, 311, _33); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_34, "floatval", &_29, 311, bytes); zephir_check_call_status(); if (ZEPHIR_GT(_22, _34)) { ZEPHIR_INIT_NVAR(_30); ZVAL_STRING(_30, "messageSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _30); zephir_check_temp_parameter(_30); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":max"), &maxSize, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_30); ZVAL_STRING(_30, "FileSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _30); zephir_check_temp_parameter(_30); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_30); object_init_ex(_30, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_35, "strtr", &_10, 53, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_36); ZVAL_STRING(_36, "FileSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _30, "__construct", &_12, 436, _35, field, _36); zephir_check_temp_parameter(_36); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _30); zephir_check_call_status(); RETURN_MM_BOOL(0); } } ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_9, this_ptr, "issetoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); if (zephir_is_true(_9)) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&types, this_ptr, "getoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); if (Z_TYPE_P(types) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Option 'allowedTypes' must be an array", "phalcon/validation/validator/file.zep", 138); return; } if ((zephir_function_exists_ex(SS("finfo_open") TSRMLS_CC) == SUCCESS)) { ZEPHIR_SINIT_NVAR(_32); ZVAL_LONG(&_32, 16); ZEPHIR_CALL_FUNCTION(&tmp, "finfo_open", NULL, 229, &_32); zephir_check_call_status(); zephir_array_fetch_string(&_28, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 143 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&mime, "finfo_file", NULL, 230, tmp, _28); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(NULL, "finfo_close", NULL, 231, tmp); zephir_check_call_status(); } else { ZEPHIR_OBS_NVAR(mime); zephir_array_fetch_string(&mime, value, SL("type"), PH_NOISY, "phalcon/validation/validator/file.zep", 147 TSRMLS_CC); } if (!(zephir_fast_in_array(mime, types TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "messageType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_11); zephir_fast_join_str(_11, SL(", "), types TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":types"), &_11, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "FileType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_11); object_init_ex(_11, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_22, "strtr", &_10, 53, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_23); ZVAL_STRING(_23, "FileType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _11, "__construct", &_12, 436, _22, field, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _11); zephir_check_call_status(); RETURN_MM_BOOL(0); } } ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_9, this_ptr, "issetoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); _37 = zephir_is_true(_9); if (!(_37)) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_22, this_ptr, "issetoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); _37 = zephir_is_true(_22); } if (_37) { zephir_array_fetch_string(&_28, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 164 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&tmp, "getimagesize", NULL, 249, _28); zephir_check_call_status(); ZEPHIR_OBS_VAR(width); zephir_array_fetch_long(&width, tmp, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 165 TSRMLS_CC); ZEPHIR_OBS_VAR(height); zephir_array_fetch_long(&height, tmp, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 166 TSRMLS_CC); ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_34, this_ptr, "issetoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); if (zephir_is_true(_34)) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_35, this_ptr, "getoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); ZEPHIR_INIT_VAR(minResolution); zephir_fast_explode_str(minResolution, SL("x"), _35, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(minWidth); zephir_array_fetch_long(&minWidth, minResolution, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 170 TSRMLS_CC); ZEPHIR_OBS_VAR(minHeight); zephir_array_fetch_long(&minHeight, minResolution, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 171 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(minWidth); ZVAL_LONG(minWidth, 1); ZEPHIR_INIT_NVAR(minHeight); ZVAL_LONG(minHeight, 1); } _38 = ZEPHIR_LT(width, minWidth); if (!(_38)) { _38 = ZEPHIR_LT(height, minHeight); } if (_38) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "messageMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_35, this_ptr, "getoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); zephir_array_update_string(&replacePairs, SL(":min"), &_35, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "FileMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_11); object_init_ex(_11, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_35, "strtr", &_10, 53, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_23); ZVAL_STRING(_23, "FileMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _11, "__construct", &_12, 436, _35, field, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _11); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_23); ZVAL_STRING(_23, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_35, this_ptr, "issetoption", NULL, 0, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); if (zephir_is_true(_35)) { ZEPHIR_INIT_NVAR(_23); ZVAL_STRING(_23, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_39, this_ptr, "getoption", NULL, 0, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); ZEPHIR_INIT_VAR(maxResolution); zephir_fast_explode_str(maxResolution, SL("x"), _39, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(maxWidth); zephir_array_fetch_long(&maxWidth, maxResolution, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 192 TSRMLS_CC); ZEPHIR_OBS_VAR(maxHeight); zephir_array_fetch_long(&maxHeight, maxResolution, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 193 TSRMLS_CC); _40 = ZEPHIR_GT(width, maxWidth); if (!(_40)) { _40 = ZEPHIR_GT(height, maxHeight); } if (_40) { ZEPHIR_INIT_NVAR(_23); ZVAL_STRING(_23, "messageMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_23); ZVAL_STRING(_23, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_41, this_ptr, "getoption", NULL, 0, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); zephir_array_update_string(&replacePairs, SL(":max"), &_41, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_23); ZVAL_STRING(_23, "FileMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_23); object_init_ex(_23, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_41, "strtr", &_10, 53, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_26); ZVAL_STRING(_26, "FileMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _23, "__construct", &_12, 436, _41, field, _26); zephir_check_temp_parameter(_26); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _23); zephir_check_call_status(); RETURN_MM_BOOL(0); } } } RETURN_MM_BOOL(1); }
/** * 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) { HashTable *_7$$4; HashPosition _6$$4; zval *_18; zend_bool _11, _14; zend_long type, timestamp, ZEPHIR_LAST_CALL_STATUS; zval *message_param = NULL, *type_param = NULL, *timestamp_param = NULL, *context = NULL, *meta = NULL, *body = NULL, *backtrace = NULL, *encoded = NULL, *len = NULL, *lastTrace = NULL, *_1 = NULL, *_2, *_3, *_9, *_10, *_12, *_13, *_15, *_0$$3 = NULL, *param$$4 = NULL, *backtraceItem$$4 = NULL, *key$$4 = NULL, **_8$$4, *_4$$5, *_5$$6, *_16$$11, *_17$$11; 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$$3, this_ptr, "interpolate", NULL, 0, message, context); zephir_check_call_status(); zephir_get_strval(message, _0$$3); } ZEPHIR_INIT_VAR(meta); zephir_create_array(meta, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); ZVAL_LONG(_2, type); ZEPHIR_CALL_METHOD(&_1, this_ptr, "gettypestring", NULL, 0, _2); zephir_check_call_status(); zephir_array_update_string(&meta, SL("Type"), &_1, PH_COPY | PH_SEPARATE); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_showBacktrace"), PH_NOISY_CC); if (zephir_is_true(_3)) { ZEPHIR_INIT_VAR(param$$4); ZVAL_LONG(param$$4, 2); ZEPHIR_CALL_FUNCTION(&backtrace, "debug_backtrace", NULL, 165, param$$4); zephir_check_call_status(); ZEPHIR_MAKE_REF(backtrace); ZEPHIR_CALL_FUNCTION(&lastTrace, "end", NULL, 183, backtrace); ZEPHIR_UNREF(backtrace); zephir_check_call_status(); if (zephir_array_isset_string(lastTrace, SS("file"))) { zephir_array_fetch_string(&_4$$5, lastTrace, SL("file"), PH_NOISY | PH_READONLY, "phalcon/logger/formatter/firephp.zep", 130 TSRMLS_CC); zephir_array_update_string(&meta, SL("File"), &_4$$5, PH_COPY | PH_SEPARATE); } if (zephir_array_isset_string(lastTrace, SS("line"))) { zephir_array_fetch_string(&_5$$6, lastTrace, SL("line"), PH_NOISY | PH_READONLY, "phalcon/logger/formatter/firephp.zep", 134 TSRMLS_CC); zephir_array_update_string(&meta, SL("Line"), &_5$$6, PH_COPY | PH_SEPARATE); } zephir_is_iterable(backtrace, &_7$$4, &_6$$4, 1, 0, "phalcon/logger/formatter/firephp.zep", 143); for ( ; zend_hash_get_current_data_ex(_7$$4, (void**) &_8$$4, &_6$$4) == SUCCESS ; zend_hash_move_forward_ex(_7$$4, &_6$$4) ) { ZEPHIR_GET_HMKEY(key$$4, _7$$4, _6$$4); ZEPHIR_GET_HVALUE(backtraceItem$$4, _8$$4); zephir_array_unset_string(&backtraceItem$$4, SS("object"), PH_SEPARATE); zephir_array_unset_string(&backtraceItem$$4, SS("args"), PH_SEPARATE); zephir_array_update_zval(&backtrace, key$$4, &backtraceItem$$4, PH_COPY | PH_SEPARATE); } zend_hash_destroy(_7$$4); FREE_HASHTABLE(_7$$4); } _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$$11 = zephir_fetch_nproperty_this(this_ptr, SL("_showBacktrace"), PH_NOISY_CC); if (zephir_is_true(_16$$11)) { zephir_array_update_string(&body, SL("backtrace"), &backtrace, PH_COPY | PH_SEPARATE); } _17$$11 = zephir_fetch_nproperty_this(this_ptr, SL("_enableLabels"), PH_NOISY_CC); if (!(zephir_is_true(_17$$11))) { 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(); }
/** * Returns a cached content * * @param int|string keyName * @param int lifetime * @return mixed */ PHP_METHOD(Phalcon_Cache_Backend_File, get) { zephir_nts_static zephir_fcall_cache_entry *_8 = NULL; int ttl, modifiedTime, ZEPHIR_LAST_CALL_STATUS; zval *keyName, *lifetime = NULL, *prefixedKey, *cacheDir, *cacheFile, *frontend, *lastLifetime, *cachedContent, *ret = NULL, *_0, *_1 = NULL, *_2, *_3 = NULL, *_4, *_5, *_6, *_7; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &keyName, &lifetime); if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_1, this_ptr, "getkey", NULL, keyName); zephir_check_call_status(); ZEPHIR_INIT_VAR(prefixedKey); ZEPHIR_CONCAT_VV(prefixedKey, _0, _1); zephir_update_property_this(this_ptr, SL("_lastKey"), prefixedKey TSRMLS_CC); ZEPHIR_OBS_VAR(cacheDir); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (!(zephir_array_isset_string_fetch(&cacheDir, _2, SS("cacheDir"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/file.zep", 115); return; } ZEPHIR_INIT_VAR(cacheFile); ZEPHIR_CONCAT_VV(cacheFile, cacheDir, prefixedKey); if ((zephir_file_exists(cacheFile TSRMLS_CC) == SUCCESS) == 1) { ZEPHIR_OBS_VAR(frontend); zephir_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC); if (!(zephir_is_true(lifetime))) { ZEPHIR_OBS_VAR(lastLifetime); zephir_read_property_this(&lastLifetime, this_ptr, SL("_lastLifetime"), PH_NOISY_CC); if (!(zephir_is_true(lastLifetime))) { ZEPHIR_CALL_METHOD(&_3, frontend, "getlifetime", NULL); zephir_check_call_status(); ttl = zephir_get_intval(_3); } else { ttl = zephir_get_intval(lastLifetime); } } else { ttl = zephir_get_intval(lifetime); } ZEPHIR_INIT_VAR(_4); zephir_filemtime(_4, cacheFile TSRMLS_CC); modifiedTime = zephir_get_intval(_4); ZEPHIR_INIT_VAR(_5); zephir_time(_5); if (!((zephir_get_numberval(_5) - ttl) > modifiedTime)) { ZEPHIR_INIT_VAR(cachedContent); zephir_file_get_contents(cachedContent, cacheFile TSRMLS_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(cachedContent)) { ZEPHIR_INIT_VAR(_6); object_init_ex(_6, phalcon_cache_exception_ce); ZEPHIR_INIT_VAR(_7); ZEPHIR_CONCAT_SVS(_7, "Cache file ", cacheFile, " could not be opened"); ZEPHIR_CALL_METHOD(NULL, _6, "__construct", &_8, _7); zephir_check_call_status(); zephir_throw_exception_debug(_6, "phalcon/cache/backend/file.zep", 151 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (zephir_is_numeric(cachedContent)) { RETURN_CCTOR(cachedContent); } else { ZEPHIR_CALL_METHOD(&ret, frontend, "afterretrieve", NULL, cachedContent); zephir_check_call_status(); RETURN_CCTOR(ret); } } } ZEPHIR_MM_RESTORE(); }
/** * Validates the data from the decoded JWT. * * @return boolean TRUE if the JWT request is valid and can be decoded. Otherwise, FALSE is returned. * * @see OAuth2\GrantType\GrantTypeInterface::getTokenData() */ PHP_METHOD(OAuth2_GrantType_JwtBearer, validateRequest) { zend_bool _14, _21; zephir_fcall_cache_entry *_9 = NULL, *_12 = NULL; zval *_6; int ZEPHIR_LAST_CALL_STATUS; zval *request, *response, *undecodedJWT = NULL, *jwt = NULL, *notBefore, *jti = NULL, *key = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4, *_5 = NULL, *_7, *_8 = NULL, *_10, *_11 = NULL, *_13 = NULL, *_15, *_16, *_17, *_18, *_19, *_20, *_22, *_23, *_24, *_25, *_26, *_27, *_28; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &request, &response); if (!(zephir_instance_of_ev(request, oauth2_requestinterface_ce TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Parameter 'request' must be an instance of 'OAuth2\\RequestInterface'", "", 0); return; } if (!(zephir_instance_of_ev(response, oauth2_responseinterface_ce TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Parameter 'response' must be an instance of 'OAuth2\\ResponseInterface'", "", 0); return; } ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "assertion", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, request, "request", NULL, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (!(zephir_is_true(_0))) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "invalid_request", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "Missing parameters: \"assertion\" required", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "assertion", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&undecodedJWT, request, "request", NULL, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); _4 = zephir_fetch_nproperty_this(this_ptr, SL("jwtUtil"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "assertion", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_5, request, "request", NULL, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_1); ZVAL_NULL(_1); ZEPHIR_INIT_NVAR(_2); ZVAL_BOOL(_2, 0); ZEPHIR_CALL_METHOD(&jwt, _4, "decode", NULL, _5, _1, _2); zephir_check_call_status(); if (!(zephir_is_true(jwt))) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "invalid_request", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "JWT is malformed", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_1); ZEPHIR_INIT_VAR(_6); array_init_size(_6, 12); zephir_array_update_string(&_6, SL("scope"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_array_update_string(&_6, SL("iss"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_array_update_string(&_6, SL("sub"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_array_update_string(&_6, SL("aud"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_array_update_string(&_6, SL("exp"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_array_update_string(&_6, SL("nbf"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_array_update_string(&_6, SL("iat"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_array_update_string(&_6, SL("jti"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_array_update_string(&_6, SL("typ"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_fast_array_merge(_1, &(_6), &(jwt) TSRMLS_CC); ZEPHIR_CPY_WRT(jwt, _1); if (!(zephir_array_isset_string(jwt, SS("iss")))) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "invalid_grant", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "Invalid issuer (iss) provided", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } if (!(zephir_array_isset_string(jwt, SS("sub")))) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "invalid_grant", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "Invalid subject (sub) provided", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } if (!(zephir_array_isset_string(jwt, SS("exp")))) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "invalid_grant", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "Expiration (exp) time must be present", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } zephir_array_fetch_string(&_7, jwt, SL("exp"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 115 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_8, "ctype_digit", &_9, _7); zephir_check_call_status(); if (zephir_is_true(_8)) { zephir_array_fetch_string(&_10, jwt, SL("exp"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 116 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_11, "time", &_12); zephir_check_call_status(); if (ZEPHIR_LE(_10, _11)) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "invalid_grant", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "JWT has expired", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } } else { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "invalid_grant", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "Expiration (exp) time must be a unix time stamp", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_OBS_VAR(notBefore); zephir_array_fetch_string(¬Before, jwt, SL("nbf"), PH_NOISY, "oauth2/granttype/jwtbearer.zep", 126 TSRMLS_CC); if (zephir_is_true(notBefore)) { ZEPHIR_CALL_FUNCTION(&_11, "ctype_digit", &_9, notBefore); zephir_check_call_status(); if (zephir_is_true(_11)) { ZEPHIR_CALL_FUNCTION(&_13, "time", &_12); zephir_check_call_status(); if (ZEPHIR_GT(notBefore, _13)) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "invalid_grant", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "JWT cannot be used before the Not Before (nbf) time", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } } else { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "invalid_grant", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "Not Before (nbf) time must be a unix time stamp", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } } _14 = !zephir_array_isset_string(jwt, SS("aud")); if (!(_14)) { zephir_array_fetch_string(&_10, jwt, SL("aud"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 140 TSRMLS_CC); _15 = zephir_fetch_nproperty_this(this_ptr, SL("audience"), PH_NOISY_CC); _14 = !ZEPHIR_IS_EQUAL(_10, _15); } if (_14) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "invalid_grant", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "Invalid audience (aud)", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } if (zephir_array_isset_string(jwt, SS("jti"))) { _16 = zephir_fetch_nproperty_this(this_ptr, SL("storage"), PH_NOISY_CC); zephir_array_fetch_string(&_10, jwt, SL("iss"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 148 TSRMLS_CC); zephir_array_fetch_string(&_17, jwt, SL("sub"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 148 TSRMLS_CC); zephir_array_fetch_string(&_18, jwt, SL("aud"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 148 TSRMLS_CC); zephir_array_fetch_string(&_19, jwt, SL("exp"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 148 TSRMLS_CC); zephir_array_fetch_string(&_20, jwt, SL("jti"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 148 TSRMLS_CC); ZEPHIR_CALL_METHOD(&jti, _16, "getjti", NULL, _10, _17, _18, _19, _20); zephir_check_call_status(); _21 = zephir_is_true(jti); if (_21) { zephir_array_fetch_string(&_22, jti, SL("expires"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 151 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_11, "time", &_12); zephir_check_call_status(); _21 = ZEPHIR_GT(_22, _11); } if (_21) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "invalid_grant", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "JSON Token Identifier (jti) has already been used", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } else { _23 = zephir_fetch_nproperty_this(this_ptr, SL("storage"), PH_NOISY_CC); zephir_array_fetch_string(&_24, jwt, SL("iss"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 155 TSRMLS_CC); zephir_array_fetch_string(&_25, jwt, SL("sub"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 155 TSRMLS_CC); zephir_array_fetch_string(&_26, jwt, SL("aud"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 155 TSRMLS_CC); zephir_array_fetch_string(&_27, jwt, SL("exp"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 155 TSRMLS_CC); zephir_array_fetch_string(&_28, jwt, SL("jti"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 155 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, _23, "setjti", NULL, _24, _25, _26, _27, _28); zephir_check_call_status(); } } _16 = zephir_fetch_nproperty_this(this_ptr, SL("storage"), PH_NOISY_CC); zephir_array_fetch_string(&_10, jwt, SL("iss"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 161 TSRMLS_CC); zephir_array_fetch_string(&_17, jwt, SL("sub"), PH_NOISY | PH_READONLY, "oauth2/granttype/jwtbearer.zep", 161 TSRMLS_CC); ZEPHIR_CALL_METHOD(&key, _16, "getclientkey", NULL, _10, _17); zephir_check_call_status(); if (!(zephir_is_true(key))) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "invalid_grant", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "Invalid issuer (iss) or subject (sub) provided", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } _16 = zephir_fetch_nproperty_this(this_ptr, SL("jwtUtil"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_1); ZVAL_BOOL(_1, 1); ZEPHIR_CALL_METHOD(&_11, _16, "decode", NULL, undecodedJWT, key, _1); zephir_check_call_status(); if (!(zephir_is_true(_11))) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 400); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "invalid_grant", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "JWT failed signature verification", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "seterror", NULL, _1, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_MM_BOOL(0); } zephir_update_property_this(this_ptr, SL("jwt"), jwt TSRMLS_CC); RETURN_MM_BOOL(1); }
/** * Stores cached content into the file backend and stops the frontend * * @param int|string keyName * @param string content * @param int lifetime * @param boolean stopBuffer */ PHP_METHOD(Phalcon_Cache_Backend_File, save) { zephir_nts_static zephir_fcall_cache_entry *_4 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *keyName = NULL, *content = NULL, *lifetime = NULL, *stopBuffer = NULL, *lastKey = NULL, *frontend, *cacheDir, *isBuffering = NULL, *cacheFile, *cachedContent = NULL, *preparedContent = NULL, *status = NULL, *_0, *_1 = NULL, *_2, *_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 4, &keyName, &content, &lifetime, &stopBuffer); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!content) { content = ZEPHIR_GLOBAL(global_null); } if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } if (!stopBuffer) { stopBuffer = ZEPHIR_GLOBAL(global_true); } 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_CALL_METHOD(&_1, this_ptr, "getkey", NULL, keyName); zephir_check_call_status(); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_VV(lastKey, _0, _1); } if (!(zephir_is_true(lastKey))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Cache must be started first", "phalcon/cache/backend/file.zep", 186); return; } ZEPHIR_OBS_VAR(frontend); zephir_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC); ZEPHIR_OBS_VAR(cacheDir); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (!(zephir_array_isset_string_fetch(&cacheDir, _0, SS("cacheDir"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/file.zep", 192); return; } ZEPHIR_INIT_VAR(cacheFile); ZEPHIR_CONCAT_VV(cacheFile, cacheDir, lastKey); if (!(zephir_is_true(content))) { ZEPHIR_CALL_METHOD(&cachedContent, frontend, "getcontent", NULL); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(cachedContent, content); } ZEPHIR_CALL_METHOD(&preparedContent, frontend, "beforestore", NULL, cachedContent); zephir_check_call_status(); if (!(zephir_is_numeric(cachedContent))) { ZEPHIR_INIT_VAR(status); zephir_file_put_contents(status, cacheFile, preparedContent TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(status); zephir_file_put_contents(status, cacheFile, cachedContent TSRMLS_CC); } if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { ZEPHIR_INIT_VAR(_2); object_init_ex(_2, phalcon_cache_exception_ce); ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_SVS(_3, "Cache file ", cacheFile, " could not be written"); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_4, _3); zephir_check_call_status(); zephir_throw_exception_debug(_2, "phalcon/cache/backend/file.zep", 215 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_CALL_METHOD(&isBuffering, frontend, "isbuffering", NULL); zephir_check_call_status(); if (ZEPHIR_IS_TRUE_IDENTICAL(stopBuffer)) { ZEPHIR_CALL_METHOD(NULL, frontend, "stop", NULL); 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); ZEPHIR_MM_RESTORE(); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_Regex, validate) { int ZEPHIR_LAST_CALL_STATUS; zend_bool failed, _2; zval *field = NULL; zval *validation, *field_param = NULL, *matches, *message = NULL, *value = NULL, *label = NULL, *replacePairs, *_0 = NULL, *_1 = NULL, *_3 = NULL, *_4 = NULL, *_5, *_6 = NULL, *_7; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, this_ptr, "issetoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); _2 = zephir_is_true(_0); if (_2) { _2 = ZEPHIR_IS_EMPTY(value); } if (_2) { RETURN_MM_BOOL(1); } ZEPHIR_INIT_NVAR(_1); ZEPHIR_INIT_VAR(_4); ZVAL_STRING(_4, "pattern", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3, this_ptr, "getoption", NULL, 0, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_preg_match(_1, _3, value, matches, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(_1)) { zephir_array_fetch_long(&_5, matches, 0, PH_NOISY | PH_READONLY, "phalcon/validation/validator/regex.zep", 62 TSRMLS_CC); failed = !ZEPHIR_IS_EQUAL(_5, value); } else { failed = 1; } if (failed == 1) { ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Regex", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_4); object_init_ex(_4, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_6, "strtr", NULL, 53, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_7); ZVAL_STRING(_7, "Regex", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _4, "__construct", NULL, 432, _6, field, _7); zephir_check_temp_parameter(_7); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _4); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); }
/** * Redirect by HTTP to another action or URL * *<code> * //Using a string redirect (internal/external) * $response->redirect("posts/index"); * $response->redirect("http://en.wikipedia.org", true); * $response->redirect("http://www.example.com/new-location", true, 301); * * //Making a redirection based on a named route * $response->redirect(array( * "for" => "index-lang", * "lang" => "jp", * "controller" => "index" * )); *</code> * * @param string|array location * @param boolean externalRedirect * @param int statusCode * @return \Phalcon\Http\Response */ PHP_METHOD(Phalcon_Http_Response, redirect) { int statusCode, ZEPHIR_LAST_CALL_STATUS; zend_bool externalRedirect, _10, _0$$5; zval *location = NULL, *externalRedirect_param = NULL, *statusCode_param = NULL, *header = NULL, *url = NULL, *dependencyInjector = NULL, *matched = NULL, *view = NULL, *_7 = NULL, *_8 = NULL, _1$$5, *_2$$5 = NULL, *_3$$6, _4$$6, *_5$$10 = NULL, *_6$$10, *_9$$11; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 3, &location, &externalRedirect_param, &statusCode_param); if (!location) { ZEPHIR_CPY_WRT(location, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(location); } if (!externalRedirect_param) { externalRedirect = 0; } else { externalRedirect = zephir_get_boolval(externalRedirect_param); } if (!statusCode_param) { statusCode = 302; } else { statusCode = zephir_get_intval(statusCode_param); } if (!(zephir_is_true(location))) { ZEPHIR_INIT_NVAR(location); ZVAL_STRING(location, "", 1); } if (externalRedirect) { ZEPHIR_CPY_WRT(header, location); } else { _0$$5 = Z_TYPE_P(location) == IS_STRING; if (_0$$5) { ZEPHIR_SINIT_VAR(_1$$5); ZVAL_STRING(&_1$$5, "://", 0); ZEPHIR_CALL_FUNCTION(&_2$$5, "strstr", NULL, 236, location, &_1$$5); zephir_check_call_status(); _0$$5 = zephir_is_true(_2$$5); } if (_0$$5) { ZEPHIR_INIT_VAR(_3$$6); ZEPHIR_SINIT_VAR(_4$$6); ZVAL_STRING(&_4$$6, "/^[^:\\/?#]++:/", 0); ZEPHIR_INIT_VAR(matched); zephir_preg_match(matched, &_4$$6, location, _3$$6, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(matched)) { ZEPHIR_CPY_WRT(header, location); } else { ZEPHIR_INIT_NVAR(header); ZVAL_NULL(header); } } else { ZEPHIR_INIT_NVAR(header); ZVAL_NULL(header); } } ZEPHIR_CALL_METHOD(&dependencyInjector, this_ptr, "getdi", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(header))) { ZEPHIR_INIT_VAR(_6$$10); ZVAL_STRING(_6$$10, "url", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_5$$10, dependencyInjector, "getshared", NULL, 0, _6$$10); zephir_check_temp_parameter(_6$$10); zephir_check_call_status(); ZEPHIR_CPY_WRT(url, _5$$10); ZEPHIR_CALL_METHOD(&header, url, "get", NULL, 0, location); zephir_check_call_status(); } ZEPHIR_INIT_VAR(_8); ZVAL_STRING(_8, "view", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_7, dependencyInjector, "has", NULL, 0, _8); zephir_check_temp_parameter(_8); zephir_check_call_status(); if (zephir_is_true(_7)) { ZEPHIR_INIT_VAR(_9$$11); ZVAL_STRING(_9$$11, "view", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&view, dependencyInjector, "getshared", NULL, 0, _9$$11); zephir_check_temp_parameter(_9$$11); zephir_check_call_status(); if (zephir_instance_of_ev(view, phalcon_mvc_viewinterface_ce TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, view, "disable", NULL, 0); zephir_check_call_status(); } } _10 = statusCode < 300; if (!(_10)) { _10 = statusCode > 308; } if (_10) { statusCode = 302; } ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, statusCode); ZEPHIR_CALL_METHOD(NULL, this_ptr, "setstatuscode", NULL, 0, _8); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_8); ZVAL_STRING(_8, "Location", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "setheader", NULL, 0, _8, header); zephir_check_temp_parameter(_8); zephir_check_call_status(); RETURN_THIS(); }
/** * Resolves the service * * @param array parameters * @param \Phalcon\DiInterface dependencyInjector * @return mixed */ PHP_METHOD(Phalcon_Di_Service, resolve) { zend_class_entry *_1$$15; zend_bool found = 0; int ZEPHIR_LAST_CALL_STATUS; zval *parameters = NULL, *dependencyInjector = NULL, *shared = NULL, *definition = NULL, *sharedInstance = NULL, *instance = NULL, *builder = NULL, *_0$$15 = NULL, *_2$$22, *_3$$22, *_4$$22; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, ¶meters, &dependencyInjector); if (!parameters) { parameters = ZEPHIR_GLOBAL(global_null); } if (!dependencyInjector) { dependencyInjector = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(shared); zephir_read_property_this(&shared, this_ptr, SL("_shared"), PH_NOISY_CC); if (zephir_is_true(shared)) { ZEPHIR_OBS_VAR(sharedInstance); zephir_read_property_this(&sharedInstance, this_ptr, SL("_sharedInstance"), PH_NOISY_CC); if (Z_TYPE_P(sharedInstance) != IS_NULL) { RETURN_CCTOR(sharedInstance); } } found = 1; ZEPHIR_INIT_VAR(instance); ZVAL_NULL(instance); ZEPHIR_OBS_VAR(definition); zephir_read_property_this(&definition, this_ptr, SL("_definition"), PH_NOISY_CC); if (Z_TYPE_P(definition) == IS_STRING) { if (zephir_class_exists(definition, 1 TSRMLS_CC)) { if (Z_TYPE_P(parameters) == IS_ARRAY) { if (zephir_fast_count_int(parameters TSRMLS_CC)) { ZEPHIR_INIT_NVAR(instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(instance, definition, parameters TSRMLS_CC); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(instance, definition TSRMLS_CC); zephir_check_call_status(); } } else { ZEPHIR_INIT_NVAR(instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(instance, definition TSRMLS_CC); zephir_check_call_status(); } } else { found = 0; } } else { if (Z_TYPE_P(definition) == IS_OBJECT) { if (zephir_instance_of_ev(definition, zend_ce_closure TSRMLS_CC)) { if (Z_TYPE_P(dependencyInjector) == IS_OBJECT) { _1$$15 = zend_fetch_class(SL("Closure"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&_0$$15, _1$$15, "bind", NULL, 0, definition, dependencyInjector); zephir_check_call_status(); ZEPHIR_CPY_WRT(definition, _0$$15); } if (Z_TYPE_P(parameters) == IS_ARRAY) { ZEPHIR_INIT_NVAR(instance); ZEPHIR_CALL_USER_FUNC_ARRAY(instance, definition, parameters); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(instance); ZEPHIR_CALL_USER_FUNC(instance, definition); zephir_check_call_status(); } } else { ZEPHIR_CPY_WRT(instance, definition); } } else { if (Z_TYPE_P(definition) == IS_ARRAY) { ZEPHIR_INIT_VAR(builder); object_init_ex(builder, phalcon_di_service_builder_ce); if (zephir_has_constructor(builder TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, builder, "__construct", NULL, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&instance, builder, "build", NULL, 181, dependencyInjector, definition, parameters); zephir_check_call_status(); } else { found = 0; } } } if (found == 0) { ZEPHIR_INIT_VAR(_2$$22); object_init_ex(_2$$22, phalcon_di_exception_ce); _3$$22 = zephir_fetch_nproperty_this(this_ptr, SL("_name"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_4$$22); ZEPHIR_CONCAT_SVS(_4$$22, "Service '", _3$$22, "' cannot be resolved"); ZEPHIR_CALL_METHOD(NULL, _2$$22, "__construct", NULL, 9, _4$$22); zephir_check_call_status(); zephir_throw_exception_debug(_2$$22, "phalcon/di/service.zep", 208 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (zephir_is_true(shared)) { zephir_update_property_this(this_ptr, SL("_sharedInstance"), instance TSRMLS_CC); } if (1) { zephir_update_property_this(this_ptr, SL("_resolved"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_resolved"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_CCTOR(instance); }
/** * Set an specific argument */ PHP_METHOD(Phalcon_Cli_Console, setArgument) { HashTable *_3; HashPosition _2; int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_1 = NULL, *_8 = NULL, *_27 = NULL; zend_bool str, shift, _0; zval *arguments_param = NULL, *str_param = NULL, *shift_param = NULL, *arg = NULL, *pos = NULL, *args = NULL, *opts = NULL, *handleArgs = NULL, **_4, _5$$5 = zval_used_for_init, _6$$5 = zval_used_for_init, *_7$$5 = NULL, _9$$6 = zval_used_for_init, *_10$$7 = NULL, _11$$7 = zval_used_for_init, *_12$$7 = NULL, *_13$$7 = NULL, _14$$7 = zval_used_for_init, _15$$7 = zval_used_for_init, *_16$$7 = NULL, *_17$$8 = NULL, _18$$8 = zval_used_for_init, *_19$$8 = NULL, _20$$9 = zval_used_for_init, _21$$9 = zval_used_for_init, *_22$$9 = NULL, _23$$10 = zval_used_for_init, *_24$$10 = NULL, *_25$$13, *_26$$13 = NULL, *_28$$15 = NULL, *_29$$16 = NULL, *_30$$17; zval *arguments = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 3, &arguments_param, &str_param, &shift_param); if (!arguments_param) { ZEPHIR_INIT_VAR(arguments); array_init(arguments); } else { arguments = arguments_param; } if (!str_param) { str = 1; } else { if (unlikely(Z_TYPE_P(str_param) != IS_BOOL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'str' must be a bool") TSRMLS_CC); RETURN_MM_NULL(); } str = Z_BVAL_P(str_param); } if (!shift_param) { shift = 1; } else { if (unlikely(Z_TYPE_P(shift_param) != IS_BOOL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'shift' must be a bool") TSRMLS_CC); RETURN_MM_NULL(); } shift = Z_BVAL_P(shift_param); } ZEPHIR_INIT_VAR(args); array_init(args); ZEPHIR_INIT_VAR(opts); array_init(opts); ZEPHIR_INIT_VAR(handleArgs); array_init(handleArgs); _0 = shift; if (_0) { _0 = ((zephir_fast_count_int(arguments TSRMLS_CC)) ? 1 : 0); } if (_0) { ZEPHIR_MAKE_REF(arguments); ZEPHIR_CALL_FUNCTION(NULL, "array_shift", &_1, 132, arguments); ZEPHIR_UNREF(arguments); zephir_check_call_status(); } zephir_is_iterable(arguments, &_3, &_2, 0, 0, "phalcon/cli/console.zep", 199); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HVALUE(arg, _4); if (Z_TYPE_P(arg) == IS_STRING) { ZEPHIR_SINIT_NVAR(_5$$5); ZVAL_STRING(&_5$$5, "--", 0); ZEPHIR_SINIT_NVAR(_6$$5); ZVAL_LONG(&_6$$5, 2); ZEPHIR_CALL_FUNCTION(&_7$$5, "strncmp", &_8, 133, arg, &_5$$5, &_6$$5); zephir_check_call_status(); if (ZEPHIR_IS_LONG(_7$$5, 0)) { ZEPHIR_SINIT_NVAR(_9$$6); ZVAL_STRING(&_9$$6, "=", 0); ZEPHIR_INIT_NVAR(pos); zephir_fast_strpos(pos, arg, &_9$$6, 0 ); if (zephir_is_true(pos)) { ZEPHIR_INIT_NVAR(_10$$7); ZEPHIR_SINIT_NVAR(_11$$7); ZVAL_LONG(&_11$$7, (zephir_get_numberval(pos) + 1)); ZEPHIR_INIT_NVAR(_12$$7); zephir_substr(_12$$7, arg, zephir_get_intval(&_11$$7), 0, ZEPHIR_SUBSTR_NO_LENGTH); zephir_fast_trim(_10$$7, _12$$7, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); ZEPHIR_INIT_NVAR(_13$$7); ZEPHIR_SINIT_NVAR(_14$$7); ZVAL_LONG(&_14$$7, 2); ZEPHIR_SINIT_NVAR(_15$$7); ZVAL_LONG(&_15$$7, (zephir_get_numberval(pos) - 2)); ZEPHIR_INIT_NVAR(_16$$7); zephir_substr(_16$$7, arg, 2 , zephir_get_intval(&_15$$7), 0); zephir_fast_trim(_13$$7, _16$$7, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); zephir_array_update_zval(&opts, _13$$7, &_10$$7, PH_COPY | PH_SEPARATE); } else { ZEPHIR_INIT_NVAR(_17$$8); ZEPHIR_SINIT_NVAR(_18$$8); ZVAL_LONG(&_18$$8, 2); ZEPHIR_INIT_NVAR(_19$$8); zephir_substr(_19$$8, arg, 2 , 0, ZEPHIR_SUBSTR_NO_LENGTH); zephir_fast_trim(_17$$8, _19$$8, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); zephir_array_update_zval(&opts, _17$$8, &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } } else { ZEPHIR_SINIT_NVAR(_20$$9); ZVAL_STRING(&_20$$9, "-", 0); ZEPHIR_SINIT_NVAR(_21$$9); ZVAL_LONG(&_21$$9, 1); ZEPHIR_CALL_FUNCTION(&_22$$9, "strncmp", &_8, 133, arg, &_20$$9, &_21$$9); zephir_check_call_status(); if (ZEPHIR_IS_LONG(_22$$9, 0)) { ZEPHIR_SINIT_NVAR(_23$$10); ZVAL_LONG(&_23$$10, 1); ZEPHIR_INIT_NVAR(_24$$10); zephir_substr(_24$$10, arg, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); zephir_array_update_zval(&opts, _24$$10, &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } else { zephir_array_append(&args, arg, PH_SEPARATE, "phalcon/cli/console.zep", 191); } } } else { zephir_array_append(&args, arg, PH_SEPARATE, "phalcon/cli/console.zep", 195); } } if (str) { ZEPHIR_INIT_VAR(_25$$13); ZEPHIR_CALL_CE_STATIC(&_26$$13, phalcon_cli_router_route_ce, "getdelimiter", &_27, 134); zephir_check_call_status(); zephir_fast_join(_25$$13, _26$$13, args TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_arguments"), _25$$13 TSRMLS_CC); } else { if (zephir_fast_count_int(args TSRMLS_CC)) { ZEPHIR_MAKE_REF(args); ZEPHIR_CALL_FUNCTION(&_28$$15, "array_shift", &_1, 132, args); ZEPHIR_UNREF(args); zephir_check_call_status(); zephir_array_update_string(&handleArgs, SL("task"), &_28$$15, PH_COPY | PH_SEPARATE); } if (zephir_fast_count_int(args TSRMLS_CC)) { ZEPHIR_MAKE_REF(args); ZEPHIR_CALL_FUNCTION(&_29$$16, "array_shift", &_1, 132, args); ZEPHIR_UNREF(args); zephir_check_call_status(); zephir_array_update_string(&handleArgs, SL("action"), &_29$$16, PH_COPY | PH_SEPARATE); } if (zephir_fast_count_int(args TSRMLS_CC)) { ZEPHIR_INIT_VAR(_30$$17); zephir_fast_array_merge(_30$$17, &(handleArgs), &(args) TSRMLS_CC); ZEPHIR_CPY_WRT(handleArgs, _30$$17); } zephir_update_property_this(this_ptr, SL("_arguments"), handleArgs TSRMLS_CC); } zephir_update_property_this(this_ptr, SL("_options"), opts TSRMLS_CC); RETURN_THIS(); }