/** * Returns an array of Phalcon\Db\Column objects describing a table * * <code>print_r($connection->describeColumns("posts")); ?></code> * * @param string $table * @param string $schema * @return Phalcon\Db\Column[] */ PHP_METHOD(Phalcon_Db_Adapter_Pdo_Oracle, describeColumns){ zval *table, *schema = NULL, *columns, *dialect, *sql, *fetch_num; zval *describe, *old_column = NULL, *field = NULL, *definition = NULL; zval *column_size = NULL, *column_precision = NULL, *column_scale = NULL; zval *column_type = NULL, *attribute = NULL, *column_name = NULL; zval *column = NULL; HashTable *ah0; HashPosition hp0; zval **hd; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 1, &table, &schema); if (!schema) { PHALCON_INIT_VAR(schema); } PHALCON_INIT_VAR(columns); array_init(columns); PHALCON_OBS_VAR(dialect); phalcon_read_property_this(&dialect, this_ptr, SL("_dialect"), PH_NOISY_CC); PHALCON_INIT_VAR(sql); phalcon_call_method_p2(sql, dialect, "describecolumns", table, schema); /** * We're using FETCH_NUM to fetch the columns */ PHALCON_INIT_VAR(fetch_num); ZVAL_LONG(fetch_num, 3); PHALCON_INIT_VAR(describe); phalcon_call_method_p2(describe, this_ptr, "fetchall", sql, fetch_num); /** * 0:column_name, 1:data_type, 2:data_length, 3:data_precision, 4:data_scale, * 5:nullable, 6:constraint_type, 7:default, 8:position; */ PHALCON_INIT_VAR(old_column); phalcon_is_iterable(describe, &ah0, &hp0, 0, 0); while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) { PHALCON_GET_HVALUE(field); PHALCON_INIT_NVAR(definition); array_init_size(definition, 1); add_assoc_long_ex(definition, SS("bindType"), 2); PHALCON_OBS_NVAR(column_size); phalcon_array_fetch_long(&column_size, field, 2, PH_NOISY_CC); PHALCON_OBS_NVAR(column_precision); phalcon_array_fetch_long(&column_precision, field, 3, PH_NOISY_CC); PHALCON_OBS_NVAR(column_scale); phalcon_array_fetch_long(&column_scale, field, 4, PH_NOISY_CC); PHALCON_OBS_NVAR(column_type); phalcon_array_fetch_long(&column_type, field, 1, PH_NOISY_CC); /** * Check the column type to get the correct Phalcon type */ if (phalcon_memnstr_str(column_type, SL("NUMBER") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 3, PH_SEPARATE TSRMLS_CC); phalcon_array_update_string_bool(&definition, SL("isNumeric"), 1, PH_SEPARATE TSRMLS_CC); phalcon_array_update_string(&definition, SL("size"), &column_precision, PH_COPY | PH_SEPARATE TSRMLS_CC); phalcon_array_update_string(&definition, SL("scale"), &column_scale, PH_COPY | PH_SEPARATE TSRMLS_CC); phalcon_array_update_string_long(&definition, SL("bindType"), 32, PH_SEPARATE TSRMLS_CC); } else { if (phalcon_memnstr_str(column_type, SL("INTEGER") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 0, PH_SEPARATE TSRMLS_CC); phalcon_array_update_string_bool(&definition, SL("isNumeric"), 1, PH_SEPARATE TSRMLS_CC); phalcon_array_update_string(&definition, SL("size"), &column_precision, PH_COPY | PH_SEPARATE TSRMLS_CC); phalcon_array_update_string_long(&definition, SL("bindType"), 1, PH_SEPARATE TSRMLS_CC); } else { if (phalcon_memnstr_str(column_type, SL("VARCHAR2") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 2, PH_SEPARATE TSRMLS_CC); phalcon_array_update_string(&definition, SL("size"), &column_size, PH_COPY | PH_SEPARATE TSRMLS_CC); } else { if (phalcon_memnstr_str(column_type, SL("FLOAT") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 7, PH_SEPARATE TSRMLS_CC); phalcon_array_update_string_bool(&definition, SL("isNumeric"), 1, PH_SEPARATE TSRMLS_CC); phalcon_array_update_string(&definition, SL("size"), &column_size, PH_COPY | PH_SEPARATE TSRMLS_CC); phalcon_array_update_string(&definition, SL("scale"), &column_scale, PH_COPY | PH_SEPARATE TSRMLS_CC); phalcon_array_update_string_long(&definition, SL("bindType"), 32, PH_SEPARATE TSRMLS_CC); } else { if (phalcon_memnstr_str(column_type, SL("TIMESTAMP") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 1, PH_SEPARATE TSRMLS_CC); } else { if (phalcon_memnstr_str(column_type, SL("RAW") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 6, PH_SEPARATE TSRMLS_CC); } else { if (phalcon_memnstr_str(column_type, SL("BLOB") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 6, PH_SEPARATE TSRMLS_CC); } else { if (phalcon_memnstr_str(column_type, SL("CLOB") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 6, PH_SEPARATE TSRMLS_CC); } else { if (phalcon_memnstr_str(column_type, SL("VARCHAR2") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 2, PH_SEPARATE TSRMLS_CC); phalcon_array_update_string(&definition, SL("size"), &column_size, PH_COPY | PH_SEPARATE TSRMLS_CC); } else { if (phalcon_memnstr_str(column_type, SL("CHAR") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 5, PH_SEPARATE TSRMLS_CC); phalcon_array_update_string(&definition, SL("size"), &column_size, PH_COPY | PH_SEPARATE TSRMLS_CC); } else { phalcon_array_update_string_long(&definition, SL("type"), 6, PH_SEPARATE TSRMLS_CC); } } } } } } } } } } if (Z_TYPE_P(old_column) == IS_NULL) { phalcon_array_update_string_bool(&definition, SL("first"), 1, PH_SEPARATE TSRMLS_CC); } else { phalcon_array_update_string(&definition, SL("after"), &old_column, PH_COPY | PH_SEPARATE TSRMLS_CC); } /** * Check if the field is primary key */ PHALCON_OBS_NVAR(attribute); phalcon_array_fetch_long(&attribute, field, 6, PH_NOISY_CC); if (PHALCON_IS_STRING(attribute, "P")) { phalcon_array_update_string_bool(&definition, SL("primary"), 1, PH_SEPARATE TSRMLS_CC); } /** * Check if the column allows null values */ PHALCON_OBS_NVAR(attribute); phalcon_array_fetch_long(&attribute, field, 5, PH_NOISY_CC); if (PHALCON_IS_STRING(attribute, "N")) { phalcon_array_update_string_bool(&definition, SL("notNull"), 1, PH_SEPARATE TSRMLS_CC); } PHALCON_OBS_NVAR(column_name); phalcon_array_fetch_long(&column_name, field, 0, PH_NOISY_CC); /** * Create a Phalcon\Db\Column to abstract the column */ PHALCON_INIT_NVAR(column); object_init_ex(column, phalcon_db_column_ce); phalcon_call_method_p2_noret(column, "__construct", column_name, definition); phalcon_array_append(&columns, column, PH_SEPARATE TSRMLS_CC); PHALCON_CPY_WRT(old_column, column_name); zend_hash_move_forward_ex(ah0, &hp0); } RETURN_CTOR(columns); }
static void pcntl_sigwaitinfo(INTERNAL_FUNCTION_PARAMETERS, int timedwait) /* {{{ */ { zval *user_set, **user_signo, *user_siginfo = NULL; long tv_sec = 0, tv_nsec = 0; sigset_t set; HashPosition pos; int signo; siginfo_t siginfo; struct timespec timeout; if (timedwait) { if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|zll", &user_set, &user_siginfo, &tv_sec, &tv_nsec) == FAILURE) { return; } } else { if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|z", &user_set, &user_siginfo) == FAILURE) { return; } } if (sigemptyset(&set) != 0) { PCNTL_G(last_error) = errno; php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno)); RETURN_FALSE; } zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(user_set), &pos); while (zend_hash_get_current_data_ex(Z_ARRVAL_P(user_set), (void **)&user_signo, &pos) == SUCCESS) { if (Z_TYPE_PP(user_signo) != IS_LONG) { SEPARATE_ZVAL(user_signo); convert_to_long_ex(user_signo); } signo = Z_LVAL_PP(user_signo); if (sigaddset(&set, signo) != 0) { PCNTL_G(last_error) = errno; php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno)); RETURN_FALSE; } zend_hash_move_forward_ex(Z_ARRVAL_P(user_set), &pos); } if (timedwait) { timeout.tv_sec = (time_t) tv_sec; timeout.tv_nsec = tv_nsec; signo = sigtimedwait(&set, &siginfo, &timeout); } else { signo = sigwaitinfo(&set, &siginfo); } if (signo == -1 && errno != EAGAIN) { PCNTL_G(last_error) = errno; php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno)); } /* * sigtimedwait and sigwaitinfo can return 0 on success on some * platforms, e.g. NetBSD */ if (!signo && siginfo.si_signo) { signo = siginfo.si_signo; } if (signo > 0 && user_siginfo) { if (Z_TYPE_P(user_siginfo) != IS_ARRAY) { zval_dtor(user_siginfo); array_init(user_siginfo); } else { zend_hash_clean(Z_ARRVAL_P(user_siginfo)); } add_assoc_long_ex(user_siginfo, "signo", sizeof("signo"), siginfo.si_signo); add_assoc_long_ex(user_siginfo, "errno", sizeof("errno"), siginfo.si_errno); add_assoc_long_ex(user_siginfo, "code", sizeof("code"), siginfo.si_code); switch(signo) { #ifdef SIGCHLD case SIGCHLD: add_assoc_long_ex(user_siginfo, "status", sizeof("status"), siginfo.si_status); # ifdef si_utime add_assoc_double_ex(user_siginfo, "utime", sizeof("utime"), siginfo.si_utime); # endif # ifdef si_stime add_assoc_double_ex(user_siginfo, "stime", sizeof("stime"), siginfo.si_stime); # endif add_assoc_long_ex(user_siginfo, "pid", sizeof("pid"), siginfo.si_pid); add_assoc_long_ex(user_siginfo, "uid", sizeof("uid"), siginfo.si_uid); break; #endif case SIGILL: case SIGFPE: case SIGSEGV: case SIGBUS: add_assoc_double_ex(user_siginfo, "addr", sizeof("addr"), (long)siginfo.si_addr); break; #ifdef SIGPOLL case SIGPOLL: add_assoc_long_ex(user_siginfo, "band", sizeof("band"), siginfo.si_band); # ifdef si_fd add_assoc_long_ex(user_siginfo, "fd", sizeof("fd"), siginfo.si_fd); # endif break; #endif EMPTY_SWITCH_DEFAULT_CASE(); } } RETURN_LONG(signo); }
static void php_intl_idn_to_46(INTERNAL_FUNCTION_PARAMETERS, const zend_string *domain, uint32_t option, int mode, zval *idna_info) { UErrorCode status = U_ZERO_ERROR; UIDNA *uts46; int32_t len; int32_t buffer_capac = 255; /* no domain name may exceed this */ zend_string *buffer = zend_string_alloc(buffer_capac, 0); UIDNAInfo info = UIDNA_INFO_INITIALIZER; int buffer_used = 0; uts46 = uidna_openUTS46(option, &status); if (php_intl_idn_check_status(status, "failed to open UIDNA instance") == FAILURE) { zend_string_efree(buffer); RETURN_FALSE; } if (mode == INTL_IDN_TO_ASCII) { len = uidna_nameToASCII_UTF8(uts46, ZSTR_VAL(domain), ZSTR_LEN(domain), ZSTR_VAL(buffer), buffer_capac, &info, &status); } else { len = uidna_nameToUnicodeUTF8(uts46, ZSTR_VAL(domain), ZSTR_LEN(domain), ZSTR_VAL(buffer), buffer_capac, &info, &status); } if (len >= 255 || php_intl_idn_check_status(status, "failed to convert name") == FAILURE) { uidna_close(uts46); zend_string_efree(buffer); RETURN_FALSE; } ZSTR_VAL(buffer)[len] = '\0'; ZSTR_LEN(buffer) = len; if (info.errors == 0) { RETVAL_STR(buffer); buffer_used = 1; } else { RETVAL_FALSE; } if (idna_info) { if (buffer_used) { /* used in return_value then */ zval_addref_p(return_value); add_assoc_zval_ex(idna_info, "result", sizeof("result")-1, return_value); } else { zval zv; ZVAL_NEW_STR(&zv, buffer); buffer_used = 1; add_assoc_zval_ex(idna_info, "result", sizeof("result")-1, &zv); } add_assoc_bool_ex(idna_info, "isTransitionalDifferent", sizeof("isTransitionalDifferent")-1, info.isTransitionalDifferent); add_assoc_long_ex(idna_info, "errors", sizeof("errors")-1, (zend_long)info.errors); } if (!buffer_used) { zend_string_efree(buffer); } uidna_close(uts46); }
/** * Prepare an HTML string of information about a single variable. */ PHP_METHOD(Phalcon_Debug_Dump, output) { zend_bool _17$$5, _18$$5, _19$$5; HashTable *_8$$4, *_42$$11, *_76$$20; HashPosition _7$$4, _41$$11, _75$$20; zval *_123, *_1$$4, *_13$$5 = NULL, *_26$$8, *_68$$8, *_32$$9, *_46$$12 = NULL, *_60$$14 = NULL, *_81$$22 = NULL, *_87$$23 = NULL, *_95$$24, *_100$$25, *_104$$26, *_108$$27, *_114$$28, *_119$$29; zephir_fcall_cache_entry *_4 = NULL, *_6 = NULL, *_12 = NULL, *_23 = NULL, *_31 = NULL, *_53 = NULL, *_57 = NULL, *_62 = NULL; int tab, ZEPHIR_LAST_CALL_STATUS; zval *name = NULL, *_0$$3; zval *variable, *name_param = NULL, *tab_param = NULL, *key = NULL, *value = NULL, *output = NULL, *space = NULL, *type = NULL, *attr = NULL, *_99 = NULL, *_124 = NULL, *_125, _126, *_2$$4 = NULL, *_3$$4, _5$$4 = zval_used_for_init, **_9$$4, *_25$$4 = NULL, _10$$5 = zval_used_for_init, *_11$$5 = NULL, *_14$$5 = NULL, *_15$$5 = NULL, *_16$$5 = NULL, *_20$$7 = NULL, *_21$$7 = NULL, *_22$$7 = NULL, *_24$$7 = NULL, *_27$$8 = NULL, *_28$$8 = NULL, _29$$8 = zval_used_for_init, *_30$$8 = NULL, *_36$$8, *_67$$8 = NULL, *_69$$8 = NULL, *_70$$8, *_71$$8, *_94$$8 = NULL, *_33$$9 = NULL, *_34$$9, _35$$9, _37$$10, *_38$$10 = NULL, *_39$$10, *_40$$11 = NULL, **_43$$11, _44$$12 = zval_used_for_init, *_45$$12 = NULL, *_47$$12 = NULL, *_48$$12 = NULL, *_49$$12 = NULL, *_50$$12 = NULL, *_51$$12 = NULL, *_52$$12 = NULL, *_54$$14 = NULL, _55$$14 = zval_used_for_init, *_56$$14 = NULL, *_59$$14 = NULL, *_61$$14 = NULL, *_63$$14 = NULL, *_64$$14 = NULL, *_65$$14 = NULL, *_66$$14 = NULL, *_58$$17, _72$$19, *_73$$19 = NULL, *_74$$19, **_77$$20, _91$$20, *_92$$20 = NULL, *_93$$20, *_78$$21 = NULL, _79$$22 = zval_used_for_init, *_80$$22 = NULL, *_82$$22 = NULL, *_83$$22 = NULL, *_84$$22 = NULL, _85$$23 = zval_used_for_init, *_86$$23 = NULL, *_88$$23 = NULL, *_89$$23 = NULL, *_90$$23 = NULL, *_96$$24 = NULL, *_97$$24, _98$$24, *_101$$25 = NULL, *_102$$25, _103$$25, *_105$$26 = NULL, *_106$$26, _107$$26, *_109$$27 = NULL, *_110$$27, _111$$27 = zval_used_for_init, _112$$27, *_113$$27 = NULL, *_115$$28 = NULL, *_116$$28, *_117$$28 = NULL, _118$$28, *_120$$29 = NULL, *_121$$29, _122$$29; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &variable, &name_param, &tab_param); if (!name_param) { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } else { zephir_get_strval(name, name_param); } if (!tab_param) { tab = 1; } else { tab = zephir_get_intval(tab_param); } ZEPHIR_INIT_VAR(space); ZVAL_STRING(space, " ", 1); ZEPHIR_INIT_VAR(output); ZVAL_STRING(output, "", 1); if (!(!name) && Z_STRLEN_P(name)) { ZEPHIR_INIT_VAR(_0$$3); ZEPHIR_CONCAT_VS(_0$$3, name, " "); ZEPHIR_CPY_WRT(output, _0$$3); } if (Z_TYPE_P(variable) == IS_ARRAY) { ZEPHIR_INIT_VAR(_1$$4); zephir_create_array(_1$$4, 2, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_3$$4); ZVAL_STRING(_3$$4, "arr", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2$$4, this_ptr, "getstyle", &_4, 0, _3$$4); zephir_check_temp_parameter(_3$$4); zephir_check_call_status(); zephir_array_update_string(&_1$$4, SL(":style"), &_2$$4, PH_COPY | PH_SEPARATE); add_assoc_long_ex(_1$$4, SS(":count"), zephir_fast_count_int(variable TSRMLS_CC)); ZEPHIR_SINIT_VAR(_5$$4); ZVAL_STRING(&_5$$4, "<b style =':style'>Array</b> (<span style =':style'>:count</span>) (\n", 0); ZEPHIR_CALL_FUNCTION(&_2$$4, "strtr", &_6, 26, &_5$$4, _1$$4); zephir_check_call_status(); zephir_concat_self(&output, _2$$4 TSRMLS_CC); zephir_is_iterable(variable, &_8$$4, &_7$$4, 0, 0, "phalcon/debug/dump.zep", 156); for ( ; zephir_hash_get_current_data_ex(_8$$4, (void**) &_9$$4, &_7$$4) == SUCCESS ; zephir_hash_move_forward_ex(_8$$4, &_7$$4) ) { ZEPHIR_GET_HMKEY(key, _8$$4, _7$$4); ZEPHIR_GET_HVALUE(value, _9$$4); ZEPHIR_SINIT_NVAR(_10$$5); ZVAL_LONG(&_10$$5, tab); ZEPHIR_CALL_FUNCTION(&_11$$5, "str_repeat", &_12, 142, space, &_10$$5); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_13$$5); zephir_create_array(_13$$5, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_15$$5); ZVAL_STRING(_15$$5, "arr", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_14$$5, this_ptr, "getstyle", &_4, 0, _15$$5); zephir_check_temp_parameter(_15$$5); zephir_check_call_status(); zephir_array_update_string(&_13$$5, SL(":style"), &_14$$5, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_13$$5, SL(":key"), &key, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_NVAR(_10$$5); ZVAL_STRING(&_10$$5, "[<span style=':style'>:key</span>] => ", 0); ZEPHIR_CALL_FUNCTION(&_14$$5, "strtr", &_6, 26, &_10$$5, _13$$5); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_16$$5); ZEPHIR_CONCAT_VV(_16$$5, _11$$5, _14$$5); zephir_concat_self(&output, _16$$5 TSRMLS_CC); _17$$5 = tab == 1; if (_17$$5) { _17$$5 = !ZEPHIR_IS_STRING(name, ""); } _18$$5 = _17$$5; if (_18$$5) { _18$$5 = !(Z_TYPE_P(key) == IS_LONG); } _19$$5 = _18$$5; if (_19$$5) { _19$$5 = ZEPHIR_IS_EQUAL(name, key); } if (_19$$5) { continue; } else { ZEPHIR_INIT_NVAR(_21$$7); ZVAL_STRING(_21$$7, "", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_22$$7); ZVAL_LONG(_22$$7, (tab + 1)); ZEPHIR_CALL_METHOD(&_20$$7, this_ptr, "output", &_23, 175, value, _21$$7, _22$$7); zephir_check_temp_parameter(_21$$7); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_24$$7); ZEPHIR_CONCAT_VS(_24$$7, _20$$7, "\n"); zephir_concat_self(&output, _24$$7 TSRMLS_CC); } } ZEPHIR_SINIT_NVAR(_5$$4); ZVAL_LONG(&_5$$4, (tab - 1)); ZEPHIR_CALL_FUNCTION(&_25$$4, "str_repeat", &_12, 142, space, &_5$$4); zephir_check_call_status(); ZEPHIR_CONCAT_VVS(return_value, output, _25$$4, ")"); RETURN_MM(); } if (Z_TYPE_P(variable) == IS_OBJECT) { ZEPHIR_INIT_VAR(_26$$8); zephir_create_array(_26$$8, 2, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_28$$8); ZVAL_STRING(_28$$8, "obj", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_27$$8, this_ptr, "getstyle", &_4, 0, _28$$8); zephir_check_temp_parameter(_28$$8); zephir_check_call_status(); zephir_array_update_string(&_26$$8, SL(":style"), &_27$$8, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_28$$8); zephir_get_class(_28$$8, variable, 0 TSRMLS_CC); zephir_array_update_string(&_26$$8, SL(":class"), &_28$$8, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_VAR(_29$$8); ZVAL_STRING(&_29$$8, "<b style=':style'>Object</b> :class", 0); ZEPHIR_CALL_FUNCTION(&_27$$8, "strtr", &_6, 26, &_29$$8, _26$$8); zephir_check_call_status(); zephir_concat_self(&output, _27$$8 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_30$$8, "get_parent_class", &_31, 176, variable); zephir_check_call_status(); if (zephir_is_true(_30$$8)) { ZEPHIR_INIT_VAR(_32$$9); zephir_create_array(_32$$9, 2, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_34$$9); ZVAL_STRING(_34$$9, "obj", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_33$$9, this_ptr, "getstyle", &_4, 0, _34$$9); zephir_check_temp_parameter(_34$$9); zephir_check_call_status(); zephir_array_update_string(&_32$$9, SL(":style"), &_33$$9, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_FUNCTION(&_33$$9, "get_parent_class", &_31, 176, variable); zephir_check_call_status(); zephir_array_update_string(&_32$$9, SL(":parent"), &_33$$9, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_VAR(_35$$9); ZVAL_STRING(&_35$$9, " <b style=':style'>extends</b> :parent", 0); ZEPHIR_CALL_FUNCTION(&_33$$9, "strtr", &_6, 26, &_35$$9, _32$$9); zephir_check_call_status(); zephir_concat_self(&output, _33$$9 TSRMLS_CC); } zephir_concat_self_str(&output, SL(" (\n") TSRMLS_CC); _36$$8 = zephir_fetch_nproperty_this(this_ptr, SL("_detailed"), PH_NOISY_CC); if (zephir_instance_of_ev(variable, phalcon_di_ce TSRMLS_CC)) { ZEPHIR_SINIT_VAR(_37$$10); ZVAL_LONG(&_37$$10, tab); ZEPHIR_CALL_FUNCTION(&_38$$10, "str_repeat", &_12, 142, space, &_37$$10); zephir_check_call_status(); ZEPHIR_INIT_VAR(_39$$10); ZEPHIR_CONCAT_VS(_39$$10, _38$$10, "[skipped]\n"); zephir_concat_self(&output, _39$$10 TSRMLS_CC); } else if (!(zephir_is_true(_36$$8))) { ZEPHIR_CALL_FUNCTION(&_40$$11, "get_object_vars", NULL, 21, variable); zephir_check_call_status(); zephir_is_iterable(_40$$11, &_42$$11, &_41$$11, 0, 0, "phalcon/debug/dump.zep", 177); for ( ; zephir_hash_get_current_data_ex(_42$$11, (void**) &_43$$11, &_41$$11) == SUCCESS ; zephir_hash_move_forward_ex(_42$$11, &_41$$11) ) { ZEPHIR_GET_HMKEY(key, _42$$11, _41$$11); ZEPHIR_GET_HVALUE(value, _43$$11); ZEPHIR_SINIT_NVAR(_44$$12); ZVAL_LONG(&_44$$12, tab); ZEPHIR_CALL_FUNCTION(&_45$$12, "str_repeat", &_12, 142, space, &_44$$12); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_46$$12); zephir_create_array(_46$$12, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_48$$12); ZVAL_STRING(_48$$12, "obj", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_47$$12, this_ptr, "getstyle", &_4, 0, _48$$12); zephir_check_temp_parameter(_48$$12); zephir_check_call_status(); zephir_array_update_string(&_46$$12, SL(":style"), &_47$$12, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_46$$12, SL(":key"), &key, PH_COPY | PH_SEPARATE); add_assoc_stringl_ex(_46$$12, SS(":type"), SL("public"), 1); ZEPHIR_SINIT_NVAR(_44$$12); ZVAL_STRING(&_44$$12, "-><span style=':style'>:key</span> (<span style=':style'>:type</span>) = ", 0); ZEPHIR_CALL_FUNCTION(&_47$$12, "strtr", &_6, 26, &_44$$12, _46$$12); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_49$$12); ZEPHIR_CONCAT_VV(_49$$12, _45$$12, _47$$12); zephir_concat_self(&output, _49$$12 TSRMLS_CC); ZEPHIR_INIT_NVAR(_48$$12); ZVAL_STRING(_48$$12, "", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_51$$12); ZVAL_LONG(_51$$12, (tab + 1)); ZEPHIR_CALL_METHOD(&_50$$12, this_ptr, "output", &_23, 175, value, _48$$12, _51$$12); zephir_check_temp_parameter(_48$$12); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_52$$12); ZEPHIR_CONCAT_VS(_52$$12, _50$$12, "\n"); zephir_concat_self(&output, _52$$12 TSRMLS_CC); } } else { do { ZEPHIR_MAKE_REF(variable); ZEPHIR_CALL_FUNCTION(&attr, "each", &_53, 177, variable); ZEPHIR_UNREF(variable); zephir_check_call_status(); if (!(zephir_is_true(attr))) { continue; } ZEPHIR_OBS_NVAR(key); zephir_array_fetch_string(&key, attr, SL("key"), PH_NOISY, "phalcon/debug/dump.zep", 187 TSRMLS_CC); ZEPHIR_OBS_NVAR(value); zephir_array_fetch_string(&value, attr, SL("value"), PH_NOISY, "phalcon/debug/dump.zep", 188 TSRMLS_CC); if (!(zephir_is_true(key))) { continue; } ZEPHIR_INIT_NVAR(_54$$14); ZEPHIR_SINIT_NVAR(_55$$14); ZVAL_LONG(&_55$$14, 0); ZEPHIR_CALL_FUNCTION(&_56$$14, "chr", &_57, 141, &_55$$14); zephir_check_call_status(); zephir_fast_explode(_54$$14, _56$$14, key, LONG_MAX TSRMLS_CC); ZEPHIR_CPY_WRT(key, _54$$14); ZEPHIR_INIT_NVAR(type); ZVAL_STRING(type, "public", 1); if (zephir_array_isset_long(key, 1)) { ZEPHIR_INIT_NVAR(type); ZVAL_STRING(type, "private", 1); zephir_array_fetch_long(&_58$$17, key, 1, PH_NOISY | PH_READONLY, "phalcon/debug/dump.zep", 200 TSRMLS_CC); if (ZEPHIR_IS_STRING(_58$$17, "*")) { ZEPHIR_INIT_NVAR(type); ZVAL_STRING(type, "protected", 1); } } ZEPHIR_SINIT_NVAR(_55$$14); ZVAL_LONG(&_55$$14, tab); ZEPHIR_CALL_FUNCTION(&_59$$14, "str_repeat", &_12, 142, space, &_55$$14); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_60$$14); zephir_create_array(_60$$14, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_54$$14); ZVAL_STRING(_54$$14, "obj", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_61$$14, this_ptr, "getstyle", &_4, 0, _54$$14); zephir_check_temp_parameter(_54$$14); zephir_check_call_status(); zephir_array_update_string(&_60$$14, SL(":style"), &_61$$14, PH_COPY | PH_SEPARATE); ZEPHIR_MAKE_REF(key); ZEPHIR_CALL_FUNCTION(&_61$$14, "end", &_62, 178, key); ZEPHIR_UNREF(key); zephir_check_call_status(); zephir_array_update_string(&_60$$14, SL(":key"), &_61$$14, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_60$$14, SL(":type"), &type, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_NVAR(_55$$14); ZVAL_STRING(&_55$$14, "-><span style=':style'>:key</span> (<span style=':style'>:type</span>) = ", 0); ZEPHIR_CALL_FUNCTION(&_61$$14, "strtr", &_6, 26, &_55$$14, _60$$14); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_63$$14); ZEPHIR_CONCAT_VV(_63$$14, _59$$14, _61$$14); zephir_concat_self(&output, _63$$14 TSRMLS_CC); ZEPHIR_INIT_NVAR(_54$$14); ZVAL_STRING(_54$$14, "", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_65$$14); ZVAL_LONG(_65$$14, (tab + 1)); ZEPHIR_CALL_METHOD(&_64$$14, this_ptr, "output", &_23, 175, value, _54$$14, _65$$14); zephir_check_temp_parameter(_54$$14); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_66$$14); ZEPHIR_CONCAT_VS(_66$$14, _64$$14, "\n"); zephir_concat_self(&output, _66$$14 TSRMLS_CC); } while (zephir_is_true(attr)); } ZEPHIR_CALL_FUNCTION(&attr, "get_class_methods", NULL, 179, variable); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_29$$8); ZVAL_LONG(&_29$$8, tab); ZEPHIR_CALL_FUNCTION(&_67$$8, "str_repeat", &_12, 142, space, &_29$$8); zephir_check_call_status(); ZEPHIR_INIT_VAR(_68$$8); zephir_create_array(_68$$8, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_28$$8); ZVAL_STRING(_28$$8, "obj", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_69$$8, this_ptr, "getstyle", &_4, 0, _28$$8); zephir_check_temp_parameter(_28$$8); zephir_check_call_status(); zephir_array_update_string(&_68$$8, SL(":style"), &_69$$8, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_28$$8); zephir_get_class(_28$$8, variable, 0 TSRMLS_CC); zephir_array_update_string(&_68$$8, SL(":class"), &_28$$8, PH_COPY | PH_SEPARATE); add_assoc_long_ex(_68$$8, SS(":count"), zephir_fast_count_int(attr TSRMLS_CC)); ZEPHIR_SINIT_NVAR(_29$$8); ZVAL_STRING(&_29$$8, ":class <b style=':style'>methods</b>: (<span style=':style'>:count</span>) (\n", 0); ZEPHIR_CALL_FUNCTION(&_69$$8, "strtr", &_6, 26, &_29$$8, _68$$8); zephir_check_call_status(); ZEPHIR_INIT_VAR(_70$$8); ZEPHIR_CONCAT_VV(_70$$8, _67$$8, _69$$8); zephir_concat_self(&output, _70$$8 TSRMLS_CC); ZEPHIR_INIT_NVAR(_28$$8); zephir_get_class(_28$$8, variable, 0 TSRMLS_CC); _71$$8 = zephir_fetch_nproperty_this(this_ptr, SL("_methods"), PH_NOISY_CC); if (zephir_fast_in_array(_28$$8, _71$$8 TSRMLS_CC)) { ZEPHIR_SINIT_VAR(_72$$19); ZVAL_LONG(&_72$$19, tab); ZEPHIR_CALL_FUNCTION(&_73$$19, "str_repeat", &_12, 142, space, &_72$$19); zephir_check_call_status(); ZEPHIR_INIT_VAR(_74$$19); ZEPHIR_CONCAT_VS(_74$$19, _73$$19, "[already listed]\n"); zephir_concat_self(&output, _74$$19 TSRMLS_CC); } else { zephir_is_iterable(attr, &_76$$20, &_75$$20, 0, 0, "phalcon/debug/dump.zep", 226); for ( ; zephir_hash_get_current_data_ex(_76$$20, (void**) &_77$$20, &_75$$20) == SUCCESS ; zephir_hash_move_forward_ex(_76$$20, &_75$$20) ) { ZEPHIR_GET_HVALUE(value, _77$$20); ZEPHIR_INIT_NVAR(_78$$21); zephir_get_class(_78$$21, variable, 0 TSRMLS_CC); zephir_update_property_array_append(this_ptr, SL("_methods"), _78$$21 TSRMLS_CC); if (ZEPHIR_IS_STRING(value, "__construct")) { ZEPHIR_SINIT_NVAR(_79$$22); ZVAL_LONG(&_79$$22, (tab + 1)); ZEPHIR_CALL_FUNCTION(&_80$$22, "str_repeat", &_12, 142, space, &_79$$22); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_81$$22); zephir_create_array(_81$$22, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_83$$22); ZVAL_STRING(_83$$22, "obj", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_82$$22, this_ptr, "getstyle", &_4, 0, _83$$22); zephir_check_temp_parameter(_83$$22); zephir_check_call_status(); zephir_array_update_string(&_81$$22, SL(":style"), &_82$$22, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_81$$22, SL(":method"), &value, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_NVAR(_79$$22); ZVAL_STRING(&_79$$22, "-><span style=':style'>:method</span>(); [<b style=':style'>constructor</b>]\n", 0); ZEPHIR_CALL_FUNCTION(&_82$$22, "strtr", &_6, 26, &_79$$22, _81$$22); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_84$$22); ZEPHIR_CONCAT_VV(_84$$22, _80$$22, _82$$22); zephir_concat_self(&output, _84$$22 TSRMLS_CC); } else { ZEPHIR_SINIT_NVAR(_85$$23); ZVAL_LONG(&_85$$23, (tab + 1)); ZEPHIR_CALL_FUNCTION(&_86$$23, "str_repeat", &_12, 142, space, &_85$$23); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_87$$23); zephir_create_array(_87$$23, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_89$$23); ZVAL_STRING(_89$$23, "obj", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_88$$23, this_ptr, "getstyle", &_4, 0, _89$$23); zephir_check_temp_parameter(_89$$23); zephir_check_call_status(); zephir_array_update_string(&_87$$23, SL(":style"), &_88$$23, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_87$$23, SL(":method"), &value, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_NVAR(_85$$23); ZVAL_STRING(&_85$$23, "-><span style=':style'>:method</span>();\n", 0); ZEPHIR_CALL_FUNCTION(&_88$$23, "strtr", &_6, 26, &_85$$23, _87$$23); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_90$$23); ZEPHIR_CONCAT_VV(_90$$23, _86$$23, _88$$23); zephir_concat_self(&output, _90$$23 TSRMLS_CC); } } ZEPHIR_SINIT_VAR(_91$$20); ZVAL_LONG(&_91$$20, tab); ZEPHIR_CALL_FUNCTION(&_92$$20, "str_repeat", &_12, 142, space, &_91$$20); zephir_check_call_status(); ZEPHIR_INIT_VAR(_93$$20); ZEPHIR_CONCAT_VS(_93$$20, _92$$20, ")\n"); zephir_concat_self(&output, _93$$20 TSRMLS_CC); } ZEPHIR_SINIT_NVAR(_29$$8); ZVAL_LONG(&_29$$8, (tab - 1)); ZEPHIR_CALL_FUNCTION(&_94$$8, "str_repeat", &_12, 142, space, &_29$$8); zephir_check_call_status(); ZEPHIR_CONCAT_VVS(return_value, output, _94$$8, ")"); RETURN_MM(); } if (Z_TYPE_P(variable) == IS_LONG) { ZEPHIR_INIT_VAR(_95$$24); zephir_create_array(_95$$24, 2, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_97$$24); ZVAL_STRING(_97$$24, "int", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_96$$24, this_ptr, "getstyle", &_4, 0, _97$$24); zephir_check_temp_parameter(_97$$24); zephir_check_call_status(); zephir_array_update_string(&_95$$24, SL(":style"), &_96$$24, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_95$$24, SL(":var"), &variable, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_VAR(_98$$24); ZVAL_STRING(&_98$$24, "<b style=':style'>Integer</b> (<span style=':style'>:var</span>)", 0); ZEPHIR_CALL_FUNCTION(&_96$$24, "strtr", &_6, 26, &_98$$24, _95$$24); zephir_check_call_status(); ZEPHIR_CONCAT_VV(return_value, output, _96$$24); RETURN_MM(); } ZEPHIR_CALL_FUNCTION(&_99, "is_float", NULL, 180, variable); zephir_check_call_status(); if (zephir_is_true(_99)) { ZEPHIR_INIT_VAR(_100$$25); zephir_create_array(_100$$25, 2, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_102$$25); ZVAL_STRING(_102$$25, "float", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_101$$25, this_ptr, "getstyle", &_4, 0, _102$$25); zephir_check_temp_parameter(_102$$25); zephir_check_call_status(); zephir_array_update_string(&_100$$25, SL(":style"), &_101$$25, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_100$$25, SL(":var"), &variable, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_VAR(_103$$25); ZVAL_STRING(&_103$$25, "<b style=':style'>Float</b> (<span style=':style'>:var</span>)", 0); ZEPHIR_CALL_FUNCTION(&_101$$25, "strtr", &_6, 26, &_103$$25, _100$$25); zephir_check_call_status(); ZEPHIR_CONCAT_VV(return_value, output, _101$$25); RETURN_MM(); } if (zephir_is_numeric(variable)) { ZEPHIR_INIT_VAR(_104$$26); zephir_create_array(_104$$26, 3, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_106$$26); ZVAL_STRING(_106$$26, "num", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_105$$26, this_ptr, "getstyle", &_4, 0, _106$$26); zephir_check_temp_parameter(_106$$26); zephir_check_call_status(); zephir_array_update_string(&_104$$26, SL(":style"), &_105$$26, PH_COPY | PH_SEPARATE); add_assoc_long_ex(_104$$26, SS(":length"), zephir_fast_strlen_ev(variable)); zephir_array_update_string(&_104$$26, SL(":var"), &variable, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_VAR(_107$$26); ZVAL_STRING(&_107$$26, "<b style=':style'>Numeric string</b> (<span style=':style'>:length</span>) \"<span style=':style'>:var</span>\"", 0); ZEPHIR_CALL_FUNCTION(&_105$$26, "strtr", &_6, 26, &_107$$26, _104$$26); zephir_check_call_status(); ZEPHIR_CONCAT_VV(return_value, output, _105$$26); RETURN_MM(); } if (Z_TYPE_P(variable) == IS_STRING) { ZEPHIR_INIT_VAR(_108$$27); zephir_create_array(_108$$27, 3, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_110$$27); ZVAL_STRING(_110$$27, "str", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_109$$27, this_ptr, "getstyle", &_4, 0, _110$$27); zephir_check_temp_parameter(_110$$27); zephir_check_call_status(); zephir_array_update_string(&_108$$27, SL(":style"), &_109$$27, PH_COPY | PH_SEPARATE); add_assoc_long_ex(_108$$27, SS(":length"), zephir_fast_strlen_ev(variable)); ZEPHIR_SINIT_VAR(_111$$27); ZVAL_LONG(&_111$$27, 4); ZEPHIR_SINIT_VAR(_112$$27); ZVAL_STRING(&_112$$27, "utf-8", 0); ZEPHIR_CALL_FUNCTION(&_109$$27, "htmlentities", NULL, 161, variable, &_111$$27, &_112$$27); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_113$$27, "nl2br", NULL, 181, _109$$27); zephir_check_call_status(); zephir_array_update_string(&_108$$27, SL(":var"), &_113$$27, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_NVAR(_111$$27); ZVAL_STRING(&_111$$27, "<b style=':style'>String</b> (<span style=':style'>:length</span>) \"<span style=':style'>:var</span>\"", 0); ZEPHIR_CALL_FUNCTION(&_113$$27, "strtr", &_6, 26, &_111$$27, _108$$27); zephir_check_call_status(); ZEPHIR_CONCAT_VV(return_value, output, _113$$27); RETURN_MM(); } if (Z_TYPE_P(variable) == IS_BOOL) { ZEPHIR_INIT_VAR(_114$$28); zephir_create_array(_114$$28, 2, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_116$$28); ZVAL_STRING(_116$$28, "bool", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_115$$28, this_ptr, "getstyle", &_4, 0, _116$$28); zephir_check_temp_parameter(_116$$28); zephir_check_call_status(); zephir_array_update_string(&_114$$28, SL(":style"), &_115$$28, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_VAR(_117$$28); if (zephir_is_true(variable)) { ZEPHIR_INIT_NVAR(_117$$28); ZVAL_STRING(_117$$28, "TRUE", 1); } else { ZEPHIR_INIT_NVAR(_117$$28); ZVAL_STRING(_117$$28, "FALSE", 1); } zephir_array_update_string(&_114$$28, SL(":var"), &_117$$28, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_VAR(_118$$28); ZVAL_STRING(&_118$$28, "<b style=':style'>Boolean</b> (<span style=':style'>:var</span>)", 0); ZEPHIR_CALL_FUNCTION(&_115$$28, "strtr", &_6, 26, &_118$$28, _114$$28); zephir_check_call_status(); ZEPHIR_CONCAT_VV(return_value, output, _115$$28); RETURN_MM(); } if (Z_TYPE_P(variable) == IS_NULL) { ZEPHIR_INIT_VAR(_119$$29); zephir_create_array(_119$$29, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_121$$29); ZVAL_STRING(_121$$29, "null", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_120$$29, this_ptr, "getstyle", &_4, 0, _121$$29); zephir_check_temp_parameter(_121$$29); zephir_check_call_status(); zephir_array_update_string(&_119$$29, SL(":style"), &_120$$29, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_VAR(_122$$29); ZVAL_STRING(&_122$$29, "<b style=':style'>NULL</b>", 0); ZEPHIR_CALL_FUNCTION(&_120$$29, "strtr", &_6, 26, &_122$$29, _119$$29); zephir_check_call_status(); ZEPHIR_CONCAT_VV(return_value, output, _120$$29); RETURN_MM(); } ZEPHIR_INIT_VAR(_123); zephir_create_array(_123, 2, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_125); ZVAL_STRING(_125, "other", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_124, this_ptr, "getstyle", &_4, 0, _125); zephir_check_temp_parameter(_125); zephir_check_call_status(); zephir_array_update_string(&_123, SL(":style"), &_124, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_123, SL(":var"), &variable, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_VAR(_126); ZVAL_STRING(&_126, "(<span style=':style'>:var</span>)", 0); ZEPHIR_CALL_FUNCTION(&_124, "strtr", &_6, 26, &_126, _123); zephir_check_call_status(); ZEPHIR_CONCAT_VV(return_value, output, _124); RETURN_MM(); }
/** * Returns an array of Phalcon\Db\Column objects describing a table * * <code>print_r($connection->describeColumns("posts")); ?></code> * * @param string $table * @param string $schema * @return Phalcon\Db\Column[] */ PHP_METHOD(Phalcon_Db_Adapter_Pdo_Oracle, describeColumns) { zval *table, *schema = NULL, *columns, *dialect, *sql = NULL, *fetch_num; zval *describe = NULL, *old_column = NULL, *field = NULL, *definition = NULL; zval *column_size = NULL, *column_precision = NULL, *column_scale = NULL; zval *column_type = NULL, *attribute = NULL, *column_name = NULL; zval *column = NULL; HashTable *ah0; HashPosition hp0; zval **hd; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 1, &table, &schema); if (!schema) { schema = PHALCON_GLOBAL(z_null); } PHALCON_INIT_VAR(columns); array_init(columns); PHALCON_OBS_VAR(dialect); phalcon_read_property_this(&dialect, this_ptr, SL("_dialect"), PH_NOISY TSRMLS_CC); PHALCON_CALL_METHOD(&sql, dialect, "describecolumns", table, schema); /** * We're using FETCH_NUM to fetch the columns */ PHALCON_INIT_VAR(fetch_num); ZVAL_LONG(fetch_num, PDO_FETCH_NUM); PHALCON_CALL_METHOD(&describe, this_ptr, "fetchall", sql, fetch_num); /** * 0:column_name, 1:data_type, 2:data_length, 3:data_precision, 4:data_scale, * 5:nullable, 6:constraint_type, 7:default, 8:position; */ PHALCON_INIT_VAR(old_column); phalcon_is_iterable(describe, &ah0, &hp0, 0, 0); while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) { PHALCON_GET_HVALUE(field); PHALCON_INIT_NVAR(definition); array_init_size(definition, 1); add_assoc_long_ex(definition, SS("bindType"), 2); PHALCON_OBS_NVAR(column_size); phalcon_array_fetch_long(&column_size, field, 2, PH_NOISY); PHALCON_OBS_NVAR(column_precision); phalcon_array_fetch_long(&column_precision, field, 3, PH_NOISY); PHALCON_OBS_NVAR(column_scale); phalcon_array_fetch_long(&column_scale, field, 4, PH_NOISY); PHALCON_OBS_NVAR(column_type); phalcon_array_fetch_long(&column_type, field, 1, PH_NOISY); /** * Check the column type to get the correct Phalcon type */ while (1) { /** * Integer */ if (phalcon_memnstr_str(column_type, SL("NUMBER"))) { phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_DECIMAL, PH_COPY); phalcon_array_update_string_bool(&definition, SL("isNumeric"), 1, PH_COPY); phalcon_array_update_string(&definition, SL("size"), column_precision, PH_COPY); phalcon_array_update_string_long(&definition, SL("bindType"), 32, PH_COPY); if (phalcon_is_numeric(column_precision)) { phalcon_array_update_string_long(&definition, SL("bytes"), Z_LVAL_P(column_precision) * 8, PH_COPY); } else { phalcon_array_update_string_long(&definition, SL("size"), 30, PH_COPY); phalcon_array_update_string_long(&definition, SL("bytes"), 80, PH_COPY); } if (phalcon_is_numeric(column_scale)) { phalcon_array_update_string(&definition, SL("scale"), column_scale, PH_COPY); } else { phalcon_array_update_string_long(&definition, SL("scale"), 6, PH_COPY); } break; } /** * Tinyint(1) is boolean */ if (phalcon_memnstr_str(column_type, SL("TINYINT(1)"))) { phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_BOOLEAN, PH_COPY); phalcon_array_update_string_long(&definition, SL("bindType"), 5, PH_COPY); break; } /** * Smallint/Bigint/Integers/Int are int */ if (phalcon_memnstr_str(column_type, SL("INTEGER"))) { phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_INTEGER, PH_COPY); phalcon_array_update_string_bool(&definition, SL("isNumeric"), 1, PH_COPY); phalcon_array_update_string(&definition, SL("size"), column_precision, PH_COPY); phalcon_array_update_string_long(&definition, SL("bindType"), 1, PH_COPY); phalcon_array_update_string_long(&definition, SL("bytes"), 32, PH_COPY); break; } /** * Float/Smallfloats/Decimals are float */ if (phalcon_memnstr_str(column_type, SL("FLOAT"))) { phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_FLOAT, PH_COPY); phalcon_array_update_string_bool(&definition, SL("isNumeric"), 1, PH_COPY); phalcon_array_update_string(&definition, SL("size"), column_size, PH_COPY); phalcon_array_update_string(&definition, SL("scale"), column_scale, PH_COPY); phalcon_array_update_string_long(&definition, SL("bindType"), 32, PH_COPY); break; } /** * Date */ if (phalcon_memnstr_str(column_type, SL("TIMESTAMP"))) { phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_DATE, PH_COPY); break; } /** * Text */ if (phalcon_memnstr_str(column_type, SL("RAW"))) { phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_TEXT, PH_COPY); break; } /** * Text */ if (phalcon_memnstr_str(column_type, SL("BLOB"))) { phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_TEXT, PH_COPY); break; } /** * Text */ if (phalcon_memnstr_str(column_type, SL("CLOB"))) { phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_TEXT, PH_COPY); break; } /** * Chars2 are string */ if (phalcon_memnstr_str(column_type, SL("VARCHAR2"))) { phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_VARCHAR, PH_COPY); phalcon_array_update_string(&definition, SL("size"), column_size, PH_COPY); break; } /** * Chars are chars */ if (phalcon_memnstr_str(column_type, SL("CHAR"))) { phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_CHAR, PH_COPY); phalcon_array_update_string(&definition, SL("size"), column_size, PH_COPY); break; } /** * Text are varchars */ if (phalcon_memnstr_str(column_type, SL("text"))) { phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_TEXT, PH_COPY); break; } /** * By default is string */ phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_VARCHAR, PH_COPY); break; } if (Z_TYPE_P(old_column) == IS_NULL) { phalcon_array_update_string_bool(&definition, SL("first"), 1, PH_COPY); } else { phalcon_array_update_string(&definition, SL("after"), old_column, PH_COPY); } /** * Check if the field is primary key */ PHALCON_OBS_NVAR(attribute); phalcon_array_fetch_long(&attribute, field, 6, PH_NOISY); if (PHALCON_IS_STRING(attribute, "P")) { phalcon_array_update_string_bool(&definition, SL("primary"), 1, PH_COPY); } /** * Check if the column allows null values */ PHALCON_OBS_NVAR(attribute); phalcon_array_fetch_long(&attribute, field, 5, PH_NOISY); if (PHALCON_IS_STRING(attribute, "N")) { phalcon_array_update_string_bool(&definition, SL("notNull"), 1, PH_COPY); } PHALCON_OBS_NVAR(column_name); phalcon_array_fetch_long(&column_name, field, 0, PH_NOISY); /** * If the column set the default values, get it */ PHALCON_OBS_NVAR(attribute); phalcon_array_fetch_long(&attribute, field, 7, PH_NOISY); if (!PHALCON_IS_EMPTY(attribute)) { phalcon_array_update_string(&definition, SL("default"), attribute, PH_COPY); } /** * Create a Phalcon\Db\Column to abstract the column */ PHALCON_INIT_NVAR(column); object_init_ex(column, phalcon_db_column_ce); PHALCON_CALL_METHOD(NULL, column, "__construct", column_name, definition); phalcon_array_append(&columns, column, PH_COPY); PHALCON_CPY_WRT(old_column, column_name); zend_hash_move_forward_ex(ah0, &hp0); } RETURN_CTOR(columns); }
/** * Returns an array of Phalcon\Db\Column objects describing a table * * <code>print_r($connection->describeColumns("posts")); ?></code> * * @param string $table * @param string $schema * @return Phalcon\Db\Column[] */ PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, describeColumns){ zval *table = NULL, *schema = NULL, *columns = NULL, *sql = NULL, *fetch_assoc = NULL; zval *describe = NULL, *old_column = NULL, *field = NULL, *definition = NULL; zval *column_type = NULL; zval *status = NULL, *matches = NULL, *pattern = NULL, *attribute = NULL, *column_name = NULL; zval *column = NULL, *dialect = NULL; zval *r0 = NULL, *r1 = NULL; zval *status2 = NULL; HashTable *ah0; HashPosition hp0; zval **hd; int eval_int; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &table, &schema) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } if (!schema) { PHALCON_ALLOC_ZVAL_MM(schema); ZVAL_NULL(schema); } PHALCON_INIT_VAR(columns); array_init(columns); PHALCON_ALLOC_ZVAL_MM(dialect); phalcon_read_property(&dialect, this_ptr, SL("_dialect"), PH_NOISY_CC); PHALCON_INIT_VAR(sql); PHALCON_CALL_METHOD_PARAMS_2(sql, dialect, "describecolumns", table, schema, PH_NO_CHECK); PHALCON_INIT_VAR(fetch_assoc); phalcon_get_class_constant(fetch_assoc, phalcon_db_ce, SL("FETCH_ASSOC") TSRMLS_CC); PHALCON_INIT_VAR(describe); PHALCON_CALL_METHOD_PARAMS_2(describe, this_ptr, "fetchall", sql, fetch_assoc, PH_NO_CHECK); PHALCON_INIT_VAR(old_column); ZVAL_NULL(old_column); if (!phalcon_valid_foreach(describe TSRMLS_CC)) { return; } ah0 = Z_ARRVAL_P(describe); zend_hash_internal_pointer_reset_ex(ah0, &hp0); ph_cycle_start_0: if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){ goto ph_cycle_end_0; } PHALCON_GET_FOREACH_VALUE(field); PHALCON_INIT_VAR(definition); array_init(definition); add_assoc_long_ex(definition, SS("bindType"), 2); PHALCON_INIT_VAR(column_type); phalcon_array_fetch_string(&column_type, field, SL("type"), PH_NOISY_CC); PHALCON_INIT_VAR(status); phalcon_fast_strpos_str(status, column_type, SL("int") TSRMLS_CC); if (PHALCON_IS_NOT_FALSE(status)) { add_assoc_long_ex(definition, SS("type"), 0); add_assoc_bool_ex(definition, SS("isNumeric"), 1); add_assoc_long_ex(definition, SS("size"), 32); // default 4byte add_assoc_long_ex(definition, SS("bindType"), 1); } else { PHALCON_INIT_VAR(status); phalcon_fast_strpos_str(status, column_type, SL("varchar") TSRMLS_CC); if (PHALCON_IS_NOT_FALSE(status)) { phalcon_array_update_string_long(&definition, SL("type"), 2, PH_SEPARATE TSRMLS_CC); phalcon_array_update_string_long(&definition, SL("size"), 255, PH_SEPARATE TSRMLS_CC); } else { PHALCON_INIT_VAR(status); phalcon_fast_strpos_str(status, column_type, SL("date") TSRMLS_CC); if (PHALCON_IS_NOT_FALSE(status)) { phalcon_array_update_string_long(&definition, SL("type"), 1, PH_SEPARATE TSRMLS_CC); phalcon_array_update_string_long(&definition, SL("size"), 0, PH_SEPARATE TSRMLS_CC); } else { PHALCON_INIT_VAR(status); PHALCON_INIT_VAR(status2); phalcon_fast_strpos_str(status, column_type, SL("numeric") TSRMLS_CC); phalcon_fast_strpos_str(status2, column_type, SL("decimal") TSRMLS_CC); if ( (PHALCON_IS_NOT_FALSE(status)) || (PHALCON_IS_NOT_FALSE(status2)) ) { add_assoc_long_ex(definition, SS("type"), 3); add_assoc_bool_ex(definition, SS("isNumeric"), 1); add_assoc_long_ex(definition, SS("size"), 32); // default 4byte add_assoc_long_ex(definition, SS("bindType"), 32); } else { PHALCON_INIT_VAR(status); phalcon_fast_strpos_str(status, column_type, SL("char") TSRMLS_CC); if (PHALCON_IS_NOT_FALSE(status)) { add_assoc_long_ex(definition, SS("type"), 5); phalcon_array_update_string_long(&definition, SL("size"), 255, PH_SEPARATE TSRMLS_CC); } else { PHALCON_INIT_VAR(status); phalcon_fast_strpos_str(status, column_type, SL("timestamp") TSRMLS_CC); if (PHALCON_IS_NOT_FALSE(status)) { add_assoc_long_ex(definition, SS("type"), 4); phalcon_array_update_string_long(&definition, SL("size"), 0, PH_SEPARATE TSRMLS_CC); } else { PHALCON_INIT_VAR(status); phalcon_fast_strpos_str(status, column_type, SL("text") TSRMLS_CC); if (PHALCON_IS_NOT_FALSE(status)) { add_assoc_long_ex(definition, SS("type"), 6); phalcon_array_update_string_long(&definition, SL("size"), 2147483647, PH_SEPARATE TSRMLS_CC); } else { PHALCON_INIT_VAR(status); phalcon_fast_strpos_str(status, column_type, SL("float") TSRMLS_CC); if (PHALCON_IS_NOT_FALSE(status)) { add_assoc_long_ex(definition, SS("type"), 7); add_assoc_bool_ex(definition, SS("isNumeric"), 1); add_assoc_long_ex(definition, SS("size"), 64); // default 4byte add_assoc_long_ex(definition, SS("bindType"), 32); } else { add_assoc_long_ex(definition, SS("type"), 5); PHALCON_INIT_VAR(status); phalcon_fast_strpos_str(status, column_type, SL("uuid") TSRMLS_CC); if (PHALCON_IS_NOT_FALSE(status)) { phalcon_array_update_string_long(&definition, SL("size"), 36, PH_SEPARATE TSRMLS_CC); } else { phalcon_array_update_string_long(&definition, SL("size"), 255, PH_SEPARATE TSRMLS_CC); } } } } } } } } } PHALCON_INIT_VAR(status); phalcon_fast_strpos_str(status, column_type, SL("(") TSRMLS_CC); if (PHALCON_IS_NOT_FALSE(status)) { PHALCON_INIT_VAR(matches); array_init(matches); PHALCON_INIT_VAR(pattern); ZVAL_STRING(pattern, "#\\(([0-9]+)(,[0-9]+)*\\)#", 1); Z_SET_ISREF_P(matches); PHALCON_INIT_VAR(r0); PHALCON_CALL_FUNC_PARAMS_3(r0, "preg_match", pattern, column_type, matches); Z_UNSET_ISREF_P(matches); if (zend_is_true(r0)) { eval_int = phalcon_array_isset_long(matches, 1); if (eval_int) { PHALCON_INIT_VAR(r1); phalcon_array_fetch_long(&r1, matches, 1, PH_NOISY_CC); phalcon_array_update_string(&definition, SL("size"), &r1, PH_COPY | PH_SEPARATE TSRMLS_CC); } } } PHALCON_INIT_VAR(status); phalcon_fast_strpos_str(status, column_type, SL("unsigned") TSRMLS_CC); if (PHALCON_IS_NOT_FALSE(status)) { phalcon_array_update_string_bool(&definition, SL("unsigned"), 1, PH_SEPARATE TSRMLS_CC); } if (Z_TYPE_P(old_column) == IS_NULL) { phalcon_array_update_string_bool(&definition, SL("first"), 1, PH_SEPARATE TSRMLS_CC); } else { phalcon_array_update_string(&definition, SL("after"), &old_column, PH_COPY | PH_SEPARATE TSRMLS_CC); } PHALCON_INIT_VAR(attribute); phalcon_array_fetch_string(&attribute, field, SL("pk"), PH_NOISY_CC); if (PHALCON_COMPARE_STRING(attribute, "1")) { phalcon_array_update_string_bool(&definition, SL("primary"), 1, PH_SEPARATE TSRMLS_CC); }else { phalcon_array_update_string_bool(&definition, SL("primary"), 0, PH_SEPARATE TSRMLS_CC); } PHALCON_INIT_VAR(attribute); phalcon_array_fetch_string(&attribute, field, SL("notnull"), PH_NOISY_CC); if (PHALCON_COMPARE_STRING(attribute, "1")) { phalcon_array_update_string_bool(&definition, SL("notNull"), 1, PH_SEPARATE TSRMLS_CC); } PHALCON_INIT_VAR(r0); phalcon_fast_strpos_str(r0, column_type, SL("integer") TSRMLS_CC); PHALCON_INIT_VAR(r1); phalcon_array_fetch_string(&r1, definition, SL("primary"), PH_NOISY_CC); if ((PHALCON_IS_NOT_FALSE(r0)) && (PHALCON_IS_NOT_FALSE(r1))) { phalcon_array_update_string_bool(&definition, SL("autoIncrement"), 1, PH_SEPARATE TSRMLS_CC); } PHALCON_INIT_VAR(column_name); phalcon_array_fetch_string(&column_name, field, SL("name"), PH_NOISY_CC); PHALCON_INIT_VAR(column); object_init_ex(column, phalcon_db_column_ce); PHALCON_CALL_METHOD_PARAMS_2_NORETURN(column, "__construct", column_name, definition, PH_CHECK); phalcon_array_append(&columns, column, PH_SEPARATE TSRMLS_CC); PHALCON_CPY_WRT(old_column, column_name); zend_hash_move_forward_ex(ah0, &hp0); goto ph_cycle_start_0; ph_cycle_end_0: RETURN_CTOR(columns);}
/** * Returns an array of Phalcon\Db\Column objects describing a table * * <code> * print_r($connection->describeColumns("posts")); * </code> */ PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, describeColumns) { zend_bool _11$$4, _36$$3; HashTable *_5; HashPosition _4; zephir_fcall_cache_entry *_35 = NULL, *_42 = NULL, *_44 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *table_param = NULL, *schema_param = NULL, *columns = NULL, *columnType = NULL, *field = NULL, *definition = NULL, *oldColumn = NULL, *sizePattern = NULL, *matches = NULL, *matchOne = NULL, *matchTwo = NULL, *columnName = NULL, *_0 = NULL, *_1, *_2 = NULL, *_3, **_6, *_7$$5 = NULL, *_8$$5 = NULL, *_9$$6 = NULL, *_10$$6 = NULL, *_26$$4 = NULL, *_12$$7 = NULL, *_13$$7 = NULL, *_14$$7, *_15$$9 = NULL, *_16$$10 = NULL, *_17$$11 = NULL, *_18$$12 = NULL, *_19$$12 = NULL, *_20$$13 = NULL, *_21$$14 = NULL, *_22$$15 = NULL, *_23$$16 = NULL, *_24$$16 = NULL, *_25$$17 = NULL, *_27$$18 = NULL, *_28$$20 = NULL, *_29$$21 = NULL, *_30$$3, *_31$$3, *_32$$3, _33$$3 = zval_used_for_init, *_34$$3 = NULL, *_37$$3, *_43$$3 = NULL, *_38$$27, *_39$$27 = NULL, *_40$$27 = NULL, *_41$$27 = NULL; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); zephir_get_strval(table, table_param); if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } ZEPHIR_INIT_VAR(oldColumn); ZVAL_NULL(oldColumn); ZEPHIR_INIT_VAR(sizePattern); ZVAL_STRING(sizePattern, "#\\(([0-9]+)(?:,\\s*([0-9]+))*\\)#", 1); ZEPHIR_INIT_VAR(columns); array_init(columns); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_2, _1, "describecolumns", NULL, 0, table, schema); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 3); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, _2, _3); zephir_check_call_status(); zephir_is_iterable(_0, &_5, &_4, 0, 0, "phalcon/db/adapter/pdo/sqlite.zep", 286); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(field, _6); ZEPHIR_INIT_NVAR(definition); zephir_create_array(definition, 1, 0 TSRMLS_CC); add_assoc_long_ex(definition, SS("bindType"), 2); ZEPHIR_OBS_NVAR(columnType); zephir_array_fetch_long(&columnType, field, 2, PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 103 TSRMLS_CC); while (1) { if (zephir_memnstr_str(columnType, SL("tinyint(1)"), "phalcon/db/adapter/pdo/sqlite.zep", 110)) { ZEPHIR_INIT_NVAR(_7$$5); ZVAL_LONG(_7$$5, 8); zephir_array_update_string(&definition, SL("type"), &_7$$5, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8$$5); ZVAL_LONG(_8$$5, 5); zephir_array_update_string(&definition, SL("bindType"), &_8$$5, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(columnType); ZVAL_STRING(columnType, "boolean", 1); break; } if (zephir_memnstr_str(columnType, SL("bigint"), "phalcon/db/adapter/pdo/sqlite.zep", 120)) { ZEPHIR_INIT_NVAR(_9$$6); ZVAL_LONG(_9$$6, 14); zephir_array_update_string(&definition, SL("type"), &_9$$6, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_10$$6); ZVAL_LONG(_10$$6, 1); zephir_array_update_string(&definition, SL("bindType"), &_10$$6, PH_COPY | PH_SEPARATE); break; } _11$$4 = zephir_memnstr_str(columnType, SL("int"), "phalcon/db/adapter/pdo/sqlite.zep", 130); if (!(_11$$4)) { _11$$4 = zephir_memnstr_str(columnType, SL("INT"), "phalcon/db/adapter/pdo/sqlite.zep", 130); } if (_11$$4) { ZEPHIR_INIT_NVAR(_12$$7); ZVAL_LONG(_12$$7, 0); zephir_array_update_string(&definition, SL("type"), &_12$$7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_13$$7); ZVAL_LONG(_13$$7, 1); zephir_array_update_string(&definition, SL("bindType"), &_13$$7, PH_COPY | PH_SEPARATE); zephir_array_fetch_long(&_14$$7, field, 5, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 136 TSRMLS_CC); if (zephir_is_true(_14$$7)) { zephir_array_update_string(&definition, SL("autoIncrement"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } break; } if (zephir_memnstr_str(columnType, SL("varchar"), "phalcon/db/adapter/pdo/sqlite.zep", 145)) { ZEPHIR_INIT_NVAR(_15$$9); ZVAL_LONG(_15$$9, 2); zephir_array_update_string(&definition, SL("type"), &_15$$9, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("date"), "phalcon/db/adapter/pdo/sqlite.zep", 153)) { ZEPHIR_INIT_NVAR(_16$$10); ZVAL_LONG(_16$$10, 1); zephir_array_update_string(&definition, SL("type"), &_16$$10, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("timestamp"), "phalcon/db/adapter/pdo/sqlite.zep", 161)) { ZEPHIR_INIT_NVAR(_17$$11); ZVAL_LONG(_17$$11, 17); zephir_array_update_string(&definition, SL("type"), &_17$$11, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("decimal"), "phalcon/db/adapter/pdo/sqlite.zep", 169)) { ZEPHIR_INIT_NVAR(_18$$12); ZVAL_LONG(_18$$12, 3); zephir_array_update_string(&definition, SL("type"), &_18$$12, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_19$$12); ZVAL_LONG(_19$$12, 32); zephir_array_update_string(&definition, SL("bindType"), &_19$$12, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("char"), "phalcon/db/adapter/pdo/sqlite.zep", 179)) { ZEPHIR_INIT_NVAR(_20$$13); ZVAL_LONG(_20$$13, 5); zephir_array_update_string(&definition, SL("type"), &_20$$13, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("datetime"), "phalcon/db/adapter/pdo/sqlite.zep", 187)) { ZEPHIR_INIT_NVAR(_21$$14); ZVAL_LONG(_21$$14, 4); zephir_array_update_string(&definition, SL("type"), &_21$$14, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("text"), "phalcon/db/adapter/pdo/sqlite.zep", 195)) { ZEPHIR_INIT_NVAR(_22$$15); ZVAL_LONG(_22$$15, 6); zephir_array_update_string(&definition, SL("type"), &_22$$15, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("float"), "phalcon/db/adapter/pdo/sqlite.zep", 203)) { ZEPHIR_INIT_NVAR(_23$$16); ZVAL_LONG(_23$$16, 7); zephir_array_update_string(&definition, SL("type"), &_23$$16, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_24$$16); ZVAL_LONG(_24$$16, 3); zephir_array_update_string(&definition, SL("bindType"), &_24$$16, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("enum"), "phalcon/db/adapter/pdo/sqlite.zep", 213)) { ZEPHIR_INIT_NVAR(_25$$17); ZVAL_LONG(_25$$17, 5); zephir_array_update_string(&definition, SL("type"), &_25$$17, PH_COPY | PH_SEPARATE); break; } ZEPHIR_INIT_NVAR(_26$$4); ZVAL_LONG(_26$$4, 2); zephir_array_update_string(&definition, SL("type"), &_26$$4, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("("), "phalcon/db/adapter/pdo/sqlite.zep", 228)) { ZEPHIR_INIT_NVAR(matches); ZVAL_NULL(matches); ZEPHIR_INIT_NVAR(_27$$18); zephir_preg_match(_27$$18, sizePattern, columnType, matches, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(_27$$18)) { ZEPHIR_OBS_NVAR(matchOne); if (zephir_array_isset_long_fetch(&matchOne, matches, 1, 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_28$$20); ZVAL_LONG(_28$$20, zephir_get_intval(matchOne)); zephir_array_update_string(&definition, SL("size"), &_28$$20, PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_NVAR(matchTwo); if (zephir_array_isset_long_fetch(&matchTwo, matches, 2, 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_29$$21); ZVAL_LONG(_29$$21, zephir_get_intval(matchTwo)); zephir_array_update_string(&definition, SL("scale"), &_29$$21, PH_COPY | PH_SEPARATE); } } } if (zephir_memnstr_str(columnType, SL("unsigned"), "phalcon/db/adapter/pdo/sqlite.zep", 243)) { zephir_array_update_string(&definition, SL("unsigned"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } if (Z_TYPE_P(oldColumn) == IS_NULL) { zephir_array_update_string(&definition, SL("first"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } else { zephir_array_update_string(&definition, SL("after"), &oldColumn, PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_30$$3, field, 5, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 259 TSRMLS_CC); if (zephir_is_true(_30$$3)) { zephir_array_update_string(&definition, SL("primary"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_31$$3, field, 3, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 266 TSRMLS_CC); if (zephir_is_true(_31$$3)) { zephir_array_update_string(&definition, SL("notNull"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_32$$3, field, 4, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 274 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_33$$3); ZVAL_STRING(&_33$$3, "null", 0); ZEPHIR_CALL_FUNCTION(&_34$$3, "strcasecmp", &_35, 16, _32$$3, &_33$$3); zephir_check_call_status(); _36$$3 = !ZEPHIR_IS_LONG(_34$$3, 0); if (_36$$3) { zephir_array_fetch_long(&_37$$3, field, 4, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 274 TSRMLS_CC); _36$$3 = !ZEPHIR_IS_STRING(_37$$3, ""); } if (_36$$3) { zephir_array_fetch_long(&_38$$27, field, 4, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 275 TSRMLS_CC); ZEPHIR_INIT_NVAR(_39$$27); ZVAL_STRING(_39$$27, "/^'|'$/", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_40$$27); ZVAL_STRING(_40$$27, "", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&_41$$27, "preg_replace", &_42, 39, _39$$27, _40$$27, _38$$27); zephir_check_temp_parameter(_39$$27); zephir_check_temp_parameter(_40$$27); zephir_check_call_status(); zephir_array_update_string(&definition, SL("default"), &_41$$27, PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&columnName, field, 1, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 281 TSRMLS_CC); ZEPHIR_INIT_NVAR(_43$$3); object_init_ex(_43$$3, phalcon_db_column_ce); ZEPHIR_CALL_METHOD(NULL, _43$$3, "__construct", &_44, 151, columnName, definition); zephir_check_call_status(); zephir_array_append(&columns, _43$$3, PH_SEPARATE, "phalcon/db/adapter/pdo/sqlite.zep", 282); ZEPHIR_CPY_WRT(oldColumn, columnName); } RETURN_CCTOR(columns); }
static void php_intl_idn_to_46(INTERNAL_FUNCTION_PARAMETERS, const char *domain, int domain_len, uint32_t option, int mode, zval *idna_info) { UErrorCode status = U_ZERO_ERROR; UIDNA *uts46; int32_t len; int32_t buffer_capac = 255; /* no domain name may exceed this */ zend_string *buffer = STR_ALLOC(buffer_capac, 0); UIDNAInfo info = UIDNA_INFO_INITIALIZER; int buffer_used = 0; uts46 = uidna_openUTS46(option, &status); if (php_intl_idn_check_status(status, "failed to open UIDNA instance", mode TSRMLS_CC) == FAILURE) { STR_FREE(buffer); RETURN_FALSE; } if (mode == INTL_IDN_TO_ASCII) { len = uidna_nameToASCII_UTF8(uts46, domain, (int32_t)domain_len, buffer->val, buffer_capac, &info, &status); } else { len = uidna_nameToUnicodeUTF8(uts46, domain, (int32_t)domain_len, buffer->val, buffer_capac, &info, &status); } if (php_intl_idn_check_status(status, "failed to convert name", mode TSRMLS_CC) == FAILURE) { uidna_close(uts46); STR_FREE(buffer); RETURN_FALSE; } if (len >= 255) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "ICU returned an unexpected length"); } buffer->val[len] = '\0'; buffer->len = len; if (info.errors == 0) { RETVAL_STR(buffer); buffer_used = 1; } else { RETVAL_FALSE; } if (idna_info) { if (buffer_used) { /* used in return_value then */ zval_addref_p(return_value); add_assoc_zval_ex(idna_info, "result", sizeof("result")-1, return_value); } else { zval zv; ZVAL_STR(&zv, buffer); buffer_used = 1; add_assoc_zval_ex(idna_info, "result", sizeof("result")-1, &zv); } add_assoc_bool_ex(idna_info, "isTransitionalDifferent", sizeof("isTransitionalDifferent")-1, info.isTransitionalDifferent); add_assoc_long_ex(idna_info, "errors", sizeof("errors")-1, (long)info.errors); } if (!buffer_used) { STR_FREE(buffer); } uidna_close(uts46); }
/** * Returns an array of Phalcon\Db\Column objects describing a table * * <code>print_r($connection->describeColumns("posts")); ?></code> */ PHP_METHOD(Phalcon_Db_Adapter_Pdo_Oracle, describeColumns) { zephir_fcall_cache_entry *_11 = NULL; HashTable *_5; HashPosition _4; int ZEPHIR_LAST_CALL_STATUS; zval *table_param = NULL, *schema_param = NULL, *columns, *oldColumn = NULL, *field = NULL, *definition = NULL, *columnSize = NULL, *columnPrecision = NULL, *columnScale = NULL, *columnType = NULL, *columnName, *_0 = NULL, *_1, *_2 = NULL, *_3 = NULL, **_6, *_7 = NULL, *_8 = NULL, *_9, *_10; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(table_param) == IS_STRING)) { zephir_get_strval(table, table_param); } else { ZEPHIR_INIT_VAR(table); ZVAL_EMPTY_STRING(table); } if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } ZEPHIR_INIT_VAR(columns); array_init(columns); ZEPHIR_INIT_VAR(oldColumn); ZVAL_NULL(oldColumn); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_2, _1, "describecolumns", NULL, 0, table, schema); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 3); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, _2, _3); zephir_check_call_status(); zephir_is_iterable(_0, &_5, &_4, 0, 0, "phalcon/db/adapter/pdo/oracle.zep", 203); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(field, _6); ZEPHIR_INIT_NVAR(definition); zephir_create_array(definition, 1, 0 TSRMLS_CC); add_assoc_long_ex(definition, SS("bindType"), 2); ZEPHIR_OBS_NVAR(columnSize); zephir_array_fetch_long(&columnSize, field, 2, PH_NOISY, "phalcon/db/adapter/pdo/oracle.zep", 102 TSRMLS_CC); ZEPHIR_OBS_NVAR(columnPrecision); zephir_array_fetch_long(&columnPrecision, field, 3, PH_NOISY, "phalcon/db/adapter/pdo/oracle.zep", 103 TSRMLS_CC); ZEPHIR_OBS_NVAR(columnScale); zephir_array_fetch_long(&columnScale, field, 4, PH_NOISY, "phalcon/db/adapter/pdo/oracle.zep", 104 TSRMLS_CC); ZEPHIR_OBS_NVAR(columnType); zephir_array_fetch_long(&columnType, field, 1, PH_NOISY, "phalcon/db/adapter/pdo/oracle.zep", 105 TSRMLS_CC); while (1) { if (zephir_memnstr_str(columnType, SL("NUMBER"), "phalcon/db/adapter/pdo/oracle.zep", 112)) { ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 3); 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_array_update_string(&definition, SL("size"), &columnPrecision, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("scale"), &columnScale, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 32); zephir_array_update_string(&definition, SL("bindType"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("INTEGER"), "phalcon/db/adapter/pdo/oracle.zep", 121)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 0); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &columnPrecision, 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("VARCHAR2"), "phalcon/db/adapter/pdo/oracle.zep", 129)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 2); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &columnSize, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("FLOAT"), "phalcon/db/adapter/pdo/oracle.zep", 135)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 7); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &columnSize, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("scale"), &columnScale, 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("TIMESTAMP"), "phalcon/db/adapter/pdo/oracle.zep", 144)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 0); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("RAW"), "phalcon/db/adapter/pdo/oracle.zep", 149)) { 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("BLOB"), "phalcon/db/adapter/pdo/oracle.zep", 154)) { 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("CLOB"), "phalcon/db/adapter/pdo/oracle.zep", 159)) { 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("CHAR"), "phalcon/db/adapter/pdo/oracle.zep", 164)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 5); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &columnSize, PH_COPY | PH_SEPARATE); break; } ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 6); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (Z_TYPE_P(oldColumn) == IS_NULL) { zephir_array_update_string(&definition, SL("first"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } else { zephir_array_update_string(&definition, SL("after"), &oldColumn, PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_9, field, 6, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/oracle.zep", 183 TSRMLS_CC); if (ZEPHIR_IS_STRING(_9, "P")) { zephir_array_update_string(&definition, SL("primary"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_10, field, 5, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/oracle.zep", 190 TSRMLS_CC); if (ZEPHIR_IS_STRING(_10, "N")) { zephir_array_update_string(&definition, SL("notNull"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&columnName, field, 0, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/oracle.zep", 194 TSRMLS_CC); ZEPHIR_INIT_NVAR(_8); object_init_ex(_8, phalcon_db_column_ce); ZEPHIR_CALL_METHOD(NULL, _8, "__construct", &_11, 138, columnName, definition); zephir_check_call_status(); zephir_array_append(&columns, _8, PH_SEPARATE, "phalcon/db/adapter/pdo/oracle.zep", 199); ZEPHIR_CPY_WRT(oldColumn, columnName); } RETURN_CCTOR(columns); }
/** * Returns an array of Phalcon\Db\Column objects describing a table * * <code> * print_r($connection->describeColumns("posts")); ?> * </code> * * @param string $table * @param string $schema * @return Phalcon\Db\Column[] */ PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, describeColumns){ zval *table, *schema = NULL, *columns, *dialect, *size_pattern; zval *sql, *fetch_assoc, *describe, *old_column = NULL; zval *field = NULL, *definition = NULL, *column_type = NULL, *pos = NULL, *attribute = NULL; zval *matches = NULL, *match_one = NULL, *column_name = NULL, *column = NULL; HashTable *ah0; HashPosition hp0; zval **hd; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &table, &schema) == FAILURE) { RETURN_MM_NULL(); } if (!schema) { PHALCON_INIT_VAR(schema); } PHALCON_INIT_VAR(columns); array_init(columns); PHALCON_OBS_VAR(dialect); phalcon_read_property(&dialect, this_ptr, SL("_dialect"), PH_NOISY_CC); PHALCON_INIT_VAR(size_pattern); ZVAL_STRING(size_pattern, "#\\(([0-9]+)(,[0-9]+)*\\)#", 1); PHALCON_INIT_VAR(sql); PHALCON_CALL_METHOD_PARAMS_2(sql, dialect, "describecolumns", table, schema); PHALCON_INIT_VAR(fetch_assoc); phalcon_get_class_constant(fetch_assoc, phalcon_db_ce, SS("FETCH_ASSOC") TSRMLS_CC); PHALCON_INIT_VAR(describe); PHALCON_CALL_METHOD_PARAMS_2(describe, this_ptr, "fetchall", sql, fetch_assoc); PHALCON_INIT_VAR(old_column); if (!phalcon_is_iterable(describe, &ah0, &hp0, 0, 0 TSRMLS_CC)) { return; } while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) { PHALCON_GET_FOREACH_VALUE(field); PHALCON_INIT_NVAR(definition); array_init_size(definition, 1); add_assoc_long_ex(definition, SS("bindType"), 2); PHALCON_OBS_NVAR(column_type); phalcon_array_fetch_string(&column_type, field, SL("type"), PH_NOISY_CC); PHALCON_INIT_NVAR(pos); phalcon_fast_stripos_str(pos, column_type, SL("int") TSRMLS_CC); if (PHALCON_IS_NOT_FALSE(pos)) { phalcon_array_update_string_long(&definition, SL("type"), 0, PH_SEPARATE TSRMLS_CC); phalcon_array_update_string_bool(&definition, SL("isNumeric"), 1, PH_SEPARATE TSRMLS_CC); phalcon_array_update_string_long(&definition, SL("bindType"), 1, PH_SEPARATE TSRMLS_CC); PHALCON_OBS_NVAR(attribute); phalcon_array_fetch_string(&attribute, field, SL("pk"), PH_NOISY_CC); if (zend_is_true(attribute)) { phalcon_array_update_string_bool(&definition, SL("autoIncrement"), 1, PH_SEPARATE TSRMLS_CC); } } else { if (phalcon_memnstr_str(column_type, SL("varchar") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 2, PH_SEPARATE TSRMLS_CC); } else { if (phalcon_memnstr_str(column_type, SL("date") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 1, PH_SEPARATE TSRMLS_CC); } else { if (phalcon_memnstr_str(column_type, SL("decimal") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 3, PH_SEPARATE TSRMLS_CC); phalcon_array_update_string_bool(&definition, SL("isNumeric"), 1, PH_SEPARATE TSRMLS_CC); phalcon_array_update_string_long(&definition, SL("bindType"), 32, PH_SEPARATE TSRMLS_CC); } else { if (phalcon_memnstr_str(column_type, SL("char") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 5, PH_SEPARATE TSRMLS_CC); } else { if (phalcon_memnstr_str(column_type, SL("datetime") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 4, PH_SEPARATE TSRMLS_CC); } else { if (phalcon_memnstr_str(column_type, SL("text") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 6, PH_SEPARATE TSRMLS_CC); } else { if (phalcon_memnstr_str(column_type, SL("float") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 7, PH_SEPARATE TSRMLS_CC); phalcon_array_update_string_bool(&definition, SL("isNumeric"), 1, PH_SEPARATE TSRMLS_CC); phalcon_array_update_string_long(&definition, SL("bindType"), 32, PH_SEPARATE TSRMLS_CC); } else { if (phalcon_memnstr_str(column_type, SL("enum") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 5, PH_SEPARATE TSRMLS_CC); } else { phalcon_array_update_string_long(&definition, SL("type"), 2, PH_SEPARATE TSRMLS_CC); } } } } } } } } } if (phalcon_memnstr_str(column_type, SL("(") TSRMLS_CC)) { PHALCON_INIT_NVAR(matches); array_init(matches); Z_SET_ISREF_P(matches); PHALCON_INIT_NVAR(pos); PHALCON_CALL_FUNC_PARAMS_3(pos, "preg_match", size_pattern, column_type, matches); Z_UNSET_ISREF_P(matches); if (zend_is_true(pos)) { if (phalcon_array_isset_long(matches, 1)) { PHALCON_OBS_NVAR(match_one); phalcon_array_fetch_long(&match_one, matches, 1, PH_NOISY_CC); phalcon_array_update_string(&definition, SL("size"), &match_one, PH_COPY | PH_SEPARATE TSRMLS_CC); } } } if (phalcon_memnstr_str(column_type, SL("unsigned") TSRMLS_CC)) { phalcon_array_update_string_bool(&definition, SL("unsigned"), 1, PH_SEPARATE TSRMLS_CC); } if (!zend_is_true(old_column)) { phalcon_array_update_string_bool(&definition, SL("first"), 1, PH_SEPARATE TSRMLS_CC); } else { phalcon_array_update_string(&definition, SL("after"), &old_column, PH_COPY | PH_SEPARATE TSRMLS_CC); } PHALCON_OBS_NVAR(attribute); phalcon_array_fetch_string(&attribute, field, SL("pk"), PH_NOISY_CC); if (zend_is_true(attribute)) { phalcon_array_update_string_bool(&definition, SL("primary"), 1, PH_SEPARATE TSRMLS_CC); } PHALCON_OBS_NVAR(attribute); phalcon_array_fetch_string(&attribute, field, SL("notnull"), PH_NOISY_CC); if (zend_is_true(attribute)) { phalcon_array_update_string_bool(&definition, SL("notNull"), 1, PH_SEPARATE TSRMLS_CC); } PHALCON_OBS_NVAR(column_name); phalcon_array_fetch_string(&column_name, field, SL("name"), PH_NOISY_CC); PHALCON_INIT_NVAR(column); object_init_ex(column, phalcon_db_column_ce); PHALCON_CALL_METHOD_PARAMS_2_NORETURN(column, "__construct", column_name, definition); phalcon_array_append(&columns, column, PH_SEPARATE TSRMLS_CC); PHALCON_CPY_WRT(old_column, column_name); zend_hash_move_forward_ex(ah0, &hp0); } RETURN_CTOR(columns); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_File, validate) { zend_bool _4, _5, _6, _8, _9, _18, _19, _21, _29, _30, _65, _72$$29, _81$$36; zephir_fcall_cache_entry *_15 = NULL, *_17 = NULL, *_44 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *_SERVER, *_POST, *_FILES, *value = NULL, *message = NULL, *label = NULL, *replacePairs = NULL, *types = NULL, *byteUnits = NULL, *unit = NULL, *maxSize = NULL, *matches = NULL, *bytes = NULL, *mime = NULL, *tmp = NULL, *width = NULL, *height = NULL, *minResolution = NULL, *maxResolution = NULL, *minWidth = NULL, *maxWidth = NULL, *minHeight = NULL, *maxHeight = NULL, *fieldTypes = NULL, *code = NULL, *minResolutionArray = NULL, *maxResolutionArray = NULL, *_0 = NULL, *_3, *_7, *_10, *_20, *_22, *_23 = NULL, *_36 = NULL, *_55 = NULL, *_64 = NULL, *_66 = NULL, *_1$$3, *_2$$5, *_11$$6 = NULL, *_14$$6 = NULL, *_16$$6, *_12$$7, *_13$$8, *_24$$9 = NULL, *_27$$9 = NULL, *_28$$9, *_25$$10, *_26$$11, *_31$$12 = NULL, *_34$$12 = NULL, *_35$$12, *_32$$13, *_33$$14, *_37$$15 = NULL, *_39$$15, *_40$$15, *_41$$15, *_42$$15, *_43$$15 = NULL, *_45$$15, *_46$$15, _47$$15, *_48$$15, *_49$$15 = NULL, *_38$$16, *_50$$18 = NULL, *_53$$18 = NULL, *_54$$18, *_51$$19, *_52$$20, *_56$$21, _57$$24, *_58$$24, *_59$$26 = NULL, *_62$$26 = NULL, *_63$$26, *_60$$27, *_61$$28, *_67$$29, *_68$$29 = NULL, *_69$$29 = NULL, *_78$$29 = NULL, *_70$$30, *_71$$31, *_73$$33 = NULL, *_76$$33 = NULL, *_77$$33, *_74$$34, *_75$$35, *_79$$36, *_80$$37, *_82$$38 = NULL, *_85$$38 = NULL, *_86$$38, *_83$$39, *_84$$40; 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 (Z_TYPE_P(label) == IS_ARRAY) { zephir_array_fetch(&_1$$3, label, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 108 TSRMLS_CC); ZEPHIR_CPY_WRT(label, _1$$3); } if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "code", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&code, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(code) == IS_ARRAY) { zephir_array_fetch(&_2$$5, code, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 117 TSRMLS_CC); ZEPHIR_CPY_WRT(code, _2$$5); } zephir_array_fetch_string(&_3, _SERVER, SL("REQUEST_METHOD"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 121 TSRMLS_CC); _4 = ZEPHIR_IS_STRING(_3, "POST"); if (_4) { _4 = ZEPHIR_IS_EMPTY(_POST); } _5 = _4; if (_5) { _5 = ZEPHIR_IS_EMPTY(_FILES); } _6 = _5; if (_6) { zephir_array_fetch_string(&_7, _SERVER, SL("CONTENT_LENGTH"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 121 TSRMLS_CC); _6 = ZEPHIR_GT_LONG(_7, 0); } _8 = _6; if (!(_8)) { _9 = zephir_array_isset_string(value, SS("error")); if (_9) { zephir_array_fetch_string(&_10, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 121 TSRMLS_CC); _9 = ZEPHIR_IS_LONG_IDENTICAL(_10, 1); } _8 = _9; } if (_8) { ZEPHIR_INIT_VAR(_11$$6); ZVAL_STRING(_11$$6, "messageIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _11$$6); zephir_check_temp_parameter(_11$$6); 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 (Z_TYPE_P(message) == IS_ARRAY) { zephir_array_fetch(&_12$$7, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 127 TSRMLS_CC); ZEPHIR_CPY_WRT(message, _12$$7); } if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_13$$8); ZVAL_STRING(_13$$8, "FileIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _13$$8); zephir_check_temp_parameter(_13$$8); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_11$$6); object_init_ex(_11$$6, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_14$$6, "strtr", &_15, 26, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_16$$6); ZVAL_STRING(_16$$6, "FileIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _11$$6, "__construct", &_17, 466, _14$$6, field, _16$$6, code); zephir_check_temp_parameter(_16$$6); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _11$$6); zephir_check_call_status(); RETURN_MM_BOOL(0); } _18 = !(zephir_array_isset_string(value, SS("error"))); if (!(_18)) { _18 = !(zephir_array_isset_string(value, SS("tmp_name"))); } _19 = _18; if (!(_19)) { zephir_array_fetch_string(&_20, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 138 TSRMLS_CC); _19 = !ZEPHIR_IS_LONG_IDENTICAL(_20, 0); } _21 = _19; if (!(_21)) { zephir_array_fetch_string(&_22, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 138 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_23, "is_uploaded_file", NULL, 246, _22); zephir_check_call_status(); _21 = !zephir_is_true(_23); } if (_21) { ZEPHIR_INIT_VAR(_24$$9); ZVAL_STRING(_24$$9, "messageEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _24$$9); zephir_check_temp_parameter(_24$$9); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (Z_TYPE_P(message) == IS_ARRAY) { zephir_array_fetch(&_25$$10, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 144 TSRMLS_CC); ZEPHIR_CPY_WRT(message, _25$$10); } if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_26$$11); ZVAL_STRING(_26$$11, "FileEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _26$$11); zephir_check_temp_parameter(_26$$11); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_24$$9); object_init_ex(_24$$9, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_27$$9, "strtr", &_15, 26, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_28$$9); ZVAL_STRING(_28$$9, "FileEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _24$$9, "__construct", &_17, 466, _27$$9, field, _28$$9, code); zephir_check_temp_parameter(_28$$9); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _24$$9); zephir_check_call_status(); RETURN_MM_BOOL(0); } _29 = !(zephir_array_isset_string(value, SS("name"))); if (!(_29)) { _29 = !(zephir_array_isset_string(value, SS("type"))); } _30 = _29; if (!(_30)) { _30 = !(zephir_array_isset_string(value, SS("size"))); } if (_30) { ZEPHIR_INIT_VAR(_31$$12); ZVAL_STRING(_31$$12, "messageValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _31$$12); zephir_check_temp_parameter(_31$$12); 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 (Z_TYPE_P(message) == IS_ARRAY) { zephir_array_fetch(&_32$$13, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 161 TSRMLS_CC); ZEPHIR_CPY_WRT(message, _32$$13); } if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_33$$14); ZVAL_STRING(_33$$14, "FileValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _33$$14); zephir_check_temp_parameter(_33$$14); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_31$$12); object_init_ex(_31$$12, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_34$$12, "strtr", &_15, 26, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_35$$12); ZVAL_STRING(_35$$12, "FileValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _31$$12, "__construct", &_17, 466, _34$$12, field, _35$$12, code); zephir_check_temp_parameter(_35$$12); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _31$$12); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "maxSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_36, this_ptr, "hasoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (zephir_is_true(_36)) { ZEPHIR_INIT_VAR(byteUnits); zephir_create_array(byteUnits, 9, 0 TSRMLS_CC); add_assoc_long_ex(byteUnits, SS("B"), 0); add_assoc_long_ex(byteUnits, SS("K"), 10); add_assoc_long_ex(byteUnits, SS("M"), 20); add_assoc_long_ex(byteUnits, SS("G"), 30); add_assoc_long_ex(byteUnits, SS("T"), 40); add_assoc_long_ex(byteUnits, SS("KB"), 10); add_assoc_long_ex(byteUnits, SS("MB"), 20); add_assoc_long_ex(byteUnits, SS("GB"), 30); add_assoc_long_ex(byteUnits, SS("TB"), 40); ZEPHIR_INIT_VAR(_37$$15); ZVAL_STRING(_37$$15, "maxSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&maxSize, this_ptr, "getoption", NULL, 0, _37$$15); zephir_check_temp_parameter(_37$$15); 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(&_38$$16, maxSize, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 180 TSRMLS_CC); ZEPHIR_CPY_WRT(maxSize, _38$$16); } ZEPHIR_INIT_NVAR(_37$$15); ZEPHIR_INIT_VAR(_39$$15); ZEPHIR_INIT_VAR(_40$$15); zephir_array_keys(_40$$15, byteUnits TSRMLS_CC); zephir_fast_join_str(_39$$15, SL("|"), _40$$15 TSRMLS_CC); ZEPHIR_INIT_VAR(_41$$15); ZEPHIR_CONCAT_SVS(_41$$15, "/^([0-9]+(?:\\.[0-9]+)?)(", _39$$15, ")?$/Di"); zephir_preg_match(_37$$15, _41$$15, 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", 186 TSRMLS_CC); } zephir_array_fetch_long(&_42$$15, matches, 1, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 189 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_43$$15, "floatval", &_44, 322, _42$$15); zephir_check_call_status(); ZEPHIR_INIT_VAR(_45$$15); zephir_array_fetch(&_46$$15, byteUnits, unit, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 189 TSRMLS_CC); ZEPHIR_SINIT_VAR(_47$$15); ZVAL_LONG(&_47$$15, 2); zephir_pow_function(_45$$15, &_47$$15, _46$$15); ZEPHIR_INIT_VAR(bytes); mul_function(bytes, _43$$15, _45$$15 TSRMLS_CC); zephir_array_fetch_string(&_48$$15, value, SL("size"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 191 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_43$$15, "floatval", &_44, 322, _48$$15); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_49$$15, "floatval", &_44, 322, bytes); zephir_check_call_status(); if (ZEPHIR_GT(_43$$15, _49$$15)) { ZEPHIR_INIT_VAR(_50$$18); ZVAL_STRING(_50$$18, "messageSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _50$$18); zephir_check_temp_parameter(_50$$18); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":max"), &maxSize, PH_COPY | PH_SEPARATE); if (Z_TYPE_P(message) == IS_ARRAY) { zephir_array_fetch(&_51$$19, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 196 TSRMLS_CC); ZEPHIR_CPY_WRT(message, _51$$19); } if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_52$$20); ZVAL_STRING(_52$$20, "FileSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _52$$20); zephir_check_temp_parameter(_52$$20); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_50$$18); object_init_ex(_50$$18, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_53$$18, "strtr", &_15, 26, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_54$$18); ZVAL_STRING(_54$$18, "FileSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _50$$18, "__construct", &_17, 466, _53$$18, field, _54$$18, code); zephir_check_temp_parameter(_54$$18); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _50$$18); zephir_check_call_status(); RETURN_MM_BOOL(0); } } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_55, this_ptr, "hasoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (zephir_is_true(_55)) { ZEPHIR_INIT_VAR(_56$$21); ZVAL_STRING(_56$$21, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&types, this_ptr, "getoption", NULL, 0, _56$$21); zephir_check_temp_parameter(_56$$21); 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", 217); return; } if ((zephir_function_exists_ex(SS("finfo_open") TSRMLS_CC) == SUCCESS)) { ZEPHIR_SINIT_VAR(_57$$24); ZVAL_LONG(&_57$$24, 16); ZEPHIR_CALL_FUNCTION(&tmp, "finfo_open", NULL, 243, &_57$$24); zephir_check_call_status(); zephir_array_fetch_string(&_58$$24, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 222 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&mime, "finfo_file", NULL, 244, tmp, _58$$24); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(NULL, "finfo_close", NULL, 245, 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", 226 TSRMLS_CC); } if (!(zephir_fast_in_array(mime, types TSRMLS_CC))) { ZEPHIR_INIT_VAR(_59$$26); ZVAL_STRING(_59$$26, "messageType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _59$$26); zephir_check_temp_parameter(_59$$26); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_59$$26); zephir_fast_join_str(_59$$26, SL(", "), types TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":types"), &_59$$26, PH_COPY | PH_SEPARATE); if (Z_TYPE_P(message) == IS_ARRAY) { zephir_array_fetch(&_60$$27, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 234 TSRMLS_CC); ZEPHIR_CPY_WRT(message, _60$$27); } if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_61$$28); ZVAL_STRING(_61$$28, "FileType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _61$$28); zephir_check_temp_parameter(_61$$28); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_59$$26); object_init_ex(_59$$26, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_62$$26, "strtr", &_15, 26, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_63$$26); ZVAL_STRING(_63$$26, "FileType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _59$$26, "__construct", &_17, 466, _62$$26, field, _63$$26, code); zephir_check_temp_parameter(_63$$26); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _59$$26); zephir_check_call_status(); RETURN_MM_BOOL(0); } } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_64, this_ptr, "hasoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _65 = zephir_is_true(_64); if (!(_65)) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_66, this_ptr, "hasoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _65 = zephir_is_true(_66); } if (_65) { zephir_array_fetch_string(&_67$$29, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 247 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&tmp, "getimagesize", NULL, 254, _67$$29); zephir_check_call_status(); ZEPHIR_OBS_VAR(width); zephir_array_fetch_long(&width, tmp, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 248 TSRMLS_CC); ZEPHIR_OBS_VAR(height); zephir_array_fetch_long(&height, tmp, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 249 TSRMLS_CC); ZEPHIR_INIT_VAR(_69$$29); ZVAL_STRING(_69$$29, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_68$$29, this_ptr, "hasoption", NULL, 0, _69$$29); zephir_check_temp_parameter(_69$$29); zephir_check_call_status(); if (zephir_is_true(_68$$29)) { ZEPHIR_INIT_VAR(_70$$30); ZVAL_STRING(_70$$30, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&minResolution, this_ptr, "getoption", NULL, 0, _70$$30); zephir_check_temp_parameter(_70$$30); zephir_check_call_status(); if (Z_TYPE_P(minResolution) == IS_ARRAY) { zephir_array_fetch(&_71$$31, minResolution, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 254 TSRMLS_CC); ZEPHIR_CPY_WRT(minResolution, _71$$31); } 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", 257 TSRMLS_CC); ZEPHIR_OBS_VAR(minHeight); zephir_array_fetch_long(&minHeight, minResolutionArray, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 258 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(minWidth); ZVAL_LONG(minWidth, 1); ZEPHIR_INIT_NVAR(minHeight); ZVAL_LONG(minHeight, 1); } _72$$29 = ZEPHIR_LT(width, minWidth); if (!(_72$$29)) { _72$$29 = ZEPHIR_LT(height, minHeight); } if (_72$$29) { ZEPHIR_INIT_VAR(_73$$33); ZVAL_STRING(_73$$33, "messageMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _73$$33); zephir_check_temp_parameter(_73$$33); 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); if (Z_TYPE_P(message) == IS_ARRAY) { zephir_array_fetch(&_74$$34, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 269 TSRMLS_CC); ZEPHIR_CPY_WRT(message, _74$$34); } if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_75$$35); ZVAL_STRING(_75$$35, "FileMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _75$$35); zephir_check_temp_parameter(_75$$35); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_73$$33); object_init_ex(_73$$33, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_76$$33, "strtr", &_15, 26, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_77$$33); ZVAL_STRING(_77$$33, "FileMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _73$$33, "__construct", &_17, 466, _76$$33, field, _77$$33, code); zephir_check_temp_parameter(_77$$33); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _73$$33); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_69$$29); ZVAL_STRING(_69$$29, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_78$$29, this_ptr, "hasoption", NULL, 0, _69$$29); zephir_check_temp_parameter(_69$$29); zephir_check_call_status(); if (zephir_is_true(_78$$29)) { ZEPHIR_INIT_VAR(_79$$36); ZVAL_STRING(_79$$36, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&maxResolution, this_ptr, "getoption", NULL, 0, _79$$36); zephir_check_temp_parameter(_79$$36); zephir_check_call_status(); if (Z_TYPE_P(maxResolution) == IS_ARRAY) { zephir_array_fetch(&_80$$37, maxResolution, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 284 TSRMLS_CC); ZEPHIR_CPY_WRT(maxResolution, _80$$37); } 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", 287 TSRMLS_CC); ZEPHIR_OBS_VAR(maxHeight); zephir_array_fetch_long(&maxHeight, maxResolutionArray, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 288 TSRMLS_CC); _81$$36 = ZEPHIR_GT(width, maxWidth); if (!(_81$$36)) { _81$$36 = ZEPHIR_GT(height, maxHeight); } if (_81$$36) { ZEPHIR_INIT_VAR(_82$$38); ZVAL_STRING(_82$$38, "messageMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _82$$38); zephir_check_temp_parameter(_82$$38); 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); if (Z_TYPE_P(message) == IS_ARRAY) { zephir_array_fetch(&_83$$39, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 295 TSRMLS_CC); ZEPHIR_CPY_WRT(message, _83$$39); } if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_84$$40); ZVAL_STRING(_84$$40, "FileMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _84$$40); zephir_check_temp_parameter(_84$$40); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_82$$38); object_init_ex(_82$$38, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_85$$38, "strtr", &_15, 26, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_86$$38); ZVAL_STRING(_86$$38, "FileMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _82$$38, "__construct", &_17, 466, _85$$38, field, _86$$38, code); zephir_check_temp_parameter(_86$$38); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _82$$38); zephir_check_call_status(); RETURN_MM_BOOL(0); } } } RETURN_MM_BOOL(1); }
/** * Returns an array of Phalcon\Db\Column objects describing a table * * <code> * print_r($connection->describeColumns("posts")); * </code> * * @param string table * @param string schema * @return Phalcon\Db\Column[] */ PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, describeColumns) { zephir_fcall_cache_entry *_21 = NULL; zephir_nts_static zephir_fcall_cache_entry *_16 = NULL, *_20 = NULL; HashTable *_5; HashPosition _4; int ZEPHIR_LAST_CALL_STATUS; zval *table_param = NULL, *schema_param = NULL, *columns, *columnType = NULL, *field = NULL, *definition = NULL, *oldColumn = NULL, *columnName, *charSize = NULL, *numericSize = NULL, *numericScale = NULL, *_0 = NULL, *_1, *_2 = NULL, *_3 = NULL, **_6, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_10, *_11, *_12, *_13 = NULL, *_14, *_15 = NULL, *_17, _18 = zval_used_for_init, *_19 = NULL; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); zephir_get_strval(table, table_param); if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } ZEPHIR_INIT_VAR(oldColumn); ZVAL_NULL(oldColumn); ZEPHIR_INIT_VAR(columns); array_init(columns); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_2, _1, "describecolumns", NULL, table, schema); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 3); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, _2, _3); zephir_check_call_status(); zephir_is_iterable(_0, &_5, &_4, 0, 0, "phalcon/db/adapter/pdo/postgresql.zep", 295); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(field, _6); ZEPHIR_INIT_NVAR(definition); zephir_create_array(definition, 1, 0 TSRMLS_CC); add_assoc_long_ex(definition, SS("bindType"), 2); ZEPHIR_OBS_NVAR(columnType); zephir_array_fetch_long(&columnType, field, 1, PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 119 TSRMLS_CC); ZEPHIR_OBS_NVAR(charSize); zephir_array_fetch_long(&charSize, field, 2, PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 120 TSRMLS_CC); ZEPHIR_OBS_NVAR(numericSize); zephir_array_fetch_long(&numericSize, field, 3, PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 121 TSRMLS_CC); ZEPHIR_OBS_NVAR(numericScale); zephir_array_fetch_long(&numericScale, field, 4, PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 122 TSRMLS_CC); while (1) { if (zephir_memnstr_str(columnType, SL("smallint(1)"), "phalcon/db/adapter/pdo/postgresql.zep", 129)) { ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 8); zephir_array_update_string(&definition, SL("type"), &_3, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 5); zephir_array_update_string(&definition, SL("bindType"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("int"), "phalcon/db/adapter/pdo/postgresql.zep", 138)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 0); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &numericSize, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 1); zephir_array_update_string(&definition, SL("bindType"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("varying"), "phalcon/db/adapter/pdo/postgresql.zep", 149)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 2); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &charSize, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("date"), "phalcon/db/adapter/pdo/postgresql.zep", 158)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 1); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 0); zephir_array_update_string(&definition, SL("size"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("numeric"), "phalcon/db/adapter/pdo/postgresql.zep", 167)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 3); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &numericSize, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("scale"), &numericScale, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 32); zephir_array_update_string(&definition, SL("bindType"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("char"), "phalcon/db/adapter/pdo/postgresql.zep", 179)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 5); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &charSize, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("timestamp"), "phalcon/db/adapter/pdo/postgresql.zep", 188)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 4); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 0); zephir_array_update_string(&definition, SL("size"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("text"), "phalcon/db/adapter/pdo/postgresql.zep", 197)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 6); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &charSize, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("float"), "phalcon/db/adapter/pdo/postgresql.zep", 206)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 7); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &numericSize, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 32); zephir_array_update_string(&definition, SL("bindType"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("bool"), "phalcon/db/adapter/pdo/postgresql.zep", 217)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 8); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 0); zephir_array_update_string(&definition, SL("size"), &_8, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_9); ZVAL_LONG(_9, 5); zephir_array_update_string(&definition, SL("bindType"), &_9, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("uuid"), "phalcon/db/adapter/pdo/postgresql.zep", 227)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 5); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 36); zephir_array_update_string(&definition, SL("size"), &_8, PH_COPY | PH_SEPARATE); break; } ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 2); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("unsigned"), "phalcon/db/adapter/pdo/postgresql.zep", 243)) { zephir_array_update_string(&definition, SL("unsigned"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } if (Z_TYPE_P(oldColumn) == IS_NULL) { zephir_array_update_string(&definition, SL("first"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } else { zephir_array_update_string(&definition, SL("after"), &oldColumn, PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_10, field, 6, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 259 TSRMLS_CC); if (ZEPHIR_IS_STRING(_10, "PRI")) { zephir_array_update_string(&definition, SL("primary"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_11, field, 5, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 266 TSRMLS_CC); if (ZEPHIR_IS_STRING(_11, "NO")) { zephir_array_update_string(&definition, SL("notNull"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_12, field, 7, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 273 TSRMLS_CC); if (ZEPHIR_IS_STRING(_12, "auto_increment")) { zephir_array_update_string(&definition, SL("autoIncrement"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_NVAR(_13); zephir_array_fetch_long(&_13, field, 9, PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 280 TSRMLS_CC); if (Z_TYPE_P(_13) != IS_NULL) { zephir_array_fetch_long(&_14, field, 9, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 281 TSRMLS_CC); ZEPHIR_INIT_NVAR(_8); ZVAL_STRING(_8, "/^'|'?::[[:alnum:][:space:]]+$/", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_9); ZVAL_STRING(_9, "", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&_15, "preg_replace", &_16, _8, _9, _14); zephir_check_temp_parameter(_8); zephir_check_temp_parameter(_9); zephir_check_call_status(); zephir_array_update_string(&definition, SL("default"), &_15, PH_COPY | PH_SEPARATE); zephir_array_fetch_string(&_17, definition, SL("default"), PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 282 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_18); ZVAL_STRING(&_18, "null", 0); ZEPHIR_CALL_FUNCTION(&_19, "strcasecmp", &_20, _17, &_18); zephir_check_call_status(); if (ZEPHIR_IS_LONG(_19, 0)) { zephir_array_update_string(&definition, SL("default"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); } } zephir_array_fetch_long(&columnName, field, 0, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 290 TSRMLS_CC); ZEPHIR_INIT_NVAR(_7); object_init_ex(_7, phalcon_db_column_ce); ZEPHIR_CALL_METHOD(NULL, _7, "__construct", &_21, columnName, definition); zephir_check_call_status(); zephir_array_append(&columns, _7, PH_SEPARATE, "phalcon/db/adapter/pdo/postgresql.zep", 291); ZEPHIR_CPY_WRT(oldColumn, columnName); } RETURN_CCTOR(columns); }
/** * Returns an array of Phalcon\Db\Column objects describing a table * * <code> * print_r( * $connection->describeColumns("posts") * ); * </code> */ PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, describeColumns) { HashTable *_5; HashPosition _4; zephir_fcall_cache_entry *_41 = NULL, *_45 = NULL, *_47 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *table_param = NULL, *schema_param = NULL, *columns = NULL, *columnType = NULL, *field = NULL, *definition = NULL, *oldColumn = NULL, *columnName = NULL, *charSize = NULL, *numericSize = NULL, *numericScale = NULL, *_0 = NULL, *_1, *_2 = NULL, *_3, **_6, *_7$$4 = NULL, *_8$$4 = NULL, *_9$$5 = NULL, *_10$$5 = NULL, *_11$$6 = NULL, *_12$$6 = NULL, *_13$$7 = NULL, *_14$$8 = NULL, *_15$$8 = NULL, *_16$$9 = NULL, *_17$$10 = NULL, *_18$$10 = NULL, *_19$$11 = NULL, *_20$$12 = NULL, *_21$$12 = NULL, *_22$$13 = NULL, *_23$$14 = NULL, *_24$$14 = NULL, *_25$$15 = NULL, *_26$$15 = NULL, *_27$$15 = NULL, *_28$$16 = NULL, *_29$$17 = NULL, *_30$$18 = NULL, *_31$$18 = NULL, *_32$$19 = NULL, *_33$$3, *_34$$3, *_35$$3, *_36$$3 = NULL, *_46$$3 = NULL, *_37$$26, *_38$$26 = NULL, *_39$$26 = NULL, *_40$$26 = NULL, *_42$$26, _43$$26 = zval_used_for_init, *_44$$26 = NULL; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); zephir_get_strval(table, table_param); if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } ZEPHIR_INIT_VAR(oldColumn); ZVAL_NULL(oldColumn); ZEPHIR_INIT_VAR(columns); array_init(columns); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_2, _1, "describecolumns", NULL, 0, table, schema); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 3); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, _2, _3); zephir_check_call_status(); zephir_is_iterable(_0, &_5, &_4, 0, 0, "phalcon/db/adapter/pdo/postgresql.zep", 281); for ( ; zend_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zend_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(field, _6); ZEPHIR_INIT_NVAR(definition); zephir_create_array(definition, 1, 0 TSRMLS_CC); add_assoc_long_ex(definition, SS("bindType"), 2); ZEPHIR_OBS_NVAR(columnType); zephir_array_fetch_long(&columnType, field, 1, PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 118 TSRMLS_CC); ZEPHIR_OBS_NVAR(charSize); zephir_array_fetch_long(&charSize, field, 2, PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 119 TSRMLS_CC); ZEPHIR_OBS_NVAR(numericSize); zephir_array_fetch_long(&numericSize, field, 3, PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 120 TSRMLS_CC); ZEPHIR_OBS_NVAR(numericScale); zephir_array_fetch_long(&numericScale, field, 4, PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 121 TSRMLS_CC); if (zephir_memnstr_str(columnType, SL("smallint(1)"), "phalcon/db/adapter/pdo/postgresql.zep", 123)) { ZEPHIR_INIT_NVAR(_7$$4); ZVAL_LONG(_7$$4, 8); zephir_array_update_string(&definition, SL("type"), &_7$$4, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8$$4); ZVAL_LONG(_8$$4, 5); zephir_array_update_string(&definition, SL("bindType"), &_8$$4, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("bigint"), "phalcon/db/adapter/pdo/postgresql.zep", 129)) { ZEPHIR_INIT_NVAR(_9$$5); ZVAL_LONG(_9$$5, 14); zephir_array_update_string(&definition, SL("type"), &_9$$5, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_10$$5); ZVAL_LONG(_10$$5, 1); zephir_array_update_string(&definition, SL("bindType"), &_10$$5, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("int"), "phalcon/db/adapter/pdo/postgresql.zep", 136)) { ZEPHIR_INIT_NVAR(_11$$6); ZVAL_LONG(_11$$6, 0); zephir_array_update_string(&definition, SL("type"), &_11$$6, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &numericSize, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_12$$6); ZVAL_LONG(_12$$6, 1); zephir_array_update_string(&definition, SL("bindType"), &_12$$6, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("varying"), "phalcon/db/adapter/pdo/postgresql.zep", 144)) { ZEPHIR_INIT_NVAR(_13$$7); ZVAL_LONG(_13$$7, 2); zephir_array_update_string(&definition, SL("type"), &_13$$7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &charSize, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("date"), "phalcon/db/adapter/pdo/postgresql.zep", 150)) { ZEPHIR_INIT_NVAR(_14$$8); ZVAL_LONG(_14$$8, 1); zephir_array_update_string(&definition, SL("type"), &_14$$8, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_15$$8); ZVAL_LONG(_15$$8, 0); zephir_array_update_string(&definition, SL("size"), &_15$$8, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("timestamp"), "phalcon/db/adapter/pdo/postgresql.zep", 156)) { ZEPHIR_INIT_NVAR(_16$$9); ZVAL_LONG(_16$$9, 17); zephir_array_update_string(&definition, SL("type"), &_16$$9, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("numeric"), "phalcon/db/adapter/pdo/postgresql.zep", 161)) { ZEPHIR_INIT_NVAR(_17$$10); ZVAL_LONG(_17$$10, 3); zephir_array_update_string(&definition, SL("type"), &_17$$10, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &numericSize, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("scale"), &numericScale, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_18$$10); ZVAL_LONG(_18$$10, 32); zephir_array_update_string(&definition, SL("bindType"), &_18$$10, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("char"), "phalcon/db/adapter/pdo/postgresql.zep", 170)) { ZEPHIR_INIT_NVAR(_19$$11); ZVAL_LONG(_19$$11, 5); zephir_array_update_string(&definition, SL("type"), &_19$$11, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &charSize, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("timestamp"), "phalcon/db/adapter/pdo/postgresql.zep", 176)) { ZEPHIR_INIT_NVAR(_20$$12); ZVAL_LONG(_20$$12, 4); zephir_array_update_string(&definition, SL("type"), &_20$$12, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_21$$12); ZVAL_LONG(_21$$12, 0); zephir_array_update_string(&definition, SL("size"), &_21$$12, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("text"), "phalcon/db/adapter/pdo/postgresql.zep", 182)) { ZEPHIR_INIT_NVAR(_22$$13); ZVAL_LONG(_22$$13, 6); zephir_array_update_string(&definition, SL("type"), &_22$$13, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &charSize, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("float"), "phalcon/db/adapter/pdo/postgresql.zep", 188)) { ZEPHIR_INIT_NVAR(_23$$14); ZVAL_LONG(_23$$14, 7); zephir_array_update_string(&definition, SL("type"), &_23$$14, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &numericSize, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_24$$14); ZVAL_LONG(_24$$14, 32); zephir_array_update_string(&definition, SL("bindType"), &_24$$14, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("bool"), "phalcon/db/adapter/pdo/postgresql.zep", 196)) { ZEPHIR_INIT_NVAR(_25$$15); ZVAL_LONG(_25$$15, 8); zephir_array_update_string(&definition, SL("type"), &_25$$15, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_26$$15); ZVAL_LONG(_26$$15, 0); zephir_array_update_string(&definition, SL("size"), &_26$$15, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_27$$15); ZVAL_LONG(_27$$15, 5); zephir_array_update_string(&definition, SL("bindType"), &_27$$15, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("jsonb"), "phalcon/db/adapter/pdo/postgresql.zep", 203)) { ZEPHIR_INIT_NVAR(_28$$16); ZVAL_LONG(_28$$16, 16); zephir_array_update_string(&definition, SL("type"), &_28$$16, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("json"), "phalcon/db/adapter/pdo/postgresql.zep", 208)) { ZEPHIR_INIT_NVAR(_29$$17); ZVAL_LONG(_29$$17, 15); zephir_array_update_string(&definition, SL("type"), &_29$$17, PH_COPY | PH_SEPARATE); } else if (zephir_memnstr_str(columnType, SL("uuid"), "phalcon/db/adapter/pdo/postgresql.zep", 213)) { ZEPHIR_INIT_NVAR(_30$$18); ZVAL_LONG(_30$$18, 5); zephir_array_update_string(&definition, SL("type"), &_30$$18, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_31$$18); ZVAL_LONG(_31$$18, 36); zephir_array_update_string(&definition, SL("size"), &_31$$18, PH_COPY | PH_SEPARATE); } else { ZEPHIR_INIT_NVAR(_32$$19); ZVAL_LONG(_32$$19, 2); zephir_array_update_string(&definition, SL("type"), &_32$$19, PH_COPY | PH_SEPARATE); } if (zephir_memnstr_str(columnType, SL("unsigned"), "phalcon/db/adapter/pdo/postgresql.zep", 229)) { zephir_array_update_string(&definition, SL("unsigned"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } if (Z_TYPE_P(oldColumn) == IS_NULL) { zephir_array_update_string(&definition, SL("first"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } else { zephir_array_update_string(&definition, SL("after"), &oldColumn, PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_33$$3, field, 6, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 245 TSRMLS_CC); if (ZEPHIR_IS_STRING(_33$$3, "PRI")) { zephir_array_update_string(&definition, SL("primary"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_34$$3, field, 5, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 252 TSRMLS_CC); if (ZEPHIR_IS_STRING(_34$$3, "NO")) { zephir_array_update_string(&definition, SL("notNull"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_35$$3, field, 7, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 259 TSRMLS_CC); if (ZEPHIR_IS_STRING(_35$$3, "auto_increment")) { zephir_array_update_string(&definition, SL("autoIncrement"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_NVAR(_36$$3); zephir_array_fetch_long(&_36$$3, field, 9, PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 266 TSRMLS_CC); if (Z_TYPE_P(_36$$3) != IS_NULL) { zephir_array_fetch_long(&_37$$26, field, 9, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 267 TSRMLS_CC); ZEPHIR_INIT_NVAR(_38$$26); ZVAL_STRING(_38$$26, "/^'|'?::[[:alnum:][:space:]]+$/", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_39$$26); ZVAL_STRING(_39$$26, "", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&_40$$26, "preg_replace", &_41, 39, _38$$26, _39$$26, _37$$26); zephir_check_temp_parameter(_38$$26); zephir_check_temp_parameter(_39$$26); zephir_check_call_status(); zephir_array_update_string(&definition, SL("default"), &_40$$26, PH_COPY | PH_SEPARATE); zephir_array_fetch_string(&_42$$26, definition, SL("default"), PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 268 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_43$$26); ZVAL_STRING(&_43$$26, "null", 0); ZEPHIR_CALL_FUNCTION(&_44$$26, "strcasecmp", &_45, 16, _42$$26, &_43$$26); zephir_check_call_status(); if (ZEPHIR_IS_LONG(_44$$26, 0)) { zephir_array_update_string(&definition, SL("default"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); } } zephir_array_fetch_long(&columnName, field, 0, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 276 TSRMLS_CC); ZEPHIR_INIT_NVAR(_46$$3); object_init_ex(_46$$3, phalcon_db_column_ce); ZEPHIR_CALL_METHOD(NULL, _46$$3, "__construct", &_47, 148, columnName, definition); zephir_check_call_status(); zephir_array_append(&columns, _46$$3, PH_SEPARATE, "phalcon/db/adapter/pdo/postgresql.zep", 277); ZEPHIR_CPY_WRT(oldColumn, columnName); } RETURN_CCTOR(columns); }
/** * Returns an array of Phalcon\Db\Column objects describing a table * * <code> * print_r($connection->describeColumns("posts")); ?> * </code> * * @param string $table * @param string $schema * @return Phalcon\Db\Column[] */ PHP_METHOD(Phalcon_Db_Adapter_Pdo_Mysql, describeColumns){ zval *table, *schema = NULL, *columns, *dialect, *sql, *fetch_assoc; zval *describe, *old_column = NULL, *size_pattern, *field = NULL; zval *definition = NULL, *column_type = NULL, *matches = NULL, *pos = NULL; zval *match_one = NULL, *attribute = NULL, *column_name = NULL, *column = NULL; HashTable *ah0; HashPosition hp0; zval **hd; int eval_int; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &table, &schema) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } if (!schema) { PHALCON_INIT_NVAR(schema); } PHALCON_INIT_VAR(columns); array_init(columns); PHALCON_INIT_VAR(dialect); phalcon_read_property(&dialect, this_ptr, SL("_dialect"), PH_NOISY_CC); PHALCON_INIT_VAR(sql); PHALCON_CALL_METHOD_PARAMS_2(sql, dialect, "describecolumns", table, schema, PH_NO_CHECK); PHALCON_INIT_VAR(fetch_assoc); phalcon_get_class_constant(fetch_assoc, phalcon_db_ce, SS("FETCH_ASSOC") TSRMLS_CC); PHALCON_INIT_VAR(describe); PHALCON_CALL_METHOD_PARAMS_2(describe, this_ptr, "fetchall", sql, fetch_assoc, PH_NO_CHECK); PHALCON_INIT_VAR(old_column); PHALCON_INIT_VAR(size_pattern); ZVAL_STRING(size_pattern, "#\\(([0-9]+)(,[0-9]+)*\\)#", 1); if (!phalcon_valid_foreach(describe TSRMLS_CC)) { return; } ah0 = Z_ARRVAL_P(describe); zend_hash_internal_pointer_reset_ex(ah0, &hp0); ph_cycle_start_0: if (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS) { goto ph_cycle_end_0; } PHALCON_GET_FOREACH_VALUE(field); PHALCON_INIT_NVAR(definition); array_init(definition); add_assoc_long_ex(definition, SS("bindType"), 2); /** * By checking every column type we convert it to a Phalcon\Db\Column */ PHALCON_INIT_NVAR(column_type); phalcon_array_fetch_string(&column_type, field, SL("type"), PH_NOISY_CC); if (phalcon_memnstr_str(column_type, SL("int") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 0, PH_SEPARATE TSRMLS_CC); phalcon_array_update_string_bool(&definition, SL("isNumeric"), 1, PH_SEPARATE TSRMLS_CC); phalcon_array_update_string_long(&definition, SL("bindType"), 1, PH_SEPARATE TSRMLS_CC); } else { if (phalcon_memnstr_str(column_type, SL("varchar") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 2, PH_SEPARATE TSRMLS_CC); } else { if (phalcon_memnstr_str(column_type, SL("date") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 1, PH_SEPARATE TSRMLS_CC); } else { if (phalcon_memnstr_str(column_type, SL("decimal") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 3, PH_SEPARATE TSRMLS_CC); phalcon_array_update_string_bool(&definition, SL("isNumeric"), 1, PH_SEPARATE TSRMLS_CC); phalcon_array_update_string_long(&definition, SL("bindType"), 32, PH_SEPARATE TSRMLS_CC); } else { if (phalcon_memnstr_str(column_type, SL("char") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 5, PH_SEPARATE TSRMLS_CC); } else { if (phalcon_memnstr_str(column_type, SL("datetime") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 4, PH_SEPARATE TSRMLS_CC); } else { if (phalcon_memnstr_str(column_type, SL("text") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 6, PH_SEPARATE TSRMLS_CC); } else { if (phalcon_memnstr_str(column_type, SL("float") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 7, PH_SEPARATE TSRMLS_CC); phalcon_array_update_string_bool(&definition, SL("isNumeric"), 1, PH_SEPARATE TSRMLS_CC); phalcon_array_update_string_long(&definition, SL("bindType"), 32, PH_SEPARATE TSRMLS_CC); } else { if (phalcon_memnstr_str(column_type, SL("enum") TSRMLS_CC)) { phalcon_array_update_string_long(&definition, SL("type"), 5, PH_SEPARATE TSRMLS_CC); } else { phalcon_array_update_string_long(&definition, SL("type"), 2, PH_SEPARATE TSRMLS_CC); } } } } } } } } } /** * If the column type has a parentheses we try to get the column size from it */ if (phalcon_memnstr_str(column_type, SL("(") TSRMLS_CC)) { PHALCON_INIT_NVAR(matches); array_init(matches); Z_SET_ISREF_P(matches); PHALCON_INIT_NVAR(pos); PHALCON_CALL_FUNC_PARAMS_3(pos, "preg_match", size_pattern, column_type, matches); Z_UNSET_ISREF_P(matches); if (zend_is_true(pos)) { eval_int = phalcon_array_isset_long(matches, 1); if (eval_int) { PHALCON_INIT_NVAR(match_one); phalcon_array_fetch_long(&match_one, matches, 1, PH_NOISY_CC); phalcon_array_update_string(&definition, SL("size"), &match_one, PH_COPY | PH_SEPARATE TSRMLS_CC); } } } /** * Check if the column is unsigned, only MySQL support this */ if (phalcon_memnstr_str(column_type, SL("unsigned") TSRMLS_CC)) { phalcon_array_update_string_bool(&definition, SL("unsigned"), 1, PH_SEPARATE TSRMLS_CC); } if (!zend_is_true(old_column)) { phalcon_array_update_string_bool(&definition, SL("first"), 1, PH_SEPARATE TSRMLS_CC); } else { phalcon_array_update_string(&definition, SL("after"), &old_column, PH_COPY | PH_SEPARATE TSRMLS_CC); } /** * Check if the field is primary key */ PHALCON_INIT_NVAR(attribute); phalcon_array_fetch_string(&attribute, field, SL("key"), PH_NOISY_CC); if (PHALCON_COMPARE_STRING(attribute, "PRI")) { phalcon_array_update_string_bool(&definition, SL("primary"), 1, PH_SEPARATE TSRMLS_CC); } /** * Check if the column allows null values */ PHALCON_INIT_NVAR(attribute); phalcon_array_fetch_string(&attribute, field, SL("null"), PH_NOISY_CC); if (PHALCON_COMPARE_STRING(attribute, "NO")) { phalcon_array_update_string_bool(&definition, SL("notNull"), 1, PH_SEPARATE TSRMLS_CC); } /** * Check if the column is auto increment */ PHALCON_INIT_NVAR(attribute); phalcon_array_fetch_string(&attribute, field, SL("extra"), PH_NOISY_CC); if (PHALCON_COMPARE_STRING(attribute, "auto_increment")) { phalcon_array_update_string_bool(&definition, SL("autoIncrement"), 1, PH_SEPARATE TSRMLS_CC); } PHALCON_INIT_NVAR(column_name); phalcon_array_fetch_string(&column_name, field, SL("field"), PH_NOISY_CC); PHALCON_INIT_NVAR(column); object_init_ex(column, phalcon_db_column_ce); PHALCON_CALL_METHOD_PARAMS_2_NORETURN(column, "__construct", column_name, definition, PH_CHECK); phalcon_array_append(&columns, column, PH_SEPARATE TSRMLS_CC); PHALCON_CPY_WRT(old_column, column_name); zend_hash_move_forward_ex(ah0, &hp0); goto ph_cycle_start_0; ph_cycle_end_0: RETURN_CTOR(columns); }
/** * 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) { HashTable *_5; HashPosition _4; zephir_fcall_cache_entry *_41 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *table_param = NULL, *schema_param = NULL, *columns = NULL, *columnType = NULL, *field = NULL, *definition = NULL, *oldColumn = NULL, *sizePattern = NULL, *matches = NULL, *matchOne = NULL, *matchTwo = NULL, *columnName = NULL, *_0 = NULL, *_1, *_2 = NULL, *_3, **_6, *_7$$5 = NULL, *_8$$5 = NULL, *_9$$6 = NULL, *_10$$6 = NULL, *_11$$7 = NULL, *_12$$8 = NULL, *_13$$9 = NULL, *_14$$10 = NULL, *_15$$11 = NULL, *_16$$12 = NULL, *_17$$13 = NULL, *_18$$14 = NULL, *_19$$14 = NULL, *_20$$15 = NULL, *_21$$15 = NULL, *_22$$16 = NULL, *_23$$16 = NULL, *_24$$17 = NULL, *_25$$17 = NULL, *_26$$18 = NULL, *_27$$18 = NULL, *_28$$19 = NULL, *_29$$20 = NULL, *_30$$21 = NULL, *_31$$4 = NULL, *_32$$22 = NULL, *_33$$24 = NULL, *_34$$25 = NULL, *_35$$3, *_36$$3, *_37$$3, *_38$$3 = NULL, *_40$$3 = NULL, *_39$$32; 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", 345); 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", 119 TSRMLS_CC); while (1) { if (zephir_memnstr_str(columnType, SL("bigint"), "phalcon/db/adapter/pdo/mysql.zep", 126)) { ZEPHIR_INIT_NVAR(_7$$5); ZVAL_LONG(_7$$5, 14); zephir_array_update_string(&definition, SL("type"), &_7$$5, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8$$5); ZVAL_LONG(_8$$5, 1); zephir_array_update_string(&definition, SL("bindType"), &_8$$5, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("int"), "phalcon/db/adapter/pdo/mysql.zep", 136)) { ZEPHIR_INIT_NVAR(_9$$6); ZVAL_LONG(_9$$6, 0); zephir_array_update_string(&definition, SL("type"), &_9$$6, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_10$$6); ZVAL_LONG(_10$$6, 1); zephir_array_update_string(&definition, SL("bindType"), &_10$$6, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("varchar"), "phalcon/db/adapter/pdo/mysql.zep", 146)) { ZEPHIR_INIT_NVAR(_11$$7); ZVAL_LONG(_11$$7, 2); zephir_array_update_string(&definition, SL("type"), &_11$$7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("datetime"), "phalcon/db/adapter/pdo/mysql.zep", 154)) { ZEPHIR_INIT_NVAR(_12$$8); ZVAL_LONG(_12$$8, 4); zephir_array_update_string(&definition, SL("type"), &_12$$8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("enum"), "phalcon/db/adapter/pdo/mysql.zep", 162)) { ZEPHIR_INIT_NVAR(_13$$9); ZVAL_LONG(_13$$9, 5); zephir_array_update_string(&definition, SL("type"), &_13$$9, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("char"), "phalcon/db/adapter/pdo/mysql.zep", 170)) { ZEPHIR_INIT_NVAR(_14$$10); ZVAL_LONG(_14$$10, 5); zephir_array_update_string(&definition, SL("type"), &_14$$10, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("date"), "phalcon/db/adapter/pdo/mysql.zep", 178)) { ZEPHIR_INIT_NVAR(_15$$11); ZVAL_LONG(_15$$11, 1); zephir_array_update_string(&definition, SL("type"), &_15$$11, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("timestamp"), "phalcon/db/adapter/pdo/mysql.zep", 186)) { ZEPHIR_INIT_NVAR(_16$$12); ZVAL_LONG(_16$$12, 17); zephir_array_update_string(&definition, SL("type"), &_16$$12, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("text"), "phalcon/db/adapter/pdo/mysql.zep", 194)) { ZEPHIR_INIT_NVAR(_17$$13); ZVAL_LONG(_17$$13, 6); zephir_array_update_string(&definition, SL("type"), &_17$$13, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("decimal"), "phalcon/db/adapter/pdo/mysql.zep", 202)) { ZEPHIR_INIT_NVAR(_18$$14); ZVAL_LONG(_18$$14, 3); zephir_array_update_string(&definition, SL("type"), &_18$$14, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_19$$14); ZVAL_LONG(_19$$14, 32); zephir_array_update_string(&definition, SL("bindType"), &_19$$14, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("double"), "phalcon/db/adapter/pdo/mysql.zep", 212)) { ZEPHIR_INIT_NVAR(_20$$15); ZVAL_LONG(_20$$15, 9); zephir_array_update_string(&definition, SL("type"), &_20$$15, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_21$$15); ZVAL_LONG(_21$$15, 32); zephir_array_update_string(&definition, SL("bindType"), &_21$$15, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("float"), "phalcon/db/adapter/pdo/mysql.zep", 222)) { ZEPHIR_INIT_NVAR(_22$$16); ZVAL_LONG(_22$$16, 7); zephir_array_update_string(&definition, SL("type"), &_22$$16, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_23$$16); ZVAL_LONG(_23$$16, 32); zephir_array_update_string(&definition, SL("bindType"), &_23$$16, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("bit"), "phalcon/db/adapter/pdo/mysql.zep", 232)) { ZEPHIR_INIT_NVAR(_24$$17); ZVAL_LONG(_24$$17, 8); zephir_array_update_string(&definition, SL("type"), &_24$$17, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_25$$17); ZVAL_LONG(_25$$17, 5); zephir_array_update_string(&definition, SL("bindType"), &_25$$17, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("tinyblob"), "phalcon/db/adapter/pdo/mysql.zep", 241)) { ZEPHIR_INIT_NVAR(_26$$18); ZVAL_LONG(_26$$18, 10); zephir_array_update_string(&definition, SL("type"), &_26$$18, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_27$$18); ZVAL_LONG(_27$$18, 5); zephir_array_update_string(&definition, SL("bindType"), &_27$$18, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("mediumblob"), "phalcon/db/adapter/pdo/mysql.zep", 250)) { ZEPHIR_INIT_NVAR(_28$$19); ZVAL_LONG(_28$$19, 12); zephir_array_update_string(&definition, SL("type"), &_28$$19, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("longblob"), "phalcon/db/adapter/pdo/mysql.zep", 258)) { ZEPHIR_INIT_NVAR(_29$$20); ZVAL_LONG(_29$$20, 13); zephir_array_update_string(&definition, SL("type"), &_29$$20, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("blob"), "phalcon/db/adapter/pdo/mysql.zep", 266)) { ZEPHIR_INIT_NVAR(_30$$21); ZVAL_LONG(_30$$21, 11); zephir_array_update_string(&definition, SL("type"), &_30$$21, PH_COPY | PH_SEPARATE); break; } ZEPHIR_INIT_NVAR(_31$$4); ZVAL_LONG(_31$$4, 2); zephir_array_update_string(&definition, SL("type"), &_31$$4, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("("), "phalcon/db/adapter/pdo/mysql.zep", 281)) { ZEPHIR_INIT_NVAR(matches); ZVAL_NULL(matches); ZEPHIR_INIT_NVAR(_32$$22); zephir_preg_match(_32$$22, sizePattern, columnType, matches, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(_32$$22)) { ZEPHIR_OBS_NVAR(matchOne); if (zephir_array_isset_long_fetch(&matchOne, matches, 1, 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_33$$24); ZVAL_LONG(_33$$24, zephir_get_intval(matchOne)); zephir_array_update_string(&definition, SL("size"), &_33$$24, PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_NVAR(matchTwo); if (zephir_array_isset_long_fetch(&matchTwo, matches, 2, 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_34$$25); ZVAL_LONG(_34$$25, zephir_get_intval(matchTwo)); zephir_array_update_string(&definition, SL("scale"), &_34$$25, PH_COPY | PH_SEPARATE); } } } if (zephir_memnstr_str(columnType, SL("unsigned"), "phalcon/db/adapter/pdo/mysql.zep", 296)) { 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(&_35$$3, field, 3, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 312 TSRMLS_CC); if (ZEPHIR_IS_STRING(_35$$3, "PRI")) { zephir_array_update_string(&definition, SL("primary"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_36$$3, field, 2, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 319 TSRMLS_CC); if (ZEPHIR_IS_STRING(_36$$3, "NO")) { zephir_array_update_string(&definition, SL("notNull"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_37$$3, field, 5, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 326 TSRMLS_CC); if (ZEPHIR_IS_STRING(_37$$3, "auto_increment")) { zephir_array_update_string(&definition, SL("autoIncrement"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_NVAR(_38$$3); zephir_array_fetch_long(&_38$$3, field, 4, PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 333 TSRMLS_CC); if (Z_TYPE_P(_38$$3) != IS_NULL) { zephir_array_fetch_long(&_39$$32, field, 4, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 334 TSRMLS_CC); zephir_array_update_string(&definition, SL("default"), &_39$$32, PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&columnName, field, 0, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 340 TSRMLS_CC); ZEPHIR_INIT_NVAR(_40$$3); object_init_ex(_40$$3, phalcon_db_column_ce); ZEPHIR_CALL_METHOD(NULL, _40$$3, "__construct", &_41, 142, columnName, definition); zephir_check_call_status(); zephir_array_append(&columns, _40$$3, PH_SEPARATE, "phalcon/db/adapter/pdo/mysql.zep", 341); ZEPHIR_CPY_WRT(oldColumn, columnName); } RETURN_CCTOR(columns); }
/** * 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, 54, 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, 233, _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, 54, 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, 54, 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, 304, _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, 304, _33); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_34, "floatval", &_29, 304, 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, 54, 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, 230, &_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, 231, tmp, _28); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(NULL, "finfo_close", NULL, 232, 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, 54, 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, 241, _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, 54, 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, 54, 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); }
/** * 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 *validation, validation_sub, *field, field_sub, *_SERVER, *_POST, *_FILES, value, message, label, replacePairs, types, byteUnits, unit, maxSize, matches, bytes, mime, tmp, width, height, minResolution, maxResolution, minWidth, maxWidth, minHeight, maxHeight, fieldTypes, code, minResolutionArray, maxResolutionArray, _0, _4, _7, _13, _15, _16, _25, _26, _42, _49, _51, _8$$3, _9$$3, _10$$3, _17$$4, _18$$4, _19$$4, _22$$5, _23$$5, _24$$5, _27$$6, _29$$6, _30$$6, _31$$6, _32$$6, _33$$6, _34$$6, _35$$6, _36$$6, _37$$6, _38$$6, _28$$7, _39$$9, _40$$9, _41$$9, _43$$10, _44$$13, _45$$13, _46$$15, _47$$15, _48$$15, _52$$16, _53$$16, _54$$16, _61$$16, _55$$17, _56$$18, _58$$20, _59$$20, _60$$20, _62$$21, _63$$22, _65$$23, _66$$23, _67$$23; zval *this_ptr = getThis(); ZVAL_UNDEF(&validation_sub); ZVAL_UNDEF(&field_sub); ZVAL_UNDEF(&value); ZVAL_UNDEF(&message); ZVAL_UNDEF(&label); ZVAL_UNDEF(&replacePairs); ZVAL_UNDEF(&types); ZVAL_UNDEF(&byteUnits); ZVAL_UNDEF(&unit); ZVAL_UNDEF(&maxSize); ZVAL_UNDEF(&matches); ZVAL_UNDEF(&bytes); ZVAL_UNDEF(&mime); ZVAL_UNDEF(&tmp); ZVAL_UNDEF(&width); ZVAL_UNDEF(&height); ZVAL_UNDEF(&minResolution); ZVAL_UNDEF(&maxResolution); ZVAL_UNDEF(&minWidth); ZVAL_UNDEF(&maxWidth); ZVAL_UNDEF(&minHeight); ZVAL_UNDEF(&maxHeight); ZVAL_UNDEF(&fieldTypes); ZVAL_UNDEF(&code); ZVAL_UNDEF(&minResolutionArray); ZVAL_UNDEF(&maxResolutionArray); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_7); ZVAL_UNDEF(&_13); ZVAL_UNDEF(&_15); ZVAL_UNDEF(&_16); ZVAL_UNDEF(&_25); ZVAL_UNDEF(&_26); ZVAL_UNDEF(&_42); ZVAL_UNDEF(&_49); ZVAL_UNDEF(&_51); ZVAL_UNDEF(&_8$$3); ZVAL_UNDEF(&_9$$3); ZVAL_UNDEF(&_10$$3); ZVAL_UNDEF(&_17$$4); ZVAL_UNDEF(&_18$$4); ZVAL_UNDEF(&_19$$4); ZVAL_UNDEF(&_22$$5); ZVAL_UNDEF(&_23$$5); ZVAL_UNDEF(&_24$$5); ZVAL_UNDEF(&_27$$6); ZVAL_UNDEF(&_29$$6); ZVAL_UNDEF(&_30$$6); ZVAL_UNDEF(&_31$$6); ZVAL_UNDEF(&_32$$6); ZVAL_UNDEF(&_33$$6); ZVAL_UNDEF(&_34$$6); ZVAL_UNDEF(&_35$$6); ZVAL_UNDEF(&_36$$6); ZVAL_UNDEF(&_37$$6); ZVAL_UNDEF(&_38$$6); ZVAL_UNDEF(&_28$$7); ZVAL_UNDEF(&_39$$9); ZVAL_UNDEF(&_40$$9); ZVAL_UNDEF(&_41$$9); ZVAL_UNDEF(&_43$$10); ZVAL_UNDEF(&_44$$13); ZVAL_UNDEF(&_45$$13); ZVAL_UNDEF(&_46$$15); ZVAL_UNDEF(&_47$$15); ZVAL_UNDEF(&_48$$15); ZVAL_UNDEF(&_52$$16); ZVAL_UNDEF(&_53$$16); ZVAL_UNDEF(&_54$$16); ZVAL_UNDEF(&_61$$16); ZVAL_UNDEF(&_55$$17); ZVAL_UNDEF(&_56$$18); ZVAL_UNDEF(&_58$$20); ZVAL_UNDEF(&_59$$20); ZVAL_UNDEF(&_60$$20); ZVAL_UNDEF(&_62$$21); ZVAL_UNDEF(&_63$$22); ZVAL_UNDEF(&_65$$23); ZVAL_UNDEF(&_66$$23); ZVAL_UNDEF(&_67$$23); ZEPHIR_MM_GROW(); zephir_get_global(&_FILES, SL("_FILES")); zephir_get_global(&_POST, SL("_POST")); zephir_get_global(&_SERVER, SL("_SERVER")); zephir_fetch_params(1, 2, 0, &validation, &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", 103 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", 103 TSRMLS_CC); _3 = ZEPHIR_GT_LONG(&_4, 0); } _5 = _3; if (!(_5)) { _6 = zephir_array_isset_string(&value, SL("error")); if (_6) { zephir_array_fetch_string(&_7, &value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 103 TSRMLS_CC); _6 = ZEPHIR_IS_LONG_IDENTICAL(&_7, 1); } _5 = _6; } if (_5) { ZEPHIR_INIT_VAR(&_8$$3); ZVAL_STRING(&_8$$3, "FileIniSize"); ZEPHIR_INIT_VAR(&_9$$3); ZVAL_STRING(&_9$$3, "messageIniSize"); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, &_8$$3, &_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_messages_message_ce); ZEPHIR_CALL_FUNCTION(&_10$$3, "strtr", NULL, 50, &message, &replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_9$$3); ZVAL_STRING(&_9$$3, "FileIniSize"); ZEPHIR_CALL_METHOD(NULL, &_8$$3, "__construct", NULL, 295, &_10$$3, field, &_9$$3, &code); 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, SL("error"))); if (!(_11)) { _11 = !(zephir_array_isset_string(&value, SL("tmp_name"))); } _12 = _11; if (!(_12)) { zephir_array_fetch_string(&_13, &value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 119 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", 119 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_16, "is_uploaded_file", NULL, 228, &_15); zephir_check_call_status(); _14 = !zephir_is_true(&_16); } if (_14) { ZEPHIR_INIT_VAR(&_17$$4); ZVAL_STRING(&_17$$4, "FileEmpty"); ZEPHIR_INIT_VAR(&_18$$4); ZVAL_STRING(&_18$$4, "messageEmpty"); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, &_17$$4, &_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_messages_message_ce); ZEPHIR_CALL_FUNCTION(&_19$$4, "strtr", NULL, 50, &message, &replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_18$$4); ZVAL_STRING(&_18$$4, "FileEmpty"); ZEPHIR_CALL_METHOD(NULL, &_17$$4, "__construct", NULL, 295, &_19$$4, field, &_18$$4, &code); 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, SL("name"))); if (!(_20)) { _20 = !(zephir_array_isset_string(&value, SL("type"))); } _21 = _20; if (!(_21)) { _21 = !(zephir_array_isset_string(&value, SL("size"))); } if (_21) { ZEPHIR_INIT_VAR(&_22$$5); ZVAL_STRING(&_22$$5, "FileValid"); ZEPHIR_INIT_VAR(&_23$$5); ZVAL_STRING(&_23$$5, "messageValid"); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, &_22$$5, &_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_messages_message_ce); ZEPHIR_CALL_FUNCTION(&_24$$5, "strtr", NULL, 50, &message, &replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_23$$5); ZVAL_STRING(&_23$$5, "FileValid"); ZEPHIR_CALL_METHOD(NULL, &_22$$5, "__construct", NULL, 295, &_24$$5, field, &_23$$5, &code); 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_CALL_METHOD(&_25, this_ptr, "hasoption", NULL, 0, &_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, SL("B"), 0); add_assoc_long_ex(&byteUnits, SL("K"), 10); add_assoc_long_ex(&byteUnits, SL("M"), 20); add_assoc_long_ex(&byteUnits, SL("G"), 30); add_assoc_long_ex(&byteUnits, SL("T"), 40); add_assoc_long_ex(&byteUnits, SL("KB"), 10); add_assoc_long_ex(&byteUnits, SL("MB"), 20); add_assoc_long_ex(&byteUnits, SL("GB"), 30); add_assoc_long_ex(&byteUnits, SL("TB"), 40); ZEPHIR_INIT_VAR(&_27$$6); ZVAL_STRING(&_27$$6, "maxSize"); ZEPHIR_CALL_METHOD(&maxSize, this_ptr, "getoption", NULL, 0, &_27$$6); zephir_check_call_status(); ZEPHIR_INIT_VAR(&matches); ZVAL_NULL(&matches); ZEPHIR_INIT_VAR(&unit); ZVAL_STRING(&unit, "B"); if (Z_TYPE_P(&maxSize) == IS_ARRAY) { zephir_array_fetch(&_28$$7, &maxSize, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 159 TSRMLS_CC); ZEPHIR_CPY_WRT(&maxSize, &_28$$7); } ZEPHIR_INIT_NVAR(&_27$$6); ZEPHIR_INIT_VAR(&_29$$6); zephir_array_keys(&_29$$6, &byteUnits TSRMLS_CC); zephir_fast_join_str(&_27$$6, SL("|"), &_29$$6 TSRMLS_CC); ZEPHIR_INIT_VAR(&_30$$6); ZEPHIR_CONCAT_SVS(&_30$$6, "/^([0-9]+(?:\\.[0-9]+)?)(", &_27$$6, ")?$/Di"); ZEPHIR_INIT_VAR(&_31$$6); zephir_preg_match(&_31$$6, &_30$$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", 165 TSRMLS_CC); } zephir_array_fetch_long(&_32$$6, &matches, 1, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 168 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_33$$6, "floatval", NULL, 319, &_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", 168 TSRMLS_CC); 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", 170 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_33$$6, "floatval", NULL, 319, &_37$$6); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_38$$6, "floatval", NULL, 319, &bytes); zephir_check_call_status(); if (ZEPHIR_GT(&_33$$6, &_38$$6)) { ZEPHIR_INIT_VAR(&_39$$9); ZVAL_STRING(&_39$$9, "FileSize"); ZEPHIR_INIT_VAR(&_40$$9); ZVAL_STRING(&_40$$9, "messageSize"); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, &_39$$9, &_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_messages_message_ce); ZEPHIR_CALL_FUNCTION(&_41$$9, "strtr", NULL, 50, &message, &replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_40$$9); ZVAL_STRING(&_40$$9, "FileSize"); ZEPHIR_CALL_METHOD(NULL, &_39$$9, "__construct", NULL, 295, &_41$$9, field, &_40$$9, &code); 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_CALL_METHOD(&_42, this_ptr, "hasoption", NULL, 0, &_26); zephir_check_call_status(); if (zephir_is_true(&_42)) { ZEPHIR_INIT_VAR(&_43$$10); ZVAL_STRING(&_43$$10, "allowedTypes"); ZEPHIR_CALL_METHOD(&types, this_ptr, "getoption", NULL, 0, &_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", 196); return; } if ((zephir_function_exists_ex(SL("finfo_open") TSRMLS_CC) == SUCCESS)) { ZVAL_LONG(&_44$$13, 16); ZEPHIR_CALL_FUNCTION(&tmp, "finfo_open", NULL, 225, &_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", 201 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&mime, "finfo_file", NULL, 226, &tmp, &_45$$13); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(NULL, "finfo_close", NULL, 227, &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", 205 TSRMLS_CC); } if (!(zephir_fast_in_array(&mime, &types TSRMLS_CC))) { ZEPHIR_INIT_VAR(&_46$$15); ZVAL_STRING(&_46$$15, "FileType"); ZEPHIR_INIT_VAR(&_47$$15); ZVAL_STRING(&_47$$15, "messageType"); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, &_46$$15, &_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_messages_message_ce); ZEPHIR_CALL_FUNCTION(&_48$$15, "strtr", NULL, 50, &message, &replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_47$$15); ZVAL_STRING(&_47$$15, "FileType"); ZEPHIR_CALL_METHOD(NULL, &_46$$15, "__construct", NULL, 295, &_48$$15, field, &_47$$15, &code); 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_CALL_METHOD(&_49, this_ptr, "hasoption", NULL, 0, &_26); zephir_check_call_status(); _50 = zephir_is_true(&_49); if (!(_50)) { ZEPHIR_INIT_NVAR(&_26); ZVAL_STRING(&_26, "maxResolution"); ZEPHIR_CALL_METHOD(&_51, this_ptr, "hasoption", NULL, 0, &_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", 226 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&tmp, "getimagesize", NULL, 237, &_52$$16); zephir_check_call_status(); ZEPHIR_OBS_VAR(&width); zephir_array_fetch_long(&width, &tmp, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 227 TSRMLS_CC); ZEPHIR_OBS_VAR(&height); zephir_array_fetch_long(&height, &tmp, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 228 TSRMLS_CC); ZEPHIR_INIT_VAR(&_54$$16); ZVAL_STRING(&_54$$16, "minResolution"); ZEPHIR_CALL_METHOD(&_53$$16, this_ptr, "hasoption", NULL, 0, &_54$$16); zephir_check_call_status(); if (zephir_is_true(&_53$$16)) { ZEPHIR_INIT_VAR(&_55$$17); ZVAL_STRING(&_55$$17, "minResolution"); ZEPHIR_CALL_METHOD(&minResolution, this_ptr, "getoption", NULL, 0, &_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", 233 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", 236 TSRMLS_CC); ZEPHIR_OBS_VAR(&minHeight); zephir_array_fetch_long(&minHeight, &minResolutionArray, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 237 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_INIT_VAR(&_59$$20); ZVAL_STRING(&_59$$20, "messageMinResolution"); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, &_58$$20, &_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_messages_message_ce); ZEPHIR_CALL_FUNCTION(&_60$$20, "strtr", NULL, 50, &message, &replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_59$$20); ZVAL_STRING(&_59$$20, "FileMinResolution"); ZEPHIR_CALL_METHOD(NULL, &_58$$20, "__construct", NULL, 295, &_60$$20, field, &_59$$20, &code); 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_CALL_METHOD(&_61$$16, this_ptr, "hasoption", NULL, 0, &_54$$16); zephir_check_call_status(); if (zephir_is_true(&_61$$16)) { ZEPHIR_INIT_VAR(&_62$$21); ZVAL_STRING(&_62$$21, "maxResolution"); ZEPHIR_CALL_METHOD(&maxResolution, this_ptr, "getoption", NULL, 0, &_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", 263 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", 266 TSRMLS_CC); ZEPHIR_OBS_VAR(&maxHeight); zephir_array_fetch_long(&maxHeight, &maxResolutionArray, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 267 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_INIT_VAR(&_66$$23); ZVAL_STRING(&_66$$23, "messageMaxResolution"); ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, &_65$$23, &_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_messages_message_ce); ZEPHIR_CALL_FUNCTION(&_67$$23, "strtr", NULL, 50, &message, &replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_66$$23); ZVAL_STRING(&_66$$23, "FileMaxResolution"); ZEPHIR_CALL_METHOD(NULL, &_65$$23, "__construct", NULL, 295, &_67$$23, field, &_66$$23, &code); 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); }
/** * Internal sanitize wrapper to filter_var */ PHP_METHOD(Phalcon_Filter, _sanitize) { zval *_2$$4, *_9$$10; zend_bool _1$$3; zephir_fcall_cache_entry *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *filter = NULL, *_14$$19; zval *value, *filter_param = NULL, *filterObject = NULL, *_0, _3$$5, *_4$$5 = NULL, _6$$6, _7$$8, _8$$9, _10$$10, *_11$$12, *_12$$12, *_13$$19; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &value, &filter_param); if (unlikely(Z_TYPE_P(filter_param) != IS_STRING && Z_TYPE_P(filter_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'filter' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(filter_param) == IS_STRING)) { zephir_get_strval(filter, filter_param); } else { ZEPHIR_INIT_VAR(filter); ZVAL_EMPTY_STRING(filter); } ZEPHIR_OBS_VAR(filterObject); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_filters"), PH_NOISY_CC); if (zephir_array_isset_fetch(&filterObject, _0, filter, 0 TSRMLS_CC)) { _1$$3 = zephir_instance_of_ev(filterObject, zend_ce_closure TSRMLS_CC); if (!(_1$$3)) { _1$$3 = zephir_is_callable(filterObject TSRMLS_CC); } if (_1$$3) { ZEPHIR_INIT_VAR(_2$$4); zephir_create_array(_2$$4, 1, 0 TSRMLS_CC); zephir_array_fast_append(_2$$4, value); ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, filterObject, _2$$4); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_RETURN_CALL_METHOD(filterObject, "filter", NULL, 0, value); zephir_check_call_status(); RETURN_MM(); } do { if (ZEPHIR_IS_STRING(filter, "email")) { ZEPHIR_SINIT_VAR(_3$$5); ZVAL_STRING(&_3$$5, "FILTER_SANITIZE_EMAIL", 0); ZEPHIR_CALL_FUNCTION(&_4$$5, "constant", NULL, 187, &_3$$5); zephir_check_call_status(); ZEPHIR_RETURN_CALL_FUNCTION("filter_var", &_5, 188, value, _4$$5); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(filter, "int")) { ZEPHIR_SINIT_VAR(_6$$6); ZVAL_LONG(&_6$$6, 519); ZEPHIR_RETURN_CALL_FUNCTION("filter_var", &_5, 188, value, &_6$$6); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(filter, "int!")) { RETURN_MM_LONG(zephir_get_intval(value)); } if (ZEPHIR_IS_STRING(filter, "absint")) { ZEPHIR_SINIT_VAR(_7$$8); ZVAL_LONG(&_7$$8, zephir_get_intval(value)); ZEPHIR_RETURN_CALL_FUNCTION("abs", NULL, 189, &_7$$8); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(filter, "string")) { ZEPHIR_SINIT_VAR(_8$$9); ZVAL_LONG(&_8$$9, 513); ZEPHIR_RETURN_CALL_FUNCTION("filter_var", &_5, 188, value, &_8$$9); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(filter, "float")) { ZEPHIR_INIT_VAR(_9$$10); zephir_create_array(_9$$10, 1, 0 TSRMLS_CC); add_assoc_long_ex(_9$$10, SS("flags"), 4096); ZEPHIR_SINIT_VAR(_10$$10); ZVAL_LONG(&_10$$10, 520); ZEPHIR_RETURN_CALL_FUNCTION("filter_var", &_5, 188, value, &_10$$10, _9$$10); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(filter, "float!")) { RETURN_MM_DOUBLE(zephir_get_doubleval(value)); } if (ZEPHIR_IS_STRING(filter, "alphanum")) { ZEPHIR_INIT_VAR(_11$$12); ZVAL_STRING(_11$$12, "/[^A-Za-z0-9]/", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_12$$12); ZVAL_STRING(_12$$12, "", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_FUNCTION("preg_replace", NULL, 29, _11$$12, _12$$12, value); zephir_check_temp_parameter(_11$$12); zephir_check_temp_parameter(_12$$12); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(filter, "trim")) { zephir_fast_trim(return_value, value, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); RETURN_MM(); } if (ZEPHIR_IS_STRING(filter, "striptags")) { ZEPHIR_RETURN_CALL_FUNCTION("strip_tags", NULL, 190, value); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(filter, "lower")) { if ((zephir_function_exists_ex(SS("mb_strtolower") TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_FUNCTION("mb_strtolower", NULL, 191, value); zephir_check_call_status(); RETURN_MM(); } zephir_fast_strtolower(return_value, value); RETURN_MM(); } if (ZEPHIR_IS_STRING(filter, "upper")) { if ((zephir_function_exists_ex(SS("mb_strtoupper") TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_FUNCTION("mb_strtoupper", NULL, 192, value); zephir_check_call_status(); RETURN_MM(); } zephir_fast_strtoupper(return_value, value); RETURN_MM(); } ZEPHIR_INIT_VAR(_13$$19); object_init_ex(_13$$19, phalcon_filter_exception_ce); ZEPHIR_INIT_VAR(_14$$19); ZEPHIR_CONCAT_SVS(_14$$19, "Sanitize filter '", filter, "' is not supported"); ZEPHIR_CALL_METHOD(NULL, _13$$19, "__construct", NULL, 9, _14$$19); zephir_check_call_status(); zephir_throw_exception_debug(_13$$19, "phalcon/filter.zep", 213 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } while(0); ZEPHIR_MM_RESTORE(); }
PHP_METHOD(Phalcon_Test, nice){ zval *v0 = NULL, *v1 = NULL, *v2 = NULL, *v3 = NULL; zval *a0 = NULL; zval *r0 = NULL, *r1 = NULL; zval *t0 = NULL; HashTable *ah0; HashPosition hp0; zval **hd; char *index; uint index_len; ulong num; int htype; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &v0) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_INIT_VAR(a0); array_init(a0); add_assoc_long_ex(a0, "hello1", strlen("hello1")+1, 1); add_assoc_long_ex(a0, "hello2", strlen("hello2")+1, 2); add_assoc_long_ex(a0, "hello3", strlen("hello3")+1, 3); PHALCON_CPY_WRT(v1, a0); if (Z_TYPE_P(v1) != IS_ARRAY) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid argument supplied for foreach()"); } else { ALLOC_HASHTABLE(ah0); zend_hash_init(ah0, 0, NULL, NULL, 0); zend_hash_copy(ah0, Z_ARRVAL_P(v1), NULL, NULL, sizeof(zval*)); zend_hash_internal_pointer_reset_ex(ah0, &hp0); fes_2ebb_0: if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){ goto fee_2ebb_0; } else { PHALCON_INIT_VAR(v3); htype = zend_hash_get_current_key_ex(ah0, &index, &index_len, &num, 0, &hp0); if (htype == HASH_KEY_IS_STRING) { ZVAL_STRINGL(v3, index, index_len-1, 1); } else { if (htype == HASH_KEY_IS_LONG) { ZVAL_LONG(v3, num); } } } PHALCON_INIT_VAR(v2); ZVAL_ZVAL(v2, *hd, 1, 0); PHALCON_INIT_VAR(r0); phalcon_array_fetch(&r0, v1, v3, PHALCON_NOISY_FETCH TSRMLS_CC); PHALCON_INIT_VAR(t0); ZVAL_LONG(t0, 100); PHALCON_INIT_VAR(r1); phalcon_add_function(r1, r0, t0 TSRMLS_CC); Z_ADDREF_P(r1); if (Z_REFCOUNT_P(v1) > 1) { zval *new_zv; Z_DELREF_P(v1); ALLOC_ZVAL(new_zv); INIT_PZVAL_COPY(new_zv, v1); v1 = new_zv; zval_copy_ctor(new_zv); } phalcon_array_update(v1, v3, r1 TSRMLS_CC); zend_hash_move_forward_ex(ah0, &hp0); goto fes_2ebb_0; fee_2ebb_0: zend_hash_destroy(ah0); efree(ah0); } PHALCON_CALL_FUNC_PARAMS_1_NORETURN("print_r", v1, 0x015); PHALCON_MM_RESTORE(); RETURN_NULL(); }
/** * Returns an array of Phalcon\Db\Column objects describing a table * * <code>print_r($connection->describeColumns("posts")); ?></code> * * @param string $table * @param string $schema * @return Phalcon\Db\Column[] */ PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, describeColumns){ zval *table, *schema = NULL, *columns, *dialect, *sql = NULL, *fetch_num; zval *describe = NULL, *old_column = NULL, *field = NULL, *definition = NULL; zval *char_size = NULL, *numeric_size = NULL, *numeric_scale = NULL, *column_type = NULL; zval *attribute = NULL, *column_name = NULL, *column = NULL; HashTable *ah0; HashPosition hp0; zval **hd; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 1, &table, &schema); if (!schema || !zend_is_true(schema)) { schema = phalcon_fetch_nproperty_this(this_ptr, SL("_schema"), PH_NOISY TSRMLS_CC); } PHALCON_INIT_VAR(columns); array_init(columns); PHALCON_OBS_VAR(dialect); phalcon_read_property_this(&dialect, this_ptr, SL("_dialect"), PH_NOISY TSRMLS_CC); PHALCON_CALL_METHOD(&sql, dialect, "describecolumns", table, schema); /** * We're using FETCH_NUM to fetch the columns */ PHALCON_INIT_VAR(fetch_num); ZVAL_LONG(fetch_num, PDO_FETCH_NUM); PHALCON_CALL_METHOD(&describe, this_ptr, "fetchall", sql, fetch_num); /** * 0:name, 1:type, 2:size, 3:numeric size, 4:numeric scale, 5: null, 6: key, 7: extra, 8: position, 9: element type */ PHALCON_INIT_VAR(old_column); phalcon_is_iterable(describe, &ah0, &hp0, 0, 0); while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) { PHALCON_GET_HVALUE(field); PHALCON_INIT_NVAR(definition); array_init_size(definition, 1); add_assoc_long_ex(definition, SS("bindType"), 2); PHALCON_OBS_NVAR(char_size); phalcon_array_fetch_long(&char_size, field, 2, PH_NOISY); if (Z_TYPE_P(char_size) != IS_NULL) { convert_to_long(char_size); } PHALCON_OBS_NVAR(numeric_size); phalcon_array_fetch_long(&numeric_size, field, 3, PH_NOISY); if (phalcon_is_numeric(numeric_size)) { convert_to_long(numeric_size); } PHALCON_OBS_NVAR(numeric_scale); phalcon_array_fetch_long(&numeric_scale, field, 4, PH_NOISY); if (phalcon_is_numeric(numeric_scale)) { convert_to_long(numeric_scale); } PHALCON_OBS_NVAR(column_type); phalcon_array_fetch_long(&column_type, field, 1, PH_NOISY); /** * Check the column type to get the correct Phalcon type */ while (1) { /** * Tinyint(1) is boolean */ if (phalcon_memnstr_str(column_type, SL("smallint(1)"))) { phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_BOOLEAN, PH_COPY); phalcon_array_update_string_long(&definition, SL("bindType"), 5, PH_COPY); break; } /** * Smallint/Bigint/Integers/Int are int */ if (phalcon_memnstr_str(column_type, SL("int"))) { phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_INTEGER, PH_COPY); phalcon_array_update_string_bool(&definition, SL("isNumeric"), 1, PH_COPY); phalcon_array_update_string(&definition, SL("size"), numeric_size, PH_COPY); phalcon_array_update_string_long(&definition, SL("bindType"), 1, PH_COPY); break; } /** * Varchar */ if (phalcon_memnstr_str(column_type, SL("varying"))) { phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_VARCHAR, PH_COPY); phalcon_array_update_string(&definition, SL("size"), char_size, PH_COPY); break; } /** * Special type for datetime */ if (phalcon_memnstr_str(column_type, SL("date"))) { phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_DATE, PH_COPY); phalcon_array_update_string_long(&definition, SL("size"), 0, PH_COPY); break; } /** * Numeric */ if (phalcon_memnstr_str(column_type, SL("numeric"))) { phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_DECIMAL, PH_COPY); phalcon_array_update_string_bool(&definition, SL("isNumeric"), 1, PH_COPY); if (phalcon_is_numeric(numeric_size)) { phalcon_array_update_string(&definition, SL("size"), numeric_size, PH_COPY); phalcon_array_update_string_long(&definition, SL("bytes"), Z_LVAL_P(numeric_size) * 8, PH_COPY); } else { phalcon_array_update_string_long(&definition, SL("size"), 30, PH_COPY); phalcon_array_update_string_long(&definition, SL("bytes"), 80, PH_COPY); } if (phalcon_is_numeric(numeric_scale)) { phalcon_array_update_string(&definition, SL("scale"), numeric_scale, PH_COPY); } else { phalcon_array_update_string_long(&definition, SL("scale"), 6, PH_COPY); } phalcon_array_update_string_long(&definition, SL("bindType"), 32, PH_COPY); break; } /** * Chars are chars */ if (phalcon_memnstr_str(column_type, SL("char"))) { phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_CHAR, PH_COPY); phalcon_array_update_string(&definition, SL("size"), char_size, PH_COPY); break; } /** * Date */ if (phalcon_memnstr_str(column_type, SL("timestamp"))) { phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_DATETIME, PH_COPY); phalcon_array_update_string_long(&definition, SL("size"), 0, PH_COPY); break; } /** * Text are varchars */ if (phalcon_memnstr_str(column_type, SL("text"))) { phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_TEXT, PH_COPY); phalcon_array_update_string(&definition, SL("size"), char_size, PH_COPY); break; } /** * Float/Smallfloats/Decimals are float */ if (phalcon_memnstr_str(column_type, SL("float"))) { phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_FLOAT, PH_COPY); phalcon_array_update_string_bool(&definition, SL("isNumeric"), 1, PH_COPY); phalcon_array_update_string(&definition, SL("size"), numeric_size, PH_COPY); phalcon_array_update_string_long(&definition, SL("bindType"), 32, PH_COPY); break; } /** * Boolean */ if (phalcon_memnstr_str(column_type, SL("bool"))) { phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_BOOLEAN, PH_COPY); phalcon_array_update_string_long(&definition, SL("size"), 0, PH_COPY); phalcon_array_update_string_long(&definition, SL("bindType"), 5, PH_COPY); break; } /** * UUID */ if (phalcon_memnstr_str(column_type, SL("uuid"))) { phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_CHAR, PH_COPY); phalcon_array_update_string_long(&definition, SL("size"), 36, PH_COPY); break; } /** * JSON */ if (phalcon_memnstr_str(column_type, SL("json"))) { phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_JSON, PH_COPY); phalcon_array_update_string(&definition, SL("size"), char_size, PH_COPY); break; } /** * ARRAY */ if (phalcon_memnstr_str(column_type, SL("ARRAY"))) { phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_ARRAY, PH_COPY); phalcon_array_update_string(&definition, SL("size"), char_size, PH_COPY); break; } /** * By default is string */ phalcon_array_update_string_long(&definition, SL("type"), PHALCON_DB_COLUMN_TYPE_OTHER, PH_COPY); break; } if (phalcon_memnstr_str(column_type, SL("unsigned"))) { phalcon_array_update_string_bool(&definition, SL("unsigned"), 1, PH_COPY); } if (Z_TYPE_P(old_column) == IS_NULL) { phalcon_array_update_string_bool(&definition, SL("first"), 1, PH_COPY); } else { phalcon_array_update_string(&definition, SL("after"), old_column, PH_COPY); } /** * Check if the field is primary key */ PHALCON_OBS_NVAR(attribute); phalcon_array_fetch_long(&attribute, field, 6, PH_NOISY); if (PHALCON_IS_STRING(attribute, "PRI")) { phalcon_array_update_string_bool(&definition, SL("primary"), 1, PH_COPY); } /** * Check if the column allows null values */ PHALCON_OBS_NVAR(attribute); phalcon_array_fetch_long(&attribute, field, 5, PH_NOISY); if (PHALCON_IS_STRING(attribute, "NO")) { phalcon_array_update_string_bool(&definition, SL("notNull"), 1, PH_COPY); } /** * Check if the column is auto increment */ PHALCON_OBS_NVAR(attribute); phalcon_array_fetch_long(&attribute, field, 7, PH_NOISY); if (PHALCON_IS_STRING(attribute, "auto_increment")) { phalcon_array_update_string_bool(&definition, SL("autoIncrement"), 1, PH_COPY); } else if (!PHALCON_IS_EMPTY(attribute)) { phalcon_array_update_string(&definition, SL("default"), attribute, PH_COPY); } PHALCON_OBS_NVAR(column_name); phalcon_array_fetch_long(&column_name, field, 0, PH_NOISY); /** * Create a Phalcon\Db\Column to abstract the column */ PHALCON_INIT_NVAR(column); object_init_ex(column, phalcon_db_column_ce); PHALCON_CALL_METHOD(NULL, column, "__construct", column_name, definition); phalcon_array_append(&columns, column, PH_COPY); PHALCON_CPY_WRT(old_column, column_name); zend_hash_move_forward_ex(ah0, &hp0); } RETURN_CTOR(columns); }
static int http_onReceive(swFactory *factory, swEventData *req) { TSRMLS_FETCH_FROM_CTX(sw_thread_ctx ? sw_thread_ctx : NULL); int fd = req->info.fd; // swTrace("on receive:%s pid:%d\n", zdata, getpid()); swConnection *conn = swServer_connection_get(SwooleG.serv, fd); if(conn->websocket_status == WEBSOCKET_STATUS_HANDSHAKE) //websocket callback { zval *zdata = php_swoole_get_data(req TSRMLS_CC); swTrace("on message callback\n"); char *buf = Z_STRVAL_P(zdata); long fin = buf[0] ? 1 : 0; long opcode = buf[1] ? 1 : 0; buf+=2; zval *zresponse; MAKE_STD_ZVAL(zresponse); object_init_ex(zresponse, swoole_http_wsresponse_class_entry_ptr); //socket fd zend_update_property_long(swoole_http_wsresponse_class_entry_ptr, zresponse, ZEND_STRL("fd"), fd TSRMLS_CC); zend_update_property_long(swoole_http_wsresponse_class_entry_ptr, zresponse, ZEND_STRL("fin"), fin TSRMLS_CC); zend_update_property_long(swoole_http_wsresponse_class_entry_ptr, zresponse, ZEND_STRL("opcode"), opcode TSRMLS_CC); zend_update_property_stringl(swoole_http_wsresponse_class_entry_ptr, zresponse, ZEND_STRL("data"), buf, (Z_STRLEN_P(zdata)-2) TSRMLS_CC); zval **args[1]; args[0] = &zresponse; zval *retval; if (call_user_function_ex(EG(function_table), NULL, php_sw_http_server_callbacks[1], &retval, 1, args, 0, NULL TSRMLS_CC) == FAILURE) { zval_ptr_dtor(&zdata); php_error_docref(NULL TSRMLS_CC, E_WARNING, "onMessage handler error"); } swTrace("===== message callback end======"); if (EG(exception)) { zval_ptr_dtor(&zdata); zend_exception_error(EG(exception), E_ERROR TSRMLS_CC); } if (retval) { zval_ptr_dtor(&retval); } zval_ptr_dtor(&zdata); return SW_OK; } http_client *client = swHashMap_find_int(php_sw_http_clients, fd); if (!client) { client = http_client_new(fd TSRMLS_CC); } php_http_parser *parser = &client->parser; /** * create request and response object */ http_request_new(client TSRMLS_CC); parser->data = client; php_http_parser_init(parser, PHP_HTTP_REQUEST); zval *zdata = php_swoole_get_data(req TSRMLS_CC); //server info zval *_request; MAKE_STD_ZVAL(_request); array_init(_request); zend_update_property(swoole_http_request_class_entry_ptr, client->zrequest, ZEND_STRL("request"), _request TSRMLS_CC); size_t n = php_http_parser_execute(parser, &http_parser_settings, Z_STRVAL_P(zdata), Z_STRLEN_P(zdata)); zval_ptr_dtor(&zdata); if (n < 0) { swWarn("php_http_parser_execute failed."); if(conn->websocket_status == WEBSOCKET_STATUS_CONNECTION) { SwooleG.serv->factory.end(&SwooleG.serv->factory, fd); } } else { if(conn->websocket_status == WEBSOCKET_STATUS_CONNECTION) // need handshake { if(php_sw_http_server_callbacks[2] == NULL) { int ret = websocket_handshake(client); http_request_free(client TSRMLS_CC); if (ret == SW_ERR) { swTrace("websocket handshake error\n"); SwooleG.serv->factory.end(&SwooleG.serv->factory, fd); } else { handshake_success(fd); swTrace("websocket handshake_success\n"); return SW_OK; } return ret; } } zval *retval; zval **args[2]; zval *zrequest = client->zrequest; //server info zval *zserver; MAKE_STD_ZVAL(zserver); array_init(zserver); zend_update_property(swoole_http_request_class_entry_ptr, zrequest, ZEND_STRL("server"), zserver TSRMLS_CC); switch (parser->method) { case PHP_HTTP_GET: add_assoc_string(zserver, "REQUEST_METHOD", "GET", 1);break; case PHP_HTTP_POST: add_assoc_string(zserver, "REQUEST_METHOD", "POST", 1);break; case PHP_HTTP_HEAD: add_assoc_string(zserver, "REQUEST_METHOD", "HEAD", 1);break; case PHP_HTTP_PUT: add_assoc_string(zserver, "REQUEST_METHOD", "PUT", 1);break; case PHP_HTTP_DELETE: add_assoc_string(zserver, "REQUEST_METHOD", "DELETE", 1);break; case PHP_HTTP_PATCH: add_assoc_string(zserver, "REQUEST_METHOD", "PATCH", 1);break; /* pathological */ case PHP_HTTP_CONNECT: add_assoc_string(zserver, "REQUEST_METHOD", "CONNECT", 1);break; case PHP_HTTP_OPTIONS: add_assoc_string(zserver, "REQUEST_METHOD", "OPTIONS", 1);break; case PHP_HTTP_TRACE: add_assoc_string(zserver, "REQUEST_METHOD", "TRACE", 1);break; /* webdav */ case PHP_HTTP_COPY: add_assoc_string(zserver, "REQUEST_METHOD", "COPY", 1);break; case PHP_HTTP_LOCK: add_assoc_string(zserver, "REQUEST_METHOD", "LOCK", 1);break; case PHP_HTTP_MKCOL: add_assoc_string(zserver, "REQUEST_METHOD", "MKCOL", 1);break; case PHP_HTTP_MOVE: add_assoc_string(zserver, "REQUEST_METHOD", "MOVE", 1);break; case PHP_HTTP_PROPFIND: add_assoc_string(zserver, "REQUEST_METHOD", "PROPFIND", 1);break; case PHP_HTTP_PROPPATCH: add_assoc_string(zserver, "REQUEST_METHOD", "PROPPATCH", 1);break; case PHP_HTTP_UNLOCK: add_assoc_string(zserver, "REQUEST_METHOD", "UNLOCK", 1);break; /* subversion */ case PHP_HTTP_REPORT: add_assoc_string(zserver, "REQUEST_METHOD", "REPORT", 1);break; case PHP_HTTP_MKACTIVITY: add_assoc_string(zserver, "REQUEST_METHOD", "MKACTIVITY", 1);break; case PHP_HTTP_CHECKOUT: add_assoc_string(zserver, "REQUEST_METHOD", "CHECKOUT", 1);break; case PHP_HTTP_MERGE: add_assoc_string(zserver, "REQUEST_METHOD", "MERGE", 1);break; /* upnp */ case PHP_HTTP_MSEARCH: add_assoc_string(zserver, "REQUEST_METHOD", "MSEARCH", 1);break; case PHP_HTTP_NOTIFY: add_assoc_string(zserver, "REQUEST_METHOD", "NOTIFY", 1);break; case PHP_HTTP_SUBSCRIBE: add_assoc_string(zserver, "REQUEST_METHOD", "SUBSCRIBE", 1);break; case PHP_HTTP_UNSUBSCRIBE: add_assoc_string(zserver, "REQUEST_METHOD", "UNSUBSCRIBE", 1);break; case PHP_HTTP_NOT_IMPLEMENTED: add_assoc_string(zserver, "REQUEST_METHOD", "GET", 1);break; } // if (parser->method == PHP_HTTP_POST) // { // add_assoc_string(zserver, "REQUEST_METHOD", "POST", 1); // } // else // { // add_assoc_string(zserver, "REQUEST_METHOD", "GET", 1); // } add_assoc_stringl(zserver, "REQUEST_URI", client->request.path, client->request.path_len, 1); add_assoc_stringl(zserver, "PATH_INFO", client->request.path, client->request.path_len, 1); add_assoc_long_ex(zserver, ZEND_STRS("REQUEST_TIME"), SwooleGS->now); swConnection *conn = swServer_connection_get(SwooleG.serv, fd); add_assoc_long(zserver, "SERVER_PORT", SwooleG.serv->connection_list[conn->from_fd].addr.sin_port); add_assoc_long(zserver, "REMOTE_PORT", ntohs(conn->addr.sin_port)); add_assoc_string(zserver, "REMOTE_ADDR", inet_ntoa(conn->addr.sin_addr), 1); if (client->request.version == 101) { add_assoc_string(zserver, "SERVER_PROTOCOL", "HTTP/1.1", 1); } else { add_assoc_string(zserver, "SERVER_PROTOCOL", "HTTP/1.0", 1); } add_assoc_string(zserver, "SERVER_SOFTWARE", SW_HTTP_SERVER_SOFTWARE, 1); add_assoc_string(zserver, "GATEWAY_INTERFACE", SW_HTTP_SERVER_SOFTWARE, 1); // ZEND_SET_SYMBOL(&EG(symbol_table), "_SERVER", zserver); zval *zresponse; MAKE_STD_ZVAL(zresponse); object_init_ex(zresponse, swoole_http_response_class_entry_ptr); //socket fd zend_update_property_long(swoole_http_response_class_entry_ptr, zresponse, ZEND_STRL("fd"), client->fd TSRMLS_CC); client->zresponse = zresponse; args[0] = &zrequest; args[1] = &zresponse; int called = 0; if(conn->websocket_status == WEBSOCKET_STATUS_CONNECTION) { called = 2; } if (call_user_function_ex(EG(function_table), NULL, php_sw_http_server_callbacks[called], &retval, 2, args, 0, NULL TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "onRequest handler error"); } if (EG(exception)) { zend_exception_error(EG(exception), E_ERROR TSRMLS_CC); } if (retval) { zval_ptr_dtor(&retval); } swTrace("======call end======\n"); if(called == 2) { handshake_success(fd); } } return SW_OK; }